Commit Graph
50 Commits
Author SHA1 Message Date
OmikronApexandClaude Fable 5 bb0f79e0be fix(audio): user-stop latch - plugin keep-alives can no longer undo a user stop
Field finding (fix14 test build): nam_tone's 1.5s keep-alive watchdog
calls raw startAudio whenever the engine is not running, restarting it
seconds after the user pressed Stop - and the shim treated any raw start
as user authority, resuming all suspended demands with it.

Per plan 8.3 (user stop always wins) raw start/stop was supposed to be
device-screen-only; now enforced:
- audio:userStartAudio / audio:userStopAudio: explicit user authority.
  Stop sets a latch (+ suspends demands); start clears it (+ resumes).
- raw audio:startAudio is SUPPRESSED while latched (log-once telemetry
  'suppressed-by-user-stop') and no longer resumes demands.
- raw audio:stopAudio no longer suspends demands (it is the transient
  stop the device-apply flow and unmigrated plugins use).
- fresh capture demands born during the latch start suspended, so the
  user start resumes them like pre-existing ones; the demand glue also
  refuses to start the engine while latched.
- device screen (src/renderer/screen.js) toggle + apply flows use the
  user-authority calls.

Contract snapshots regenerated (2 IPC channels, 2 preload keys).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 01:08:52 +02:00
OmikronApexandClaude Fable 5 668aff98fe fix(audio): add missing using-declarations for the mixer bindings
NodeAddon.cpp imports each addon-namespace binding explicitly; the mixer
exports compiled in DeviceBindings but were undeclared at the export
table. Full MSVC build:audio now green; addon-exports snapshot
regenerated (7 new exports).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:35:38 +02:00
OmikronApexandClaude Fable 5 a5ab8c27c7 feat(audio): mixer bridge — tiered audio.mixer.* surface, reap, diag heuristic
Phase B JS half (plan §5.1/§8):
- mixer-bridge.ts: tier-3 producer handles bound to the requesting
  webContents (no handle, no writes; holder death releases channels),
  tier-2 gain/mute open to any caller (fader belongs to the user, native
  clamps), gain persistence keyed holderId+label (§8.8), idle reap of
  silent unfilled channels (§8.9), double-audio log-once heuristic +
  channel-diagnostic event (§8.6), channel-added/removed/changed events.
- audio-bridge.ts: audio:mixer:* IPC channels; preload: audio.mixer.*.
- contract snapshots regenerated deliberately (7 channels, 1 preload key).
- tests: mixer-bridge suite (9) with fake native mixer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:30:44 +02:00
OmikronApexandClaude Fable 5 b51f88a574 feat(audio): engine-owned Mixer — RendererBus generalized to N channels
Phase B core (plan §5/§8):
- engine/Mixer.h: lock-free slot state machine (Free→Active→Draining→Free),
  channel #0 = the RendererBus byte-compatible permanent default, lazy
  ~512KB ring allocation per claimed slot (high-water, never freed under a
  live audio thread), per-channel gain/mute with block ramps (click-free),
  fade-to-silence reclaim (§5), hard cap 24 with no-capacity refusal
  (§8.9), group start gates at block granularity (§8.13), native gain
  clamp via sanitizeStreamGain (§5.1 tier 2).
- AudioEngine: mixer replaces the bare rendererBus member;
  setRendererBus/pushRendererAudio/getRendererBusMetrics delegate to
  channel #0 unchanged; pullRendererBus now mixes all ready channels
  (duplex + split paths and the StreamSink submix carry every channel).
- N-API: mixerCreateChannel/Release/Push/SetGain/SetMute/SetGroup/List.
- tests/engine_units/mixer_test.cpp: byte-compat vs plain RendererBus,
  cap refusal, live-consumer fade-then-free, ramp clamps, group gate,
  bounded strings. renderer_bus_test still green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:27:08 +02:00
OmikronApexandClaude Fable 5 5ecf55cb0c feat(audio): wire lease registry into IPC — leases surface, demand glue, legacy telemetry
Phase A wiring (plan §6.8/§8/§9):
- lease-bridge.ts: holder identity derived from the IPC sender (compound
  identity — enforced wc id + attributed tag), webContents destroy →
  death invalidation, main-frame navigation → reload grace window,
  capture demand drives startAudio/stopAudio, detection demand drives
  setNoteDetectionEnabled.
- audio-bridge.ts: audio:leases:* channels; raw startAudio/stopAudio now
  resume/suspend demands (user authority, §8.3); raw detection disarm is
  ignored while a demand holder still needs it armed (fixes 6.3's
  last-disarmer-kills-concurrent-consumer); log-once legacy telemetry.
- preload: audio.leases.* (acquire/release/takeover/getHolder/
  acquireDemand/releaseDemand/snapshot/onEvent).
- contract snapshots regenerated deliberately (7 IPC channels, 1 preload key).
- tests: lease-bridge suite (9) incl. death matrix destroy/reload paths;
  _load-ts gains a .ts require hook for cross-module TS imports.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:13:16 +02:00
OmikronApexandClaude Fable 5 f5276b787c feat(audio): lease registry — exclusive leases + refcounted demands
Phase A of docs/audio-ownership-plan.md: scopes, refusal-by-default,
drain-then-grant takeover (§8.1), reload grace window (§8.2), user-stop
suspend semantics (§8.3), well-known internal holders (§8.4), layered
base+override values (§8.10), snapshot with holder ages (§8.7).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:05:51 +02:00
OmikronApexandClaude Fable 5 8da14b598a docs(audio): ownership & mixer plan — leases, routes, engine-owned mixer
Reviewed 2026-07-14: 14 decisions in §8, capability-pipeline
integration + compound holder identity in §9.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:03:05 +02:00
OmikronApexandClaude Fable 5 1ba9b59e8a fix(audio): validate LoadPreset arg before arming the rebuild barrier
PR #107 round-2 review: beginChainRebuild() ran before
info[0].As<Napi::String>(), so a non-string argument threw between begin
and the worker taking ownership — leaking the barrier and blocking editor
opens permanently. Validate + read the argument first; the barrier is now
armed only on a path where every exit releases it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 12:16:22 +02:00
OmikronApexandClaude Fable 5 ea8c6a9ccd fix(audio): address PR #107 review — close serializer gaps, editor lifetime races, dispatch failures
All 8 CodeRabbit findings verified against the code and fixed:

- ChainOps: macOS LoadVST routes its addProcessor through chainMutationMutex
  (macOS is a first-class platform; deadlock-safe — a worker holding the
  mutex never waits on the Node/main thread there). All four single-slot
  workers (LoadVST/NAM/IR/ReplaceIR) now bump chainGeneration so the
  executor's foreign-write detection sees direct loads, not just presets.
- Rebuild barrier (beginChainRebuild/endChainRebuild): LoadPreset and
  ClearChain arm it before editor teardown; OpenPluginEditor refuses to
  open while a teardown+clear/rebuild is pending (#56 window between
  closeAllPluginEditorWindows returning and the worker taking the mutex).
- EditorWindows: all slot/processor resolution in editor lambdas runs under
  a try_lock of chainMutationMutex (try_lock, never blocking — workers
  holding the mutex block-wait on the message thread). Sandbox promotion
  bumps chainGeneration. editorWindows map is now message-thread-only
  (duplicate-window check and close-erase moved into the queued lambdas).
  Null slot->processor recheck after a faulted promotion capture.
- closeAllPluginEditorWindows returns false on refused post / 15s timeout;
  ClearChain skips the clear and LoadPreset resolves {success:false}
  instead of freeing processors under a live editor.
- AddonContext: dispatchOnMessageThread reports refused-post/timeout;
  doShutdown leaves the message thread running when teardown didn't
  complete instead of unloading mid-destruction.
- RendererBus::push rejects NaN/Inf/non-positive rates and a step that
  underflows to zero; new testRejectsUnusableRates unit case.

Verified: addon builds clean, all 78 JS tests pass (storm, contracts,
executor, N-API fuzz), all 5 engine_units native tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 11:56:08 +02:00
OmikronApexandClaude Fable 5 d887c68014 docs: commit the audio-engine TLC findings + plan this branch implements
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 03:24:46 +02:00
OmikronApexandClaude Fable 5 48d7e68a91 test: fix two Windows-environment-dependent failures (suite now fully green)
Both tests pre-dated this branch and failed only on Windows checkouts — the
product code was correct in both cases:

- audio-effects-executor 'preload exposes the trusted surface': asserted a
  byte-exact two-line bridge snippet with \n, which never matches a
  core.autocrlf (CRLF) working tree. Line endings are now normalized before
  the includes checks.

- config-paths 'SAFETY: ... ONLY in optInExtras': rebuilt the expected ML
  cache paths with host-native path.join, producing backslash paths that
  never equal the forward-slash simulated envs — failing the mlCaches
  equality and, worse, making the protected-root child checks vacuously
  pass on Windows (a silent coverage gap in the safety assertions). The
  test now uses the envs' resolved torchHome/hfHome fields, exactly what
  production returns, with '/' as the child separator.

npm test: 78/78 passing (1 quarantined storm gate, green under CHAIN_STORM=1).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 03:18:33 +02:00
OmikronApexandClaude Fable 5 9d0963d6d5 feat(audio): getLatencyBreakdown — one owner for every latency term
Deep-read §5: latency had three unreconciled truths — getLatencyMs' static
half-capacity ring guess (42.7 ms), the verifier's input-delta-only offset,
and the renderer bus adding prime+fill+resample that no figure surfaced.

New engine API + export: per-term breakdown (deviceBufferMs, input/output
driver latency, MEASURED split-ring residency, monitor total) plus the
renderer-bus song-audio delay (measured bus fill) as its own term. On the
user's split exclusive setup the measured ring sits at ~10 ms — the legacy
figure overstated monitor latency by ~33 ms (102.7 reported vs ~70 real).

getLatencyMs is unchanged for compatibility; UI adoption of the breakdown
is renderer follow-up. Snapshots regenerated (104 exports).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 03:05:19 +02:00
OmikronApexandClaude Fable 5 f0340ed425 fix(audio-engine): single persistence store for device settings (TLC Part II §4)
The device config was persisted in TWO stores — the main process's
file-backed settings AND localStorage['slopsmith-audio-device'] — merged on
load by newest-savedAt. A main-side migration/reset left stale localStorage
that could win the timestamp race and resurrect wiped settings, and a device
re-save from either path re-persisted mute flags captured at that moment,
interleaving with the (now-arbitrated) runtime mute writers.

The file store is now the only write target. localStorage is treated as a
one-time migration source: a strictly-newer browser copy is imported into
the file store, then the key is deleted either way — after the first load
the file is the single source of truth.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 03:02:18 +02:00
OmikronApexandClaude Fable 5 88f881dd1e fix(audio): refcounted monitor-mute arbiter (TLC Part II §2)
The old single monitorMuted atomic had five writers fighting
last-writer-wins: the settings checkbox, startup restore, the executor's
preload read-force-restore, releaseRoute's unconditional setMonitorMute(true)
(which clobbered the user's persisted preference), and the renderer's
song-load suppression (un-refcounted — overlapping windows un-suppressed
each other early).

Native arbiter on SourceChain: userMonitorMute (the preference — checkbox +
restore only), refcounted monitorMuteHolds (force-mute overrides), and
refcounted suppressions (setMonitorMuteSuppressed keeps its bool surface;
true=acquire, false=release, clamped at 0). Effective dry-mute =
(holds || pref) && chain empty && no suppression — the suppressed-beats-muted
precedence is unchanged. New exports: acquire/releaseMonitorMuteHold,
getMonitorMuteState (diag); snapshots regenerated.

Executor rewrite: acquires a suppression (dry-during-load, the default) or a
hold, and releases exactly what it acquired via a single-fire closure that
runs UNCONDITIONALLY (each load owns its acquisition — the stale-snapshot
race against a mid-hold user toggle is structurally gone). releaseRoute no
longer touches mute state at all. The ownership test now pins: preference
API never called, acquire/release balanced.

Renderer callers are unchanged: the checkbox writes the preference as
before, and the song-load suppression sites now compose instead of racing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 03:01:09 +02:00
OmikronApexandClaude Fable 5 2906d2814b refactor(audio): split N-API bindings into grouped files (phase 7b complete)
Splits the remaining 88 handlers out of NodeAddon.cpp, grouped to match the
preload API sections (plan §3.5): DeviceBindings (enumeration/selection/
audio-control/stream sink), ControlBindings (gain/metering/MIDI/debug
logging), DetectionBindings (pitch/chart/verdict/source-indexed, owns the
shared getValidatedSource), ChainBindings (slot/state/preset), and
BackingBindings. Declarations live in addon/Bindings.h; NodeAddon.cpp keeps
Init/Shutdown and the exports table — which now doubles as the API index the
old 3699-line file lacked — at 459 lines.

This completes the Part IV decomposition: AudioEngine.{h,cpp} 819+3223 →
509+1284 across seven engine/ units; NodeAddon.cpp 3699 → 459 across seven
addon/ units. All gates green (contract-check, storm, arg-fuzz, full suite).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 02:33:24 +02:00
OmikronApexandClaude Fable 5 f473aad920 refactor(audio): move chain workers into ChainOps.cpp (phase 7b)
Moves the five chain-mutating async workers (LoadPreset/LoadVST/LoadNAM/
LoadIR/ReplaceIR), their N-API handlers, loadVstSandboxAware, and the shared
load helpers (decodeStateBlob, loadSafeSampleRate/BlockSize) verbatim into
src/audio/addon/ChainOps.cpp — joining the phase-7a serialization primitives
in their planned home (§3.3). NodeAddon keeps using-declarations; the export
table is unchanged. Storm and arg-fuzz gates stay green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 02:29:16 +02:00
OmikronApexandClaude Fable 5 95b32ba160 refactor(audio): extract EditorWindows (phase 7b)
Moves the in-process plugin editor cluster — PluginEditorWindow, the
slotId→window map, the message-thread teardown pair (closeAll / destroyAll,
the #56 use-after-free guards), OpenPluginEditor with the full Windows
sandbox-promotion flow, and ClosePluginEditor — verbatim into
src/audio/addon/EditorWindows.{h,cpp}. NodeAddon keeps using-declarations;
the export table and ClearChain/LoadPreset teardown calls are unchanged.

The two bindings pick up NapiHelpers slot-id validation while moving (the
same deep-read §2 fix the other bindings got in phase 6 — a NaN slot id
used to coerce to slot 0 and open/close the wrong editor).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 02:23:09 +02:00
OmikronApexandClaude Fable 5 7b72907503 fix(audio-effects): executor detects foreign chain writes via chainGeneration
The JS half of the phase-7a serializer (TLC Part II §1, executor-state
hazard): the executor's stageSlots map (stageId → native slotId) is built at
load time, but any direct loadPreset/clearChain from the audio_engine bundle
or rig_builder's legacy path silently invalidated it — subsequent
setStageBypass/setStageParameter/activateSegment flipped bypass/params on
the WRONG slots or returned no-target with nothing detecting the divergence.

Now: the route records the chainGeneration its load returned; every stage
operation compares it against getChainGeneration() first and reports a
stale-route no-target ('re-load the plan', with expected/current generations)
instead of mutating someone else's chain. loadChainPlan also verifies the
generation didn't move between its loadPreset and the getChainState slot
mapping, rolling back if a foreign write landed in that window. Old addons
without the counter degrade gracefully (checks no-op).

Pinned by a new executor test: fresh route flows, foreign bump → all three
stage ops refuse without touching native slots.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 02:19:42 +02:00
OmikronApexandClaude Fable 5 dd40b2f227 fix(audio): renderer-bus flush flag + reconfigure reads user intent (phase 8)
Two deep-read fixes now homed in their phase-1/2 units:

RendererBus (§4): setEnabled(false) no longer writes readIndex from the
control thread — the ring's designated consumer-side writer is pull(). The
drop-on-disable is now a flushRequested atomic the consumer honors at its
next pull, closing the last SPSC-discipline hole (a concurrent pull
mid-drain could overwrite the control thread's store and replay a stale
tail after re-enable). New unit test pins flush-then-fresh-audio.

setAudioDevices (§3): the restart decision reads state.userWantsAudio
(intent, written only by start/stopAudio) instead of the racy device-state
flag that transient audioDeviceStopped() fires clear — a reconfigure landing
inside a transient-stop window no longer leaves the engine configured but
stopped ('no audio until Start/Apply is pressed again').

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 01:47:32 +02:00
OmikronApexandClaude Fable 5 db337eaf29 fix(audio): serialize chain mutations + chainGeneration (phase 7a)
The single highest-value fix of the TLC pass (deep-read §1): one native
chain-mutation mutex (addon/ChainOps) held across the FULL Execute() of
every chain worker (LoadPreset/LoadVST/LoadNAM/LoadIR/ReplaceIR) and the
synchronous mutators (clearChain/removeProcessor/moveProcessor). Two
overlapping loadPreset calls can no longer interleave clear()/addProcessor()
into a merged-garbage chain — the plugin-vs-plugin fight becomes
last-writer-wins.

chainGeneration (monotonic, bumped under the mutex) is returned in loadPreset
results and exposed as getChainGeneration (new export, snapshot regenerated),
so the audio-effects executor can detect a foreign write invalidated its
stageSlots map and re-sync instead of flipping bypass/params on wrong slots —
the prerequisite for the single-chain-owner ownership track.

Also rides here: LoadPresetWorker's slot-state restore goes through
setSlotState() instead of const_cast (deep-read §9).

The phase-0 storm test flips from expected-fail to a hard gate: 50 iterations
of concurrent loadPreset now always end with exactly one caller's chain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 01:45:01 +02:00
OmikronApexandClaude Fable 5 d4e0bfc272 refactor(audio): extract AddonContext + NapiHelpers, guard raw N-API args (phase 6)
AddonContext (src/audio/addon/): engine/vstHost lifetime + snapshot rule,
the JUCE message thread with the macOS no-pump fork quarantined into ONE
file, the shutdown latch (exposed as isShuttingDown), doShutdown with a UI
teardown hook (NodeAddon points it at the editor-window nuke, #56), and the
pending-async-load registry. NodeAddon keeps using-declarations so the
binding bodies are unchanged. Also fixes SetBackingSpeed's bare `engine`
dereference — the one binding that dodged the file's own snapshot rule.

NapiHelpers (typed extractors argInt/argSlotId/argFiniteFloat/argBool/
argMidiChannel/argMidiByte) + rewrites of the unguarded bindings — the
deep-read §2 fix, done once: SetParameter/SetBypass/RemoveProcessor/
MoveProcessor/SetMultiBypass/SendMidiToSlot/SetGain plus the St-1 routing
quartet (SetPan/SetPostGain/SetBranch/SetBranchSrc). NaN slot ids no longer
coerce to slot 0; MIDI channel/program are range-checked before JUCE.

New gate: tests/napi-arg-fuzz.test.js — table-driven garbage (NaN/Inf/
negative/string/missing/object) against the real addon; chain state must be
byte-identical after the storm and a valid call must still apply.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 01:41:07 +02:00
OmikronApexandClaude Fable 5 6b0bfb7be3 refactor(audio): extract ExtraInputs (phase 5b)
Moves the additional-input-device registry — InputDeviceSlot (manager,
callback, ring, scratches, latency delta, desired-name intent,
permanent-unbind flag), bind/unbind/closeSlot/reopenDesired, the bindable
enumeration, and the per-slot device-callback trio — verbatim into
src/audio/engine/ExtraInputs.{h,cpp}. Sources are prepared/released through
the bound SourcePool (same locking as before); the primary manager reference
serves the duplicate-binding check, latency delta, and enumeration. The
slots array stays public so the split output callback's ring-drain loop is
unchanged; addSource resolves per-slot readiness via resolveForSource().

The (typeName, name) device-identity limitation moves with its honest
comment — its fix lands here later without touching the engine again
(plan §2.3). Completes phase 5; live 28-stage split-mode probe on real
devices behaves identically to pre-move.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 01:29:16 +02:00
OmikronApexandClaude Fable 5 827f02b4b4 refactor(audio): extract SourcePool (phase 5a)
Moves the fixed SourceChain pool, add/remove/reclaim lifecycle, the
per-deviceKey callbacksInFlight quiescence handshake, deferred-release
parking, and mixSourcesForDevice verbatim into
src/audio/engine/SourcePool.{h,cpp}. Device callbacks now hold an RAII
CallbackGuard (identical increment/decrement points — no early returns
existed between them) and call pool.mixForDevice(); the device hooks use
prepare/releaseDeviceSources and withDeviceSources, preserving each site's
original locking (the primary about-to-start prepare loop stays deliberately
lockless, as before).

addSource's extra-device resolution (registry reads) stays on the engine
facade, which passes resolved readiness/format/latency into
pool.addResolved() — the pool has no dependency on the InputDeviceSlot
registry, which phase 5b extracts next.

Threaded storm unit test deferred (SourceChain is JUCE-linked; TSAN
unavailable on MSVC) — multi-source.test.js covers the pool through the
addon and is green against the rebuilt binary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 01:23:55 +02:00
OmikronApexandClaude Fable 5 6ace5a209a refactor(audio): extract DeviceSetup + shared rate-match helpers (phase 4)
Moves probeDeviceOptionsDual, applyDuplexSetup, applySplitSetup, and
teardownSplitMode verbatim into src/audio/engine/DeviceSetup.{h,cpp}. The
component holds references to the two device managers + EngineState and owns
no lifetime; engine-owned collaborators (monitor chain, split output ring +
counters, output callback registration) are passed by reference per call.
setAudioDevices stays on the facade as the orchestrator. The public
DeviceOptions/DeviceConfig/DeviceConfigResult shapes move to the slopsmith
namespace with using-aliases on AudioEngine, so the NodeAddon spelling is
unchanged.

Lands the deep-read §7 dedupe structurally: the <=0.5 rate tolerance,
midpoint-rounding fail-closed candidate, and empty-name→first-enumerated
resolution now exist once (RateMatch.h — JUCE-free + unit-tested boundary
cases — and DeviceSetup::resolveDeviceName/rateSupportedBy) instead of three
hand-synced copies.

Full device-matrix validation (WASAPI shared/exclusive, ASIO, dual-type
split) rides the next tester build per the plan's phase-4 gate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 00:27:51 +02:00
OmikronApexandClaude Fable 5 d8f5784c63 refactor(audio): extract BackingPlayer (phase 3)
Moves the backing-track cluster — AudioFormatManager/reader/transport,
TimeSliceThread read-ahead, signalsmith-stretch state, lock-free speed
hand-off, BackingLeveler, playhead caches, and renderBackingBlockLocked —
verbatim into src/audio/engine/BackingPlayer.{h,cpp}.

Boundary per the plan (§2.4): control-thread lifecycle + non-blocking
getters live on the class; the RT mix POLICY (try-lock pattern, RMS
metering, volume fader, stream-submix capture) stays in the engine's output
callbacks via getLock()/readyLocked()/renderBlockLocked()/renderBuffer() —
both callbacks keep holding the try-lock through their stream publish, so
the render buffer is never read while prepare() can resize it. The volume
fader atomic and level meter stay engine-side.

Synthetic-reader unit tests deferred (JUCE-linked, same constraint as
StreamSink); covered by the backing play/seek/speed integration surface.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 00:19:53 +02:00
OmikronApexandClaude Fable 5 797501e5ff refactor(audio): extract StreamSink (phase 2)
Promotes the streamer-mix output sink to a class owning its
AudioDeviceManager, drain callback, ring, scratches, submix compose
(publish, was composeAndPushStreamMix), and open/close/clear/reopen
lifecycle — moved verbatim into src/audio/engine/StreamSink.{h,cpp}. Bus
flags (includeBacking/includeGuitar/gain) and the level meter move in;
engine sample rate / output block size are read through the bound
EngineState&. AudioEngine keeps thin facades so the NodeAddon surface is
unchanged; the guitar-snapshot scratch stays on the engine (it snapshots
the engine's own mix).

Compose-matrix unit tests are deferred: they need juce::AudioBuffer, which
the JUCE-free engine_units harness doesn't link — covered meanwhile by the
stream under/overflow counters + level meter over IPC and the OBS-capture
manual smoke.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:53:27 +02:00
OmikronApexandClaude Fable 5 70f3316094 refactor(audio): extract RendererBus (phase 2)
Moves the WebAudio→engine bus — ring, producer-side linear resampler,
prefill gate, fill clamp, metrics — verbatim into
src/audio/engine/RendererBus.h. AudioEngine keeps thin facades
(setRendererBus/pushRendererAudio/pullRendererBus/getRendererBusMetrics) so
the NodeAddon surface is unchanged. JUCE-free: pull() takes raw channel
pointers, which is what lets tests/engine_units drive the resampler
continuity, prime/underflow/clamp, and metrics cases without a device.

The control-thread readIndex write on disable (deep-read §4) is preserved
verbatim and marked; its flush-flag fix lands as the phase-8 commit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:46:55 +02:00
OmikronApexandClaude Fable 5 eb40b87dea refactor(audio): extract EngineState with intent/state split (phase 1)
Moves the shared run-state atomics (currentSampleRate, block sizes,
duplexMode, run flags) into slopsmith::EngineState (src/audio/engine/) so
later extracted units take EngineState& and stay unit-testable without JUCE
devices. AudioEngine binds the members back by reference under their
historical names — zero call-site churn, behavior-identical.

The old audioRunning conflated user intent with device state (deep-read
§3/§6); it is now state.deviceRunning (same semantics, isAudioRunning compat
pinned) plus a new state.userWantsAudio written only by startAudio/stopAudio.
Nothing reads the intent flag yet — phase 8 flips setAudioDevices' restart
decision onto it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:42:29 +02:00
OmikronApexandClaude Fable 5 eeb83cbdbc refactor(audio): extract PackedStereoRing — one SPSC ring template (phase 1)
Replaces the four hand-maintained copies of the packed-LR SPSC design
(split-mode output ring, per-InputDeviceSlot rings, stream-sink ring,
renderer-bus ring) with slopsmith::PackedStereoRing<NFrames>
(src/audio/engine/PackedStereoRing.h). The template owns the storage,
power-of-two/lock-free asserts, pack/unpack, producer publish, reset, the
w<r resync, and the lapped catch-up; per-site consumer policy (pull-vs-
consume skew, renderer prime/fill-clamp) stays verbatim at the call sites.

Pure code move per the TLC plan — no behavior change; the renderer bus's
control-thread readIndex write on disable (deep-read §4) is deliberately
preserved and gets its flush-flag fix in phase 2.

Unit-tested in tests/engine_units/packed_stereo_ring_test.cpp: threaded
tear-freedom under lapping (2M frames), drop-oldest catch-up, index-reset
resync, pull-vs-consume skew.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:38:56 +02:00
OmikronApexandClaude Fable 5 3e449c0318 test(audio): quarantined chain-mutation storm test (expected-fail)
Documents TLC deep-read §1: concurrent loadPreset workers interleave
clear()/addProcessor() and merge both presets — reproduces first iteration
([storm-ir-1-0, storm-ir-2-0, storm-ir-2-1]). Quarantined behind
CHAIN_STORM=1; flips to a hard gate when ChainOps lands the serializer
(plan phase 7).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:28:34 +02:00
OmikronApexandClaude Fable 5 3c8dd62ecb fix(audio): sanitize input/chain/output/backing gains at the engine setters
NaN/Inf from any JS caller (audio:setGain does no validation) previously
reached the gain atomics raw; a NaN master gain multiplies the whole device
output to NaN and poisons the peak meters (TLC deep-read §2). Clamp at the
four setters — the single choke point covering the legacy facade, the
source-indexed API, and the audio-effects executor.

Bounds 0..32 match the executor's clampGain (Phase 0.b compat pin); stream/
renderer-bus keep their historical 0..8 via the same JUCE-free helper, now
testable in the new tests/engine_units target (Phase 0.c harness).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:28:34 +02:00
OmikronApexandClaude Fable 5 bbb3b58db8 test(contracts): Phase 0.a contract snapshots for audio surface
Snapshot the three public surfaces the audio-engine decomposition must not
change (docs/audio-engine-tlc.md Part IV §4): addon export table, audio-bridge
IPC channels, preload audio/audioEffects API keys. contract-check.test.js
diffs regenerated surfaces against the committed snapshots.

result-shapes.json (golden result key/type shapes) is deferred until the
engine_units harness can run the addon against a null device.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:21:21 +02:00
OmikronApexandClaude Fable 5 fcce4672d9 feat(build): bundle bongocat plugin
Add got-feedback/feedback-plugin-bongocat to the clone_slopsmith plugin
list so CI/release builds ship Bongo Cat's Rhythm Trainer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 22:01:52 +02:00
OmikronApexandClaude Fable 5 ec6a84c3c8 fix(nightly): dedupe publish assets across overlapping globs
The artifacts/**/*.zip glob overlaps artifacts/**/velopack/**/*, so a
zip inside a velopack dir would be uploaded twice and fail the release
create. Track seen paths and append each file once.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 23:09:11 +02:00
OmikronApexandClaude Fable 5 a56ef7828c fix(nightly): suppress Velopack Portable.zip on macOS too
The mac vpk pack emitted feedback-osx-arm64-nightly-Portable.zip
alongside the manual tester zip — same duplication as Windows. Updates
use the -full.nupkg feed, so the portable zip is redundant.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 22:54:50 +02:00
OmikronApexandClaude Fable 5 970bd5068e fix(nightly): ship a single portable zip on Windows
vpk pack emitted a Portable.zip (Update.exe stub wrapping win-unpacked)
alongside the plain feedback-windows-x64.zip, so testers saw two
different portable downloads. Pass --noPortable to suppress it and add
artifacts/**/*.zip to the publish globs so the plain zip (and the macOS
tester zip) land on the rolling nightly release instead of only in
workflow artifacts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 22:51:35 +02:00
OmikronApexandClaude Fable 5 bcbb0e329e fix(main): allow getDisplayMedia through the media permission handler
getDisplayMedia (renderer-bus whole-app loopback capture) rides the
'media' permission request with EMPTY mediaTypes. The audio-only rule
denied it, so the display-media handler never ran and exclusive/ASIO
output lost all page audio (song previews, element-song fallback).

Allow media requests unless they explicitly ask for 'video' (camera
stays blocked; getDisplayMedia video is the app's own frame), mirror
the policy in the permission-check handler, and add [asio-diag] logs
to every deny path plus the display-media handler so future denials
name their stage in tester logs.

Verified packaged: display-media granted → renderer-bus engaged,
engine busEnabled/busFlowing=true on ASIO.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 01:44:06 +02:00
OmikronApexandClaude Fable 5 d069414300 fix(diag): compute busFlowing from per-poll counter deltas
Cumulative pushed/consumed never regress, so '> 0' stayed true forever
after the first frame — a stalled renderer bus (one of the states this
diagnostic exists to expose) would still report flowing. First sample
after enable reports false (no baseline yet).

Addresses CodeRabbit review on #95.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 00:18:10 +02:00
OmikronApexandClaude Fable 5 ee7abe3dc9 feat(diag): --debug ASIO routing diagnostics ([asio-diag])
Testers report song/game audio on the default WASAPI device while the
guitar rides the selected ASIO output. The renderer-side reroute chain
([feedpak-route]/[renderer-bus]) has change-gated logs, but the native
side of the story (what the engine actually opened, whether the backing
transport/renderer bus is live) was invisible in tester logs.

- audio-bridge: debug-gated 2s engine snapshot, change-gated + 30s
  heartbeat: device types/names, duplex, backing, renderer-bus health
- debug:isEnabled IPC + preload audio.debugEnabled() so the static
  bundle can gate its verbose lines on --debug

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 00:08:33 +02:00
OmikronApexandClaude Fable 5 09617aa417 fix(bundle): copy all top-level core python packages (routers/ etc.)
core#834 extracted routes into a new top-level routers/ package; the
bundle script only copied lib/, so the packaged backend would die with
ModuleNotFoundError: No module named 'routers'. Copy every top-level
package (dir with __init__.py) except plugins/ (bundled selectively
below) and tests/ (never ships), so the ongoing R3 extraction series
can't keep breaking packaged builds.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 16:47:32 +02:00
OmikronApexandClaude Fable 5 add4facb85 fix(bundle): copy all top-level core .py modules, not just server.py
Core added appstate.py (core#833); bundle-slopsmith.sh's whitelist only
copied server.py, so packaged builds crashed on startup with
ModuleNotFoundError: No module named 'appstate'. Glob top-level *.py so
future sibling modules can't repeat this.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 16:22:05 +02:00
OmikronApexandClaude Fable 5 83b8b66fe7 fix(ci): rename entitlements file — vpk requires .entitlements extension
Nightly run 29093119570 failed:
  --signEntitlements does not have an .entitlements extension
vpk validates the file extension. Rename
resources/entitlements.mac.plist -> entitlements.mac.entitlements
and update all references (electron-builder config, sign-macos-binaries.sh,
both workflows). Content unchanged; codesign/electron-builder accept any
extension.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 15:04:31 +02:00
OmikronApexandClaude Fable 5 1046b71f34 fix(ci): anchor --signEntitlements path with $PWD
vpk signing docs recommend absolute paths; relative path breaks if vpk
changes cwd internally. CodeRabbit review nit on #93.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 14:18:47 +02:00
OmikronApexandClaude Fable 5 077309cf00 fix(build): preserve mac entitlements through Velopack re-sign
Same gap as nightly.yml: vpk pack --signAppIdentity without
--signEntitlements strips electron-builder's entitlements
(audio-input, allow-jit, ...) from the release feed's .app.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 14:04:45 +02:00
OmikronApexandClaude Fable 5 782aea76f9 fix(nightly): preserve mac entitlements through Velopack re-sign
vpk pack re-signs the .app; without --signEntitlements the codesign
strips electron-builder's entitlements (com.apple.security.device.audio-input
et al). Hardened-runtime app then gets microphone auto-denied by TCC with
no prompt — root cause of silent-input nightly reports.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 14:03:15 +02:00
OmikronApexandClaude 0645ce724d fix(mac): add diagnostic logging to ensureMicrophoneAccess TCC flow
Every decision point in the macOS microphone permission path now logs its
status and context to the debug log, including the previously silent
'granted' early-return path — which is the prime suspect for the stale-
grant bug (TCC reports 'granted' for a signature-keyed entry that no
longer matches the running binary).

Also logs:
- platform gate skip
- app.isPackaged === false skip (and why it matters re: NSMicrophoneUsageDescription)
- getMediaAccessStatus return value in all branches
- app identity (name, version, exe path) on 'granted' early return
- askForMediaAccess result + extra warning on user denial
- full error stack on exceptions (not just the message)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-09 23:54:20 +02:00
OmikronApexandClaude Fable 5 f3c14271cc chore(plugin-manager): rebrand UI strings from Slopsmith to fee[dB]ack
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 09:22:46 +02:00
OmikronApexandClaude Fable 5 524c2e0dca chore(build): stop bundling feedback-plugin-setlist
Playlists are integrated into the core app, so the setlist plugin is
obsolete and its repo is being archived.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:17:54 +02:00
OmikronApex 371a4fb36b ci(build): stop full matrix on pushes to main
ship-ci.yml covers checks and nightly.yml builds main daily; the
3-platform matrix only needs to run on tags and manual dispatch.
2026-07-03 18:02:31 +02:00
OmikronApexandClaude Fable 5 1df4c753d9 ci(nightly): fix macOS/Windows packaging broken by fee[dB]ack rename
nightly.yml still globbed for the old Slopsmith.app bundle name and
failed every night. Find the .app dynamically (name-agnostic *.app glob
- the new name contains [dB], which a shell glob reads as a character
class) and derive zip names from the bundle, matching the fix already
on main in rc.yml/build.yml. Also refresh stale Slopsmith comments in
build.yml.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 17:33:46 +02:00