Johan Le Baut 2 هفته پیش
والد
کامیت
3940bd235e
1فایلهای تغییر یافته به همراه58 افزوده شده و 0 حذف شده
  1. 58 0
      AGENTS.md

+ 58 - 0
AGENTS.md

@@ -0,0 +1,58 @@
+# 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 remaining inputs, sustained stability, headroom, looper integration, MIDI bindings, and unattended 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, looper channel assignments, mix, planned/forbidden connections, and the exact PipeWire links currently tracked for observation.
+- `config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf` is a PipeWire filter-chain fragment with four mono mixer inputs, one mono output, and initial gain `0.2` per input. 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, single four-channel looper, source-to-channel assignments, 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`, then compares observed links against the explicitly managed ports and links. It reports differences only; it must remain non-mutating.
+- `tests/` contains Python `unittest` tests for the state validator, observer, and mixer configuration. 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. The observer's scope is deliberately narrower: it compares links only when both endpoints are listed in `routing.managed_ports`. Keep unrelated WirePlumber-managed hardware 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:
+
+```sh
+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:
+
+```sh
+python3 scripts/observe_pipewire.py
+python3 scripts/observe_pipewire.py --state path/to/desired-state.yaml
+```
+
+The observer invokes `pw-link -l` itself. It 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 one four-channel loop; assign each declared source to one unique channel 1–4.
+- 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 observed PipeWire ports rather than logical aliases.
+- 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`.
+- Keep reconciliation observe-only. Do not add automatic repair or alter target links as a side effect of validation or observation.
+- 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, auto-pull, or production service-installation workflow is configured. Keep unverified changes away from live audio use and follow the README's rollback procedure for target experiments.