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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 122 additions & 3 deletions tests/approved_native_m2_contract.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,9 @@ test("P0 MAIN WIRE unplug uses UI-to-native EdgeId and no fake graph",()=>{
test("P0 real slot VST3 power and native editor use verified instance tokens",()=>{
const bridge=read("web/approved-native-bridge.js");
const main=read("src/Main.cpp");
assert.match(bridge,/function verifiedFxFor\(t,slot\)/);
assert.match(bridge,/fxRackVM\.m4EditorPlan\(current,/);
assert.match(read("web/approved-fx-rack-view-model.js"),/function m4EditorPlan\(snapshot,/);
assert.doesNotMatch(bridge,/function verifiedFxFor\(/);
assert.match(bridge,/function requestM4FxPower\(t,action,button=null\)/);
assert.match(bridge,/if\(action==="slotPower"\)/);
assert.match(bridge,/if\(action==="fxOn"\)/);
Expand Down Expand Up @@ -3611,8 +3613,13 @@ test("native FX remove/reorder/transfer requires exact token, ACK and ordered re

test("ImmerSIB opens the exact native ChannelId HWND, survives VST3 editor, no success-only toast",()=>{
const bridge=read("web/approved-native-bridge.js"),host=read("src/Main.cpp");
assert.match(bridge,/insert\.catalogId==='armix\.builtin\.imersip\.v1' && current\.admitted/);
assert.match(bridge,/backend\.emitEvent\("arMixAction",\{action:"routingFxEditor",channelId:id,slot,/);
const editorVM=read("web/approved-fx-rack-view-model.js");
assert.match(bridge,/fxRackVM\.editorNavigationPlan\(current,/);
assert.match(editorVM,/view\.raw\?\.mixerSession\?\.authority==="CHANNEL_ID"/);
assert.match(bridge,/else \{\s*\/\/ Both vendor VST3 and ImmerSIB retain their exact real/);
assert.match(bridge,/backend\.emitEvent\("arMixAction",\{action:"routingFxEditor",\s*channelId:editor\.channelId,slot:editor\.slot,/);
assert.match(bridge,/else if\(editor\.authority==="LOGICAL"\)/);
assert.match(bridge,/action:"logicalVendorFxEditor"/);
assert.doesNotMatch(bridge,/else status\("Native VST3 editor opened"\)/);
assert.match(host,/shownWindow=dedicatedImmerSIB\?immersibEditorWindow_:editorWindow_/);
assert.match(host,/shownOwner=dedicatedImmerSIB\?immersibEditorOwner_:routedEditorOwner_/);
Expand Down Expand Up @@ -5934,3 +5941,115 @@ test("G-MV30 bridge has one M4 insert IPC, and never paints or opens from ack.st
assert.doesNotMatch(ack,/ack\?\.state|paintM4FxInstances\(|openRoutedFxEditor\(/);
assert.doesNotMatch(source,/document\.|window\.|backend\.emitEvent|setTimeout/);
});

// G-MV31: automatic native/logical FX editor navigation must never cross a
// session generation between confirmed readback and the queued microtask.
test("G-MV31 ChannelId FX editor action is bound to physical graph, roster, device and instance",()=>{
const raw=gmv20AcceptedGraph();
raw.mixerSession={authority:"CHANNEL_ID",deviceEpoch:raw.device.epoch,
routeRevision:raw.graph.revision,rosterRevision:raw.graph.rosterRevision};
raw.graph.channels[0].inserts=[{id:"instance-native-22",
catalogId:"vendor.fx-22",name:"Delay",bypassed:false}];
const snap=protocol.normalizeSnapshot(raw);
assert.ok(snap?.admitted,"must start from genuinely normalized native snapshot");
const id=snap.graph.channels[0].id,
hw=protocol.nativeHardwareConfiguration(snap.device);
const open=fxRackVM.editorNavigationPlan(snap,{
channelId:id,slot:0,hardwareConfiguration:hw});
assert.equal(open.kind,"OPEN");
assert.equal(open.lease.authority,"CHANNEL_ID");
assert.equal(open.lease.channelId,id);
assert.equal(open.lease.instanceId,"instance-native-22");
assert.equal(fxRackVM.editorNavigationLeaseMatches(snap,open.lease,
{hardwareConfiguration:hw}),true);
for(const edit of [
s=>{s.device.epoch="9999";s.raw.mixerSession.deviceEpoch="9999";},
s=>{s.graph.revision="998";},
s=>{s.graph.rosterRevision="997";},
s=>{s.graph.channels[0].inserts[0].id="instance-replacement";},
s=>{s.graph.channels[0].inserts[0].catalogId="another.vendor";},
s=>{s.raw.mixerSession.authority="M4";},
s=>{s.retained=true;s.admitted=false;},
s=>{s.graph.channels[0].inserts=[];},
s=>{s.graph.channels.push({...s.graph.channels[0]});},
]){
const next=clone(snap);edit(next);
assert.equal(fxRackVM.editorNavigationLeaseMatches(next,open.lease,
{hardwareConfiguration:hw}),false);
}
assert.equal(fxRackVM.editorNavigationLeaseMatches(snap,open.lease,
{hardwareConfiguration:hw+":new-buffer"}),false,
"same-epoch device configuration replacement must revoke HWND navigation");
assert.equal(fxRackVM.editorNavigationPlan(snap,{
channelId:id,slot:1,hardwareConfiguration:hw}).kind,"PICKER");
assert.equal(fxRackVM.editorNavigationPlan(snap,{
channelId:id,slot:0,hardwareConfiguration:null}).kind,"UNAVAILABLE");
assert.equal(fxRackVM.editorNavigationPlan(snap,{
channelId:"9007199254740993",slot:0,hardwareConfiguration:hw}).kind,"UNAVAILABLE");
});
test("G-MV31 .smix editor navigation is scoped to exact workspace, graph, and FX lease",()=>{
const ch={id:"9007199254740993",role:"INPUT",
inserts:[{id:"logical-instance",catalogId:"catalog.test"}]};
const base={logical:true,admitted:false,retained:false,workspaceToken:"work-a",
device:{epoch:"0"},
graph:{revision:"5",rosterRevision:"5",channels:[ch]}};
const params={channelId:ch.id,slot:0};
const open=fxRackVM.editorNavigationPlan(base,params);
assert.equal(open.kind,"OPEN");
assert.equal(open.lease.authority,"LOGICAL");
assert.equal(open.lease.workspaceToken,"work-a");
assert.equal(open.lease.deviceEpoch,null);
assert.equal(fxRackVM.editorNavigationLeaseMatches(base,open.lease),true);
const changed=clone(base);
changed.workspaceToken="work-b";
assert.equal(fxRackVM.editorNavigationLeaseMatches(changed,open.lease),false);
changed.workspaceToken="work-a";changed.graph.revision="6";
assert.equal(fxRackVM.editorNavigationLeaseMatches(changed,open.lease),false);
const physical=clone(base);physical.logical=false;physical.admitted=true;
assert.equal(fxRackVM.editorNavigationLeaseMatches(physical,open.lease),false);
const offline=clone(base);offline.retained=true;
assert.equal(fxRackVM.editorNavigationPlan(offline,params).kind,"UNAVAILABLE");
const empty=clone(base);empty.graph.channels[0].inserts=[];
assert.equal(fxRackVM.editorNavigationPlan(empty,params).kind,"PICKER");
});
test("G-MV31 manual M4 editor must read one admitted FX slot from current host",()=>{
const snap={admitted:false,retained:false,device:{epoch:"55"},raw:{
mixerSession:{authority:"M4",deviceEpoch:"55",routeRevision:"12",
channels:Array.from({length:10},()=>({role:"INPUT"}))},
legacyM4:{active:true,routeAccepted:true,nativeBusStructural:false,
routingRevision:"12",fxInstances:Array.from({length:10},()=>[])}
}};
snap.raw.legacyM4.fxInstances[4][0]={
instanceId:"verified-m4-fx",catalogId:"vendor.m4",bypassed:false};
const args={channel:4,slot:0,verifiedM4:true};
assert.deepEqual(fxRackVM.m4EditorPlan(snap,args),{kind:"OPEN",
channel:4,slot:0,instanceId:"verified-m4-fx",deviceEpoch:55,revision:12});
assert.equal(fxRackVM.m4EditorPlan(snap,{...args,slot:1}).kind,"PICKER");
for(const delta of [
{verifiedM4:false},{offline:true},{channel:-1},{slot:8}
])assert.equal(fxRackVM.m4EditorPlan(snap,{...args,...delta}).kind,"UNAVAILABLE");
for(const change of [
s=>{s.raw.mixerSession.authority="CHANNEL_ID";},
s=>{s.raw.legacyM4.routingRevision="13";},
s=>{s.device.epoch="56";},
s=>{s.raw.legacyM4.routeAccepted=false;},
s=>{s.raw.legacyM4.nativeBusStructural=true;},
s=>{s.raw.legacyM4.fxInstances[4][0].instanceId="";}
]){
const v=clone(snap);change(v);
assert.equal(fxRackVM.m4EditorPlan(v,args).kind,"UNAVAILABLE");
}
});
test("G-MV31 bridge delegates deferred and manually opened FX editors to one pure plan",()=>{
const bridge=read("web/approved-native-bridge.js");
assert.match(bridge,/fxRackVM\.editorNavigationPlan\(verified,/);
assert.match(bridge,/fxRackVM\.editorNavigationPlan\(current,/);
assert.match(bridge,/fxRackVM\.editorNavigationLeaseMatches\(current,lease,/);
assert.match(bridge,/track&&nativeIdFor\(track\)===channelId/);
assert.match(bridge,/fxRackVM\.m4EditorPlan\(current,/);
assert.doesNotMatch(bridge,/function verifiedFxFor\(/);
Comment thread
masarray marked this conversation as resolved.
Resolved
assert.match(bridge,/scope\?\.closeNativePicker\?\.\(\)/);
assert.match(bridge,/openVerifiedInsertedFx\(p\.channelId,p\.slot,p\.catalogId,inserted\.id\)/);
assert.doesNotMatch(read("web/approved-fx-rack-view-model.js"),
/backend\.emitEvent|document\.|window\.|setTimeout/);
});
5 changes: 4 additions & 1 deletion tests/rc_operator_workflow_contract.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ test('built-in FX preset store works with verified offline logical workspace',()
});
test('FX picker closes and opens an actual editor only after accepted native or logical readback',()=>{
assert.match(bridge,/function openVerifiedInsertedFx\(channelId,slot,catalogId,instanceId\)/);
assert.match(bridge,/effect\.id!==instanceId\|\|effect\.catalogId!==catalogId/);
assert.match(bridge,/plan\.lease\.instanceId!==instanceId/);
assert.match(bridge,/plan\.lease\.catalogId!==catalogId/);
assert.match(bridge,/fxRackVM\.editorNavigationLeaseMatches\(current,lease,/);
assert.match(bridge,/fxRackVM\.m4EditorPlan\(current,/);
assert.match(bridge,/justInsertedLogicalFx/);
assert.match(bridge,/scope\?\.closeNativePicker\?\.\(\);\s*openVerifiedInsertedFx\(p\.channelId,p\.slot,p\.catalogId,inserted\.id\)/);
// Native editor requires verified accepted lease, not catalog key or ACK.
Expand Down
81 changes: 81 additions & 0 deletions web/approved-fx-rack-view-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,86 @@
revision};
}


// G-MV31: one exact, immutable navigation policy for the verified /preview/
// FX editor. No HWND, IPC, DOM or duplicated editor state lives in this VM.
// Capture the accepted graph and device generation before a deferred click;
// the same generation must still own the instance when it is consumed.
function editorNavigationPlan(view,{channelId:id,slot,
hardwareConfiguration}={}) {
const unavailable={kind:"UNAVAILABLE"},graph=view?.graph;
if(!channelId(id)||!Number.isInteger(slot)||slot<0||slot>=8||
!rosterUnique(graph)||!Array.isArray(graph?.channels)||
!channelId(graph.revision)||!channelId(graph.rosterRevision)||
new Set(graph.channels.map(ch=>ch.id)).size!==graph.channels.length)
return unavailable;
const offline=view?.logical===true&&view?.admitted===false&&
view?.retained===false&&
typeof view.workspaceToken==="string"&&view.workspaceToken.length>0;
const physical=view?.logical!==true&&view?.admitted===true&&
view?.retained===false&&
view.graph.capabilities?.callbackOwnsChannelIds===true&&
view.raw?.mixerSession?.authority==="CHANNEL_ID"&&
view.raw.mixerSession.deviceEpoch===view.device?.epoch&&
channelId(view.device.epoch)&&
typeof hardwareConfiguration==="string"&&hardwareConfiguration.length>0;
if(!offline&&!physical)return unavailable;
const rows=graph.channels.filter(ch=>ch.id===id);
if(rows.length!==1||!VALID_ROLES.has(rows[0].role)||
!Array.isArray(rows[0].inserts))return unavailable;
const effect=rows[0].inserts[slot];
if(effect==null)return {kind:"PICKER"};
if(typeof effect.id!=="string"||!effect.id||
typeof effect.catalogId!=="string"||!effect.catalogId)
return unavailable;
const lease=Object.freeze({
authority:offline?"LOGICAL":"CHANNEL_ID",
channelId:id,slot,instanceId:effect.id,catalogId:effect.catalogId,
graphRevision:graph.revision,rosterRevision:graph.rosterRevision,
workspaceToken:offline?view.workspaceToken:null,
deviceEpoch:physical?view.device.epoch:null,
hardwareConfiguration:physical?hardwareConfiguration:null
});
return {kind:"OPEN",lease};
}
function editorNavigationLeaseMatches(view,lease,{hardwareConfiguration}={}) {
if(!lease||typeof lease!=="object")return false;
const now=editorNavigationPlan(view,{
channelId:lease.channelId,slot:lease.slot,hardwareConfiguration});
if(now.kind!=="OPEN")return false;
return Object.keys(now.lease).every(key=>now.lease[key]===lease[key])&&
Object.keys(lease).length===Object.keys(now.lease).length;
}

// 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;
const slots=m.fxInstances?.[channel];
if(!Array.isArray(slots))return unavailable;
const effect=slots[slot];
if(effect==null)return {kind:"PICKER"};
if(typeof effect.instanceId!=="string"||!effect.instanceId||
typeof effect.catalogId!=="string"||!effect.catalogId)
return unavailable;
return {kind:"OPEN",channel,slot,instanceId:effect.instanceId,
deviceEpoch:epoch,revision};
}

function nativeInsertPlan(snapshot,{channelId:id,slot,catalogId,pending=false}={}) {
const graph=snapshot?.graph;
if(pending||snapshot?.admitted!==true||snapshot?.retained===true||
Expand Down Expand Up @@ -429,6 +509,7 @@
m4Presentation,nativePowerSettlement,m4PowerPlan,m4RackAckResult,
m4RackSettlement,
m4InsertPlan,m4InsertAckResult,m4InsertReadbackSettlement,
editorNavigationPlan,editorNavigationLeaseMatches,m4EditorPlan,
nativeInsertPlan,nativeEditPlan,nativeInsertSettlement,
nativePowerPlan,nativePowerAckResult,
globalPowerContext,globalPowerPlan,globalPowerAckResult,
Expand Down
Loading
Loading