Johan Le Baut 1 тиждень тому
батько
коміт
ac14de715f
25 змінених файлів з 770 додано та 25 видалено
  1. 5 4
      README.md
  2. 8 0
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/manifest.ttl
  3. 21 0
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui.ttl
  4. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/background.png
  5. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/bypass_off.png
  6. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/bypass_on.png
  7. 45 0
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/icon-nam.html
  8. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/knob.png
  9. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/knob.xcf
  10. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/screenshot-nam.png
  11. 130 0
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/stylesheet-nam.css
  12. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/thumbnail-nam.png
  13. BIN
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/neural_amp_modeler.so
  14. 112 0
      artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/neural_amp_modeler.ttl
  15. 12 0
      artifacts/nam-lv2/arm64/current/provenance.json
  16. 6 0
      artifacts/nam-lv2/arm64/current/runtime-dependencies.txt
  17. 1 0
      build/arm64/Dockerfile
  18. 129 0
      build/arm64/build-nam-lv2.sh
  19. 7 2
      build/arm64/entrypoint.sh
  20. 3 0
      config/desired-state.yaml
  21. 1 0
      config/systemd/user/rigforge-mod-ui.service.in
  22. 187 15
      scripts/deploy.py
  23. 5 2
      scripts/generate_mod_ui_pedalboard.py
  24. 13 0
      scripts/validate_desired_state.py
  25. 85 2
      tests/test_deploy.py

+ 5 - 4
README.md

@@ -123,7 +123,7 @@ The helper accepts `install|uninstall|reload` plus `reset mod-ui`, and targets `
 
 For PipeWire, install updates only the Rigforge filter fragment, applies the declared quantum as a runtime setting, and restarts `filter-chain.service` only when the fragment changes. It never restarts `pipewire.service` or WirePlumber. `reload pipewire` reapplies the quantum and restarts the filter-chain user service. This restart removes the filter-chain nodes and their graph links; the fragment recreates ports but not links. Reconciliation is a separate explicit target; installing `mod-host` alone does not install its timer. After a PipeWire/filter restart, inspect with `python3 scripts/observe_pipewire.py`. Uninstall removes only the unchanged managed fragment, restores a file that was present before the first install, returns quantum selection to automatic, and reloads the filter service. Local edits to managed files stop removal or replacement rather than being discarded. Runtime quantum is not persistent across a PipeWire daemon restart.
 
-For NAM LV2, install downloads the declared Raspberry Pi 5 archive with `curl`, checks the archive structure, extracts the `neural_amp_modeler.lv2` bundle under `~/.lv2/`, and records the archive SHA-256 and managed bundle fingerprint. This is a locally computed identity hash, not an independent publisher checksum. An existing same-name bundle is preserved for uninstall; locally modified managed bundles are not overwritten or removed. `reload namlv2` does nothing because plugin installation itself requires no host reload; restart `mod-host` after installing or removing the plugin. On the target, tag `v0.2.3` was installed at `~/.lv2/neural_amp_modeler.lv2`; the observed contents were `manifest.ttl`, `modgui/`, `modgui.ttl`, `neural_amp_modeler.so`, and `neural_amp_modeler.ttl`. The downloaded archive SHA-256 was `80d1a711d573afb7323cbf2ea1a79e39386e58ba449d076c5d89e10b50de3212`; this is an identity hash only, not an independent publisher checksum. The selected NAM model was loaded during the initial manual mod-host chain test; sustained performance and automated startup remain unverified. The release archive is fetched at install time and is not committed to this repository.
+For NAM LV2, `install namlv2` installs the tracked ARM64 bundle at `artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2` under `~/.lv2/`, verifies its build provenance, and records artifact and installed-tree fingerprints. Build it with the `nam-lv2` task documented below. The pinned source remains v0.2.3; the Raspberry Pi 5 release archive is retained as source metadata but is not installed because its statically linked C++ runtime crashed while loading the declared A2 model on this target. The replacement is built with Debian 13's GCC and dynamically links the system `libstdc++` and `libgcc_s`. The previous bundle is preserved at `~/.lv2/neural_amp_modeler.lv2.rigforge-backup` and can be restored by `uninstall namlv2`. `reload namlv2` does nothing; restart `mod-host` after installing or removing the plugin.
 
 For LSP and Dragonfly Reverb, the YAML declares tags and release URLs, and the installer places only LV2 bundles in `~/.lv2/`. LSP installs `lsp-plugins.lv2`; Dragonfly installs its Early Reflections, Hall, Plate, and Room Reverb bundles. LSP extraction requires `7z`, `7zz`, or `7za` on `PATH`, with support for the compression methods used in the release; install or update that system package separately if needed. A listing or extraction error aborts the install before any bundle is changed. The installers hash archives for identity tracking, check archive paths and expected manifests, preserve existing same-name bundles for uninstall, and refuse to remove locally modified managed bundles. `reload lsp` and `reload dragonfly-reverb` do not restart an LV2 host; restart the host after installation or removal. The LSP mono impulse-response plugin was instantiated and used in the initial manual chain test; its `libcairo2` dependency is included in target preparation. Other LSP plugins and Dragonfly runtime dependencies remain unverified on target.
 
@@ -147,7 +147,7 @@ Remove the service with `./scripts/deploy.sh uninstall sooperlooper`.
 
 `install mod-host-ports`, `install mod-host`, and `install mod-ui` are explicit targets and are deliberately excluded from `install all`. `mod-host-ports` starts two mono `/usr/bin/pw-loopback` boundaries: a PipeWire sink `rigforge.mod-host-input` with a paired source visible to mod-ui, and a sink visible to mod-ui paired with the source `rigforge.mod-host-output`. Rigforge's observer manages UMC capture → input sink and output source → guitar mixer/looper. mod-ui is configured to display one “Rigforge Mod-Host Input” and one “Rigforge Mod-Host Output” and owns the internal cables from input to NAM, NAM to IR, and IR to output.
 
-`scripts/generate_mod_ui_pedalboard.py` builds the reference bundle from the YAML: one NAM, one LSP mono IR, the Crunch TB and Vox AC30 assets, the declared NAM output level, and those three mod-ui-owned arcs. During `install mod-ui`, deployment generates a target-specific bundle under Rigforge's dedicated user data directory so the absolute model/IR paths match that checkout; the bundle is fingerprinted and protected from local edits. mod-ui then resumes its last saved board across restarts. `./scripts/deploy.sh reset mod-ui` explicitly restores the generated reference and backs up any prior default board and last-state file as adjacent `.rigforge-reset-backup` paths.
+`scripts/generate_mod_ui_pedalboard.py` builds the reference bundle from the YAML: one NAM, one LSP mono IR, the Crunch TB and Vox AC30 assets, the declared NAM output level, and those three mod-ui-owned arcs. During `install mod-ui`, deployment copies the declared NAM models into Rigforge's dedicated `MOD_USER_FILES_DIR/NAM Models/Rigforge` directory and generates a target-specific bundle whose model path points there; the model copies are fingerprinted and removed only if unchanged when mod-ui is uninstalled. The reference bundle is also target-specific, fingerprinted, and protected from local edits. mod-ui then resumes its last saved board across restarts. `./scripts/deploy.sh reset mod-ui` explicitly restores the generated reference and backs up any prior default board and last-state file as adjacent `.rigforge-reset-backup` paths.
 
 The mod-host unit runs `pw-jack mod-host -n -p 5555 -f 5556`; it no longer runs `configure_mod_host.py`. The mod-ui service starts under `pw-jack`, opens a persistent local WebSocket session so the board loads even before a browser connects, and is the sole control/feedback client for mod-host. Install the ARM64 artifacts, NAM/LSP bundles, and the declared audio assets before activation. The target ports, virtual loopback naming, pedalboard loading, and sustained audio still require an on-target test; the YAML marks newly introduced boundary links as `planned`.
 
@@ -219,9 +219,10 @@ docker buildx build --platform linux/arm64 --load -f build/arm64/Dockerfile -t r
 docker run --rm --platform linux/arm64 --user "$(id -u):$(id -g)" -v "$PWD:/workspace" rigforge-arm64-build:debian13 sooperlooper
 docker run --rm --platform linux/arm64 --user "$(id -u):$(id -g)" -v "$PWD:/workspace" rigforge-arm64-build:debian13 mod-host
 docker run --rm --platform linux/arm64 --user "$(id -u):$(id -g)" -v "$PWD:/workspace" rigforge-arm64-build:debian13 mod-ui
+docker run --rm --platform linux/arm64 --user "$(id -u):$(id -g)" -v "$PWD:/workspace" rigforge-arm64-build:debian13 nam-lv2
 ```
 
-Use task `all` to build all three programs in sequence. The shared image contains the union of their compiler/runtime build dependencies; each task retrieves the source tag from YAML, records the resolved commit, builds only its target, checks runtime dependencies, and writes its artifacts and provenance under `artifacts/<project>/arm64/current/`. The SooperLooper task builds both `sooperlooper` and `slconsole`; the mod-ui task packages its pinned web app, ARM64 `libmod_utils.so`, and vendored Python requirements. It applies the upstream-documented Tornado compatibility adjustment, the SSL hostname backport needed by this Python 3.13 build, and the tracked Rigforge port-mapping/WebSocket patch from `build/arm64/patch_mod_ui_rigforge.py` (its hash is recorded in provenance). The build checks that it is running in an ARM64 Debian container. Each successful task replaces only its own prior output, and staged output is removed on failure. Run the container with the host UID/GID as above so generated files remain accessible to the host user. To update a source version, change its `deployment.sooperlooper.tag`, `deployment.mod_host.tag`, or `deployment.mod_ui.tag`, validate the YAML, then rerun the corresponding task. Buildx `--load` for one ARM64 platform and `docker run --platform linux/arm64` need binfmt/QEMU on AMD64 hosts.
+Use task `all` to build the four programs in sequence. The shared image contains the union of their compiler/runtime build dependencies; each task retrieves the source tag from YAML, records the resolved commit, builds only its target, checks runtime dependencies, and writes its artifacts and provenance under `artifacts/<project>/arm64/current/`. The NAM task deliberately avoids `-static-libstdc++` from the upstream Pi release workflow and verifies a dynamic `libstdc++` dependency. The SooperLooper task builds both `sooperlooper` and `slconsole`; the mod-ui task packages its pinned web app, ARM64 `libmod_utils.so`, and vendored Python requirements. It applies the upstream-documented Tornado compatibility adjustment, the SSL hostname backport needed by this Python 3.13 build, and the tracked Rigforge port-mapping/WebSocket patch from `build/arm64/patch_mod_ui_rigforge.py` (its hash is recorded in provenance). The build checks that it is running in an ARM64 Debian container. The NAM build refuses to overwrite existing artifact output; move it aside for review before rebuilding. Run the container with the host UID/GID as above so generated files remain accessible to the host user. To update a source version, change its corresponding `deployment.*.tag`, validate the YAML, then rerun the corresponding task. Buildx `--load` for one ARM64 platform and `docker run --platform linux/arm64` need binfmt/QEMU on AMD64 hosts.
 
 SooperLooper's tagged source does not define ARM64 atomics in `libs/pbd/pbd/atomic.h` or `src/atomic.h`; the build task injects GCC `__atomic` operations for AArch64 in its temporary clone, leaving the upstream source repository untouched. This local portability patch is recorded in provenance. The image only compiles; it does not deploy or run either program on the Pi. Successful compilation does not establish runtime compatibility: inspect dependencies and test on the target. Review upstream licenses and artifact size before committing generated binaries and provenance.
 
@@ -251,7 +252,7 @@ The remaining target checks are:
 2. Test direct mixer inputs 2 and 4 with sources when available; their direct-to-mix routes remain unverified. Looper capture inputs 2–4 are now linked but have not been tested with instruments.
 3. Measure sustained stability and headroom at 48 kHz / 128 frames with all active sources; the current `ERR = 0` observation was brief.
 4. Test the new PipeWire loopback boundary ports and verify that mod-ui displays and connects them; then verify mod-host feedback pairing, the generated board's initial NAM/IR state, UI edits across restart, explicit reset, and recovery after unplug/replug.
-5. The owner has manually verified FCB notes 6–9 switching the guitar NAM models through the old direct bridge path, with near-instant reported transitions. The updated bridge now uses mod-ui's WebSocket and still needs an on-target test. SooperLooper's supplied FCB1010 bindings were also tested successfully over the declared PipeWire MIDI edge. Verify that the updated observer restores this edge after reboot, service restart, and UMC unplug/replug; verify unattended startup, OSC initialization, audio routing, and the persistence/effect of `discrete_prefader 0` separately.
+5. The owner manually verified FCB notes 6–9 through the old direct mod-host bridge. On 2026-11-23, the upstream Raspberry Pi 5 NAM LV2 binary crashed with SIGSEGV in `NeuralAudio::NAMIsA2` while parsing the declared A2 `SlimmableContainer` model (version 0.7.0), both from the mod-ui picker and the new WebSocket bridge. The NAM file copies matched and memory was available. Rebuilding the same v0.2.3 sources on Debian 13 with GCC 14 and a dynamic system `libstdc++` avoided the crash: bridge-level selections for notes 6, 7, 9, and 8 and a mod-ui selection from the path containing `NAM Models` all completed with zero mod-host restarts. The original shared object is preserved in `~/.lv2/neural_amp_modeler.lv2.rigforge-backup`. This verifies model-load requests and host process survival, not physical FCB delivery, audible model quality, or sustained audio stability. SooperLooper's supplied FCB1010 bindings were also tested successfully over the declared PipeWire MIDI edge. Verify that the updated observer restores this edge after reboot, service restart, and UMC unplug/replug; verify unattended startup, OSC initialization, audio routing, and the persistence/effect of `discrete_prefader 0` separately.
 
 Do not treat planned packages, commands, ports, or service settings as target-validated until these checks have been performed.
 

+ 8 - 0
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/manifest.ttl

@@ -0,0 +1,8 @@
+@prefix lv2:  <http://lv2plug.in/ns/lv2core#>.
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
+@prefix state: <http://lv2plug.in/ns/ext/state#> .
+
+<http://github.com/mikeoliphant/neural-amp-modeler-lv2>
+	a lv2:Plugin;
+	lv2:binary <neural_amp_modeler.so>;
+	rdfs:seeAlso <neural_amp_modeler.ttl>,<modgui.ttl>.

+ 21 - 0
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui.ttl

@@ -0,0 +1,21 @@
+@prefix modgui: <http://moddevices.com/ns/modgui#>.
+@prefix lv2:    <http://lv2plug.in/ns/lv2core#>.
+
+<http://github.com/mikeoliphant/neural-amp-modeler-lv2>
+    modgui:gui [
+        modgui:resourcesDirectory <modgui>;
+        modgui:iconTemplate <modgui/icon-nam.html>;
+        modgui:stylesheet <modgui/stylesheet-nam.css>;
+        modgui:screenshot <modgui/screenshot-nam.png>;
+        modgui:thumbnail <modgui/thumbnail-nam.png>;
+        modgui:discussionURL <https://forum.mod.audio/t/neural-amp-modeler/10112> ;
+        modgui:port [
+            lv2:index 0;
+            lv2:symbol "input_level";
+            lv2:name "Input Lvl";
+        ], [
+            lv2:index 1;
+            lv2:symbol "output_level";
+            lv2:name "Output Lvl";
+        ];
+    ].

BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/background.png


BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/bypass_off.png


BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/bypass_on.png


+ 45 - 0
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/icon-nam.html

@@ -0,0 +1,45 @@
+<div class="mod-pedal mod-pedal-nam">
+    <div mod-role="drag-handle" class="mod-drag-handle"></div>
+    <div class="mod-control-group group1 clearfix">
+        {{#controls}}
+        <div class="mod-knob" title="{{name}}">
+            <div class="mod-knob-title">{{name}}</div>
+            <div class="mod-knob-image" mod-role="input-control-port" mod-port-symbol="{{symbol}}"></div>
+        </div>
+        {{/controls}}
+    </div>
+    <div class="mod-footswitch" mod-role="bypass"></div>
+
+    <div class="mod-control-group group2 clearfix">
+        <div class="mod-control-group mod-enumerated-group bottom clearfix">
+            {{#effect.parameters}}
+            {{#path}}
+            <div class="mod-enumerated" mod-role="input-parameter" mod-parameter-uri="{{uri}}" mod-widget="custom-select-path">
+                <div mod-role="input-parameter-value" mod-parameter-uri="{{uri}}" class="mod-enumerated-selected">
+                    -- choose a NAM model --
+                </div>
+                <div class="mod-enumerated-list">
+                    {{#files}}
+                    <div mod-role="enumeration-option" mod-parameter-value="{{fullname}}">{{basename}}</div>
+                    {{/files}}
+                </div>
+            </div>
+            {{/path}}
+            {{/effect.parameters}}
+        </div>
+    </div>
+    <div class="mod-pedal-input">
+        {{#effect.ports.audio.input}}
+        <div class="mod-input mod-input-disconnected" title="{{name}}" mod-role="input-audio-port" mod-port-symbol="{{symbol}}">
+            <div class="mod-pedal-input-image"></div>
+        </div>
+        {{/effect.ports.audio.input}}
+    </div>
+    <div class="mod-pedal-output">
+        {{#effect.ports.audio.output}}
+        <div class="mod-output mod-output-disconnected" title="{{name}}" mod-role="output-audio-port" mod-port-symbol="{{symbol}}">
+            <div class="mod-pedal-output-image"></div>
+        </div>
+        {{/effect.ports.audio.output}}
+    </div>
+</div>

BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/knob.png


BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/knob.xcf


BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/screenshot-nam.png


+ 130 - 0
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/stylesheet-nam.css

@@ -0,0 +1,130 @@
+/* nam */
+
+@import url(/fonts/nexa/stylesheet.css);
+@import url(/fonts/questrial/stylesheet.css);
+
+/* = CONTAINER
+================================================ */
+.mod-pedal-nam {
+    background-position:center center;
+    background-repeat:no-repeat;
+    /* background image is 1121 × 536*/
+    background-size:560px 268px;
+    background-image:url(/resources/background.png{{{ns}}});
+    width:560px;
+    height:268px;
+    position:absolute;
+    border-radius:40px;
+}
+
+/* = BYPASS
+================================================ */
+.mod-pedal-nam .mod-footswitch {
+    background-image:url(/resources/bypass_on.png{{{ns}}});
+    background-position:center center;
+    background-repeat:no-repeat;
+    background-size:82px 47px;
+    width:82px;
+    height:47px;
+    top:132px;
+    left:235px;
+    cursor:pointer;
+    position:absolute;
+}
+.mod-pedal-nam .mod-footswitch.on {
+    background-image:url(/resources/bypass_off.png{{{ns}}});
+}
+
+/* = KNOBS
+================================================ */
+.mod-pedal-nam .mod-control-group {
+    z-index:30;
+    position:relative;
+    margin:0px;
+    padding:0px;
+    display:inline;
+}
+
+.mod-pedal-nam .group1 {
+    top:86px;
+    left:22px;
+}
+
+.mod-pedal-nam .group2 {
+    top:107px;
+    left:78px;
+}
+
+.mod-pedal-nam .mod-control-group .mod-knob .mod-knob-title {
+    text-align: center;
+    color:white;
+}
+
+.mod-pedal-nam .mod-control-group .mod-knob {
+    overflow:hidden;
+    position:relative;
+    display:inline-block;
+}
+
+.mod-pedal-nam .mod-control-group .mod-knob:first-child {
+    margin-left: 0px;
+}
+
+.mod-pedal-nam .mod-control-group .mod-knob:last-child {
+    margin-left: 315px;
+}
+
+.mod-pedal-nam .mod-control-group .mod-knob .mod-knob-image {
+    background-image:url(/resources/knob.png{{{ns}}});
+    background-position:left center;
+    background-repeat:no-repeat;
+    background-size:5000px 100px;
+    height:100px;
+    width:100px;
+    cursor:pointer;
+}
+
+.mod-pedal-nam .mod-enumerated {
+    position: relative;
+    font-weight: bold;
+    cursor: pointer;
+    color: white;
+}
+
+.mod-pedal-nam .mod-enumerated .mod-enumerated-selected {
+    padding-left: 5px;
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    background-color: transparent;
+    color: white;
+    display: block;
+}
+
+/* THE LIST OF OPTIONS */
+.mod-pedal-nam .mod-enumerated .mod-enumerated-list {
+    background: black;
+    display: none;
+    overflow: auto;
+    position: absolute;
+    padding: 0;
+    width: 405px;
+    height: 220px;
+    border: 2px solid #333;
+}
+
+.mod-pedal-nam .mod-enumerated .mod-enumerated-list > div {
+    padding: 3px 5px;
+}
+
+.mod-pedal-nam .mod-enumerated .mod-enumerated-list > div.selected {
+    background: #333;
+}
+
+.mod-pedal-nam .mod-enumerated .mod-enumerated-list > div:hover {
+    background: #222;
+}
+
+.mod-pedal-nam .mod-enumerated .mod-enumerated-list > div.selected:hover {
+    background: #555;
+}

BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/modgui/thumbnail-nam.png


BIN
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/neural_amp_modeler.so


+ 112 - 0
artifacts/nam-lv2/arm64/current/neural_amp_modeler.lv2/neural_amp_modeler.ttl

@@ -0,0 +1,112 @@
+@prefix atom:  <http://lv2plug.in/ns/ext/atom#>.
+@prefix doap:  <http://usefulinc.com/ns/doap#>.
+@prefix foaf: <http://xmlns.com/foaf/0.1/>.
+@prefix lv2:   <http://lv2plug.in/ns/lv2core#>.
+@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
+@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>.
+@prefix ui:    <http://lv2plug.in/ns/extensions/ui#>.
+@prefix units: <http://lv2plug.in/ns/extensions/units#>.
+@prefix urid:  <http://lv2plug.in/ns/ext/urid#>.
+@prefix opts:  <http://lv2plug.in/ns/ext/options#> .
+@prefix param: <http://lv2plug.in/ns/ext/parameters#>.
+@prefix patch: <http://lv2plug.in/ns/ext/patch#>.
+@prefix state: <http://lv2plug.in/ns/ext/state#>.
+@prefix work:  <http://lv2plug.in/ns/ext/worker#>.
+@prefix mod: <http://moddevices.com/ns/mod#>.
+
+<http://github.com/mikeoliphant/neural-amp-modeler-lv2#model>
+	a lv2:Parameter;
+	mod:fileTypes "nam,nammodel,json,aidax,aidadspmodel";
+	rdfs:label "Neural Model";
+	rdfs:range atom:Path.
+
+<http://github.com/mikeoliphant/neural-amp-modeler-lv2>
+	a lv2:Plugin, lv2:SimulatorPlugin, doap:Project;
+	doap:name "Neural Amp Modeler";
+	lv2:project <http://github.com/mikeoliphant/neural-amp-modeler-lv2>;
+	lv2:minorVersion 2;
+	lv2:microVersion 3;
+	doap:license <http://opensource.org/licenses/gpl-3-0>;
+
+	doap:maintainer [
+		foaf:name "Mike Oliphant";
+		foaf:homepage <http://github.com/mikeoliphant>;
+	];
+
+	lv2:requiredFeature urid:map, work:schedule;
+	lv2:optionalFeature lv2:hardRTCapable, opts:options, state:threadSafeRestore;
+	lv2:extensionData work:interface, state:interface, opts:interface;
+	opts:supportedOption <http://lv2plug.in/ns/ext/buf-size#maxBlockLength>;
+
+	rdfs:comment """
+LV2 plugin for neural network machine learning guitar amplifier simulation models
+
+Models supported:
+  Neural Amp Modeler (NAM): https://github.com/sdatkinson/neural-amp-modeler
+  RTNeural keras/Aida-x models: https://github.com/jatinchowdhury18/RTNeural
+
+A large collection of models is available at https://www.tone3000.com
+""";
+
+	patch:writable <http://github.com/mikeoliphant/neural-amp-modeler-lv2#model>;
+
+	# Control
+	lv2:port [
+		a atom:AtomPort, lv2:InputPort;
+		atom:bufferType atom:Sequence;
+		atom:supports patch:Message;
+		lv2:designation lv2:control;
+		lv2:index 0;
+		lv2:symbol "control";
+		lv2:name "Control"
+	], [
+		a atom:AtomPort, lv2:OutputPort;
+		atom:bufferType atom:Sequence;
+		atom:supports patch:Message;
+		lv2:designation lv2:control;
+		lv2:index 1;
+		lv2:symbol "notify";
+		lv2:name "Notify"
+	];
+
+	# Audio Ports
+	lv2:port [
+		a lv2:InputPort, lv2:AudioPort;
+		lv2:index 2;
+		lv2:symbol "input";
+		lv2:name "Input";
+	], [
+		a lv2:OutputPort, lv2:AudioPort;
+		lv2:index 3;
+		lv2:symbol "output";
+		lv2:name "Output";
+	];
+
+	# Parameters
+	lv2:port [
+		a lv2:ControlPort, lv2:InputPort;
+		lv2:index 4;
+		lv2:symbol "input_level";
+		lv2:name "Input Lvl";
+		lv2:default 0.0;
+		lv2:minimum -20.0;
+		lv2:maximum 20.0;
+		units:unit units:db;
+	], [
+		a lv2:ControlPort, lv2:InputPort;
+		lv2:index 5;
+		lv2:symbol "output_level";
+		lv2:name "Output Lvl";
+		lv2:default 0.0;
+		lv2:minimum -20.0;
+		lv2:maximum 20.0;
+		units:unit units:db;
+	], [
+		a lv2:ControlPort, lv2:InputPort;
+		lv2:index 6;
+		lv2:symbol "quality_scale";
+		lv2:name "Quality";
+		lv2:default 1.0;
+		lv2:minimum 0.0;
+		lv2:maximum 1.0;
+	].

+ 12 - 0
artifacts/nam-lv2/arm64/current/provenance.json

@@ -0,0 +1,12 @@
+{
+  "source_url": "https://github.com/mikeoliphant/neural-amp-modeler-lv2",
+  "tag": "v0.2.3",
+  "source_commit": "3d0e1c26a4cfb7085b185811dd564f7ec7ec4991",
+  "neural_audio_commit": "b1137e1db2d43670e7dcf6345ade7808613cac20",
+  "platform": "linux/aarch64",
+  "compiler": "g++ (Debian 14.2.0-19) 14.2.0",
+  "cmake": "3.31.6",
+  "linkage": "system libstdc++ and libgcc_s",
+  "artifact": "neural_amp_modeler.lv2/neural_amp_modeler.so",
+  "artifact_sha256": "6a08f9e45a361997406832b0d1d0f2f94cc96ed114c1df7604ca7af43d5fe434"
+}

+ 6 - 0
artifacts/nam-lv2/arm64/current/runtime-dependencies.txt

@@ -0,0 +1,6 @@
+	linux-vdso.so.1 (0x00007fff7af08000)
+	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x00007fff7aa90000)
+	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x00007fff7a9e0000)
+	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x00007fff7a9a0000)
+	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x00007fff7a7d0000)
+	/lib/ld-linux-aarch64.so.1 (0x00007fff7aed0000)

+ 1 - 0
build/arm64/Dockerfile

@@ -8,6 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
     autopoint \
     build-essential \
     ca-certificates \
+    cmake \
     gettext \
     git \
     libasound2-dev \

+ 129 - 0
build/arm64/build-nam-lv2.sh

@@ -0,0 +1,129 @@
+#!/bin/sh
+set -eu
+
+repository_root=${RIGFORGE_ROOT:-/workspace}
+state_file="$repository_root/config/desired-state.yaml"
+artifact_directory="$repository_root/artifacts/nam-lv2/arm64/current"
+staged_directory=
+work_directory=
+
+cleanup() {
+    if [ -n "$staged_directory" ] && [ -e "$staged_directory" ]; then
+        rm -rf "$staged_directory"
+    fi
+    if [ -n "$work_directory" ] && [ -e "$work_directory" ]; then
+        rm -rf "$work_directory"
+    fi
+}
+
+trap cleanup EXIT
+trap 'exit 129' HUP
+trap 'exit 130' INT
+trap 'exit 143' TERM
+
+case "$(dpkg --print-architecture)" in
+    arm64) ;;
+    *) printf '%s\n' "This build task requires an ARM64 container." >&2; exit 1 ;;
+esac
+
+python3 - "$repository_root" "$state_file" <<'PY'
+import sys
+from pathlib import Path
+
+import yaml
+
+repository_root = Path(sys.argv[1])
+sys.path.insert(0, str(repository_root / "scripts"))
+from validate_desired_state import validate_state
+
+with Path(sys.argv[2]).open(encoding="utf-8") as stream:
+    state = yaml.safe_load(stream)
+errors = validate_state(state)
+if errors:
+    raise SystemExit("Invalid desired state: " + "; ".join(errors))
+PY
+
+set -- $(python3 - "$state_file" <<'PY'
+import sys
+
+import yaml
+
+with open(sys.argv[1], encoding="utf-8") as stream:
+    nam = yaml.safe_load(stream)["deployment"]["namlv2"]
+print(nam["source_url"])
+print(nam["tag"])
+PY
+)
+source_url=$1
+tag=$2
+
+mkdir -p "$(dirname "$artifact_directory")"
+previous_directory="$artifact_directory.previous"
+if [ -e "$artifact_directory" ] || [ -e "$previous_directory" ]; then
+    printf '%s\n' "Refusing to overwrite an existing NAM LV2 artifact; move it aside first." >&2
+    exit 1
+fi
+
+work_directory=$(mktemp -d /tmp/nam-lv2-build.XXXXXX)
+staged_directory=$(mktemp -d "$(dirname "$artifact_directory")/.build.XXXXXX")
+source_directory="$work_directory/source"
+git clone --no-checkout "$source_url" "$source_directory"
+git -C "$source_directory" checkout --detach "refs/tags/$tag"
+git -C "$source_directory" submodule update --init --recursive
+source_commit=$(git -C "$source_directory" rev-parse HEAD)
+neural_audio_commit=$(git -C "$source_directory/deps/NeuralAudio" rev-parse HEAD)
+
+# Do not inherit the release workflow's -static-libstdc++/-static-libgcc flags.
+unset CFLAGS CXXFLAGS
+"$(command -v cmake)" -S "$source_directory" -B "$work_directory/build" \
+    -DCMAKE_BUILD_TYPE=Release \
+    -DBUILD_NAMCORE=ON \
+    -DBUILD_INTERNAL_STATIC_WAVENET=ON \
+    -DBUILD_INTERNAL_STATIC_LSTM=ON \
+    -DMULTIFRAME_8X8_CONVOLUTION=8
+"$(command -v cmake)" --build "$work_directory/build" --target copy_binaries -j2
+
+bundle="$work_directory/build/neural_amp_modeler.lv2"
+if [ ! -d "$bundle" ] || [ ! -f "$bundle/neural_amp_modeler.so" ]; then
+    printf '%s\n' "NAM LV2 build did not produce the expected bundle." >&2
+    exit 1
+fi
+
+install -d "$staged_directory/neural_amp_modeler.lv2"
+cp -a "$bundle/." "$staged_directory/neural_amp_modeler.lv2/"
+ldd "$staged_directory/neural_amp_modeler.lv2/neural_amp_modeler.so" \
+    > "$staged_directory/runtime-dependencies.txt"
+if grep -F 'not found' "$staged_directory/runtime-dependencies.txt"; then
+    printf '%s\n' "Unresolved runtime dependency in NAM LV2 build." >&2
+    exit 1
+fi
+if ! grep -F 'libstdc++.so.6 =>' "$staged_directory/runtime-dependencies.txt" >/dev/null; then
+    printf '%s\n' "NAM LV2 must use the target's shared libstdc++ runtime." >&2
+    exit 1
+fi
+
+binary_sha256=$(sha256sum "$staged_directory/neural_amp_modeler.lv2/neural_amp_modeler.so" | cut -d ' ' -f 1)
+cmake_version=$("$(command -v cmake)" --version | sed -n '1s/^cmake version //p')
+compiler_version=$(c++ --version | sed -n '1p')
+cat > "$staged_directory/provenance.json" <<EOF
+{
+  "source_url": "$source_url",
+  "tag": "$tag",
+  "source_commit": "$source_commit",
+  "neural_audio_commit": "$neural_audio_commit",
+  "platform": "linux/aarch64",
+  "compiler": "$compiler_version",
+  "cmake": "$cmake_version",
+  "linkage": "system libstdc++ and libgcc_s",
+  "artifact": "neural_amp_modeler.lv2/neural_amp_modeler.so",
+  "artifact_sha256": "$binary_sha256"
+}
+EOF
+
+chmod 0755 "$staged_directory"
+chmod 0644 "$staged_directory/provenance.json" "$staged_directory/runtime-dependencies.txt"
+mv "$staged_directory" "$artifact_directory"
+staged_directory=
+printf 'Built NAM LV2 %s at %s\n' "$tag" "$source_commit"
+printf 'Artifact: %s/neural_amp_modeler.lv2\n' "$artifact_directory"
+printf 'SHA-256: %s\n' "$binary_sha256"

+ 7 - 2
build/arm64/entrypoint.sh

@@ -14,14 +14,19 @@ case "${1:-}" in
         shift
         exec /opt/rigforge/build/arm64/build-mod-ui.sh "$@"
         ;;
+    nam-lv2)
+        shift
+        exec /opt/rigforge/build/arm64/build-nam-lv2.sh "$@"
+        ;;
     all)
         shift
         /opt/rigforge/build/arm64/build-sooperlooper.sh "$@"
         /opt/rigforge/build/arm64/build-mod-host.sh "$@"
-        exec /opt/rigforge/build/arm64/build-mod-ui.sh "$@"
+        /opt/rigforge/build/arm64/build-mod-ui.sh "$@"
+        exec /opt/rigforge/build/arm64/build-nam-lv2.sh "$@"
         ;;
     *)
-        printf '%s\n' "Usage: docker run ... rigforge-arm64-build:{tag} sooperlooper|mod-host|mod-ui|all" >&2
+        printf '%s\n' "Usage: docker run ... rigforge-arm64-build:{tag} sooperlooper|mod-host|mod-ui|nam-lv2|all" >&2
         exit 2
         ;;
 esac

+ 3 - 0
config/desired-state.yaml

@@ -36,7 +36,9 @@ system:
 deployment:
   namlv2:
     tag: v0.2.3
+    source_url: https://github.com/mikeoliphant/neural-amp-modeler-lv2
     archive_url: https://github.com/mikeoliphant/neural-amp-modeler-lv2/releases/download/v0.2.3/neural_amp_modeler_lv2_rpi5.tgz
+    artifact_directory: artifacts/nam-lv2/arm64/current
     bundle_directory: neural_amp_modeler.lv2
   lsp:
     tag: "1.2.37"
@@ -109,6 +111,7 @@ deployment:
     websocket_port: 8888
     reference_directory: .local/share/rigforge/mod-ui/references
     pedalboards_directory: .local/share/rigforge/mod-ui/pedalboards
+    user_files_directory: .local/share/rigforge/mod-ui/user-files
     last_state_file: .local/share/rigforge/mod-ui/last-rigforge.json
     hardware_input_port: rigforge.mod-host-input.capture:capture_AUX0
     hardware_output_port: rigforge.mod-host-output.playback:playback_AUX0

+ 1 - 0
config/systemd/user/rigforge-mod-ui.service.in

@@ -10,6 +10,7 @@ Environment=MOD_DEV_ENVIRONMENT=0
 Environment=MOD_DATA_DIR=@MOD_DATA_DIR@
 Environment=MOD_LAST_STATE_JSON=@MOD_LAST_STATE@
 Environment=MOD_USER_PEDALBOARDS_DIR=@PEDALBOARDS_DIR@
+Environment=MOD_USER_FILES_DIR=@USER_FILES_DIR@
 Environment=MOD_DEFAULT_PEDALBOARD=@REFERENCE_PEDALBOARD@
 Environment=MOD_DEVICE_WEBSERVER_PORT=@WEBSOCKET_PORT@
 Environment=MOD_RIGFORGE_CAPTURE_PORT=@HARDWARE_INPUT_PORT@

+ 187 - 15
scripts/deploy.py

@@ -66,6 +66,8 @@ def load_deployment():
             errors.append(f"{component} bundle paths are invalid")
     tag = namlv2.get("tag")
     match = NAM_RELEASE_ASSET.fullmatch(namlv2.get("archive_url", ""))
+    if namlv2.get("source_url") != "https://github.com/mikeoliphant/neural-amp-modeler-lv2":
+        errors.append("NAM LV2 source URL is invalid")
     if not isinstance(tag, str) or not re.fullmatch(r"[A-Za-z0-9._-]+", tag):
         errors.append("NAM LV2 tag is invalid")
     if match is None or match.group("tag") != tag:
@@ -693,9 +695,42 @@ def deploy_namlv2(action, config, registry):
     destination = Path.home() / ".lv2" / bundle_name
     validate_user_destination(destination)
     managed = registry.get("namlv2")
+    artifact_directory = config.get("artifact_directory")
+    artifact_bundle = None
+    artifact_digest = None
+    if artifact_directory is not None:
+        relative = PurePosixPath(artifact_directory)
+        if relative.is_absolute() or ".." in relative.parts or not relative.parts:
+            raise RuntimeError("NAM LV2 artifact directory must be a safe repository path")
+        artifact_root = (ROOT / Path(*relative.parts)).resolve()
+        if not artifact_root.is_relative_to(ROOT.resolve()):
+            raise RuntimeError("NAM LV2 artifact directory escapes the repository")
+        artifact_bundle = artifact_root / bundle_name
+        provenance_path = artifact_root / "provenance.json"
+        if not artifact_bundle.is_dir() or not provenance_path.is_file():
+            raise FileNotFoundError(
+                f"built NAM LV2 artifact is missing: {artifact_bundle}"
+            )
+        with provenance_path.open(encoding="utf-8") as stream:
+            provenance = json.load(stream)
+        if (
+            provenance.get("source_url") != "https://github.com/mikeoliphant/neural-amp-modeler-lv2"
+            or provenance.get("tag") != config["tag"]
+            or provenance.get("linkage") != "system libstdc++ and libgcc_s"
+        ):
+            raise RuntimeError("built NAM LV2 artifact provenance does not match desired state")
+        plugin_binary = artifact_bundle / "neural_amp_modeler.so"
+        if (
+            not (artifact_bundle / "manifest.ttl").is_file()
+            or not (artifact_bundle / "neural_amp_modeler.ttl").is_file()
+            or not plugin_binary.is_file()
+            or file_sha256(plugin_binary) != provenance.get("artifact_sha256")
+        ):
+            raise RuntimeError("built NAM LV2 artifact failed its provenance check")
+        artifact_digest = tree_sha256(artifact_bundle)
 
     if action == "reload":
-        print("Nothing to reload for the NAM LV2 plugin; restart its LV2 host after installation.")
+        print("Nothing to reload for the NAM LV2 plugin; restart mod-host after installation.")
         return
 
     if action == "uninstall":
@@ -756,7 +791,9 @@ def deploy_namlv2(action, config, registry):
             raise RuntimeError(f"managed NAM LV2 bundle is missing: {destination}")
         if tree_sha256(destination) != managed.get("installed_sha256"):
             raise RuntimeError(f"managed NAM LV2 bundle changed locally; refusing overwrite: {destination}")
-        if managed.get("tag") == config["tag"]:
+        if managed.get("tag") == config["tag"] and (
+            artifact_digest is None or managed.get("artifact_sha256") == artifact_digest
+        ):
             print(f"NAM LV2 tag {config['tag']} is already installed and unchanged.")
             return
         backup = validate_backup_path(managed.get("backup"), destination, is_directory=True)
@@ -772,17 +809,25 @@ def deploy_namlv2(action, config, registry):
 
     with tempfile.TemporaryDirectory(prefix="rigforge-namlv2-") as temporary_dir:
         temporary = Path(temporary_dir)
-        archive_path = temporary / "namlv2.tgz"
-        download_archive(config["archive_url"], archive_path)
-        archive_digest = hashlib.sha256(archive_path.read_bytes()).hexdigest()
-        inspect_archive(archive_path, bundle_name)
-        extraction_root = temporary / "extract"
-        extraction_root.mkdir()
-        extracted_bundle = extraction_root / bundle_name
-        extracted_bundle.mkdir()
-        extract_bundle(archive_path, extracted_bundle, bundle_name)
-        if not extracted_bundle.is_dir():
-            raise RuntimeError(f"expected bundle missing after extraction: {extracted_bundle}")
+        archive_digest = None
+        if artifact_bundle is not None:
+            extracted_bundle = artifact_bundle
+        else:
+            archive_path = temporary / "namlv2.tgz"
+            download_archive(config["archive_url"], archive_path)
+            archive_digest = hashlib.sha256(archive_path.read_bytes()).hexdigest()
+            inspect_archive(archive_path, bundle_name)
+            extraction_root = temporary / "extract"
+            extraction_root.mkdir()
+            extracted_bundle = extraction_root / bundle_name
+            extracted_bundle.mkdir()
+            extract_bundle(archive_path, extracted_bundle, bundle_name)
+        if (
+            not extracted_bundle.is_dir()
+            or not (extracted_bundle / "manifest.ttl").is_file()
+            or not (extracted_bundle / "neural_amp_modeler.so").is_file()
+        ):
+            raise RuntimeError(f"expected NAM LV2 bundle missing or incomplete: {extracted_bundle}")
         destination.parent.mkdir(parents=True, exist_ok=True)
         staged_bundle = destination.with_name(destination.name + ".rigforge-new")
         previous_bundle = destination.with_name(destination.name + ".rigforge-old")
@@ -820,9 +865,15 @@ def deploy_namlv2(action, config, registry):
         "backup_sha256": backup_sha256,
         "installed_sha256": tree_sha256(destination),
     }
+    if artifact_digest is not None:
+        registry["namlv2"]["artifact_sha256"] = artifact_digest
+        registry["namlv2"]["build_provenance"] = str(artifact_root / "provenance.json")
     write_registry(registry)
     print(f"Installed NAM LV2 tag {config['tag']} at {destination}.")
-    print(f"Downloaded archive SHA-256 (identity only, no publisher checksum): {archive_digest}")
+    if artifact_digest is not None:
+        print(f"Installed built NAM LV2 artifact SHA-256: {artifact_digest}")
+    elif archive_digest is not None:
+        print(f"Downloaded archive SHA-256 (identity only, no publisher checksum): {archive_digest}")
 
 
 def systemd_quote(value):
@@ -902,7 +953,17 @@ def render_mod_ui_service(config):
     service_template = ROOT / config["service_source"]
     with state_file.open(encoding="utf-8") as stream:
         state = yaml.safe_load(stream)
-    reference_files = generate_bundle_files(state, ROOT)
+    nam_processor = state["routing"]["mod_host_chains"]["guitar"]["processors"][0]
+    nam_model_path = (
+        Path.home()
+        / config["user_files_directory"]
+        / "NAM Models"
+        / "Rigforge"
+        / Path(nam_processor["asset_path"]).name
+    )
+    reference_files = generate_bundle_files(
+        state, ROOT, nam_model_path=nam_model_path
+    )
     bundle_digest = hashlib.sha256()
     for name, content_bytes in sorted(reference_files.items()):
         bundle_digest.update(name.encode("utf-8") + b"\0" + content_bytes + b"\0")
@@ -930,6 +991,7 @@ def render_mod_ui_service(config):
         "@MOD_DATA_DIR@": systemd_quote(home / ".local" / "share" / "rigforge" / "mod-ui"),
         "@MOD_LAST_STATE@": systemd_quote(home / config["last_state_file"]),
         "@PEDALBOARDS_DIR@": systemd_quote(home / config["pedalboards_directory"]),
+        "@USER_FILES_DIR@": systemd_quote(home / config["user_files_directory"]),
         "@REFERENCE_PEDALBOARD@": systemd_quote(reference_pedalboard),
         "@HARDWARE_INPUT_PORT@": config["hardware_input_port"],
         "@HARDWARE_OUTPUT_PORT@": config["hardware_output_port"],
@@ -1325,6 +1387,109 @@ def deploy_mod_host_ports(action, config, registry):
     )
 
 
+def mod_ui_nam_model_sources(state):
+    nam = state["routing"]["mod_host_chains"]["guitar"]["processors"][0]
+    relative_paths = {nam["asset_path"], *nam.get("available_models", {}).values()}
+    sources = {}
+    for relative in sorted(relative_paths):
+        source = (ROOT / Path(*PurePosixPath(relative).parts)).resolve()
+        if not source.is_relative_to(ROOT.resolve()) or not source.is_file():
+            raise FileNotFoundError(
+                f"declared NAM model is missing or outside repository: {source}"
+            )
+        if source.name in sources and sources[source.name] != source:
+            raise RuntimeError(
+                f"declared NAM models have a filename collision: {source.name}"
+            )
+        sources[source.name] = source
+    return sources
+
+
+def manage_mod_ui_nam_models(action, config, registry, state):
+    key = "mod_ui_nam_models"
+    root = Path.home() / config["user_files_directory"] / "NAM Models" / "Rigforge"
+    managed = registry.get(key)
+
+    if action == "uninstall":
+        if managed is None:
+            return
+        if managed.get("directory") != str(root):
+            raise RuntimeError("managed mod-ui NAM model directory changed")
+        recorded = managed.get("files")
+        if not isinstance(recorded, dict):
+            raise RuntimeError("managed mod-ui NAM model registry is invalid")
+        for name, digest in recorded.items():
+            destination = root / name
+            validate_user_destination(destination)
+            if destination.is_symlink():
+                raise RuntimeError(f"managed NAM model became a symlink: {destination}")
+            if destination.exists() and (
+                not destination.is_file() or file_sha256(destination) != digest
+            ):
+                raise RuntimeError(
+                    f"managed NAM model changed locally; refusing to remove: {destination}"
+                )
+        for name in recorded:
+            (root / name).unlink(missing_ok=True)
+        try:
+            root.rmdir()
+        except OSError:
+            pass
+        registry.pop(key)
+        write_registry(registry)
+        return
+
+    if action != "install":
+        return
+
+    sources = mod_ui_nam_model_sources(state)
+    if managed is None:
+        recorded = {}
+    else:
+        if managed.get("directory") != str(root):
+            raise RuntimeError("managed mod-ui NAM model directory changed")
+        recorded = managed.get("files")
+        if not isinstance(recorded, dict):
+            raise RuntimeError("managed mod-ui NAM model registry is invalid")
+
+    if set(recorded) - set(sources):
+        raise RuntimeError("managed mod-ui NAM model set changed; uninstall mod-ui first")
+
+    root.mkdir(parents=True, exist_ok=True)
+    plan = []
+    for name, source in sources.items():
+        destination = root / name
+        validate_user_destination(destination)
+        if destination.is_symlink():
+            raise RuntimeError(
+                f"refusing to replace symlink in mod-ui NAM directory: {destination}"
+            )
+        expected_digest = file_sha256(source)
+        current_digest = file_sha256(destination)
+        prior_digest = recorded.get(name)
+        if prior_digest is not None:
+            if current_digest != prior_digest:
+                raise RuntimeError(
+                    f"managed NAM model changed locally; refusing overwrite: {destination}"
+                )
+            plan.append((name, source, destination, expected_digest, current_digest != expected_digest))
+        elif current_digest is None:
+            plan.append((name, source, destination, expected_digest, True))
+        elif current_digest != expected_digest:
+            raise RuntimeError(
+                f"unmanaged file conflicts with declared NAM model: {destination}"
+            )
+
+    installed = dict(recorded)
+    for name, source, destination, expected_digest, needs_install in plan:
+        if needs_install:
+            atomic_install(source, destination)
+        installed[name] = expected_digest
+
+    registry[key] = {"directory": str(root), "files": installed}
+    write_registry(registry)
+
+
 def deploy_mod_ui(action, config, registry):
     if action == "install":
         if "mod_host_ports" not in registry:
@@ -1351,6 +1516,11 @@ def deploy_mod_ui(action, config, registry):
         return
     if action == "uninstall" and "midi_bridge" in registry:
         raise RuntimeError("uninstall midi-bridge before uninstalling mod-ui")
+    state = yaml.safe_load(
+        (ROOT / "config" / "desired-state.yaml").read_text(encoding="utf-8")
+    )
+    if action == "install":
+        manage_mod_ui_nam_models("install", config, registry, state)
     unit = render_mod_ui_service(config)
     reference_sha256 = None
     if action != "uninstall":
@@ -1363,6 +1533,8 @@ def deploy_mod_ui(action, config, registry):
         unit,
         registry,
     )
+    if action == "uninstall":
+        manage_mod_ui_nam_models("uninstall", config, registry, state)
     if action == "install":
         registry["mod_ui"]["reference_bundle"] = {
             "destination": str(unit["reference_bundle"]),

+ 5 - 2
scripts/generate_mod_ui_pedalboard.py

@@ -31,7 +31,7 @@ def resolved_asset(repo_root, relative):
     return path
 
 
-def generate_bundle_files(state, repo_root=ROOT, asset_root=None):
+def generate_bundle_files(state, repo_root=ROOT, asset_root=None, nam_model_path=None):
     errors = validate_state(state)
     if errors:
         raise ValueError("invalid desired state: " + "; ".join(errors))
@@ -40,7 +40,10 @@ def generate_bundle_files(state, repo_root=ROOT, asset_root=None):
     asset_root = Path(asset_root or repo_root / "artifacts" / "mod-ui" / "arm64" / "current" / "app" / "default.pedalboard")
     routing = state["routing"]["mod_host_chains"]["guitar"]
     nam, ir = routing["processors"]
-    nam_path = resolved_asset(repo_root, nam["asset_path"])
+    nam_source_path = resolved_asset(repo_root, nam["asset_path"])
+    nam_path = Path(nam_model_path).resolve() if nam_model_path else nam_source_path
+    if not nam_path.is_file():
+        raise FileNotFoundError(f"NAM model file is missing: {nam_path}")
     ir_path = resolved_asset(repo_root, ir["asset_path"])
     output_level = nam["parameters"]["output_level"]
 

+ 13 - 0
scripts/validate_desired_state.py

@@ -422,6 +422,10 @@ def validate_state(state):
         if not isinstance(namlv2, dict):
             errors.append("deployment.namlv2 must be a mapping")
         else:
+            if namlv2.get("source_url") != "https://github.com/mikeoliphant/neural-amp-modeler-lv2":
+                errors.append(
+                    "deployment.namlv2.source_url must match the approved GitHub repository"
+                )
             tag = namlv2.get("tag")
             allowed_tag_characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._-"
             if not isinstance(tag, str) or not tag or any(
@@ -437,6 +441,14 @@ def validate_state(state):
                 errors.append("deployment.namlv2.archive_url must match its tag and approved RPi 5 release asset")
             if namlv2.get("bundle_directory") != "neural_amp_modeler.lv2":
                 errors.append("deployment.namlv2.bundle_directory must be neural_amp_modeler.lv2")
+            if namlv2.get("artifact_directory") != "artifacts/nam-lv2/arm64/current":
+                errors.append(
+                    "deployment.namlv2.artifact_directory must be artifacts/nam-lv2/arm64/current"
+                )
+            if namlv2.get("artifact_directory") != "artifacts/nam-lv2/arm64/current":
+                errors.append(
+                    "deployment.namlv2.artifact_directory must be artifacts/nam-lv2/arm64/current"
+                )
 
         sooperlooper = deployment.get("sooperlooper")
         if not isinstance(sooperlooper, dict):
@@ -581,6 +593,7 @@ def validate_state(state):
                 ("websocket_host", "127.0.0.1"),
                 ("reference_directory", ".local/share/rigforge/mod-ui/references"),
                 ("pedalboards_directory", ".local/share/rigforge/mod-ui/pedalboards"),
+                ("user_files_directory", ".local/share/rigforge/mod-ui/user-files"),
                 ("last_state_file", ".local/share/rigforge/mod-ui/last-rigforge.json"),
                 ("hardware_input_port", "rigforge.mod-host-input.capture:capture_AUX0"),
                 ("hardware_output_port", "rigforge.mod-host-output.playback:playback_AUX0"),

+ 85 - 2
tests/test_deploy.py

@@ -125,7 +125,10 @@ class DeploymentTests(unittest.TestCase):
         return deploy.load_deployment()["midi_bridge"]
 
     def make_archive(self, destination, files=None):
-        files = files or {"manifest.ttl": b"<urn:nam> a <urn:Plugin> .\n", "plugin.so": b"binary"}
+        files = files or {
+            "manifest.ttl": b"<urn:nam> a <urn:Plugin> .\n",
+            "neural_amp_modeler.so": b"binary",
+        }
         with tarfile.open(destination, "w:gz") as archive:
             directory = tarfile.TarInfo("neural_amp_modeler.lv2")
             directory.type = tarfile.DIRTYPE
@@ -639,11 +642,62 @@ class DeploymentTests(unittest.TestCase):
         self.assertIn("run_mod_ui_service.py", content)
         self.assertIn("MOD_DEFAULT_PEDALBOARD=", content)
         self.assertIn("MOD_RIGFORGE_CAPTURE_PORT=", content)
+        self.assertIn(
+            f'MOD_USER_FILES_DIR="{self.home / config["user_files_directory"]}"',
+            content,
+        )
         self.assertIn("rigforge.mod-host-input.capture:capture_AUX0", content)
         self.assertIn("rigforge.mod-host-output.playback:playback_AUX0", content)
         self.assertIn("Requires=rigforge-mod-host.service rigforge-mod-host-ports.service", content)
         self.assertIn("pw-jack", content)
 
+    def test_mod_ui_manages_declared_nam_models_for_local_picker(self):
+        registry = {
+            "mod_host_ports": {},
+            "mod_host": {},
+        }
+        config = deploy.load_deployment()["mod_ui"]
+        deploy.deploy_mod_ui("install", config, registry)
+
+        model_root = self.home / config["user_files_directory"] / "NAM Models" / "Rigforge"
+        state = deploy.yaml.safe_load(
+            (ROOT / "config" / "desired-state.yaml").read_text(encoding="utf-8")
+        )
+        model_names = set(deploy.mod_ui_nam_model_sources(state))
+        self.assertEqual({path.name for path in model_root.iterdir()}, model_names)
+
+        reference = Path(
+            deploy.read_registry()["mod_ui"]["reference_bundle"]["destination"]
+        )
+        ttl = (reference / "rigforge-guitar.ttl").read_text(encoding="utf-8")
+        self.assertIn(str(model_root / "Vox_AC15CH_Crunch_TB.nam"), ttl)
+
+        deploy.deploy_mod_ui("uninstall", config, deploy.read_registry())
+        self.assertFalse(model_root.exists())
+        self.assertNotIn("mod_ui_nam_models", deploy.read_registry())
+
+    def test_mod_ui_refuses_to_remove_locally_modified_nam_model(self):
+        registry = {
+            "mod_host_ports": {},
+            "mod_host": {},
+        }
+        config = deploy.load_deployment()["mod_ui"]
+        deploy.deploy_mod_ui("install", config, registry)
+        model = (
+            self.home
+            / config["user_files_directory"]
+            / "NAM Models"
+            / "Rigforge"
+            / "Vox_AC15CH_Crunch_TB.nam"
+        )
+        model.write_bytes(b"local change")
+
+        with self.assertRaisesRegex(RuntimeError, "changed locally"):
+            deploy.deploy_mod_ui("uninstall", config, deploy.read_registry())
+
+        self.assertEqual(model.read_bytes(), b"local change")
+        self.assertIn("mod_ui_nam_models", deploy.read_registry())
+
     def test_mod_ui_reference_bundle_is_immutable_after_install(self):
         config = deploy.load_deployment()["mod_ui"]
         registry = {"mod_host_ports": {}, "mod_host": {}}
@@ -860,7 +914,7 @@ Attributes = A_ -rw-r--r--
         (destination / "old.txt").write_text("prior plugin", encoding="utf-8")
         self.install_nam()
         self.assertTrue((destination / "manifest.ttl").is_file())
-        self.assertTrue((destination / "plugin.so").is_file())
+        self.assertTrue((destination / "neural_amp_modeler.so").is_file())
         registry = deploy.read_registry()
         self.assertEqual(registry["namlv2"]["tag"], "v0.2.3")
         self.assertTrue(registry["namlv2"]["archive_sha256"])
@@ -870,6 +924,35 @@ Attributes = A_ -rw-r--r--
         self.assertNotIn("manifest.ttl", {path.name for path in destination.iterdir()})
         self.assertNotIn("namlv2", deploy.read_registry())
 
+    def test_nam_install_uses_the_dynamic_runtime_build_artifact(self):
+        config = deploy.load_deployment()["namlv2"]
+        destination = self.home / ".lv2/neural_amp_modeler.lv2"
+
+        with patch.object(
+            deploy,
+            "download_archive",
+            side_effect=AssertionError("built artifact install must not download the static release"),
+        ):
+            deploy.deploy_namlv2("install", config, deploy.read_registry())
+
+        source = ROOT / config["artifact_directory"] / config["bundle_directory"]
+        self.assertEqual(deploy.tree_sha256(destination), deploy.tree_sha256(source))
+        registry = deploy.read_registry()["namlv2"]
+        self.assertEqual(registry["tag"], "v0.2.3")
+        self.assertIsNone(registry["archive_sha256"])
+        self.assertEqual(registry["artifact_sha256"], deploy.tree_sha256(source))
+
+        with patch.object(
+            deploy,
+            "download_archive",
+            side_effect=AssertionError("idempotent build artifact install must not download"),
+        ):
+            deploy.deploy_namlv2("install", config, deploy.read_registry())
+        self.assertEqual(deploy.tree_sha256(destination), deploy.tree_sha256(source))
+        deploy.deploy_namlv2("uninstall", config, deploy.read_registry())
+        self.assertFalse(destination.exists())
+        self.assertNotIn("namlv2", deploy.read_registry())
+
     def test_nam_pending_uninstall_recovers_after_bundle_removal(self):
         destination = self.home / ".lv2/neural_amp_modeler.lv2"
         destination.mkdir(parents=True)