From 5dc4f8f8dbedec4b8035f316cde08f1318bdd577 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 03:55:52 +0700 Subject: [PATCH 01/29] feat(io3a): publish truthful secondary ASIO capture readback to approved I/O UI Classify secondary source OFF, NEEDS_REMAP, DEGRADED, WAITING_FOR_PCM, and PCM_FLOW_OBSERVED from native reader and physical lease evidence; distinguish driver-open from actual primary consumption and from channel audibility. Project through existing native snapshot, add compact diagnostics to existing AUDIO I/O panel, and cover fail-closed transitions with portable tests. No second renderer, no new JS truth owner, no hardware FAT claim. --- engine/device/SecondaryCaptureReadbackState.h | 36 +++++++++++++ src/LiveAudioEngine.h | 51 +++++++++++++++++++ src/Main.cpp | 3 ++ .../QualifiedSecondaryCaptureReaderCases.h | 20 ++++++++ web/mixer-io.js | 32 +++++++++++- 5 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 engine/device/SecondaryCaptureReadbackState.h diff --git a/engine/device/SecondaryCaptureReadbackState.h b/engine/device/SecondaryCaptureReadbackState.h new file mode 100644 index 000000000..75dbb786d --- /dev/null +++ b/engine/device/SecondaryCaptureReadbackState.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include + +// IO-3A: portable, deterministic *CONTROL readback* of independently +// clocked B input capture. Driver-open is never equated with source LIVE; +// callback counts distinguish producer observation from actual primary +// consumer progress. No realtime work, allocation or device ownership. +namespace armix::device { +enum class SecondaryCaptureReadbackState { + notConfigured, needsRemap, degraded, waitingForPcm, pcmFlowObserved +}; +constexpr SecondaryCaptureReadbackState classifySecondaryCapture( + bool installedMap, bool remapRequired, bool opened, + bool faulted, bool primaryEpochMatches, + std::uint64_t captureBlocks, std::uint64_t consumedBlocks) noexcept { + if(remapRequired)return SecondaryCaptureReadbackState::needsRemap; + if(!installedMap)return SecondaryCaptureReadbackState::notConfigured; + if(!opened||faulted||!primaryEpochMatches) + return SecondaryCaptureReadbackState::degraded; + if(!captureBlocks||!consumedBlocks) + return SecondaryCaptureReadbackState::waitingForPcm; + return SecondaryCaptureReadbackState::pcmFlowObserved; +} +constexpr const char* secondaryCaptureStateName( + SecondaryCaptureReadbackState state) noexcept { + switch(state) { + case SecondaryCaptureReadbackState::notConfigured:return "NOT_CONFIGURED"; + case SecondaryCaptureReadbackState::needsRemap:return "NEEDS_REMAP"; + case SecondaryCaptureReadbackState::degraded:return "DEGRADED"; + case SecondaryCaptureReadbackState::waitingForPcm:return "WAITING_FOR_PCM"; + case SecondaryCaptureReadbackState::pcmFlowObserved:return "PCM_FLOW_OBSERVED"; + } + return "DEGRADED"; +} +} // namespace armix::device diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index bbcb31612..2d53944c3 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -19,6 +19,7 @@ #include "../engine/device/JuceIndependentClockDevice.h" #include "../engine/device/LiveSecondaryOutputDevice.h" #include "../engine/device/LiveSecondaryCaptureDevice.h" +#include "../engine/device/SecondaryCaptureReadbackState.h" #include "../engine/core/LiveOutputRouteGate.h" #include "../engine/core/NativeOutputTransition.h" #include "../engine/core/NativeRenderAuthority.h" @@ -2714,6 +2715,56 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback o->setProperty ("secondaryOutputUnderflow",static_cast(streamFifo.underflowFrames)); o->setProperty ("secondaryOutputPriming",static_cast(streamFifo.primingFrames)); o->setProperty ("secondaryOutputOverflow",static_cast(streamFifo.overflowFrames)); + // IO-3A: device B is a capture producer only. Native readback is + // projected off the audio callback; this is NOT a GUI-selected source + // and NOT proof of acoustic hardware FAT or a routed live ChannelId. + const auto b=secondaryCapture_.readback(); + const auto readerStatus=qualifiedSecondaryReader_.status(); + const bool bInstalled=qualifiedSecondaryInstalled_.load( + std::memory_order_acquire); + const bool bNeedsRemap=qualifiedCaptureNeedsRemap_.load( + std::memory_order_acquire); + const bool epochMatches=b.primaryEpoch!=0 && + b.primaryEpoch==dryRoutingLab_.epoch(); + const auto captureState=armix::device::classifySecondaryCapture( + bInstalled,bNeedsRemap,b.ready,b.faulted,epochMatches, + b.clock.captureBlocks,readerStatus.secondaryAccepted); + auto secondary=std::make_unique(); + secondary->setProperty("role","INPUT_ONLY_ASIO"); + secondary->setProperty("status", + armix::device::secondaryCaptureStateName(captureState)); + secondary->setProperty("installedInputMap",bInstalled); + secondary->setProperty("needsRemap",bNeedsRemap); + secondary->setProperty("driverReady",b.ready); + secondary->setProperty("driverFault",b.faulted); + secondary->setProperty("primaryEpochMatches",epochMatches); + secondary->setProperty("driver",b.driverName); + secondary->setProperty("activePinMaskHex",b.activeInputPins.toString(16)); + secondary->setProperty("inputChannels",b.callbackInputs); + secondary->setProperty("captureRate",b.captureRate); + secondary->setProperty("primaryRate",b.primaryRate); + secondary->setProperty("capturePeriod",b.capturePeriod); + secondary->setProperty("primaryPeriod",b.primaryPeriod); + secondary->setProperty("bridgeTargetMs",b.bridgeTargetMs); + secondary->setProperty("primaryEpoch", + juce::String(std::to_string(b.primaryEpoch))); + secondary->setProperty("captureGeneration", + juce::String(std::to_string(b.captureGeneration))); + secondary->setProperty("deviceLease", + juce::String(std::to_string(b.deviceLease))); + secondary->setProperty("classFingerprintHex", + juce::String::toHexString( + static_cast(b.driverClassFingerprint))); + secondary->setProperty("identityProvenance", + "ASIO_REGISTERED_CLASS_NOT_PHYSICAL_ENDPOINT_GUID"); + secondary->setProperty("captureBlocks", + static_cast(b.clock.captureBlocks)); + secondary->setProperty("primaryConsumedBlocks", + static_cast(readerStatus.secondaryAccepted)); + secondary->setProperty("silentPrimaryBlocks", + static_cast(readerStatus.secondarySilent)); + secondary->setProperty("sourceAudibleProven",false); + o->setProperty("secondaryCapture",juce::var(secondary.release())); o->setProperty ("adaptiveClockActive", dual); o->setProperty ("adaptiveClockFaulted", dual && independent_.faulted()); o->setProperty ("adaptiveClockMode", dual ? "INDEPENDENT_WASAPI_RENDER_MASTER" : "DIRECT"); diff --git a/src/Main.cpp b/src/Main.cpp index 18b10ea60..2c81ec318 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1741,6 +1741,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr obj->setProperty("globalFxBypassed",engine_.globalFxBypassed()); obj->setProperty("channelAppearance",channelAppearance_.snapshot(accepted.getProperty("graph",{}))); obj->setProperty("waitingAsioInputs",live.getProperty("waitingAsioInputs",0)); + // IO-3A: native diagnostic only; no UI-side claim of accepted + // A+B source routing or an authorized driver by display name. + obj->setProperty("secondaryCapture",live.getProperty("secondaryCapture",{})); obj->setProperty("externalOutputs", live.getProperty("dryRoutingLab",{}).getProperty("externalOutputs",{})); obj->setProperty("externalRevision", diff --git a/tests/io2/QualifiedSecondaryCaptureReaderCases.h b/tests/io2/QualifiedSecondaryCaptureReaderCases.h index 9f12bf60a..401c045a9 100644 --- a/tests/io2/QualifiedSecondaryCaptureReaderCases.h +++ b/tests/io2/QualifiedSecondaryCaptureReaderCases.h @@ -3,6 +3,7 @@ #include "../../engine/device/QualifiedSecondaryCaptureReader.h" #include "../../engine/device/QualifiedCaptureHostMode.h" #include "../../engine/device/QualifiedCaptureAdmission.h" +#include "../../engine/device/SecondaryCaptureReadbackState.h" #include "../../engine/device/QualifiedInputGraphBridge.h" #include "../../engine/core/DynamicNativeSessionPublisher.h" #include @@ -20,6 +21,25 @@ inline bool near(float a,float b,float tolerance=0.03f) { return std::abs(a-b){ From 5c067aaf1256289c7d16e526cc736d585234463d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 03:56:22 +0700 Subject: [PATCH 02/29] test(io3a): include string_view explicitly for portable readback state assertions --- tests/io2/QualifiedSecondaryCaptureReaderCases.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/io2/QualifiedSecondaryCaptureReaderCases.h b/tests/io2/QualifiedSecondaryCaptureReaderCases.h index 401c045a9..a015ce56d 100644 --- a/tests/io2/QualifiedSecondaryCaptureReaderCases.h +++ b/tests/io2/QualifiedSecondaryCaptureReaderCases.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace armix::io2_clocked_test { namespace d=armix::device; From e54d647926791068e497e32f78a4699b9c0cfe7d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:02:59 +0700 Subject: [PATCH 03/29] fix(io3a): defer approved UI changes until generated /preview/ bundle is rebuilt from same source --- web/mixer-io.js | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/web/mixer-io.js b/web/mixer-io.js index 86d7ed5d8..bf34032b4 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -1346,28 +1346,7 @@ captureRow.id='arIODeviceCaptureEvidence'; captureRow.setAttribute('aria-label','Verified raw input PCM before mixer routing'); panel.appendChild(captureRow); - // IO-3A additive native readback. No optimistic LIVE status, no - // unqualified GUI device controls or phantom driver selection. - const b=lastStatus.secondaryCapture||{}; - if(b.status&&b.status!=='NOT_CONFIGURED'){ - const status=String(b.status); - const name=String(b.driver||'SECONDARY CAPTURE B'); - const details=b.driverReady? - Number(b.inputChannels||0)+' IN · '+Number(b.captureRate||0).toLocaleString('en-US')+ - ' Hz · '+Number(b.capturePeriod||0)+' samples': - 'No active verified capture callback'; - const row=node('div','arIODeviceCaptureEvidence'); - row.setAttribute('aria-label','Secondary ASIO input native readback'); - row.append(node('span','arIODeviceMicro','DEVICE B · CAPTURE ONLY · '+status.replaceAll('_',' ')), - node('span','',name+' · '+details)); - if(status==='PCM_FLOW_OBSERVED') - row.appendChild(node('small','','Native A+B capture blocks observed; ChannelId source routing still requires matching graph readback.')); - else if(status==='NEEDS_REMAP') - row.appendChild(node('small','','Primary device generation changed; explicit native source remap required.')); - else if(status==='DEGRADED') - row.appendChild(node('small','','B unavailable or faulted; do not substitute Device A pins.')); - panel.appendChild(row); - } + if(!types.length&&!a.open) panel.appendChild(node('p','arIODeviceEmpty', @@ -1540,8 +1519,6 @@ const signature=ioTab+'|'+JSON.stringify([s.epoch,s.revision,s.pending,s.draftRoutes, s.outputPorts,s.mainOutputs,s.draftMainOutputs,s.monitorOutputs,s.draftMonitorOutputs,s.monitorSends,s.draftMonitorSends,s.ports,deviceInventory,deviceDraft,deviceBusy,deviceNote,matrixPage[ioTab==='device'?deviceMatrixView:ioTab],deviceMatrixView,monitorSendsExpanded, [...matrixDraft],[...matrixSide],softwareEdit,softwarePage,sourceIdentity(s),sourceAliases(s), - lastStatus.secondaryCapture?.status,lastStatus.secondaryCapture?.driver, - lastStatus.secondaryCapture?.deviceLease, !!lastStatus.monitor,window.__arMixFastAudioState?.()]); if(lastSignature===signature)return; lastSignature=signature; @@ -2000,12 +1977,7 @@ if(!overlay.hidden){ refreshAudioPath(); // P0 text-only 12Hz; no matrix DOM churn const identity=(d.driver||'')+'/'+(d.rate||0)+'/'+(d.buffer||0); - const b=d.secondaryCapture||{}; - const deviceIdentity=identity+'/'+String(b.status||'')+'/'+ - String(b.driver||'')+'/'+String(b.deviceLease||''); - if(overlay.dataset.deviceIdentity!==deviceIdentity){ - overlay.dataset.deviceIdentity=deviceIdentity;refreshIO(); - } + if(overlay.dataset.deviceIdentity!==identity){overlay.dataset.deviceIdentity=identity;refreshIO();} } }); backend?.addEventListener?.('arMixAudioDeviceInventory',d=>{ From 7c829df1c67fc237164211d37b14569d9c625c1c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:15:42 +0700 Subject: [PATCH 04/29] fix(io3a): require fresh real ASRC PCM windows, not successful priming pulls, before flow readback --- engine/device/SecondaryCaptureReadbackState.h | 79 +++++++++++++++++-- 1 file changed, 73 insertions(+), 6 deletions(-) diff --git a/engine/device/SecondaryCaptureReadbackState.h b/engine/device/SecondaryCaptureReadbackState.h index 75dbb786d..cc9c09de9 100644 --- a/engine/device/SecondaryCaptureReadbackState.h +++ b/engine/device/SecondaryCaptureReadbackState.h @@ -1,24 +1,91 @@ // SPDX-License-Identifier: AGPL-3.0-only #pragma once +#include #include -// IO-3A: portable, deterministic *CONTROL readback* of independently -// clocked B input capture. Driver-open is never equated with source LIVE; -// callback counts distinguish producer observation from actual primary -// consumer progress. No realtime work, allocation or device ownership. +// IO-3A: portable CONTROL-thread readback, never an audio renderer or a +// driver-open / source-audibility assertion. All timing is monotonic host time. namespace armix::device { enum class SecondaryCaptureReadbackState { notConfigured, needsRemap, degraded, waitingForPcm, pcmFlowObserved }; + +// ASRC renderedFrames counts *all* output, including priming and starvation. +// Only frames with a usable FIR input window represent captured PCM. +// This is playback-time evidence, not proof of an audible ChannelId source. +constexpr std::uint64_t secondaryUsableAsrcFrames( + std::uint64_t rendered, std::uint64_t priming, + std::uint64_t underflow) noexcept { + return rendered>priming && rendered-priming>underflow + ? rendered-priming-underflow : 0; +} + +// Off-RT stateful freshness guard. A single callback or an old cumulative +// counter cannot keep B labelled "PCM_FLOW_OBSERVED" indefinitely. Observe +// BOTH independent producer progress and genuinely usable ASRC output within +// the same bounded recent interval. Baseline the first observation for each +// native-issued device lease, including after reset or counters wrap. +class SecondaryCaptureFlowEvidence final { +public: + static constexpr double freshnessMs=500.; + std::uint64_t recentUsableFrames( + std::uint64_t deviceLease, std::uint64_t captureBlocks, + std::uint64_t rendered, std::uint64_t priming, + std::uint64_t underflow, double nowMs, + bool admitted) noexcept { + const auto usable=secondaryUsableAsrcFrames( + rendered,priming,underflow); + if(!deviceLease||!std::isfinite(nowMs)||nowMs<0.) { + reset(); + return 0; + } + if(deviceLease!=lease_ || captureBlockslastCaptureBlocks_)captureProgressMs_=nowMs; + if(usable>lastUsableFrames_)usableProgressMs_=nowMs; + lastCaptureBlocks_=captureBlocks; + lastUsableFrames_=usable; + const bool freshCapture=captureProgressMs_>=0. && + nowMs>=captureProgressMs_ && + nowMs-captureProgressMs_<=freshnessMs; + const bool freshUsable=usableProgressMs_>=0. && + nowMs>=usableProgressMs_ && + nowMs-usableProgressMs_<=freshnessMs; + return freshCapture&&freshUsable?usable:0; + } + void reset() noexcept { + lease_=lastCaptureBlocks_=lastUsableFrames_=0; + captureProgressMs_=usableProgressMs_=-1.; + } +private: + std::uint64_t lease_=0,lastCaptureBlocks_=0,lastUsableFrames_=0; + double captureProgressMs_=-1.,usableProgressMs_=-1.; +}; + +// The last parameter is RECENT usable ASRC frames, not authorized pull calls. constexpr SecondaryCaptureReadbackState classifySecondaryCapture( bool installedMap, bool remapRequired, bool opened, bool faulted, bool primaryEpochMatches, - std::uint64_t captureBlocks, std::uint64_t consumedBlocks) noexcept { + std::uint64_t captureBlocks, std::uint64_t recentUsableFrames) noexcept { if(remapRequired)return SecondaryCaptureReadbackState::needsRemap; if(!installedMap)return SecondaryCaptureReadbackState::notConfigured; if(!opened||faulted||!primaryEpochMatches) return SecondaryCaptureReadbackState::degraded; - if(!captureBlocks||!consumedBlocks) + if(!captureBlocks||!recentUsableFrames) return SecondaryCaptureReadbackState::waitingForPcm; return SecondaryCaptureReadbackState::pcmFlowObserved; } From 0a378d4b10562d81d816d29f4597e19ef646c8d1 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:16:01 +0700 Subject: [PATCH 05/29] fix(io3a): use recent valid ASRC frames and capture freshness for native B health --- src/LiveAudioEngine.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 2207d950b..f42598a8c 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -2753,9 +2753,22 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback std::memory_order_acquire); const bool epochMatches=b.primaryEpoch!=0 && b.primaryEpoch==dryRoutingLab_.epoch(); + // ASRC accepted pulls can render *only priming silence*. Require + // positive FIR-valid output and independently fresh capture writes. + // The CONTROL-only guard expires a silent/stalled B after 500 ms; + // cumulative historical counters never imply ongoing PCM. + const auto usableAsrcFrames=armix::device::secondaryUsableAsrcFrames( + b.clock.asrc.renderedFrames,b.clock.asrc.primingFrames, + b.clock.asrc.underflowFrames); + const auto recentlyUsed=secondaryFlowEvidence_.recentUsableFrames( + b.deviceLease,b.clock.captureBlocks,b.clock.asrc.renderedFrames, + b.clock.asrc.primingFrames,b.clock.asrc.underflowFrames, + juce::Time::getMillisecondCounterHiRes(), + bInstalled && !bNeedsRemap && b.ready && !b.faulted && + epochMatches); const auto captureState=armix::device::classifySecondaryCapture( bInstalled,bNeedsRemap,b.ready,b.faulted,epochMatches, - b.clock.captureBlocks,readerStatus.secondaryAccepted); + b.clock.captureBlocks,recentlyUsed); auto secondary=std::make_unique(); secondary->setProperty("role","INPUT_ONLY_ASIO"); secondary->setProperty("status", @@ -2788,6 +2801,14 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback static_cast(b.clock.captureBlocks)); secondary->setProperty("primaryConsumedBlocks", static_cast(readerStatus.secondaryAccepted)); + secondary->setProperty("asrcUsableFrames", + static_cast(usableAsrcFrames)); + secondary->setProperty("asrcPrimingFrames", + static_cast(b.clock.asrc.primingFrames)); + secondary->setProperty("asrcUnderflowFrames", + static_cast(b.clock.asrc.underflowFrames)); + secondary->setProperty("recentUsablePcm", + recentlyUsed>0); secondary->setProperty("silentPrimaryBlocks", static_cast(readerStatus.secondarySilent)); secondary->setProperty("sourceAudibleProven",false); @@ -3183,6 +3204,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback std::atomic qualifiedSecondaryInstalled_{false}; std::atomic qualifiedCaptureNeedsRemap_{false}; // device lifecycle invalidated B std::uint64_t secondaryLeaseSequence_=0; // CONTROL only, never callback + armix::device::SecondaryCaptureFlowEvidence secondaryFlowEvidence_; // CONTROL status only std::optional savedDirectSetup_; juce::AudioPluginFormatManager formats_; // Strong ownership stays on CONTROL. The admitted native ChannelId From d7aab5ceb92aed6bc31046a39e5612d2a3f0e659 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:16:43 +0700 Subject: [PATCH 06/29] test(io3a): reproduce real ASRC priming silence and stale capture clock in B readback --- .../QualifiedSecondaryCaptureReaderCases.h | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/io2/QualifiedSecondaryCaptureReaderCases.h b/tests/io2/QualifiedSecondaryCaptureReaderCases.h index bbc892dc8..e45c906ba 100644 --- a/tests/io2/QualifiedSecondaryCaptureReaderCases.h +++ b/tests/io2/QualifiedSecondaryCaptureReaderCases.h @@ -41,6 +41,31 @@ inline void run() { check(d::secondaryCaptureStateName(Health::pcmFlowObserved)== std::string_view("PCM_FLOW_OBSERVED"), "Readback state is stable and machine-readable"); + // A successful FIFO pull is not proof of sound: ASRC may output only + // priming (or later starvation) frames. Epoch/lease and time freshness + // are required for any positive B PCM flow observation. + check(d::secondaryUsableAsrcFrames(128,128,0)==0 && + d::secondaryUsableAsrcFrames(128,0,128)==0 && + d::secondaryUsableAsrcFrames(256,128,64)==64, + "Only ASRC FIR-valid frames count; priming and underflow excluded"); + d::SecondaryCaptureFlowEvidence evidence; + check(evidence.recentUsableFrames(22,0,0,0,0,100.,true)==0, + "Initial B lease observation is only a baseline"); + check(evidence.recentUsableFrames(22,1,128,128,0,110.,true)==0, + "Priming-only authenticated pulls must not advertise B PCM"); + check(evidence.recentUsableFrames(22,2,256,128,0,120.,true)==128, + "Both producer and actually usable consumer progress within 500ms"); + check(evidence.recentUsableFrames(22,2,384,128,0,700.,true)==0, + "Stopped B producer cannot remain FLOW_OBSERVED indefinitely"); + check(evidence.recentUsableFrames(23,100,500,0,0,710.,true)==0, + "Reconnect with new B lease cannot reuse accumulated PCM history"); + check(evidence.recentUsableFrames(23,101,628,128,0,720.,true)>0, + "Fresh B callback and ASRC after new lease restores flow evidence"); + check(evidence.recentUsableFrames(23,102,756,128,0,725.,false)==0, + "Faulted capture immediately invalidates timed flow evidence"); + check(evidence.recentUsableFrames(23,102,756,128,0,730.,true)==0, + "Recovery cannot reuse data accumulated before fault"); + // The host may select direct A or qualified A+B, never a partial bridge. check(d::qualifiedCaptureHostMode(false,false)== d::QualifiedCaptureHostMode::directPrimary, @@ -105,6 +130,31 @@ inline void run() { d::SecondaryCaptureClockStream clock; const d::SecondaryCaptureClockStream::Format format{ 44100.,48000.,frames,frames,2,captureGeneration,epoch,2002}; + // REAL clock/ASRC regression (not just mocked numbers): a successful + // read of one B block can be entirely priming silence. + { + d::SecondaryCaptureClockStream probeClock; + check(probeClock.prepare(format)&&probeClock.activate(), + "real ASRC priming probe prepared on control thread"); + std::array sourceL{},sourceR{},destL{},destR{}; + sourceL.fill(.4f);sourceR.fill(.6f); + const float* probeIn[]{sourceL.data(),sourceR.data()}; + float* probeOut[]{destL.data(),destR.data()}; + check(probeClock.push(probeIn,2,frames), + "one independent B producer block accepted"); + check(probeClock.pull(probeOut,2,frames, + captureGeneration,epoch,2002), + "B primary pull is authorized even while priming"); + const auto probe=probeClock.status(); + check(probe.asrc.renderedFrames==frames && + probe.asrc.primingFrames==frames && + d::secondaryUsableAsrcFrames( + probe.asrc.renderedFrames,probe.asrc.primingFrames, + probe.asrc.underflowFrames)==0, + "actual 44.1k->48k ASRC authorized pull has NO usable PCM"); + probeClock.stop(); + } + check(clock.prepare(format)&&clock.activate(),"independent 44.1k B into 48k A ASRC ready"); using Admission=d::QualifiedCaptureAdmission; check(Admission::verify(plan,clock,epoch,1,frames)==Admission::Fault::none, From a99c0e0a35052f9406492b180a0ee3820d64a3fc Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:17:02 +0700 Subject: [PATCH 07/29] test(io3a): verify new-lease usable frame delta instead of same cumulative count --- tests/io2/QualifiedSecondaryCaptureReaderCases.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/io2/QualifiedSecondaryCaptureReaderCases.h b/tests/io2/QualifiedSecondaryCaptureReaderCases.h index e45c906ba..9168267dd 100644 --- a/tests/io2/QualifiedSecondaryCaptureReaderCases.h +++ b/tests/io2/QualifiedSecondaryCaptureReaderCases.h @@ -59,7 +59,7 @@ inline void run() { "Stopped B producer cannot remain FLOW_OBSERVED indefinitely"); check(evidence.recentUsableFrames(23,100,500,0,0,710.,true)==0, "Reconnect with new B lease cannot reuse accumulated PCM history"); - check(evidence.recentUsableFrames(23,101,628,128,0,720.,true)>0, + check(evidence.recentUsableFrames(23,101,628,0,0,720.,true)>0, "Fresh B callback and ASRC after new lease restores flow evidence"); check(evidence.recentUsableFrames(23,102,756,128,0,725.,false)==0, "Faulted capture immediately invalidates timed flow evidence"); From ccaaedfd41e3f100d631b447f1d7afdbbdb390eb Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:41:11 +0700 Subject: [PATCH 08/29] feat(io3b): validate exact typed secondary ASIO capture intent against installed ChannelId graph --- integration/QualifiedCaptureConsoleIntent.h | 199 ++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 integration/QualifiedCaptureConsoleIntent.h diff --git a/integration/QualifiedCaptureConsoleIntent.h b/integration/QualifiedCaptureConsoleIntent.h new file mode 100644 index 000000000..4fc6c4745 --- /dev/null +++ b/integration/QualifiedCaptureConsoleIntent.h @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once + +#include "ApprovedNativeV8Projection.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// IO-3B native CONTROL-plane decoder for the *existing* approved console +// requestId/epoch/revision ABI. No audio device opens, allocations in audio, +// source preview ownership, optimistic ACK, secondary renderer or JS DSP. +// Only the message-thread device coordinator may use the validated proposal. +namespace armix::console { +struct QualifiedCaptureSourceIntent final { + std::uint64_t channelId=0; + bool secondary=false,stereo=false; + int left=-1,right=-1; // PHYSICAL indices, not JUCE callback ordinals +}; +struct QualifiedCaptureConsoleIntent final { + juce::String requestId,secondaryDriver; + juce::BigInteger secondaryPins; + double captureRate=0.; + int capturePeriod=0; + std::uint64_t deviceEpoch=0,graphRevision=0,rosterRevision=0; + std::vector sources; +}; +struct QualifiedCaptureConsoleDecode final { + QualifiedCaptureConsoleIntent command; + juce::String error; + bool ok() const noexcept {return error.isEmpty();} +}; + +inline bool qualifiedCaptureDecimal(const juce::var& value, + std::uint64_t& result) noexcept { + if(!nativeV8Decimal(value))return false; + const std::string s=value.toString().toStdString(); + std::uint64_t parsed=0; + const auto [end,code]=std::from_chars(s.data(),s.data()+s.size(),parsed); + if(code!=std::errc{}||end!=s.data()+s.size()||!parsed)return false; + result=parsed; + return true; +} +inline bool qualifiedCaptureInt(const juce::var& value,int lo,int hi, + int& result) noexcept { + if(!value.isInt())return false; + const int v=static_cast(value); + if(vhi)return false; + result=v; + return true; +} +inline bool qualifiedCaptureHasPin(const juce::var& pins,int pin) noexcept { + if(const auto* a=pins.getArray()) + for(const auto& item:*a) + if(item.isInt()&&static_cast(item)==pin)return true; + return false; +} + +// Pure, side-effect-free parse: exact installed graph is still checked again +// by the native engine immediately before any B driver open or publication. +inline QualifiedCaptureConsoleDecode decodeQualifiedCaptureConsoleIntent( + const juce::var& request,const juce::var& nativeSnapshot, + const juce::var& installedBus) { + const auto reject=[](const char* reason) { + QualifiedCaptureConsoleDecode failed; + failed.error=reason; + return failed; + }; + if(!request.isObject()||!nativeSnapshot.isObject()|| + !installedBus.isObject()|| + request.getProperty("operation","").toString()!="INSTALL_SECONDARY_CAPTURE") + return reject("INVALID_SECONDARY_CAPTURE_INTENT"); + const auto device=nativeSnapshot.getProperty("device",{}); + const auto graph=nativeSnapshot.getProperty("graph",{}); + const auto caps=graph.getProperty("capabilities",{}); + const auto payload=request.getProperty("payload",{}); + const auto graphRows=graph.getProperty("channels",{}); + const auto busRows=installedBus.getProperty("channels",{}); + const auto requestId=request.getProperty("requestId",{}); + const auto epochRaw=request.getProperty("deviceEpoch",{}); + const auto revisionRaw=request.getProperty("baseGraphRevision",{}); + const auto rosterRaw=request.getProperty("baseRosterRevision",{}); + if(!device.isObject()||!graph.isObject()||!caps.isObject()|| + !payload.isObject()||!graphRows.isArray()||!busRows.isArray()|| + !static_cast(caps.getProperty("callbackOwnsChannelIds",false))|| + device.getProperty("backend","").toString()!="ASIO"|| + !requestId.isString()|| + !requestId.toString().startsWith("io-capture-")|| + requestId.toString().length()>128|| + requestId.toString().length()<13|| + payload.getProperty("confirmed",{})!=juce::var(true)) + return reject("SECONDARY_CAPTURE_OPERATOR_OR_GRAPH_NOT_ADMITTED"); + if(!nativeV8Decimal(epochRaw)||!nativeV8Decimal(revisionRaw)|| + !nativeV8Decimal(rosterRaw)|| + epochRaw.toString()!=device.getProperty("epoch",{}).toString()|| + revisionRaw.toString()!=graph.getProperty("revision",{}).toString()|| + rosterRaw.toString()!=graph.getProperty("rosterRevision",{}).toString()|| + revisionRaw.toString()!=installedBus.getProperty("graphRevision",{}).toString()|| + rosterRaw.toString()!=installedBus.getProperty("rosterRevision",{}).toString()) + return reject("STALE_SECONDARY_CAPTURE_GRAPH"); + QualifiedCaptureConsoleIntent command; + if(!qualifiedCaptureDecimal(epochRaw,command.deviceEpoch)|| + !qualifiedCaptureDecimal(revisionRaw,command.graphRevision)|| + !qualifiedCaptureDecimal(rosterRaw,command.rosterRevision)) + return reject("INVALID_SECONDARY_CAPTURE_REVISION"); + command.requestId=requestId.toString(); + const auto driver=payload.getProperty("secondaryDriver",{}); + if(!driver.isString()||driver.toString().isEmpty()|| + driver.toString().length()>128|| + driver.toString().containsAnyOf("\r\n")) + return reject("INVALID_SECONDARY_DRIVER"); + command.secondaryDriver=driver.toString(); + const auto rate=payload.getProperty("captureRate",{}); + if(!nativeV8Number(rate,command.captureRate)|| + command.captureRate<8000.||command.captureRate>192000.|| + !qualifiedCaptureInt(payload.getProperty("capturePeriod",{}), + 32,8192,command.capturePeriod)) + return reject("INVALID_SECONDARY_CAPTURE_FORMAT"); + const auto physical=payload.getProperty("secondaryInputPins",{}); + const auto* physicalPins=physical.getArray(); + if(!physicalPins||physicalPins->isEmpty()||physicalPins->size()>16) + return reject("INVALID_SECONDARY_CAPTURE_PINS"); + int previous=-1; + for(const auto& raw:*physicalPins) { + int index=-1; + if(!qualifiedCaptureInt(raw,0,63,index)||index<=previous) + return reject("DUPLICATE_OR_UNSORTED_SECONDARY_CAPTURE_PIN"); + command.secondaryPins.setBit(index); + previous=index; + } + const auto rows=payload.getProperty("sources",{}); + const auto* sourceRows=rows.getArray(); + if(!sourceRows||sourceRows->isEmpty()||sourceRows->size()>64) + return reject("SECONDARY_CAPTURE_SOURCE_COUNT_INVALID"); + const auto primaryPins=device.getProperty("enabledInputs",{}); + if(!primaryPins.isArray()||!primaryPins.getArray()|| + primaryPins.getArray()->isEmpty()) + return reject("PRIMARY_CAPTURE_PINS_UNVERIFIED"); + bool usesSecondary=false; + for(const auto& row:*sourceRows) { + if(!row.isObject())return reject("INVALID_SECONDARY_SOURCE_ROW"); + QualifiedCaptureSourceIntent source; + if(!qualifiedCaptureDecimal(row.getProperty("channelId",{}), + source.channelId)) + return reject("INVALID_SECONDARY_SOURCE_CHANNEL_ID"); + const auto role=row.getProperty("deviceRole",{}); + const auto stereo=row.getProperty("stereo",{}); + if(!role.isString()|| + (role.toString()!="PRIMARY"&&role.toString()!="SECONDARY")|| + !stereo.isBool()) + return reject("INVALID_SECONDARY_SOURCE_ROLE"); + source.secondary=role.toString()=="SECONDARY"; + source.stereo=static_cast(stereo); + if(!qualifiedCaptureInt(row.getProperty("leftPhysical",{}),0,63, + source.left)) + return reject("INVALID_SECONDARY_SOURCE_LEFT"); + const auto right=row.getProperty("rightPhysical",{}); + if(source.stereo) { + if(!qualifiedCaptureInt(right,0,63,source.right)|| + source.left==source.right) + return reject("INVALID_SECONDARY_SOURCE_STEREO"); + }else if(!qualifiedCaptureInt(right,-1,-1,source.right)) + return reject("INVALID_SECONDARY_SOURCE_MONO"); + const auto permitted=[&](int pin) { + return source.secondary?command.secondaryPins[pin]: + qualifiedCaptureHasPin(primaryPins,pin); + }; + if(!permitted(source.left)|| + (source.stereo&&!permitted(source.right))) + return reject("SECONDARY_SOURCE_PIN_NOT_VERIFIED"); + bool input=false,installedInput=false; + for(const auto& installed:*graphRows.getArray()) { + if(installed.getProperty("id","").toString()== + row.getProperty("channelId",{}).toString() && + installed.getProperty("role","").toString()=="INPUT") + input=true; + } + for(const auto& native:*busRows.getArray()) { + if(native.getProperty("id","").toString()== + row.getProperty("channelId",{}).toString() && + native.getProperty("role","").toString()=="INPUT") + installedInput=true; + } + if(!input||!installedInput) + return reject("SECONDARY_CAPTURE_CHANNEL_NOT_INSTALLED"); + for(const auto& prior:command.sources) + if(prior.channelId==source.channelId) + return reject("DUPLICATE_SECONDARY_SOURCE_CHANNEL"); + usesSecondary=usesSecondary||source.secondary; + command.sources.push_back(source); + } + if(!usesSecondary)return reject("NO_SECONDARY_SOURCE_SELECTED"); + return {std::move(command),{}}; +} +} // namespace armix::console From 85a1321eb942b62c49671a5cb5c1fbff0263b281 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:42:13 +0700 Subject: [PATCH 09/29] feat(io3b): route typed explicit ASIO B install through existing console ACK/readback dispatcher --- src/Main.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 2c81ec318..fa6adfd5b 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -9,6 +9,7 @@ #include "ApprovedConsoleNativeTransportV6.h" #include "../integration/ApprovedNativeRuntimeSnapshot.h" #include "../integration/ApprovedNativeControlIntent.h" +#include "../integration/QualifiedCaptureConsoleIntent.h" #include "LiveAudioEngine.h" #include "NativeSessionToken.h" #include "ArSonMixStartupSplash.h" @@ -1824,11 +1825,47 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(acceptedControlRequests_.size()>512) acceptedControlRequests_.remove(0); } - const auto translated=armix::console::translateApprovedNativeControl( - request,before,installedBus); + const bool installingCapture= + request.getProperty("operation","").toString()=="INSTALL_SECONDARY_CAPTURE"; + const auto translated=installingCapture? + armix::console::ApprovedNativeControlIntent{}: + armix::console::translateApprovedNativeControl( + request,before,installedBus); bool applied=false; juce::String nativeError; - if(!replay&&translated.ok()) { + juce::String requestedSecondaryMask; + if(!replay&&installingCapture) { + const auto decoded=armix::console::decodeQualifiedCaptureConsoleIntent( + request,before,installedBus); + if(!decoded.ok())nativeError=decoded.error; + else if(nativeShowBusy_||studioBackupBusy_|| + engine_.isGraphSwitchPending()||mixerSessionWorker_.busy()) { + nativeError="SECONDARY_CAPTURE_TRANSACTION_BUSY"; + }else{ + std::vector sources; + sources.reserve(decoded.command.sources.size()); + for(const auto& src:decoded.command.sources) { + LiveAudioEngine::QualifiedPhysicalSourceChoice choice; + choice.channel=armix::mixer::ChannelId{src.channelId}; + choice.onSecondary=src.secondary; + choice.leftPhysical=src.left; + choice.rightPhysical=src.right; + choice.stereo=src.stereo; + sources.push_back(choice); + } + requestedSecondaryMask=decoded.command.secondaryPins.toString(16); + const auto result=engine_.installSecondaryAsioCapture( + decoded.command.secondaryDriver, + decoded.command.secondaryPins, + decoded.command.captureRate,decoded.command.capturePeriod, + decoded.command.deviceEpoch,decoded.command.graphRevision, + decoded.command.rosterRevision,sources); + applied=result.accepted; + if(!applied) + nativeError=result.error?juce::String(result.error): + juce::String("SECONDARY_CAPTURE_INSTALL_FAILED"); + } + }else if(!replay&&translated.ok()) { const auto command=translated.translated; if(command.getProperty("operation","").toString()=="NATIVE_LOAD_INSERT") { // Exactly one catalog-resolved vendor processor from the @@ -1875,7 +1912,26 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr const auto device=after.getProperty("device",{}); const auto graph=after.getProperty("graph",{}); const auto caps=graph.getProperty("capabilities",{}); - const bool nativeStillAdmitted=applied&&caps.isObject()&& + const auto secondary=after.getProperty("secondaryCapture",{}); + // A driver-open ACK is never a PCM/live-source claim. Exact B + // native readback must match the selected pin-mask, epoch and driver + // before accepting the structural graph transaction. The approved + // browser will demand a LATER matching producer snapshot. + const bool secondaryAccepted=!installingCapture|| + (secondary.isObject()&& + static_cast(secondary.getProperty("installedInputMap",false))&& + static_cast(secondary.getProperty("driverReady",false))&& + !static_cast(secondary.getProperty("driverFault",true))&& + !static_cast(secondary.getProperty("needsRemap",true))&& + static_cast(secondary.getProperty("primaryEpochMatches",false))&& + secondary.getProperty("primaryEpoch","").toString()== + request.getProperty("deviceEpoch","").toString()&& + secondary.getProperty("driver","").toString()== + request.getProperty("payload",{}).getProperty("secondaryDriver","").toString()&& + secondary.getProperty("activePinMaskHex","").toString()== + requestedSecondaryMask&& + secondary.getProperty("deviceLease","0").toString()!="0"); + const bool nativeStillAdmitted=applied&&caps.isObject()&&secondaryAccepted&& static_cast(caps.getProperty("callbackOwnsChannelIds",false))&& device.getProperty("epoch","0").toString()== request.getProperty("deviceEpoch","").toString(); @@ -1886,11 +1942,17 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr replay?"DUPLICATE_REQUEST_ID": translated.error.isNotEmpty()?translated.error: nativeError.isNotEmpty()?nativeError: + applied&&installingCapture?"SECONDARY_CAPTURE_READBACK_MISMATCH": applied?"NATIVE_CALLBACK_LOST":"NATIVE_PCM_MUTATION_REJECTED"); ack->setProperty("deviceEpoch",device.getProperty("epoch","0")); ack->setProperty("graphRevision",graph.getProperty("revision","0")); ack->setProperty("rosterRevision",graph.getProperty("rosterRevision","0")); ack->setProperty("productionCallbackLive",false); + if(installingCapture){ + // Diagnostics only, never a statement of ChannelId audibility. + ack->setProperty("secondaryCapture",secondary); + ack->setProperty("sourceAudibleProven",false); + } if(browser_.loaded) browser_.emitEventIfBrowserIsVisible("arMixConsoleAck", juce::var(ack.release())); From ac9aacc9bb9b0598981c3a8d8cd1841055eab0a2 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:43:01 +0700 Subject: [PATCH 10/29] test(io3b): canonical ChannelId A/B capture intent, stale epoch, duplicate pins and rejected unsafe routes --- tests/approved_native_v8_projection_test.cpp | 85 ++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index 744dfc406..4e8ed2a54 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -3,6 +3,7 @@ #include "../integration/ApprovedNativeV8Projection.h" #include "../src/ApprovedNativeV8Projection.h" #include "../integration/ApprovedNativeControlIntent.h" +#include "../integration/QualifiedCaptureConsoleIntent.h" #include "../integration/ApprovedNativeRuntimeSnapshot.h" #include "../integration/FirstSoundSignalEvidence.h" #if defined(NDEBUG) @@ -1045,7 +1046,91 @@ static void retainedDocumentDoesNotAdmitPcm() { assert(!projectRetainedNativeChannelIdGraph(snapshot,live)); } +static void qualifiedCaptureNativeIntentRegression() { + auto snap=canonicalSnapshot(); + auto bus=realBusReadbackFixture(); + snap.getProperty("device",{}).getDynamicObject()->setProperty("backend","ASIO"); + assert(projectApprovedNativeV8(snap,bus,true)); + auto valid=[]() { + return parse(R"JSON({ + "operation":"INSTALL_SECONDARY_CAPTURE", + "requestId":"io-capture-00001", + "deviceEpoch":"91", + "baseGraphRevision":"25", + "baseRosterRevision":"9", + "payload":{ + "confirmed":true, + "secondaryDriver":"Qualified B ASIO", + "secondaryInputPins":[0,7], + "captureRate":44100, + "capturePeriod":128, + "sources":[{ + "channelId":"9007199254740993", + "deviceRole":"SECONDARY", + "leftPhysical":7, + "rightPhysical":-1, + "stereo":false + }] + } + })JSON"); + }; + const auto accepted=decodeQualifiedCaptureConsoleIntent(valid(),snap,bus); + assert(accepted.ok()); + assert(accepted.command.requestId=="io-capture-00001"); + assert(accepted.command.deviceEpoch==91 && + accepted.command.graphRevision==25 && + accepted.command.rosterRevision==9); + assert(accepted.command.captureRate==44100.); + assert(accepted.command.capturePeriod==128); + assert(accepted.command.secondaryPins[0]&&accepted.command.secondaryPins[7]&& + accepted.command.secondaryPins.countNumberOfSetBits()==2); + assert(accepted.command.sources.size()==1); + assert(accepted.command.sources[0].channelId==9007199254740993ULL && + accepted.command.sources[0].secondary && + accepted.command.sources[0].left==7); + auto bad=valid(); + bad.getProperty("payload",{}).getDynamicObject()->setProperty("confirmed",false); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getDynamicObject()->setProperty("baseGraphRevision","24"); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getProperty("payload",{}).getDynamicObject()->setProperty( + "secondaryInputPins",parse(R"JSON({"p":[0,0]})JSON").getProperty("p",{})); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getProperty("payload",{}).getProperty("sources",{})[0].getDynamicObject() + ->setProperty("leftPhysical",3); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getProperty("payload",{}).getProperty("sources",{})[0].getDynamicObject() + ->setProperty("channelId","18446744073709551615"); // actual MAIN + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getProperty("payload",{}).getProperty("sources",{})[0].getDynamicObject() + ->setProperty("channelId","18446744073709551616"); // uint64 overflow + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getProperty("payload",{}).getProperty("sources",{})[0].getDynamicObject() + ->setProperty("deviceRole","PRIMARY"); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getProperty("payload",{}).getDynamicObject()->setProperty("capturePeriod",12); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getProperty("payload",{}).getProperty("sources",{})[0].getDynamicObject() + ->setProperty("stereo",true); + bad.getProperty("payload",{}).getProperty("sources",{})[0].getDynamicObject() + ->setProperty("rightPhysical",7); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); + bad.getDynamicObject()->setProperty("requestId","io-capture-0001"); + const auto wrongBackend=canonicalSnapshot(); // NOT ASIO and NOT admitted + assert(!decodeQualifiedCaptureConsoleIntent(bad,wrongBackend,bus).ok()); +} + int main() { + qualifiedCaptureNativeIntentRegression(); retainedDocumentDoesNotAdmitPcm(); auto snap=canonicalSnapshot(); auto bus=realBusReadbackFixture(); From 014b3d60d0fac528bf467ec0852feddee39456d2 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:50:22 +0700 Subject: [PATCH 11/29] fix(io3b): correlate accepted B capture ACK to installed exact PCM and roster revisions --- src/Main.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index fa6adfd5b..ab1447ad3 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1834,6 +1834,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr bool applied=false; juce::String nativeError; juce::String requestedSecondaryMask; + juce::String installedCaptureGraphRevision; + juce::String installedCaptureRosterRevision; if(!replay&&installingCapture) { const auto decoded=armix::console::decodeQualifiedCaptureConsoleIntent( request,before,installedBus); @@ -1861,7 +1863,12 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr decoded.command.deviceEpoch,decoded.command.graphRevision, decoded.command.rosterRevision,sources); applied=result.accepted; - if(!applied) + if(applied){ + installedCaptureGraphRevision= + juce::String(std::to_string(result.pcmRevision)); + installedCaptureRosterRevision= + juce::String(std::to_string(result.rosterRevision)); + }else nativeError=result.error?juce::String(result.error): juce::String("SECONDARY_CAPTURE_INSTALL_FAILED"); } @@ -1930,7 +1937,11 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr request.getProperty("payload",{}).getProperty("secondaryDriver","").toString()&& secondary.getProperty("activePinMaskHex","").toString()== requestedSecondaryMask&& - secondary.getProperty("deviceLease","0").toString()!="0"); + secondary.getProperty("deviceLease","0").toString()!="0"&& + graph.getProperty("revision","").toString()== + installedCaptureGraphRevision&& + graph.getProperty("rosterRevision","").toString()== + installedCaptureRosterRevision); const bool nativeStillAdmitted=applied&&caps.isObject()&&secondaryAccepted&& static_cast(caps.getProperty("callbackOwnsChannelIds",false))&& device.getProperty("epoch","0").toString()== From fd657b5c3daba48f718e13cdae7107c957cc1cf3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 04:51:00 +0700 Subject: [PATCH 12/29] fix(io3b): accept existing opaque v8 session requestIds; keep replay guard in single dispatcher --- integration/QualifiedCaptureConsoleIntent.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/integration/QualifiedCaptureConsoleIntent.h b/integration/QualifiedCaptureConsoleIntent.h index 4fc6c4745..659cc0e19 100644 --- a/integration/QualifiedCaptureConsoleIntent.h +++ b/integration/QualifiedCaptureConsoleIntent.h @@ -88,10 +88,8 @@ inline QualifiedCaptureConsoleDecode decodeQualifiedCaptureConsoleIntent( !payload.isObject()||!graphRows.isArray()||!busRows.isArray()|| !static_cast(caps.getProperty("callbackOwnsChannelIds",false))|| device.getProperty("backend","").toString()!="ASIO"|| - !requestId.isString()|| - !requestId.toString().startsWith("io-capture-")|| + !requestId.isString()||requestId.toString().isEmpty()|| requestId.toString().length()>128|| - requestId.toString().length()<13|| payload.getProperty("confirmed",{})!=juce::var(true)) return reject("SECONDARY_CAPTURE_OPERATOR_OR_GRAPH_NOT_ADMITTED"); if(!nativeV8Decimal(epochRaw)||!nativeV8Decimal(revisionRaw)|| From dcd1aedc6c77fcd41c5c44315618eaf626e86e8f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 05:03:09 +0700 Subject: [PATCH 13/29] fix(io3b): bind capture install request targetChannelId to installed B-source ChannelId --- integration/QualifiedCaptureConsoleIntent.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/integration/QualifiedCaptureConsoleIntent.h b/integration/QualifiedCaptureConsoleIntent.h index 659cc0e19..57a7326e1 100644 --- a/integration/QualifiedCaptureConsoleIntent.h +++ b/integration/QualifiedCaptureConsoleIntent.h @@ -27,6 +27,7 @@ struct QualifiedCaptureConsoleIntent final { double captureRate=0.; int capturePeriod=0; std::uint64_t deviceEpoch=0,graphRevision=0,rosterRevision=0; + std::uint64_t targetChannelId=0; // exact approved v8 INPUT target std::vector sources; }; struct QualifiedCaptureConsoleDecode final { @@ -103,7 +104,9 @@ inline QualifiedCaptureConsoleDecode decodeQualifiedCaptureConsoleIntent( QualifiedCaptureConsoleIntent command; if(!qualifiedCaptureDecimal(epochRaw,command.deviceEpoch)|| !qualifiedCaptureDecimal(revisionRaw,command.graphRevision)|| - !qualifiedCaptureDecimal(rosterRaw,command.rosterRevision)) + !qualifiedCaptureDecimal(rosterRaw,command.rosterRevision)|| + !qualifiedCaptureDecimal(request.getProperty("targetChannelId",{}), + command.targetChannelId)) return reject("INVALID_SECONDARY_CAPTURE_REVISION"); command.requestId=requestId.toString(); const auto driver=payload.getProperty("secondaryDriver",{}); @@ -192,6 +195,14 @@ inline QualifiedCaptureConsoleDecode decodeQualifiedCaptureConsoleIntent( command.sources.push_back(source); } if(!usesSecondary)return reject("NO_SECONDARY_SOURCE_SELECTED"); + // The existing v8 controller's one ChannelId target must be the + // actually selected B source. Do not allow a misleading main/primary + // target to acquire ACK for a different channel's physical binding. + bool targetIsSecondary=false; + for(const auto& source:command.sources) + if(source.channelId==command.targetChannelId && source.secondary) + targetIsSecondary=true; + if(!targetIsSecondary)return reject("SECONDARY_CAPTURE_TARGET_MISMATCH"); return {std::move(command),{}}; } } // namespace armix::console From 25723428dc13a4b0f4ac111249f94e36e0a0a9ae Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 05:03:27 +0700 Subject: [PATCH 14/29] test(io3b): exact B-source target and opaque v8 requestId, reject mismatched MAIN target --- tests/approved_native_v8_projection_test.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index 4e8ed2a54..70a43e845 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -1054,6 +1054,7 @@ static void qualifiedCaptureNativeIntentRegression() { auto valid=[]() { return parse(R"JSON({ "operation":"INSTALL_SECONDARY_CAPTURE", + "targetChannelId":"9007199254740993", "requestId":"io-capture-00001", "deviceEpoch":"91", "baseGraphRevision":"25", @@ -1079,7 +1080,13 @@ static void qualifiedCaptureNativeIntentRegression() { assert(accepted.command.requestId=="io-capture-00001"); assert(accepted.command.deviceEpoch==91 && accepted.command.graphRevision==25 && - accepted.command.rosterRevision==9); + accepted.command.rosterRevision==9 && + accepted.command.targetChannelId==9007199254740993ULL); + // Reuse the approved v8 session's opaque requestId rather than a + // second JS-side command sequence or an IO-specific prefix requirement. + auto alternate=valid(); + alternate.getDynamicObject()->setProperty("requestId","session-control-42"); + assert(decodeQualifiedCaptureConsoleIntent(alternate,snap,bus).ok()); assert(accepted.command.captureRate==44100.); assert(accepted.command.capturePeriod==128); assert(accepted.command.secondaryPins[0]&&accepted.command.secondaryPins[7]&& @@ -1092,6 +1099,9 @@ static void qualifiedCaptureNativeIntentRegression() { bad.getProperty("payload",{}).getDynamicObject()->setProperty("confirmed",false); assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); bad=valid(); + bad.getDynamicObject()->setProperty("targetChannelId","18446744073709551615"); + assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); + bad=valid(); bad.getDynamicObject()->setProperty("baseGraphRevision","24"); assert(!decodeQualifiedCaptureConsoleIntent(bad,snap,bus).ok()); bad=valid(); From d702d019b0fef7dfa747c348bb96eeb91f16fd65 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 05:04:13 +0700 Subject: [PATCH 15/29] docs(io3b): exact native capture request/ACK contract and explicit unimplemented UI/persistence gates --- ...ONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md diff --git a/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md b/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md new file mode 100644 index 000000000..e76d01015 --- /dev/null +++ b/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md @@ -0,0 +1,50 @@ +# IO-3B — Typed secondary ASIO capture control (native-only integration contract) + +**Scope:** approved ArSonMix `/preview/` **single** v8 console request/ACK/readback transport; Windows JUCE primary ASIO A plus one independently-clocked input-only ASIO B. **Not yet an operator-facing GUI or physical FAT result.** Cross-workstream source: [multi-device ARD](../ARD_ARSONMIX_MULTI_DEVICE_IO_V2_20261118.md), [coordination #812](https://github.com/masarray/arsonmix/issues/812). + +## Native command (implemented source boundary, not enabled in published picker) + +```json +{ + "operation":"INSTALL_SECONDARY_CAPTURE", + "requestId":"", + "deviceEpoch":"91", + "baseGraphRevision":"25", + "baseRosterRevision":"9", + "targetChannelId":"9007199254740993", + "payload":{ + "confirmed":true, + "secondaryDriver":"", + "secondaryInputPins":[0,7], + "captureRate":44100, + "capturePeriod":128, + "sources":[ + {"channelId":"9007199254740993","deviceRole":"SECONDARY", + "leftPhysical":7,"rightPhysical":-1,"stereo":false} + ] + } +} +``` + +All IDs are **canonical uint64 decimal strings**; do not round through JavaScript Number. `targetChannelId` must be an installed INPUT that is actually assigned to B in the `sources` list. Every source row must refer to an exact installed ChannelId and a selected, observed native **physical** input index (not a dense JUCE callback ordinal). `secondaryInputPins` must be unique, sorted, 1–16 channels and within supported driver bit bounds. `PRIMARY` input rows, when needed to preserve currently accepted A channels, use the accepted A physical mask. Incomplete A/B rows are rejected by the native qualified graph compiler. + +The native CONTROL decoder `integration/QualifiedCaptureConsoleIntent.h` checks the exact installed public graph, matching internal nativeBus revision/roster, operator confirmation, requestId and input roles. The one `Main.cpp::handleApprovedNativeControl` dispatcher invokes `LiveAudioEngine::installSecondaryAsioCapture`, which **rechecks** actual ASIO driver identity, registration class, current A/B pins, negotiated sample rate/buffer and native leases before publishing one ChannelId PCM/FX owner. Outputs must already be disarmed; **no speaker is auto-armed**. + +## ACK and later readback + +The existing `arMixConsoleAck` replies with requestId, `status` ACCEPTED/REJECTED, errorCode and installed deviceEpoch/graphRevision/rosterRevision. Native controller also includes `secondaryCapture` diagnostics (driver, physical mask, generation, lease, clock and fault) on this operation. ACK acceptance requires verified installed B capture readback, not merely driver `open()` success, and `productionCallbackLive` / `sourceAudibleProven` remain **false**. The approved consumer must request a *later* `arMixConsoleSnapshot` and verify the same B identity, mask, epoch, lease, ChannelId map and advanced graph revision. `WAITING_FOR_PCM` and `PCM_FLOW_OBSERVED` are native diagnostics, **not proof that the assigned channel is audible**; priming/underflow frames do not count as B PCM. + +**Important integration gap:** The current browser `web/approved-native-contract.js::readbackProvesIntent` does not yet recognize `INSTALL_SECONDARY_CAPTURE` and the published Source Picker does not expose this operation. **Do not advertise it as usable or activate via an unreviewed JS side path.** Follow-up IO-3C must implement the approved controller capability + exact later readback with canonical Pages generated assets and Chromium tests in one vertical slice. Do not add a second WebView event bus or standalone preview. + +## Persistence, fallback and hardware qualification + +Current v1 `.smix` cannot store both physical driver identities/pins. While a qualified A+B graph is installed, Save/autosave is intentionally **rejected before replacing the last known-good file**. Explicit loading of a saved primary-only `.smix` now uses `QualifiedMapChange::replaceWithPrimaryOnly` under a fully muted native transaction, returning to direct A PCM and retiring the B capture reader **only after** successful publication; WIRE/FX-only edits continue inheriting the exact qualified B map. This is a safe temporary guard, not an IO-5 persistence implementation. + +Real simultaneous two-vendor ASIO input PCM, CLI driver open constraints, Windows installer, latency and hardware FAT remain **NOT RUN**. The synthetic native fixtures prove graph/ASRC policy, not hardware compatibility or actual acoustic performance. Independently routed BUS/CH Device B output remains a future scope, not the existing WASAPI MAIN mirror. + +## Required follow-up + +1. Parent IO-2D #825 exact-head Windows MSVC/CTest + Codex + protected Required CI Gate, then merge. +2. Reconcile stacked #830 with *latest main*, run its own exact-head Windows and approved GUI gates. +3. IO-3C actual compact Device B picker and later accepted readback in existing approved `/preview/` only; regenerate canonical embedded GUI with scripts and test compiled resources. +4. IO-5 durable physical binding schema and offline remap before enabling A+B Save; physical two-vendor ASIO FAT before shipping product capability. From bb749fe4efa2150fb9d5c3941e618b0c983ec138 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 07:31:25 +0700 Subject: [PATCH 16/29] fix(io3a): forward real ASIO B readback into approved native console snapshot Fix native install ACK always being rejected because LiveAudioEngine B status was not projected to approvedNativeSnapshot. Publish only engine-issued CONTROL status in the existing v8 snapshot and test positive/negative identity projection without manufacturing PCM/audibility. --- integration/ApprovedNativeRuntimeSnapshot.h | 16 +++++++++++++ src/Main.cpp | 2 ++ tests/approved_native_v8_projection_test.cpp | 24 ++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index 2ce7c450b..35356e6bc 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -10,6 +10,22 @@ // its installed realtime callback owns the accepted publisher/epoch. // G0/M4 and any forged nativeBus without that predicate MUST stay unadmitted. namespace armix::console { +// IO-3A: project only genuine native engine status into the ONE approved +// CONTROL snapshot. No browser-selected device, DSP graph or positive LIVE +// state is manufactured by this diagnostic projection. +inline bool projectSecondaryCaptureNativeReadback( + juce::var& approved,const juce::var& live) { + if(!approved.isObject()||!live.isObject()|| + !approved.getProperty("device",{}).isObject())return false; + const auto secondary=live.getProperty("secondaryCapture",{}); + if(!secondary.isObject() || + secondary.getProperty("role","").toString()!="INPUT_ONLY_ASIO" || + !secondary.getProperty("status",{}).isString() || + !secondary.getProperty("installedInputMap",{}).isBool())return false; + approved.getDynamicObject()->setProperty("secondaryCapture",secondary); + return true; +} + // Legacy M2 counted only device START callbacks; the actual routing epoch // also advances on STOP. After ASIO/WASAPI re-open they can differ (e.g., // G0 start=2 while accepted routing epoch=3). Always use the installed diff --git a/src/Main.cpp b/src/Main.cpp index 85384fcfd..a52550294 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1725,6 +1725,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr (void) armix::console::projectRetainedNativeChannelIdGraph (accepted, live); } armix::console::publishAuthoritativeMixerSession(accepted); + // Project B readback from the same engine-issued control snapshot. + (void)armix::console::projectSecondaryCaptureNativeReadback(accepted,live); const auto caps=accepted.getProperty("graph",{}) .getProperty("capabilities",{}); const auto authority=accepted.getProperty("mixerSession",{}) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index 70a43e845..8e39301c9 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -1139,7 +1139,31 @@ static void qualifiedCaptureNativeIntentRegression() { assert(!decodeQualifiedCaptureConsoleIntent(bad,wrongBackend,bus).ok()); } +static void nativeSecondaryCaptureStatusProjectionTest() { + auto approved=canonicalSnapshot(); + auto real=parse(R"JSON({"secondaryCapture":{ + "role":"INPUT_ONLY_ASIO","status":"WAITING_FOR_PCM", + "installedInputMap":true,"driver":"ASIO B", + "deviceLease":"9007199254740993","primaryEpoch":"91", + "activePinMaskHex":"81","sourceAudibleProven":false + }})JSON"); + assert(projectSecondaryCaptureNativeReadback(approved,real)); + const auto observed=approved.getProperty("secondaryCapture",{}); + assert(observed.isObject() && + observed.getProperty("deviceLease","").toString()=="9007199254740993" && + observed.getProperty("driver","").toString()=="ASIO B" && + !static_cast(observed.getProperty("sourceAudibleProven",true))); + const auto fake=parse(R"JSON({"secondaryCapture":{ + "role":"SECOND_RENDER","status":"PCM_FLOW_OBSERVED", + "installedInputMap":true}})JSON"); + assert(!projectSecondaryCaptureNativeReadback(approved,fake) && + approved.getProperty("secondaryCapture",{}).getProperty("driver","").toString()=="ASIO B"); + const auto none=parse(R"JSON({"secondaryCapture":null})JSON"); + assert(!projectSecondaryCaptureNativeReadback(approved,none)); +} + int main() { + nativeSecondaryCaptureStatusProjectionTest(); qualifiedCaptureNativeIntentRegression(); retainedDocumentDoesNotAdmitPcm(); auto snap=canonicalSnapshot(); From 8a79992fa154fcf4d33c9c03a445a7edf39bbdc6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 07:46:49 +0700 Subject: [PATCH 17/29] feat(io3c): correlate ASIO B ACK to later hardware lease readback in sole v8 controller --- web/approved-native-contract.js | 62 ++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/web/approved-native-contract.js b/web/approved-native-contract.js index b13705bbf..6b70a9215 100644 --- a/web/approved-native-contract.js +++ b/web/approved-native-contract.js @@ -311,6 +311,40 @@ } return rows; } + // IO-3B: the stable native device B lease is created only AFTER driver + // verification. ACK carries this native-issued token; a second, later + // independent snapshot must match it along with actual hardware masks. + // Never consider driver-open as ChannelId PCM or audible source proof. + function secondaryCaptureLeaseEvidence(status,payload,epoch) { + if(!object(status)||!object(payload)|| + typeof payload.secondaryDriver!=="string" || + typeof status.driver!=="string" || + status.driver!==payload.secondaryDriver || + status.role!=="INPUT_ONLY_ASIO" || + status.installedInputMap!==true ||status.driverReady!==true || + status.driverFault!==false ||status.needsRemap!==false || + status.primaryEpochMatches!==true || + status.primaryEpoch!==epoch ||decimal(status.deviceLease)===null || + status.deviceLease==="0" ||decimal(status.captureGeneration)===null || + status.captureGeneration==="0" || + !Number.isFinite(payload.captureRate) || + status.captureRate!==payload.captureRate || + !Number.isInteger(payload.capturePeriod) || + status.capturePeriod!==payload.capturePeriod || + !Array.isArray(payload.secondaryInputPins) || + payload.secondaryInputPins.length<1 || + payload.secondaryInputPins.length>16 || + payload.secondaryInputPins.some((pin,i)=>!Number.isInteger(pin) || + pin<0||pin>63||(i>0&&pin<=payload.secondaryInputPins[i-1]))) + return null; + let mask=0n; + for(const pin of payload.secondaryInputPins)mask|=1n<c.id===targetChannelId); if (!ch) return false; + if (operation==="INSTALL_SECONDARY_CAPTURE") { + if(ch.role!=="INPUT"||payload.confirmed!==true || + !Array.isArray(payload.sources) || + !payload.sources.some(source=>object(source) && + source.channelId===targetChannelId && + source.deviceRole==="SECONDARY") || + cmp(next.graph.revision,pending.baseGraphRevision)<=0 || + !pending.ack?.secondaryLease)return false; + const fresh=secondaryCaptureLeaseEvidence( + next.raw?.secondaryCapture,payload,next.device.epoch); + const ack=pending.ack.secondaryLease; + return !!fresh && Object.keys(ack).every(key=>fresh[key]===ack[key]); + } if (operation === "SET_INPUT_GAIN") return ch.role==="INPUT" && Number.isFinite(payload.valueDb) && Number.isFinite(ch.controls?.inputGainDb) && @@ -781,8 +828,21 @@ cmp(raw.rosterRevision,pending.baseRosterRevision) < 0) { pending=null;lastError="STALE_NATIVE_ACK";subscribe();notify();return false; } + let secondaryLease=null; + if(pending.operation==="INSTALL_SECONDARY_CAPTURE") { + secondaryLease=secondaryCaptureLeaseEvidence( + raw.secondaryCapture,pending.payload,raw.deviceEpoch); + if(!secondaryLease || + !pending.payload.sources?.some(row=>object(row) && + row.channelId===pending.targetChannelId && + row.deviceRole==="SECONDARY") || + cmp(raw.graphRevision,pending.baseGraphRevision)<=0) { + pending=null;lastError="INVALID_SECONDARY_CAPTURE_ACK"; + subscribe();notify();return false; + } + } pending.ack={deviceEpoch:raw.deviceEpoch,graphRevision:raw.graphRevision, - rosterRevision:raw.rosterRevision}; + rosterRevision:raw.rosterRevision,secondaryLease}; lastError="PENDING_ACCEPTED_SNAPSHOT";notify(); // Reject ACK-only "success": explicitly request a LATER independent readback. subscribe(); From af40b8e7f1f49085f64c50de0dd9fb9d029e2be0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 07:47:38 +0700 Subject: [PATCH 18/29] test(io3c): reject ACK-only B sound and mismatched later driver/pin/epoch/lease readback --- tests/approved_native_m2_contract.test.cjs | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 7471f7d41..850b63213 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -29,6 +29,79 @@ function gmv20AcceptedGraph() { return fixture; } +test("IO-3C native B device capture needs matching ACK AND later independent lease readback",()=>{ + const base=gmv20AcceptedGraph(); + base.device.backend="ASIO"; + base.device.outputArmed=false; + base.graph.capabilities.supportedOps.push("INSTALL_SECONDARY_CAPTURE"); + const source=base.graph.channels.find(c=>c.role==="INPUT").id; + const payload={confirmed:true,secondaryDriver:"B ASIO", + captureRate:44100,capturePeriod:128,secondaryInputPins:[0,7], + sources:[{channelId:source,deviceRole:"SECONDARY", + leftPhysical:7,rightPhysical:-1,stereo:false}]}; + const health={role:"INPUT_ONLY_ASIO",status:"WAITING_FOR_PCM", + installedInputMap:true,driverReady:true,driverFault:false, + needsRemap:false,primaryEpochMatches:true, + primaryEpoch:base.device.epoch,deviceLease:"9007199254740993", + captureGeneration:"9007199254740994",driver:"B ASIO", + captureRate:44100,capturePeriod:128,activePinMaskHex:"81", + sourceAudibleProven:false,recentUsablePcm:false}; + const later=clone(base); + later.graph.revision=String(BigInt(base.graph.revision)+1n); + later.secondaryCapture=clone(health); + const make=()=>{ + const emitted=[],accepted=[]; + const ctl=protocol.createController({emit:(name,payload)=>emitted.push({name,payload}), + onAccepted:(snap,pending)=>accepted.push({snap,pending})}); + assert.equal(ctl.onSnapshot(clone(base)),true); + const command=ctl.intent("INSTALL_SECONDARY_CAPTURE",source,payload); + assert.equal(command.ok,true,"use same opaque v8 requestId transport"); + const ack={requestId:command.requestId,status:"ACCEPTED",errorCode:"NONE", + deviceEpoch:base.device.epoch,graphRevision:later.graph.revision, + rosterRevision:base.graph.rosterRevision,secondaryCapture:clone(health)}; + return {ctl,emitted,accepted,ack}; + }; + const yes=make(); + assert.equal(yes.ctl.onSnapshot(clone(later)),true, + "unsolicited B snapshot cannot settle un-ACKed operator intent"); + assert.equal(yes.ctl.state().pending?.operation,"INSTALL_SECONDARY_CAPTURE"); + assert.equal(yes.ctl.onAck(clone(yes.ack)),true); + assert.equal(yes.accepted.length,1,"ACK never promotes PCM"); + assert.equal(yes.ctl.onSnapshot(clone(later)),true); + assert.equal(yes.accepted.length,2); + assert.equal(yes.accepted[1].pending.operation,"INSTALL_SECONDARY_CAPTURE"); + assert.equal(yes.ctl.state().lastError,"ACCEPTED_READBACK"); + assert.equal(yes.emitted.filter(x=>x.name==="arMixConsoleIntent").length,1); + assert.ok(yes.emitted.filter(x=>x.name==="arMixConsoleSubscribe").length>=1); + assert.equal(yes.ctl.onAck(clone(yes.ack)),false,"replayed ACK rejected"); + for(const field of ["deviceLease","captureGeneration","driver", + "activePinMaskHex","captureRate","capturePeriod","driverReady", + "primaryEpochMatches","needsRemap","installedInputMap"]) { + const another=make(),corrupted=clone(later); + corrupted.secondaryCapture[field]=field==="driverReady"?false: + field==="primaryEpochMatches"?false:field==="needsRemap"?true: + field==="installedInputMap"?false:field==="driver"?"Other ASIO": + field==="activePinMaskHex"?"1":field==="captureRate"?48000: + field==="capturePeriod"?256:"1"; + assert.equal(another.ctl.onAck(clone(another.ack)),true); + assert.equal(another.ctl.onSnapshot(corrupted),false, + field+" mismatch must not claim native B installed"); + assert.equal(another.ctl.state().lastError,"ACK_READBACK_EFFECT_MISMATCH"); + assert.equal(another.accepted.length,1,"the last accepted A graph stays intact"); + } + for(const bad of [ + {driverReady:false},{deviceLease:"0"},{activePinMaskHex:"1"}, + {driver:"Unselected"},{captureGeneration:"0"},{primaryEpochMatches:false} + ]) { + const another=make(),ack=clone(another.ack); + Object.assign(ack.secondaryCapture,bad); + assert.equal(another.ctl.onAck(ack),false, + "false B-driver ACK rejected without waiting for fake PCM"); + assert.equal(another.ctl.state().lastError,"INVALID_SECONDARY_CAPTURE_ACK"); + assert.equal(another.accepted.length,1); + } +}); + test("G-MV25 schema-v6 owner switch cancels no-ACK/ACKed ChannelId without stale PCM repaint",()=>{ const base=gmv20AcceptedGraph(); base.mixerSession={authority:"CHANNEL_ID",deviceEpoch:base.device.epoch, From cc5145ccb57130fed090d3c82362f28a08d4d082 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 07:50:01 +0700 Subject: [PATCH 19/29] docs(io3c): record exact native B ACK+later v8 lease readback and remaining picker gap --- .../IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md b/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md index e76d01015..da363937e 100644 --- a/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md +++ b/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md @@ -34,7 +34,7 @@ The native CONTROL decoder `integration/QualifiedCaptureConsoleIntent.h` checks The existing `arMixConsoleAck` replies with requestId, `status` ACCEPTED/REJECTED, errorCode and installed deviceEpoch/graphRevision/rosterRevision. Native controller also includes `secondaryCapture` diagnostics (driver, physical mask, generation, lease, clock and fault) on this operation. ACK acceptance requires verified installed B capture readback, not merely driver `open()` success, and `productionCallbackLive` / `sourceAudibleProven` remain **false**. The approved consumer must request a *later* `arMixConsoleSnapshot` and verify the same B identity, mask, epoch, lease, ChannelId map and advanced graph revision. `WAITING_FOR_PCM` and `PCM_FLOW_OBSERVED` are native diagnostics, **not proof that the assigned channel is audible**; priming/underflow frames do not count as B PCM. -**Important integration gap:** The current browser `web/approved-native-contract.js::readbackProvesIntent` does not yet recognize `INSTALL_SECONDARY_CAPTURE` and the published Source Picker does not expose this operation. **Do not advertise it as usable or activate via an unreviewed JS side path.** Follow-up IO-3C must implement the approved controller capability + exact later readback with canonical Pages generated assets and Chromium tests in one vertical slice. Do not add a second WebView event bus or standalone preview. +**IO-3C controller milestone (implemented, fast tested):** The existing `web/approved-native-contract.js::readbackProvesIntent` now recognizes `INSTALL_SECONDARY_CAPTURE`, but only when a previously correlated native `arMixConsoleAck` supplied the exact installed Device B lease and a **later independent** `arMixConsoleSnapshot.secondaryCapture` matches driver class/name, verified physical mask, capture generation, device lease, epoch, rate and period. `WAITING_FOR_PCM` is a valid *installed but not yet flowing* state, **never proof of audible ChannelId signal**. The test in `tests/approved_native_m2_contract.test.cjs` covers stale/forged ACK, wrong mask, mismatched lease, mismatched driver and failure to publish optimistic PCM. Fast UI, Fast Native, M1–M2 and ImerSip P9 PASS for commit `af40b8e7`. The public `/preview/` Source Picker still does not expose this operation, and `graph.capabilities.supportedOps` does not yet advertise it; therefore **the user cannot activate B in the GUI**. Follow-up must deliver the approved operator UI with verified driver inventory, capability, canonical Pages generation and full Chromium/Windows tests. No second WebView event bus or standalone preview. ## Persistence, fallback and hardware qualification From 8ebe0a260463c9b798178b5164875543d3174e68 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:33:26 +0700 Subject: [PATCH 20/29] feat(io3d): advertise Device B intent only from verified disarmed ASIO native state --- integration/ApprovedNativeRuntimeSnapshot.h | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index 35356e6bc..e6a72fa03 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -26,6 +26,55 @@ inline bool projectSecondaryCaptureNativeReadback( return true; } +// IO-3D: an installed primary ChannelId callback may *offer* an explicitly +// confirmed Device B capture transaction. The existing native engine is still +// the final authority: offering the op is NOT an ASIO driver compatibility, +// audible PCM, saved session, or physical dual-device FAT claim. +// This only enriches the ONE approved v8 capability array; no extra transport. +inline bool publishQualifiedSecondaryCaptureCapability( + juce::var& approved,const juce::var& live,bool controlIdle) { + if(!controlIdle||!approved.isObject()||!live.isObject())return false; + const auto device=approved.getProperty("device",{}); + const auto graph=approved.getProperty("graph",{}); + const auto caps=graph.getProperty("capabilities",{}); + const auto secondary=live.getProperty("secondaryCapture",{}); + if(!device.isObject()||!graph.isObject()||!caps.isObject()|| + !secondary.isObject()|| + device.getProperty("backend","").toString()!="ASIO"|| + device.getProperty("outputArmed",juce::var(true))!=juce::var(false)|| + !static_cast(caps.getProperty("callbackOwnsChannelIds",false))|| + !static_cast(live.getProperty("directRouteAuthorized",false))|| + static_cast(live.getProperty("adaptiveClockActive",true))|| + live.getProperty("asioRegistryAttestation","").toString().isEmpty()|| + live.getProperty("asioRegistryAttestation","").toString()=="NONE"|| + secondary.getProperty("role","").toString()!="INPUT_ONLY_ASIO"|| + static_cast(secondary.getProperty("installedInputMap",true))|| + static_cast(secondary.getProperty("driverReady",true))|| + static_cast(secondary.getProperty("driverFault",true))) + return false; + const auto state=secondary.getProperty("status","").toString(); + if(state!="NOT_CONFIGURED"&&state!="NEEDS_REMAP")return false; + const auto pins=device.getProperty("enabledInputs",{}); + const auto channels=graph.getProperty("channels",{}); + const auto ops=caps.getProperty("supportedOps",{}); + if(!pins.isArray()||pins.getArray()->isEmpty()|| + !channels.isArray()||!ops.isArray())return false; + bool hasInput=false; + for(const auto& ch:*channels.getArray()) + if(ch.getProperty("role","").toString()=="INPUT") { + hasInput=true;break; + } + if(!hasInput)return false; + auto verified=*ops.getArray(); + if(!verified.contains(juce::String("INSTALL_SECONDARY_CAPTURE"))) + verified.add(juce::String("INSTALL_SECONDARY_CAPTURE")); + if(auto* c=caps.getDynamicObject()) { + c->setProperty("supportedOps",juce::var(verified)); + return true; + } + return false; +} + // Legacy M2 counted only device START callbacks; the actual routing epoch // also advances on STOP. After ASIO/WASAPI re-open they can differ (e.g., // G0 start=2 while accepted routing epoch=3). Always use the installed From 60a54b3e0b8cecc0d63eec4d9a876499cfc5a03a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:33:43 +0700 Subject: [PATCH 21/29] feat(io3d): publish qualified Device B request capability from native session owner --- src/Main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index a52550294..9b419d6c5 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1727,6 +1727,13 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr armix::console::publishAuthoritativeMixerSession(accepted); // Project B readback from the same engine-issued control snapshot. (void)armix::console::projectSecondaryCaptureNativeReadback(accepted,live); + // IO-3D: one CONTROL-owned installed ASIO capability. Do not advertise + // a B command on unadmitted, armed, stale or busy primary sessions. + // The engine rechecks all physical leases at the actual driver open. + (void)armix::console::publishQualifiedSecondaryCaptureCapability( + accepted,live, + !deviceApply_.busy()&&!nativeShowBusy_&&!studioBackupBusy_&& + !engine_.isGraphSwitchPending()&&!mixerSessionWorker_.busy()); const auto caps=accepted.getProperty("graph",{}) .getProperty("capabilities",{}); const auto authority=accepted.getProperty("mixerSession",{}) From 51659f0af2e2e34acd367208cfc15d5f65485d1e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:33:59 +0700 Subject: [PATCH 22/29] fix(io3d): reject Device B control commands absent from exact native advertised capability --- integration/QualifiedCaptureConsoleIntent.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/integration/QualifiedCaptureConsoleIntent.h b/integration/QualifiedCaptureConsoleIntent.h index 57a7326e1..08ded297c 100644 --- a/integration/QualifiedCaptureConsoleIntent.h +++ b/integration/QualifiedCaptureConsoleIntent.h @@ -93,6 +93,13 @@ inline QualifiedCaptureConsoleDecode decodeQualifiedCaptureConsoleIntent( requestId.toString().length()>128|| payload.getProperty("confirmed",{})!=juce::var(true)) return reject("SECONDARY_CAPTURE_OPERATOR_OR_GRAPH_NOT_ADMITTED"); + // An arbitrary WebView event may not bypass the capability that the + // installed native callback actually advertised for this exact epoch. + // The UI's own supportedOps check is necessary but never sufficient. + const auto offered=caps.getProperty("supportedOps",{}); + if(!offered.isArray()|| + !offered.getArray()->contains(juce::String("INSTALL_SECONDARY_CAPTURE"))) + return reject("SECONDARY_CAPTURE_CAPABILITY_UNAVAILABLE"); if(!nativeV8Decimal(epochRaw)||!nativeV8Decimal(revisionRaw)|| !nativeV8Decimal(rosterRaw)|| epochRaw.toString()!=device.getProperty("epoch",{}).toString()|| From 856b74c27916f8d4b25f0e8f2d47f1848ddf9723 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:34:41 +0700 Subject: [PATCH 23/29] test(io3d): fail-closed Device B capability, replay, disarmed ASIO and readback policy matrix --- tests/approved_native_v8_projection_test.cpp | 80 ++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index 8e39301c9..baf5e68b1 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -1075,6 +1075,86 @@ static void qualifiedCaptureNativeIntentRegression() { } })JSON"); }; + // Advertised capability is a preflight offer on the ONE native graph, + // never proof that B driver is compatible or any microphone audible. + // Arbitrary WebView intents cannot bypass the native capability. + assert(!decodeQualifiedCaptureConsoleIntent(valid(),snap,bus).ok()); + snap.getProperty("device",{}).getDynamicObject() + ->setProperty("outputArmed",false); + const auto live=parse(R"JSON({ + "directRouteAuthorized":true,"adaptiveClockActive":false, + "asioRegistryAttestation":"REGISTERED_CLASS", + "secondaryCapture":{"role":"INPUT_ONLY_ASIO","status":"NOT_CONFIGURED", + "installedInputMap":false,"driverReady":false,"driverFault":false} + })JSON"); + auto copy=[](const juce::var& value) { + return juce::JSON::parse(juce::JSON::toString(value,false)); + }; + const auto deny=[&](const juce::var& source,const juce::var& state, + bool idle=true) { + auto target=copy(source); + const auto before=juce::JSON::toString(target,false); + assert(!publishQualifiedSecondaryCaptureCapability(target,state,idle)); + assert(juce::JSON::toString(target,false)==before); + }; + deny(snap,live,false); // CONTROL is busy + { + auto bad=copy(snap); + bad.getProperty("device",{}).getDynamicObject()->setProperty("backend","WASAPI"); + deny(bad,live); + bad=copy(snap); + bad.getProperty("device",{}).getDynamicObject()->setProperty("outputArmed",true); + deny(bad,live); + bad=copy(snap); + bad.getProperty("graph",{}).getProperty("capabilities",{}) + .getDynamicObject()->setProperty("callbackOwnsChannelIds",false); + deny(bad,live); + bad=copy(snap); + bad.getProperty("device",{}).getDynamicObject() + ->setProperty("enabledInputs",juce::var(juce::Array{})); + deny(bad,live); + } + { + auto bad=copy(live); + bad.getDynamicObject()->setProperty("directRouteAuthorized",false); + deny(snap,bad); + bad=copy(live); + bad.getDynamicObject()->setProperty("adaptiveClockActive",true); + deny(snap,bad); + bad=copy(live); + bad.getDynamicObject()->setProperty("asioRegistryAttestation","NONE"); + deny(snap,bad); + bad=copy(live); + bad.getProperty("secondaryCapture",{}).getDynamicObject() + ->setProperty("installedInputMap",true); + deny(snap,bad); + bad=copy(live); + bad.getProperty("secondaryCapture",{}).getDynamicObject() + ->setProperty("driverFault",true); + deny(snap,bad); + bad=copy(live); + bad.getProperty("secondaryCapture",{}).getDynamicObject() + ->setProperty("status","PCM_FLOW_OBSERVED"); + deny(snap,bad); + } + assert(publishQualifiedSecondaryCaptureCapability(snap,live,true)); + const auto advertised=snap.getProperty("graph",{}) + .getProperty("capabilities",{}).getProperty("supportedOps",{}); + assert(advertised.isArray() && advertised.getArray()->contains( + juce::String("INSTALL_SECONDARY_CAPTURE"))); + assert(publishQualifiedSecondaryCaptureCapability(snap,live,true)); + assert(snap.getProperty("graph",{}).getProperty("capabilities",{}) + .getProperty("supportedOps",{}).getArray()->size()==advertised.getArray()->size()); + // An explicit B remap is allowed to be re-attempted only when the + // old B device is CLOSED; this still requires the new physical lease. + auto remap=copy(live); + remap.getProperty("secondaryCapture",{}).getDynamicObject() + ->setProperty("status","NEEDS_REMAP"); + assert(publishQualifiedSecondaryCaptureCapability(copy(snap),remap,true)==false); + // A mutable approved copy can expose the offer; do not touch the old bus. + auto remapSnapshot=copy(snap); + assert(publishQualifiedSecondaryCaptureCapability(remapSnapshot,remap,true)); + assert(!static_cast(snap.getProperty("productionCallbackLive",true))); const auto accepted=decodeQualifiedCaptureConsoleIntent(valid(),snap,bus); assert(accepted.ok()); assert(accepted.command.requestId=="io-capture-00001"); From a44a86eeeadff26c72299be53fb922cd8fe40432 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:35:37 +0700 Subject: [PATCH 24/29] fix(io3d): keep capability regression on mutable approved snapshot --- tests/approved_native_v8_projection_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index baf5e68b1..80b549c0a 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -1150,7 +1150,6 @@ static void qualifiedCaptureNativeIntentRegression() { auto remap=copy(live); remap.getProperty("secondaryCapture",{}).getDynamicObject() ->setProperty("status","NEEDS_REMAP"); - assert(publishQualifiedSecondaryCaptureCapability(copy(snap),remap,true)==false); // A mutable approved copy can expose the offer; do not touch the old bus. auto remapSnapshot=copy(snap); assert(publishQualifiedSecondaryCaptureCapability(remapSnapshot,remap,true)); From 8e098f0fc2fb055bb83b1fd4c5483c4a369af6ef Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:39:44 +0700 Subject: [PATCH 25/29] fix(io3d): whitelist actual pinned ASIO class proof before offering B capture --- integration/ApprovedNativeRuntimeSnapshot.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index e6a72fa03..478ced845 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -45,8 +45,10 @@ inline bool publishQualifiedSecondaryCaptureCapability( !static_cast(caps.getProperty("callbackOwnsChannelIds",false))|| !static_cast(live.getProperty("directRouteAuthorized",false))|| static_cast(live.getProperty("adaptiveClockActive",true))|| - live.getProperty("asioRegistryAttestation","").toString().isEmpty()|| - live.getProperty("asioRegistryAttestation","").toString()=="NONE"|| + (live.getProperty("asioRegistryAttestation","").toString()!= + "POSTOPEN_REGISTERED_ASIO_DRIVER_CLASS_PINNED" && + live.getProperty("asioRegistryAttestation","").toString()!= + "SAVED_PREFLIGHT_POSTOPEN_REGISTRATION_CONSISTENT")|| secondary.getProperty("role","").toString()!="INPUT_ONLY_ASIO"|| static_cast(secondary.getProperty("installedInputMap",true))|| static_cast(secondary.getProperty("driverReady",true))|| From ceab3653213bb1231b8c56dcf5deaef9d8a7f4d7 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:39:48 +0700 Subject: [PATCH 26/29] test(io3d): verify only native pinned ASIO registration may expose B op --- tests/approved_native_v8_projection_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index 80b549c0a..37e8b7aca 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -1083,7 +1083,7 @@ static void qualifiedCaptureNativeIntentRegression() { ->setProperty("outputArmed",false); const auto live=parse(R"JSON({ "directRouteAuthorized":true,"adaptiveClockActive":false, - "asioRegistryAttestation":"REGISTERED_CLASS", + "asioRegistryAttestation":"POSTOPEN_REGISTERED_ASIO_DRIVER_CLASS_PINNED", "secondaryCapture":{"role":"INPUT_ONLY_ASIO","status":"NOT_CONFIGURED", "installedInputMap":false,"driverReady":false,"driverFault":false} })JSON"); From 21d2143cbdbf44fe04381380fa30b66e4e885966 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:44:07 +0700 Subject: [PATCH 27/29] feat(io3d): fail closed invalid Device B intents before one native ACK transport --- web/approved-native-contract.js | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/web/approved-native-contract.js b/web/approved-native-contract.js index 6b70a9215..85225ec2f 100644 --- a/web/approved-native-contract.js +++ b/web/approved-native-contract.js @@ -311,6 +311,58 @@ } return rows; } + // IO-3D: pure GUI preflight mirrors the native CONTROL decoder's physical + // source identity rules. It does NOT query/open a driver or grant a lease. + // Native rechecks every field at the actual one-owner transaction boundary. + function validQualifiedCaptureRequest(snapshot,targetChannelId,payload) { + if(!snapshot?.admitted || !object(payload) || + snapshot.device?.backend!=="ASIO" || + snapshot.device.outputArmed!==false || + payload.confirmed!==true || + typeof payload.secondaryDriver!=="string" || + payload.secondaryDriver.length<1 || + payload.secondaryDriver.length>128 || + /[\r\n]/.test(payload.secondaryDriver) || + !Number.isFinite(payload.captureRate) || + payload.captureRate<8000 || payload.captureRate>192000 || + !Number.isInteger(payload.capturePeriod) || + payload.capturePeriod<32 || payload.capturePeriod>8192) + return false; + const pins=payload.secondaryInputPins; + if(!Array.isArray(pins)||pins.length<1||pins.length>16|| + pins.some((n,i)=>!Number.isInteger(n)||n<0||n>63|| + (i>0&&n<=pins[i-1])))return false; + const sources=payload.sources; + if(!Array.isArray(sources)||sources.length<1||sources.length>64) + return false; + const nativeInputs=new Set(snapshot.graph.channels.filter( + ch=>ch.role==="INPUT").map(ch=>ch.id)); + const aPins=new Set(snapshot.device.enabledInputs); + const bPins=new Set(pins); + const used=new Set(); + let selectedB=false,hasB=false; + for(const row of sources) { + if(!object(row)||decimal(row.channelId)===null || + row.channelId==="0" ||!nativeInputs.has(row.channelId) || + used.has(row.channelId) || + !["PRIMARY","SECONDARY"].includes(row.deviceRole) || + typeof row.stereo!=="boolean" || + !Number.isInteger(row.leftPhysical) || + row.leftPhysical<0||row.leftPhysical>63)return false; + const allowed=row.deviceRole==="SECONDARY"?bPins:aPins; + if(!allowed.has(row.leftPhysical) || + (row.stereo?(!Number.isInteger(row.rightPhysical) || + row.rightPhysical<0||row.rightPhysical>63 || + row.leftPhysical===row.rightPhysical|| + !allowed.has(row.rightPhysical)):row.rightPhysical!==-1)) + return false; + used.add(row.channelId); + hasB ||= row.deviceRole==="SECONDARY"; + if(row.channelId===targetChannelId && row.deviceRole==="SECONDARY") + selectedB=true; + } + return hasB && selectedB; + } // IO-3B: the stable native device B lease is created only AFTER driver // verification. ACK carries this native-issued token; a second, later // independent snapshot must match it along with actual hardware masks. @@ -762,6 +814,9 @@ return refuseIntent("UNKNOWN_CHANNEL_ID"); } if (!object(payload)) return refuseIntent("INVALID_PAYLOAD"); + if(operation==="INSTALL_SECONDARY_CAPTURE" && + !validQualifiedCaptureRequest(current,targetChannelId,payload)) + return refuseIntent("INVALID_SECONDARY_CAPTURE_INTENT"); let fxExpected=null; if(operation==="REMOVE_INSERT"||operation==="MOVE_INSERT") { const source=current.graph.channels.find(c=>c.id===targetChannelId); @@ -857,6 +912,7 @@ } return Object.freeze({decimal,cmp,normalizeSnapshot, nativeHardwareConfiguration,selectNativeReadModel,readbackProvesIntent, + validQualifiedCaptureRequest, logicalReadbackProves,diagnoseFirstSound,createController, validPresentationName,validPresentationColor,validPresentationIcon, operatorMessage,physicalOutputOverview}); From 05f2ac043f34225d9e64a2758c1c2b30a1aff37e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:44:45 +0700 Subject: [PATCH 28/29] test(io3d): negative GUI B source request matrix without driver open or optimistic PCM --- tests/approved_native_m2_contract.test.cjs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 850b63213..10ac6a3df 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -102,6 +102,60 @@ test("IO-3C native B device capture needs matching ACK AND later independent lea } }); +test("IO-3D Device B request must be a valid physical native source transaction before emit",()=>{ + const base=gmv20AcceptedGraph(); + base.device.backend="ASIO"; + base.device.outputArmed=false; + base.graph.capabilities.supportedOps.push("INSTALL_SECONDARY_CAPTURE"); + const source=base.graph.channels.find(c=>c.role==="INPUT").id; + const valid={confirmed:true,secondaryDriver:"B ASIO",captureRate:44100, + capturePeriod:128,secondaryInputPins:[0,7], + sources:[{channelId:source,deviceRole:"SECONDARY", + leftPhysical:7,rightPhysical:-1,stereo:false}]}; + const snap=protocol.normalizeSnapshot(clone(base)); + assert.ok(snap?.admitted); + assert.equal(protocol.validQualifiedCaptureRequest(snap,source,valid),true); + const reject=(payload,config=base,target=source)=>{ + const emitted=[]; + const ctl=protocol.createController({ + emit:(name,p)=>emitted.push({name,p}), + onAccepted:()=>{},onStatus:()=>{} + }); + assert.equal(ctl.onSnapshot(clone(config)),true); + const before=ctl.state().current; + const outcome=ctl.intent("INSTALL_SECONDARY_CAPTURE",target,clone(payload)); + assert.equal(outcome.ok,false); + assert.equal(emitted.filter(e=>e.name==="arMixConsoleIntent").length,0, + "no unsafe native driver opening event"); + assert.equal(ctl.state().current,before,"accepted PCM must not change"); + assert.equal(ctl.state().pending,null); + }; + for(const change of [ + {confirmed:false},{secondaryDriver:""},{secondaryDriver:"Other\nASIO"}, + {secondaryDriver:"X".repeat(129)},{captureRate:0},{captureRate:192001}, + {capturePeriod:12},{capturePeriod:8193}, + {secondaryInputPins:[]},{secondaryInputPins:[7,0]}, + {secondaryInputPins:[7,7]},{secondaryInputPins:[-1]}, + {sources:[]},{sources:[{...valid.sources[0],leftPhysical:3}]}, + {sources:[{...valid.sources[0],channelId:"18446744073709551616"}]}, + {sources:[{...valid.sources[0],channelId:"200"}]}, + {sources:[{...valid.sources[0],deviceRole:"PRIMARY"}]}, + {sources:[{...valid.sources[0],stereo:true,rightPhysical:7}]}, + {sources:[valid.sources[0],valid.sources[0]]} + ]) reject({...valid,...change}); + const armed=clone(base); + armed.device.outputArmed=true; + reject(valid,armed); + const other=clone(base); + other.device.backend="WASAPI"; + reject(valid,other); + const wrongChannel=base.graph.channels.find(c=>c.role==="MAIN").id; + reject(valid,base,wrongChannel); + const missing=clone(base); + missing.graph.capabilities.supportedOps=[]; + reject(valid,missing); +}); + test("G-MV25 schema-v6 owner switch cancels no-ACK/ACKed ChannelId without stale PCM repaint",()=>{ const base=gmv20AcceptedGraph(); base.mixerSession={authority:"CHANNEL_ID",deviceEpoch:base.device.epoch, From e9d6797e9371836a20b39caebf353c117643d4f4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Fri, 20 Nov 2026 09:56:48 +0700 Subject: [PATCH 29/29] docs(io3d): reconcile native B capability and contract guards with IO-2E epoch recovery --- ...ONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md b/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md index da363937e..5d3ee1ee1 100644 --- a/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md +++ b/docs/architecture/IO3B_SECONDARY_CAPTURE_NATIVE_CONTRACT_20261120.md @@ -34,7 +34,42 @@ The native CONTROL decoder `integration/QualifiedCaptureConsoleIntent.h` checks The existing `arMixConsoleAck` replies with requestId, `status` ACCEPTED/REJECTED, errorCode and installed deviceEpoch/graphRevision/rosterRevision. Native controller also includes `secondaryCapture` diagnostics (driver, physical mask, generation, lease, clock and fault) on this operation. ACK acceptance requires verified installed B capture readback, not merely driver `open()` success, and `productionCallbackLive` / `sourceAudibleProven` remain **false**. The approved consumer must request a *later* `arMixConsoleSnapshot` and verify the same B identity, mask, epoch, lease, ChannelId map and advanced graph revision. `WAITING_FOR_PCM` and `PCM_FLOW_OBSERVED` are native diagnostics, **not proof that the assigned channel is audible**; priming/underflow frames do not count as B PCM. -**IO-3C controller milestone (implemented, fast tested):** The existing `web/approved-native-contract.js::readbackProvesIntent` now recognizes `INSTALL_SECONDARY_CAPTURE`, but only when a previously correlated native `arMixConsoleAck` supplied the exact installed Device B lease and a **later independent** `arMixConsoleSnapshot.secondaryCapture` matches driver class/name, verified physical mask, capture generation, device lease, epoch, rate and period. `WAITING_FOR_PCM` is a valid *installed but not yet flowing* state, **never proof of audible ChannelId signal**. The test in `tests/approved_native_m2_contract.test.cjs` covers stale/forged ACK, wrong mask, mismatched lease, mismatched driver and failure to publish optimistic PCM. Fast UI, Fast Native, M1–M2 and ImerSip P9 PASS for commit `af40b8e7`. The public `/preview/` Source Picker still does not expose this operation, and `graph.capabilities.supportedOps` does not yet advertise it; therefore **the user cannot activate B in the GUI**. Follow-up must deliver the approved operator UI with verified driver inventory, capability, canonical Pages generation and full Chromium/Windows tests. No second WebView event bus or standalone preview. +**IO-3C controller milestone (implemented, fast tested):** The existing `web/approved-native-contract.js::readbackProvesIntent` now recognizes `INSTALL_SECONDARY_CAPTURE`, but only when a previously correlated native `arMixConsoleAck` supplied the exact installed Device B lease and a **later independent** `arMixConsoleSnapshot.secondaryCapture` matches driver class/name, verified physical mask, capture generation, device lease, epoch, rate and period. `WAITING_FOR_PCM` is a valid *installed but not yet flowing* state, **never proof of audible ChannelId signal**. The test in `tests/approved_native_m2_contract.test.cjs` covers stale/forged ACK, wrong mask, mismatched lease, mismatched driver and failure to publish optimistic PCM. Fast UI, Fast Native, M1–M2 and ImerSip P9 PASS for commit `af40b8e7`. The public `/preview/` Source Picker still does not expose this operation; **the user cannot yet activate B in the GUI**. IO-3D conditionally advertises `INSTALL_SECONDARY_CAPTURE` on the real native snapshot only for an admitted, pinned ASIO callback with output disarmed, idle CONTROL state and unconfigured/remappable B. This is an offer to start a transaction, **not** proof that B is installed, available or audible. Follow-up must deliver the approved operator UI with verified driver inventory, capability, canonical Pages generation and full Chromium/Windows tests. No second WebView event bus or standalone preview. + +## IO-3D — fail-closed native capability and GUI contract (implemented on draft #830) + +The one `Main.cpp::approvedNativeSnapshot` now calls +`publishQualifiedSecondaryCaptureCapability` from +`integration/ApprovedNativeRuntimeSnapshot.h`. It exposes the existing v8 +`INSTALL_SECONDARY_CAPTURE` operation only when the installed ChannelId +callback owns the same graph, the primary is exact pinned/attested ASIO, +MAIN/MONITOR output is disarmed, no independent WASAPI render clock is active, +the primary physical input mask exists, the B map is not already installed, +and control-side device/session/graph operations are idle. An arbitrary +browser intent is rejected by the **native** decoder unless this capability +is currently installed; the engine still rechecks device masks and lease +identities before any B driver open. + +The pure `web/approved-native-contract.js::validQualifiedCaptureRequest` +guards the same public command preflight against malformed driver names, rate +or period, unsorted/duplicate B pins, nonexistent/stale INPUT ChannelIds, +unselected physical A/B pins, duplicate source rows and mono/stereo +inconsistency. Invalid requests are refused without emitting +`arMixConsoleIntent` or mutating accepted graph/PCM. Tests: +`tests/approved_native_v8_projection_test.cpp` (actual native capability +projection/denials) and `tests/approved_native_m2_contract.test.cjs` +(positive lease matching and invalid-intent no-emit matrix). These are +source-level and control contract proofs, **not** two-device physical FAT. + +`IO-2E` parent #825 adds retained qualified A+B lease retirement across +primary device epochs: only an explicit output-disarmed A-only session +replacement retires the old B map; implicit cross-epoch commits are rejected. +The device binding is independently verified before the restore. + +Current PR stack: #825 is the native foundation; draft #830 is based on its +latest native HEAD and owns this typed command/readback. Parent Windows +exact-HEAD requalification and child Windows/Chromium qualification must be +verified separately before promotion. ## Persistence, fallback and hardware qualification