From 668f6af4792516b3d1f7aa546ae95b079cb1296e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 16:27:00 +0700 Subject: [PATCH 1/4] refactor(mv13): extract native hotkey command admission and dispatch planner --- CMakeLists.txt | 4 +- src/Main.cpp | 138 +++++--------------------- src/NativeHotkeyCommandPlan.h | 134 +++++++++++++++++++++++++ tests/native_hotkey_registry_test.cpp | 113 +++++++++++++++++++++ 4 files changed, 274 insertions(+), 115 deletions(-) create mode 100644 src/NativeHotkeyCommandPlan.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b65591033..2a6982611 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,7 +337,7 @@ juce_add_binary_data(ARMixAssets SOURCES ${ARMIX_IMERSIB_SCENE_PNG_SOURCES}) target_include_directories(ARMixConsole PRIVATE "${ARMIX_APPROVED_GUI_DIR}") -target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h engine/builtin_fx/HarmonyDsp.h engine/builtin_fx/HarmonyMusicKey.h engine/builtin_fx/ChannelHarmonyProcessor.h engine/builtin_fx/SonKuSpatialProcessor.h engine/builtin_fx/sonku/SonKuSpatialCore.h engine/builtin_fx/sonku/SonKuMeasuredHrir.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/NativeFxParameterHotkey.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) +target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h engine/builtin_fx/HarmonyDsp.h engine/builtin_fx/HarmonyMusicKey.h engine/builtin_fx/ChannelHarmonyProcessor.h engine/builtin_fx/SonKuSpatialProcessor.h engine/builtin_fx/sonku/SonKuSpatialCore.h engine/builtin_fx/sonku/SonKuMeasuredHrir.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/NativeFxParameterHotkey.h src/NativeHotkeyCommandPlan.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) # Explicit UTF-8 source decoding: native channel icons are Unicode, and # MSVC's machine-specific ANSI source charset corrupts emoji literals. # Limit the flag to C++ (not Windows .rc/resource compilation). @@ -1541,7 +1541,7 @@ if(BUILD_TESTING) # H1 OS-global shortcut registration and stable identity are control-only. juce_add_console_app(ARMixNativeHotkeyTests PRODUCT_NAME "ArSonMix Native Hotkey Registry Tests") target_sources(ARMixNativeHotkeyTests PRIVATE tests/native_hotkey_registry_test.cpp - src/NativeHotkeyRegistry.h) + src/NativeHotkeyRegistry.h src/NativeHotkeyCommandPlan.h) target_link_libraries(ARMixNativeHotkeyTests PRIVATE juce::juce_core juce::juce_recommended_config_flags) if(WIN32) diff --git a/src/Main.cpp b/src/Main.cpp index 7b5e76c1b..dcf8eda17 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -46,6 +46,7 @@ #include "NativeMixerSessionSaveWorker.h" #include "NativeLogicalMixerControl.h" #include "NativeHotkeyRegistry.h" +#include "NativeHotkeyCommandPlan.h" #include "NativeFxParameterHotkey.h" #include "NativeFxControlRequest.h" #include "SonKuNativeBridgeContract.h" @@ -1708,47 +1709,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } if(scope=="SESSION") { const auto accepted=approvedNativeSnapshot(); - const auto graph=accepted.getProperty("graph",{}); - const auto channels=graph.getProperty("channels",{}); - const auto caps=graph.getProperty("capabilities",{}); - const auto id=supplied.getProperty("channelId",{}).toString(); - const auto op=supplied.getProperty("operation","").toString(); - const bool fxRack=op=="SET_FX_RACK_BYPASS"; - const bool fxSlot=op=="SET_FX_SLOT_BYPASS"; - const bool fxParam=op.startsWith("SET_FX_PARAM_"); - bool found=false,fxAvailable=false; - if(static_cast(caps.getProperty("callbackOwnsChannelIds",false)) && - channels.isArray())for(const auto& c:*channels.getArray()) { - if(c.getProperty("id","").toString()!=id || - (c.getProperty("role","").toString()!="INPUT" && - c.getProperty("role","").toString()!="GROUP" && - c.getProperty("role","").toString()!="FX_RETURN"))continue; - found=true; - if(fxRack)fxAvailable=c.getProperty("fxRackBypassed",{}).isBool(); - else if(fxSlot) { - const auto inserts=c.getProperty("inserts",{}); - const auto slot=supplied.getProperty("slot",{}); - const auto token=supplied.getProperty("insertId",{}); - if(slot.isInt()&&token.isString()&&inserts.isArray()) { - const int index=static_cast(slot); - if(index>=0&&indexsize()) - fxAvailable=inserts.getArray()->getReference(index) - .getProperty("id","").toString()==token.toString(); - } - } - break; - } - if(!found)error="HOTKEY_CHANNEL_NOT_ADMITTED"; - if(error.isEmpty()&&(fxRack||fxSlot)&&!fxAvailable) - error="HOTKEY_FX_INSTANCE_NOT_ADMITTED"; - const auto ops=caps.getProperty("supportedOps",{}); - const auto* allowed=ops.getArray(); - if(error.isEmpty() && !fxRack && !fxSlot && !fxParam && - op!="SET_MUTE" && op!="SET_SOLO") - error="HOTKEY_ACTION_UNSUPPORTED"; - if(error.isEmpty() && !fxRack && !fxSlot && !fxParam && - (!allowed || !allowed->contains(juce::var(op)))) - error="HOTKEY_ACTION_NOT_ADMITTED"; + error=armix::hotkey::NativeHotkeyCommandPlan:: + registrationError(supplied,accepted); if(error.isEmpty()) { if(mixerSessionId_.isEmpty()) mixerSessionId_=juce::Uuid().toDashedString().toLowerCase(); @@ -1779,79 +1741,29 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr emitApprovedNativeSnapshot(); return; } - if(mapping.scope!="SESSION" || - mapping.sessionId!=mixerSessionId_ || deviceApply_.busy() || - nativeShowBusy_ || studioBackupBusy_ || engine_.isGraphSwitchPending()) - return; - const auto accepted=approvedNativeSnapshot(); - const auto graph=accepted.getProperty("graph",{}); - if(!static_cast(graph.getProperty("capabilities",{}) - .getProperty("callbackOwnsChannelIds",false)))return; - const auto channels=graph.getProperty("channels",{}); - if(!channels.isArray())return; - const juce::var* match=nullptr; - for(const auto& ch:*channels.getArray()) - if(ch.getProperty("id","").toString()==mapping.channelId && - (ch.getProperty("role","").toString()=="INPUT" || - ch.getProperty("role","").toString()=="GROUP" || - ch.getProperty("role","").toString()=="FX_RETURN")) { - match=&ch;break; - } - if(!match)return; - if(mapping.operation.startsWith("SET_FX_PARAM_")) { - (void)applyFxParameterHotkey(mapping); - return; - } - const bool fxRack=mapping.operation=="SET_FX_RACK_BYPASS"; - const bool fxSlot=mapping.operation=="SET_FX_SLOT_BYPASS"; - if(fxRack||fxSlot) { - juce::var bypass; - if(fxRack)bypass=match->getProperty("fxRackBypassed",{}); - else { - const auto inserts=match->getProperty("inserts",{}); - if(!inserts.isArray()||mapping.slot<0|| - mapping.slot>=inserts.getArray()->size())return; - const auto insert=inserts.getArray()->getReference(mapping.slot); - // Fail closed: if a plugin was replaced or reordered, hotkey - // must never touch the different processor at the same slot. - if(insert.getProperty("id","").toString()!=mapping.insertId)return; - bypass=insert.getProperty("bypassed",{}); - } - if(!bypass.isBool())return; - auto native=juce::var(new juce::DynamicObject()); - auto* n=native.getDynamicObject(); - n->setProperty("action",fxRack?"routingNativeFxRackBypass": - "routingNativeFxInsertBypass"); - n->setProperty("requestId","hotkey-fx-"+juce::String( - static_cast(++firedHotkeySerial_))); - n->setProperty("channelId",mapping.channelId); - n->setProperty("deviceEpoch",accepted.getProperty("device",{}).getProperty("epoch","0")); - n->setProperty("revision",graph.getProperty("revision","0")); - n->setProperty("value",!static_cast(bypass)); - if(fxSlot) { - n->setProperty("slot",mapping.slot); - n->setProperty("insertId",mapping.insertId); - } - // Exact same owner, guardrails and ACK as GUI rack/slot Power. - onAction(native); - return; + // Existing control-thread guards, single native dispatcher and FX + // ParamID service remain authoritative. The planner has no side effects. + if(mapping.scope!="SESSION" || mapping.sessionId!=mixerSessionId_ || + deviceApply_.busy() || nativeShowBusy_ || studioBackupBusy_ || + engine_.isGraphSwitchPending())return; + const auto plan=armix::hotkey::NativeHotkeyCommandPlan::dispatch( + mapping,approvedNativeSnapshot(),mixerSessionId_,true, + firedHotkeySerial_+1); + using Kind=armix::hotkey::NativeHotkeyCommandPlan::Kind; + switch(plan.kind) { + case Kind::parameter: + (void)applyFxParameterHotkey(mapping); + break; + case Kind::action: + ++firedHotkeySerial_; + onAction(plan.request); // same FX dispatcher as GUI + break; + case Kind::intent: + ++firedHotkeySerial_; + handleApprovedNativeControl(plan.request); // one PCM intent owner + break; + case Kind::ignore: break; } - if(mapping.operation!="SET_MUTE"&&mapping.operation!="SET_SOLO")return; - const auto control=mapping.operation=="SET_MUTE"?"mute":"solo"; - const auto existing=match->getProperty("controls",{}).getProperty(control,{}); - if(!existing.isBool())return; - auto payload=juce::var(new juce::DynamicObject()); - payload.getDynamicObject()->setProperty("value",!static_cast(existing)); - auto request=juce::var(new juce::DynamicObject()); - auto* o=request.getDynamicObject(); - o->setProperty("requestId","hotkey-"+juce::String(static_cast(++firedHotkeySerial_))); - o->setProperty("operation",mapping.operation); - o->setProperty("targetChannelId",mapping.channelId); - o->setProperty("deviceEpoch",accepted.getProperty("device",{}).getProperty("epoch","0")); - o->setProperty("baseGraphRevision",graph.getProperty("revision","0")); - o->setProperty("baseRosterRevision",graph.getProperty("rosterRevision","0")); - o->setProperty("payload",payload); - handleApprovedNativeControl(request); } void handleLogicalMixerIntent(const juce::var& request) { diff --git a/src/NativeHotkeyCommandPlan.h b/src/NativeHotkeyCommandPlan.h new file mode 100644 index 000000000..4921fac75 --- /dev/null +++ b/src/NativeHotkeyCommandPlan.h @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "NativeHotkeyRegistry.h" +#include + +// MV-13: CONTROL-thread-only decision boundary for native hotkey commands. +// The JUCE ConsoleWindow owns one dispatcher and one authoritative snapshot; +// this pure planner never registers OS chords, mutates a graph or touches PCM. +namespace armix::hotkey { +class NativeHotkeyCommandPlan final { +public: + enum class Kind { ignore, parameter, action, intent }; + struct Dispatch final {Kind kind=Kind::ignore; juce::var request;}; + + // Shared registration/firing role and ChannelId check. All IDs remain + // opaque uint64 decimal strings (never JS doubles or UI strip indices). + static juce::var admittedChannel(const juce::var& graph, + const juce::String& channelId) { + if (!static_cast(graph.getProperty("capabilities",{}) + .getProperty("callbackOwnsChannelIds",false))) + return {}; + const auto rows=graph.getProperty("channels",{}); + if (!rows.isArray())return {}; + for (const auto& row:*rows.getArray()) { + const auto role=row.getProperty("role","").toString(); + if (row.getProperty("id",{}).isString() && + row.getProperty("id","").toString()==channelId && + (role=="INPUT"||role=="GROUP"||role=="FX_RETURN")) + return row; + } + return {}; + } + + static bool exactFxSlot(const juce::var& row,int slot,const juce::String& insertId) { + const auto inserts=row.getProperty("inserts",{}); + return inserts.isArray() && slot>=0 && slotsize() && + insertId.isNotEmpty() && + inserts.getArray()->getReference(slot).getProperty("id",{}).isString() && + inserts.getArray()->getReference(slot).getProperty("id","").toString()==insertId; + } + + // Fail closed before any registry persistence or native OS registration. + // ParamID admission remains owned by the existing VST3 parameter service. + static juce::String registrationError(const juce::var& supplied, + const juce::var& accepted) { + const auto graph=accepted.getProperty("graph",{}); + const auto row=admittedChannel(graph, + supplied.getProperty("channelId","").toString()); + if (!row.isObject())return "HOTKEY_CHANNEL_NOT_ADMITTED"; + const auto operation=supplied.getProperty("operation","").toString(); + const bool rack=operation=="SET_FX_RACK_BYPASS"; + const bool slot=operation=="SET_FX_SLOT_BYPASS"; + const bool param=operation.startsWith("SET_FX_PARAM_"); + if (rack && !row.getProperty("fxRackBypassed",{}).isBool()) + return "HOTKEY_FX_INSTANCE_NOT_ADMITTED"; + if (slot) { + const auto index=supplied.getProperty("slot",{}); + const auto token=supplied.getProperty("insertId",{}); + if (!index.isInt() || !token.isString() || + !exactFxSlot(row,static_cast(index),token.toString())) + return "HOTKEY_FX_INSTANCE_NOT_ADMITTED"; + } + if (!rack && !slot && !param) { + if (operation!="SET_MUTE" && operation!="SET_SOLO") + return "HOTKEY_ACTION_UNSUPPORTED"; + const auto ops=graph.getProperty("capabilities",{}) + .getProperty("supportedOps",{}); + if (!ops.isArray() || !ops.getArray()->contains(juce::var(operation))) + return "HOTKEY_ACTION_NOT_ADMITTED"; + } + return {}; + } + + // Plan only. ConsoleWindow's current onAction / handleApprovedNativeControl + // remain the SINGLE transport and enforcement points, including ACK and + // accepted post-ACK readback. No hotkey-specific graph mutation path. + static Dispatch dispatch(const Mapping& mapping,const juce::var& accepted, + const juce::String& sessionId,bool hostReady, + std::uint64_t requestSerial) { + if (!hostReady || mapping.scope!="SESSION" || + mapping.sessionId!=sessionId || requestSerial==0 || + !Registry::valid(mapping)) + return {}; + const auto graph=accepted.getProperty("graph",{}); + const auto row=admittedChannel(graph,mapping.channelId); + if (!row.isObject())return {}; + if (mapping.operation.startsWith("SET_FX_PARAM_")) + return {Kind::parameter,{}}; + const bool rack=mapping.operation=="SET_FX_RACK_BYPASS"; + const bool slot=mapping.operation=="SET_FX_SLOT_BYPASS"; + if (rack||slot) { + if (slot&&!exactFxSlot(row,mapping.slot,mapping.insertId))return {}; + const auto bypass=rack?row.getProperty("fxRackBypassed",{}): + row.getProperty("inserts",{}).getArray()->getReference(mapping.slot) + .getProperty("bypassed",{}); + if (!bypass.isBool())return {}; + auto out=juce::var(new juce::DynamicObject()); + auto* target=out.getDynamicObject(); + target->setProperty("action",rack?"routingNativeFxRackBypass": + "routingNativeFxInsertBypass"); + target->setProperty("requestId","hotkey-fx-"+ + juce::String(static_cast(requestSerial))); + target->setProperty("channelId",mapping.channelId); + target->setProperty("deviceEpoch",accepted.getProperty("device",{}) + .getProperty("epoch","0")); + target->setProperty("revision",graph.getProperty("revision","0")); + target->setProperty("value",!static_cast(bypass)); + if (slot) { + target->setProperty("slot",mapping.slot); + target->setProperty("insertId",mapping.insertId); + } + return {Kind::action,out}; + } + if (mapping.operation!="SET_MUTE" && mapping.operation!="SET_SOLO")return {}; + const auto current=row.getProperty("controls",{}).getProperty( + mapping.operation=="SET_MUTE"?"mute":"solo",{}); + if (!current.isBool())return {}; + auto value=juce::var(new juce::DynamicObject()); + value.getDynamicObject()->setProperty("value",!static_cast(current)); + auto out=juce::var(new juce::DynamicObject()); + auto* target=out.getDynamicObject(); + target->setProperty("requestId","hotkey-"+ + juce::String(static_cast(requestSerial))); + target->setProperty("operation",mapping.operation); + target->setProperty("targetChannelId",mapping.channelId); + target->setProperty("deviceEpoch",accepted.getProperty("device",{}) + .getProperty("epoch","0")); + target->setProperty("baseGraphRevision",graph.getProperty("revision","0")); + target->setProperty("baseRosterRevision",graph.getProperty("rosterRevision","0")); + target->setProperty("payload",value); + return {Kind::intent,out}; + } +}; +} // namespace armix::hotkey diff --git a/tests/native_hotkey_registry_test.cpp b/tests/native_hotkey_registry_test.cpp index 44b86124c..b9ad16599 100644 --- a/tests/native_hotkey_registry_test.cpp +++ b/tests/native_hotkey_registry_test.cpp @@ -5,6 +5,7 @@ #include #include #include "../src/NativeHotkeyRegistry.h" +#include "../src/NativeHotkeyCommandPlan.h" using armix::hotkey::Mapping; using armix::hotkey::Registry; @@ -127,6 +128,118 @@ int main() { assert(item.getProperty("status","").toString()=="UNAVAILABLE"); } #endif + + // MV-13: native command construction is independent of ConsoleWindow, + // registered chords and any extra audio/graph owner. + using Planner=armix::hotkey::NativeHotkeyCommandPlan; + auto accepted=juce::var(new juce::DynamicObject()); + auto device=juce::var(new juce::DynamicObject()); + device.getDynamicObject()->setProperty("epoch","18446744073709551610"); + accepted.getDynamicObject()->setProperty("device",device); + auto graph=juce::var(new juce::DynamicObject()); + graph.getDynamicObject()->setProperty("revision","9007199254740995"); + graph.getDynamicObject()->setProperty("rosterRevision","9007199254740996"); + auto caps=juce::var(new juce::DynamicObject()); + caps.getDynamicObject()->setProperty("callbackOwnsChannelIds",true); + juce::Array ops; + ops.add("SET_MUTE");ops.add("SET_SOLO"); + caps.getDynamicObject()->setProperty("supportedOps",juce::var(ops)); + graph.getDynamicObject()->setProperty("capabilities",caps); + auto channel=juce::var(new juce::DynamicObject()); + const juce::String largeId="18446744073709551615"; + channel.getDynamicObject()->setProperty("id",largeId); + channel.getDynamicObject()->setProperty("role","INPUT"); + channel.getDynamicObject()->setProperty("fxRackBypassed",false); + auto controls=juce::var(new juce::DynamicObject()); + controls.getDynamicObject()->setProperty("mute",false); + controls.getDynamicObject()->setProperty("solo",true); + channel.getDynamicObject()->setProperty("controls",controls); + juce::Array inserts; + for(int i=0;i<3;++i) { + auto item=juce::var(new juce::DynamicObject()); + item.getDynamicObject()->setProperty("id", + i==2?"original-instance":("other-"+juce::String(i))); + item.getDynamicObject()->setProperty("bypassed",i==2); + inserts.add(item); + } + channel.getDynamicObject()->setProperty("inserts",juce::var(inserts)); + juce::Array channels;channels.add(channel); + graph.getDynamicObject()->setProperty("channels",juce::var(channels)); + accepted.getDynamicObject()->setProperty("graph",graph); + Mapping largeMute=mute;largeMute.channelId=largeId; + assert(Registry::valid(largeMute)); + assert(Planner::registrationError(Registry::encode(largeMute),accepted).isEmpty()); + auto fired=Planner::dispatch(largeMute,accepted,session,true,42); + assert(fired.kind==Planner::Kind::intent); + assert(fired.request.getProperty("targetChannelId","").toString()==largeId); + assert(fired.request.getProperty("requestId","").toString()=="hotkey-42"); + assert(fired.request.getProperty("deviceEpoch","").toString()=="18446744073709551610"); + assert(fired.request.getProperty("baseGraphRevision","").toString()=="9007199254740995"); + assert(fired.request.getProperty("baseRosterRevision","").toString()=="9007199254740996"); + assert(fired.request.getProperty("payload",{}) + .getProperty("value",{}).isBool()); + assert(static_cast(fired.request.getProperty("payload",{}) + .getProperty("value",{}))); + assert(!static_cast(channel.getProperty("controls",{}) + .getProperty("mute",{}))); // never optimistic native mutation + Mapping largeRack=rack;largeRack.channelId=largeId; + auto power=Planner::dispatch(largeRack,accepted,session,true,43); + assert(power.kind==Planner::Kind::action); + assert(power.request.getProperty("action","").toString()=="routingNativeFxRackBypass"); + assert(power.request.getProperty("requestId","").toString()=="hotkey-fx-43"); + assert(static_cast(power.request.getProperty("value",{}))); + Mapping largeSlot=slot;largeSlot.channelId=largeId; + power=Planner::dispatch(largeSlot,accepted,session,true,44); + assert(power.kind==Planner::Kind::action); + assert(power.request.getProperty("slot",-1)==juce::var(2)); + assert(power.request.getProperty("insertId","").toString()=="original-instance"); + assert(!static_cast(power.request.getProperty("value",{}))); + Mapping staleSlot=largeSlot;staleSlot.insertId="reordered-different-instance"; + assert(Planner::registrationError(Registry::encode(staleSlot),accepted)== + "HOTKEY_FX_INSTANCE_NOT_ADMITTED"); + assert(Planner::dispatch(staleSlot,accepted,session,true,44).kind== + Planner::Kind::ignore); + auto badGraph=accepted; + auto capsOff=juce::var(new juce::DynamicObject()); + capsOff.getDynamicObject()->setProperty("callbackOwnsChannelIds",false); + auto noCallback=juce::var(new juce::DynamicObject()); + noCallback.getDynamicObject()->setProperty("capabilities",capsOff); + noCallback.getDynamicObject()->setProperty("channels",juce::var(channels)); + badGraph=juce::var(new juce::DynamicObject()); + badGraph.getDynamicObject()->setProperty("graph",noCallback); + assert(Planner::dispatch(largeMute,badGraph,session,true,45).kind== + Planner::Kind::ignore); + assert(Planner::registrationError(Registry::encode(largeMute),badGraph)== + "HOTKEY_CHANNEL_NOT_ADMITTED"); + assert(Planner::dispatch(largeMute,accepted,"different-session",true,46).kind== + Planner::Kind::ignore); + assert(Planner::dispatch(largeMute,accepted,session,false,46).kind== + Planner::Kind::ignore); + Mapping largeSolo=solo;largeSolo.channelId=largeId; + fired=Planner::dispatch(largeSolo,accepted,session,true,47); + assert(fired.kind==Planner::Kind::intent); + assert(!static_cast(fired.request.getProperty("payload",{}) + .getProperty("value",{}))); + Mapping largeParam=param;largeParam.channelId=largeId; + assert(Planner::dispatch(largeParam,accepted,session,true,48).kind== + Planner::Kind::parameter); + Mapping wrongRole=largeMute;wrongRole.channelId="1"; + assert(Planner::dispatch(wrongRole,accepted,session,true,48).kind== + Planner::Kind::ignore); + auto absent=Registry::encode(largeMute); + absent.getDynamicObject()->setProperty("operation","SET_MUTE_UNSUPPORTED"); + assert(Planner::registrationError(absent,accepted)=="HOTKEY_ACTION_UNSUPPORTED"); + auto missingOp=juce::var(new juce::DynamicObject()); + missingOp.getDynamicObject()->setProperty("callbackOwnsChannelIds",true); + missingOp.getDynamicObject()->setProperty("supportedOps",juce::var(juce::Array{})); + auto noOpGraph=juce::var(new juce::DynamicObject()); + noOpGraph.getDynamicObject()->setProperty("capabilities",missingOp); + noOpGraph.getDynamicObject()->setProperty("channels",juce::var(channels)); + auto noOps=juce::var(new juce::DynamicObject()); + noOps.getDynamicObject()->setProperty("graph",noOpGraph); + assert(Planner::registrationError(Registry::encode(largeMute),noOps)== + "HOTKEY_ACTION_NOT_ADMITTED"); + assert(temp.deleteRecursively()); std::cout<<"PASS: global chord validation, native registration rollback, " "session identity and crash-safe persistence\n"; From 763739a975b7b4d43a2e46dc17db6e3619e38e87 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 16:30:20 +0700 Subject: [PATCH 2/4] test(mv13): assert native hotkey policy owner rather than inlined Main.cpp tokens --- tests/approved_native_gui_bundle_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py index e6f08d004..13fb26963 100644 --- a/tests/approved_native_gui_bundle_test.py +++ b/tests/approved_native_gui_bundle_test.py @@ -109,7 +109,11 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self) self.assertIn('data-action="slotPower"', context_menu) self.assertIn('data-action="fxOn"', context_menu) native_host = (ROOT / "src/Main.cpp").read_text("utf-8") - self.assertIn("HOTKEY_FX_INSTANCE_NOT_ADMITTED", native_host) + hotkey_policy = (ROOT / "src/NativeHotkeyCommandPlan.h").read_text("utf-8") + self.assertIn("HOTKEY_FX_INSTANCE_NOT_ADMITTED", hotkey_policy) + self.assertIn("NativeHotkeyCommandPlan::registrationError", native_host) + self.assertIn("NativeHotkeyCommandPlan::dispatch", native_host) + self.assertIn("exactFxSlot", hotkey_policy) self.assertIn("Browse Parameters…", context_menu) self.assertIn("Last Touched Hotkey…", context_menu) self.assertIn("arMixFxParameterHotkeyInspect", context_menu) @@ -130,7 +134,8 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self) self.assertIn("Orbit…", context_menu) self.assertIn('withEventListener ("arMixHotkeyIntent"', native_host) self.assertIn("fireNativeHotkey", native_host) - self.assertIn("handleApprovedNativeControl(request)", native_host) + self.assertIn("handleApprovedNativeControl(plan.request)", native_host) + self.assertIn("onAction(plan.request)", native_host) self.assertIn("WM_HOTKEY", (ROOT / "src/NativeHotkeyRegistry.h").read_text("utf-8")) self.assertNotIn("approved-native-context-menu.js", approved) self.assertIn("arMixGuiReady", (out / "assets/approved-native-bridge.js").read_text("utf-8")) From f140e4c06c6d8224eb04f1f940383f1bf8bc7f4c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 16:31:41 +0700 Subject: [PATCH 3/4] test(mv13): accept multiline C++ hotkey policy qualifier in architecture contract --- tests/approved_native_gui_bundle_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py index 13fb26963..fa981c0d3 100644 --- a/tests/approved_native_gui_bundle_test.py +++ b/tests/approved_native_gui_bundle_test.py @@ -111,7 +111,7 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self) native_host = (ROOT / "src/Main.cpp").read_text("utf-8") hotkey_policy = (ROOT / "src/NativeHotkeyCommandPlan.h").read_text("utf-8") self.assertIn("HOTKEY_FX_INSTANCE_NOT_ADMITTED", hotkey_policy) - self.assertIn("NativeHotkeyCommandPlan::registrationError", native_host) + self.assertRegex(native_host, r"NativeHotkeyCommandPlan::\\s*registrationError") self.assertIn("NativeHotkeyCommandPlan::dispatch", native_host) self.assertIn("exactFxSlot", hotkey_policy) self.assertIn("Browse Parameters…", context_menu) From c56a2c594aff8b256789e16e86e3fc0acbce6c96 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 16:32:04 +0700 Subject: [PATCH 4/4] test(mv13): use regex whitespace class for split native C++ qualifier --- tests/approved_native_gui_bundle_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py index fa981c0d3..7fcd2880c 100644 --- a/tests/approved_native_gui_bundle_test.py +++ b/tests/approved_native_gui_bundle_test.py @@ -111,7 +111,7 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self) native_host = (ROOT / "src/Main.cpp").read_text("utf-8") hotkey_policy = (ROOT / "src/NativeHotkeyCommandPlan.h").read_text("utf-8") self.assertIn("HOTKEY_FX_INSTANCE_NOT_ADMITTED", hotkey_policy) - self.assertRegex(native_host, r"NativeHotkeyCommandPlan::\\s*registrationError") + self.assertRegex(native_host, r"NativeHotkeyCommandPlan::\s*registrationError") self.assertIn("NativeHotkeyCommandPlan::dispatch", native_host) self.assertIn("exactFxSlot", hotkey_policy) self.assertIn("Browse Parameters…", context_menu)