Bladeren bron

add sooperlooper service

Johan Le Baut 2 weken geleden
bovenliggende
commit
32500fb9c4

+ 20 - 2
README.md

@@ -112,11 +112,13 @@ After a manual `git pull --ff-only`, run the deploy helper from any directory:
 ~/rigforge/scripts/deploy.sh install lsp
 ~/rigforge/scripts/deploy.sh install dragonfly-reverb
 ~/rigforge/scripts/deploy.sh install mod-host
+~/rigforge/scripts/deploy.sh install sooperlooper
 ~/rigforge/scripts/deploy.sh install reconcile
+~/rigforge/scripts/deploy.sh install midi-bridge
 ~/rigforge/scripts/deploy.sh install all
 ```
 
-The helper accepts `install|uninstall|reload` and `all|namlv2|lsp|dragonfly-reverb|pipewire|mod-host|reconcile`. It reads versions, paths, URLs, 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.
+The helper accepts `install|uninstall|reload` and `all|namlv2|lsp|dragonfly-reverb|pipewire|mod-host|reconcile|midi-bridge|sooperlooper`. `all` deliberately excludes `mod-host`, `reconcile`, `midi-bridge`, and `sooperlooper`, which are opt-in services. It reads versions, paths, URLs, and settings 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. 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.
 
@@ -124,6 +126,22 @@ For NAM LV2, install downloads the declared Raspberry Pi 5 archive with `curl`,
 
 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.
 
+### SooperLooper service
+
+`install sooperlooper` installs and enables an explicit `systemd --user` service; it is excluded from `install all`. The service runs the ARM64 artifact at `artifacts/sooperlooper/arm64/current/sooperlooper` through `/usr/bin/pw-jack` and loads `config/sooperlooper/fcb1010.slb`. The `-l` and `-c` arguments are rendered from the looper component's `loop_count` and `channels_per_loop` in `config/desired-state.yaml` (currently 1 and 4); `-t` is configured by `deployment.sooperlooper.timeout_seconds` (currently 30).
+
+After startup, the unit waits four seconds and sends `/sl/0/set sf discrete_prefader 0` to `127.0.0.1:9951` with `/usr/bin/oscsend`. The delay, OSC endpoint, and `discrete_prefader` value are also declared in the desired state. This initializes the control expected by the FCB's volume bindings. It does not establish the audio links between SooperLooper, the sources, and the mixer; those routes and target behavior remain to be verified.
+
+```sh
+./scripts/deploy.sh install sooperlooper
+systemctl --user status rigforge-sooperlooper.service
+journalctl -f _SYSTEMD_USER_UNIT=rigforge-sooperlooper.service
+```
+
+Install requires the built ARM64 artifact, the tracked `.slb` file, and target runtime dependencies including `oscsend` from `liblo-tools`. The helper preserves any prior unit file and refuses to overwrite or remove locally edited managed units. It does not use `sudo` or restart PipeWire/WirePlumber. The service has not yet been installed or runtime-tested on the target.
+
+Remove the service with `./scripts/deploy.sh uninstall sooperlooper`.
+
 ### mod-host guitar chain
 
 `install mod-host` is an explicit target and is deliberately not included in `install all`: it activates the guitar processing chain. It requires the ARM64 artifact under `artifacts/mod-host/arm64/current/`, the NAM and LSP bundles already installed, the tracked `amp_emul/` assets, and the runtime packages in the target preparation list. It installs and enables only the `systemd --user` mod-host service; it does not use `sudo` or directly restart PipeWire/WirePlumber. The unit refers to the repository checkout from which `deploy.sh` was run, so keep that checkout at that path or uninstall/reinstall after moving it.
@@ -215,7 +233,7 @@ The remaining target checks are:
 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. Re-test mod-host startup after installing the new port-readiness guard, then verify reboot with lingering enabled, startup resource limits, and recovery when an LV2 plugin fails to load.
-5. The owner has manually verified FCB notes 6–9 switching the guitar NAM models through the bridge, with near-instant reported transitions. The `midi-bridge` user service is now installable locally; still install and verify unattended startup and UMC unplug/replug recovery on the target. Also verify the supplied FCB1010 bindings with the eventual SooperLooper build, OSC port readiness, and the effect and persistence of `discrete_prefader 0` separately.
+5. The owner has manually verified FCB notes 6–9 switching the guitar NAM models through the bridge, with near-instant reported transitions. The `midi-bridge` and `sooperlooper` user services are now installable locally; still install and verify unattended startup and UMC unplug/replug recovery on the target. Verify SooperLooper OSC startup, the supplied FCB1010 bindings, audio routing, and the effect and persistence of `discrete_prefader 0` separately.
 
 Do not treat planned packages, commands, ports, or service settings as target-validated until these checks have been performed.
 

+ 13 - 0
config/desired-state.yaml

@@ -56,6 +56,19 @@ deployment:
   sooperlooper:
     source_url: https://github.com/abarker/sooperlooper-mods
     tag: v1.7.9-mods.1
+    binary_source: artifacts/sooperlooper/arm64/current/sooperlooper
+    service_source: config/systemd/user/rigforge-sooperlooper.service.in
+    service_destination: .config/systemd/user/rigforge-sooperlooper.service
+    user_service: rigforge-sooperlooper.service
+    binding_file: config/sooperlooper/fcb1010.slb
+    pw_jack_path: /usr/bin/pw-jack
+    oscsend_path: /usr/bin/oscsend
+    timeout_seconds: 30
+    osc:
+      host: 127.0.0.1
+      port: 9951
+      post_start_delay_seconds: 4
+      discrete_prefader: 0
   mod_host:
     source_url: https://github.com/mod-audio/mod-host
     tag: v1.15.0.3371

+ 17 - 0
config/systemd/user/rigforge-sooperlooper.service.in

@@ -0,0 +1,17 @@
+[Unit]
+Description=Rigforge SooperLooper
+Wants=pipewire.service wireplumber.service
+After=pipewire.service wireplumber.service
+PartOf=pipewire.service wireplumber.service
+
+[Service]
+Type=simple
+ExecStart=@PW_JACK@ @SOOPERLOOPER_BINARY@ -l @LOOP_COUNT@ -c @CHANNELS_PER_LOOP@ -t @TIMEOUT_SECONDS@ -m @BINDING_FILE@
+ExecStartPost=/bin/sh -c 'sleep @POST_START_DELAY_SECONDS@; exec @OSCSEND@ @OSC_HOST@ @OSC_PORT@ /sl/0/set sf discrete_prefader @DISCRETE_PREFADER@'
+Restart=on-failure
+RestartSec=5
+TimeoutStartSec=90
+TimeoutStopSec=10
+
+[Install]
+WantedBy=default.target

+ 135 - 35
scripts/deploy.py

@@ -36,17 +36,19 @@ def load_deployment():
     if not isinstance(deployment, dict):
         raise ValueError("deployment must be a mapping")
     namlv2 = deployment.get("namlv2")
+    sooperlooper = deployment.get("sooperlooper")
     pipewire = deployment.get("pipewire")
     reconcile = deployment.get("reconcile")
     midi_bridge = deployment.get("midi_bridge")
     if (
         not isinstance(namlv2, dict)
+        or not isinstance(sooperlooper, dict)
         or not isinstance(pipewire, dict)
         or not isinstance(reconcile, dict)
         or not isinstance(midi_bridge, dict)
     ):
         raise ValueError(
-            "deployment.namlv2, deployment.pipewire, deployment.reconcile, "
+            "deployment.namlv2, deployment.sooperlooper, deployment.pipewire, deployment.reconcile, "
             "and deployment.midi_bridge must be mappings"
         )
     for component, archive_format in PLUGIN_ARCHIVES.items():
@@ -914,6 +916,66 @@ def render_midi_bridge_service(config):
     }
 
 
+def render_sooperlooper_service(config, state):
+    repository_root = ROOT.resolve()
+    binary = repository_root / config["binary_source"]
+    service_template = repository_root / config["service_source"]
+    binding_file = repository_root / config["binding_file"]
+    for description, path in (
+        ("ARM64 SooperLooper artifact", binary),
+        ("SooperLooper service template", service_template),
+        ("SooperLooper MIDI binding file", binding_file),
+    ):
+        if not path.is_file():
+            raise RuntimeError(f"{description} is missing: {path}")
+    if not os.access(binary, os.X_OK):
+        raise RuntimeError(f"ARM64 SooperLooper artifact is not executable: {binary}")
+
+    components = state.get("system", {}).get("components", [])
+    loopers = [
+        component for component in components
+        if isinstance(component, dict) and component.get("id") == "looper"
+    ] if isinstance(components, list) else []
+    if len(loopers) != 1:
+        raise RuntimeError("desired state must declare exactly one SooperLooper component")
+    loop_count = loopers[0].get("loop_count")
+    channels_per_loop = loopers[0].get("channels_per_loop")
+    if (
+        not isinstance(loop_count, int)
+        or isinstance(loop_count, bool)
+        or loop_count < 1
+        or not isinstance(channels_per_loop, int)
+        or isinstance(channels_per_loop, bool)
+        or channels_per_loop < 1
+    ):
+        raise RuntimeError("desired SooperLooper loop and channel counts must be positive integers")
+
+    osc = config["osc"]
+    replacements = {
+        "@PW_JACK@": systemd_quote(config["pw_jack_path"]),
+        "@SOOPERLOOPER_BINARY@": systemd_quote(binary.resolve()),
+        "@LOOP_COUNT@": str(loop_count),
+        "@CHANNELS_PER_LOOP@": str(channels_per_loop),
+        "@TIMEOUT_SECONDS@": str(config["timeout_seconds"]),
+        "@BINDING_FILE@": systemd_quote(binding_file.resolve()),
+        "@POST_START_DELAY_SECONDS@": str(osc["post_start_delay_seconds"]),
+        "@OSCSEND@": systemd_quote(config["oscsend_path"]),
+        "@OSC_HOST@": systemd_quote(osc["host"]),
+        "@OSC_PORT@": str(osc["port"]),
+        "@DISCRETE_PREFADER@": str(osc["discrete_prefader"]),
+    }
+    content = service_template.read_text(encoding="utf-8")
+    for placeholder, replacement in replacements.items():
+        content = content.replace(placeholder, replacement)
+    if re.search(r"@[A-Z_]+@", content):
+        raise RuntimeError("unexpanded placeholder remains in SooperLooper service template")
+    return {
+        "name": config["user_service"],
+        "destination": Path.home() / config["service_destination"],
+        "content": content.encode("utf-8"),
+    }
+
+
 def atomic_install_bytes(content, destination):
     destination.parent.mkdir(parents=True, exist_ok=True)
     fd, temporary_name = tempfile.mkstemp(prefix=f".{destination.name}.", dir=destination.parent)
@@ -927,51 +989,56 @@ def atomic_install_bytes(content, destination):
             os.unlink(temporary_name)
 
 
-def deploy_midi_bridge(action, config, registry):
-    unit = render_midi_bridge_service(config)
+def deploy_single_user_service(action, registry_key, target_name, display_name, unit, registry):
     destination = unit["destination"]
     service_name = unit["name"]
     validate_user_destination(destination)
     if destination.exists() and not destination.is_file():
-        raise RuntimeError(f"MIDI bridge service destination has the wrong type: {destination}")
-    managed = registry.get("midi_bridge")
+        raise RuntimeError(f"{display_name} service destination has the wrong type: {destination}")
+    managed = registry.get(registry_key)
 
     if action == "reload":
         if managed is None:
-            raise RuntimeError("MIDI bridge is not managed; install midi-bridge before reloading it")
+            raise RuntimeError(
+                f"{display_name} is not managed; install {target_name} before reloading it"
+            )
         if managed.get("pending_uninstall"):
-            raise RuntimeError("MIDI bridge uninstall is incomplete; retry uninstall midi-bridge first")
+            raise RuntimeError(
+                f"{display_name} uninstall is incomplete; retry uninstall {target_name} first"
+            )
         if not destination.is_file():
-            raise RuntimeError(f"managed MIDI bridge service file is missing: {destination}")
+            raise RuntimeError(f"managed {display_name} service file is missing: {destination}")
         if file_sha256(destination) != managed.get("installed_sha256"):
-            raise RuntimeError(f"managed MIDI bridge service file changed locally: {destination}")
+            raise RuntimeError(f"managed {display_name} service file changed locally: {destination}")
         run(["systemctl", "--user", "restart", service_name])
         run(["systemctl", "--user", "is-active", "--quiet", service_name])
-        print("Rigforge MIDI bridge user service restarted.")
+        print(f"Rigforge {display_name} user service restarted.")
         return
 
     if action == "uninstall":
         if managed is None:
-            print("No managed MIDI bridge service to uninstall.")
+            print(f"No managed {display_name} service to uninstall.")
             return
         backup_path = validate_backup_path(managed.get("backup"), destination)
         backup_digest = managed.get("backup_sha256")
         if backup_path is not None and backup_path.exists():
             if not backup_path.is_file() or file_sha256(backup_path) != backup_digest:
-                raise RuntimeError(f"recorded MIDI bridge service backup changed locally: {backup_path}")
+                raise RuntimeError(
+                    f"recorded {display_name} service backup changed locally: {backup_path}"
+                )
         elif backup_path is not None and not managed.get("pending_uninstall"):
-            raise RuntimeError(f"recorded MIDI bridge service backup is missing: {backup_path}")
+            raise RuntimeError(f"recorded {display_name} service backup is missing: {backup_path}")
         if (backup_path is None) != (backup_digest is None):
-            raise RuntimeError("invalid MIDI bridge service backup record")
+            raise RuntimeError(f"invalid {display_name} service backup record")
 
         current_digest = file_sha256(destination)
         recoverable_digests = {managed.get("installed_sha256"), backup_digest, None}
         if managed.get("pending_uninstall"):
             if current_digest not in recoverable_digests:
-                raise RuntimeError(f"unexpected file blocks MIDI bridge uninstall: {destination}")
+                raise RuntimeError(f"unexpected file blocks {display_name} uninstall: {destination}")
         elif current_digest != managed.get("installed_sha256"):
             raise RuntimeError(
-                f"managed MIDI bridge service file changed locally; refusing removal: {destination}"
+                f"managed {display_name} service file changed locally; refusing removal: {destination}"
             )
         if (
             backup_path is not None
@@ -979,11 +1046,11 @@ def deploy_midi_bridge(action, config, registry):
             and current_digest == managed.get("installed_sha256")
         ):
             raise RuntimeError(
-                f"recorded MIDI bridge service backup is missing; refusing removal: {backup_path}"
+                f"recorded {display_name} service backup is missing; refusing removal: {backup_path}"
             )
 
         managed["pending_uninstall"] = True
-        registry["midi_bridge"] = managed
+        registry[registry_key] = managed
         write_registry(registry)
         run(["systemctl", "--user", "disable", "--now", service_name])
         if backup_path is not None and current_digest == backup_digest:
@@ -993,22 +1060,26 @@ def deploy_midi_bridge(action, config, registry):
             if current_digest == managed.get("installed_sha256"):
                 destination.unlink()
             elif current_digest is not None:
-                raise RuntimeError(f"unexpected file blocks MIDI bridge uninstall: {destination}")
+                raise RuntimeError(f"unexpected file blocks {display_name} uninstall: {destination}")
             if backup_path is not None:
                 if backup_path.exists():
                     os.replace(backup_path, destination)
                 elif file_sha256(destination) != backup_digest:
-                    raise RuntimeError(f"recorded MIDI bridge service backup is missing: {backup_path}")
+                    raise RuntimeError(
+                        f"recorded {display_name} service backup is missing: {backup_path}"
+                    )
         run(["systemctl", "--user", "daemon-reload"])
-        registry.pop("midi_bridge")
+        registry.pop(registry_key)
         write_registry(registry)
-        print("Rigforge MIDI bridge user service removed; prior unit restored if present.")
+        print(f"Rigforge {display_name} user service removed; prior unit restored if present.")
         return
 
     content = unit["content"]
     installed_digest = hashlib.sha256(content).hexdigest()
     if managed is not None and managed.get("pending_uninstall"):
-        raise RuntimeError("MIDI bridge uninstall is incomplete; retry uninstall midi-bridge first")
+        raise RuntimeError(
+            f"{display_name} uninstall is incomplete; retry uninstall {target_name} first"
+        )
     if managed is None:
         if user_unit_is_active(service_name) or user_unit_is_enabled(service_name):
             raise RuntimeError(
@@ -1028,17 +1099,19 @@ def deploy_midi_bridge(action, config, registry):
         pending_install = True
     else:
         if managed.get("destination") != str(destination):
-            raise RuntimeError("recorded MIDI bridge service path changed")
+            raise RuntimeError(f"recorded {display_name} service path changed")
         backup_path = validate_backup_path(managed.get("backup"), destination)
         backup = str(backup_path) if backup_path is not None else None
         backup_digest = managed.get("backup_sha256")
         if (backup_path is None) != (backup_digest is None):
-            raise RuntimeError("invalid MIDI bridge service backup record")
+            raise RuntimeError(f"invalid {display_name} service backup record")
         if backup_path is not None and backup_path.exists():
             if not backup_path.is_file() or file_sha256(backup_path) != backup_digest:
-                raise RuntimeError(f"recorded MIDI bridge service backup changed locally: {backup_path}")
+                raise RuntimeError(
+                    f"recorded {display_name} service backup changed locally: {backup_path}"
+                )
         elif backup_path is not None and not managed.get("pending_install"):
-            raise RuntimeError(f"recorded MIDI bridge service backup is missing: {backup_path}")
+            raise RuntimeError(f"recorded {display_name} service backup is missing: {backup_path}")
         previous_digest = (
             managed.get("previous_installed_sha256")
             if managed.get("pending_install")
@@ -1047,9 +1120,11 @@ def deploy_midi_bridge(action, config, registry):
         current_digest = file_sha256(destination)
         if managed.get("pending_install"):
             if current_digest not in {previous_digest, backup_digest, None}:
-                raise RuntimeError(f"MIDI bridge service changed locally during interrupted install: {destination}")
+                raise RuntimeError(
+                    f"{display_name} service changed locally during interrupted install: {destination}"
+                )
         elif current_digest != previous_digest:
-            raise RuntimeError(f"managed MIDI bridge service file changed locally: {destination}")
+            raise RuntimeError(f"managed {display_name} service file changed locally: {destination}")
         pending_install = current_digest != installed_digest
 
     unit_changed = file_sha256(destination) != installed_digest
@@ -1066,23 +1141,25 @@ def deploy_midi_bridge(action, config, registry):
         "pending_install": pending_install,
         "pending_activation": True,
     })
-    registry["midi_bridge"] = managed
+    registry[registry_key] = managed
     write_registry(registry)
 
     if backup_path is not None:
         if backup_path.exists():
             if not backup_path.is_file() or file_sha256(backup_path) != backup_digest:
-                raise RuntimeError(f"recorded MIDI bridge service backup changed locally: {backup_path}")
+                raise RuntimeError(
+                    f"recorded {display_name} service backup changed locally: {backup_path}"
+                )
         elif file_sha256(destination) == backup_digest:
             shutil.copy2(destination, backup_path)
         else:
-            raise RuntimeError(f"recorded MIDI bridge service backup is missing: {backup_path}")
+            raise RuntimeError(f"recorded {display_name} service backup is missing: {backup_path}")
     if unit_changed:
         atomic_install_bytes(content, destination)
 
     managed.pop("previous_installed_sha256", None)
     managed.pop("pending_install", None)
-    registry["midi_bridge"] = managed
+    registry[registry_key] = managed
     write_registry(registry)
     run(["systemctl", "--user", "daemon-reload"])
     run(["systemctl", "--user", "enable", service_name])
@@ -1094,9 +1171,27 @@ def deploy_midi_bridge(action, config, registry):
     ])
     run(["systemctl", "--user", "is-active", "--quiet", service_name])
     managed.pop("pending_activation", None)
-    registry["midi_bridge"] = managed
+    registry[registry_key] = managed
     write_registry(registry)
-    print(f"Installed and activated Rigforge MIDI bridge user service at {destination}.")
+    print(f"Installed and activated Rigforge {display_name} user service at {destination}.")
+
+
+def deploy_midi_bridge(action, config, registry):
+    unit = render_midi_bridge_service(config)
+    deploy_single_user_service(
+        action, "midi_bridge", "midi-bridge", "MIDI bridge", unit, registry
+    )
+
+
+def deploy_sooperlooper(action, config, registry, state=None):
+    if state is None:
+        state = yaml.safe_load(
+            (ROOT / "config" / "desired-state.yaml").read_text(encoding="utf-8")
+        )
+    unit = render_sooperlooper_service(config, state)
+    deploy_single_user_service(
+        action, "sooperlooper", "sooperlooper", "SooperLooper", unit, registry
+    )
 
 
 def file_sha256(path):
@@ -1587,6 +1682,7 @@ def main(argv=None):
             "mod-host",
             "reconcile",
             "midi-bridge",
+            "sooperlooper",
         ),
     )
     args = parser.parse_args(argv)
@@ -1607,6 +1703,10 @@ def main(argv=None):
             deploy_reconcile(args.action, deployment["reconcile"], registry)
         elif args.target == "midi-bridge":
             deploy_midi_bridge(args.action, deployment["midi_bridge"], registry)
+        elif args.target == "sooperlooper":
+            deploy_sooperlooper(
+                args.action, deployment["sooperlooper"], registry, state=state
+            )
         else:
             component = "dragonfly_reverb" if args.target == "dragonfly-reverb" else args.target
             deploy_lv2_archives(args.action, component, deployment[component], registry)

+ 2 - 2
scripts/deploy.sh

@@ -2,7 +2,7 @@
 set -u
 
 usage() {
-    printf 'Usage: %s install|uninstall|reload all|namlv2|lsp|dragonfly-reverb|pipewire|mod-host|reconcile|midi-bridge\n' "$0" >&2
+    printf 'Usage: %s install|uninstall|reload all|namlv2|lsp|dragonfly-reverb|pipewire|mod-host|reconcile|midi-bridge|sooperlooper\n' "$0" >&2
     exit 2
 }
 
@@ -15,7 +15,7 @@ case "$action" in
 esac
 case "$target" in
     all) targets=(pipewire namlv2 lsp dragonfly-reverb) ;;
-    namlv2|lsp|dragonfly-reverb|pipewire|mod-host|reconcile|midi-bridge) targets=("$target") ;;
+    namlv2|lsp|dragonfly-reverb|pipewire|mod-host|reconcile|midi-bridge|sooperlooper) targets=("$target") ;;
     *) usage ;;
 esac
 

+ 55 - 0
scripts/validate_desired_state.py

@@ -406,6 +406,61 @@ def validate_state(state):
                 character not in allowed_tag_characters for character in tag
             ):
                 errors.append("deployment.sooperlooper.tag must be a simple version tag")
+            for key, expected in (
+                ("binary_source", "artifacts/sooperlooper/arm64/current/sooperlooper"),
+                (
+                    "service_source",
+                    "config/systemd/user/rigforge-sooperlooper.service.in",
+                ),
+                (
+                    "service_destination",
+                    ".config/systemd/user/rigforge-sooperlooper.service",
+                ),
+                ("user_service", "rigforge-sooperlooper.service"),
+                ("binding_file", "config/sooperlooper/fcb1010.slb"),
+                ("pw_jack_path", "/usr/bin/pw-jack"),
+                ("oscsend_path", "/usr/bin/oscsend"),
+            ):
+                if sooperlooper.get(key) != expected:
+                    errors.append(f"deployment.sooperlooper.{key} must be {expected}")
+            timeout_seconds = sooperlooper.get("timeout_seconds")
+            if (
+                not isinstance(timeout_seconds, int)
+                or isinstance(timeout_seconds, bool)
+                or not 1 <= timeout_seconds <= 300
+            ):
+                errors.append("deployment.sooperlooper.timeout_seconds must be between 1 and 300")
+            osc = sooperlooper.get("osc")
+            if not isinstance(osc, dict):
+                errors.append("deployment.sooperlooper.osc must be a mapping")
+            else:
+                if osc.get("host") != "127.0.0.1":
+                    errors.append("deployment.sooperlooper.osc.host must be 127.0.0.1")
+                port = osc.get("port")
+                if (
+                    not isinstance(port, int)
+                    or isinstance(port, bool)
+                    or not 1 <= port <= 65535
+                ):
+                    errors.append("deployment.sooperlooper.osc.port must be a valid UDP port")
+                delay = osc.get("post_start_delay_seconds")
+                if (
+                    not isinstance(delay, int)
+                    or isinstance(delay, bool)
+                    or not 0 <= delay <= 30
+                ):
+                    errors.append(
+                        "deployment.sooperlooper.osc.post_start_delay_seconds must be between 0 and 30"
+                    )
+                prefader = osc.get("discrete_prefader")
+                if (
+                    not isinstance(prefader, int)
+                    or isinstance(prefader, bool)
+                    or prefader not in (0, 1)
+                ):
+                    errors.append(
+                        "deployment.sooperlooper.osc.discrete_prefader must be 0 or 1"
+                    )
 
         mod_host = deployment.get("mod_host")
         if not isinstance(mod_host, dict):

+ 60 - 0
tests/test_deploy.py

@@ -105,6 +105,9 @@ class DeploymentTests(unittest.TestCase):
     def mod_host_config(self):
         return deploy.load_deployment()["mod_host"]
 
+    def sooperlooper_config(self):
+        return deploy.load_deployment()["sooperlooper"]
+
     def reconcile_config(self):
         return deploy.load_deployment()["reconcile"]
 
@@ -462,6 +465,63 @@ class DeploymentTests(unittest.TestCase):
         self.assertEqual(destination.read_text(encoding="utf-8"), "local change")
         self.assertEqual(self.commands, [])
 
+    def test_sooperlooper_service_uses_desired_counts_bindings_and_prefader_osc(self):
+        config = self.sooperlooper_config()
+        destination = self.home / config["service_destination"]
+        destination.parent.mkdir(parents=True)
+        destination.write_text("prior SooperLooper unit", encoding="utf-8")
+
+        deploy.deploy_sooperlooper("install", config, deploy.read_registry())
+
+        installed = destination.read_text(encoding="utf-8")
+        binary = (ROOT / config["binary_source"]).resolve()
+        binding_file = (ROOT / config["binding_file"]).resolve()
+        self.assertIn(
+            f'ExecStart="/usr/bin/pw-jack" "{binary}" -l 1 -c 4 -t 30 -m "{binding_file}"',
+            installed,
+        )
+        self.assertIn(
+            "ExecStartPost=/bin/sh -c 'sleep 4; exec \"/usr/bin/oscsend\" "
+            "\"127.0.0.1\" 9951 /sl/0/set sf discrete_prefader 0'",
+            installed,
+        )
+        self.assertIn("PartOf=pipewire.service wireplumber.service", installed)
+        self.assertEqual(
+            self.commands,
+            [
+                ["systemctl", "--user", "daemon-reload"],
+                ["systemctl", "--user", "enable", "rigforge-sooperlooper.service"],
+                ["systemctl", "--user", "restart", "rigforge-sooperlooper.service"],
+                ["systemctl", "--user", "is-active", "--quiet", "rigforge-sooperlooper.service"],
+            ],
+        )
+        self.assertIn("sooperlooper", deploy.read_registry())
+
+        self.commands.clear()
+        deploy.deploy_sooperlooper("uninstall", config, deploy.read_registry())
+        self.assertEqual(destination.read_text(encoding="utf-8"), "prior SooperLooper unit")
+        self.assertNotIn("sooperlooper", deploy.read_registry())
+        self.assertEqual(
+            self.commands,
+            [
+                ["systemctl", "--user", "disable", "--now", "rigforge-sooperlooper.service"],
+                ["systemctl", "--user", "daemon-reload"],
+            ],
+        )
+
+    def test_sooperlooper_reload_refuses_local_unit_edits(self):
+        config = self.sooperlooper_config()
+        deploy.deploy_sooperlooper("install", config, deploy.read_registry())
+        destination = self.home / config["service_destination"]
+        destination.write_text("local change", encoding="utf-8")
+        self.commands.clear()
+
+        with self.assertRaisesRegex(RuntimeError, "changed locally"):
+            deploy.deploy_sooperlooper("reload", config, deploy.read_registry())
+
+        self.assertEqual(destination.read_text(encoding="utf-8"), "local change")
+        self.assertEqual(self.commands, [])
+
     def test_mod_host_install_and_uninstall_do_not_manage_reconcile_timer(self):
         reconcile_config = self.reconcile_config()
         mod_host_config = self.mod_host_config()

+ 16 - 0
tests/test_desired_state.py

@@ -170,6 +170,22 @@ class DesiredStateValidationTests(unittest.TestCase):
         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)
+        self.assertEqual(state["deployment"]["sooperlooper"]["timeout_seconds"], 30)
+        self.assertEqual(state["deployment"]["sooperlooper"]["osc"]["discrete_prefader"], 0)
+        state["deployment"]["sooperlooper"]["osc"]["port"] = 70000
+        self.assertIn(
+            "deployment.sooperlooper.osc.port must be a valid UDP port",
+            validate_state(state),
+        )
+
+        state = copy.deepcopy(self.state)
+        state["deployment"]["sooperlooper"]["timeout_seconds"] = 0
+        self.assertIn(
+            "deployment.sooperlooper.timeout_seconds must be between 1 and 300",
+            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)))