Johan Le Baut 2 tygodni temu
rodzic
commit
85a834496c
3 zmienionych plików z 34 dodań i 10 usunięć
  1. 1 1
      README.md
  2. 25 9
      scripts/observe_pipewire.py
  3. 8 0
      tests/test_pipewire_observer.py

+ 1 - 1
README.md

@@ -64,7 +64,7 @@ An explicit one-shot mode can create missing declared links after checking that
 python3 scripts/observe_pipewire.py --reconcile-once
 ```
 
-This mode never removes an unlisted link, changes undeclared connections, or restarts services. It attempts declared additions first and removes explicitly listed stale links only after every desired managed link is visible; if any desired link remains missing, removals are deferred. It then re-reads the graph and reports remaining differences. Use it only during a safe test window: repaired or removed links can immediately change audible routing. Unit tests use simulated `pw-link` results.
+This mode never removes an unlisted link, changes undeclared connections, or restarts services. It attempts declared additions first and removes explicitly listed stale links only after every desired managed link is visible; if any desired link remains missing, removals are deferred. An `unavailable-port` action names the missing endpoint and its expected direction; missing `effect_0`/`effect_1` ports include a hint to start/check mod-host and plugin loading. It then re-reads the graph and reports remaining differences. Use it only during a safe test window: repaired or removed links can immediately change audible routing. 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. 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.
 

+ 25 - 9
scripts/observe_pipewire.py

@@ -197,15 +197,31 @@ def reconcile_once(state, runner=subprocess.run):
         for report in missing_links:
             source = report["from"]
             destination = report["to"]
-            if source not in outputs or destination not in inputs:
-                actions.append(
-                    {
-                        "kind": "unavailable-port",
-                        "from": source,
-                        "to": destination,
-                        "result": "not-linked",
-                    }
-                )
+            unavailable = []
+            if source not in outputs:
+                unavailable.append({"port": source, "direction": "output"})
+            if destination not in inputs:
+                unavailable.append({"port": destination, "direction": "input"})
+            if unavailable:
+                action = {
+                    "kind": "unavailable-port",
+                    "from": source,
+                    "to": destination,
+                    "missing_ports": unavailable,
+                    "result": "not-linked",
+                    "reason": (
+                        "required PipeWire port(s) are not present in the current graph"
+                    ),
+                }
+                if any(
+                    item["port"].startswith(("effect_0:", "effect_1:"))
+                    for item in unavailable
+                ):
+                    action["hint"] = (
+                        "mod-host must be running and load the NAM/IR plugins to expose "
+                        "effect_0/effect_1 ports"
+                    )
+                actions.append(action)
                 continue
             try:
                 runner(

+ 8 - 0
tests/test_pipewire_observer.py

@@ -330,7 +330,13 @@ class PipeWireObserverTests(unittest.TestCase):
                     "kind": "unavailable-port",
                     "from": CAPTURE_0,
                     "to": AMP_INPUT,
+                    "missing_ports": [{"port": AMP_INPUT, "direction": "input"}],
                     "result": "not-linked",
+                    "reason": "required PipeWire port(s) are not present in the current graph",
+                    "hint": (
+                        "mod-host must be running and load the NAM/IR plugins to expose "
+                        "effect_0/effect_1 ports"
+                    ),
                 },
                 {"kind": "link", "from": AMP_OUTPUT, "to": CAB_INPUT, "result": "requested"},
                 {"kind": "link", "from": CAB_OUTPUT, "to": MIX_INPUT_0, "result": "requested"},
@@ -434,7 +440,9 @@ class PipeWireObserverTests(unittest.TestCase):
                 "kind": "unavailable-port",
                 "from": CAPTURE_2,
                 "to": MIX_INPUT_2,
+                "missing_ports": [{"port": CAPTURE_2, "direction": "output"}],
                 "result": "not-linked",
+                "reason": "required PipeWire port(s) are not present in the current graph",
             }],
         )
         self.assertTrue(result["differences"])