diff --git a/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md b/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md index e16a1bef4..07c01ba76 100644 --- a/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md +++ b/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md @@ -54,3 +54,26 @@ The native audit header now exposes `ProductionRenderAudit::assessWindow(before, The result `exclusiveNativeObserved` requires at least one **completed** native callback in the bounded window, zero newly rendered M4 blocks, zero native failures or overlap denials, and zero unpatched/muted-no-render exits. It rejects process/device epoch discontinuity, counter regression/reset, and unsettled endpoint snapshots (which can occur because the source counters are independent relaxed atomics). An M4 total from a *previous* window does not itself disqualify current native-only evidence; an M4 increment **in** the window always does. This deliberately does **not** authorize audio, promise audible ASIO, qualify a device, or automatically remove the compatibility code. A single clean window is insufficient for M3b retirement. Repeat across real hardware sessions and record the matching output identity, source-only and WIRE/BUS/FX PCM fixtures, muted/not-muted state, sample rate/buffer transitions, and independent headphone listening. Until then M4 remains reachable. No new renderer, UI polling, or heavy workflow is introduced. + + +## M3c: bounded multi-window evidence (CONTROL only) + +`ProductionRenderAudit::assessSeries(boundaries,minimumNativeCompleted)` +requires at least **three consecutive clean bounded render windows** and a +nonzero native callback coverage threshold (default 128 completed callbacks). +Every boundary must supply independently verified **same process nonce, +same physical device epoch and installed ChannelId admission**. It rejects +M4 activity, partial/in-flight counters, native failures, overlap denials, +unpatched or muted-no-render activity, device epochs changing midseries, +counter regression and too little callback coverage. A historical M4 count +before the first boundary does not contaminate a later clean series. + +This is a read-only, allocation-free CONTROL-side evidence helper with +deterministic native tests; it does **not** automatically read hardware facts, +grant audio permission, delete legacy M4 code or prove physical ASIO output. +Field runs must collect genuine `dryRoutingLab.renderAudit` snapshots and +independently record exact device+pins and installed graph evidence. Qualify +distinct post-restart/device configurations in separate consecutive series. +Legacy M4 code must remain until separate *physical* FAT and full WIRE/BUS/FX +PCM continuity is witnessed. A clean CI test of the classifier does not +qualify any real interface or vendor plugin. diff --git a/engine/core/ProductionRenderAudit.h b/engine/core/ProductionRenderAudit.h index 8cd098811..821ad3f45 100644 --- a/engine/core/ProductionRenderAudit.h +++ b/engine/core/ProductionRenderAudit.h @@ -2,6 +2,8 @@ #pragma once #include #include +#include +#include // Read-only evidence for the single JUCE production renderer. Neither this // type nor its counters authorize PCM/output. No heap, lock, wait or log on RT. @@ -78,6 +80,67 @@ class ProductionRenderAudit final { return {WindowStatus::silentOrMuted,delta}; return {WindowStatus::exclusiveNativeObserved,delta}; } + // CONTROL-only, conservative evidence over MULTIPLE nonempty bounded + // windows. This prevents one short transient native window from being + // mistaken for proof that the M4 compatibility path can be retired. + // processNonce/epoch/admission must come from independently checked + // device/session evidence, not from a browser badge or raw counter. + // A continuous span crosses NO device restarts; repeat on a new epoch. + struct Boundary { + Snapshot counters{}; + std::uint64_t processNonce=0,deviceEpoch=0; + bool verifiedInstalledChannelId=false; + }; + enum class SeriesStatus : std::uint8_t { + tooFewWindows,invalidContext,badRenderWindow, + insufficientNativeBlocks,continuousNativeObserved + }; + struct RenderSeries { + SeriesStatus status=SeriesStatus::tooFewWindows; + WindowStatus firstBadWindow=WindowStatus::invalidContext; + std::uint64_t nativeCompleted=0; + [[nodiscard]] constexpr bool continuousNativeObserved() const noexcept { + return status==SeriesStatus::continuousNativeObserved; + } + }; + [[nodiscard]] static constexpr RenderSeries assessSeries( + std::span boundaries, + std::uint64_t minimumNativeCompleted=128) noexcept { + // Require >=3 independent bounded windows, not a single callback. + // A zero caller-selected threshold cannot bypass the evidence gate. + if(boundaries.size()<4 || minimumNativeCompleted==0) + return {SeriesStatus::tooFewWindows,WindowStatus::invalidContext,0}; + const auto& first=boundaries.front(); + if(!first.processNonce || !first.deviceEpoch || + !first.verifiedInstalledChannelId) + return {SeriesStatus::invalidContext,WindowStatus::invalidContext,0}; + std::uint64_t total=0; + for(std::size_t i=1;istd::numeric_limits::max()- + window.delta.nativeCompleted) + return {SeriesStatus::badRenderWindow, + WindowStatus::countersRegressed,total}; + total+=window.delta.nativeCompleted; + } + return total>=minimumNativeCompleted? + RenderSeries{SeriesStatus::continuousNativeObserved, + WindowStatus::exclusiveNativeObserved,total}: + RenderSeries{SeriesStatus::insufficientNativeBlocks, + WindowStatus::noNativeRender,total}; + } ProductionRenderAudit()=default; ProductionRenderAudit(const ProductionRenderAudit&)=delete; ProductionRenderAudit& operator=(const ProductionRenderAudit&)=delete; diff --git a/src/NativeDeviceApplyCoordinator.h b/src/NativeDeviceApplyCoordinator.h index 31dceba31..404050d22 100644 --- a/src/NativeDeviceApplyCoordinator.h +++ b/src/NativeDeviceApplyCoordinator.h @@ -58,9 +58,20 @@ class NativeDeviceApplyCoordinator final { return out; } auto& r=out.value; - r.backend=config.getProperty("backend",{}).toString(); - r.capture=config.getProperty("captureDevice",{}).toString(); - r.playback=config.getProperty("playbackDevice",{}).toString(); + const auto rawBackend=config.getProperty("backend",{}); + const auto rawCapture=config.getProperty("captureDevice",{}); + const auto rawPlayback=config.getProperty("playbackDevice",{}); + // Device names are exact JUCE-provided strings. A JSON number, + // boolean or object must never be string-coerced into a physical + // endpoint. An omitted/empty capture is valid for output-only mode. + if(!rawBackend.isString() || !rawPlayback.isString() || + (!rawCapture.isVoid() && !rawCapture.isString())) { + out.error="Invalid audio device name types"; + return out; + } + r.backend=rawBackend.toString(); + r.capture=rawCapture.isVoid()?juce::String{}:rawCapture.toString(); + r.playback=rawPlayback.toString(); if(r.backend.isEmpty()||r.playback.isEmpty()|| r.backend.length()>160||r.capture.length()>250||r.playback.length()>250) { out.error="Choose an actual playback device"; diff --git a/tests/native_device_apply_coordinator_test.cpp b/tests/native_device_apply_coordinator_test.cpp index 76e47afe6..d41f50a7f 100644 --- a/tests/native_device_apply_coordinator_test.cpp +++ b/tests/native_device_apply_coordinator_test.cpp @@ -80,10 +80,22 @@ int main() { "sampleRate":0,"bufferSize":0})"); auto output=Coordinator::parse(outputOnly); assert(output && output.value.rate==0. && output.value.block==0.); + // Capture name is optional only when it is genuinely absent or empty. + const auto explicitEmpty=config(R"({"backend":"Windows Audio", + "captureDevice":"","playbackDevice":"Speakers","sampleRate":0,"bufferSize":0})"); + const auto outputParsed=Coordinator::parse(explicitEmpty); + assert(outputParsed && outputParsed.value.capture.isEmpty()); assert(Coordinator::validateNames(output.value,{},{"Speakers"},true).isEmpty()); assert(Coordinator::validateNames(output.value,{},{"Speakers"},false).isNotEmpty()); for(const auto& invalid : { - "{}", R"({"backend":"ASIO","playbackDevice":"X","sampleRate":"48000","bufferSize":256})", + "{}", R"({"backend":42,"playbackDevice":"X","sampleRate":48000,"bufferSize":256})", + R"({"backend":true,"playbackDevice":"X","sampleRate":48000,"bufferSize":256})", + R"({"backend":"ASIO","playbackDevice":19,"sampleRate":48000,"bufferSize":256})", + R"({"backend":"ASIO","playbackDevice":true,"sampleRate":48000,"bufferSize":256})", + R"({"backend":"ASIO","captureDevice":false,"playbackDevice":"X","sampleRate":48000,"bufferSize":256})", + R"({"backend":"ASIO","captureDevice":72,"playbackDevice":"X","sampleRate":48000,"bufferSize":256})", + R"({"backend":"ASIO","playbackDevice":["X"],"sampleRate":48000,"bufferSize":256})", + R"({"backend":"ASIO","playbackDevice":"X","sampleRate":"48000","bufferSize":256})", R"({"backend":"ASIO","playbackDevice":"X","sampleRate":4000,"bufferSize":256})", R"({"backend":"ASIO","playbackDevice":"X","sampleRate":48000,"bufferSize":1.5})", R"({"backend":"ASIO","playbackDevice":"X","sampleRate":48000,"bufferSize":8193})", diff --git a/tests/production_render_audit_test.cpp b/tests/production_render_audit_test.cpp index d1759b4d1..83472245d 100644 --- a/tests/production_render_audit_test.cpp +++ b/tests/production_render_audit_test.cpp @@ -3,6 +3,7 @@ #undef NDEBUG #endif #include "../engine/core/ProductionRenderAudit.h" +#include #include #include #include @@ -90,6 +91,65 @@ int main() { assert(Audit::assessWindow(begin,withUnpatched,true,true,true).status== Status::silentOrMuted); + // M3c: a single successful render window cannot qualify sustained + // native-only ownership. Every boundary needs independent same-process + // same-physical-epoch admission, and each intervening window must prove + // completed ChannelId PCM with no M4/silent/failed/overlap activity. + using Boundary=Audit::Boundary; + using SeriesStatus=Audit::SeriesStatus; + Audit continuous; + continuous.started(Audit::Path::compatibilityM4); + continuous.completed(Audit::Path::compatibilityM4); // historical only + std::array boundaries{}; + for(std::size_t i=0;i{ + boundaries.data(),3},1).status==SeriesStatus::tooFewWindows); + auto stale=boundaries; + stale[2].deviceEpoch=20; + assert(Audit::assessSeries(stale,1).status==SeriesStatus::invalidContext); + stale=boundaries; + stale[1].processNonce=74; + assert(Audit::assessSeries(stale,1).status==SeriesStatus::invalidContext); + stale=boundaries; + stale[2].verifiedInstalledChannelId=false; + assert(Audit::assessSeries(stale,1).status==SeriesStatus::invalidContext); + stale=boundaries; + stale[0].processNonce=0; + assert(Audit::assessSeries(stale,1).status==SeriesStatus::invalidContext); + stale=boundaries; + ++stale[2].counters.m4Started; + ++stale[2].counters.m4Completed; + const auto legacyInWindow=Audit::assessSeries(stale,1); + assert(legacyInWindow.status==SeriesStatus::badRenderWindow); + assert(legacyInWindow.firstBadWindow==Status::legacyRendered); + stale=boundaries; + ++stale[2].counters.mutedNoRender; + assert(Audit::assessSeries(stale,1).status==SeriesStatus::badRenderWindow); + stale=boundaries; + ++stale[2].counters.nativeStarted; // genuine in-flight snapshot + assert(Audit::assessSeries(stale,1).status==SeriesStatus::badRenderWindow); + stale=boundaries; + stale[2].counters.nativeStarted=0; // reset or swapped process + const auto resetSeries=Audit::assessSeries(stale,1); + assert(resetSeries.status==SeriesStatus::badRenderWindow); + assert(resetSeries.firstBadWindow==Status::countersRegressed); + // These results never authorize output, retire M4 or replace physical + // ASIO field evidence. A different epoch requires a NEW series. + // A clean native window is *render ownership evidence only*. Neither // this test nor the classifier is an audible ASIO physical FAT. }