From d9f73fdc8c76f3f897542910e6385e46dba395a9 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:16:30 +0700 Subject: [PATCH 01/20] feat(m2): publish actual JUCE device pins with strictly empty unadmitted ChannelId graph --- src/ApprovedConsoleM2Snapshot.h | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/ApprovedConsoleM2Snapshot.h diff --git a/src/ApprovedConsoleM2Snapshot.h b/src/ApprovedConsoleM2Snapshot.h new file mode 100644 index 000000000..41d10696a --- /dev/null +++ b/src/ApprovedConsoleM2Snapshot.h @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include + +// M2 bridge: the installed M4 callback is NOT yet a universal ChannelId +// renderer. Publish only the real active JUCE pins/telemetry, with an EMPTY +// ChannelId graph. No ordinal-to-ChannelId conversion, fictional capabilities, +// duplicate DSP/audio callback, or implicit hardware arming. +namespace armix::console::approvedM2 { +inline juce::String decimal (const juce::var& v) { + if (v.isInt() || v.isInt64()) { + const auto n=static_cast(v); + return n > 0 ? juce::String(n) : juce::String("1"); + } + if (v.isString()) { + const auto t=v.toString(); + if (t.isNotEmpty() && t.length()<=20 && t.containsOnly("0123456789") + && t[0]!='0') return t; + } + return "1"; // UNREADY control session, not a hardware epoch or real pin. +} +inline juce::var build (const juce::var& installed, + const juce::var& actualDevice) { + auto result=std::make_unique(); + result->setProperty("schemaVersion",6); + result->setProperty("productionCallbackLive",false); + const auto route=installed.getProperty("dryRoutingLab",juce::var()); + auto device=std::make_unique(); + device->setProperty("epoch",decimal(route.getProperty("epoch",juce::var()))); + device->setProperty("backend",actualDevice.getProperty("backend","")); + device->setProperty("captureDevice",actualDevice.getProperty("captureDevice","")); + device->setProperty("playbackDevice",actualDevice.getProperty("playbackDevice","")); + device->setProperty("sampleRate",actualDevice.getProperty("rate",0)); + device->setProperty("bufferFrames",actualDevice.getProperty("buffer",0)); + const bool open=static_cast(actualDevice.getProperty("open",false)); + device->setProperty("outputArmed",open && + !static_cast(actualDevice.getProperty("outputMuted",true))); + juce::Array inputPorts,outputPorts,inputEndpoints,outputEndpoints; + const auto addPorts=[&](const char* enabledName,const char* labelsName, + const char* prefix,juce::Array& ports, + juce::Array& endpoints) { + const auto enabled=actualDevice.getProperty(enabledName,juce::var()); + const auto labels=actualDevice.getProperty(labelsName,juce::var()); + const auto* indices=enabled.getArray(); + const auto* names=labels.getArray(); + if (!open || !indices || !names) return; + for (const auto& value:*indices) { + if (!value.isInt()) continue; + const int pin=static_cast(value); + if (pin<0 || pin>=names->size() || pin>255) continue; + const auto label=names->getReference(pin).toString(); + if (label.isEmpty()) continue; + auto entry=std::make_unique(); + entry->setProperty("id",juce::String(prefix)+":"+juce::String(pin)); + entry->setProperty("port",pin); + entry->setProperty("callback",static_cast(ports.size())); + entry->setProperty("label",label); + entry->setProperty("active",true); + ports.add(pin); + endpoints.add(juce::var(entry.release())); + } + }; + addPorts("enabledInputs","inputNames","in",inputPorts,inputEndpoints); + addPorts("enabledOutputs","outputNames","out",outputPorts,outputEndpoints); + device->setProperty("enabledInputs",juce::var(inputPorts)); + device->setProperty("enabledOutputs",juce::var(outputPorts)); + device->setProperty("inputEndpoints",juce::var(inputEndpoints)); + device->setProperty("outputEndpoints",juce::var(outputEndpoints)); + result->setProperty("device",juce::var(device.release())); + + auto graph=std::make_unique(); + graph->setProperty("revision","0"); + graph->setProperty("rosterRevision","0"); + graph->setProperty("channels",juce::var(juce::Array())); + graph->setProperty("destinations",juce::var(juce::Array())); + auto caps=std::make_unique(); + for (const char* field: {"callbackOwnsChannelIds","fullVendorFxMigration", + "showAndOutputParity","physicalCaptureMapped","dynamicChannels", + "groups","fxReturns","monitor","sendsOnFaders"}) + caps->setProperty(field,false); + caps->setProperty("supportedOps",juce::var(juce::Array())); + graph->setProperty("capabilities",juce::var(caps.release())); + result->setProperty("graph",juce::var(graph.release())); + + auto telemetry=std::make_unique(); + const auto peak=static_cast(installed.getProperty("inputPeak",0.0)); + const double safePeak=std::isfinite(peak) && peak>=0.0 ? peak : 0.0; + telemetry->setProperty("rawCapturePeak",safePeak); + telemetry->setProperty("rawCapturePresent",open && !inputPorts.isEmpty() && + static_cast(installed.getProperty("callbackCount",0.0))>0.0 && + safePeak>0.0005); + telemetry->setProperty("mainPcmPresent",false); // No accepted ChannelId MAIN. + telemetry->setProperty("monitorPcmPresent",false); + result->setProperty("telemetry",juce::var(telemetry.release())); + return juce::var(result.release()); +} +} // namespace armix::console::approvedM2 From cb23d157a8fd0e2c5525e0acbe8b20546095d9f4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:17:16 +0700 Subject: [PATCH 02/20] feat(m2): native-accepted snapshot and ACK transaction controller, no optimistic GUI state --- web/approved-native-m2-state.js | 213 ++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 web/approved-native-m2-state.js diff --git a/web/approved-native-m2-state.js b/web/approved-native-m2-state.js new file mode 100644 index 000000000..2706ff5a8 --- /dev/null +++ b/web/approved-native-m2-state.js @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// M2: the one Pages GUI's native-accepted console transaction controller. +// Only control-plane. Never an audio engine, browser-generated ChannelId, +// hardware pin source, or optimistic success indicator. +(function (root, factory) { + const exported = factory(); + if (typeof module !== "undefined" && module.exports) module.exports = exported; + if (root) root.ArSonMixNativeM2 = exported; +})(typeof globalThis !== "undefined" ? globalThis : this, function () { + "use strict"; + const MAX = (1n << 64n) - 1n; + const ASSERT = (ok, why) => { if (!ok) throw Error("M2_" + why); }; + const DECIMAL = /^(0|[1-9][0-9]*)$/; + const OPERATIONS = /^[A-Z_]+$/; + const REQUIRED_CAPS = [ + "callbackOwnsChannelIds", "fullVendorFxMigration", "showAndOutputParity", + "physicalCaptureMapped", "dynamicChannels", "groups", "fxReturns", + "monitor", "sendsOnFaders" + ]; + function uint64(value, positive = false) { + ASSERT(typeof value === "string" && DECIMAL.test(value), "BAD_UINT64"); + const number = BigInt(value); + ASSERT(number <= MAX && (!positive || number > 0n), "UINT64_RANGE"); + return number; + } + function fields(obj, names) { + ASSERT(obj && typeof obj === "object" && !Array.isArray(obj), "BAD_OBJECT"); + for (const key of names) ASSERT(Object.prototype.hasOwnProperty.call(obj, key), "MISSING_" + key); + } + function validateSnapshot(input) { + fields(input, ["schemaVersion", "productionCallbackLive", "device", "graph", "telemetry"]); + ASSERT(input.schemaVersion === 6 && typeof input.productionCallbackLive === "boolean", "VERSION"); + const d = input.device, g = input.graph, t = input.telemetry; + fields(d, ["epoch", "backend", "captureDevice", "playbackDevice", "inputEndpoints", + "outputEndpoints", "enabledInputs", "enabledOutputs", "sampleRate", "bufferFrames", "outputArmed"]); + fields(g, ["revision", "rosterRevision", "channels", "destinations", "capabilities"]); + fields(t, ["rawCapturePresent", "rawCapturePeak", "mainPcmPresent", "monitorPcmPresent"]); + uint64(d.epoch, true); + uint64(g.revision); + uint64(g.rosterRevision); + ASSERT(typeof d.outputArmed === "boolean", "OUTPUT_ARM_FLAG"); + ASSERT(typeof t.rawCapturePresent === "boolean" && + typeof t.mainPcmPresent === "boolean" && + typeof t.monitorPcmPresent === "boolean" && + typeof t.rawCapturePeak === "number" && Number.isFinite(t.rawCapturePeak) && + t.rawCapturePeak >= 0, "TELEMETRY"); + for (const key of ["enabledInputs", "enabledOutputs"]) { + ASSERT(Array.isArray(d[key]), "PORT_MASK"); + ASSERT(d[key].every(x => Number.isSafeInteger(x) && x >= 0 && x <= 255), "PORT"); + ASSERT(new Set(d[key]).size === d[key].length, "DUPLICATE_PIN"); + } + for (const [kind, items, pins] of [ + ["in", d.inputEndpoints, d.enabledInputs], + ["out", d.outputEndpoints, d.enabledOutputs] + ]) { + ASSERT(Array.isArray(items), "ENDPOINTS"); + const ids = new Set(), callbacks = new Set(); + for (const e of items) { + ASSERT(e && Number.isSafeInteger(e.port) && pins.includes(e.port) && + e.id === kind + ":" + e.port && e.active === true && + Number.isSafeInteger(e.callback) && e.callback >= 0 && + typeof e.label === "string" && e.label.length > 0, "ENDPOINT"); + ASSERT(!ids.has(e.id) && !callbacks.has(e.callback), "DUPLICATE_ENDPOINT"); + ids.add(e.id); callbacks.add(e.callback); + } + } + ASSERT(Array.isArray(g.channels) && Array.isArray(g.destinations), "GRAPH_ARRAY"); + fields(g.capabilities, [...REQUIRED_CAPS, "supportedOps"]); + for (const key of REQUIRED_CAPS) ASSERT(typeof g.capabilities[key] === "boolean", "CAPABILITY"); + ASSERT(Array.isArray(g.capabilities.supportedOps) && + g.capabilities.supportedOps.every(op => typeof op === "string" && OPERATIONS.test(op)) && + new Set(g.capabilities.supportedOps).size === g.capabilities.supportedOps.length, "OPS"); + const ids = new Set(); + for (const channel of g.channels) { + ASSERT(channel && typeof channel === "object", "CHANNEL"); + uint64(channel.id, true); + ASSERT(!ids.has(channel.id), "DUPLICATE_CHANNEL"); + ids.add(channel.id); + } + for (const dest of g.destinations) { + uint64(dest.id, true); + ASSERT(ids.has(dest.id), "UNKNOWN_DESTINATION"); + } + // A non-LIVE producer can expose diagnostic fields, but these cannot + // authorize operator actions or claim the callback owns the graph. + if (input.productionCallbackLive) { + ASSERT(["callbackOwnsChannelIds", "fullVendorFxMigration", + "showAndOutputParity", "physicalCaptureMapped"].every(k => g.capabilities[k]), + "FALSE_LIVE_CLAIM"); + } + return JSON.parse(JSON.stringify(input)); // no external mutable reference + } + function validRequestId(s) { + return typeof s === "string" && s.length <= 128 && + /^[^\s:]+:[1-9][0-9]*$/.test(s); + } + function matching(ack, snapshot) { + return snapshot && snapshot.device.epoch === ack.deviceEpoch && + snapshot.graph.revision === ack.graphRevision && + snapshot.graph.rosterRevision === ack.rosterRevision; + } + function createController({emit, notify = () => {}, session = "gui-m2"} = {}) { + ASSERT(typeof emit === "function" && validRequestId(session + ":1"), "SESSION"); + let accepted = null, pending = null, candidate = null, sequence = 0n; + let state = "WAITING_NATIVE_SNAPSHOT"; + function status() { return state; } + function snapshot() { return accepted ? JSON.parse(JSON.stringify(accepted)) : null; } + function pendingRequest() { return pending ? {...pending.intent} : null; } + function live() { return Boolean(accepted?.productionCallbackLive); } + function publish(s) { + accepted = s; + state = s.productionCallbackLive ? "ACCEPTED_NATIVE_CALLBACK" : "M2_NATIVE_READBACK_ONLY"; + notify(state, snapshot()); + } + function receiveSnapshot(raw) { + let next; + try { next = validateSnapshot(raw); } + catch (e) { state = "INVALID_NATIVE_SNAPSHOT"; notify(state, e.message); return false; } + if (accepted) { + if (uint64(next.device.epoch) < uint64(accepted.device.epoch)) return false; + if (next.device.epoch === accepted.device.epoch && + uint64(next.graph.revision) < uint64(accepted.graph.revision)) return false; + } + if (pending) { + if (accepted && next.device.epoch !== accepted.device.epoch) { + // Real hardware changed: invalidate all uncommitted UI intentions. + pending = null; candidate = null; publish(next); + notify("DEVICE_CHANGED_INTENT_CANCELLED"); return true; + } + if (pending.ack) { + if (!matching(pending.ack, next)) return false; + pending = null; candidate = null; publish(next); return true; + } + candidate = next; // Native may deliver the snapshot before its ACK. + return false; + } + publish(next); return true; + } + function request(operation, targetChannelId, payload = {}) { + if (!accepted || pending || !live() || + !accepted.graph.capabilities.supportedOps.includes(operation)) { + notify("M2_OPERATION_NOT_NATIVE_ADMITTED", operation); return null; + } + if (typeof operation !== "string" || !OPERATIONS.test(operation)) return null; + if (targetChannelId !== null && targetChannelId !== undefined) { + try { uint64(targetChannelId, true); } + catch (_) { return null; } + if (!accepted.graph.channels.some(x => x.id === targetChannelId)) return null; + } + if (!payload || typeof payload !== "object" || Array.isArray(payload)) return null; + if (operation === "SET_SOURCE" && + !accepted.device.inputEndpoints.some(x => x.id === payload.portId && x.active)) return null; + ++sequence; + const id = session + ":" + sequence; + const intent = { + requestId: id, + deviceEpoch: accepted.device.epoch, + baseGraphRevision: accepted.graph.revision, + baseRosterRevision: accepted.graph.rosterRevision, + operation, + targetChannelId: targetChannelId ?? null, + payload: JSON.parse(JSON.stringify(payload)) + }; + pending = {intent, ack:null}; candidate = null; + state = "PENDING_NATIVE_ACK"; + try { emit("arMixConsoleIntent", intent); } + catch (e) { + pending = null; state = "NATIVE_TRANSPORT_FAILED"; + notify(state, e.message); return null; + } + notify(state, intent); + return id; + } + function receiveAck(raw) { + if (!pending || !raw || raw.requestId !== pending.intent.requestId) + return false; + let epoch,rev,roster; + try { + epoch=uint64(raw.deviceEpoch,true); + rev=uint64(raw.graphRevision); + roster=uint64(raw.rosterRevision); + } catch (_) { return false; } + if (raw.deviceEpoch !== pending.intent.deviceEpoch || + !["ACCEPTED","REJECTED","REQUIRES_DEVICE_CHANGE"].includes(raw.status)) + return false; + if (raw.status !== "ACCEPTED") { + // Rejection, stale, or unsupported may NEVER mutate accepted UI graph. + pending = null; candidate = null; + state = "NATIVE_REJECTED"; + notify(state, typeof raw.errorCode === "string" ? raw.errorCode : "NO_REASON"); + return true; + } + if (accepted && epoch === uint64(accepted.device.epoch) && + rev < uint64(accepted.graph.revision)) return false; + if (roster < 0n) return false; + pending.ack = {...raw}; + state = "AWAITING_MATCHED_NATIVE_SNAPSHOT"; + notify(state, raw); + if (candidate && matching(raw, candidate)) { + const confirmed = candidate; + candidate = null; pending = null; publish(confirmed); + } + return true; + } + function disconnect() { + accepted = null; pending = null; candidate = null; + state = "NATIVE_DISCONNECTED"; notify(state); + } + return Object.freeze({status, snapshot, live, pendingRequest, receiveSnapshot, + receiveAck, request, disconnect}); + } + return Object.freeze({uint64, validateSnapshot, createController}); +}); From ef39aacf86bf298181816b628e7f80ec108bf383 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:17:53 +0700 Subject: [PATCH 03/20] feat(m2): subscribe native v6, enforce ACK/snapshot, block demo audio mutations in EXE --- web/approved-native-bridge.js | 91 +++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 15 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 6b43c23c3..5ca91fc41 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -1,29 +1,90 @@ // SPDX-License-Identifier: AGPL-3.0-only -// Thin transport seam for the ONE already-approved Pages GUI. -// IMPORTANT: this is an M1 source/visual integration bridge, NOT a PCM driver. -// Native ChannelId/EdgeId ACK/readback binding must be added before product UAT. +// M2 transport seam for EXACT approved /preview/ HTML. No GUI redesign. +// Never infer ChannelId from demo-strip order; never run JS PCM or promote +// optimistic intent to accepted state. Owner ENGINE #266 supplies native ops. (() => { "use strict"; const backend = window.__JUCE__?.backend; + const connected = Boolean(backend?.emitEvent && backend?.addEventListener); + const model = window.ArSonMixNativeM2; + const controller = connected && model?.createController + ? model.createController({ + emit: (event, payload) => backend.emitEvent(event, payload), + session: "native-m2-" + Math.floor(Date.now() * 1000).toString(36) + + "-" + Math.floor(Math.random() * 0x100000000).toString(36), + notify: status => { + document.documentElement.dataset.armixNativeStatus = status; + } + }) + : null; const descriptor = Object.freeze({ - source: "site/preview-v2 + site/preview-buttons", + source: "scripts/build_pages.py => /preview/", pagesRoute: "/preview/", - nativeTransport: Boolean(backend?.emitEvent && backend?.addEventListener), - acceptedGraphConnected: false, - productionCallbackLive: false, - status: "M1_VISUAL_BUNDLE_ONLY__NOT_AUDIO_READY" + nativeTransport: connected, + get acceptedGraphConnected() { return false; }, // M2 has no visual slot<->ID mapping yet. + get productionCallbackLive() { return Boolean(controller?.live()); }, + get status() { return controller?.status() || "NATIVE_TRANSPORT_UNAVAILABLE"; }, + get acceptedSnapshot() { return controller?.snapshot() || null; }, + get pendingIntent() { return controller?.pendingRequest() || null; }, + request(operation, targetChannelId, payload) { + return controller?.request(operation, targetChannelId, payload) || null; + } }); Object.defineProperty(window, "__ARMIX_APPROVED_NATIVE_GUI__", { value: descriptor, configurable: false, writable: false }); - // The native startup signal certifies ONLY that the approved DOM loaded. - // It never reports VST3, PCM, hardware pins or graph capabilities as live. - if (!descriptor.nativeTransport) return; - const ready = () => backend.emitEvent("arMixGuiReady", { - gui: "APPROVED_PAGES_PREVIEW_BUTTONS", - visualReady: true, - audioReady: false + if (!connected || !controller) return; + + backend.addEventListener("arMixConsoleSnapshot", message => { + controller.receiveSnapshot(message); }); + backend.addEventListener("arMixConsoleAck", message => { + controller.receiveAck(message); + }); + + // The public Pages GUI contains interactive demonstration state for /preview/. + // M2 MUST NOT allow those audio controls to mutate browser-only state inside + // an installed native mixer. Presentation/navigation/selection remain intact. + // No HTML/CSS/layout edits, overlay or additional audio callback. + const mutatingActions = new Set([ + "mute", "solo", "cue", "phase", "fxOn", "slotPower", "removeFx", + "openPlugin", "wireGain", "wireRoute", "resetClip", + "rename", "format", "fxReorder", "route" + ]); + const mutatingFields = new Set([ + "level", "pan", "trim", "input", "output", "sendLevel", "sendPan", + "mute", "solo", "format", "activeSend" + ]); + const guard = event => { + const node = event.target?.closest?.( + "[data-action],[data-field],.fader,.fx-grip,#preview" + ); + if (!node) return; + const action = node.dataset?.action; + const field = node.dataset?.field; + const audio = node.matches?.("#preview,.fader,.fx-grip") || + mutatingActions.has(action) || mutatingFields.has(field); + if (!audio) return; + event.preventDefault(); + event.stopImmediatePropagation(); + }; + for (const type of ["click", "input", "change", "pointerdown", "wheel", + "keydown", "dragstart", "drop"]) + document.addEventListener(type, guard, {capture:true, passive:false}); + + const ready = () => { + // Ready signifies WebView DOM only, NOT real PCM, native routing or FX. + backend.emitEvent("arMixGuiReady", { + gui: "APPROVED_PAGES_PREVIEW_BUTTONS", + visualReady: true, + audioReady: false, + schemaVersion: 6 + }); + backend.emitEvent("arMixConsoleSubscribe", { + protocol: "v6", schemaVersion: 6, + source: "APPROVED_PAGES_NATIVE_M2" + }); + }; if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", ready, {once:true}); } else ready(); From 03e79aaacbca8d64d51bc2431f5ee405cbf01507 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:18:36 +0700 Subject: [PATCH 04/20] feat(m2): wire genuine native v6 subscribe/snapshot/rejected intent ACK into sole JUCE ConsoleWindow --- src/Main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index daf27bab2..302e616c3 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -6,6 +6,7 @@ #include #include "ApprovedGuiResources.h" #include "LiveAudioEngine.h" +#include "ApprovedConsoleM2Snapshot.h" #include "ArSonMixStartupSplash.h" #include "VstOrbitController.h" #include "../engine/core/OrbitDistanceMapping.h" @@ -195,6 +196,37 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr }) .withEventListener ("arMixParameter", [this] (juce::var args) { onParameter (args); }) .withEventListener ("arMixAction", [this] (juce::var args) { onAction (args); }) + .withEventListener ("arMixConsoleSubscribe", [this] (juce::var args) + { + if (args.getProperty("protocol","").toString()!="v6" || + static_cast(args.getProperty("schemaVersion",0))!=6) return; + m2ConsoleSubscribed_ = true; + emitApprovedM2Snapshot(); + }) + .withEventListener ("arMixConsoleIntent", [this] (juce::var args) + { + // Native M4 does not own the v8 universal ChannelId graph. + // Explicit REJECTED ACK: NEVER mutate an ordinal route through + // an unadmitted operation and NEVER claim audio success. + const auto id=args.getProperty("requestId",{}).toString(); + if(id.isEmpty()||id.length()>128)return; + const auto snapshot=armix::console::approvedM2::build( + engine_.status(),currentDeviceSnapshot()); + const auto device=snapshot.getProperty("device",{}); + const auto graph=snapshot.getProperty("graph",{}); + auto ack=std::make_unique(); + ack->setProperty("requestId",id); + ack->setProperty("status","REJECTED"); + ack->setProperty("deviceEpoch",device.getProperty("epoch","1")); + ack->setProperty("graphRevision",graph.getProperty("revision","0")); + ack->setProperty("rosterRevision",graph.getProperty("rosterRevision","0")); + ack->setProperty("errorCode","NATIVE_CHANNELID_CALLBACK_NOT_ADMITTED"); + if(browser_.loaded) { + browser_.emitEventIfBrowserIsVisible("arMixConsoleAck", + juce::var(ack.release())); + emitApprovedM2Snapshot(); + } + }) .withResourceProvider (assetFor)) { settingsDirectory().createDirectory(); @@ -259,6 +291,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr std::unique_ptr audioSetupWindow_; juce::String startupError_, lastAudioXml_; bool initialStateSent_ = false; + bool m2ConsoleSubscribed_ = false; bool webViewPeerWarmed_ = false; bool webViewStartupNoticeSent_ = false; juce::uint32 webViewStartupTick_ = 0; @@ -467,6 +500,14 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr emitNotice ("Device interrupted. DIRECT restore is retrying with bounded backoff.", true); } + void emitApprovedM2Snapshot() + { + if (!browser_.loaded || !m2ConsoleSubscribed_) return; + browser_.emitEventIfBrowserIsVisible("arMixConsoleSnapshot", + armix::console::approvedM2::build(engine_.status(), + currentDeviceSnapshot())); + } + void emitNotice (const juce::String& message, bool error = false) { auto o = std::make_unique(); @@ -2542,6 +2583,11 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if (startupError_.isNotEmpty() && !bool (state.getProperty ("connected", false))) state.getDynamicObject()->setProperty ("error", startupError_); browser_.emitEventIfBrowserIsVisible ("arMixStatus", state); + // Control-thread native readback. Same existing 12 Hz timer; no + // callback allocations or a second polling worker. One Hz is enough + // for topology/device invalidation, not for audio metering. + if(m2ConsoleSubscribed_ && timerTicks_ % 12 == 0) + emitApprovedM2Snapshot(); } }; From c5dee1112e667741892f33716fac77ec57ff4ff6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:19:00 +0700 Subject: [PATCH 05/20] build(m2): embed deterministic native transaction controller beside exact /preview/ HTML --- scripts/build_approved_native_gui.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py index a0a32b4e2..19f9bc4db 100644 --- a/scripts/build_approved_native_gui.py +++ b/scripts/build_approved_native_gui.py @@ -21,8 +21,9 @@ ROOT = Path(__file__).resolve().parents[1] CANONICAL = ROOT / "site" / "preview-v2" NATIVE_ADAPTER = ROOT / "web" / "approved-native-bridge.js" -ADAPTER_MARKER = '' -SCHEMA = "arsonmix.approved-native-pages-bundle.v2" +M2_STATE = ROOT / "web" / "approved-native-m2-state.js" +ADAPTER_MARKER = '\n' +SCHEMA = "arsonmix.approved-native-pages-bundle.v3" def sha256(data: bytes) -> str: @@ -110,6 +111,7 @@ def stage(out: Path) -> dict: shutil.rmtree(out) out.mkdir(parents=True) shutil.copytree(pages / "assets", out / "assets") + shutil.copy2(M2_STATE, out / "assets" / "approved-native-m2-state.js") shutil.copy2(NATIVE_ADAPTER, out / "assets" / "approved-native-bridge.js") native = native_html(approved.decode("utf-8")).encode("utf-8") (out / "index.html").write_bytes(native) @@ -128,7 +130,7 @@ def stage(out: Path) -> dict: "approvedPagesHtmlSha256": sha256(approved), "nativeHtmlSha256": sha256(native), "adapter": "web/approved-native-bridge.js", - "adapterState": "SCAFFOLD_ONLY__NOT_LIVE_PCM", + "adapterState": "M2_NATIVE_ACK_SNAPSHOT_GATED__PCM_NOT_CERTIFIED", "files": [{"path":p.relative_to(out).as_posix(), "sha256":sha256(p.read_bytes())} for p in files], } (out / "approved-gui-manifest.json").write_text( From d440b245166377a68c446ddfa5f8358b851324cf Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:19:13 +0700 Subject: [PATCH 06/20] build(m2): track native snapshot gate and full bundle SHA resources --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d97d5e1f4..ae9172fe3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ file(GLOB_RECURSE ARMIX_APPROVED_GUI_SOURCE_INPUTS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/site/preview-buttons/assets/*") list(APPEND ARMIX_APPROVED_GUI_SOURCE_INPUTS "${CMAKE_CURRENT_SOURCE_DIR}/web/approved-native-bridge.js" + "${CMAKE_CURRENT_SOURCE_DIR}/web/approved-native-m2-state.js" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build_approved_native_gui.py") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${ARMIX_APPROVED_GUI_SOURCE_INPUTS}) execute_process( From 2d99a87a90d8dd22c6154662cfb51b03fcccd96f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:19:17 +0700 Subject: [PATCH 07/20] build(m2): track native snapshot gate and full bundle SHA resources --- scripts/package_native_windows.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/package_native_windows.ps1 b/scripts/package_native_windows.ps1 index 9e546fc1f..91e1e1087 100644 --- a/scripts/package_native_windows.ps1 +++ b/scripts/package_native_windows.ps1 @@ -67,7 +67,7 @@ $approvedGuiManifestPath = Join-Path $approvedGuiDir "approved-gui-manifest.json $approvedGui = Get-Content -LiteralPath $approvedGuiManifestPath -Raw -Encoding UTF8 | ConvertFrom-Json if ($approvedGui.authoritativePagesRoute -ne "/preview/" -or $approvedGui.authoritativePagesOutput -ne "preview/index.html" -or - $approvedGui.adapterState -ne "SCAFFOLD_ONLY__NOT_LIVE_PCM") { + $approvedGui.adapterState -ne "M2_NATIVE_ACK_SNAPSHOT_GATED__PCM_NOT_CERTIFIED") { throw "Native GUI bundle does not match approved Pages renderer and truthful M1 status" } New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null @@ -114,7 +114,7 @@ $manifest = [ordered]@{ approvedGuiManifestSha256 = (Get-FileHash -LiteralPath $approvedGuiManifestPath -Algorithm SHA256).Hash.ToLowerInvariant() approvedGuiResourceCount = @($approvedGui.files).Count approvedGuiSource = "site/preview-v2 DOM + site/preview-buttons approved PNG skin (deterministic JUCE BinaryData)" - approvedGuiAdapterStatus = "SCAFFOLD_ONLY__NOT_LIVE_PCM" + approvedGuiAdapterStatus = "M2_NATIVE_ACK_SNAPSHOT_GATED__PCM_NOT_CERTIFIED" guiCalibration = "APPROVED_PAGES_VISUAL_PROVENANCE_ONLY__M1_NOT_PRODUCT_READY" fatStatus = "EXPERIMENTAL_NOT_HARDWARE_QUALIFIED" note = "No assertion of clean 0-FX sound, measured round-trip latency or native render-hardware XRUN." From c0fa3f74292e248c3a8d41fa11c139264290ccbd Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:19:20 +0700 Subject: [PATCH 08/20] build(m2): track native snapshot gate and full bundle SHA resources --- scripts/verify_native_windows_artifact.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/verify_native_windows_artifact.ps1 b/scripts/verify_native_windows_artifact.ps1 index fce66be51..c3dda6793 100644 --- a/scripts/verify_native_windows_artifact.ps1 +++ b/scripts/verify_native_windows_artifact.ps1 @@ -80,7 +80,7 @@ if ($manifest.approvedGuiManifestSha256 -ne $approvedHash -or $manifest.approvedGuiPagesSha256 -ne $approved.approvedPagesHtmlSha256 -or $manifest.approvedGuiNativeHtmlSha256 -ne $approved.nativeHtmlSha256 -or $manifest.approvedGuiCanonicalSha256 -ne $approved.canonicalSourceSha256 -or - $manifest.approvedGuiAdapterStatus -ne "SCAFFOLD_ONLY__NOT_LIVE_PCM" -or + $manifest.approvedGuiAdapterStatus -ne "M2_NATIVE_ACK_SNAPSHOT_GATED__PCM_NOT_CERTIFIED" -or $manifest.guiCalibration -ne "APPROVED_PAGES_VISUAL_PROVENANCE_ONLY__M1_NOT_PRODUCT_READY" -or $manifest.approvedGuiResourceCount -ne @($approved.files).Count) { throw "REJECT: native release provenance does not match the approved Pages GUI" @@ -133,7 +133,7 @@ foreach ($item in $approved.files) { } } if ($embeddedText.IndexOf('APPROVED_PAGES_PREVIEW_BUTTONS', [StringComparison]::Ordinal) -lt 0 -or - $embeddedText.IndexOf('M1_VISUAL_BUNDLE_ONLY__NOT_AUDIO_READY', [StringComparison]::Ordinal) -lt 0 -or + $embeddedText.IndexOf('M2_NATIVE_READBACK_ONLY', [StringComparison]::Ordinal) -lt 0 -or $embeddedText.IndexOf('WEBVIEW2_GUI_READY_TIMEOUT', [StringComparison]::Ordinal) -lt 0 -or $embeddedText.IndexOf('AUDIO_GLITCH_WINDOW', [StringComparison]::Ordinal) -lt 0) { throw "REJECT: approved GUI bridge or native device safety markers absent" From e7881a2f07bf493c14a795332c7e677d4f63fef0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:19:25 +0700 Subject: [PATCH 09/20] build(m2): track native snapshot gate and full bundle SHA resources --- tests/approved_native_gui_bundle_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py index ff19498c2..9719726c5 100644 --- a/tests/approved_native_gui_bundle_test.py +++ b/tests/approved_native_gui_bundle_test.py @@ -18,7 +18,7 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self) manifest = bundle.stage(out) self.assertEqual(manifest["authoritativePagesRoute"], "/preview/") self.assertEqual(manifest["authoritativePagesOutput"], "preview/index.html") - self.assertEqual(manifest["adapterState"], "SCAFFOLD_ONLY__NOT_LIVE_PCM") + self.assertEqual(manifest["adapterState"], "M2_NATIVE_ACK_SNAPSHOT_GATED__PCM_NOT_CERTIFIED") approved = (source / "index.html").read_text("utf-8") native = (out / "index.html").read_text("utf-8") self.assertEqual(native.replace(bundle.ADAPTER_MARKER + "\n", ""), approved) From 44e715b8e3d09f5376a0f25490fd497559980d1c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:20:54 +0700 Subject: [PATCH 10/20] =?UTF-8?q?test(m2):=20prove=20exact=20ACK=E2=86=92s?= =?UTF-8?q?napshot=20commit,=20stale=20epoch=20rejection,=20real=20pin=20m?= =?UTF-8?q?asks,=20large=20ChannelIds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/approved_native_m2_contract_test.cjs | 145 +++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tests/approved_native_m2_contract_test.cjs diff --git a/tests/approved_native_m2_contract_test.cjs b/tests/approved_native_m2_contract_test.cjs new file mode 100644 index 000000000..f9e0cddc3 --- /dev/null +++ b/tests/approved_native_m2_contract_test.cjs @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// M2 production handshake has no speculative/optimistic graph promotion. +// Same JS used by the ONLY /preview/ WebView2 native resource provider. +const {test}=require('node:test'); +const assert=require('node:assert/strict'); +const {readFileSync}=require('node:fs'); +const {createController,validateSnapshot,uint64}=require('../web/approved-native-m2-state.js'); +const read=path=>readFileSync(path,'utf8'); +const fullCaps=()=>({ + callbackOwnsChannelIds:true,fullVendorFxMigration:true, + showAndOutputParity:true,physicalCaptureMapped:true, + dynamicChannels:true,groups:true,fxReturns:true,monitor:true, + sendsOnFaders:true,supportedOps:['SET_FADER','SET_SOURCE'] +}); +const status=(epoch='69',revision='5',live=true)=>({ + schemaVersion:6,productionCallbackLive:live, + device:{epoch,backend:'ASIO',captureDevice:'real',playbackDevice:'real', + inputEndpoints:[{id:'in:4',port:4,callback:0,label:'verified four',active:true}], + outputEndpoints:[{id:'out:2',port:2,callback:0,label:'verified out',active:true}], + enabledInputs:[4],enabledOutputs:[2],sampleRate:48000, + bufferFrames:128,outputArmed:false}, + graph:{revision,rosterRevision:'2', + channels:[{id:'18446744073709551614',name:'actual native ID',role:'INPUT', + processingFormat:'MONO',inserts:[],sends:[]}], + destinations:[],capabilities:fullCaps()}, + telemetry:{rawCapturePresent:false,rawCapturePeak:0, + mainPcmPresent:false,monitorPcmPresent:false} +}); +function session() { + const events=[],updates=[]; + const ctl=createController({emit:(event,payload)=>events.push({event,payload}), + session:'native-m2-proof',notify:(status,detail)=>updates.push([status,detail])}); + return {ctl,events,updates}; +} +test('uint64 ChannelIds are lossless and JS never compares them as Number',()=>{ + assert.equal(uint64('18446744073709551615'),(1n<<64n)-1n); + assert.throws(()=>uint64(18446744073709551615),/M2_BAD_UINT64/); + for(const n of ['01','-1','+2','18446744073709551616','3.3']) + assert.throws(()=>uint64(n)); +}); +test('real driver pin mask is mandatory; inactive or imaginary pins fail closed',()=>{ + const good=status(); assert.deepEqual(validateSnapshot(good),good); + const bad=status();bad.device.inputEndpoints[0].port=7; + assert.throws(()=>validateSnapshot(bad),/M2_ENDPOINT/); + const bad2=status();bad2.device.enabledInputs=[4,4]; + assert.throws(()=>validateSnapshot(bad2),/M2_DUPLICATE_PIN/); + const bad3=status();bad3.device.inputEndpoints[0].id='in:9'; + assert.throws(()=>validateSnapshot(bad3),/M2_ENDPOINT/); +}); +test('no producer LIVE parity => snapshot may exist but ALL operator edits are refused',()=>{ + const {ctl,events}=session(); + const g=status('69','0',false); g.graph.channels=[]; + g.graph.destinations=[];g.graph.capabilities.supportedOps=[]; + Object.keys(g.graph.capabilities).forEach(k=>{ + if(k!=='supportedOps')g.graph.capabilities[k]=false; + }); + assert.equal(ctl.receiveSnapshot(g),true); + assert.equal(ctl.status(),'M2_NATIVE_READBACK_ONLY'); + assert.equal(ctl.request('SET_FADER',null,{value:-5}),null); + assert.equal(events.length,0); +}); +test('intent emits canonical native request with same accepted base revisions and stable ChannelId',()=>{ + const {ctl,events}=session();ctl.receiveSnapshot(status()); + const id=ctl.request('SET_FADER','18446744073709551614',{db:-5}); + assert.equal(id,'native-m2-proof:1'); + assert.equal(events[0].event,'arMixConsoleIntent'); + assert.deepEqual(events[0].payload,{ + requestId:id,deviceEpoch:'69',baseGraphRevision:'5',baseRosterRevision:'2', + operation:'SET_FADER',targetChannelId:'18446744073709551614',payload:{db:-5} + }); + assert.equal(ctl.request('SET_FADER','18446744073709551614',{db:0}),null); + assert.equal(ctl.status(),'PENDING_NATIVE_ACK'); +}); +test('matching ACK alone does NOT commit; commit after exact later native snapshot',()=>{ + const {ctl}=session();ctl.receiveSnapshot(status()); + const id=ctl.request('SET_FADER','18446744073709551614',{db:-12}); + assert.equal(ctl.receiveAck({requestId:id,status:'ACCEPTED',deviceEpoch:'69', + graphRevision:'6',rosterRevision:'2',errorCode:''}),true); + assert.equal(ctl.status(),'AWAITING_MATCHED_NATIVE_SNAPSHOT'); + assert.equal(ctl.snapshot().graph.revision,'5'); + assert.equal(ctl.receiveSnapshot(status('69','7')),false); + assert.equal(ctl.snapshot().graph.revision,'5'); + assert.equal(ctl.receiveSnapshot(status('69','6')),true); + assert.equal(ctl.snapshot().graph.revision,'6'); + assert.equal(ctl.status(),'ACCEPTED_NATIVE_CALLBACK'); +}); +test('out-of-order snapshot is quarantined until ACK; stale/foreign ACK ignored',()=>{ + const {ctl}=session();ctl.receiveSnapshot(status()); + const id=ctl.request('SET_FADER','18446744073709551614',{db:-6}); + assert.equal(ctl.receiveSnapshot(status('69','6')),false); + assert.equal(ctl.snapshot().graph.revision,'5'); + assert.equal(ctl.receiveAck({requestId:'other:99',status:'ACCEPTED',deviceEpoch:'69', + graphRevision:'6',rosterRevision:'2',errorCode:''}),false); + assert.equal(ctl.receiveAck({requestId:id,status:'ACCEPTED',deviceEpoch:'69', + graphRevision:'6',rosterRevision:'2',errorCode:''}),true); + assert.equal(ctl.snapshot().graph.revision,'6'); +}); +test('REJECTED/stale leaves accepted graph unchanged, never optimistic PCM',()=>{ + const {ctl}=session();ctl.receiveSnapshot(status()); + const id=ctl.request('SET_FADER','18446744073709551614',{db:-6}); + assert.equal(ctl.receiveAck({requestId:id,status:'REJECTED', + deviceEpoch:'69',graphRevision:'5',rosterRevision:'2',errorCode:'STALE_GRAPH'}),true); + assert.equal(ctl.snapshot().graph.revision,'5'); + assert.equal(ctl.status(),'NATIVE_REJECTED'); + assert.equal(ctl.pendingRequest(),null); +}); +test('device epoch change cancels in-flight edit and accepts new hardware truth',()=>{ + const {ctl}=session();ctl.receiveSnapshot(status()); + const id=ctl.request('SET_FADER','18446744073709551614',{db:-9}); + assert.equal(ctl.receiveSnapshot(status('70','0',false)),true); + assert.equal(ctl.pendingRequest(),null); + assert.equal(ctl.snapshot().device.epoch,'70'); + assert.equal(ctl.receiveAck({requestId:id,status:'ACCEPTED',deviceEpoch:'69', + graphRevision:'6',rosterRevision:'2',errorCode:''}),false); + assert.equal(ctl.status(),'M2_NATIVE_READBACK_ONLY'); +}); +test('cannot send source outside actual enabled endpoints or unknown channel ids',()=>{ + const {ctl,events}=session();ctl.receiveSnapshot(status()); + assert.equal(ctl.request('SET_SOURCE','18446744073709551614',{portId:'in:0'}),null); + assert.equal(ctl.request('SET_FADER','1',{db:-5}),null); + assert.equal(events.length,0); +}); +test('native EXE exposes ONE approved GUI + truthful producer with no JS DSP',()=>{ + const cpp=read('src/Main.cpp'),header=read('src/ApprovedConsoleM2Snapshot.h'); + const adapter=read('web/approved-native-bridge.js'); + const generator=read('scripts/build_approved_native_gui.py'); + assert.match(cpp,/withEventListener \("arMixConsoleSubscribe"/); + assert.match(cpp,/withEventListener \("arMixConsoleIntent"/); + assert.match(cpp,/emitApprovedM2Snapshot/); + assert.match(cpp,/NATIVE_CHANNELID_CALLBACK_NOT_ADMITTED/); + assert.match(cpp,/withResourceProvider \(assetFor\)/); + assert.match(header,/enabledInputs/); + assert.match(header,/enabledOutputs/); + assert.match(header,/productionCallbackLive",false/); + assert.match(header,/mainPcmPresent",false/); + assert.match(header,/callbackOwnsChannelIds/); + assert.match(adapter,/arMixConsoleSnapshot/); + assert.match(adapter,/arMixConsoleAck/); + assert.match(adapter,/arMixConsoleSubscribe/); + assert.match(adapter,/APPROVED_PAGES_PREVIEW_BUTTONS/); + assert.match(adapter,/stopImmediatePropagation/); // block fake demo audio edits + assert.doesNotMatch(adapter,/AudioContext|AudioWorklet|createOscillator|setMasterMuted/); + assert.match(generator,/approved-native-m2-state\.js/); + assert.match(generator,/scripts" \/ "build_pages\.py"/); +}); From dbf8e4417bfbe78a4cc61bcf16ff4ddf281fe20d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:21:08 +0700 Subject: [PATCH 11/20] test(m2): ensure embedded native gate is honest, never fabricated live PCM --- tests/native_artifact_packaging_contract_test.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/native_artifact_packaging_contract_test.mjs b/tests/native_artifact_packaging_contract_test.mjs index 6b33b1a86..1aa410188 100644 --- a/tests/native_artifact_packaging_contract_test.mjs +++ b/tests/native_artifact_packaging_contract_test.mjs @@ -79,11 +79,14 @@ test('native bridge authenticates UI readiness but never hallucinates PCM/VST3 L assert.match(nativeMain,/withEventListener \("arMixGuiReady"/); assert.doesNotMatch(nativeMain,/pageFinishedLoading \(const juce::String&\) override \{ loaded = true; \}/); assert.match(adapter,/emitEvent\("arMixGuiReady"/); - assert.match(adapter,/acceptedGraphConnected: false/); - assert.match(adapter,/productionCallbackLive: false/); + assert.match(adapter,/get acceptedGraphConnected\(\) \{ return false; \}/); + assert.match(adapter,/get productionCallbackLive\(\) \{ return Boolean\(controller\?\.live\(\)\); \}/); assert.match(packaging,/webView2LoaderMode = "JUCE_WEBVIEW2_LOADER_STATIC_LINKED_V1"/); assert.match(verify,/manifest\.webView2LoaderMode/); assert.match(verify,/WEBVIEW2_GUI_READY_TIMEOUT/); + assert.match(adapter,/arMixConsoleSubscribe/); + assert.match(nativeMain,/emitApprovedM2Snapshot/); + assert.match(read('web/approved-native-m2-state.js'),/AWAITING_MATCHED_NATIVE_SNAPSHOT/); }); test('physical 10CH+4AUX runtime remains hardware-unqualified, no fake UAT',()=>{ From df9788a1679369f206d46260365cee8a3146e0ca Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:21:23 +0700 Subject: [PATCH 12/20] ci(m2): exact-head Windows validates native state gate, request ACK semantics and JS syntax --- .github/workflows/p1-windows.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 93e3c2c89..a8c472873 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -9,6 +9,8 @@ on: - 'integration/console-v6/**' - 'src/**' - 'web/approved-native-bridge.js' + - 'web/approved-native-m2-state.js' + - 'tests/approved_native_m2_contract_test.cjs' - 'scripts/build_approved_native_gui.py' - 'tests/approved_native_gui_bundle_test.py' - 'engine/**' @@ -32,6 +34,8 @@ on: - 'integration/console-v6/**' - 'src/**' - 'web/approved-native-bridge.js' + - 'web/approved-native-m2-state.js' + - 'tests/approved_native_m2_contract_test.cjs' - 'scripts/build_approved_native_gui.py' - 'tests/approved_native_gui_bundle_test.py' - 'web/bridge.js' @@ -91,7 +95,7 @@ jobs: run: | # Do not hide earlier Node failures with the exit code of the LAST # command. One Node invocation also avoids repeated startup costs. - foreach ($file in @('web/bridge.js', 'web/plugin-ui.js', 'web/monitor.js', 'web/app.js', 'web/mixer-io.js', 'web/mixer-layout.js')) { + foreach ($file in @('web/bridge.js', 'web/plugin-ui.js', 'web/monitor.js', 'web/app.js', 'web/mixer-io.js', 'web/mixer-layout.js', 'web/approved-native-bridge.js', 'web/approved-native-m2-state.js')) { node --check $file if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } @@ -120,6 +124,8 @@ jobs: ) node --test $contracts if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + node --test tests/approved_native_m2_contract_test.cjs + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - name: Configure Windows x64 shell: pwsh run: > From 9f066e5a44a00164af8a54316e7efe1d6d74f102 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:21:32 +0700 Subject: [PATCH 13/20] test(ci): M2 native transport and ACK tests must trigger Windows on PR and main --- tests/ci_workflow_efficiency_test.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ci_workflow_efficiency_test.mjs b/tests/ci_workflow_efficiency_test.mjs index e7a64eabb..fba93f55a 100644 --- a/tests/ci_workflow_efficiency_test.mjs +++ b/tests/ci_workflow_efficiency_test.mjs @@ -74,6 +74,8 @@ test('native PCM and device changes always use Windows/CTest, never Chromium by test('approved Pages to JUCE build seam is a native gate, never an unrelated CSS-only job', () => { for (const filename of [ 'web/approved-native-bridge.js', + 'web/approved-native-m2-state.js', + 'tests/approved_native_m2_contract_test.cjs', 'scripts/build_approved_native_gui.py', 'tests/approved_native_gui_bundle_test.py' ]) { From 2b15eeb5fdd3f019628591908f30aad3a906df2a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:23:16 +0700 Subject: [PATCH 14/20] test(m2): update native exact-Pages contract to truthful ACK-gated stage --- tests/reconciled_gui_engine_contract_test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reconciled_gui_engine_contract_test.mjs b/tests/reconciled_gui_engine_contract_test.mjs index 5fede272e..2894a9d6d 100644 --- a/tests/reconciled_gui_engine_contract_test.mjs +++ b/tests/reconciled_gui_engine_contract_test.mjs @@ -64,7 +64,7 @@ test('JUCE native resources use EXACT assembled Pages /preview/, not archived we assert.match(pagesBuilder,/APPROVED_SINGLE_GUI/); assert.match(pagesBuilder,/buttons_dest=dst\/'preview'/); assert.match(generator,/approvedPagesHtmlSha256/); - assert.match(generator,/SCAFFOLD_ONLY__NOT_LIVE_PCM/); + assert.match(generator,/M2_NATIVE_ACK_SNAPSHOT_GATED__PCM_NOT_CERTIFIED/); assert.match(nativeAdapter,/acceptedGraphConnected: false/); assert.match(nativeAdapter,/productionCallbackLive: false/); // Historical web app still verifies its archival CSS/standalone consistency. From d82e2e183e69edf8df5e9500e82ff8d74d860f45 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:24:52 +0700 Subject: [PATCH 15/20] test(m2): assert live getter derives exclusively from accepted native snapshot --- tests/reconciled_gui_engine_contract_test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/reconciled_gui_engine_contract_test.mjs b/tests/reconciled_gui_engine_contract_test.mjs index 2894a9d6d..cdcf5df3e 100644 --- a/tests/reconciled_gui_engine_contract_test.mjs +++ b/tests/reconciled_gui_engine_contract_test.mjs @@ -65,8 +65,8 @@ test('JUCE native resources use EXACT assembled Pages /preview/, not archived we assert.match(pagesBuilder,/buttons_dest=dst\/'preview'/); assert.match(generator,/approvedPagesHtmlSha256/); assert.match(generator,/M2_NATIVE_ACK_SNAPSHOT_GATED__PCM_NOT_CERTIFIED/); - assert.match(nativeAdapter,/acceptedGraphConnected: false/); - assert.match(nativeAdapter,/productionCallbackLive: false/); + assert.match(nativeAdapter,/get acceptedGraphConnected\(\) \{ return false; \}/); + assert.match(nativeAdapter,/get productionCallbackLive\(\) \{ return Boolean\(controller\?\.live\(\)\); \}/); // Historical web app still verifies its archival CSS/standalone consistency. // It is NEVER the native compiled mixer or a second GUI product. assert.ok(css.endsWith(oldSourceCss),'archival CSS byte relationship drift'); From b69db05cf461c5883a3b7226d51ddde8704fd053 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:25:43 +0700 Subject: [PATCH 16/20] fix(m2): source native callback ordinal from epoch-verified JUCE registry, never infer from port mask --- src/ApprovedConsoleM2Snapshot.h | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/ApprovedConsoleM2Snapshot.h b/src/ApprovedConsoleM2Snapshot.h index 41d10696a..560fe3f4b 100644 --- a/src/ApprovedConsoleM2Snapshot.h +++ b/src/ApprovedConsoleM2Snapshot.h @@ -38,32 +38,55 @@ inline juce::var build (const juce::var& installed, device->setProperty("outputArmed",open && !static_cast(actualDevice.getProperty("outputMuted",true))); juce::Array inputPorts,outputPorts,inputEndpoints,outputEndpoints; + // Correlate active JUCE mask with the EXACT callback ordinal published + // by LiveDryRoutingLab's verified per-epoch registry. A mask alone does + // not prove ordinal packing after device switch; no guessing allowed. + const auto verifiedInputs=route.getProperty("ports",juce::var()); + const auto verifiedOutputs=route.getProperty("outputPorts",juce::var()); const auto addPorts=[&](const char* enabledName,const char* labelsName, - const char* prefix,juce::Array& ports, + const char* prefix,const juce::var& verified, + juce::Array& ports, juce::Array& endpoints) { const auto enabled=actualDevice.getProperty(enabledName,juce::var()); const auto labels=actualDevice.getProperty(labelsName,juce::var()); const auto* indices=enabled.getArray(); const auto* names=labels.getArray(); - if (!open || !indices || !names) return; + const auto* actualCallbacks=verified.getArray(); + if (!open || !indices || !names || !actualCallbacks) return; for (const auto& value:*indices) { if (!value.isInt()) continue; const int pin=static_cast(value); if (pin<0 || pin>=names->size() || pin>255) continue; + int callback=-1; + for(int i=0;isize();++i) { + const auto& row=actualCallbacks->getReference(i); + if(juce::String(prefix)=="in") { + const auto actualPin=row.getProperty("port",juce::var()); + const auto actualCallback=row.getProperty("callback",juce::var()); + if(actualPin.isInt() && actualCallback.isInt() && + static_cast(actualPin)==pin) + callback=static_cast(actualCallback); + } else if(row.isInt() && static_cast(row)==pin) { + callback=i; + } + } + if(callback<0 || callback>255)continue; // no native proof => no endpoint const auto label=names->getReference(pin).toString(); if (label.isEmpty()) continue; auto entry=std::make_unique(); entry->setProperty("id",juce::String(prefix)+":"+juce::String(pin)); entry->setProperty("port",pin); - entry->setProperty("callback",static_cast(ports.size())); + entry->setProperty("callback",callback); entry->setProperty("label",label); entry->setProperty("active",true); ports.add(pin); endpoints.add(juce::var(entry.release())); } }; - addPorts("enabledInputs","inputNames","in",inputPorts,inputEndpoints); - addPorts("enabledOutputs","outputNames","out",outputPorts,outputEndpoints); + addPorts("enabledInputs","inputNames","in",verifiedInputs, + inputPorts,inputEndpoints); + addPorts("enabledOutputs","outputNames","out",verifiedOutputs, + outputPorts,outputEndpoints); device->setProperty("enabledInputs",juce::var(inputPorts)); device->setProperty("enabledOutputs",juce::var(outputPorts)); device->setProperty("inputEndpoints",juce::var(inputEndpoints)); From 0b6a7ba07d9884ca39eddbef3535acf9fc5070d8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:26:21 +0700 Subject: [PATCH 17/20] fix(m2): report exact JUCE active pin masks, expose actionable endpoints only when registry proves ordinal --- src/ApprovedConsoleM2Snapshot.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ApprovedConsoleM2Snapshot.h b/src/ApprovedConsoleM2Snapshot.h index 560fe3f4b..c0dc6fd96 100644 --- a/src/ApprovedConsoleM2Snapshot.h +++ b/src/ApprovedConsoleM2Snapshot.h @@ -87,8 +87,13 @@ inline juce::var build (const juce::var& installed, inputPorts,inputEndpoints); addPorts("enabledOutputs","outputNames","out",verifiedOutputs, outputPorts,outputEndpoints); - device->setProperty("enabledInputs",juce::var(inputPorts)); - device->setProperty("enabledOutputs",juce::var(outputPorts)); + // Physical masks are always the active JUCE device's truth, even when + // callback-registry proof has not yet arrived. Unverified pins simply + // have NO corresponding actionable endpoint until registry validation. + device->setProperty("enabledInputs",actualDevice.getProperty( + "enabledInputs",juce::var(juce::Array()))); + device->setProperty("enabledOutputs",actualDevice.getProperty( + "enabledOutputs",juce::var(juce::Array()))); device->setProperty("inputEndpoints",juce::var(inputEndpoints)); device->setProperty("outputEndpoints",juce::var(outputEndpoints)); result->setProperty("device",juce::var(device.release())); From aaf305d9e653a71e0d371ba814211dccbda1f1ff Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:27:54 +0700 Subject: [PATCH 18/20] fix(m2): bounded pending intent timeout invalidates state until fresh JUCE readback --- web/approved-native-m2-state.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/approved-native-m2-state.js b/web/approved-native-m2-state.js index 2706ff5a8..42f527173 100644 --- a/web/approved-native-m2-state.js +++ b/web/approved-native-m2-state.js @@ -202,12 +202,22 @@ } return true; } + function expirePending(requestId) { + if (!pending || pending.intent.requestId !== requestId) return false; + pending = null; candidate = null; + state = "NATIVE_ACK_TIMEOUT"; + notify(state, requestId); + // Timeouts are NOT rejections from JUCE. Never presume that a native + // transaction failed OR succeeded: force a fresh snapshot before retry. + accepted = null; + return true; + } function disconnect() { accepted = null; pending = null; candidate = null; state = "NATIVE_DISCONNECTED"; notify(state); } return Object.freeze({status, snapshot, live, pendingRequest, receiveSnapshot, - receiveAck, request, disconnect}); + receiveAck, request, expirePending, disconnect}); } return Object.freeze({uint64, validateSnapshot, createController}); }); From bb5f096dddc773306c22061d692aed2971ee47a6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:28:12 +0700 Subject: [PATCH 19/20] feat(m2): explicit native lock feedback and bounded ACK-timeout recovery in approved GUI --- web/approved-native-bridge.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 5ca91fc41..09c312fac 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -14,6 +14,13 @@ "-" + Math.floor(Math.random() * 0x100000000).toString(36), notify: status => { document.documentElement.dataset.armixNativeStatus = status; + if (status === "NATIVE_REJECTED" || + status === "DEVICE_CHANGED_INTENT_CANCELLED" || + status === "NATIVE_ACK_TIMEOUT") { + if (typeof say === "function") + say("Native control " + status.toLowerCase().replaceAll("_", " ") + + " · accepted audio state unchanged"); + } } }) : null; @@ -27,7 +34,21 @@ get acceptedSnapshot() { return controller?.snapshot() || null; }, get pendingIntent() { return controller?.pendingRequest() || null; }, request(operation, targetChannelId, payload) { - return controller?.request(operation, targetChannelId, payload) || null; + const token = controller?.request(operation, targetChannelId, payload); + if (token) { + // A missing native ACK must never leave the operator with indefinite + // PENDING or permit an unsafe retry against an unknown audio graph. + setTimeout(() => { + if (controller.pendingRequest()?.requestId === token) { + controller.expirePending(token); + backend.emitEvent("arMixConsoleSubscribe", { + protocol: "v6", schemaVersion: 6, + source: "APPROVED_PAGES_NATIVE_M2_TIMEOUT_RECOVERY" + }); + } + }, 4000); + } + return token || null; } }); Object.defineProperty(window, "__ARMIX_APPROVED_NATIVE_GUI__", { @@ -55,6 +76,7 @@ "level", "pan", "trim", "input", "output", "sendLevel", "sendPan", "mute", "solo", "format", "activeSend" ]); + let lastGuardNotice = 0; const guard = event => { const node = event.target?.closest?.( "[data-action],[data-field],.fader,.fx-grip,#preview" @@ -67,6 +89,16 @@ if (!audio) return; event.preventDefault(); event.stopImmediatePropagation(); + // Existing status strip, not a new widget or alternate GUI: be explicit + // that browser-only audio gestures are NOT native PCM transactions. + if (event.type === "click" || event.type === "pointerdown") { + const now = Date.now(); + if (now - lastGuardNotice > 1600) { + lastGuardNotice = now; + if (typeof say === "function") + say("Native controls waiting for accepted ChannelId mapping · no PCM edit applied"); + } + } }; for (const type of ["click", "input", "change", "pointerdown", "wheel", "keydown", "dragstart", "drop"]) From 28862dd4a79d8772bb34b73fd151853b94edb88c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 02:28:28 +0700 Subject: [PATCH 20/20] test(m2): missing ACK cannot promote graph or permit retry until native readback --- tests/approved_native_m2_contract_test.cjs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/approved_native_m2_contract_test.cjs b/tests/approved_native_m2_contract_test.cjs index f9e0cddc3..d8836b1ff 100644 --- a/tests/approved_native_m2_contract_test.cjs +++ b/tests/approved_native_m2_contract_test.cjs @@ -120,6 +120,21 @@ test('cannot send source outside actual enabled endpoints or unknown channel ids assert.equal(ctl.request('SET_FADER','1',{db:-5}),null); assert.equal(events.length,0); }); +test('ACK timeout never says rejected or accepted; requires fresh native snapshot',()=>{ + const {ctl}=session(); + ctl.receiveSnapshot(status()); + const id=ctl.request('SET_FADER','18446744073709551614',{db:-7}); + assert.equal(ctl.expirePending('other:12'),false); + assert.equal(ctl.expirePending(id),true); + assert.equal(ctl.pendingRequest(),null); + assert.equal(ctl.snapshot(),null); + assert.equal(ctl.status(),'NATIVE_ACK_TIMEOUT'); + assert.equal(ctl.receiveAck({requestId:id,status:'ACCEPTED',deviceEpoch:'69', + graphRevision:'6',rosterRevision:'2',errorCode:''}),false); + assert.equal(ctl.request('SET_FADER','18446744073709551614',{db:-7}),null); + assert.equal(ctl.receiveSnapshot(status('69','6')),true); + assert.equal(ctl.status(),'ACCEPTED_NATIVE_CALLBACK'); +}); test('native EXE exposes ONE approved GUI + truthful producer with no JS DSP',()=>{ const cpp=read('src/Main.cpp'),header=read('src/ApprovedConsoleM2Snapshot.h'); const adapter=read('web/approved-native-bridge.js');