From 6bf577a865ef50c9a07dcea8b9f6fa3b7fda4b41 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 19 Nov 2026 21:38:39 +0700 Subject: [PATCH 1/3] refactor(gui G-MV33): consolidate M4 FX lease authority and first-ACK-wins --- tests/approved_native_m2_contract.test.cjs | 125 ++++++++++++++++++++- web/approved-fx-rack-view-model.js | 115 ++++++++++--------- web/approved-native-bridge.js | 21 ++-- 3 files changed, 200 insertions(+), 61 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index f15acb71b..a3aacaded 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -4590,7 +4590,7 @@ test("G-MV28 M4 rack settlement needs exact full installed snapshot, not an old const source=read("web/approved-native-bridge.js"); assert.ok(source.includes("fxRackVM.m4Presentation(")); assert.ok(source.includes("fxRackVM.nativePowerSettlement(")); - assert.match(source,/fxRackVM\.m4RackSettlement\(p,next\)/); + assert.match(source,/fxRackVM\.m4RackSettlement\(p,next,/); assert.doesNotMatch(source,/const actual=p\.kind==="rack"\?/); }); @@ -5931,7 +5931,7 @@ test("G-MV30 bridge has one M4 insert IPC, and never paints or opens from ack.st source=read("web/approved-fx-rack-view-model.js"); assert.match(bridge,/fxRackVM\.m4InsertPlan\(accepted,/); assert.match(bridge,/fxRackVM\.m4InsertAckResult\(pendingFxInsert,ack\)/); - assert.match(bridge,/fxRackVM\.m4InsertReadbackSettlement\(p,snapshot\)/); + assert.match(bridge,/fxRackVM\.m4InsertReadbackSettlement\(p,snapshot,/); assert.match(bridge,/reconcileM4FxInsertReadback\(next\)/); assert.equal((bridge.match(/action:"routingFxInsert"/g)||[]).length,0, "bridge must emit one ViewModel-planned action, not a duplicated raw dispatcher"); @@ -6053,3 +6053,124 @@ test("G-MV31 bridge delegates deferred and manually opened FX editors to one pur assert.doesNotMatch(read("web/approved-fx-rack-view-model.js"), /backend\.emitEvent|document\.|window\.|setTimeout/); }); + + +test("G-MV33 exact M4 FX host admission and hardware-scoped transaction settlement",()=>{ + const device={epoch:"31",sampleRate:48000,bufferFrames:256, + enabledInputs:[0,1],enabledOutputs:[0,1]}; + const token=protocol.nativeHardwareConfiguration(device); + assert.equal(typeof token,"string"); + const base={admitted:false,retained:false,device,raw:{ + mixerSession:{authority:"M4",deviceEpoch:"31",routeRevision:"12", + channels:Array.from({length:10},()=>({fxRackBypassed:false}))}, + legacyM4:{active:true,routeAccepted:true,nativeBusStructural:false, + routingRevision:"12",fxInstances:Array.from({length:10},(_,i)=>i===4? + [{instanceId:"fx-old",catalogId:"vendor.old",bypassed:false}]:[])} + }}; + const opts={channel:4,verifiedM4:true,hardwareConfiguration:token}; + const rack=fxRackVM.m4PowerPlan(base,{...opts,action:"fxOn"}); + const power=fxRackVM.m4PowerPlan(base,{...opts,action:"slotPower",slot:0}); + const insert=fxRackVM.m4InsertPlan(base,{...opts,slot:1,catalogId:"vendor.new"}); + const editor=fxRackVM.m4EditorPlan(base,{...opts,slot:0}); + assert.deepEqual([rack.kind,power.kind,insert.kind,editor.kind], + ["READY","READY","READY","OPEN"]); + for(const plan of [rack,power,insert]) + assert.equal(plan.pending.hardwareConfiguration,token); + assert.equal(editor.instanceId,"fx-old"); + for(const delta of [ + {verifiedM4:false},{offline:true},{hardwareConfiguration:null}, + {hardwareConfiguration:""},{channel:10} + ]){ + const input={...opts,...delta}; + assert.equal(fxRackVM.m4PowerPlan(base,{...input,action:"fxOn"}).kind, + "UNAVAILABLE"); + assert.equal(fxRackVM.m4InsertPlan(base,{...input,slot:1, + catalogId:"vendor.new"}).kind,"UNAVAILABLE"); + assert.equal(fxRackVM.m4EditorPlan(base,{...input,slot:0}).kind, + "UNAVAILABLE"); + } + for(const change of [ + s=>{s.admitted=true;},s=>{s.retained=true;}, + s=>{s.raw.mixerSession.authority="CHANNEL_ID";}, + s=>{s.raw.mixerSession.routeRevision="13";}, + s=>{s.raw.legacyM4.active=false;}, + s=>{s.raw.legacyM4.routeAccepted=false;}, + s=>{s.raw.legacyM4.nativeBusStructural=true;}, + s=>{s.raw.legacyM4.routingRevision="9007199254740993";}, + s=>{s.device.epoch="32";} + ]){ + const changed=clone(base);change(changed); + assert.equal(fxRackVM.m4PowerPlan(changed,{...opts,action:"fxOn"}).kind,"UNAVAILABLE"); + assert.equal(fxRackVM.m4InsertPlan(changed,{...opts,slot:1, + catalogId:"vendor.new"}).kind,"UNAVAILABLE"); + assert.equal(fxRackVM.m4EditorPlan(changed,{...opts,slot:0}).kind,"UNAVAILABLE"); + } + const remapped=clone(base);remapped.device.enabledInputs=[2,3]; + const newer=protocol.nativeHardwareConfiguration(remapped.device); + assert.notEqual(newer,token); + remapped.raw.mixerSession.channels[4].fxRackBypassed=true; + remapped.raw.legacyM4.fxInstances[4][0].bypassed=true; + assert.equal(fxRackVM.m4RackSettlement( + {...rack.pending,acked:true},remapped,newer),"STALE"); + assert.equal(fxRackVM.m4SlotPowerSettlement( + {...power.pending,acked:true},remapped,newer),"STALE"); + const installed=clone(remapped); + installed.raw.legacyM4.routingRevision="13"; + installed.raw.mixerSession.routeRevision="13"; + installed.raw.legacyM4.fxInstances[4][1]={ + instanceId:"fx-new",catalogId:"vendor.new",bypassed:false}; + assert.equal(fxRackVM.m4InsertReadbackSettlement( + {...insert.pending,acked:true},installed,newer).kind,"STALE"); + assert.equal(fxRackVM.m4RackSettlement( + {...rack.pending,acked:true},base,token),"WAIT"); + const acceptedRack=clone(base); + acceptedRack.raw.mixerSession.channels[4].fxRackBypassed=true; + assert.equal(fxRackVM.m4RackSettlement( + {...rack.pending,acked:true},acceptedRack,token),"CONFIRMED"); + const acceptedPower=clone(base); + acceptedPower.raw.legacyM4.fxInstances[4][0].bypassed=true; + assert.equal(fxRackVM.m4SlotPowerSettlement( + {...power.pending,acked:true},acceptedPower,token),"CONFIRMED"); + const acceptedInsert=clone(base); + acceptedInsert.raw.legacyM4.routingRevision="13"; + acceptedInsert.raw.mixerSession.routeRevision="13"; + acceptedInsert.raw.legacyM4.fxInstances[4][1]={ + instanceId:"fx-new",catalogId:"vendor.new",bypassed:false}; + assert.equal(fxRackVM.m4InsertReadbackSettlement( + {...insert.pending,acked:true},acceptedInsert,token).kind,"CONFIRMED"); + assert.equal(fxRackVM.m4InsertReadbackSettlement( + {...insert.pending,acked:false},acceptedInsert,token).kind,"WAIT"); + assert.equal(fxRackVM.m4InsertReadbackSettlement( + {...insert.pending,acked:true},acceptedInsert,null).kind,"STALE"); +}); +test("G-MV33 late duplicate negative ACK cannot discard verified FX lease",()=>{ + const rack={requestId:"rack-1",channel:4,epoch:"31",revision:"12", + bypassed:true,acked:true}; + const rackAck={requestId:"rack-1",channel:4,deviceEpoch:31, + routingRevision:12,bypassed:true,ok:false}; + assert.equal(fxRackVM.m4RackAckResult(rack,rackAck),"IGNORE"); + assert.equal(fxRackVM.m4RackAckResult({...rack,acked:false},rackAck),"REJECTED"); + const power={requestId:"power-1",channel:4,slot:0,acked:true}; + const powerAck={requestId:"power-1",channel:4,slot:0,ok:false}; + assert.equal(fxRackVM.m4SlotPowerAckResult(power,powerAck),"IGNORE"); + assert.equal(fxRackVM.m4SlotPowerAckResult({...power,acked:false},powerAck), + "REJECTED"); + const insert={authority:"M4",requestId:"insert-1",channel:4,slot:1,acked:true}; + const insertAck={requestId:"insert-1",channel:4,slot:1,ok:false, + state:{fxInstances:[{instanceId:"fake"}]}}; + assert.equal(fxRackVM.m4InsertAckResult(insert,insertAck),"IGNORE"); + assert.equal(fxRackVM.m4InsertAckResult({...insert,acked:false},insertAck), + "REJECTED"); + const source=read("web/approved-fx-rack-view-model.js"); + const bridge=read("web/approved-native-bridge.js"); + assert.equal((source.match(/function m4FxHost\(/g)||[]).length,1); + assert.equal((source.match(/const host=m4FxHost\(snapshot,/g)||[]).length,3); + for(const name of ["m4PowerPlan","m4InsertPlan","m4EditorPlan"]) + assert.match(source,new RegExp("function "+name+"\\(snapshot,")); + assert.match(bridge,/hardwareConfiguration:protocol\.nativeHardwareConfiguration\(current\?\.device\)/); + assert.match(bridge,/hardwareConfiguration:protocol\.nativeHardwareConfiguration\(accepted\?\.device\)/); + assert.match(bridge,/fxRackVM\.m4RackSettlement\(p,next,/); + assert.match(bridge,/fxRackVM\.m4SlotPowerSettlement\(p,next,/); + assert.match(bridge,/fxRackVM\.m4InsertReadbackSettlement\(p,snapshot,/); + assert.doesNotMatch(source,/backend\.emitEvent|document\.|window\.|setTimeout/); +}); diff --git a/web/approved-fx-rack-view-model.js b/web/approved-fx-rack-view-model.js index 405ecc438..47aa86921 100644 --- a/web/approved-fx-rack-view-model.js +++ b/web/approved-fx-rack-view-model.js @@ -110,11 +110,13 @@ const n=Number(x); return Number.isSafeInteger(n)&&n>0? n:null; } - function m4PowerPlan(snapshot,{action,channel,slot=null, - verifiedM4=false,offline=false,pending=false}={}) { - const unavailable={kind:"UNAVAILABLE"}; - const s=snapshot?.raw?.mixerSession,m=snapshot?.raw?.legacyM4, - epoch=safeM4Token(snapshot?.device?.epoch), + // G-MV33: ONE immutable-readback physical M4 FX admission core. + // The bridge provides the existing protocol's canonical hardware fingerprint; + // no second device model, FX host, WebView controller or IPC dispatcher. + function m4FxHost(snapshot,{channel,slot=null,verifiedM4=false, + offline=false,pending=false,hardwareConfiguration}={}) { + const s=snapshot?.raw?.mixerSession,m=snapshot?.raw?.legacyM4; + const epoch=safeM4Token(snapshot?.device?.epoch), revision=safeM4Token(m?.routingRevision); if(pending||offline||verifiedM4!==true|| snapshot?.admitted!==false||snapshot?.retained===true|| @@ -125,21 +127,42 @@ s.routeRevision!==m.routingRevision|| !Array.isArray(s.channels)||s.channels.length!==10|| !Number.isInteger(channel)||channel<0||channel>=10|| - !s.channels[channel])return unavailable; - const lease={channel,epoch:s.deviceEpoch, - revision:s.routeRevision,acked:false}; - if(action==="fxOn") { + !s.channels[channel]|| + (slot!==null&&(!Number.isInteger(slot)||slot<0||slot>=8))|| + (hardwareConfiguration!==undefined&& + (typeof hardwareConfiguration!=="string"||!hardwareConfiguration))) + return null; + return {s,m,epoch,revision,hardwareConfiguration: + hardwareConfiguration===undefined?null:hardwareConfiguration}; + } + function m4FxHardwareLease(host){ + return host.hardwareConfiguration===null?{}: + {hardwareConfiguration:host.hardwareConfiguration}; + } + function m4FxHardwareMatches(pending,hardwareConfiguration){ + return !Object.prototype.hasOwnProperty.call(pending,"hardwareConfiguration")|| + (typeof hardwareConfiguration==="string"&& + pending.hardwareConfiguration===hardwareConfiguration); + } + function m4PowerPlan(snapshot,{action,channel,slot=null, + verifiedM4=false,offline=false,pending=false,hardwareConfiguration}={}) { + const unavailable={kind:"UNAVAILABLE"}; + const host=m4FxHost(snapshot,{channel,slot,verifiedM4,offline,pending, + hardwareConfiguration}); + if(!host)return unavailable; + const {s,m,epoch,revision}=host; + const lease={channel,epoch:s.deviceEpoch,revision:s.routeRevision, + acked:false,...m4FxHardwareLease(host)}; + if(action==="fxOn"){ const row=s.channels[channel]; if(typeof row.fxRackBypassed!=="boolean"||slot!==null) return unavailable; const bypassed=!row.fxRackBypassed; return {kind:"READY",action:"routingFxRackBypass",key:channel, - timeoutMs:8000, - pending:{...lease,bypassed}, + timeoutMs:8000,pending:{...lease,bypassed}, payload:{channel,deviceEpoch:epoch,revision,value:bypassed}}; } - if(action!=="slotPower"||!Number.isInteger(slot)|| - slot<0||slot>=8)return unavailable; + if(action!=="slotPower"||slot===null)return unavailable; const instances=m.fxInstances?.[channel],live=instances?.[slot]; if(!Array.isArray(instances)|| typeof live?.instanceId!=="string"||!live.instanceId|| @@ -153,13 +176,14 @@ deviceEpoch:epoch,revision,value:bypass}}; } function m4RackAckResult(pending,ack) { - if(!pending||!ack||ack.requestId!==pending.requestId)return "IGNORE"; + if(!pending||!ack||ack.requestId!==pending.requestId|| + pending.acked===true)return "IGNORE"; return ack.ok===true&&ack.channel===pending.channel&& String(ack.deviceEpoch)===pending.epoch&& String(ack.routingRevision)===pending.revision&& ack.bypassed===pending.bypassed?"ACKED":"REJECTED"; } - function m4RackSettlement(pending,snapshot) { + function m4RackSettlement(pending,snapshot,hardwareConfiguration) { if(!pending)return "NONE"; const s=snapshot?.raw?.mixerSession,m=snapshot?.raw?.legacyM4; if(snapshot?.admitted!==false||snapshot?.retained===true|| @@ -169,6 +193,7 @@ s.deviceEpoch!==pending.epoch|| s.routeRevision!==pending.revision|| m.routingRevision!==pending.revision|| + !m4FxHardwareMatches(pending,hardwareConfiguration)|| !Number.isInteger(pending.channel)|| pending.channel<0||pending.channel>=10|| !Array.isArray(s.channels)||s.channels.length!==10) @@ -202,39 +227,31 @@ // independent, validated Console-v6 PCM readback. Editors open only when // the accepted M4 snapshot proves the exact new catalog/instance/route. function m4InsertPlan(snapshot,{channel,slot,catalogId, - verifiedM4=false,offline=false,pending=false}={}) { + verifiedM4=false,offline=false,pending=false,hardwareConfiguration}={}) { const unavailable={kind:"UNAVAILABLE"}; - const s=snapshot?.raw?.mixerSession,m=snapshot?.raw?.legacyM4; - const epoch=safeM4Token(snapshot?.device?.epoch), - revision=safeM4Token(m?.routingRevision); - if(offline||pending||verifiedM4!==true|| - snapshot?.admitted!==false||snapshot?.retained===true|| - s?.authority!=="M4"||m?.active!==true||m?.routeAccepted!==true|| - m.nativeBusStructural===true|| - epoch===null||revision===null|| - s.deviceEpoch!==snapshot.device.epoch|| - s.routeRevision!==m.routingRevision|| - !Array.isArray(s.channels)||s.channels.length!==10|| - !Number.isInteger(channel)||channel<0||channel>=10|| - !s.channels[channel]|| - !Number.isInteger(slot)||slot<0||slot>=8|| - typeof catalogId!=="string"||!catalogId)return unavailable; + const host=m4FxHost(snapshot,{channel,slot,verifiedM4,offline,pending, + hardwareConfiguration}); + if(!host||slot===null||typeof catalogId!=="string"||!catalogId) + return unavailable; + const {m,epoch,revision}=host; const instances=m.fxInstances?.[channel]; if(!Array.isArray(instances)||instances[slot]!=null|| (slot>0&&instances[slot-1]==null))return unavailable; return {kind:"READY",action:"routingFxInsert", payload:{id:catalogId,channel,slot,deviceEpoch:epoch,revision}, pending:{authority:"M4",id:catalogId,channel,slot, - epoch:snapshot.device.epoch,revision:m.routingRevision,acked:false}}; + epoch:snapshot.device.epoch,revision:m.routingRevision,acked:false, + ...m4FxHardwareLease(host)}}; } function m4InsertAckResult(pending,ack){ if(!pending||pending.authority!=="M4"|| - !ack||ack.requestId!==pending.requestId)return "IGNORE"; + !ack||ack.requestId!==pending.requestId|| + pending.acked===true)return "IGNORE"; return ack.ok===true&&ack.channel===pending.channel&& ack.slot===pending.slot?"ACKED":"REJECTED"; // Deliberately ignore ack.state, including FX inventory and revision. } - function m4InsertReadbackSettlement(pending,snapshot){ + function m4InsertReadbackSettlement(pending,snapshot,hardwareConfiguration){ if(!pending||pending.authority!=="M4")return {kind:"NONE"}; const s=snapshot?.raw?.mixerSession,m=snapshot?.raw?.legacyM4, revision=safeM4Token(m?.routingRevision), @@ -246,6 +263,7 @@ s.deviceEpoch!==pending.epoch|| s.routeRevision!==m.routingRevision|| previous===null||revision===null||revision=10|| !Number.isInteger(pending.slot)||pending.slot<0||pending.slot>=8) return {kind:"STALE"}; @@ -315,21 +333,12 @@ // M4 uses host ordinals, never ChannelIds. An old accepted FX inventory // cannot be permission to open an editor after device/route owner changes. function m4EditorPlan(snapshot,{channel,slot,verifiedM4=false, - offline=false}={}) { - const unavailable={kind:"UNAVAILABLE"},s=snapshot?.raw?.mixerSession, - m=snapshot?.raw?.legacyM4, - epoch=safeM4Token(snapshot?.device?.epoch), - revision=safeM4Token(m?.routingRevision); - if(offline||verifiedM4!==true||snapshot?.admitted!==false|| - snapshot?.retained===true||s?.authority!=="M4"|| - m?.active!==true||m.routeAccepted!==true|| - m.nativeBusStructural===true||epoch===null||revision===null|| - s.deviceEpoch!==snapshot.device.epoch|| - s.routeRevision!==m.routingRevision|| - !Array.isArray(s.channels)||s.channels.length!==10|| - !Number.isInteger(channel)||channel<0||channel>=10|| - !s.channels[channel]|| - !Number.isInteger(slot)||slot<0||slot>=8)return unavailable; + offline=false,hardwareConfiguration}={}) { + const unavailable={kind:"UNAVAILABLE"}; + const host=m4FxHost(snapshot,{channel,slot,verifiedM4,offline, + hardwareConfiguration}); + if(!host||slot===null)return unavailable; + const {m,epoch,revision}=host; const slots=m.fxInstances?.[channel]; if(!Array.isArray(slots))return unavailable; const effect=slots[slot]; @@ -484,12 +493,13 @@ // M4 compatibility FX slot ACK is NOT readback. Keep the per-slot lease // locked until independent accepted M4 snapshot proves its exact token. function m4SlotPowerAckResult(pending,ack){ - if(!pending||!ack||pending.requestId!==ack.requestId)return "IGNORE"; + if(!pending||!ack||pending.requestId!==ack.requestId|| + pending.acked===true)return "IGNORE"; if(ack.channel!==pending.channel||ack.slot!==pending.slot|| ack.ok!==true)return "REJECTED"; return "ACKED"; } - function m4SlotPowerSettlement(pending,snapshot){ + function m4SlotPowerSettlement(pending,snapshot,hardwareConfiguration){ if(!pending)return "NONE"; const session=snapshot?.raw?.mixerSession,m=snapshot?.raw?.legacyM4; if(snapshot?.retained===true||snapshot?.admitted===true|| @@ -497,7 +507,8 @@ snapshot?.device?.epoch!==pending.epoch|| session.deviceEpoch!==pending.epoch|| session.routeRevision!==pending.revision|| - m?.routingRevision!==pending.revision)return "STALE"; + m?.routingRevision!==pending.revision|| + !m4FxHardwareMatches(pending,hardwareConfiguration))return "STALE"; const slots=m.fxInstances?.[pending.channel]; const actual=Array.isArray(slots)?slots[pending.slot]:null; if(actual?.instanceId!==pending.token)return "STALE"; diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 7240e01ed..279f9ac86 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -1312,7 +1312,8 @@ function reconcileM4FxInsertReadback(snapshot){ const p=pendingFxInsert; if(!p||p.authority!=="M4")return {kind:"NONE"}; - const decision=fxRackVM.m4InsertReadbackSettlement(p,snapshot); + const decision=fxRackVM.m4InsertReadbackSettlement(p,snapshot, + protocol.nativeHardwareConfiguration(snapshot?.device)); if(decision.kind==="STALE"){ pendingFxInsert=null; status("FX INSERT expired · native routing changed"); @@ -1416,9 +1417,11 @@ Number(button?.dataset?.slot):null; const map=action==="fxOn"?pendingM4RackPowers:pendingSlotPowers; const key=action==="fxOn"?channel:channel+":"+slot; - const plan=fxRackVM.m4PowerPlan(controller?.state()?.current,{ + const current=controller?.state()?.current; + const plan=fxRackVM.m4PowerPlan(current,{ action,channel,slot,pending:map.has(key), - verifiedM4:m4Verified(),offline:!!logicalView + verifiedM4:m4Verified(),offline:!!logicalView, + hardwareConfiguration:protocol.nativeHardwareConfiguration(current?.device) }); if(plan.kind!=="READY")return false; const requestId=action==="fxOn"? @@ -1438,14 +1441,16 @@ } function reconcileM4RackReadback(next){ for(const [lane,p] of pendingM4RackPowers){ - const decision=fxRackVM.m4RackSettlement(p,next); + const decision=fxRackVM.m4RackSettlement(p,next, + protocol.nativeHardwareConfiguration(next?.device)); if(decision==="STALE"||decision==="CONFIRMED") pendingM4RackPowers.delete(lane); } // An M4 slot remains pending after ACK until its own exact instance // lease and requested bypass are present in independently accepted PCM. for(const [key,p] of pendingSlotPowers){ - const decision=fxRackVM.m4SlotPowerSettlement(p,next); + const decision=fxRackVM.m4SlotPowerSettlement(p,next, + protocol.nativeHardwareConfiguration(next?.device)); if(decision==="STALE"||decision==="CONFIRMED") pendingSlotPowers.delete(key); } @@ -3629,7 +3634,8 @@ return true; } const plan=fxRackVM.m4EditorPlan(current,{ - channel:m4Index(t),slot,verifiedM4:m4Verified(),offline:!!logicalView}); + channel:m4Index(t),slot,verifiedM4:m4Verified(),offline:!!logicalView, + hardwareConfiguration:protocol.nativeHardwareConfiguration(current?.device)}); if(plan.kind==="OPEN") openRoutedFxEditor(plan.channel,plan.slot,plan.instanceId, plan.deviceEpoch,plan.revision); @@ -3884,7 +3890,8 @@ } const plan=fxRackVM.m4InsertPlan(accepted,{ catalogId:plugin?.id,channel,slot,verifiedM4:m4Verified(), - offline:!!logicalView,pending:!!pendingFxInsert}); + offline:!!logicalView,pending:!!pendingFxInsert, + hardwareConfiguration:protocol.nativeHardwareConfiguration(accepted?.device)}); if(plan.kind!=="READY"){ status("FX INSERT REJECTED · choose an empty consecutive slot on a native CH with verified route/catalog"); return true; From c0b5eb8ec1e139e03f51a0389830cdcec2594b0b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 19 Nov 2026 21:39:25 +0700 Subject: [PATCH 2/3] test(gui G-MV33): reject missing and malformed FX slot ordinals --- tests/approved_native_m2_contract.test.cjs | 8 ++++++++ web/approved-fx-rack-view-model.js | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index a3aacaded..0cdf5173e 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -6077,6 +6077,14 @@ test("G-MV33 exact M4 FX host admission and hardware-scoped transaction settleme for(const plan of [rack,power,insert]) assert.equal(plan.pending.hardwareConfiguration,token); assert.equal(editor.instanceId,"fx-old"); + for(const badSlot of [undefined,null,"0",-1,8,NaN]){ + assert.equal(fxRackVM.m4InsertPlan(base,{...opts,slot:badSlot, + catalogId:"vendor.new"}).kind,"UNAVAILABLE"); + assert.equal(fxRackVM.m4EditorPlan(base,{...opts,slot:badSlot}).kind, + "UNAVAILABLE"); + assert.equal(fxRackVM.m4PowerPlan(base,{...opts,slot:badSlot, + action:"slotPower"}).kind,"UNAVAILABLE"); + } for(const delta of [ {verifiedM4:false},{offline:true},{hardwareConfiguration:null}, {hardwareConfiguration:""},{channel:10} diff --git a/web/approved-fx-rack-view-model.js b/web/approved-fx-rack-view-model.js index 47aa86921..81c2fdb95 100644 --- a/web/approved-fx-rack-view-model.js +++ b/web/approved-fx-rack-view-model.js @@ -162,7 +162,7 @@ timeoutMs:8000,pending:{...lease,bypassed}, payload:{channel,deviceEpoch:epoch,revision,value:bypassed}}; } - if(action!=="slotPower"||slot===null)return unavailable; + if(action!=="slotPower"||!Number.isInteger(slot))return unavailable; const instances=m.fxInstances?.[channel],live=instances?.[slot]; if(!Array.isArray(instances)|| typeof live?.instanceId!=="string"||!live.instanceId|| @@ -231,7 +231,8 @@ const unavailable={kind:"UNAVAILABLE"}; const host=m4FxHost(snapshot,{channel,slot,verifiedM4,offline,pending, hardwareConfiguration}); - if(!host||slot===null||typeof catalogId!=="string"||!catalogId) + if(!host||!Number.isInteger(slot)|| + typeof catalogId!=="string"||!catalogId) return unavailable; const {m,epoch,revision}=host; const instances=m.fxInstances?.[channel]; @@ -337,7 +338,7 @@ const unavailable={kind:"UNAVAILABLE"}; const host=m4FxHost(snapshot,{channel,slot,verifiedM4,offline, hardwareConfiguration}); - if(!host||slot===null)return unavailable; + if(!host||!Number.isInteger(slot))return unavailable; const {m,epoch,revision}=host; const slots=m.fxInstances?.[channel]; if(!Array.isArray(slots))return unavailable; From f2d70cbef51d3f9f3ca82fd2bf814e998444c485 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 19 Nov 2026 21:41:27 +0700 Subject: [PATCH 3/3] test(gui G-MV33): keep RC editor contract aligned with hardware readback lease --- tests/rc_operator_workflow_contract.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rc_operator_workflow_contract.test.mjs b/tests/rc_operator_workflow_contract.test.mjs index cc00588d0..8ad469927 100644 --- a/tests/rc_operator_workflow_contract.test.mjs +++ b/tests/rc_operator_workflow_contract.test.mjs @@ -72,8 +72,8 @@ test('FX picker closes and opens an actual editor only after accepted native or assert.match(fxVM,/function m4InsertAckResult\(pending,ack\)/); assert.match(fxVM,/ack\.channel===pending\.channel&&/); assert.match(fxVM,/ack\.slot===pending\.slot/); - assert.match(fxVM,/function m4InsertReadbackSettlement\(pending,snapshot\)/); - assert.match(bridge,/fxRackVM\.m4InsertReadbackSettlement\(p,snapshot\)/); + assert.match(fxVM,/function m4InsertReadbackSettlement\(pending,snapshot,/); + assert.match(bridge,/fxRackVM\.m4InsertReadbackSettlement\(p,snapshot,/); assert.match(bridge,/openRoutedFxEditor\(decision\.channel,decision\.slot,decision\.instanceId,/); const m4AckHandler=bridge.split('backend.addEventListener("arMixRoutingFxInsertAck",ack=>{')[1] ?.split('backend.addEventListener("arMixCatalog",catalog=>{')[0];