From 055313598bc3b23201694de815f40bd5c582f4bd Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 2 Nov 2026 23:12:14 +0700 Subject: [PATCH 1/6] fix(engine): M1 sample-continuous fader, offline AUX parity, bounded graph retirement tests --- ...M1_REALTIME_CORE_STABILIZATION_20261102.md | 11 +++++ engine/core/PreparedMixerBlock.h | 36 ++++++++++----- tests/mixer_routing_plan_test.cpp | 45 +++++++++++++++++++ tests/realtime_control_test.cpp | 37 +++++++++++++++ 4 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 docs/M1_REALTIME_CORE_STABILIZATION_20261102.md diff --git a/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md new file mode 100644 index 000000000..a1bd83fae --- /dev/null +++ b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md @@ -0,0 +1,11 @@ +# M1 — Realtime core stabilization (2026-11-02) + +**Stacked source**: ENGINE #266 at `40a059785993cc6a4bb593020bf9749de92746f9`. No competing DSP, native callback, GUI or worker per channel. + +This checkpoint repairs the Windows CTest AUX static/offline regression and corrects native fader/PAN de-zippering to remain **64 audio samples across variable callback frames** (4/16/32/12), including reverse direction. Existing live PRE/POST sends and AUX return faders retain their prepared 64-sample ramp; offline/no-live paths must not inherit old live AUX targets. All work uses fixed-size arrays and no new callback heap allocations. + +The existing `RealtimeRoutePublisher` owns bounded retirement. New tests hold a real leased reader across two graph publications, verify refusal when the queue is full, and verify all four prepared owners are reclaimed after the reader leaves. All tests run in the existing CTest executables with no additional CI matrix. + +**Runtime invariant:** `LiveAudioEngine::audioDeviceIOCallbackWithContext` is still M4 until the full CH1 external/Orbit owner, native vendor FX/editor/Show, physical input/output pins and monitor can migrate together. Never enable universal supportedOps or silently render the new graph alongside M4. Worker-only work belongs to existing control/Show-save processing, NOT the real-time callback. + +**Remaining M1 release gates:** pass exact-SHA Windows MSVC/CTest, integrate a single full-fidelity ChannelId callback with atomic admission and no FX loss, then qualify ASIO/WASAPI and zero-FX crackle on actual hardware. This change alone is **not M1 complete**, not UAT, not acoustic FAT. diff --git a/engine/core/PreparedMixerBlock.h b/engine/core/PreparedMixerBlock.h index 5bf6c2ec1..4b75cff29 100644 --- a/engine/core/PreparedMixerBlock.h +++ b/engine/core/PreparedMixerBlock.h @@ -450,6 +450,9 @@ class PreparedMixerBlock final { preRampRemaining_[strip]=0; lastGainL_[strip]=gl; lastGainR_[strip]=gr; + gainGoalL_[strip]=gl; + gainGoalR_[strip]=gr; + gainRampRemaining_[strip]=0; rampPrimed_[strip]=true; } // The MUTE/PRE-SEND de-click is 64 AUDIO SAMPLES, not one @@ -480,7 +483,7 @@ class PreparedMixerBlock final { // Once the message thread publishes a changed send target, // the SAME callback switches to one live PRE/POST processor // which follows 64-sample gains across varying block sizes. - if(auxAutomationActive_.load(std::memory_order_acquire)) + if(live && auxAutomationActive_.load(std::memory_order_acquire)) dispatchLiveAux(strip,SendTap::preFader,l,r,frames); else graph.aux.dispatch(strip,SendTap::preFader,l,r, auxLeft_.data(),auxRight_.data(),frames); @@ -495,14 +498,20 @@ class PreparedMixerBlock final { } } if(live) { - // A block-linear fader/PAN ramp avoids zipper clicks at the - // native callback rate. UI sends at most one target per rAF. - const int ramp=std::min(frames,64); - const float dL=(gl-lastGainL_[strip])/ramp; - const float dR=(gr-lastGainR_[strip])/ramp; + // Fader/PAN dezipper is 64 AUDIO SAMPLES, not one callback. + // Reversing the target restarts from the actual applied gain. + if(gl!=gainGoalL_[strip] || gr!=gainGoalR_[strip]) { + gainGoalL_[strip]=gl;gainGoalR_[strip]=gr; + gainRampRemaining_[strip]=64; + } float lv=lastGainL_[strip],rv=lastGainR_[strip]; + int gainRemaining=gainRampRemaining_[strip]; for(int f=0;f0) { + lv+=(gl-lv)/static_cast(gainRemaining); + rv+=(gr-rv)/static_cast(gainRemaining); + --gainRemaining; + } else {lv=gl;rv=gr;} l[f]*=lv;r[f]*=rv; if(monitorBusL) { const float gain=nextMonitorGain(strip); @@ -517,7 +526,8 @@ class PreparedMixerBlock final { masterL_[f]+=l[f];masterR_[f]+=r[f]; } } - lastGainL_[strip]=gl;lastGainR_[strip]=gr; + lastGainL_[strip]=lv;lastGainR_[strip]=rv; + gainRampRemaining_[strip]=gainRemaining; }else for(int f=0;f right_{}; std::array auxLeft_{},auxRight_{}; std::array preGate_{},preGateTarget_{}, - lastGainL_{},lastGainR_{}; - std::array preRampRemaining_{}; + lastGainL_{},lastGainR_{},gainGoalL_{},gainGoalR_{}; + std::array preRampRemaining_{},gainRampRemaining_{}; std::array,stripCount> physicalTarget_{}; std::array physicalBlend_{}; // OFF until any native SET_SEND_LEVEL. Audio callback reads only; diff --git a/tests/mixer_routing_plan_test.cpp b/tests/mixer_routing_plan_test.cpp index 19517fb1c..1a2832a8e 100644 --- a/tests/mixer_routing_plan_test.cpp +++ b/tests/mixer_routing_plan_test.cpp @@ -690,6 +690,50 @@ static void verifyLegacyToDynamicProductionPcmParity() { } + +static void verifyRealtimeFaderRampAcrossShortCallbacks() { + using namespace armix::mixer; + const std::array pins{0,1}; + ChannelRoutingConfig routing; + routing.stripsAndMaster.strips[0]= + {SourceMode::mono,0,-1,1.f,0.f,false,false}; + SendRequest sends; + sends.toMaster[0]=true; + PreparedRenderGraph graph; + RenderError error; + assert(PreparedRenderGraph::compile(routing,pins,sends,graph,error)); + PreparedMixerBlock block(graph,64); + RealtimeStripControls controls; + assert(controls.set(0,1.f,0.f,true,false,false)); + std::array mic{},unused{},left{},right{}; + mic.fill(.8f); + const float* sources[]={mic.data(),unused.data()}; + const auto noFx=[](int,float*,float*,int) noexcept {}; + const auto render=[&](int frames) { + left.fill(0.f);right.fill(0.f); + return block.process(sources,2,left.data(),right.data(),frames, + noFx,nullptr,&controls); + }; + assert(render(4)); + const float baseline=left[0]; + assert(baseline>.01f && close(right[3],baseline)); + assert(controls.set(0,0.f,0.f,true,false,false)); + assert(render(4)); + assert(close(left[3],baseline*60.f/64.f,3.e-5f)); + assert(render(16)); + assert(close(left[15],baseline*44.f/64.f,3.e-5f)); + assert(render(32)); + assert(close(left[31],baseline*12.f/64.f,3.e-5f)); + assert(render(12)); + assert(close(left[11],0.f,3.e-5f)); + // Mid-show fader reversal must not jump to the last requested target. + assert(controls.set(0,1.f,0.f,true,false,false)); + assert(render(4)); + assert(close(left[3],baseline*4.f/64.f,3.e-5f)); + assert(render(60)); + assert(close(left[59],baseline,3.e-5f)); +} + static void verifyRealtimeAuxPostGainWithoutGraphRebuild() { using namespace armix::mixer; const std::array pins{0,1}; @@ -969,6 +1013,7 @@ int main() { verifyDynamicChannelIdLiveControls(); verifyDynamicNativeSessionPublication(); verifyStudioConsoleBusBatchPcm(); + verifyRealtimeFaderRampAcrossShortCallbacks(); verifyRealtimeAuxMasterPcmBothOutputs(); verifyRealtimeAuxPostGainWithoutGraphRebuild(); verifyLegacyToDynamicProductionPcmParity(); diff --git a/tests/realtime_control_test.cpp b/tests/realtime_control_test.cpp index 0cb920ab9..91b288fdb 100644 --- a/tests/realtime_control_test.cpp +++ b/tests/realtime_control_test.cpp @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only #include "../engine/core/RealtimeControl.h" +#include "../engine/core/RealtimeRoutePublisher.h" +#include #include #ifdef NDEBUG #undef NDEBUG @@ -51,6 +53,41 @@ int main(){ checkPan(0.f,0.f,1.f,0.f,1.f); checkPan(0.f,1.f,0.f,1.f,0.f); std::cout<<"PASS: native stereo pan centre, extremes, half-pan and unit-gain dual-mono\n"; + + // M1: retired FX/PCM snapshots remain owned until callbacks release + // their leases; a full bounded queue rejects instead of growing memory. + struct RetireProbe { + std::atomic* counter; + explicit RetireProbe(std::atomic& c):counter(&c){} + ~RetireProbe(){counter->fetch_add(1,std::memory_order_relaxed);} + }; + std::atomic destroyed{0}; + RealtimeRoutePublisher publisher; + const auto publish=[&](std::uint64_t revision) { + auto next=std::make_unique::Snapshot>(); + next->deviceEpoch=7;next->graphRevision=revision; + next->prepared=std::make_unique(destroyed); + return publisher.publish(std::move(next),revision-1,7); + }; + using Result=RealtimeRoutePublisher::Result; + assert(publish(1)==Result::applied); + { + auto lease=publisher.acquire(); + assert(lease.get(7)&&lease.get(7)->graphRevision==1); + assert(publish(2)==Result::applied); + assert(publish(3)==Result::applied); + assert(publisher.pendingRetirements()==2); + assert(publish(4)==Result::retirementFull); + assert(destroyed.load(std::memory_order_relaxed)==1); + assert(lease.get(7)->graphRevision==1); + } + assert(publisher.pollRetirement()); + assert(publisher.pendingRetirements()==0); + assert(destroyed.load(std::memory_order_relaxed)==3); + assert(publish(4)==Result::applied); + publisher.unpublish(); + assert(publisher.pollRetirement()); + assert(destroyed.load(std::memory_order_relaxed)==4); // Runtime contract for the exact RT graph publication helper. struct FakeGraph { int id; }; FakeGraph old{1}, next{2}, third{3}; From 9f15f2b948c4490cde8740c47d0ce8b58d7b989b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 2 Nov 2026 23:14:01 +0700 Subject: [PATCH 2/6] fix(worker): release Show snapshots, vendor blobs and completion closures on every job boundary --- ...M1_REALTIME_CORE_STABILIZATION_20261102.md | 3 ++ src/NativeShowSaveWorker.h | 39 ++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md index a1bd83fae..8ba3ac0f2 100644 --- a/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md +++ b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md @@ -9,3 +9,6 @@ The existing `RealtimeRoutePublisher` owns bounded retirement. New tests hold a **Runtime invariant:** `LiveAudioEngine::audioDeviceIOCallbackWithContext` is still M4 until the full CH1 external/Orbit owner, native vendor FX/editor/Show, physical input/output pins and monitor can migrate together. Never enable universal supportedOps or silently render the new graph alongside M4. Worker-only work belongs to existing control/Show-save processing, NOT the real-time callback. **Remaining M1 release gates:** pass exact-SHA Windows MSVC/CTest, integrate a single full-fidelity ChannelId callback with atomic admission and no FX loss, then qualify ASIO/WASAPI and zero-FX crackle on actual hardware. This change alone is **not M1 complete**, not UAT, not acoustic FAT. + +## Worker payload lifetime hardening +`NativeShowSaveWorker` validates Show IDs before reserving, releases snapshot/blob/closure memory immediately on start failure, and moves the completion closure rather than retaining a second copy after IO completion. The long-lived worker is reused; no new OS thread or realtime allocation has been introduced. Windows JUCE compilation and runtime verification are release gates. diff --git a/src/NativeShowSaveWorker.h b/src/NativeShowSaveWorker.h index f44e1f23f..f568003d2 100644 --- a/src/NativeShowSaveWorker.h +++ b/src/NativeShowSaveWorker.h @@ -43,17 +43,19 @@ class NativeShowSaveWorker final : private juce::Thread { } bool launch(juce::File studio,SnapshotV2 snapshot, std::vector binaryStates,Completion completion) { - if(!reserve(Operation::save,std::move(studio),std::move(completion)) || - !detail::uuid(snapshot.id))return false; + // Reject invalid requests BEFORE reserving or retaining a potentially + // large vendor-state payload on this long-lived worker. + if(!detail::uuid(snapshot.id) || + !reserve(Operation::save,std::move(studio),std::move(completion))) + return false; snapshot_=std::move(snapshot); blobs_=std::move(binaryStates); - if(startThread())return true; - return false; + return startOrRelease(); } bool list(juce::File studio,Completion completion) { if(!reserve(Operation::list,std::move(studio),std::move(completion))) return false; - return startThread(); + return startOrRelease(); } bool read(juce::File studio,juce::String showId, juce::int64 epoch,juce::int64 revision,Completion completion) { @@ -62,9 +64,27 @@ class NativeShowSaveWorker final : private juce::Thread { return false; requestedId_=std::move(showId); requestEpoch_=epoch;requestRevision_=revision; - return startThread(); + return startOrRelease(); } private: + // Start failure must release captured Show snapshots, binary-state blobs + // and completion closures. The worker never transfers these to RT. + bool startOrRelease() { + if(startThread())return true; + releaseJob(); + return false; + } + // Exclusively invoked after the worker's IO is finished or before it + // started. No concurrent use with the caller/message thread. + void releaseJob() { + snapshot_=SnapshotV2{}; + blobs_.clear(); + blobs_.shrink_to_fit(); + requestedId_={}; + requestEpoch_=0;requestRevision_=0; + studio_={}; + finished_={}; + } bool reserve(Operation mode,juce::File studio,Completion completion) { if(isThreadRunning()||!completion)return false; operation_=mode;studio_=std::move(studio); @@ -86,10 +106,11 @@ class NativeShowSaveWorker final : private juce::Thread { } catch(...) { result.error="Unknown native Show IO exception; session unchanged"; } - blobs_.clear(); // release captured bytes on IO thread after commit - blobs_.shrink_to_fit(); + // Move the completion closure out: the worker must not retain a + // second copy of UI captures or a large Show snapshot between jobs. + auto done=std::move(finished_); + releaseJob(); // IO worker thread, never audio callback auto alive=alive_; - auto done=finished_; // A 128 MB vendor-blob result must not be copied by std::function // when JUCE queues an async callback on the message thread. auto delivered=std::make_shared(std::move(result)); From 773fbddafdbc070831f496a1a6269230f96ce120 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 2 Nov 2026 23:35:43 +0700 Subject: [PATCH 3/6] feat(engine): reconcile AUX realtime control, prove ownership; gate M1 hardware FAT artifact --- .github/workflows/p1-windows.yml | 9 ++++---- docs/FIRST_SOUND_FAT_QUICKSTART_20261101.md | 22 ++++++++++++++++++- ...M1_REALTIME_CORE_STABILIZATION_20261102.md | 7 ++++++ engine/core/PreparedMixerBlock.h | 11 +++++----- tests/mixer_routing_plan_test.cpp | 9 +++++++- tests/realtime_control_test.cpp | 4 +++- 6 files changed, 50 insertions(+), 12 deletions(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 965bd2fbf..266baddc7 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -137,12 +137,13 @@ jobs: & ./scripts/verify_native_windows_artifact.ps1 -OutputDir dist if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # PRs compile/CTest/package but never silently publish a stable build. - # This single M4 FAT branch is explicitly allowed to upload an - # UNQUALIFIED experimental ZIP for real physical hardware testing. + # Only explicitly named hardware-FAT candidate PRs may upload an + # UNQUALIFIED test artifact. It is never a public/stable release. + # No extra build matrix and no upload when CTest/package audit fails. - uses: actions/upload-artifact@v4 - if: ${{ github.event_name != 'pull_request' || github.head_ref == 'milestone/m4-unified-native-multichannel-fx-20261101' }} + if: ${{ github.event_name != 'pull_request' || github.head_ref == 'milestone/m4-unified-native-multichannel-fx-20261101' || github.head_ref == 'work/m1-realtime-stability-20261102' }} with: - name: ${{ github.event_name == 'pull_request' && 'ArSonMix-M4-EXPERIMENTAL-Hardware-FAT-Windows-x64' || 'ArSonMix-GUI10CH-P012-Verified-Hardware-FAT-Windows-x64' }} + name: ${{ github.event_name == 'pull_request' && (github.head_ref == 'work/m1-realtime-stability-20261102' && 'ArSonMix-M1-EXPERIMENTAL-Hardware-FAT-Windows-x64' || 'ArSonMix-M4-EXPERIMENTAL-Hardware-FAT-Windows-x64') || 'ArSonMix-GUI10CH-P012-Verified-Hardware-FAT-Windows-x64' }} path: dist/ if-no-files-found: error retention-days: 14 diff --git a/docs/FIRST_SOUND_FAT_QUICKSTART_20261101.md b/docs/FIRST_SOUND_FAT_QUICKSTART_20261101.md index baa97a730..c518d4eaf 100644 --- a/docs/FIRST_SOUND_FAT_QUICKSTART_20261101.md +++ b/docs/FIRST_SOUND_FAT_QUICKSTART_20261101.md @@ -1,5 +1,5 @@ # ArSonMix — Windows First Sound / Hardware FAT -Date: 1 November 2026. Current production: **10 input channels + 4 AUX**, one JUCE callback, MAIN/MONITOR and native VST3. The experimental dynamic CH11/Group engine has **not** replaced the production callback. The outstanding 0FX hardware crackle issue is #15. This is a FAT **candidate**, not hardware certified or guaranteed zero physical latency. +Date: 1 November 2026. M1 hardware candidate addendum: 2 November 2026. Current production: **10 input channels + 4 AUX**, one JUCE callback, MAIN/MONITOR and native VST3. The experimental dynamic CH11/Group engine has **not** replaced the production callback. The outstanding 0FX hardware crackle issue is #15. This is a FAT **candidate**, not hardware certified or guaranteed zero physical latency. ## 1. Verify package Extract the complete Windows Actions ZIP to a writable folder. `BUILD_PROVENANCE.json` must show the same `sourceCommit` as the GitHub run; EXE SHA-256 must equal `exeSha256`. Keep `portable_mode.txt`, never delete an existing `Studio` workspace. The file is a Windows x64 JUCE GUI executable; Microsoft Edge WebView2 Runtime and the correct audio hardware driver are required. @@ -28,3 +28,23 @@ Send: (a) screenshot of active driver/rate/buffer/pins, (b) accepted CH01 patch **PASS is hardware-grounded:** correct MAIN source path, verified mute/fader control, no wrong-endpoint output, clean 0FX wired audio for >=30 minutes on the recorded device/rate/buffer, followed by real plugin testing. A green Windows CTest/Chromium CI is not a substitute. Historical full test matrix remains `docs/HARDWARE_FAT_GUI10_ENGINE_P012_20261027.md`. This packaged guide supersedes obsolete manual START AUDIO instructions. + +## 5. M1 candidate — structured physical acceptance (not an M5 universal graph) + +The **ArSonMix-M1-EXPERIMENTAL-Hardware-FAT-Windows-x64** workflow artifact is uploaded only if the exact PR SHA completes Windows compile, all CTests, packaging and ZIP/embedded-GUI SHA256 verification. A PR artifact is not a public stable release. The EXE preserves the existing **native M4 10CH + 4AUX** callback, not a live CH11/group universal engine. DO NOT apply an unqualified artifact on a live public-performance show. + +One real device, one verified I/O clock, wired monitoring, LOW output gain and initially **0 VST3**. Start at a supported buffer of 256 samples, then 128 and 64 only after the earlier stage has passed; document actual negotiated values, don't assume the driver honored the request. For each supported buffer: + +| Native check | Operator action and expected physical result | Hard fail / retain evidence | +|---|---|---| +| Unpatched startup | Launch without input patch; MAIN stays silent and unarmed | Any unexpected output/audio or wrong endpoint | +| Device isolation | Select real active ASIO or WASAPI endpoint; verify L/R physical pins, rate and epoch | Invalid pins, auto re-arm on hotplug, unexpected fallback | +| Real 0FX | Patch CH01 mic/line input, explicitly ARM; record 30-minute continuous wired output | Pops/crackle: Mark Crackle and Copy Full Report | +| Short-buffer gain | Move CH01 fader repeatedly and reverse while moving; listen for clicks, watch true meters | Zipper clicks, freezes, inconsistent physical gain | +| AUX gain/edge | Connect a validated SEND to AUX; change send and AUX return levels with effects bypassed | Silence despite accepted change, stale/reverted controls, double direct signal | +| Monitor isolation | If a separate hardware pair exists, enable MONITOR intentionally | MONITOR leaking to MAIN or shared hardware pair | +| Vendor/plugin | Only after 0FX clean, insert real VST3 and toggle bypass/editor | Stuck UI, plugin recreation, audio gap, FX state loss | +| Show lifecycle | Save and recall same route/plugin states, check output is never armed implicitly | Stale device epoch, missing FX, corrupt restoration | +| Safe shutdown | Stop/restart and unplug/replug device, reselect/ARM deliberately | Audio on unexpected pins, leaked resource or crash | + +**Required evidence**: download artifact name and exact 40-character SHA from `BUILD_PROVENANCE.json`; SHA256 of installed EXE; physical device name/driver/rate/buffer and enabled port mapping; 0FX duration; crackle report if any; one short video or screenshots demonstrating CH01, AUX, MONITOR and Show. The test passes only for the exact device and configuration tested, and never proves every VST3 or absolute crash-proof operation. diff --git a/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md index 8ba3ac0f2..17f836666 100644 --- a/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md +++ b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md @@ -12,3 +12,10 @@ The existing `RealtimeRoutePublisher` owns bounded retirement. New tests hold a ## Worker payload lifetime hardening `NativeShowSaveWorker` validates Show IDs before reserving, releases snapshot/blob/closure memory immediately on start failure, and moves the completion closure rather than retaining a second copy after IO completion. The long-lived worker is reused; no new OS thread or realtime allocation has been introduced. Windows JUCE compilation and runtime verification are release gates. + +## Exact CI evidence and hardware artifact scope (revision 2) +Windows run `41479462759` compiled successfully but 52/54 CTests passed. The remaining two failures were analyzed and corrected together: +1. Native `setAuxSendGain` / `setAuxBusGain` is **one atomic automation plane** even without separate strip controls, as exercised by `dedicated_aux_bus_test.cpp`. The old conditional gate silenced actual physical AUX level edits. In the routing CTest, a newly built `PreparedMixerBlock` establishes fresh compiled defaults, while an already automated block retains its explicit target. +2. The graph-retirement test needed to count the rejected candidate's destructor too: 3 original accepted + 1 rejected + 1 newly accepted = **5 distinct prepared instances**. The lifetime test checks that saturation safely rejects and reader-owned graphs are not reclaimed early. + +This patch also authorizes **one** exact-branch `M1-EXPERIMENTAL` GitHub Actions artifact **only after** all CTests and package/provenance validation pass. This does not enable universal routing/CH11, promote stable release, or change hardware patch/ARM policy. The packaged FAT guide now includes explicit pass/fail cases for wired 0FX ASIO, AUX/monitor, state recall and hotplug. No parallel CI matrix or redundant always-on worker. diff --git a/engine/core/PreparedMixerBlock.h b/engine/core/PreparedMixerBlock.h index 4b75cff29..0a13020e6 100644 --- a/engine/core/PreparedMixerBlock.h +++ b/engine/core/PreparedMixerBlock.h @@ -483,7 +483,7 @@ class PreparedMixerBlock final { // Once the message thread publishes a changed send target, // the SAME callback switches to one live PRE/POST processor // which follows 64-sample gains across varying block sizes. - if(live && auxAutomationActive_.load(std::memory_order_acquire)) + if(auxAutomationActive_.load(std::memory_order_acquire)) dispatchLiveAux(strip,SendTap::preFader,l,r,frames); else graph.aux.dispatch(strip,SendTap::preFader,l,r, auxLeft_.data(),auxRight_.data(),frames); @@ -557,7 +557,7 @@ class PreparedMixerBlock final { // Once the message thread publishes a changed send target, // the SAME callback switches to one live PRE/POST processor // which follows 64-sample gains across varying block sizes. - if(live && auxAutomationActive_.load(std::memory_order_acquire)) + if(auxAutomationActive_.load(std::memory_order_acquire)) dispatchLiveAux(strip,SendTap::postFader,l,r,frames); else graph.aux.dispatch(strip,SendTap::postFader,l,r, auxLeft_.data(),auxRight_.data(),frames); @@ -586,9 +586,10 @@ class PreparedMixerBlock final { // the sample-continuous 64-frame de-zipper across 4/8/16-frame // callbacks. The fader scales the return AFTER hosted AUX VST3 // for both MAIN and independent MONITOR, not source dry PCM. - // Offline/static rendering never inherits a previous live - // automation target. Native live control provides 'live'. - const bool automated=live && auxBusAutomationActive_.load( + // AUX automation is independent of channel fader/MUTE control. + // A caller may automate AUX sends/returns without supplying a + // RealtimeStripControls bank; keep one canonical DSP target plane. + const bool automated=auxBusAutomationActive_.load( std::memory_order_acquire); const float target=automated ?auxBusTarget_[b].load(std::memory_order_acquire):bus.gain; diff --git a/tests/mixer_routing_plan_test.cpp b/tests/mixer_routing_plan_test.cpp index 1a2832a8e..b8c3b120e 100644 --- a/tests/mixer_routing_plan_test.cpp +++ b/tests/mixer_routing_plan_test.cpp @@ -842,8 +842,15 @@ static void verifyRealtimeAuxMasterPcmBothOutputs() { assert(!block.setAuxBusGain(0,std::numeric_limits::quiet_NaN())); assert(close(block.auxBusGain(0),0.f)); assert(close(block.plan().aux.buses[0].gain,1.f)); // topology immutable - // Legacy offline/no-live-control path still uses immutable compiled gain. + // Explicit AUX automation remains live even without a separate strip + // controls object. It MUST NOT silently fall back to stale compiled gain + // because older physical/native paths do not always pass that object. assert(block.process(inputs,2,left.data(),right.data(),64,noFx)); + assert(close(left[0],0.f)); + // A newly prepared graph starts at its own immutable initial gain: + // structural transaction/Show recall does not leak old AUX state. + PreparedMixerBlock freshlyPrepared(graph,64); + assert(freshlyPrepared.process(inputs,2,left.data(),right.data(),64,noFx)); assert(close(left[0],initial)); } diff --git a/tests/realtime_control_test.cpp b/tests/realtime_control_test.cpp index 91b288fdb..10678cd4a 100644 --- a/tests/realtime_control_test.cpp +++ b/tests/realtime_control_test.cpp @@ -87,7 +87,9 @@ int main(){ assert(publish(4)==Result::applied); publisher.unpublish(); assert(publisher.pollRetirement()); - assert(destroyed.load(std::memory_order_relaxed)==4); + // Three accepted snapshots + one rejected admission + final fourth + // accepted snapshot: all five owners are reclaimed (no leak/double free). + assert(destroyed.load(std::memory_order_relaxed)==5); // Runtime contract for the exact RT graph publication helper. struct FakeGraph { int id; }; FakeGraph old{1}, next{2}, third{3}; From 6c0f0a54f4bcd3b737e6282db434979cd25d6852 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 3 Nov 2026 04:53:10 +0700 Subject: [PATCH 4/6] refactor(engine): enforce one native render owner; retire dead stereo VST fallback --- CMakeLists.txt | 2 +- docs/ENGINE_RUNTIME_AUTHORITY_20261103.md | 57 +++++++++++++ ...M1_REALTIME_CORE_STABILIZATION_20261102.md | 3 + engine/core/NativeRenderAuthority.h | 40 ++++++++++ src/LiveAudioEngine.h | 80 +++++-------------- tests/realtime_control_test.cpp | 12 +++ 6 files changed, 135 insertions(+), 59 deletions(-) create mode 100644 docs/ENGINE_RUNTIME_AUTHORITY_20261103.md create mode 100644 engine/core/NativeRenderAuthority.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c169f8269..34aa9b7bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ juce_add_gui_app(ARMixConsole juce_add_binary_data(ARMixAssets SOURCES web/index.html web/styles.css web/plugin-ui.css web/app.js web/plugin-ui.js web/bridge.js web/monitor.js web/mixer-io.js web/mixer-io.css web/mixer-layout.js web/mixer-layout.css web/assets/audio-interface.svg) -target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) +target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/core/NativeRenderAuthority.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) target_compile_definitions(ARMixConsole PRIVATE JUCE_WEB_BROWSER=1 JUCE_USE_WIN_WEBVIEW2=1 diff --git a/docs/ENGINE_RUNTIME_AUTHORITY_20261103.md b/docs/ENGINE_RUNTIME_AUTHORITY_20261103.md new file mode 100644 index 000000000..316ed961e --- /dev/null +++ b/docs/ENGINE_RUNTIME_AUTHORITY_20261103.md @@ -0,0 +1,57 @@ +# ArSonMix — ONE production engine, GUI-directed ownership +Date: 2026-11-03. Status: **binding engine ownership map** (code-enforced for existing M4 callback, NOT universal live certification). + +## Only one runtime authority + +```text +PR #278 + #285 approved GUI workflow (reference only, not audio) + | +PR #271 web native renderer → ConsoleLiveBridgeV6 snapshot/intent/ACK + | + Native JUCE LiveAudioEngine + | + NativeRenderAuthority (one selector) + | | | + UNPATCHED ACCEPTED M4 DIAGNOSTIC + silence one real mixer test-only 0FX + | + LiveDryRoutingLab + LiveChannelFxGraph + PreparedMixerBlock + | + existing CH1 original VST/Orbit lease + AUX / MAIN / MONITOR + | + actual verified device pins +``` + +The `NativeRenderAuthority` is an explicit, fixed-cost callback selector. **There is no second simultaneously running mixer.** The former standalone stereo plugin dispatch inside the diagnostic-only remainder was unreachable and is deleted, not hidden behind another flag. An unpatched NORMAL route stays silent and cannot silently fall back to stereo CH1. + +## What is active, what is migration-only, what is test-only + +| Ownership | Modules | Decision | +| --- | --- | --- | +| **PRODUCTION, temporary compatibility** | `src/LiveAudioEngine.h`, `src/LiveDryRoutingLab.h`, `engine/core/LiveChannelFxGraph.h`, `engine/core/PreparedMixerBlock.h`, native CH1 VST/Orbit lease | KEEP until truly equivalent unified render; bugfixes only, no new competing features | +| **Future canonical ChannelId engine (prepared, not yet production)** | `DynamicChannelRoster`, `DynamicPreparedMixerBlock`, `DynamicNativeSessionPublisher`, `DynamicChannelFxLeaseBank`, `UnifiedLegacyProductionAdmission`, `DynamicAcceptedSession` | KEEP as one migration target; **do not attach as a second callback** or advertise LIVE | +| **Compatibility translation** | `LegacyLiveGraphMigration`, accepted device epoch / actual port pin mapping | KEEP until cutover with exact PCM, VST/editor and Show parity; then retire in one controlled transaction | +| **Testing-only** | `PreparedNativeMixerSession.h`, dedicated offline dynamic test targets | No longer list testing-only session as shipped `ARMixConsole` source; keep its separate CTest target | +| **Diagnostics, no effect graph** | old stereo scratch path in `LiveAudioEngine`, diagnostic tone/capture, health and 0FX evidence | KEEP isolated with NO vendor plugin processing and NO production fallback | +| **Single non-RT worker** | `NativeShowSaveWorker` | KEEP Show I/O on worker, not on callback; no extra per-channel/per-plugin worker | + +## Stop rules — prevents return of mixed engines + +1. The approved reference GUI is the *workflow authority*. Native accepted snapshots, stable ChannelIds, real device pins and ACK remain the *data/PCM authority*. Never let JS or a browser mock own audio routing or create fake FX. +2. There is **one** `audioDeviceIOCallbackWithContext` production entry point and **one** selected render owner at any time. Do not run M4 and dynamic PCM, or duplicate native vendor VST3 instances. +3. New channels, Group, FX Return and WIRE must go into the **universal ChannelId graph**. No new business feature is allowed to extend fixed 10CH/M4 design, except fixes for actual physical audio reliability. +4. Freeze old plugin-feature experiments; preserve external #15 0FX crackle evidence and driver safety research (including draft #251). No destructive deletion or premature PR closure while hardware equivalence is unknown. +5. When universal graph passes real M4 migration/production gates, **remove** M4 callback selection, ordinal-as-identity adapters and legacy CH1 special cases in the **same integration PR**. The real diagnostic tone/capture remains a separate legitimate service, not a mixer. +6. Integration #270 alone certifies exact combined GUI/native SHA, Windows CTest/Chromium, VST/editor/Show parity and measured physical audio. Do not mark GUI as LIVE from screenshots or offline data. + +## Decommission gates (NOT met yet) + +- Real 10CH + 4AUX, MAIN/MONITOR, CH1 original vendor/Orbit/editor and Show state are rendered by the same accepted ChannelId graph. +- Normal continuous fader/MUTE/SOLO/SEND controls remain audible without mandatory device restart; no lost plugin tail or duplicated dry output. +- Native ACK/epoch/revision, output disarm/rearm and physical sparse port map are verified. +- Windows exact-SHA build/CTest and physical ASIO/WASAPI 0FX + 1FX FAT pass. + +**Result:** no obsolete active stereo plugin engine remains available from the diagnostic fallback; current M4 compatibility is intentionally quarantined and will be retired only when the unified engine demonstrably replaces it. diff --git a/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md index 17f836666..510d1ed01 100644 --- a/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md +++ b/docs/M1_REALTIME_CORE_STABILIZATION_20261102.md @@ -19,3 +19,6 @@ Windows run `41479462759` compiled successfully but 52/54 CTests passed. The rem 2. The graph-retirement test needed to count the rejected candidate's destructor too: 3 original accepted + 1 rejected + 1 newly accepted = **5 distinct prepared instances**. The lifetime test checks that saturation safely rejects and reader-owned graphs are not reclaimed early. This patch also authorizes **one** exact-branch `M1-EXPERIMENTAL` GitHub Actions artifact **only after** all CTests and package/provenance validation pass. This does not enable universal routing/CH11, promote stable release, or change hardware patch/ARM policy. The packaged FAT guide now includes explicit pass/fail cases for wired 0FX ASIO, AUX/monitor, state recall and hotplug. No parallel CI matrix or redundant always-on worker. + +## 2026-11-03 single production authority cleanup +Real-time callback now routes through the explicit `NativeRenderAuthority` decision. The no-longer-reachable legacy stereo FX processing code has been removed from the diagnostic-only path; this does not change accepted 10CH/4AUX production routing. `PreparedNativeMixerSession.h` remains tested but is no longer listed in the shipping GUI application target. See `docs/ENGINE_RUNTIME_AUTHORITY_20261103.md` for the decommission map and strict migration gates. diff --git a/engine/core/NativeRenderAuthority.h b/engine/core/NativeRenderAuthority.h new file mode 100644 index 000000000..03d81b64b --- /dev/null +++ b/engine/core/NativeRenderAuthority.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include + +// Production render ownership, never an audio engine or a second callback. +// The approved GUI can project ONE native engine. Until the full ChannelId +// VST/editor/Show cutover is admitted, only the existing M4 route owns PCM. +// The legacy stereo path is diagnostic-only, never a hidden fallback. +namespace armix::mixer { +enum class NativeRenderOwner : std::uint8_t { + failSilentUnpatched, + acceptedM4Session, + isolatedDiagnostic +}; + +struct NativeRenderAuthority final { + static constexpr NativeRenderOwner select( + bool normalAudio, bool m4SessionActive) noexcept { + // A verified accepted M4 route always owns the callback: a diagnostic + // mode must never start processing a second stereo FX chain over it. + if(m4SessionActive)return NativeRenderOwner::acceptedM4Session; + if(normalAudio)return NativeRenderOwner::failSilentUnpatched; + return NativeRenderOwner::isolatedDiagnostic; + } + static constexpr bool isProduction(NativeRenderOwner owner) noexcept { + return owner==NativeRenderOwner::acceptedM4Session; + } + static constexpr bool mayRunDiagnostic(NativeRenderOwner owner) noexcept { + return owner==NativeRenderOwner::isolatedDiagnostic; + } +}; +static_assert(NativeRenderAuthority::select(true,false)== + NativeRenderOwner::failSilentUnpatched); +static_assert(NativeRenderAuthority::select(true,true)== + NativeRenderOwner::acceptedM4Session); +static_assert(NativeRenderAuthority::select(false,true)== + NativeRenderOwner::acceptedM4Session); +static_assert(NativeRenderAuthority::select(false,false)== + NativeRenderOwner::isolatedDiagnostic); +} // namespace armix::mixer diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index bfade45ca..9c9aae5c0 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -12,6 +12,7 @@ #include "../engine/device/JuceIndependentClockDevice.h" #include "../engine/device/LiveSecondaryOutputDevice.h" #include "../engine/core/LiveOutputRouteGate.h" +#include "../engine/core/NativeRenderAuthority.h" #include "../engine/device/AsioPriorityDeviceManager.h" #include "../engine/device/AsioRegistryIdentityProbe.h" #include "../engine/device/DirectRouteFence.h" @@ -1751,6 +1752,13 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback std::memory_order_relaxed); return; } + // ONE explicit owner for the whole device callback. The GUI cannot + // select an experimental ChannelId renderer or revive stereo CH1. + // Cutover to universal will replace this authority transaction only + // after the full VST3/Show/epoch proof, never add a parallel callback. + const auto renderOwner=armix::mixer::NativeRenderAuthority::select( + activeDiagnosticRoute==armix::diagnostics::Route::normal, + dryRoutingLab_.active()); const auto cycle = handoff_.beginCycle(); // R0B B3: production NORMAL audio has a single native routing owner. // Until a device-epoch-validated 10CH/4AUX route is published, output @@ -1761,8 +1769,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback // Keep the existing FX graph handoff progressing even when unpatched: // a staged ADD/REMOVE must ACK and retire on the callback thread. // Only atomic reads and deterministic output writes; no RT heap or I/O. - if (activeDiagnosticRoute == armix::diagnostics::Route::normal - && !dryRoutingLab_.active()) + if (renderOwner == + armix::mixer::NativeRenderOwner::failSilentUnpatched) { // P0: SILENT output must not mean blind capture diagnostics. // A verified ASIO/WASAPI callback can carry PCM before any @@ -1817,7 +1825,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback // action, with an immutable preallocated P1D graph. Its own zero-VST // callback path NEVER falls through to CH1 on stale/hotplug routes. // DirectFence was already checked above; no output to unknown device. - if (dryRoutingLab_.active()) + if (renderOwner == + armix::mixer::NativeRenderOwner::acceptedM4Session) { const auto outputGate=armix::mixer::LiveOutputRouteGate::evaluate( dryRoutingLab_.active(), @@ -1938,13 +1947,16 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback juce::FloatVectorOperations::clear(outputs[channel],samples); return; } + // The only remaining stereo renderer is DIAGNOSTIC. It may emit + // a bounded test tone or test capture but never host channel VST3 + // or become a fallback production mixer. + jassert(armix::mixer::NativeRenderAuthority::mayRunDiagnostic( + renderOwner)); const bool enabled = monitor_.load (std::memory_order_relaxed) && !routeReconfiguring_.load (std::memory_order_acquire); const auto route = diagnosticRoute_.load (std::memory_order_relaxed); const bool toneTest = route == armix::diagnostics::Route::outputOnlyTone; const bool captureTest = route == armix::diagnostics::Route::captureOnly; - const bool dry = dryTest_.load (std::memory_order_relaxed) - || route != armix::diagnostics::Route::normal; if (toneTest && outputChannels > 0) testOutputFrames_.fetch_add (static_cast (samples), std::memory_order_relaxed); if (captureTest && inputChannels > 0) @@ -1974,10 +1986,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback { const int frames = juce::jmin (maxFrames, samples - offset); // Preallocated backing store: no resizing/capacity bookkeeping in RT. - // Two-channel AudioBuffer view refers to scratch_ without ownership. - // JUCE uses its inline channel pointer storage for two channels. - juce::AudioBuffer scratchView ( - scratch_.getArrayOfWritePointers(), 2, frames); + // Test-only stereo buffers are preallocated. There is no VST + // buffer view or plugin dispatch in the diagnostic-only path. if (toneTest) { auto* left = scratch_.getWritePointer (0); @@ -2001,55 +2011,9 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback for (int i = 0; i < frames; ++i) if (!toneTest) inPeak = juce::jmax (inPeak, std::abs (dst[i])); } - // MIDI capacity is empty unless the plugin itself changes it. - juce::MidiBuffer midi; - if (!dry) - { - // One atomic order snapshot per block: stable physical FX and bypass identity. - const auto order = cycle.graph->orderPacked.load (std::memory_order_acquire); - for (int fx = 0; fx < cycle.graph->count; ++fx) - { - const int physical = Graph::physicalAt (order, fx); - auto& slot = cycle.graph->slots[physical]; - if (!slot.processor) {midi.clear();continue;} - auto& bypass=cycle.graph->bypassEnvelope[physical]; - bypass.request(cycle.graph->bypassFlags[physical].load(std::memory_order_acquire)); - // Steady wet/dry requires no copy or extra arithmetic. - // A transition temporarily snapshots the exact input to - // this insert; a second full FX graph is never created. - const bool blend=bypass.transitioning(); - if (blend) - for(int ch=0;ch<2;++ch) - juce::FloatVectorOperations::copy( - dryScratch_.getWritePointer(ch), - scratch_.getReadPointer(ch),frames); - if (bypass.shouldProcessWet()) - { - const auto pluginBeginUs = clockMicros(); - slot.processor->processBlock (scratchView, midi); - const auto pluginUs = clockMicros() - pluginBeginUs; - lastPluginUsBySlot_[physical].store (pluginUs, std::memory_order_relaxed); - publishMax (worstPluginUsBySlot_[physical], pluginUs); - publishMax (worstPluginUs_, pluginUs); - if (static_cast (pluginUs) > periodUs * 0.75) - slowPlugins_.fetch_add (1, std::memory_order_relaxed); - } - if (blend) - { - float* wetL=scratch_.getWritePointer(0); - float* wetR=scratch_.getWritePointer(1); - const float* dryL=dryScratch_.getReadPointer(0); - const float* dryR=dryScratch_.getReadPointer(1); - for(int i=0;i #include #ifdef NDEBUG @@ -14,6 +15,17 @@ #include using namespace armix::rt; int main(){ + // Production cannot fall through to a second stereo/VST mixer. The + // only old stereo path is explicitly test/diagnostic and disconnected + // from an accepted native M4 route. + using Owner=armix::mixer::NativeRenderOwner; + using Authority=armix::mixer::NativeRenderAuthority; + assert(Authority::select(true,false)==Owner::failSilentUnpatched); + assert(Authority::select(true,true)==Owner::acceptedM4Session); + assert(Authority::select(false,true)==Owner::acceptedM4Session); + assert(Authority::select(false,false)==Owner::isolatedDiagnostic); + assert(!Authority::mayRunDiagnostic( + Authority::select(false,true))); SpscQueue q; int value=-1; assert(!q.tryPop(value)); From 388785c595f2ad7d898b8956a24e2f9e6dbbd5e4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 3 Nov 2026 04:54:42 +0700 Subject: [PATCH 5/6] test(contracts): follow single render authority; reject diagnostic VST fallback --- tests/live_graph_contract_test.mjs | 25 +++++++++++++++++++++---- tests/live_routing_ui_contract_test.mjs | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/live_graph_contract_test.mjs b/tests/live_graph_contract_test.mjs index 594c641cf..87bf43246 100644 --- a/tests/live_graph_contract_test.mjs +++ b/tests/live_graph_contract_test.mjs @@ -28,6 +28,22 @@ test('preset UI reflects callback-acknowledged state not queued state',()=>{ assert.match(m,/arMixNativePresetLoaded/); assert.match(b,/RECALL LIVE/); }); +test('single engine production selection forbids old VST processing in diagnostic fallback',()=>{ + const authority=readFileSync(new URL('../engine/core/NativeRenderAuthority.h',import.meta.url),'utf8'); + assert.match(authority,/enum class NativeRenderOwner/); + assert.match(authority,/failSilentUnpatched/); + assert.match(authority,/acceptedM4Session/); + assert.match(authority,/isolatedDiagnostic/); + assert.match(e,/NativeRenderAuthority::select\(/); + assert.match(e,/NativeRenderOwner::acceptedM4Session/); + const start=e.indexOf('// The only remaining stereo renderer is DIAGNOSTIC'); + const end=e.indexOf('const auto elapsedUs = clockMicros() - beginUs',start); + assert.ok(start>0 && end>start,'explicit diagnostic-only tail must exist'); + const fallback=e.slice(start,end); + assert.doesNotMatch(fallback,/processor->processBlock|MidiBuffer midi|make_unique|make_shared/, + 'no second legacy stereo FX chain may be executed from diagnostics'); +}); + test('ADD/REMOVE remain guarded while MOVE publishes physical-slot order',()=>{ assert.match(e,/fxMovePhase_\.load/); assert.match(e,/FxOrderPlan::moved/); @@ -52,7 +68,7 @@ test('R0B CH1 MOVE inside routed 10CH graph uses the same callback-boundary de-c assert.match(move,/FxOrderPlan::moved/); assert.match(move,/fxMovePendingOrder_\.store/); assert.doesNotMatch(move,/detach\(|attach\(|prepareToPlay|releaseResources/); - const begin=e.indexOf('if (dryRoutingLab_.active())',e.indexOf('callbackCount_.fetch_add')); + const begin=e.indexOf('if (renderOwner ==',e.indexOf('callbackCount_.fetch_add')); const end=e.indexOf('const bool enabled = monitor_',begin); const routed=e.slice(begin,end); assert.match(routed,/FxMoveRamp::gain\(\s*routedFxMove,i,samples\)/); @@ -79,7 +95,7 @@ test('R0B major milestone: ADD and REMOVE are prepared control-thread transactio assert.match(e,/ownPlugin\s*\(/); assert.match(e,/old\.reset\(\); \/\/ Vendor cleanup only on final CONTROL-owned reference/); assert.match(e,/handoff_\.stage\(stagedOwner_\.get\(\)\)/); - const callback=e.slice(e.indexOf('if (dryRoutingLab_.active())',e.indexOf('callbackCount_.fetch_add')), + const callback=e.slice(e.indexOf('if (renderOwner ==',e.indexOf('callbackCount_.fetch_add')), e.indexOf('const bool enabled = monitor_',e.indexOf('callbackCount_.fetch_add'))); assert.match(callback,/handoff_\.endCycle\(cycle\)/); assert.match(callback,/cycle\.fadeOut/); @@ -103,13 +119,14 @@ test('R0B B3 NORMAL output is fail-silent while FX graph retirement still progre const beginning=e.indexOf('void audioDeviceIOCallbackWithContext'); const fence=e.indexOf('if (!independent_.active()',beginning); const lease=e.indexOf('const auto cycle = handoff_.beginCycle()',beginning); - const failSilent=e.indexOf('if (activeDiagnosticRoute == armix::diagnostics::Route::normal',beginning); + const failSilent=e.indexOf('if (renderOwner ==',lease); const callbackMetrics=e.indexOf('const std::uint64_t beginUs = clockMicros()',beginning); assert.ok(beginning>=0 && fence>beginning && lease>fence && failSilent>lease && callbackMetrics>failSilent, 'DIRECT fence first, then FX cycle lease, then fail-silent native gate'); const gate=e.slice(failSilent,callbackMetrics); - assert.match(gate,/!dryRoutingLab_\.active\(\)/); + assert.match(e,/NativeRenderAuthority::select\(/); + assert.match(gate,/NativeRenderOwner::failSilentUnpatched/); assert.match(gate,/FloatVectorOperations::clear\(outputs\[c\], samples\)/); assert.match(gate,/outputPeakL_\.store\(0\.f/); assert.match(gate,/handoff_\.endCycle\(cycle\)/, diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index 7e3f9ac05..454b8e8e9 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -46,7 +46,7 @@ test("GUI exposes only truthful dry device routes and acknowledged commit",()=>{ }); test("STOP-race is fail closed: all outputs are written to silence without CH1 fallback",()=>{ - const enter=engine.indexOf("if (dryRoutingLab_.active())",engine.indexOf("callbackCount_.fetch_add")); + const enter=engine.indexOf("if (renderOwner ==",engine.indexOf("callbackCount_.fetch_add")); // Bound the entire routed branch by the first statement of the legacy // fallback, not by an informational comment that can change at each R0B slice. const end=engine.indexOf("const bool enabled = monitor_",enter); From 1e21bf0a0d8aff33b02b56cec5c2e5c328fd41d1 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 3 Nov 2026 04:55:54 +0700 Subject: [PATCH 6/6] test(engine): enforce CH1 leased FX and FX-free diagnostics after legacy retirement --- tests/live_graph_contract_test.mjs | 13 +++++++++---- tests/p0_diagnostic_contract_test.mjs | 7 ++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/live_graph_contract_test.mjs b/tests/live_graph_contract_test.mjs index 87bf43246..281dc9784 100644 --- a/tests/live_graph_contract_test.mjs +++ b/tests/live_graph_contract_test.mjs @@ -54,11 +54,16 @@ test('ADD/REMOVE remain guarded while MOVE publishes physical-slot order',()=>{ test('bypass is sample-smoothed on audio callback without control-thread CPU work',()=>{ assert.match(e,/bypassEnvelope/); - assert.match(e,/bypass\.request\(cycle\.graph->bypassFlags/); - assert.match(e,/bypass\.transitioning\(\)/); + const start=e.indexOf('static void processLegacyChannelOne('); + const end=e.indexOf('void audioDeviceIOCallbackWithContext',start); + assert.ok(start>=0&&end>start,'the accepted M4 CH1 owner must still exist'); + const leaseFx=e.slice(start,end); + assert.match(leaseFx,/bypass\.request\(graph->bypassFlags/); + assert.match(leaseFx,/slot\.processor->processBlock\(buffer,midi\)/); + assert.match(leaseFx,/bypass\.transitioning\(\)/); assert.match(e,/dryScratch_\.setSize \(2, maxFrames/); - assert.match(e,/bypass\.next\(\)/); - assert.match(e,/bypass\.shouldProcessWet\(\)/); + assert.match(leaseFx,/bypass\.next\(\)/); + assert.match(leaseFx,/bypass\.shouldProcessWet\(\)/); assert.doesNotMatch(e.slice(e.indexOf('bool setBypass'),e.indexOf('bool removeAt')),/detach\(|prepareToPlay|releaseResources/); }); diff --git a/tests/p0_diagnostic_contract_test.mjs b/tests/p0_diagnostic_contract_test.mjs index 417ebd0a8..f44fd5a20 100644 --- a/tests/p0_diagnostic_contract_test.mjs +++ b/tests/p0_diagnostic_contract_test.mjs @@ -27,7 +27,12 @@ test('audio callback isolates low-amplitude oscillator from input and VST3',()=> assert.match(engine,/const bool captureTest = route == armix::diagnostics::Route::captureOnly/); assert.match(engine,/diagnosticTone_\.next \(audible\)/); assert.match(engine,/if \(!toneTest\)/); - assert.match(engine,/if \(!dry\)/); + const start=engine.indexOf('// The only remaining stereo renderer is DIAGNOSTIC'); + const end=engine.indexOf('const auto elapsedUs = clockMicros() - beginUs',start); + assert.ok(start>0&&end>start,'isolated diagnostics must have an explicit owner'); + assert.doesNotMatch(engine.slice(start,end), + /processor->processBlock|MidiBuffer midi/, + 'test tone and capture-only must never enter a legacy VST processor'); assert.match(osc,/0\.0316227766/); assert.doesNotMatch(osc,/new |malloc\(|std::vector|mutex|lock_guard|fwrite\(/); assert.match(build,/P0DiagnosticTone/);