From c66fcb9946c3279dcaceb1125cb93a2322d04c34 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 19 Nov 2026 09:51:33 +0700 Subject: [PATCH 1/2] fix(g-mv25): fence pending v6 edits when installed PCM producer authority changes --- tests/approved_native_m2_contract.test.cjs | 77 ++++++++++++++++++++++ web/approved-native-contract.js | 17 ++++- 2 files changed, 92 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 394e80061..142ec2d55 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -29,6 +29,83 @@ function gmv20AcceptedGraph() { return fixture; } +test("G-MV25 schema-v6 owner switch cancels no-ACK/ACKed ChannelId without stale PCM repaint",()=>{ + const base=gmv20AcceptedGraph(); + base.mixerSession={authority:"CHANNEL_ID",deviceEpoch:base.device.epoch, + routeRevision:base.graph.revision,rosterRevision:base.graph.rosterRevision}; + base.device.outputArmed=false; + const m4=clone(base); + m4.productionCallbackLive=false; + m4.graph.capabilities.callbackOwnsChannelIds=false; + m4.graph.capabilities.supportedOps=[]; + m4.mixerSession={authority:"M4",deviceEpoch:base.device.epoch, + routeRevision:base.graph.revision,rosterRevision:base.graph.rosterRevision}; + assert.ok(protocol.normalizeSnapshot(base)?.admitted); + assert.equal(protocol.normalizeSnapshot(m4)?.admitted,false); + assert.equal(protocol.nativeHardwareConfiguration(base.device), + protocol.nativeHardwareConfiguration(m4.device)); + for(const acknowledged of [false,true]){ + const emitted=[],accepted=[],controller=protocol.createController({ + emit:(name,payload)=>emitted.push({name,payload}), + onAccepted:(snapshot,confirmed)=>accepted.push({snapshot,confirmed}) + }); + assert.equal(controller.onSnapshot(clone(base)),true); + const pending=controller.intent("SET_FADER","7",{valueDb:-5}); + assert.equal(pending.ok,true); + if(acknowledged) { + assert.equal(controller.onAck({ + requestId:pending.requestId,status:"ACCEPTED",errorCode:"NONE", + deviceEpoch:base.device.epoch,graphRevision:base.graph.revision, + rosterRevision:base.graph.rosterRevision}),true); + assert.equal(controller.state().pending?.requestId,pending.requestId); + } + assert.equal(controller.onSnapshot(clone(m4)),true, + "same-epoch M4 authority must not be hidden behind old ChannelId ACK"); + assert.equal(controller.state().pending,null); + assert.equal(controller.state().lastError,"STALE_NATIVE_AUTHORITY"); + assert.equal(controller.state().current.admitted,false); + assert.equal(controller.state().current.raw.mixerSession.authority,"M4"); + assert.equal(accepted.length,2,"M4 readback is projected in the same callback"); + assert.equal(accepted[1].confirmed,undefined, + "an old ACK cannot confirm PCM on the replacement producer"); + assert.equal(controller.onAck({ + requestId:pending.requestId,status:"ACCEPTED",errorCode:"NONE", + deviceEpoch:base.device.epoch,graphRevision:base.graph.revision, + rosterRevision:base.graph.rosterRevision}),false, + "late ChannelId ACK cannot reactivate retired owner"); + assert.equal(controller.state().current.admitted,false); + assert.equal(controller.intent("SET_FADER","7",{valueDb:-4}).ok,false, + "unadmitted M4 has no ChannelId write authority"); + const recovered=clone(base); + recovered.graph.revision="6"; + recovered.graph.rosterRevision="8"; + recovered.mixerSession.routeRevision="6"; + recovered.mixerSession.rosterRevision="8"; + assert.equal(controller.onSnapshot(recovered),true); + assert.equal(controller.state().current.admitted,true); + assert.equal(controller.state().current.device.outputArmed,false, + "recovery never invents physical MONITOR ON"); + assert.equal(accepted.length,3); + assert.equal(accepted[2].confirmed,undefined, + "recovered producer readback is not confirmation of old fader intent"); + const send=controller.intent("SET_FADER","7",{valueDb:-4}); + assert.equal(send.ok,true,"fresh accepted revision can accept new UI gesture"); + assert.equal(emitted.filter(e=>e.name==="arMixConsoleIntent").length,2, + "no automatic replay of old local controls or monitor commands"); + assert.equal(emitted.some(e=>e.payload?.action==="monitor"),false); + } + const altered=clone(m4); + altered.graph.revision="4"; + const seen=[],c=protocol.createController({ + emit(){},onAccepted:n=>seen.push(n) + }); + assert.equal(c.onSnapshot(clone(base)),true); + assert.equal(c.onSnapshot(altered),false, + "older graph revisions remain fail-closed even across authority changes"); + assert.equal(c.state().lastError,"OLD_NATIVE_REVISION"); + assert.equal(seen.length,1); +}); + test("G-MV20 schema-v6 pending intent is fenced on same-epoch physical pin or format change",()=>{ const base=gmv20AcceptedGraph(),before=JSON.stringify(base); const hardware=protocol.nativeHardwareConfiguration(base.device); diff --git a/web/approved-native-contract.js b/web/approved-native-contract.js index fa8553f3c..79fd861ce 100644 --- a/web/approved-native-contract.js +++ b/web/approved-native-contract.js @@ -642,9 +642,22 @@ // A same-epoch physical pin/format reconfiguration invalidates the // current control lease even before ACK. Otherwise an older pending // v6 edit would suppress the new admitted snapshot indefinitely. + // G-MV25: an accepted ChannelId producer can relinquish the PCM + // graph to M4/UNADMITTED without a hardware or epoch change. A + // no-ACK local gesture must not freeze that newer authoritative + // snapshot until its old 8-second timer fires. Fence it at the SAME + // schema-v6 owner switch as the physical pin/epoch fence, before + // the pending ACK projection gate below. The native graph revision + // check above remains monotonic: never resurrect older PCM graphs. + const authorityChanged= + next.admitted!==current.admitted || + next.raw?.mixerSession?.authority!== + current.raw?.mixerSession?.authority; if (pending && (epochCompare !== 0 || next.retained || - next.hardwareConfiguration!==current.hardwareConfiguration)) { - pending=null;lastError="STALE_DEVICE"; + next.hardwareConfiguration!==current.hardwareConfiguration || + authorityChanged)) { + pending=null; + lastError=authorityChanged?"STALE_NATIVE_AUTHORITY":"STALE_DEVICE"; } } if (pending && !pending.ack) { From 3ee388a49190a7f014c59eceab95eaf99a4b6136 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 19 Nov 2026 09:53:53 +0700 Subject: [PATCH 2/2] fix(g-mv25): retain STALE_DEVICE semantics for NEEDS_REMAP and hardware identity loss --- web/approved-native-contract.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web/approved-native-contract.js b/web/approved-native-contract.js index 79fd861ce..b13705bbf 100644 --- a/web/approved-native-contract.js +++ b/web/approved-native-contract.js @@ -653,11 +653,14 @@ next.admitted!==current.admitted || next.raw?.mixerSession?.authority!== current.raw?.mixerSession?.authority; - if (pending && (epochCompare !== 0 || next.retained || - next.hardwareConfiguration!==current.hardwareConfiguration || - authorityChanged)) { + const physicalStale=epochCompare!==0||next.retained|| + next.hardwareConfiguration!==current.hardwareConfiguration; + if (pending && (physicalStale||authorityChanged)) { pending=null; - lastError=authorityChanged?"STALE_NATIVE_AUTHORITY":"STALE_DEVICE"; + // Preserve existing NEEDS_REMAP/physical-error contracts even if + // their PCM authority also changes. Distinguish only a pure + // same-device ChannelId → M4/UNADMITTED owner switch. + lastError=physicalStale?"STALE_DEVICE":"STALE_NATIVE_AUTHORITY"; } } if (pending && !pending.ack) {