Browse Source

arm builder for sooperlooper et mod-host

Johan Le Baut 2 weeks ago
parent
commit
479aca126f

+ 5 - 0
.dockerignore

@@ -0,0 +1,5 @@
+.git
+.crush
+artifacts
+__pycache__
+*.py[cod]

+ 20 - 10
README.md

@@ -31,12 +31,12 @@ This records the preparation already performed on `rigforge` and is a starting p
 - `config/desired-state.yaml`: versioned desired audio topology and provisional target mapping.
 - `config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf`: tested filter-chain node configuration for the four-input mono direct mixer.
 - `config/sooperlooper/fcb1010.slb`: supplied FCB1010 binding file, pending on-target verification.
-- `build/sooperlooper/`: reserved for the later ARM64 Docker build definition.
+- `build/arm64/`: shared ARM64 build image and task scripts for SooperLooper and mod-host.
 - `scripts/validate_desired_state.py`: validates topology and routing invariants without changing the target.
 - `scripts/observe_pipewire.py`: read-only comparison by default, with explicit one-shot repair for declared missing links.
 - `scripts/deploy.sh` and `scripts/deploy.py`: scoped user-level installation, removal, and reload of declared PipeWire and NAM LV2 files.
 - `tests/`: unit tests for desired-state validation, PipeWire observation/reconciliation, and deployment operations.
-- `artifacts/sooperlooper/arm64/`: reserved for an artifact and its provenance, subject to repository hosting limits and redistribution terms.
+- `artifacts/sooperlooper/arm64/` and `artifacts/mod-host/arm64/`: generated binaries, runtime dependency reports, and build provenance; commit after reviewing licensing and repository size.
 
 The YAML describes desired state; a control surface is not a second source of truth. The initial audio profile declares 48 kHz and a quantum of 128 frames, which was reported to sound good during a temporary target test. At 48 kHz, 128 frames is about 2.7 ms per period, not the end-to-end latency. This runtime value has not yet been made persistent or measured under sustained load; apply it temporarily on the target with `pw-metadata -n settings 0 clock.force-quantum 128` and return to automatic selection with `pw-metadata -n settings 0 clock.force-quantum 0`. Concrete PipeWire ports, buffer settings, package names, services, and artifact installation path will only be recorded as verified after target tests.
 
@@ -65,7 +65,7 @@ python3 scripts/observe_pipewire.py --reconcile-once
 
 This mode never removes links, changes undeclared connections, or restarts services. It makes one attempt per missing managed link, then re-reads the graph and reports remaining differences. Use it only during a safe test window: a repaired link can immediately make audio audible. Do not disconnect a working link just to test repair during live use. If all desired links are already present, this mode is a no-op. Unit tests use simulated `pw-link` results.
 
-On 2026-11-18, the target owner deliberately removed the managed AUX2 capture-to-mixer link during a safe test. Observation reported that single link as missing. After updating `rigforge` to commit `83fb0a7`, `--reconcile-once` requested the link, and the final check reported `differences: []`. A subsequent read-only observation also reported no differences, the microphone was confirmed audible again, and all 20 unit tests passed on the target. This verifies one-shot repair for a managed link on the current target; it does not validate continuous reconciliation, service restarts, or recovery from missing ports.
+On 2026-11-18, the target owner deliberately removed the managed AUX2 capture-to-mixer link during a safe test. Observation reported that single link as missing. After updating `rigforge` to commit `83fb0a7`, `--reconcile-once` requested the link, and the final check reported `differences: []`. A subsequent read-only observation also reported no differences, the microphone was confirmed audible again, and all 20 unit tests passed on the target. In a later target test, restarting `filter-chain.service` removed all three managed links; explicit `--reconcile-once` requested all three, and the final observer again reported `differences: []`. Audio audibility after this later repair was not reported. These tests verify one-shot repair on the current target, not continuous reconciliation or recovery when ports are unavailable. After any filter-chain service restart, run the read-only observer and, during a safe test window, explicitly reconcile if links are missing.
 
 ## Candidate direct mix test
 
@@ -111,25 +111,35 @@ After a manual `git pull --ff-only`, run the deploy helper from any directory:
 
 The helper accepts `install|uninstall|reload` and `all|namlv2|pipewire`. It reads versions, paths, URL, and quantum from `config/desired-state.yaml`; its deployment registry is stored under `~/.local/state/rigforge/`, and any pre-existing target backup is stored next to that target. It does not use `sudo` or change files outside the declared paths, adjacent backup paths, and registry directory.
 
-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. 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 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. The deploy helper deliberately does not reconcile links automatically. After a restart, first run `python3 scripts/observe_pipewire.py`; if declared links are missing, use `python3 scripts/observe_pipewire.py --reconcile-once` only during an appropriate safe test window, then observe again. 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` intentionally does nothing because no LV2 host is declared; restart the eventual host after installing or removing the plugin. The supplied release asset has not yet been installed or tested on the target, and runtime dependencies and compatibility remain to be confirmed there. The release archive is fetched at install time and is not committed to this repository.
+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` intentionally does nothing because no LV2 host is declared; restart the eventual 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`. `reload namlv2` printed the expected no-op message. The downloaded archive SHA-256 was `80d1a711d573afb7323cbf2ea1a79e39386e58ba449d076c5d89e10b50de3212`; this is an identity hash only, not a publisher checksum. Host discovery, runtime dependencies, compatibility, and plugin operation remain unverified. The release archive is fetched at install time and is not committed to this repository.
 
-`install all` and `uninstall all` attempt both targets and report an overall failure if either action fails. `reload all` restarts the filter-chain service and prints the NAM no-op message. Check the target afterwards with `python3 scripts/validate_desired_state.py`, `python3 -m unittest discover -s tests -v`, and `python3 scripts/observe_pipewire.py`.
+On the target, `install pipewire` applied quantum 128 and reported that the installed fragment was already current; the following observer reported no differences. A later `reload pipewire` applied the quantum and restarted the filter-chain service, after which observation found all three managed links missing. One-shot reconciliation requested each link, and the subsequent observer reported `differences: []`. This confirms the graph links were present after reconciliation, not that audio was audible. `install all` and `uninstall all` attempt both targets and report an overall failure if either action fails. `reload all` restarts the filter-chain service and prints the NAM no-op message. Check the target afterwards with `python3 scripts/validate_desired_state.py`, `python3 -m unittest discover -s tests -v`, and `python3 scripts/observe_pipewire.py`.
 
 ## Development PC
 
-The development host is Ubuntu AMD64 with Docker. The SooperLooper source under evaluation is <https://github.com/abarker/sooperlooper-mods>. The Docker build procedure is intentionally not yet provided: first select a tag and inspect that tag's build instructions and licensing. The eventual build command must take an explicit tag, resolve and record its exact commit, build for ARM64, and record artifact architecture, runtime dependencies, provenance, and checksum. The container is for building only; SooperLooper will run natively on the Raspberry Pi.
+The development host can be Ubuntu AMD64 or WSL2 with Docker Buildx and ARM64 emulation available. The shared image under `build/arm64/` uses Debian 13 ARM64 tools. Source URLs and tags are declared in `config/desired-state.yaml` and validated before either build. SooperLooper uses `v1.7.9-mods.1`, resolving to `946b92e342bfb31c731671463995d31daf79fc0e`; mod-host uses `v1.15.0.3371`, resolving to `956e13e538a440a6ee87fd350e6b510ec5e7a1b6`.
 
-No SooperLooper artifact or Dockerfile is included at this stage.
+Build the common image once from the rigforge repository root, then select a build task:
+
+```sh
+docker buildx build --platform linux/arm64 --load -f build/arm64/Dockerfile -t rigforge-arm64-build:debian13 .
+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
+```
+
+Use task `all` to build both programs in sequence. The shared image contains the union of their compiler dependencies; each task retrieves the source tag from YAML, records the resolved commit, builds only its target, checks runtime dependencies, hashes the binary, and writes its executable, `runtime-dependencies.txt`, and `provenance.json` under `artifacts/<project>/arm64/current/`. 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` or `deployment.mod_host.tag`, validate the YAML, then rerun the 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.
 
 ## `rigforge` target
 
-The filter-chain fragment is installed in the user configuration on `rigforge`, and `filter-chain.service` was restarted to load it. The user confirmed guitar and microphone are audible together through the filter. Three manual links are currently active and declared in `routing.managed_links` for observation only. This is an initial listening check, not a sustained load, dropout, four-instrument, or headroom test.
+The filter-chain fragment is installed in the user configuration on `rigforge`, and `filter-chain.service` was restarted to load it. The user confirmed guitar and microphone are audible together through the filter. Three managed links are currently present after explicit one-shot reconciliation; they remain declared in `routing.managed_links` for observation. This is an initial listening check, not a sustained load, dropout, four-instrument, or headroom test.
 
 The next target checks are:
 
-1. The read-only observer and one-shot repair have been tested on `rigforge`; all three declared links were present afterward and the repaired microphone path was audible.
+1. The read-only observer and one-shot repair have been tested on `rigforge`. Repairing one missing link restored the audible microphone path; after a later filter-chain service restart, reconciliation requested all three missing links and the observer reported no differences. Audibility after that later repair remains unconfirmed.
 2. Later, test inputs 2 and 4 with sources when available; they are included in the mixer but not verified 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. Inspect the user service session and resource limits before defining autonomous startup. `Linger=no` currently means the running audio session is associated with the active login; unattended startup is not established.

BIN
artifacts/mod-host/arm64/current/mod-host


+ 8 - 0
artifacts/mod-host/arm64/current/provenance.json

@@ -0,0 +1,8 @@
+{
+  "source_url": "https://github.com/mod-audio/mod-host",
+  "tag": "v1.15.0.3371",
+  "commit": "956e13e538a440a6ee87fd350e6b510ec5e7a1b6",
+  "platform": "linux/arm64",
+  "artifact": "mod-host",
+  "sha256": "f60c93e45fe2bd69f2bd87dc90f59df679564e98724edb30e8d819b96e0b0249"
+}

+ 19 - 0
artifacts/mod-host/arm64/current/runtime-dependencies.txt

@@ -0,0 +1,19 @@
+	linux-vdso.so.1 (0x00007b535b9d7000)
+	liblilv-0.so.0 => /lib/aarch64-linux-gnu/liblilv-0.so.0 (0x00007b535a850000)
+	libjack.so.0 => /lib/aarch64-linux-gnu/libjack.so.0 (0x00007b535a7d0000)
+	libfftw3_threads.so.3 => /lib/aarch64-linux-gnu/libfftw3_threads.so.3 (0x00007b535a7a0000)
+	libfftw3f_threads.so.3 => /lib/aarch64-linux-gnu/libfftw3f_threads.so.3 (0x00007b535a770000)
+	libfftw3.so.3 => /lib/aarch64-linux-gnu/libfftw3.so.3 (0x00007b535a690000)
+	libfftw3f.so.3 => /lib/aarch64-linux-gnu/libfftw3f.so.3 (0x00007b535a540000)
+	libreadline.so.8 => /lib/aarch64-linux-gnu/libreadline.so.8 (0x00007b535a4c0000)
+	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x00007b535a410000)
+	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x00007b535a250000)
+	libserd-0.so.0 => /lib/aarch64-linux-gnu/libserd-0.so.0 (0x00007b535a210000)
+	libsord-0.so.0 => /lib/aarch64-linux-gnu/libsord-0.so.0 (0x00007b535a1e0000)
+	libsratom-0.so.0 => /lib/aarch64-linux-gnu/libsratom-0.so.0 (0x00007b535a1b0000)
+	libzix-0.so.0 => /lib/aarch64-linux-gnu/libzix-0.so.0 (0x00007b535a180000)
+	/lib/ld-linux-aarch64.so.1 (0x00007b535b980000)
+	libdb-5.3.so => /lib/aarch64-linux-gnu/libdb-5.3.so (0x00007b5359fb0000)
+	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x00007b5359d40000)
+	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x00007b5359d00000)
+	libtinfo.so.6 => /lib/aarch64-linux-gnu/libtinfo.so.6 (0x00007b5359cb0000)

+ 9 - 0
artifacts/sooperlooper/arm64/current/provenance.json

@@ -0,0 +1,9 @@
+{
+  "source_url": "https://github.com/abarker/sooperlooper-mods",
+  "tag": "v1.7.9-mods.1",
+  "commit": "946b92e342bfb31c731671463995d31daf79fc0e",
+  "platform": "linux/arm64",
+  "artifact": "sooperlooper",
+  "sha256": "129dda9ada2969df9eb9371638293987553bb4f26bd26f251d746f81a4d1f3db",
+  "local_patches": ["GCC AArch64 atomic operations in libs/pbd/pbd/atomic.h and src/atomic.h"]
+}

+ 25 - 0
artifacts/sooperlooper/arm64/current/runtime-dependencies.txt

@@ -0,0 +1,25 @@
+	linux-vdso.so.1 (0x000071c8457a8000)
+	libjack.so.0 => /lib/aarch64-linux-gnu/libjack.so.0 (0x000071c844e20000)
+	liblo.so.7 => /lib/aarch64-linux-gnu/liblo.so.7 (0x000071c844de0000)
+	libsigc-2.0.so.0 => /lib/aarch64-linux-gnu/libsigc-2.0.so.0 (0x000071c844db0000)
+	librubberband.so.2 => /lib/aarch64-linux-gnu/librubberband.so.2 (0x000071c844d30000)
+	libsamplerate.so.0 => /lib/aarch64-linux-gnu/libsamplerate.so.0 (0x000071c844ba0000)
+	libsndfile.so.1 => /lib/aarch64-linux-gnu/libsndfile.so.1 (0x000071c844af0000)
+	libasound.so.2 => /lib/aarch64-linux-gnu/libasound.so.2 (0x000071c8449b0000)
+	libxml2.so.2 => /lib/aarch64-linux-gnu/libxml2.so.2 (0x000071c8447e0000)
+	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x000071c844570000)
+	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x000071c8444c0000)
+	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x000071c844480000)
+	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x000071c8442c0000)
+	libdb-5.3.so => /lib/aarch64-linux-gnu/libdb-5.3.so (0x000071c8440f0000)
+	/lib/ld-linux-aarch64.so.1 (0x000071c845750000)
+	libfftw3.so.3 => /lib/aarch64-linux-gnu/libfftw3.so.3 (0x000071c844010000)
+	libFLAC.so.14 => /lib/aarch64-linux-gnu/libFLAC.so.14 (0x000071c843f90000)
+	libvorbis.so.0 => /lib/aarch64-linux-gnu/libvorbis.so.0 (0x000071c843f40000)
+	libvorbisenc.so.2 => /lib/aarch64-linux-gnu/libvorbisenc.so.2 (0x000071c843e80000)
+	libopus.so.0 => /lib/aarch64-linux-gnu/libopus.so.0 (0x000071c843b10000)
+	libogg.so.0 => /lib/aarch64-linux-gnu/libogg.so.0 (0x000071c843ae0000)
+	libmpg123.so.0 => /lib/aarch64-linux-gnu/libmpg123.so.0 (0x000071c843a70000)
+	libmp3lame.so.0 => /lib/aarch64-linux-gnu/libmp3lame.so.0 (0x000071c8439e0000)
+	libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x000071c8439a0000)
+	liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x000071c843950000)

BIN
artifacts/sooperlooper/arm64/current/sooperlooper


+ 36 - 0
build/arm64/Dockerfile

@@ -0,0 +1,36 @@
+FROM debian:13-slim
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+    autoconf \
+    automake \
+    autopoint \
+    build-essential \
+    ca-certificates \
+    gettext \
+    git \
+    libasound2-dev \
+    libfftw3-dev \
+    libjack-jackd2-dev \
+    liblilv-dev \
+    liblo-dev \
+    libncurses-dev \
+    libreadline-dev \
+    librubberband-dev \
+    libsamplerate0-dev \
+    libsigc++-2.0-dev \
+    libsndfile1-dev \
+    libtool \
+    libtool-bin \
+    libxml2-dev \
+    pkg-config \
+    python3-yaml \
+    && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /opt/rigforge
+COPY scripts/validate_desired_state.py /opt/rigforge/scripts/validate_desired_state.py
+COPY build/arm64/ /opt/rigforge/build/arm64/
+RUN chmod 0755 /opt/rigforge/build/arm64/*.sh
+
+ENTRYPOINT ["/opt/rigforge/build/arm64/entrypoint.sh"]

+ 109 - 0
build/arm64/build-mod-host.sh

@@ -0,0 +1,109 @@
+#!/bin/sh
+set -eu
+
+repository_root=${RIGFORGE_ROOT:-/workspace}
+state_file="$repository_root/config/desired-state.yaml"
+artifact_directory="$repository_root/artifacts/mod-host/arm64"
+work_directory=
+temporary_directory=
+previous_directory="$artifact_directory/previous"
+
+cleanup() {
+    if [ -n "$work_directory" ]; then
+        rm -rf "$work_directory"
+    fi
+    if [ -n "$temporary_directory" ]; then
+        rm -rf "$temporary_directory"
+    fi
+    if [ ! -e "$artifact_directory/current" ] && [ -e "$previous_directory" ]; then
+        mv "$previous_directory" "$artifact_directory/current"
+    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
+
+state_path = Path(sys.argv[2])
+with state_path.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:
+    source = yaml.safe_load(stream)["deployment"]["mod_host"]
+print(source["source_url"])
+print(source["tag"])
+PY
+)
+source_url=$1
+tag=$2
+
+mkdir -p "$artifact_directory"
+work_directory=$(mktemp -d /tmp/mod-host-build.XXXXXX)
+temporary_directory=$(mktemp -d "$artifact_directory/.build.XXXXXX")
+git clone --no-checkout "$source_url" "$work_directory/source"
+git -C "$work_directory/source" checkout --detach "refs/tags/$tag"
+source_commit=$(git -C "$work_directory/source" rev-parse HEAD)
+
+cd "$work_directory/source"
+make -j"$(nproc)"
+
+install -m 0755 mod-host "$temporary_directory/mod-host"
+ldd "$temporary_directory/mod-host" > "$temporary_directory/runtime-dependencies.txt"
+if grep -F 'not found' "$temporary_directory/runtime-dependencies.txt"; then
+    printf '%s\n' "Unresolved runtime dependencies in the compiled executable." >&2
+    exit 1
+fi
+
+binary_sha256=$(sha256sum "$temporary_directory/mod-host" | cut -d ' ' -f 1)
+cat > "$temporary_directory/provenance.json" <<EOF
+{
+  "source_url": "$source_url",
+  "tag": "$tag",
+  "commit": "$source_commit",
+  "platform": "linux/arm64",
+  "artifact": "mod-host",
+  "sha256": "$binary_sha256"
+}
+EOF
+
+chmod 0755 "$temporary_directory"
+chmod 0644 "$temporary_directory/provenance.json" "$temporary_directory/runtime-dependencies.txt"
+if [ ! -e "$artifact_directory/current" ] && [ -e "$previous_directory" ]; then
+    mv "$previous_directory" "$artifact_directory/current"
+fi
+if [ -e "$previous_directory" ]; then
+    rm -rf "$previous_directory"
+fi
+if [ -e "$artifact_directory/current" ]; then
+    mv "$artifact_directory/current" "$previous_directory"
+fi
+mv "$temporary_directory" "$artifact_directory/current"
+temporary_directory=
+rm -rf "$previous_directory"
+printf 'Built %s at %s\n' "$tag" "$source_commit"
+printf 'Artifact: %s/current/mod-host\n' "$artifact_directory"
+printf 'SHA-256: %s\n' "$binary_sha256"

+ 163 - 0
build/arm64/build-sooperlooper.sh

@@ -0,0 +1,163 @@
+#!/bin/sh
+set -eu
+
+repository_root=${RIGFORGE_ROOT:-/workspace}
+state_file="$repository_root/config/desired-state.yaml"
+artifact_directory="$repository_root/artifacts/sooperlooper/arm64"
+work_directory=
+temporary_directory=
+previous_directory="$artifact_directory/previous"
+
+cleanup() {
+    if [ -n "$work_directory" ]; then
+        rm -rf "$work_directory"
+    fi
+    if [ -n "$temporary_directory" ]; then
+        rm -rf "$temporary_directory"
+    fi
+    if [ ! -e "$artifact_directory/current" ] && [ -e "$previous_directory" ]; then
+        mv "$previous_directory" "$artifact_directory/current"
+    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
+
+state_path = Path(sys.argv[2])
+with state_path.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:
+    source = yaml.safe_load(stream)["deployment"]["sooperlooper"]
+print(source["source_url"])
+print(source["tag"])
+PY
+)
+source_url=$1
+tag=$2
+
+mkdir -p "$artifact_directory"
+work_directory=$(mktemp -d /tmp/sooperlooper-build.XXXXXX)
+temporary_directory=$(mktemp -d "$artifact_directory/.build.XXXXXX")
+git clone --no-checkout "$source_url" "$work_directory/source"
+git -C "$work_directory/source" checkout --detach "refs/tags/$tag"
+source_commit=$(git -C "$work_directory/source" rev-parse HEAD)
+
+cd "$work_directory/source"
+./autogen.sh
+./configure --without-gui --prefix=/usr
+
+python3 - "$work_directory/source/libs/pbd/pbd/atomic.h" "$work_directory/source/src/atomic.h" <<'PY'
+import sys
+from pathlib import Path
+
+replacement = '''#if defined(__aarch64__)
+
+typedef struct { volatile int counter; } atomic_t;
+#define ATOMIC_INIT(i) { (i) }
+#define atomic_read(v) __atomic_load_n(&(v)->counter, __ATOMIC_SEQ_CST)
+#define atomic_set(v, i) __atomic_store_n(&(v)->counter, (i), __ATOMIC_SEQ_CST)
+static __inline__ void atomic_add(int i, atomic_t *v) { __atomic_add_fetch(&v->counter, i, __ATOMIC_SEQ_CST); }
+static __inline__ int atomic_add_return(int i, atomic_t *v) { return __atomic_add_fetch(&v->counter, i, __ATOMIC_SEQ_CST); }
+static __inline__ int atomic_add_negative(int i, atomic_t *v) { return __atomic_add_fetch(&v->counter, i, __ATOMIC_SEQ_CST) < 0; }
+static __inline__ void atomic_sub(int i, atomic_t *v) { __atomic_sub_fetch(&v->counter, i, __ATOMIC_SEQ_CST); }
+static __inline__ int atomic_sub_return(int i, atomic_t *v) { return __atomic_sub_fetch(&v->counter, i, __ATOMIC_SEQ_CST); }
+static __inline__ void atomic_inc(atomic_t *v) { __atomic_add_fetch(&v->counter, 1, __ATOMIC_SEQ_CST); }
+static __inline__ int atomic_inc_return(atomic_t *v) { return __atomic_add_fetch(&v->counter, 1, __ATOMIC_SEQ_CST); }
+static __inline__ int atomic_inc_and_test(atomic_t *v) { return __atomic_add_fetch(&v->counter, 1, __ATOMIC_SEQ_CST) == 0; }
+static __inline__ void atomic_dec(atomic_t *v) { __atomic_sub_fetch(&v->counter, 1, __ATOMIC_SEQ_CST); }
+static __inline__ int atomic_dec_return(atomic_t *v) { return __atomic_sub_fetch(&v->counter, 1, __ATOMIC_SEQ_CST); }
+static __inline__ int atomic_dec_and_test(atomic_t *v) { return __atomic_sub_fetch(&v->counter, 1, __ATOMIC_SEQ_CST) == 0; }
+static __inline__ int atomic_dec_if_positive(atomic_t *v) {
+    int current = atomic_read(v);
+    for (;;) {
+        int decremented = current - 1;
+        if (decremented < 0) return decremented;
+        if (__atomic_compare_exchange_n(&v->counter, &current, decremented, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return decremented;
+    }
+}
+static __inline__ int atomic_sub_and_test(int i, atomic_t *v) { return __atomic_sub_fetch(&v->counter, i, __ATOMIC_SEQ_CST) == 0; }
+static __inline__ void atomic_clear_mask(unsigned long mask, unsigned long *addr) { __atomic_fetch_and(addr, ~mask, __ATOMIC_SEQ_CST); }
+static __inline__ void atomic_set_mask(unsigned long mask, unsigned long *addr) { __atomic_fetch_or(addr, mask, __ATOMIC_SEQ_CST); }
+#define smp_mb__before_atomic_dec() __atomic_thread_fence(__ATOMIC_SEQ_CST)
+#define smp_mb__after_atomic_dec() __atomic_thread_fence(__ATOMIC_SEQ_CST)
+#define smp_mb__before_atomic_inc() __atomic_thread_fence(__ATOMIC_SEQ_CST)
+#define smp_mb__after_atomic_inc() __atomic_thread_fence(__ATOMIC_SEQ_CST)
+
+#elif defined(__powerpc__) || defined(__ppc__)
+'''
+
+for filename in sys.argv[1:]:
+    path = Path(filename)
+    text = path.read_text(encoding="utf-8")
+    needle = "#if defined(__powerpc__) || defined(__ppc__)\n"
+    if text.count(needle) != 1:
+        raise SystemExit(f"Expected one PowerPC atomic implementation guard in {path}")
+    path.write_text(text.replace(needle, replacement, 1), encoding="utf-8")
+PY
+
+make -C libs -j"$(nproc)"
+make -C src -j"$(nproc)" sooperlooper
+
+install -m 0755 src/sooperlooper "$temporary_directory/sooperlooper"
+ldd "$temporary_directory/sooperlooper" > "$temporary_directory/runtime-dependencies.txt"
+if grep -F 'not found' "$temporary_directory/runtime-dependencies.txt"; then
+    printf '%s\n' "Unresolved runtime dependencies in the compiled executable." >&2
+    exit 1
+fi
+
+binary_sha256=$(sha256sum "$temporary_directory/sooperlooper" | cut -d ' ' -f 1)
+cat > "$temporary_directory/provenance.json" <<EOF
+{
+  "source_url": "$source_url",
+  "tag": "$tag",
+  "commit": "$source_commit",
+  "platform": "linux/arm64",
+  "artifact": "sooperlooper",
+  "sha256": "$binary_sha256",
+  "local_patches": ["GCC AArch64 atomic operations in libs/pbd/pbd/atomic.h and src/atomic.h"]
+}
+EOF
+
+chmod 0755 "$temporary_directory"
+chmod 0644 "$temporary_directory/provenance.json" "$temporary_directory/runtime-dependencies.txt"
+if [ ! -e "$artifact_directory/current" ] && [ -e "$previous_directory" ]; then
+    mv "$previous_directory" "$artifact_directory/current"
+fi
+if [ -e "$previous_directory" ]; then
+    rm -rf "$previous_directory"
+fi
+if [ -e "$artifact_directory/current" ]; then
+    mv "$artifact_directory/current" "$previous_directory"
+fi
+mv "$temporary_directory" "$artifact_directory/current"
+temporary_directory=
+rm -rf "$previous_directory"
+printf 'Built %s at %s\n' "$tag" "$source_commit"
+printf 'Artifact: %s/current/sooperlooper\n' "$artifact_directory"
+printf 'SHA-256: %s\n' "$binary_sha256"

+ 22 - 0
build/arm64/entrypoint.sh

@@ -0,0 +1,22 @@
+#!/bin/sh
+set -eu
+
+case "${1:-}" in
+    sooperlooper)
+        shift
+        exec /opt/rigforge/build/arm64/build-sooperlooper.sh "$@"
+        ;;
+    mod-host)
+        shift
+        exec /opt/rigforge/build/arm64/build-mod-host.sh "$@"
+        ;;
+    all)
+        shift
+        /opt/rigforge/build/arm64/build-sooperlooper.sh "$@"
+        exec /opt/rigforge/build/arm64/build-mod-host.sh "$@"
+        ;;
+    *)
+        printf '%s\n' "Usage: docker run ... rigforge-arm64-build:{tag} sooperlooper|mod-host|all" >&2
+        exit 2
+        ;;
+esac

+ 6 - 0
config/desired-state.yaml

@@ -38,6 +38,12 @@ deployment:
     tag: v0.2.3
     archive_url: https://github.com/mikeoliphant/neural-amp-modeler-lv2/releases/download/v0.2.3/neural_amp_modeler_lv2_rpi5.tgz
     bundle_directory: neural_amp_modeler.lv2
+  sooperlooper:
+    source_url: https://github.com/abarker/sooperlooper-mods
+    tag: v1.7.9-mods.1
+  mod_host:
+    source_url: https://github.com/mod-audio/mod-host
+    tag: v1.15.0.3371
   pipewire:
     fragment_source: config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf
     fragment_destination: .config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf

+ 2 - 2
config/pipewire/filter-chain.conf.d/README.md

@@ -45,6 +45,6 @@ The fragment added nodes visible in the graph inspected by `pw-link` on the targ
 
 ## Links and operational status
 
-This file creates a filter graph; it does not create the project's audio links. Test links may be made manually with `pw-link` after the actual ports have been observed. A future Rigforge reconciler may manage explicitly declared links. Neither `pw-link` nor automatic reconciliation is invoked by this fragment.
+This file creates a filter graph; it does not create the project's audio links. The links can be made manually with `pw-link` after the actual ports have been observed. `scripts/observe_pipewire.py` compares declared links read-only by default; its explicit `--reconcile-once` mode can request only declared missing links after checking that both ports exist. Neither `pw-link` nor reconciliation is invoked by this fragment. Restarting `filter-chain.service` removes its nodes and their graph links, so inspect the graph after a restart and reconcile only when appropriate during a safe test window.
 
-The fragment has passed an initial listening test with guitar and microphone. The three test links are declared in the desired-state YAML for read-only observation. The test is not a sustained load, dropout, summed-headroom, four-instrument, or looper test. Keep the gains conservative and verify the exact live graph before any future reconciliation is allowed to modify links. See the root `README.md` for the target test record and rollback notes.
+The fragment has passed an initial listening test with guitar and microphone. The three links are declared in the desired-state YAML for read-only observation. The test is not a sustained load, dropout, summed-headroom, four-instrument, or looper test. Keep the gains conservative and verify the exact live graph before explicitly reconciling links. See the root `README.md` for the target test record and rollback notes.

BIN
scripts/__pycache__/validate_desired_state.cpython-310.pyc


+ 26 - 0
scripts/validate_desired_state.py

@@ -174,6 +174,32 @@ def validate_state(state):
             if namlv2.get("bundle_directory") != "neural_amp_modeler.lv2":
                 errors.append("deployment.namlv2.bundle_directory must be neural_amp_modeler.lv2")
 
+        sooperlooper = deployment.get("sooperlooper")
+        if not isinstance(sooperlooper, dict):
+            errors.append("deployment.sooperlooper must be a mapping")
+        else:
+            source_url = sooperlooper.get("source_url")
+            if source_url != "https://github.com/abarker/sooperlooper-mods":
+                errors.append("deployment.sooperlooper.source_url must match the approved GitHub repository")
+            tag = sooperlooper.get("tag")
+            if not isinstance(tag, str) or not tag or any(
+                character not in allowed_tag_characters for character in tag
+            ):
+                errors.append("deployment.sooperlooper.tag must be a simple version tag")
+
+        mod_host = deployment.get("mod_host")
+        if not isinstance(mod_host, dict):
+            errors.append("deployment.mod_host must be a mapping")
+        else:
+            source_url = mod_host.get("source_url")
+            if source_url != "https://github.com/mod-audio/mod-host":
+                errors.append("deployment.mod_host.source_url must match the approved GitHub repository")
+            tag = mod_host.get("tag")
+            if not isinstance(tag, str) or not tag or any(
+                character not in allowed_tag_characters for character in tag
+            ):
+                errors.append("deployment.mod_host.tag must be a simple version tag")
+
         pipewire = deployment.get("pipewire")
         if not isinstance(pipewire, dict):
             errors.append("deployment.pipewire must be a mapping")

BIN
tests/__pycache__/test_desired_state.cpython-310.pyc


+ 24 - 0
tests/test_desired_state.py

@@ -63,6 +63,30 @@ class DesiredStateValidationTests(unittest.TestCase):
         state["deployment"]["pipewire"]["fragment_destination"] = ".config/other.conf"
         self.assertTrue(any("fragment_destination" in error for error in validate_state(state)))
 
+        state = copy.deepcopy(self.state)
+        state["deployment"]["sooperlooper"]["source_url"] = "https://example.invalid/source"
+        self.assertTrue(any("source_url must match" in error for error in validate_state(state)))
+
+        state = copy.deepcopy(self.state)
+        state["deployment"]["sooperlooper"]["tag"] = "../latest"
+        self.assertTrue(any("sooperlooper.tag must be a simple version tag" in error for error in validate_state(state)))
+
+        state = copy.deepcopy(self.state)
+        del state["deployment"]["sooperlooper"]["tag"]
+        self.assertTrue(any("sooperlooper.tag must be a simple version tag" in error for error in validate_state(state)))
+
+        state = copy.deepcopy(self.state)
+        state["deployment"]["mod_host"]["source_url"] = "https://example.invalid/source"
+        self.assertTrue(any("mod_host.source_url must match" in error for error in validate_state(state)))
+
+        state = copy.deepcopy(self.state)
+        state["deployment"]["mod_host"]["tag"] = "../latest"
+        self.assertTrue(any("mod_host.tag must be a simple version tag" in error for error in validate_state(state)))
+
+        state = copy.deepcopy(self.state)
+        del state["deployment"]["mod_host"]
+        self.assertIn("deployment.mod_host must be a mapping", validate_state(state))
+
     def test_return_exclusion_marker_is_not_an_active_connection(self):
         self.assertEqual(validate_state(self.state), [])
 

+ 44 - 0
tests/test_pipewire_observer.py

@@ -178,6 +178,50 @@ class PipeWireObserverTests(unittest.TestCase):
         self.assertEqual(result["differences"], [])
         self.assertIn(["pw-link", CAPTURE_2, MIX_INPUT_2], calls)
 
+    def test_reconcile_once_restores_all_managed_links_after_service_restart(self):
+        links = set()
+        calls = []
+
+        def render_links():
+            return "".join(f"{source}\n  |-> {destination}\n" for source, destination in sorted(links))
+
+        def runner(command, **kwargs):
+            calls.append(command)
+            if command == ["pw-link", "-l"]:
+                return SimpleNamespace(stdout=render_links())
+            if command == ["pw-link", "-o"]:
+                return SimpleNamespace(stdout=f"{CAPTURE_0}\n{CAPTURE_2}\n{MIX_OUTPUT}\n")
+            if command == ["pw-link", "-i"]:
+                return SimpleNamespace(stdout=f"{MIX_INPUT_0}\n{MIX_INPUT_2}\n{PLAYBACK_0}\n")
+            if tuple(command) in {
+                ("pw-link", CAPTURE_0, MIX_INPUT_0),
+                ("pw-link", CAPTURE_2, MIX_INPUT_2),
+                ("pw-link", MIX_OUTPUT, PLAYBACK_0),
+            }:
+                links.add((command[1], command[2]))
+                return SimpleNamespace(stdout="")
+            self.fail(f"unexpected command: {command}")
+
+        result = reconcile_once(self.state, runner)
+
+        self.assertEqual(
+            result["actions"],
+            [
+                {"kind": "link", "from": CAPTURE_0, "to": MIX_INPUT_0, "result": "requested"},
+                {"kind": "link", "from": CAPTURE_2, "to": MIX_INPUT_2, "result": "requested"},
+                {"kind": "link", "from": MIX_OUTPUT, "to": PLAYBACK_0, "result": "requested"},
+            ],
+        )
+        self.assertEqual(result["differences"], [])
+        self.assertEqual(
+            [command for command in calls if len(command) == 3 and command[0] == "pw-link"],
+            [
+                ["pw-link", CAPTURE_0, MIX_INPUT_0],
+                ["pw-link", CAPTURE_2, MIX_INPUT_2],
+                ["pw-link", MIX_OUTPUT, PLAYBACK_0],
+            ],
+        )
+
     def test_reconcile_once_does_not_link_when_endpoint_is_unavailable(self):
         state = copy.deepcopy(self.state)
         links = {(CAPTURE_0, MIX_INPUT_0), (MIX_OUTPUT, PLAYBACK_0)}