Johan Le Baut 2 veckor sedan
förälder
incheckning
9ad4db3ca6

+ 9 - 9
README.md

@@ -29,7 +29,7 @@ This records the preparation already performed on `rigforge` and is a starting p
 ## Repository layout
 
 - `config/desired-state.yaml`: versioned desired audio topology and provisional target mapping.
-- `config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf`: candidate four-channel input to mono direct mixer; not yet installed or run on the target.
+- `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.
 - `scripts/validate_desired_state.py`: validates topology and routing invariants without changing the target.
@@ -54,13 +54,13 @@ For an initial read-only graph observation on a system with `pw-link`, run:
 python3 scripts/observe_pipewire.py
 ```
 
-The observer reads `pw-link -l` and compares only connections whose endpoints are explicitly listed under `routing.managed_ports`; expected edges go in `routing.managed_links`. Both lists are empty at this stage, so it intentionally reports no project mismatches. The existing WirePlumber links between UMC AUX ports and their split monitor ports are not classified as project-managed. Only concrete UMC ALSA AUX port names are accepted; logical nodes such as `direct_mix` are rejected until an actual PipeWire node/port exists. The observer only prints missing or unexpected link proposals; it never creates or deletes links. No polling or automatic repair is enabled in this increment.
+The observer reads `pw-link -l` and compares only connections whose endpoints are explicitly listed under `routing.managed_ports`; expected edges go in `routing.managed_links`. The current YAML lists the three tested guitar/microphone mixer links and only those exact observed UMC and filter-chain ports. WirePlumber's hardware links remain outside project management. The observer only reports missing or unexpected project links; it never creates or deletes links. No polling or automatic repair is enabled.
 
 ## Candidate direct mix test
 
-`config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf` defines a PipeWire builtin mixer with four mono inputs, a single mono output, and a conservative initial gain of 0.2 per input. It is a candidate config for a two-input listening test using `capture_AUX0` and `capture_AUX2`; it is not installed, loaded, or claimed to be syntactically validated by PipeWire yet. Inputs 2 and 4 are provisioned for later checks, not confirmed by instrument tests.
+`config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf` defines a PipeWire builtin mixer with four mono inputs, a single mono output, and an initial gain of 0.2 per input. It was loaded on `rigforge`; its input and output nodes appeared in the graph. Manual links from capture AUX0 and AUX2 through mixer input ports AUX0 and AUX2 to playback AUX0 produced audible guitar and microphone together. Inputs 2 and 4 are provisioned but remain untested with instruments.
 
-The installed PipeWire example explicitly documents loading fragments from `~/.config/pipewire/filter-chain.conf.d/` with `pipewire -c filter-chain.conf`, which is the command used by the current user service. After this candidate is available in the target checkout, it can be tested as a reversible user-level fragment, without editing `/etc` or the packaged config:
+The installed PipeWire example documents loading fragments from `~/.config/pipewire/filter-chain.conf.d/` with `pipewire -c filter-chain.conf`, which is the command used by the current user service. The fragment was installed and tested in that user configuration without editing `/etc` or the packaged config:
 
 ```sh
 target="$HOME/.config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf"
@@ -73,7 +73,7 @@ install -m 0644 config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf "$t
 systemctl --user restart filter-chain.service
 ```
 
-Then confirm `filter-chain.service` is active, inspect `pw-cli ls Node`, `pw-link -o`, and `pw-link -i`, and stop if the two project nodes do not appear or the service reports an error. Do not infer the new port names: use the exact names printed by PipeWire. At low monitor volume, connect only the physical capture ports for inputs 1 and 3 to the matching mixer inputs, and the mixer output to `playback_AUX0`; listen for guitar and microphone, then remove these test links with `pw-link -d` using the exact observed endpoint names. Existing WirePlumber hardware links must be left alone.
+The test has already been performed on `rigforge`: `filter-chain.service` was active and exposed input ports `rigforge.direct-mix.input:playback_AUX0` through `playback_AUX3` and output port `rigforge.direct-mix.output:capture_FL`. The three links now declared in YAML were connected manually with `pw-link`; guitar on input 1 and microphone on input 3 were heard together through the mixer. Existing WirePlumber hardware links were left untouched.
 
 Rollback the fragment and reload the filter service after the test:
 
@@ -86,7 +86,7 @@ fi
 systemctl --user restart filter-chain.service
 ```
 
-This restarts only `filter-chain.service`, not the main PipeWire daemon; it has not yet been exercised with this project fragment. If activation or sound behaves unexpectedly, first remove the test links, perform the rollback, verify the filter service is active, and do not repeatedly restart it. The repository tests check channel/gain declarations, not PipeWire's native config parser or target runtime behavior.
+This restarts only `filter-chain.service`, not the main PipeWire daemon. The fragment and three links have passed an initial target listening test, but the test is not a sustained load, dropout, four-instrument, or headroom test. If activation or sound behaves unexpectedly, first remove the test links, perform the rollback, verify the filter service is active, and do not repeatedly restart it. Repository tests check channel/gain declarations and observer comparisons; they do not replace target runtime measurements.
 
 ## Development PC
 
@@ -96,12 +96,12 @@ No SooperLooper artifact or Dockerfile is included at this stage.
 
 ## `rigforge` target
 
-No packages, artifacts, services, or permanent audio configuration have been installed or changed by this initial increment. A temporary direct PipeWire test linked `capture_AUX0` and `capture_AUX2` to `playback_AUX0`; guitar and microphone were heard together at 48 kHz / 128 frames. `pw-top` showed the active capture driver at 128 frames with `ERR = 0` during the reported test. The temporary links have since been removed. This is an initial listening check, not a sustained load, dropout, 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 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 next target checks are:
 
-1. Confirm the software-mixed direct path and its gain staging before adding processing or looper returns.
-2. Later, test inputs 2 and 4 with sources when available; for planning only, the four existing capture channels are assumed to work.
+1. Run the read-only PipeWire observer on `rigforge`; the expected result is no differences while the three test links remain active.
+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.
 5. Verify FCB1010 MIDI messages and the supplied bindings with the eventual SooperLooper build. Verify OSC port readiness and the effect and persistence of `discrete_prefader 0` separately.

+ 17 - 2
config/desired-state.yaml

@@ -113,8 +113,23 @@ routing:
   looper_returns:
     destination: direct_mix
     feed_looper_inputs: false
-  managed_ports: []
-  managed_links: []
+  managed_ports:
+    - alsa_input.hw_U192k_0:capture_AUX0
+    - rigforge.direct-mix.input:playback_AUX0
+    - alsa_input.hw_U192k_0:capture_AUX2
+    - rigforge.direct-mix.input:playback_AUX2
+    - rigforge.direct-mix.output:capture_FL
+    - alsa_output.hw_U192k_0:playback_AUX0
+  managed_links:
+    - from: alsa_input.hw_U192k_0:capture_AUX0
+      to: rigforge.direct-mix.input:playback_AUX0
+      status: observed
+    - from: alsa_input.hw_U192k_0:capture_AUX2
+      to: rigforge.direct-mix.input:playback_AUX2
+      status: observed
+    - from: rigforge.direct-mix.output:capture_FL
+      to: alsa_output.hw_U192k_0:playback_AUX0
+      status: observed
   monitoring:
     hardware_monitoring: verify-on-target
     software_monitoring: verify-on-target

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

@@ -0,0 +1,50 @@
+# Rigforge PipeWire filter-chain fragments
+
+## `rigforge-direct-mix.conf`
+
+This PipeWire filter-chain fragment has been loaded and its input/output nodes were observed on `rigforge`. A manual test linked the guitar from input 1 and microphone from input 3 into the mixer and sent its mono output to `playback_AUX0`; the user confirmed both were audible together. The fragment declares one built-in mixer with four mono inputs and one mono output. It remains a candidate for the full Rigforge routing, not the complete looper or processing graph.
+
+The initial mixer gain for each input is `0.2` (approximately -14 dB). This is only a conservative starting value, not a calibrated level or a guarantee against clipping. Summed levels must be tested with the real sources and loop returns before live use.
+
+## Configuration sections
+
+### `context.modules`
+
+Declares modules to load in the PipeWire process that reads this configuration. Here it asks that process to load `libpipewire-module-filter-chain`. It does not load the module into every PipeWire process or automatically add the fragment to the main `pipewire.service` configuration.
+
+### `args`
+
+Contains arguments for the filter-chain module, including descriptive metadata and the graph and node properties used to expose the filter's ports.
+
+### `filter.graph`
+
+Defines the signal-processing graph inside the filter:
+
+- `nodes` declares one built-in node named `mix` using the `mixer` plugin.
+- `control` sets the initial `Gain 1` through `Gain 4` values to `0.2`.
+- `inputs` exports the node's four inputs as the filter's input ports.
+- `outputs` exports the mixer's single output as the filter's output port.
+
+This graph performs summing in the filter. It does not itself connect physical capture ports to the four inputs or connect the output to a hardware playback port.
+
+### `capture.props`
+
+Sets properties for the input-side PipeWire node created by the filter-chain module. In this candidate, `media.class = "Audio/Sink"` makes it appear as an audio sink with input ports, named `rigforge.direct-mix.input`. Its declared positions are four AUX channels and remixing is disabled so channels are intended to stay distinct.
+
+On the tested target, the input node exposed ports `rigforge.direct-mix.input:playback_AUX0` through `playback_AUX3`. Input capture `capture_AUX0` was linked to input-node `playback_AUX0`, and `capture_AUX2` to `playback_AUX2`. The channel mapping follows those tested links for guitar and voice only; AUX1 and AUX3 remain untested with instruments.
+
+### `playback.props`
+
+Sets properties for the output-side PipeWire node, named `rigforge.direct-mix.output`. It is declared as a mono audio source with an `FL` output position. `node.passive = true` requests passive behavior when nothing consumes the output. This node still needs an explicit link to the intended hardware playback port.
+
+## Relationship to PipeWire configuration
+
+The fragment does **not** replace or overwrite PipeWire's packaged default configuration. The directory name `filter-chain.conf.d` is read only when a process loads the base `filter-chain.conf` configuration, as the installed PipeWire example describes. On the current target, `filter-chain.service` runs `/usr/bin/pipewire -c filter-chain.conf` as a separate user service. The fragment is therefore intended for that filter-chain process, not as a drop-in for the main PipeWire daemon's `pipewire.conf`.
+
+The fragment added nodes visible in the graph inspected by `pw-link` on the target, and its tested ports accepted manual links from the UMC capture node and to the UMC playback node. Thus this filter-chain instance can participate in the tested graph path on this target. The filter does not automatically connect its nodes or prove the final routing.
+
+## 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.
+
+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.

+ 9 - 4
scripts/observe_pipewire.py

@@ -11,7 +11,12 @@ from validate_desired_state import validate_state as validate_desired_state
 
 
 MANAGED_ENDPOINT_PATTERN = re.compile(
-    r"^alsa_(?:input|output)\.hw_U192k_0:(?:capture|playback)_AUX[0-3]$"
+    r"^(?:"
+    r"alsa_input\.hw_U192k_0:capture_AUX[0-3]|"
+    r"alsa_output\.hw_U192k_0:playback_AUX[0-3]|"
+    r"rigforge\.direct-mix\.input:playback_AUX[0-3]|"
+    r"rigforge\.direct-mix\.output:capture_FL"
+    r")$"
 )
 
 
@@ -38,7 +43,7 @@ def validate_managed_links(state):
         managed_ports = []
     for index, port in enumerate(managed_ports):
         if not isinstance(port, str) or not MANAGED_ENDPOINT_PATTERN.fullmatch(port):
-            errors.append(f"routing.managed_ports[{index}] must be a concrete UMC AUX port")
+            errors.append(f"routing.managed_ports[{index}] is not an approved observed Rigforge or UMC port")
     if len(managed_ports) != len(set(port for port in managed_ports if isinstance(port, str))):
         errors.append("routing.managed_ports must not contain duplicate ports")
 
@@ -53,9 +58,9 @@ def validate_managed_links(state):
         source = link.get("from")
         destination = link.get("to")
         if not isinstance(source, str) or not MANAGED_ENDPOINT_PATTERN.fullmatch(source):
-            errors.append(f"routing.managed_links[{index}].from must be a concrete UMC AUX port")
+            errors.append(f"routing.managed_links[{index}].from is not an approved observed Rigforge or UMC port")
         if not isinstance(destination, str) or not MANAGED_ENDPOINT_PATTERN.fullmatch(destination):
-            errors.append(f"routing.managed_links[{index}].to must be a concrete UMC AUX port")
+            errors.append(f"routing.managed_links[{index}].to is not an approved observed Rigforge or UMC port")
         if (
             isinstance(source, str)
             and isinstance(destination, str)

+ 58 - 2
tests/test_pipewire_observer.py

@@ -11,6 +11,9 @@ from observe_pipewire import load_state, observe, parse_pw_link_output, validate
 CAPTURE_0 = "alsa_input.hw_U192k_0:capture_AUX0"
 CAPTURE_2 = "alsa_input.hw_U192k_0:capture_AUX2"
 CAPTURE_3 = "alsa_input.hw_U192k_0:capture_AUX3"
+MIX_INPUT_0 = "rigforge.direct-mix.input:playback_AUX0"
+MIX_INPUT_2 = "rigforge.direct-mix.input:playback_AUX2"
+MIX_OUTPUT = "rigforge.direct-mix.output:capture_FL"
 PLAYBACK_0 = "alsa_output.hw_U192k_0:playback_AUX0"
 
 
@@ -20,13 +23,16 @@ class PipeWireObserverTests(unittest.TestCase):
         cls.state = load_state(ROOT / "config" / "desired-state.yaml")
 
     def test_empty_managed_set_ignores_wireplumber_hardware_links(self):
+        state = copy.deepcopy(self.state)
+        state["routing"]["managed_ports"] = []
+        state["routing"]["managed_links"] = []
         observed = parse_pw_link_output(
             "alsa_output.usb-umc:Line1.split:output_AUX0\n"
             f"  |-> {PLAYBACK_0}\n"
             f"{CAPTURE_0}\n"
             "  |-> alsa_input.usb-umc:Mic1.split:input_AUX0\n"
         )
-        self.assertEqual(observe(self.state, observed), [])
+        self.assertEqual(observe(state, observed), [])
 
     def test_reports_missing_and_unexpected_managed_links_without_mutating(self):
         state = copy.deepcopy(self.state)
@@ -64,10 +70,60 @@ class PipeWireObserverTests(unittest.TestCase):
         state["routing"]["managed_links"] = [
             {"from": "direct_mix", "to": PLAYBACK_0, "status": "planned"}
         ]
-        self.assertTrue(any("concrete UMC AUX port" in error for error in validate_managed_links(state)))
+        self.assertTrue(any("approved observed Rigforge or UMC port" in error for error in validate_managed_links(state)))
+
+    def test_declared_filter_mix_links_are_valid_and_match_observed_graph(self):
+        links = {
+            (CAPTURE_0, MIX_INPUT_0),
+            (CAPTURE_2, MIX_INPUT_2),
+            (MIX_OUTPUT, PLAYBACK_0),
+        }
+        self.assertEqual(validate_managed_links(self.state), [])
+        self.assertEqual(observe(self.state, links), [])
+
+    def test_reports_missing_filter_mix_link(self):
+        links = {
+            (CAPTURE_0, MIX_INPUT_0),
+            (MIX_OUTPUT, PLAYBACK_0),
+        }
+        reports = observe(self.state, links)
+        self.assertEqual(
+            reports,
+            [
+                {
+                    "kind": "missing",
+                    "from": CAPTURE_2,
+                    "to": MIX_INPUT_2,
+                    "action": "would-link",
+                }
+            ],
+        )
+
+    def test_reports_unexpected_link_between_managed_filter_ports(self):
+        state = copy.deepcopy(self.state)
+        state["routing"]["managed_ports"].append(CAPTURE_3)
+        links = {
+            (CAPTURE_0, MIX_INPUT_0),
+            (CAPTURE_2, MIX_INPUT_2),
+            (MIX_OUTPUT, PLAYBACK_0),
+            (CAPTURE_3, MIX_INPUT_2),
+        }
+        reports = observe(state, links)
+        self.assertEqual(
+            reports,
+            [
+                {
+                    "kind": "unexpected",
+                    "from": CAPTURE_3,
+                    "to": MIX_INPUT_2,
+                    "action": "would-review",
+                }
+            ],
+        )
 
     def test_managed_links_must_use_declared_ports(self):
         state = copy.deepcopy(self.state)
+        state["routing"]["managed_ports"].remove(PLAYBACK_0)
         state["routing"]["managed_links"] = [
             {"from": CAPTURE_0, "to": PLAYBACK_0, "status": "planned"}
         ]