From 3f45d4d07180b46dd2682dffbccba9e589d3331f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 07:40:50 +0700 Subject: [PATCH 1/3] feat(m3): fail-closed field render window classification from actual RT counters --- engine/core/ProductionRenderAudit.h | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/engine/core/ProductionRenderAudit.h b/engine/core/ProductionRenderAudit.h index 99dde2fd9..8cd098811 100644 --- a/engine/core/ProductionRenderAudit.h +++ b/engine/core/ProductionRenderAudit.h @@ -14,6 +14,70 @@ class ProductionRenderAudit final { std::uint64_t m4Started=0,m4Completed=0,m4Failed=0; std::uint64_t overlapDenied=0,unpatchedSilent=0,mutedNoRender=0; }; + // CONTROL/field diagnostics only. The caller must supply two snapshots + // from the same process and same *physical* device epoch, both with an + // independently verified installed ChannelId admission. This never grants + // permission to render, arm an output, or retire legacy code. + enum class WindowStatus : std::uint8_t { + invalidContext, countersRegressed, boundaryInFlight, + legacyRendered, nativeFailed, noNativeRender, + silentOrMuted, exclusiveNativeObserved + }; + struct RenderWindow { + WindowStatus status=WindowStatus::invalidContext; + Snapshot delta{}; + [[nodiscard]] constexpr bool exclusiveNativeObserved() const noexcept { + return status==WindowStatus::exclusiveNativeObserved; + } + }; + [[nodiscard]] static constexpr RenderWindow assessWindow( + Snapshot before,Snapshot after,bool sameProcess, + bool sameDeviceEpoch,bool channelIdAdmittedAtBothEnds) noexcept { + if(!sameProcess || !sameDeviceEpoch || !channelIdAdmittedAtBothEnds) + return {WindowStatus::invalidContext,{}}; + const auto monotonic=[](Snapshot x,Snapshot y) constexpr noexcept { + return y.nativeStarted>=x.nativeStarted && + y.nativeCompleted>=x.nativeCompleted && + y.nativeFailed>=x.nativeFailed && + y.m4Started>=x.m4Started && + y.m4Completed>=x.m4Completed && + y.m4Failed>=x.m4Failed && + y.overlapDenied>=x.overlapDenied && + y.unpatchedSilent>=x.unpatchedSilent && + y.mutedNoRender>=x.mutedNoRender; + }; + if(!monotonic(before,after)) + return {WindowStatus::countersRegressed,{}}; + // Relaxed atomic CONTROL snapshots can catch one callback in flight. + // Neither partial endpoint is valid proof of a completed DSP window. + const auto settled=[](Snapshot s) constexpr noexcept { + return s.nativeStarted>=s.nativeCompleted && + s.nativeStarted-s.nativeCompleted==s.nativeFailed && + s.m4Started>=s.m4Completed && + s.m4Started-s.m4Completed==s.m4Failed; + }; + if(!settled(before) || !settled(after)) + return {WindowStatus::boundaryInFlight,{}}; + const Snapshot delta{ + after.nativeStarted-before.nativeStarted, + after.nativeCompleted-before.nativeCompleted, + after.nativeFailed-before.nativeFailed, + after.m4Started-before.m4Started, + after.m4Completed-before.m4Completed, + after.m4Failed-before.m4Failed, + after.overlapDenied-before.overlapDenied, + after.unpatchedSilent-before.unpatchedSilent, + after.mutedNoRender-before.mutedNoRender}; + if(delta.m4Started || delta.m4Completed || delta.m4Failed) + return {WindowStatus::legacyRendered,delta}; + if(delta.nativeFailed || delta.overlapDenied) + return {WindowStatus::nativeFailed,delta}; + if(delta.nativeCompleted==0) + return {WindowStatus::noNativeRender,delta}; + if(delta.unpatchedSilent || delta.mutedNoRender) + return {WindowStatus::silentOrMuted,delta}; + return {WindowStatus::exclusiveNativeObserved,delta}; + } ProductionRenderAudit()=default; ProductionRenderAudit(const ProductionRenderAudit&)=delete; ProductionRenderAudit& operator=(const ProductionRenderAudit&)=delete; From 24ecef8145fca17fcbc7cc8f09067340c931b429 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 07:41:24 +0700 Subject: [PATCH 2/3] test(m3): enforce epoch, settled counters, no M4 fallback and no faults in native evidence window --- tests/production_render_audit_test.cpp | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/production_render_audit_test.cpp b/tests/production_render_audit_test.cpp index 1c103897a..d1759b4d1 100644 --- a/tests/production_render_audit_test.cpp +++ b/tests/production_render_audit_test.cpp @@ -27,4 +27,69 @@ int main() { assert(s.overlapDenied==1&&s.unpatchedSilent==2&&s.mutedNoRender==1); assert(s.nativeStarted==s.nativeCompleted+s.nativeFailed); assert(s.m4Started==s.m4Completed+s.m4Failed); + + // M3b source-retirement gate: read two real counter boundaries, not + // process-lifetime totals. Historical M4 blocks must not taint a new + // native-only window, but a fresh M4 block must disqualify it. + using Status=Audit::WindowStatus; + const auto begin=a.snapshot(); + for(int i=0;i<4;++i) { + a.started(Audit::Path::channelId); + a.completed(Audit::Path::channelId); + } + const auto end=a.snapshot(); + const auto verified=Audit::assessWindow(begin,end,true,true,true); + assert(verified.exclusiveNativeObserved()); + assert(verified.delta.nativeCompleted==4); + assert(verified.delta.m4Started==0); + assert(verified.delta.nativeFailed==0); + + assert(Audit::assessWindow(begin,end,false,true,true).status== + Status::invalidContext); + assert(Audit::assessWindow(begin,end,true,false,true).status== + Status::invalidContext); + assert(Audit::assessWindow(begin,end,true,true,false).status== + Status::invalidContext); + + auto reset=end; + --reset.m4Completed; + assert(Audit::assessWindow(begin,reset,true,true,true).status== + Status::countersRegressed); + auto mid=end; + ++mid.nativeStarted; // asynchronous CONTROL read during DSP callback + assert(Audit::assessWindow(begin,mid,true,true,true).status== + Status::boundaryInFlight); + auto beforePartial=begin; + ++beforePartial.nativeStarted; + assert(Audit::assessWindow(beforePartial,end,true,true,true).status== + Status::boundaryInFlight); + + auto withLegacy=end; + ++withLegacy.m4Started;++withLegacy.m4Completed; + const auto fallback=Audit::assessWindow(begin,withLegacy,true,true,true); + assert(fallback.status==Status::legacyRendered); + assert(fallback.delta.m4Completed==1); + + auto withFailure=end; + ++withFailure.nativeStarted;++withFailure.nativeFailed; + assert(Audit::assessWindow(begin,withFailure,true,true,true).status== + Status::nativeFailed); + auto withOverlap=end; + ++withOverlap.overlapDenied; + assert(Audit::assessWindow(begin,withOverlap,true,true,true).status== + Status::nativeFailed); + + auto noNewBlock=Audit::assessWindow(end,end,true,true,true); + assert(noNewBlock.status==Status::noNativeRender); + auto withMute=end; + ++withMute.mutedNoRender; + assert(Audit::assessWindow(begin,withMute,true,true,true).status== + Status::silentOrMuted); + auto withUnpatched=end; + ++withUnpatched.unpatchedSilent; + assert(Audit::assessWindow(begin,withUnpatched,true,true,true).status== + Status::silentOrMuted); + + // A clean native window is *render ownership evidence only*. Neither + // this test nor the classifier is an audible ASIO physical FAT. } From 8f8b4503e374507907f509e237403d39f3f3f4a7 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 07:41:56 +0700 Subject: [PATCH 3/3] docs(m3): specify conservative native PCM field evidence and non-retirement boundary --- docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md b/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md index e16b4ad7b..e16a1bef4 100644 --- a/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md +++ b/docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md @@ -46,3 +46,11 @@ Retire an M4 branch only after actual native field sessions show no M4 render deltas with equivalent VST3/FX, channel meters, bus and physical MAIN performance across restart, devices and output mute. Never permit legacy fallback merely because native publication failed. + +## M3b conservative window evaluation (source-only helper) + +The native audit header now exposes `ProductionRenderAudit::assessWindow(before,after,sameProcess,sameDeviceEpoch,channelIdAdmittedAtBothEnds)` for CONTROL/field-evidence analysis. Supply two independent `dryRoutingLab.renderAudit` observations **and** verify the actual device epoch and installed ChannelId admission at both ends; these booleans are external observations, never inferred from a WebView status badge. + +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.