AGENTS.md 11 KB

Agent guide

Project purpose and status

Rigforge is a Raspberry Pi audio pedalboard project. Treat this repository as a desired-state model plus a small set of tested candidates and read-only tools, not as a finished deployable system. Hardware routing and operational settings remain partly provisional. The root README.md is the authoritative record of current target observations, validation status, test procedure, and rollback details; check it before changing target-facing configuration.

The current target is Debian GNU/Linux 13 on AArch64 with a Behringer UMC404HD 192k, PipeWire, and WirePlumber. Guitar on physical input 1 and microphone on input 3 have been heard through the candidate mixer. The target owner also reports an initial guitar test through the Vox AC15 NAM model and Vox AC30 cabinet IR with pleasing crunch and no crackles. Sustained stability, headroom, remaining inputs, looper integration, MIDI bindings, and automatic service startup are not verified. Do not turn reported or candidate settings into claims of verified behavior.

Layout and architecture

  • config/desired-state.yaml is the central YAML description of the intended components, four mono sources, two four-channel SooperLooper loops (sources feed the first loop; the second loop has no inputs and only output 1 routed to the mix), mix, the guitar NAM/cabinet chain, four-channel mod-host PipeWire boundaries, planned/forbidden connections, and exact external PipeWire links tracked for observation.
  • config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf is a PipeWire filter-chain fragment with nine mono mixer inputs (four direct sources, four first-loop returns, and one second-loop return) implemented as two cascaded mixer stages, one mono output, and initial external-input gain 0.2. It defines the processing graph and ports, but does not create links to hardware or implement the looper graph.
  • scripts/validate_desired_state.py checks the YAML's four-source/physical-input model, one SooperLooper instance with two four-channel loops, source-to-first-loop channel assignments, the unconnected second-loop inputs and single mix return, mix declaration, and prohibition on routing looper returns back to looper inputs.
  • scripts/observe_pipewire.py validates the state and managed endpoint declarations, reads pw-link -l, and compares observed links against explicitly managed ports and links. Without --reconcile-once, it is read-only; one-shot reconciliation and the separately deployed timer create only declared missing links and remove only declared stale links.
  • scripts/generate_mod_ui_pedalboard.py builds the YAML-declared guitar NAM→IR chain and three direct-through source pairs; mod-ui owns plugin instances and internal cables after loading it.
  • scripts/run_mod_host_ports.py runs the paired four-channel PipeWire loopbacks which form stable mod-ui-visible input/output boundaries.
  • scripts/prepare_mod_ui_pedalboard.py regenerates and validates the canonical mod-ui bundle once per system boot, keeps backups outside mod-ui's scanned pedalboard directory, and refuses to launch on an invalid board.
  • scripts/run_mod_ui_service.py launches mod-ui under pw-jack, holds a WebSocket session, and verifies the guitar PipeWire boundary links before reporting ready. The mod-ui patch must schedule saved-board boundary retries on Tornado's event loop; do not block pedalboard loading while plugin ports are being created.
  • build/arm64/patch_mod_ui_rigforge.py reapplies the local PipeWire-boundary mapping and acknowledged MIDI WebSocket command when rebuilding the pinned mod-ui artifact; keep it consistent with the tracked artifact changes.
  • scripts/wait_mod_host_ports.py waits for boundary and mixer endpoints before mod-host starts, avoiding startup races after PipeWire restarts.
  • scripts/midi_action_bridge.py retains ALSA Note On bindings and changes NAM files through mod-ui's WebSocket, never a second mod-host control connection.
  • The old scripts/configure_mod_host.py is not used by the service architecture; do not reintroduce its direct plugin/link ownership alongside mod-ui.
  • config/systemd/user/rigforge-pipewire-reconcile.service.in and .timer.in define periodic reconciliation for the whole YAML-managed graph.
  • config/systemd/user/rigforge-mod-host-ports.service.in, rigforge-mod-host.service.in, and rigforge-mod-ui.service.in define the opt-in boundary, backend, and UI services; mod-ui runs its clean-board preparation before launch.
  • scripts/deploy.sh dispatches scoped user-level install/uninstall/reload actions plus explicit reset mod-ui for YAML-declared services and bundles. Audio-host/UI targets and reconcile are opt-in, not part of all.
  • tests/ contains Python unittest tests for state validation, observation/reconciliation, the generated pedalboard, MIDI WebSocket control, and simulated deployment operations. These validate repository-level invariants, not live audio behavior.
  • config/sooperlooper/fcb1010.slb is supplied controller configuration, pending target verification. No SooperLooper build definition or artifact is present.

The YAML is the source of truth for desired topology and the generated pedalboard. mod-ui owns the guitar NAM→IR cable and the bass/voice/synth input-to-output passthrough cables; its Rigforge bridge applies those boundary Connect/Disconnect operations through pw-link. Rigforge's observer owns only external UMC→input-boundary and output-boundary→mixer/looper links. The observer compares only external links whose endpoints are listed in routing.managed_ports. Keep mod-ui-owned cables and unrelated WirePlumber links out of scope. Managed endpoint names are constrained by an explicit allowlist pattern in the observer, so a new port naming scheme must be deliberately reviewed and tested there as well as declared in YAML.

Commands

Run from the repository root:

python3 scripts/validate_desired_state.py
python3 scripts/validate_desired_state.py path/to/desired-state.yaml
python3 -m unittest discover -s tests -v

The validator defaults to config/desired-state.yaml; it exits nonzero for invalid state or load errors. The tests use the standard library unittest runner and import PyYAML (yaml); there is no dependency manifest or separate build/lint configuration in the repository.

On a target with pw-link and the logged-in PipeWire session available, run the read-only observer with:

python3 scripts/observe_pipewire.py
python3 scripts/observe_pipewire.py --state path/to/desired-state.yaml

The observer invokes pw-link -l itself. Its default mode never creates or removes links. A clean test run does not verify physical port mappings, sustained performance, clipping headroom, or hardware operation; those require target checks described in README.md.

State and safety invariants

  • Preserve exactly the four named sources (guitar, bass, voice, synth) and physical inputs 1–4, each once, unless the validator and its tests are intentionally updated along with the model.
  • Preserve one looper component/instance and two four-channel loops; assign each declared source to one unique channel 1–4 on the first loop. Keep every second-loop input unconnected and route only its output 1 to direct-mix AUX8.
  • The mix must declare an output and include looper returns. Looper returns must not feed any looper input; the explicit forbidden connection is policy documentation, not an active route.
  • A managed link's endpoints must both be declared in routing.managed_ports, and names must match the observer's approved endpoint pattern. Use concrete PipeWire boundary ports rather than logical aliases or mod-ui plugin ports. Never add NAM→IR to Rigforge's managed links.
  • Link status values used by the observer are planned and observed; both are compared against the current graph. Only declare real target observations as observed.
  • Deployment declarations belong in config/desired-state.yaml. The deploy helper must remain scoped to declared user paths, preserve and restore prior files, refuse destructive actions after local modifications, and never restart the main PipeWire or WirePlumber service as a generic update.
  • Keep observation as the default. Explicit --reconcile-once and the separately installed user timer may create declared missing links and remove only exact links listed in routing.managed_unlinks; they must defer removals until all desired managed links are present, must not alter other connections, and must not restart PipeWire/WirePlumber. Retain tests for simulated repair, safe removal, deferral, and post-check behavior.
  • Mixer gain 0.2 is an initial conservative value, not a calibrated level or clipping guarantee. Test summed sources and loop returns on hardware before live use.

Working conventions and gotchas

  • Use Python 3 and preserve the existing standard-library unittest style. Tests construct modified state with deep copies so cases do not contaminate shared fixtures.
  • YAML files are loaded with yaml.safe_load; keep changes compatible with the validator's explicit structural/type checks.
  • Scripts resolve their default state file relative to their own location, so the documented commands work from any current directory, though repository-root execution is the clearest convention.
  • PipeWire's filter-chain.conf.d fragment is loaded by the separate filter-chain process (pipewire -c filter-chain.conf on the current target), not automatically by the main PipeWire daemon. It defines nodes/ports, not connections. Target service installation and restart steps are specific to the README's current test and should not be treated as an established deployment recipe.
  • The current port mapping, sample rate/quantum, and physical output details have differing verification levels recorded in YAML and README. Preserve those distinctions; do not infer a complete deployment procedure from the exploratory test notes.
  • Deployment is manual; no CI/CD or auto-pull is configured. The new loopback boundaries, paired mod-host feedback socket, mod-ui service, generated bundle loading, and MIDI WebSocket path are not target-verified. Keep unverified changes away from live audio use and follow the README's rollback procedure for target experiments.
  • install mod-host-ports, install mod-host, and install mod-ui activate the candidate guitar path and are intentionally excluded from install all. install reconcile separately enables graph-wide periodic link repair and is also opt-in. mod-host's control and feedback sockets listen on all interfaces without authentication by owner request; do not change that policy silently, and retain the security warning in documentation.

Environnement local — rigforge

La machine rigforge est accessible depuis ce PC avec :

ssh -i ~/.ssh/id_ed25519 jojo@192.168.8.178

Demander mon accord avant toute connexion SSH. Ne pas modifier la machine distante sans autorisation explicite.