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
101 changes: 87 additions & 14 deletions src/ConsoleLiveBridgeV6.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,38 @@ class LiveConsoleBridgeV6 final {
const auto bus=route.getProperty("nativeBus",juce::var());
if(native && bus.isObject()) {
object->setProperty("nativeBus",bus);
// Native PCM is the only source of exact ChannelIds,
// EdgeIds and accepted revision for the v8 projection.
const auto channels=bus.getProperty("channels",{});
const auto edges=bus.getProperty("edges",{});
const auto rev=bus.getProperty("graphRevision",{});
const auto roster=bus.getProperty("rosterRevision",{});
const auto nativeOps=bus.getProperty("supportedOps",{});
std::uint64_t graphId=0,rosterId=0;
const auto* ops=nativeOps.getArray();
if(channels.isArray() && edges.isArray() && ops &&
ops->contains(juce::var(juce::String(
"NATIVE_APPLY_WIRE_TRANSACTION"))) &&
decodeDecimal(rev,graphId) && graphId &&
decodeDecimal(roster,rosterId) && rosterId) {
const auto graph=actual.getProperty("graph",{});
if(auto* accepted=graph.getDynamicObject()) {
accepted->setProperty("revision",rev);
accepted->setProperty("rosterRevision",roster);
accepted->setProperty("channels",channels);
accepted->setProperty("edges",edges);
const auto capabilities=graph.getProperty("capabilities",{});
if(auto* caps=capabilities.getDynamicObject()) {
caps->setProperty("callbackOwnsChannelIds",true);
juce::Array<juce::var> available;
available.add(juce::var(juce::String(
"APPLY_WIRE_TRANSACTION")));
caps->setProperty("supportedOps",juce::var(available));
}
}
}
// Full product-LIVE remains gated on VST3/Show/monitor
// parity and measured hardware FAT (#15).
}
// Separate namespace: these operations mutate the one
// INSTALLED M4 JUCE PCM graph. They are NEVER universal
Expand Down Expand Up @@ -547,6 +579,8 @@ class LiveConsoleBridgeV6 final {
const auto req=intent.getProperty("requestId",juce::var());
const auto request=req.isString()?req.toString():juce::String();
const auto key=request.toStdString();
const bool v8Wire=intent.getProperty("operation","").toString()==
"APPLY_WIRE_TRANSACTION";
const auto device=snapshot.getProperty("device",juce::var());
const auto graph=snapshot.getProperty("graph",juce::var());
const auto legacy=snapshot.getProperty("legacyM4",juce::var());
Expand All @@ -567,24 +601,56 @@ class LiveConsoleBridgeV6 final {
recentIds_.push_back(key);completed_.insert(key);
const auto operation=intent.getProperty("operation","").toString();
const auto payload=intent.getProperty("payload",juce::var());
// One existing decoder, one native candidate, one PCM publisher.
const auto baseGraph=v8Wire?intent.getProperty("baseGraphRevision",{})
:intent.getProperty("nativeGraphRevision",{});
const auto baseRoster=v8Wire?intent.getProperty("baseRosterRevision",{})
:intent.getProperty("nativeRosterRevision",{});
const auto legacyBase=v8Wire?legacy.getProperty("routingRevision",{})
:intent.getProperty("legacyRoutingRevision",{});
if(ioBusy)error="NATIVE_SHOW_OR_BACKUP_BUSY";
else if(!decodeDecimal(intent.getProperty("deviceEpoch",{}),requestedEpoch) ||
!decodeDecimal(intent.getProperty("legacyRoutingRevision",{}),legacyRevision) ||
!decodeDecimal(intent.getProperty("nativeGraphRevision",{}),nativeRev) ||
!decodeDecimal(intent.getProperty("nativeRosterRevision",{}),rosterRev) ||
!decodeDecimal(legacyBase,legacyRevision) ||
!decodeDecimal(baseGraph,nativeRev) ||
!decodeDecimal(baseRoster,rosterRev) ||
intent.getProperty("deviceEpoch","").toString()!=epoch ||
intent.getProperty("legacyRoutingRevision","").toString()!=
legacy.getProperty("routingRevision","").toString())
legacyBase.toString()!=legacy.getProperty("routingRevision","").toString())
error="STALE_NATIVE_BUS_DEVICE_OR_ROUTE";
else if(!bus.isObject() ||
bus.getProperty("graphRevision","").toString()!=
intent.getProperty("nativeGraphRevision","").toString() ||
bus.getProperty("rosterRevision","").toString()!=
intent.getProperty("nativeRosterRevision","").toString() ||
bus.getProperty("graphRevision","").toString()!=baseGraph.toString() ||
bus.getProperty("rosterRevision","").toString()!=baseRoster.toString() ||
legacy.getProperty("controlPlane","").toString()!="LEGACY_M4_ORDINAL")
error="NATIVE_BUS_GRAPH_NOT_ADMITTED";
else if(!payload.isObject())error="INVALID_NATIVE_BUS_PAYLOAD";
else if(operation=="NATIVE_CREATE_CHANNEL" ||
else if(v8Wire &&
(graph.getProperty("revision","").toString()!=baseGraph.toString() ||
graph.getProperty("rosterRevision","").toString()!=baseRoster.toString()))
error="STALE_GRAPH_REVISION";
else if(v8Wire) {
const auto caps=graph.getProperty("capabilities",{});
const auto ops=caps.getProperty("supportedOps",{});
const auto* allowed=ops.getArray();
const auto rows=graph.getProperty("channels",{});
const auto focus=intent.getProperty("targetChannelId",{});
armix::mixer::ChannelId parsed{};
const bool valid=focus.isString() &&
armix::integration::parseNativeChannelId(
focus.toString().toStdString(),parsed);
bool admitted=false;
if(valid)if(const auto* channels=rows.getArray())
for(const auto& row:*channels)
if(row.getProperty("id","").toString()==focus.toString())
{admitted=true;break;}
if(!admitted || !graph.getProperty("edges",{}).isArray() ||
!static_cast<bool>(caps.getProperty("callbackOwnsChannelIds",false)) ||
!allowed || !allowed->contains(juce::var(juce::String(
"APPLY_WIRE_TRANSACTION"))))
error="UNIVERSAL_WIRE_NOT_ADMITTED";
}
if(error.isEmpty() && !payload.isObject())
error="INVALID_NATIVE_BUS_PAYLOAD";
if(error.isNotEmpty()) {
// Do not touch installed native audio on stale requests.
} else if(operation=="NATIVE_CREATE_CHANNEL" ||
operation=="NATIVE_PATCH_CHANNEL") {
if(operation=="NATIVE_CREATE_CHANNEL") {
const auto name=payload.getProperty("name","").toString();
Expand Down Expand Up @@ -696,7 +762,7 @@ class LiveConsoleBridgeV6 final {
rosterRev=response.rosterRevision;}
}
}
else if(operation=="NATIVE_APPLY_WIRE_TRANSACTION") {
else if(operation=="NATIVE_APPLY_WIRE_TRANSACTION" || v8Wire) {
using namespace armix::mixer;
const auto raw=payload.getProperty("changes",juce::var());
const auto* list=raw.getArray();
Expand All @@ -722,6 +788,11 @@ class LiveConsoleBridgeV6 final {
error="INVALID_NATIVE_WIRE_SOURCE";break;
}
change.from={source};
// MAIN focus cannot disconnect someone else's edge.
if(v8Wire && item.getProperty("from",{}).toString()!=
intent.getProperty("targetChannelId",{}).toString()) {
error="UNIVERSAL_WIRE_UNFOCUSED_SOURCE";break;
}
if(change.kind!=WireChange::Kind::remove) {
if(!decodeDecimal(item.getProperty("to",{}),dest) ||
dest==0) {
Expand Down Expand Up @@ -847,8 +918,10 @@ class LiveConsoleBridgeV6 final {
ack.requestId=key;
ack.status=applied?"ACCEPTED":"REJECTED";
ack.deviceEpoch=epoch.toStdString();
ack.graphRevision=graph.getProperty("revision","0").toString().toStdString();
ack.rosterRevision=graph.getProperty("rosterRevision","0").toString().toStdString();
ack.graphRevision=v8Wire && applied?std::to_string(nativeRev):
graph.getProperty("revision","0").toString().toStdString();
ack.rosterRevision=v8Wire && applied?std::to_string(rosterRev):
graph.getProperty("rosterRevision","0").toString().toStdString();
ack.errorCode=error.toStdString();
const auto json=PuzzleV8Wire::ack(ack);
auto wire=juce::JSON::parse(juce::String::fromUTF8(json.c_str()));
Expand Down
2 changes: 1 addition & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
const auto snapshot=armix::console::LiveConsoleBridgeV6::snapshot(engine_.status());
const auto op=args.getProperty("operation","").toString();
juce::var ack;
if(op.startsWith("NATIVE_"))
if(op.startsWith("NATIVE_") || op=="APPLY_WIRE_TRANSACTION")
ack=consoleBridge_.processNativeBusIntent(
args,snapshot,engine_,
nativeShowBusy_||studioBackupBusy_,
Expand Down
82 changes: 82 additions & 0 deletions tests/live_channel_fx_graph_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,88 @@ static void verifyNativeConsoleWireRejectsUnsupportedM4AndPreservesEpoch() {
liveMixIntent);
assert(mixAck.getProperty("status","").toString()=="ACCEPTED");
assert(busControl.liveMixes==1&&busControl.commits==1);
// Canonical public v8 operation uses the SAME installed ChannelId
// publisher and ACK revisions, never a WebView/legacy owned PCM graph.
const auto v8Route=live.getProperty("dryRoutingLab",{});
const auto v8Bus=v8Route.getProperty("nativeBus",{});
auto* v8BusObject=v8Bus.getDynamicObject();
assert(v8BusObject);
const auto v8Rows=v8Bus.getProperty("channels",{});
auto v8Input=std::make_unique<juce::DynamicObject>();
v8Input->setProperty("id","20");
v8Input->setProperty("role","INPUT");
v8Rows.getArray()->add(juce::var(v8Input.release()));
juce::Array<juce::var> v8Edges;
auto v8Edge=std::make_unique<juce::DynamicObject>();
v8Edge->setProperty("edgeId","77");
v8Edge->setProperty("from","20");
v8Edge->setProperty("to","18");
v8Edge->setProperty("tap","POST_FADER");
v8Edge->setProperty("gainLinear",.5);
v8Edges.add(juce::var(v8Edge.release()));
v8BusObject->setProperty("edges",juce::var(v8Edges));
juce::Array<juce::var> v8InstalledOps;
v8InstalledOps.add(juce::var(juce::String("NATIVE_APPLY_WIRE_TRANSACTION")));
v8BusObject->setProperty("supportedOps",juce::var(v8InstalledOps));
const auto acceptedV8=Bridge::snapshot(live);
const auto acceptedV8Graph=acceptedV8.getProperty("graph",{});
const auto acceptedV8Caps=acceptedV8Graph.getProperty("capabilities",{});
assert(!static_cast<bool>(acceptedV8.getProperty("productionCallbackLive",true)));
assert(acceptedV8Graph.getProperty("revision","").toString()=="3");
assert(acceptedV8Graph.getProperty("rosterRevision","").toString()=="4");
assert(acceptedV8Graph.getProperty("channels",{}).getArray()->size()==2);
assert(acceptedV8Graph.getProperty("edges",{}).getArray()->size()==1);
assert(acceptedV8Graph.getProperty("edges",{}).getArray()->getReference(0)
.getProperty("edgeId","").toString()=="77");
assert(static_cast<bool>(acceptedV8Caps.getProperty("callbackOwnsChannelIds",false)));
assert(acceptedV8Caps.getProperty("supportedOps",{}).getArray()->contains(
juce::var(juce::String("APPLY_WIRE_TRANSACTION"))));
auto v8IntentObject=std::make_unique<juce::DynamicObject>();
v8IntentObject->setProperty("requestId","v8:wire:1");
v8IntentObject->setProperty("deviceEpoch","9007199254740993");
v8IntentObject->setProperty("baseGraphRevision","3");
v8IntentObject->setProperty("baseRosterRevision","4");
v8IntentObject->setProperty("operation","APPLY_WIRE_TRANSACTION");
v8IntentObject->setProperty("targetChannelId","20");
v8IntentObject->setProperty("payload",batch.getProperty("payload",{}));
const auto v8WireIntent=juce::var(v8IntentObject.release());
const auto applyV8=[&](const juce::var& command,const juce::var& snapshot) {
return bridge.processNativeBusIntent(command,snapshot,busControl,false,
[](const juce::String&,ChannelId,const juce::var&,
std::uint64_t,std::uint64_t,std::uint64_t)
->BusControl::Report {return {};});
};
auto v8Reply=applyV8(v8WireIntent,acceptedV8);
assert(v8Reply.getProperty("status","").toString()=="ACCEPTED");
assert(v8Reply.getProperty("graphRevision","").toString()=="4");
assert(v8Reply.getProperty("rosterRevision","").toString()=="5");
assert(busControl.nativeWireBatches==2);
assert(applyV8(v8WireIntent,acceptedV8)
.getProperty("errorCode","").toString()=="DUPLICATE_REQUEST_ID");
auto staleV8=juce::JSON::parse(juce::JSON::toString(v8WireIntent,false));
staleV8.getDynamicObject()->setProperty("requestId","v8:wire:stale");
staleV8.getDynamicObject()->setProperty("baseGraphRevision","2");
assert(applyV8(staleV8,acceptedV8).getProperty("status","").toString()=="REJECTED");
assert(busControl.nativeWireBatches==2);
// A focused MAIN plug cannot modify another admitted channel's wire
// even if its edge ID is otherwise syntactically valid.
auto wrongFocus=juce::JSON::parse(juce::JSON::toString(v8WireIntent,false));
wrongFocus.getDynamicObject()->setProperty("requestId","v8:wire:wrong-focus");
wrongFocus.getDynamicObject()->setProperty("targetChannelId","18");
const auto rejectedFocus=applyV8(wrongFocus,acceptedV8);
assert(rejectedFocus.getProperty("status","").toString()=="REJECTED");
assert(rejectedFocus.getProperty("errorCode","").toString()==
"UNIVERSAL_WIRE_UNFOCUSED_SOURCE");
assert(busControl.nativeWireBatches==2);
// Subsequent native producer snapshot must match the acknowledged graph
// and roster revision before GUI may paint an accepted WIRE cable.
v8BusObject->setProperty("graphRevision","4");
v8BusObject->setProperty("rosterRevision","5");
const auto afterV8=Bridge::snapshot(live);
assert(afterV8.getProperty("graph",{}).getProperty("revision","")
.toString()==v8Reply.getProperty("graphRevision","").toString());
assert(afterV8.getProperty("graph",{}).getProperty("rosterRevision","")
.toString()==v8Reply.getProperty("rosterRevision","").toString());
// Fail-closed device fault: do not advertise a compatibility actuator
// against a poisoned physical port topology or stale hardware session.
auto liveRoute=live.getProperty("dryRoutingLab",{});
Expand Down
Loading