From 596df02b01382219ca17b80b54dce61427f8d83b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 13:30:19 +0700 Subject: [PATCH 1/5] refactor(mv7): verify native SOURCE ACK revision and independently installed PCM readback --- web/approved-channel-strip-view-model.js | 42 ++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/web/approved-channel-strip-view-model.js b/web/approved-channel-strip-view-model.js index a1a5ffa4f..824e9a820 100644 --- a/web/approved-channel-strip-view-model.js +++ b/web/approved-channel-strip-view-model.js @@ -263,7 +263,10 @@ function sourceAckResult(pending,ack,authority) { if(!pending||ack?.requestId!==pending.requestId)return "IGNORE"; if(authority==="CHANNEL_ID") - return ack?.ok===true?"ACKED":"REJECTED"; + return ack?.ok===true && ack?.channelId===pending.id && + decimalId(pending.beforeRevision) && decimalId(ack.graphRevision) && + BigInt(ack.graphRevision)>BigInt(pending.beforeRevision)? + "ACKED":"REJECTED"; if(authority!=="M4")return "REJECTED"; const next=ack?.state||{},row=next.acceptedRoute?.channels?.[pending.channel]; return ack?.ok===true&&next.ready===true&& @@ -275,8 +278,43 @@ "ACKED":"REJECTED"; } + + // MV-7: ACK is only a correlated native acceptance, never proof of PCM. + // Compare the installed ChannelId SOURCE row, physical pins and exact + // revision without converting 64-bit graph identities through Number. + // The bridge remains the sole holder of the active transient request. + function sourceReadbackSettlement(pending,next) { + if(!pending)return "NONE"; + if(!decimalId(pending.id)||!decimalId(pending.epoch)|| + next?.device?.epoch!==pending.epoch|| + next?.retained===true||next?.admitted!==true|| + (next?.raw?.mixerSession && + next.raw.mixerSession.authority!=="CHANNEL_ID"))return "STALE"; + const rows=next?.graph?.channels; + if(!Array.isArray(rows))return "PENDING"; + const channel=rows.find(row=>row?.id===pending.id); + if(!channel||channel.role!=="INPUT")return "STALE"; + if(pending.acked!==true)return "PENDING_ACK"; + if(!decimalId(pending.ackRevision)|| + !decimalId(next.graph.revision)|| + BigInt(next.graph.revision) Date: Wed, 18 Nov 2026 13:31:07 +0700 Subject: [PATCH 2/5] refactor(mv7): hold native SOURCE transaction through correlated PCM readback --- web/approved-native-bridge.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index ec79d6495..60a3b284a 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -1049,7 +1049,8 @@ return; } const requestId="source-native-"+(++nativeSourceSerial); - activeNativeSource={requestId,id,choice:entry.choice,epoch:entry.epoch}; + activeNativeSource={requestId,id,choice:entry.choice,epoch:entry.epoch, + beforeRevision:current.graph.revision,acked:false}; backend.emitEvent("arMixAction",{ action:plan.action,requestId,...plan.payload }); @@ -1057,10 +1058,22 @@ window.setTimeout(()=>{ if(activeNativeSource?.requestId!==requestId)return; activeNativeSource=null; - nativeToast("Source ACK timed out · previous PCM preserved"); + status("SOURCE timeout · refreshing accepted PCM and input choices"); controller?.subscribe(); },8000); } + // Only independently installed ChannelId PCM readback may confirm SOURCE. + // Do not release the one active native transaction after ACK alone. + function settleNativeSourceReadback(next) { + const verdict=stripVM.sourceReadbackSettlement(activeNativeSource,next); + if(verdict!=="CONFIRMED"&&verdict!=="STALE")return; + const settled=activeNativeSource; + activeNativeSource=null; + if(verdict==="CONFIRMED") + status("Input "+settled.choice.label+" · native PCM readback verified"); + else status("SOURCE changed or disconnected · accepted input refreshed"); + if(pendingNativeSources.size)window.queueMicrotask(dispatchNativeSource); + } let pendingBusCreate=null,pendingTrackDelete=null,stripRequestSerial=0; function requestNativeTrackDelete(track){ if(logicalView)return logicalIntent("DELETE_CHANNEL",nativeIdFor(track),{}).ok; @@ -2668,6 +2681,7 @@ status("NATIVE READBACK INVALID · existing GUI controls unchanged"); return; } + settleNativeSourceReadback(next); if(readModel.kind==="LOGICAL_ONLY") { const staged=readModel.view; let revealCreatedId=null,wireImpact=null; @@ -2979,10 +2993,17 @@ backend.addEventListener("arMixNativeSourceAck",ack=>{ const verdict=stripVM.sourceAckResult(activeNativeSource,ack,"CHANNEL_ID"); if(verdict==="IGNORE")return; - activeNativeSource=null; - if(verdict!=="ACKED") + if(verdict==="ACKED"){ + // ACK contains the publisher revision, but is not yet installed PCM. + activeNativeSource={...activeNativeSource,acked:true, + ackRevision:ack.graphRevision}; + status("Native input ACKed · verifying accepted PCM source"); + // An independently accepted snapshot can race ahead of the ACK. + settleNativeSourceReadback(controller?.state()?.current); + }else{ + activeNativeSource=null; nativeToast("Native input rejected · "+(ack?.error||"stale PCM")); - else status("Native input accepted · checking subsequent PCM readback"); + } controller?.subscribe(); }); backend.addEventListener("arMixNativeBusAck",ack=>{ From f1da56eab8ef3c2efe7ccc9e1e01cf2ca0b35ea1 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 13:32:25 +0700 Subject: [PATCH 3/5] test(mv7): prove SOURCE ACK not PCM; exact pins, revision and queued readback gate --- tests/approved_native_m2_contract.test.cjs | 102 +++++++++++++++++++-- 1 file changed, 96 insertions(+), 6 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 2fcdb13d3..271551540 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -15,6 +15,57 @@ const clone=x=>JSON.parse(JSON.stringify(x)); // GUI-4: SOURCE ONLY and physical PRIMARY OUT must not consume a parallel SEND. + +test("MV-7 native SOURCE requires ACKed graph revision AND independently installed input pins",()=>{ + const id="9007199254740993",epoch="18446744073709551610"; + const beforeRevision="9223372036854775807",afterRevision="9223372036854775808"; + const p={requestId:"source-native-99",id,epoch,beforeRevision, + choice:{label:"Mic A",mode:"STEREO",left:2,right:3},acked:false}; + const snapshot={admitted:true,retained:false,device:{epoch}, + graph:{revision:beforeRevision,channels:[{id,role:"INPUT", + source:{portId:"in:2",portIdRight:"in:3",sourceFormat:"STEREO"}}]}}; + const before=JSON.stringify(snapshot); + const settle=(request,readback=snapshot)=>stripVM.sourceReadbackSettlement(request,readback); + assert.equal(settle(null),"NONE"); + assert.equal(settle(p),"PENDING_ACK"); + assert.equal(settle({...p,acked:true,ackRevision:afterRevision}),"PENDING", + "even matching pins at old revision are not accepted readback"); + const installed=clone(snapshot);installed.graph.revision=afterRevision; + assert.equal(settle({...p,acked:true,ackRevision:afterRevision},installed), + "CONFIRMED"); + assert.equal(JSON.stringify(snapshot),before,"VM cannot mutate accepted PCM"); + const acked={...p,acked:true,ackRevision:afterRevision}; + const other=clone(installed);other.graph.channels[0].source.portIdRight="in:4"; + assert.equal(settle(acked,other),"PENDING", + "stereo right pin must independently match native source readback"); + const wrongFormat=clone(installed); + wrongFormat.graph.channels[0].source.sourceFormat="MONO"; + assert.equal(settle(acked,wrongFormat),"PENDING"); + const noRoute=clone(installed);delete noRoute.graph.channels[0].source; + assert.equal(settle(acked,noRoute),"PENDING"); + const reconnect=clone(installed);reconnect.device.epoch="18446744073709551611"; + assert.equal(settle(acked,reconnect),"STALE"); + assert.equal(settle(acked,{...installed,retained:true,admitted:false}),"STALE"); + const missing=clone(installed);missing.graph.channels=[]; + assert.equal(settle(acked,missing),"STALE"); + const mono={...acked,choice:{label:"Mono",mode:"MONO",left:2,right:-1}}; + const monoread=clone(installed);delete monoread.graph.channels[0].source.portIdRight; + monoread.graph.channels[0].source.sourceFormat="MONO"; + assert.equal(settle(mono,monoread),"CONFIRMED"); + const none={...acked,choice:{label:"None",mode:"NONE",left:-1,right:-1}}; + assert.equal(settle(none,noRoute),"CONFIRMED"); + assert.equal(settle(none,installed),"PENDING", + "SOURCE NONE must not remove a physical input from UI before installed PCM"); + const model=read("web/approved-channel-strip-view-model.js"); + const bridge=read("web/approved-native-bridge.js"); + assert.match(bridge,/stripVM\.sourceReadbackSettlement\(/); + assert.match(bridge,/beforeRevision:current\.graph\.revision,acked:false/); + assert.match(bridge,/ackRevision:ack\.graphRevision/); + assert.match(bridge,/settleNativeSourceReadback\(next\)/); + assert.doesNotMatch(model,/backend\.emitEvent|document\.|window\.setTimeout/, + "Channel Strip readback remains pure; bridge holds one transient source queue"); +}); + test("MV-6 SOURCE input queues bind exact native device epoch and verified pins",()=>{ const choices=[{label:"None",mode:"NONE",left:-1,right:-1}, {label:"Mono · IN 1",mode:"MONO",left:0,right:-1}, @@ -124,12 +175,26 @@ test("MV-6 M4 SOURCE dispatch reuses fresh revision but never migrates stale dev assert.equal(stripVM.sourceAckResult(pending,{...ack,state:{...ack.state, acceptedRoute:{channels:Array.from({length:10},(_,i)=>i===4? {mode:"MONO",left:2,right:-1}:null)}}},"M4"),"REJECTED"); - assert.equal(stripVM.sourceAckResult({requestId:"source-native-1"}, - {requestId:"source-native-1",ok:true},"CHANNEL_ID"),"ACKED"); - assert.equal(stripVM.sourceAckResult({requestId:"source-native-1"}, - {requestId:"source-native-2",ok:true},"CHANNEL_ID"),"IGNORE"); - assert.equal(stripVM.sourceAckResult({requestId:"source-native-1"}, - {requestId:"source-native-1",ok:false},"CHANNEL_ID"),"REJECTED"); + const nativePending={requestId:"source-native-1", + id:"9007199254740993",epoch:"18446744073709551610", + beforeRevision:"9223372036854775807"}; + const nativeAck={requestId:"source-native-1", + channelId:"9007199254740993",graphRevision:"9223372036854775808", + ok:true}; + assert.equal(stripVM.sourceAckResult(nativePending,nativeAck,"CHANNEL_ID"), + "ACKED"); + assert.equal(stripVM.sourceAckResult(nativePending, + {...nativeAck,requestId:"source-native-2"},"CHANNEL_ID"),"IGNORE"); + assert.equal(stripVM.sourceAckResult(nativePending, + {...nativeAck,ok:false},"CHANNEL_ID"),"REJECTED"); + assert.equal(stripVM.sourceAckResult(nativePending, + {...nativeAck,channelId:"9007199254740994"},"CHANNEL_ID"),"REJECTED"); + assert.equal(stripVM.sourceAckResult(nativePending, + {...nativeAck,graphRevision:nativePending.beforeRevision},"CHANNEL_ID"), + "REJECTED"); + assert.equal(stripVM.sourceAckResult(nativePending, + {...nativeAck,graphRevision:"18446744073709551616"},"CHANNEL_ID"), + "REJECTED"); const bridge=read("web/approved-native-bridge.js"); assert.match(bridge,/stripVM\.sourceQueueSelection\(/); assert.equal((bridge.match(/stripVM\.sourceDispatchPlan\(/g)||[]).length,2, @@ -2248,6 +2313,31 @@ test("P0 native hardware IN remains selectable after ChannelId ownership, failed assert.equal(sourceCommands()[1].payload.left,1); assert.equal(sourceCommands()[1].payload.graphRevision,base.graph.revision); assert.notEqual(sourceCommands()[1].payload.requestId,id); + // MV-7: a later positive ACK must NOT drain a third channel edit until the + // exact new source pins and native graph revision are observed separately. + assert.equal(choose(scope.tracks[0],"Mono · Mic A [IN 1]"),true); + const secondCommand=sourceCommands()[1]; + listeners.get("arMixNativeSourceAck")({ + requestId:secondCommand.payload.requestId,channelId:second.id, + graphRevision:"6",ok:true + }); + assert.equal(sourceCommands().length,2,"ACK is not installed PCM readback"); + listeners.get("arMixConsoleSnapshot")(base); + while(microtasks.length)microtasks.shift()(); + assert.equal(sourceCommands().length,2, + "unchanged pre-ACK PCM must hold next queued SOURCE"); + const installed=clone(base); + installed.graph.revision="6"; + installed.graph.channels.find(ch=>ch.id===second.id).source={ + sourceFormat:"MONO",portId:"in:1" + }; + installed.mixerSession.routeRevision="6"; + listeners.get("arMixConsoleSnapshot")(installed); + while(microtasks.length)microtasks.shift()(); + assert.equal(sourceCommands().length,3, + "installed source readback unlocks only one next queued edit"); + assert.equal(sourceCommands()[2].payload.channelId,first.id); + assert.equal(sourceCommands()[2].payload.graphRevision,"6"); }); test("M3/V60 Windows bundle dispatches exactly one fader release through native ACK and fences FX reorder",()=>{ const builder=read("scripts/build_approved_native_gui.py"); From fed78a39e0a76d3f3de5f8b6c8cd291cc283cc65 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 13:37:28 +0700 Subject: [PATCH 4/5] fix(mv7): reject mismatched session authority/epoch and non-advancing native readback revision --- web/approved-channel-strip-view-model.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/approved-channel-strip-view-model.js b/web/approved-channel-strip-view-model.js index 824e9a820..8364df9c3 100644 --- a/web/approved-channel-strip-view-model.js +++ b/web/approved-channel-strip-view-model.js @@ -288,15 +288,17 @@ if(!decimalId(pending.id)||!decimalId(pending.epoch)|| next?.device?.epoch!==pending.epoch|| next?.retained===true||next?.admitted!==true|| - (next?.raw?.mixerSession && - next.raw.mixerSession.authority!=="CHANNEL_ID"))return "STALE"; + (next?.raw && (next.raw.mixerSession?.authority!=="CHANNEL_ID"|| + next.raw.mixerSession.deviceEpoch!==pending.epoch)))return "STALE"; const rows=next?.graph?.channels; if(!Array.isArray(rows))return "PENDING"; const channel=rows.find(row=>row?.id===pending.id); if(!channel||channel.role!=="INPUT")return "STALE"; if(pending.acked!==true)return "PENDING_ACK"; - if(!decimalId(pending.ackRevision)|| + if(!decimalId(pending.beforeRevision)|| + !decimalId(pending.ackRevision)|| !decimalId(next.graph.revision)|| + BigInt(pending.ackRevision)<=BigInt(pending.beforeRevision)|| BigInt(next.graph.revision) Date: Wed, 18 Nov 2026 13:37:48 +0700 Subject: [PATCH 5/5] test(mv7): reject mismatched session generation and non-advancing ACK revision --- tests/approved_native_m2_contract.test.cjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 271551540..31e225bc1 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -46,6 +46,12 @@ test("MV-7 native SOURCE requires ACKed graph revision AND independently install const reconnect=clone(installed);reconnect.device.epoch="18446744073709551611"; assert.equal(settle(acked,reconnect),"STALE"); assert.equal(settle(acked,{...installed,retained:true,admitted:false}),"STALE"); + assert.equal(settle(acked,{...installed,raw:{mixerSession:{ + authority:"M4",deviceEpoch:epoch}}}),"STALE"); + assert.equal(settle(acked,{...installed,raw:{mixerSession:{ + authority:"CHANNEL_ID",deviceEpoch:"18446744073709551611"}}}),"STALE"); + assert.equal(settle({...acked,ackRevision:beforeRevision},installed),"PENDING", + "ACK publisher revision cannot equal original accepted source graph"); const missing=clone(installed);missing.graph.channels=[]; assert.equal(settle(acked,missing),"STALE"); const mono={...acked,choice:{label:"Mono",mode:"MONO",left:2,right:-1}};