Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
63 changes: 63 additions & 0 deletions engine/core/ProductionRenderAudit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma once
#include <atomic>
#include <cstdint>
#include <limits>
#include <span>

// 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.
Expand Down Expand Up @@ -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<const Boundary> 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;i<boundaries.size();++i) {
const auto& prior=boundaries[i-1];
const auto& current=boundaries[i];
if(prior.processNonce!=first.processNonce ||
current.processNonce!=first.processNonce ||
prior.deviceEpoch!=first.deviceEpoch ||
current.deviceEpoch!=first.deviceEpoch ||
!prior.verifiedInstalledChannelId ||
!current.verifiedInstalledChannelId)
return {SeriesStatus::invalidContext,WindowStatus::invalidContext,total};
const auto window=assessWindow(prior.counters,current.counters,
true,true,true);
if(!window.exclusiveNativeObserved())
return {SeriesStatus::badRenderWindow,window.status,total};
if(total>std::numeric_limits<std::uint64_t>::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;
Expand Down
17 changes: 14 additions & 3 deletions src/NativeDeviceApplyCoordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
14 changes: 13 additions & 1 deletion tests/native_device_apply_coordinator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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})",
Expand Down
60 changes: 60 additions & 0 deletions tests/production_render_audit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#undef NDEBUG
#endif
#include "../engine/core/ProductionRenderAudit.h"
#include <array>
#include <cassert>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -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<Boundary,4> boundaries{};
for(std::size_t i=0;i<boundaries.size();++i) {
boundaries[i]={continuous.snapshot(),73,19,true};
if(i+1<boundaries.size())
for(int block=0;block<8;++block) {
continuous.started(Audit::Path::channelId);
continuous.completed(Audit::Path::channelId);
}
}
const auto sustained=Audit::assessSeries(boundaries,24);
assert(sustained.continuousNativeObserved());
assert(sustained.nativeCompleted==24);
assert(Audit::assessSeries(boundaries,25).status==
SeriesStatus::insufficientNativeBlocks);
assert(Audit::assessSeries(boundaries,0).status==
SeriesStatus::tooFewWindows);
assert(Audit::assessSeries(std::span<const Boundary>{
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.
}
Loading