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
2 changes: 2 additions & 0 deletions .github/workflows/p1-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ jobs:
node --test tests/workstream_coordination_contract.test.mjs tests/ci_workflow_efficiency_test.mjs tests/chat_ci_dispatch_contract.test.mjs tests/approved_native_m2_contract.test.cjs tests/native_artifact_packaging_contract_test.mjs tests/windows_installer_contract_test.mjs tests/live_graph_contract_test.mjs tests/native_caption_wire_geometry_contract.test.cjs
python -m unittest discover -s tests -p approved_native_gui_bundle_test.py -v
python -m unittest discover -s scripts/tests -p test_factoryfx_release_bundle.py -v
- name: WaveShell JUCE 8 class-index regression (no paid Windows)
run: python -m unittest discover -s tests -p test_waveshell_juce_patch.py -v
- name: Compressor exact-source native CPU A/B (same runner, non-gating timing)
if: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'perf/compressor-') }}
run: python scripts/benchmark_compressor_ab.py --reference 043748a552e66fd72e217cbf66aa35e6cc3e0b21
Expand Down
25 changes: 23 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT DEFINED JUCE_ROOT)
message(FATAL_ERROR "Pass -DJUCE_ROOT=C:/path/to/JUCE (8.0.15+ required)")
endif()
add_subdirectory("${JUCE_ROOT}" "${CMAKE_BINARY_DIR}/juce")

find_package(Python3 REQUIRED COMPONENTS Interpreter)
# JUCE 8.0.15 WaveShell class indices move after setHostContext.
# Apply audited upstream 3fa28d0 ordering correction before compilation.
execute_process(
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/patch_juce_vst3_waveshell.py"
--juce-root "${JUCE_ROOT}"
RESULT_VARIABLE ARMIX_WAVESHELL_PATCH_RESULT
OUTPUT_VARIABLE ARMIX_WAVESHELL_PATCH_MESSAGE
ERROR_VARIABLE ARMIX_WAVESHELL_PATCH_ERROR)
if(NOT ARMIX_WAVESHELL_PATCH_RESULT EQUAL 0)
message(FATAL_ERROR "JUCE WaveShell VST3 host fix not verified: ${ARMIX_WAVESHELL_PATCH_ERROR}")
endif()
message(STATUS "${ARMIX_WAVESHELL_PATCH_MESSAGE}")
add_subdirectory("${JUCE_ROOT}" "${CMAKE_BINARY_DIR}/juce")
# The independent exact-byte verifier must use the SAME Python interpreter
# selected by CMake to generate compressed favicon/PNG resources (Windows
# runners can have several Python versions with different zlib builds).
Expand Down Expand Up @@ -276,6 +287,16 @@ if(BUILD_TESTING)
juce::juce_audio_devices juce::juce_recommended_config_flags)
target_compile_features(ARMixDeviceApplyCoordinatorTests PRIVATE cxx_std_20)
add_test(NAME NativeDeviceApplyPinValidationAndRollbackEvidence COMMAND ARMixDeviceApplyCoordinatorTests)
juce_add_console_app(ARMixVst3StartupSafetyTests PRODUCT_NAME "ArSonMix Waves VST3 Identity and Recovery Tests")
target_sources(ARMixVst3StartupSafetyTests PRIVATE
tests/vst3_waves_identity_startup_test.cpp
src/Vst3DescriptionCache.h src/StartupVst3RecoveryGuard.h)
target_link_libraries(ARMixVst3StartupSafetyTests PRIVATE
juce::juce_audio_processors juce::juce_recommended_config_flags)
target_compile_features(ARMixVst3StartupSafetyTests PRIVATE cxx_std_20)
add_test(NAME WavesVst3IdentityAndStartupCrashRecovery COMMAND ARMixVst3StartupSafetyTests)
add_test(NAME Vst3WaveShellHostContextOrderingFixture
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_waveshell_juce_patch.py")
add_executable(ARMixLiveRoutingEpochTests tests/live_port_epoch_publisher_test.cpp)
target_compile_features(ARMixLiveRoutingEpochTests PRIVATE cxx_std_20)
add_test(NAME P1ELivePortGenerationRevisionAndRealtimeRetirement COMMAND ARMixLiveRoutingEpochTests)
Expand Down
1 change: 1 addition & 0 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Assembled /preview/ DOM (presentation only)
| Modal setup transaction (M2b) | src/Main.cpp::showDeviceSetup; NativeDeviceApplyCoordinator.h | Persistent one-owner lease across visible JUCE selector, explicit Apply and automatic ASIO restart; repeated Setup clicks never re-mute; selector close completes readback/rebind before releasing lease |
| Live hardware readback (M2c) | src/NativeDeviceApplyCoordinator.h; src/Main.cpp | Consolidated actual device-object readback on CONTROL, strict ASIO driver instance identity and live mask/rate/buffer verification before Apply/rollback; no new device owner or callback |
| Production audio compatibility | src/LiveDryRoutingLab.h; engine/core/UnifiedLegacyProductionAdmission.h | Retain only proven required M4/FAT migration semantics; never create another render authority |
| Waves VST3 / crash-safe recovery | scripts/patch_juce_vst3_waveshell.py; src/Vst3DescriptionCache.h; src/StartupVst3RecoveryGuard.h | Correct JUCE 8 WaveShell class-ordering defect; require name+UID resolution; protect saved .smix from repeated startup vendor crashes |
| M3a actual render evidence | engine/core/ProductionRenderAudit.h; LiveDryRoutingLab::process/status; docs/architecture/M3_RENDER_PATH_EVIDENCE_20261111.md | One native or M4 render attempt per JUCE callback; success/fault/overlap and muted/unpatched readback; no audio authority change |
| Built-in DSP and VST lifecycle | engine/builtin_fx/**; src/NativeBuiltInFx.h; src/FactoryFxRegistry.h; src/PluginCatalog.h; engine/core/DynamicChannelFxLeaseBank.h; src/LiveAudioEngine.h | Per-processor DSP; one built-in registration for live insert, offline prepare, restore and native picker. Specialized editors and vendor lease remain with their existing owners. |
| Player | engine/player/**; src/Main.cpp dispatch | Worker decode / buffered PCM, one native graph virtual input, no independent hardware output callback |
Expand Down
30 changes: 30 additions & 0 deletions docs/architecture/WAVESHELL_STARTUP_RECOVERY_20261111.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# WaveShell identity and startup recovery — P0

Root cause: ArSonMix pins JUCE 8.0.15; its VST3ModuleHandle::create resolves
a class index before IPluginFactory3::setHostContext. Waves WaveShell can
re-enumerate its factory at setHostContext, shifting indices and opening
an entirely different plugin. JUCE fixed this on 2026-09-03 in commit
3fa28d0a14f1be97d49603c710afaa6b9b900cdb.

scripts/patch_juce_vst3_waveshell.py applies the exact necessary ordering
change to pinned JUCE 8 before compilation. Unknown or partial sources
fail CMake configure rather than ship a silently vulnerable VST3 host.
Tests enforce idempotence and host-context-before-class-index ordering.

DescriptionCache::choose now selects by exact catalog product name and
JUCE 32-bit UID, rejecting collisions. Direct ADD, native ChannelId ADD,
legacy and saved-session restore pass the expected name. Catalog keys and
the .smix schema are preserved; a mismatched old catalog fails closed.

Crash-safe startup: Vst3RestoreCrashGuard records automatic saved-FX restore
before instantiating any VST3 vendor module. An abnormal termination leaves
the marker. The next launch opens the GUI and does not repeat automatic
FX restore; saved .smix, preset binaries and factory plugins remain intact.
After 15 seconds of normal post-restore operation, or normal application
shutdown, the marker is cleared. A read-only settings folder fails safe.
User can manually Open after investigating/updating the affected VST3.

This guards crashes within startup FX restore, not all possible startup
crash causes: gather WER dump and machine audio/WebView2 diagnostics.
Physical WaveShell v17 listening, GUI/editor identity and restored sessions
must be tested on a licensed user's machine. This is not physical FAT proof.
68 changes: 68 additions & 0 deletions scripts/patch_juce_vst3_waveshell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
"""Apply JUCE's 2026 WaveShell host-context ordering fix to pinned JUCE 8.

The repository intentionally pins JUCE 8.0.15 for the verified native host.
JUCE upstream 3fa28d0 (2026-09-03) fixes WaveShell class-list mutation:
the factory must receive setHostContext BEFORE resolving a class index.
Patch only the three pinned-JUCE anchors, idempotently, or fail closed.
Never patch a different/unknown JUCE implementation silently.
"""
import argparse
from pathlib import Path

RELATIVE = Path("modules/juce_audio_processors_headless/format_types/juce_VST3PluginFormatImpl.h")

OLD = (
"static VST3ModuleHandle create (const File& pluginFile, const PluginDescription& desc)",
" const auto numClasses = factory->countClasses();\n"
" result.classIndex = findClassMatchingDescription (factory, desc);",
"const auto module = VST3ModuleHandle::create (file, description);",
)
NEW = (
"static VST3ModuleHandle create (const File& pluginFile, const PluginDescription& desc, FUnknown* hostContext)",
" // JUCE upstream 3fa28d0: WaveShell changes class indices in setHostContext.\n"
" // Resolve the class index only AFTER the same host context is set.\n"
" if (VSTComSmartPtr<IPluginFactory3> pf3; pf3.loadFrom (factory.get()))\n"
" pf3->setHostContext (hostContext);\n"
" const auto numClasses = factory->countClasses();\n"
" result.classIndex = findClassMatchingDescription (factory, desc);",
"const auto module = VST3ModuleHandle::create (file, description, host->getFUnknown());",
)


def apply_patch(source: str) -> tuple[str, bool]:
# We deliberately support only the audited JUCE 8.0.15 implementation.
if all(source.count(after) == 1 for after in NEW):
return source, False
if any(source.count(before) != 1 for before in OLD):
raise ValueError("JUCE_VST3_WAVESHELL_PATCH_UNSUPPORTED_SOURCE")
if any(after in source for after in NEW):
raise ValueError("JUCE_VST3_WAVESHELL_PATCH_PARTIAL_SOURCE")
updated = source
for before, after in zip(OLD, NEW):
updated = updated.replace(before, after, 1)
if not all(updated.count(after) == 1 for after in NEW):
raise ValueError("JUCE_VST3_WAVESHELL_PATCH_POSTCONDITION_FAILED")
return updated, True


def patch_root(root: Path) -> bool:
target = root / RELATIVE
if not target.is_file():
raise FileNotFoundError(f"JUCE_VST3_WAVESHELL_SOURCE_MISSING: {target}")
original = target.read_text(encoding="utf-8")
changed, modified = apply_patch(original)
if modified:
target.write_text(changed, encoding="utf-8")
return modified


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--juce-root", type=Path, required=True)
args = parser.parse_args()
try:
modified = patch_root(args.juce_root)
except (OSError, ValueError) as exc:
parser.exit(1, f"{exc}\n")
print("JUCE_VST3_WAVESHELL_CONTEXT_ORDER=" + ("PATCHED" if modified else "VERIFIED"))
12 changes: 7 additions & 5 deletions src/LiveAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
}

juce::String addVst3(const juce::String& filename,int uid,
const juce::String& catalogId)
const juce::String& catalogId,
const juce::String& expectedName={})
{
if(independent_.active())return "Return to DIRECT mode before editing VST3";
if(handoff_.busy() || fxMovePhase_.load(std::memory_order_acquire)!=0)
Expand All @@ -1044,7 +1045,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
const auto frames=juce::jmax(32,device->getCurrentBufferSizeSamples());
if(!(rate>0.0) || frames>maxFrames)
return "Unsupported device sample rate or buffer quantum";
const auto chosen=armix::vst::DescriptionCache::resolve(*fmt,filename,uid);
const auto chosen=armix::vst::DescriptionCache::resolve(*fmt,filename,uid,expectedName);
if(!chosen)return "Effect identity not found inside VST3 module";
juce::String error;
auto instance=formats_.createPluginInstance(*chosen,rate,frames,error);
Expand Down Expand Up @@ -1152,7 +1153,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
if (fx.binary.getSize() > armix::storage::NativePresetArchive::maxStateBytes ||
!juce::File (fx.path).exists() || !fx.path.endsWithIgnoreCase (".vst3"))
return "Plugin is missing or invalid: " + fx.name;
const auto match=armix::vst::DescriptionCache::resolve(*fmt,fx.path,fx.uid);
const auto match=armix::vst::DescriptionCache::resolve(*fmt,fx.path,fx.uid,fx.name);
if (!match) return "VST3 plugin identity missing: " + fx.name;

juce::String error;
Expand Down Expand Up @@ -2071,7 +2072,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
LiveDryRoutingLab::NativeBusResult installNativeVst3(
std::uint64_t ep,std::uint64_t pcmRevision,
std::uint64_t rosterRevision,armix::mixer::ChannelId id,
const juce::String& path,int uid,const juce::String& catalogId) {
const juce::String& path,int uid,const juce::String& catalogId,
const juce::String& expectedName={}) {
LiveDryRoutingLab::NativeBusResult fail{};
fail.error="NATIVE_VST3_HOST_UNAVAILABLE";
auto* device=deviceManager_.getCurrentAudioDevice();
Expand All @@ -2091,7 +2093,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
if(!fmt||!fmt->fileMightContainThisPluginType(path))
{fail.error="NATIVE_VST3_MODULE_NOT_FOUND";return fail;}
try {
const auto chosen=armix::vst::DescriptionCache::resolve(*fmt,path,uid);
const auto chosen=armix::vst::DescriptionCache::resolve(*fmt,path,uid,expectedName);
if(!chosen){fail.error="NATIVE_VST3_IDENTITY_NOT_FOUND";return fail;}
juce::String pluginError;
auto instance=formats_.createPluginInstance(*chosen,rate,
Expand Down
51 changes: 44 additions & 7 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#endif
#endif
#include "PluginCatalog.h"
#include "StartupVst3RecoveryGuard.h"
#include "PortableWorkspace.h"
#include "StudioBackup.h"
#include "NativeLiveShowCapture.h"
Expand Down Expand Up @@ -386,6 +387,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
diagnostics_.record("DYNAMIC_MIXER_EXIT_SAVE_REJECTED",error);
}
engine_.stop();
// Normal shutdown is not an interrupted startup. Leave marker intact
// on abnormal vendor termination (destructors never run).
if(startupFxGuard_)(void)startupFxGuard_->complete();
browser_.setVisible (false);
setLookAndFeel (nullptr); // before the owned LookAndFeel is destroyed
}
Expand Down Expand Up @@ -434,6 +438,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
juce::String mixerSessionError_,lastMixerSessionFingerprint_;
bool mixerSessionStartupInspected_=false;
bool mixerSessionRecoveryPending_=false;
std::unique_ptr<armix::startup::Vst3RestoreCrashGuard> startupFxGuard_;
juce::uint32 startupFxGuardTick_=0;
std::unique_ptr<juce::FileChooser> mixerFileChooser_;
bool mixerFileDialogOpen_=false;
juce::File lastMixerFile_;
Expand Down Expand Up @@ -1629,7 +1635,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
*builtIn,ep,rev,roster,armix::mixer::ChannelId{target}):
engine_.installNativeVst3(
ep,rev,roster,armix::mixer::ChannelId{target},
plugin->path,plugin->uid,plugin->key());
plugin->path,plugin->uid,plugin->key(),plugin->name);
applied=result.accepted && result.error &&
result.error[0]==0;
if(!applied)nativeError=result.error;
Expand Down Expand Up @@ -5724,7 +5730,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
closePluginEditor();
try
{
error = engine_.addVst3 (plugin->path, plugin->uid, plugin->key());
error = engine_.addVst3 (plugin->path, plugin->uid, plugin->key(),plugin->name);
}
catch (const std::exception& ex)
{
Expand Down Expand Up @@ -6204,13 +6210,44 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
mixerSessionStartupInspected_=true;
if(armix::session::NativeMixerSessionStore(settingsDirectory()).exists()){
mixerSessionRecoveryPending_=true;
const auto error=restoreSavedMixerSession(startupError_.isEmpty());
if(error.isNotEmpty())
emitNotice(error.startsWith("NEEDS_REMAP:")?error.fromFirstOccurrenceOf(": ",false,false):error,true);
else
deviceSettingsDirty_=true;
auto guard=std::make_unique<armix::startup::Vst3RestoreCrashGuard>(settingsDirectory());
// A crash in vendor DLL code bypasses C++ exception handling.
// Preserve the user's .smix without replaying its FX at every
// launch. Manual Open remains available after diagnosis.
if(guard->interrupted()) {
mixerSessionStatus_="STARTUP_FX_SAFE_RECOVERY";
mixerSessionError_="Previous startup ended during FX restore. "
"Session preserved; reopen it manually after checking VST3 plugins.";
diagnostics_.record("STARTUP_FX_RESTORE_CRASH_GUARD",mixerSessionError_);
emitNotice(mixerSessionError_,true);
} else if(!guard->arm()) {
mixerSessionStatus_="STARTUP_FX_RESTORE_UNAVAILABLE";
mixerSessionError_="Unable to protect saved FX startup. "
"Session preserved; check the settings folder permissions.";
diagnostics_.record("STARTUP_FX_RESTORE_GUARD_IO",mixerSessionError_);
emitNotice(mixerSessionError_,true);
} else {
startupFxGuard_=std::move(guard);
const auto error=restoreSavedMixerSession(startupError_.isEmpty());
if(error.isNotEmpty()) {
(void)startupFxGuard_->complete();
startupFxGuard_.reset();
emitNotice(error.startsWith("NEEDS_REMAP:")?
error.fromFirstOccurrenceOf(": ",false,false):error,true);
} else {
// Count stability only after vendor construction.
startupFxGuardTick_=juce::Time::getMillisecondCounter();
deviceSettingsDirty_=true;
}
}
}else if(startupError_.isEmpty())requestAutomaticMain();
}
// Do not clear the marker as soon as constructors return: Waves and
// other VST3 vendors may crash in their first audio callbacks.
if(startupFxGuard_ && browser_.loaded &&
juce::Time::getMillisecondCounter()-startupFxGuardTick_>=15000u) {
if(startupFxGuard_->complete())startupFxGuard_.reset();
}
serviceAsioMixerRestart();
// ONE actionable notice per unexpected DIRECT reroute. The audio
// callback has already zero-filled output atomically; status, log and
Expand Down
2 changes: 1 addition & 1 deletion src/NativeMixerSessionFxRestore.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NativeMixerSessionFxRestore final {
auto* format=formats.getFormat(0);
if(!format || !format->fileMightContainThisPluginType(insert.path))
return "Saved VST3 unavailable: "+insert.catalogId;
const auto chosen=armix::vst::DescriptionCache::resolve(*format,insert.path,insert.uid);
const auto chosen=armix::vst::DescriptionCache::resolve(*format,insert.path,insert.uid,insert.name);
if(!chosen)return "Saved VST3 identity not found: "+insert.catalogId;
juce::String pluginError;
auto processor=formats.createPluginInstance(*chosen,sampleRate,frames,pluginError);
Expand Down
Loading
Loading