Quellcode durchsuchen

modui handles links inside modhost

Johan Le Baut vor 1 Woche
Ursprung
Commit
71c65638ae

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 1
README.md


+ 56 - 1
artifacts/mod-ui/arm64/current/app/mod/host.py

@@ -31,6 +31,7 @@ try:
 except ImportError:
     pass
 
+from mod.rigforge_pipewire import boundary_connection, connect_link, disconnect_link
 from mod import (
     TextFileFlusher,
     get_hardware_descriptor, get_nearest_valid_scalepoint_value, get_unique_name,
@@ -3687,12 +3688,36 @@ class Host(object):
         instance_id = self.mapper.get_id_without_creating(instance)
         return "effect_%d:%s" % (instance_id, portsymbol)
 
+    def _rigforge_pipewire_boundary(self, port_from, port_to):
+        return boundary_connection(
+            port_from,
+            port_to,
+            self.rigforge_capture_port,
+            self.rigforge_playback_port,
+            self._fix_host_connection_port,
+        )
+
     def connect(self, port_from, port_to, callback):
         if (port_from, port_to) in self.connections:
             logging.info("[host] NOTE: Requested connection already exists")
             callback(True)
             return
 
+        pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+        if pipewire_link is not None:
+            ok = connect_link(*pipewire_link)
+            callback(ok)
+            if ok:
+                self.connections.append((port_from, port_to))
+                self.pedalboard_modified = True
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            else:
+                logging.error(
+                    "[host] PipeWire backend failed to connect ports: '%s' => '%s'",
+                    pipewire_link[0], pipewire_link[1]
+                )
+            return
+
         def host_callback(ok):
             callback(ok)
             if ok:
@@ -3706,6 +3731,27 @@ class Host(object):
                            host_callback, datatype='boolean')
 
     def disconnect(self, port_from, port_to, callback):
+        pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+        if pipewire_link is not None:
+            ok = disconnect_link(*pipewire_link)
+            callback(ok)
+            if ok:
+                self.msg_callback("disconnect %s %s" % (port_from, port_to))
+                self.pedalboard_modified = True
+                try:
+                    self.connections.remove((port_from, port_to))
+                except ValueError:
+                    logging.info(
+                        "[host] Requested '%s' => '%s' connection was not in the UI state",
+                        port_from, port_to
+                    )
+            else:
+                logging.error(
+                    "[host] PipeWire backend failed to disconnect ports: '%s' => '%s'",
+                    pipewire_link[0], pipewire_link[1]
+                )
+            return
+
         def host_callback(ok):
             # always return true. disconnect failures are not fatal, but still print error for debugging
             callback(True)
@@ -4337,7 +4383,16 @@ class Host(object):
                     port_to_2   = self._fix_host_connection_port(port_to)
                 except:
                     continue
-                self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
+                pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+                if pipewire_link is not None:
+                    if not connect_link(*pipewire_link):
+                        logging.error(
+                            "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
+                            pipewire_link[0], pipewire_link[1]
+                        )
+                        continue
+                else:
+                    self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
                 self.connections.append((port_from, port_to))
                 self.msg_callback("connect %s %s" % (port_from, port_to))
 

+ 70 - 0
artifacts/mod-ui/arm64/current/app/mod/rigforge_pipewire.py

@@ -0,0 +1,70 @@
+"""PipeWire link helpers used by the Rigforge mod-ui host integration."""
+
+import subprocess
+
+
+def boundary_connection(
+    port_from,
+    port_to,
+    capture_port,
+    playback_port,
+    resolve_host_port,
+):
+    """Translate mod-ui graph boundary cables to concrete PipeWire ports."""
+    if port_from == "/graph/capture_1" and capture_port:
+        return capture_port, resolve_host_port(port_to)
+    if port_to == "/graph/playback_1" and playback_port:
+        return resolve_host_port(port_from), playback_port
+    return None
+
+
+def _link_status(source, destination, runner):
+    try:
+        result = runner(
+            ["pw-link", "-l"],
+            check=False,
+            capture_output=True,
+            text=True,
+        )
+    except OSError:
+        return None
+    if result.returncode != 0:
+        return None
+
+    current_port = None
+    for line in result.stdout.splitlines():
+        if line.startswith("  |-> "):
+            if current_port == source and line.removeprefix("  |-> ") == destination:
+                return True
+        elif line.startswith("  |<- "):
+            if current_port == destination and line.removeprefix("  |<- ") == source:
+                return True
+        else:
+            current_port = line.strip()
+    return False
+
+
+def connect_link(source, destination, runner=subprocess.run):
+    try:
+        result = runner(
+            ["pw-link", source, destination],
+            check=False,
+            capture_output=True,
+            text=True,
+        )
+    except OSError:
+        return False
+    return result.returncode == 0 or _link_status(source, destination, runner) is True
+
+
+def disconnect_link(source, destination, runner=subprocess.run):
+    try:
+        result = runner(
+            ["pw-link", "-d", source, destination],
+            check=False,
+            capture_output=True,
+            text=True,
+        )
+    except OSError:
+        return False
+    return result.returncode == 0 or _link_status(source, destination, runner) is False

+ 4 - 2
artifacts/mod-ui/arm64/current/provenance.json

@@ -9,6 +9,8 @@
   "additional_python_requirement": "backports.ssl_match_hostname==3.7.0.1",
   "python_compatibility_patch": "Tornado 4.3 collections.MutableMapping to collections.abc.MutableMapping",
   "rigforge_integration_patch": "build/arm64/patch_mod_ui_rigforge.py",
-  "rigforge_integration_patch_sha256": "a0a6135bfa05e4e1ae5843fd46589b961dd6588f02c02dc1fcdd819d2a27b8f6",
-  "license": "AGPL-3.0-or-later"
+  "rigforge_integration_patch_sha256": "8742e8b3c5c503b2e4dec62ec953054d271b77a235c5875c64323c375041fe2e",
+  "license": "AGPL-3.0-or-later",
+  "rigforge_pipewire_helper": "build/arm64/mod_ui_pipewire.py",
+  "rigforge_pipewire_helper_sha256": "0820e7d21c140a273834ef1395998de250c46996e3a8a7ef4c1eb5a68d8db078"
 }

+ 3 - 0
build/arm64/build-mod-ui.sh

@@ -138,6 +138,7 @@ python3 -m pip list --path "$staging_directory/vendor" --format=freeze \
 
 native_library_sha256=$(sha256sum "$staging_directory/app/modtools/libmod_utils.so" | cut -d ' ' -f 1)
 rigforge_patch_sha256=$(sha256sum "$repository_root/build/arm64/patch_mod_ui_rigforge.py" | cut -d ' ' -f 1)
+rigforge_pipewire_helper_sha256=$(sha256sum "$repository_root/build/arm64/mod_ui_pipewire.py" | cut -d ' ' -f 1)
 cat > "$staging_directory/provenance.json" <<EOF
 {
   "source_url": "$source_url",
@@ -151,6 +152,8 @@ cat > "$staging_directory/provenance.json" <<EOF
   "python_compatibility_patch": "Tornado 4.3 collections.MutableMapping to collections.abc.MutableMapping",
   "rigforge_integration_patch": "build/arm64/patch_mod_ui_rigforge.py",
   "rigforge_integration_patch_sha256": "$rigforge_patch_sha256",
+  "rigforge_pipewire_helper": "build/arm64/mod_ui_pipewire.py",
+  "rigforge_pipewire_helper_sha256": "$rigforge_pipewire_helper_sha256",
   "license": "AGPL-3.0-or-later"
 }
 EOF

+ 70 - 0
build/arm64/mod_ui_pipewire.py

@@ -0,0 +1,70 @@
+"""PipeWire link helpers used by the Rigforge mod-ui host integration."""
+
+import subprocess
+
+
+def boundary_connection(
+    port_from,
+    port_to,
+    capture_port,
+    playback_port,
+    resolve_host_port,
+):
+    """Translate mod-ui graph boundary cables to concrete PipeWire ports."""
+    if port_from == "/graph/capture_1" and capture_port:
+        return capture_port, resolve_host_port(port_to)
+    if port_to == "/graph/playback_1" and playback_port:
+        return resolve_host_port(port_from), playback_port
+    return None
+
+
+def _link_status(source, destination, runner):
+    try:
+        result = runner(
+            ["pw-link", "-l"],
+            check=False,
+            capture_output=True,
+            text=True,
+        )
+    except OSError:
+        return None
+    if result.returncode != 0:
+        return None
+
+    current_port = None
+    for line in result.stdout.splitlines():
+        if line.startswith("  |-> "):
+            if current_port == source and line.removeprefix("  |-> ") == destination:
+                return True
+        elif line.startswith("  |<- "):
+            if current_port == destination and line.removeprefix("  |<- ") == source:
+                return True
+        else:
+            current_port = line.strip()
+    return False
+
+
+def connect_link(source, destination, runner=subprocess.run):
+    try:
+        result = runner(
+            ["pw-link", source, destination],
+            check=False,
+            capture_output=True,
+            text=True,
+        )
+    except OSError:
+        return False
+    return result.returncode == 0 or _link_status(source, destination, runner) is True
+
+
+def disconnect_link(source, destination, runner=subprocess.run):
+    try:
+        result = runner(
+            ["pw-link", "-d", source, destination],
+            check=False,
+            capture_output=True,
+            text=True,
+        )
+    except OSError:
+        return False
+    return result.returncode == 0 or _link_status(source, destination, runner) is False

+ 114 - 0
build/arm64/patch_mod_ui_rigforge.py

@@ -16,6 +16,16 @@ def replace_once(path, original, replacement):
 
 def apply(source_root):
     app = Path(source_root)
+    helper_source = Path(__file__).with_name("mod_ui_pipewire.py")
+    helper_target = app / "mod" / "rigforge_pipewire.py"
+    helper_target.write_bytes(helper_source.read_bytes())
+
+    replace_once(
+        app / "mod" / "host.py",
+        "from mod import (\n",
+        "from mod.rigforge_pipewire import boundary_connection, connect_link, disconnect_link\n"
+        "from mod import (\n",
+    )
 
     replace_once(
         app / "mod" / "host.py",
@@ -64,6 +74,110 @@ def apply(source_root):
                     self.cvportsOut.append(CV_PREFIX + port_name)
                 else:
                     self.audioportsOut.append(port_name)
+''',
+    )
+    replace_once(
+        app / "mod" / "host.py",
+        '''    def connect(self, port_from, port_to, callback):
+        if (port_from, port_to) in self.connections:
+''',
+        '''    def _rigforge_pipewire_boundary(self, port_from, port_to):
+        return boundary_connection(
+            port_from,
+            port_to,
+            self.rigforge_capture_port,
+            self.rigforge_playback_port,
+            self._fix_host_connection_port,
+        )
+
+    def connect(self, port_from, port_to, callback):
+        if (port_from, port_to) in self.connections:
+''',
+    )
+    replace_once(
+        app / "mod" / "host.py",
+        '''        def host_callback(ok):
+            callback(ok)
+            if ok:
+                self.connections.append((port_from, port_to))
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            else:
+                logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
+
+        self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
+''',
+        '''        pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+        if pipewire_link is not None:
+            ok = connect_link(*pipewire_link)
+            callback(ok)
+            if ok:
+                self.connections.append((port_from, port_to))
+                self.pedalboard_modified = True
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            else:
+                logging.error(
+                    "[host] PipeWire backend failed to connect ports: '%s' => '%s'",
+                    pipewire_link[0], pipewire_link[1]
+                )
+            return
+
+        def host_callback(ok):
+            callback(ok)
+            if ok:
+                self.connections.append((port_from, port_to))
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            else:
+                logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
+
+        self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
+''',
+    )
+    replace_once(
+        app / "mod" / "host.py",
+        '''    def disconnect(self, port_from, port_to, callback):
+        def host_callback(ok):
+''',
+        '''    def disconnect(self, port_from, port_to, callback):
+        pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+        if pipewire_link is not None:
+            ok = disconnect_link(*pipewire_link)
+            callback(ok)
+            if ok:
+                self.msg_callback("disconnect %s %s" % (port_from, port_to))
+                self.pedalboard_modified = True
+                try:
+                    self.connections.remove((port_from, port_to))
+                except ValueError:
+                    logging.info(
+                        "[host] Requested '%s' => '%s' connection was not in the UI state",
+                        port_from, port_to
+                    )
+            else:
+                logging.error(
+                    "[host] PipeWire backend failed to disconnect ports: '%s' => '%s'",
+                    pipewire_link[0], pipewire_link[1]
+                )
+            return
+
+        def host_callback(ok):
+        ''',
+    )
+    replace_once(
+        app / "mod" / "host.py",
+        '''                self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
+                self.connections.append((port_from, port_to))
+''',
+        '''                pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+                if pipewire_link is not None:
+                    if not connect_link(*pipewire_link):
+                        logging.error(
+                            "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
+                            pipewire_link[0], pipewire_link[1]
+                        )
+                        continue
+                else:
+                    self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
+                self.connections.append((port_from, port_to))
 ''',
     )
     replace_once(

+ 1 - 82
scripts/run_mod_ui_service.py

@@ -8,68 +8,7 @@ import sys
 import time
 from pathlib import Path
 
-import yaml
-
 from mod_ui_websocket import ModUiWebSocketClient
-from observe_pipewire import list_ports, parse_pw_link_output
-
-
-def mod_ui_audio_boundary_links(state):
-    chain = state["routing"]["mod_host_chains"]["guitar"]
-    processors = chain["processors"]
-    if not processors:
-        raise ValueError("the mod-ui guitar chain has no processors")
-    return (
-        (chain["source_port"], processors[0]["input_port"]),
-        (processors[-1]["output_port"], chain["mod_ui_output_port"]),
-    )
-
-
-def ensure_mod_ui_audio_links(state, runner=subprocess.run):
-    """Restore only the two board-to-boundary audio cables owned by mod-ui."""
-    result = runner(
-        ["pw-link", "-l"],
-        check=True,
-        capture_output=True,
-        text=True,
-    )
-    links = parse_pw_link_output(result.stdout)
-    expected = mod_ui_audio_boundary_links(state)
-    missing = [edge for edge in expected if edge not in links]
-    if not missing:
-        return 0
-
-    outputs = list_ports(runner, "-o")
-    inputs = list_ports(runner, "-i")
-    for source, destination in missing:
-        if source not in outputs:
-            raise RuntimeError(f"mod-ui audio source port is unavailable: {source}")
-        if destination not in inputs:
-            raise RuntimeError(f"mod-ui audio destination port is unavailable: {destination}")
-        runner(
-            ["pw-link", source, destination],
-            check=True,
-            capture_output=True,
-            text=True,
-        )
-        print(f"Restored mod-ui audio cable: {source} -> {destination}")
-
-    result = runner(
-        ["pw-link", "-l"],
-        check=True,
-        capture_output=True,
-        text=True,
-    )
-    remaining = [
-        edge for edge in expected
-        if edge not in parse_pw_link_output(result.stdout)
-    ]
-    if remaining:
-        source, destination = remaining[0]
-        raise RuntimeError(
-            f"mod-ui audio cable is still missing after repair: {source} -> {destination}"
-        )
-    return len(missing)
 
 
 def run_service(
@@ -79,9 +18,7 @@ def run_service(
     port,
     websocket_path,
     timeout,
-    state,
     popen=subprocess.Popen,
-    pw_link_runner=subprocess.run,
 ):
     process = popen([str(pw_jack), str(launcher)])
     stopping = [False]
@@ -93,8 +30,6 @@ def run_service(
     old_int = signal.signal(signal.SIGINT, request_stop)
     client = ModUiWebSocketClient(host, port, websocket_path, timeout=2)
     deadline = time.monotonic() + timeout
-    repair_audio_links = False
-    next_audio_link_repair = 0.0
     try:
         while not stopping[0]:
             if process.poll() is not None:
@@ -116,7 +51,6 @@ def run_service(
                     raise RuntimeError(f"mod-ui launcher exited with status {process.returncode}")
                 message = client.serve_once(timeout=0.5)
                 if message and message.startswith("loading_end "):
-                    repair_audio_links = True
                     break
                 if time.monotonic() >= deadline:
                     raise RuntimeError("mod-ui did not finish loading a pedalboard before timeout")
@@ -124,19 +58,7 @@ def run_service(
         while not stopping[0]:
             if process.poll() is not None:
                 raise RuntimeError(f"mod-ui launcher exited with status {process.returncode}")
-            message = client.serve_once(timeout=0.5)
-            if message and message.startswith("loading_end "):
-                repair_audio_links = True
-                next_audio_link_repair = 0.0
-            if repair_audio_links and time.monotonic() >= next_audio_link_repair:
-                try:
-                    repaired = ensure_mod_ui_audio_links(state, runner=pw_link_runner)
-                    if repaired == 0:
-                        print("mod-ui audio boundary cables are already connected")
-                    repair_audio_links = False
-                except (OSError, subprocess.CalledProcessError, RuntimeError, ValueError) as error:
-                    print(f"ERROR: could not ensure mod-ui audio boundary cables: {error}", file=sys.stderr)
-                    next_audio_link_repair = time.monotonic() + 2.0
+            client.serve_once(timeout=0.5)
     finally:
         signal.signal(signal.SIGTERM, old_term)
         signal.signal(signal.SIGINT, old_int)
@@ -167,8 +89,6 @@ def main(argv=None):
         print(f"ERROR: pw-jack is missing: {args.pw_jack}", file=sys.stderr)
         return 1
     try:
-        with (root / "config" / "desired-state.yaml").open(encoding="utf-8") as stream:
-            state = yaml.safe_load(stream)
         run_service(
             args.launcher,
             args.pw_jack,
@@ -176,7 +96,6 @@ def main(argv=None):
             args.port,
             args.websocket_path,
             args.timeout,
-            state,
         )
     except (OSError, RuntimeError, ValueError) as error:
         print(f"ERROR: {error}", file=sys.stderr)

+ 131 - 0
tests/test_mod_ui_pipewire.py

@@ -0,0 +1,131 @@
+import hashlib
+import json
+import sys
+import unittest
+from pathlib import Path
+from types import SimpleNamespace
+
+ROOT = Path(__file__).resolve().parents[1]
+sys.path.insert(0, str(ROOT / "build" / "arm64"))
+
+from mod_ui_pipewire import boundary_connection, connect_link, disconnect_link
+
+
+class FakePwLink:
+    def __init__(self, links=()):
+        self.links = set(links)
+        self.commands = []
+
+    def __call__(self, command, **_kwargs):
+        self.commands.append(command)
+        if command == ["pw-link", "-l"]:
+            output = "\n".join(
+                f"{source}\n  |-> {destination}"
+                for source, destination in sorted(self.links)
+            )
+            return SimpleNamespace(returncode=0, stdout=output, stderr="")
+        if len(command) == 3 and command[0] == "pw-link" and command[1] != "-d":
+            edge = (command[1], command[2])
+            if edge in self.links:
+                return SimpleNamespace(returncode=1, stdout="", stderr="already linked")
+            self.links.add(edge)
+            return SimpleNamespace(returncode=0, stdout="", stderr="")
+        if len(command) == 4 and command[:2] == ["pw-link", "-d"]:
+            edge = (command[2], command[3])
+            if edge not in self.links:
+                return SimpleNamespace(returncode=1, stdout="", stderr="not linked")
+            self.links.remove(edge)
+            return SimpleNamespace(returncode=0, stdout="", stderr="")
+        raise AssertionError(f"unexpected command: {command}")
+
+
+class ModUiPipeWireTests(unittest.TestCase):
+    def resolve(self, port):
+        return {
+            "/graph/rigforge_nam/input": "effect_0:input",
+            "/graph/rigforge_ir/out": "effect_1:out",
+        }[port]
+
+    def test_maps_only_rigforge_boundary_edges_to_pipewire_ports(self):
+        capture = "rigforge.mod-host-input.capture:capture_AUX0"
+        playback = "rigforge.mod-host-output.playback:playback_AUX0"
+
+        self.assertEqual(
+            boundary_connection(
+                "/graph/capture_1",
+                "/graph/rigforge_nam/input",
+                capture,
+                playback,
+                self.resolve,
+            ),
+            (capture, "effect_0:input"),
+        )
+        self.assertEqual(
+            boundary_connection(
+                "/graph/rigforge_ir/out",
+                "/graph/playback_1",
+                capture,
+                playback,
+                self.resolve,
+            ),
+            ("effect_1:out", playback),
+        )
+        self.assertIsNone(
+            boundary_connection(
+                "/graph/rigforge_nam/output",
+                "/graph/rigforge_ir/in",
+                capture,
+                playback,
+                self.resolve,
+            )
+        )
+
+    def test_pipewire_connect_is_idempotent_and_disconnect_tracks_actual_link(self):
+        edge = (
+            "rigforge.mod-host-input.capture:capture_AUX0",
+            "effect_0:input",
+        )
+        runner = FakePwLink()
+
+        self.assertTrue(connect_link(*edge, runner=runner))
+        self.assertIn(edge, runner.links)
+        self.assertTrue(connect_link(*edge, runner=runner))
+        self.assertTrue(disconnect_link(*edge, runner=runner))
+        self.assertNotIn(edge, runner.links)
+        self.assertTrue(disconnect_link(*edge, runner=runner))
+
+    def test_unexpected_pw_link_failure_is_not_reported_as_success(self):
+        def fail_connect(command, **_kwargs):
+            return SimpleNamespace(returncode=1, stdout="", stderr="connection refused")
+
+        self.assertFalse(
+            connect_link(
+                "rigforge.mod-host-input.capture:capture_AUX0",
+                "effect_0:input",
+                runner=fail_connect,
+            )
+        )
+
+    def test_tracked_mod_ui_artifact_matches_its_rebuild_patch_and_provenance(self):
+        artifact = ROOT / "artifacts/mod-ui/arm64/current"
+        helper_source = (ROOT / "build/arm64/mod_ui_pipewire.py").read_bytes()
+        helper_artifact = artifact / "app/mod/rigforge_pipewire.py"
+        host_source = (artifact / "app/mod/host.py").read_text(encoding="utf-8")
+        provenance = json.loads((artifact / "provenance.json").read_text(encoding="utf-8"))
+
+        self.assertEqual(helper_artifact.read_bytes(), helper_source)
+        self.assertIn("from mod.rigforge_pipewire import", host_source)
+        self.assertIn("connect_link(*pipewire_link)", host_source)
+        self.assertIn("disconnect_link(*pipewire_link)", host_source)
+        self.assertEqual(
+            provenance["rigforge_integration_patch_sha256"],
+            hashlib.sha256((ROOT / "build/arm64/patch_mod_ui_rigforge.py").read_bytes()).hexdigest(),
+        )
+        self.assertEqual(
+            provenance["rigforge_pipewire_helper_sha256"],
+            hashlib.sha256(helper_source).hexdigest(),
+        )
+
+
+if __name__ == "__main__":
+    unittest.main()

+ 0 - 94
tests/test_run_mod_ui_service.py

@@ -1,94 +0,0 @@
-import sys
-import unittest
-from pathlib import Path
-from types import SimpleNamespace
-
-ROOT = Path(__file__).resolve().parents[1]
-sys.path.insert(0, str(ROOT / "scripts"))
-
-import yaml
-
-from run_mod_ui_service import ensure_mod_ui_audio_links, mod_ui_audio_boundary_links
-
-
-class FakePwLink:
-    def __init__(self, links, outputs, inputs):
-        self.links = set(links)
-        self.outputs = set(outputs)
-        self.inputs = set(inputs)
-        self.added = []
-
-    def __call__(self, command, **_kwargs):
-        if command == ["pw-link", "-l"]:
-            output = "\n".join(
-                f"{source}\n  |-> {destination}"
-                for source, destination in sorted(self.links)
-            )
-            return SimpleNamespace(stdout=output)
-        if command == ["pw-link", "-o"]:
-            return SimpleNamespace(stdout="\n".join(sorted(self.outputs)))
-        if command == ["pw-link", "-i"]:
-            return SimpleNamespace(stdout="\n".join(sorted(self.inputs)))
-        if len(command) == 3 and command[0] == "pw-link":
-            edge = (command[1], command[2])
-            if edge[0] not in self.outputs or edge[1] not in self.inputs:
-                raise RuntimeError(f"invalid fake PipeWire connection: {edge}")
-            self.links.add(edge)
-            self.added.append(edge)
-            return SimpleNamespace(stdout="")
-        raise AssertionError(f"unexpected command: {command}")
-
-
-class ModUiServiceAudioLinkTests(unittest.TestCase):
-    @classmethod
-    def setUpClass(cls):
-        with (ROOT / "config" / "desired-state.yaml").open(encoding="utf-8") as stream:
-            cls.state = yaml.safe_load(stream)
-        cls.expected = mod_ui_audio_boundary_links(cls.state)
-
-    def make_runner(self, links=(), missing_inputs=()):
-        outputs = {
-            "rigforge.mod-host-input.capture:capture_AUX0",
-            "effect_1:out",
-        }
-        inputs = {
-            "effect_0:input",
-            "rigforge.mod-host-output.playback:playback_AUX0",
-        } - set(missing_inputs)
-        return FakePwLink(links, outputs, inputs)
-
-    def test_repairs_only_the_two_missing_board_boundary_cables(self):
-        existing = {
-            ("effect_0:output", "effect_1:in"),
-            ("unrelated:source", "unrelated:sink"),
-        }
-        runner = self.make_runner(existing)
-
-        repaired = ensure_mod_ui_audio_links(self.state, runner=runner)
-
-        self.assertEqual(repaired, 2)
-        self.assertEqual(set(runner.added), set(self.expected))
-        self.assertTrue(set(self.expected).issubset(runner.links))
-        self.assertIn(("unrelated:source", "unrelated:sink"), runner.links)
-        self.assertIn(("effect_0:output", "effect_1:in"), runner.links)
-
-    def test_is_idempotent_when_board_boundary_cables_exist(self):
-        runner = self.make_runner(self.expected)
-
-        repaired = ensure_mod_ui_audio_links(self.state, runner=runner)
-
-        self.assertEqual(repaired, 0)
-        self.assertEqual(runner.added, [])
-
-    def test_reports_missing_plugin_port_without_adding_partial_links(self):
-        runner = self.make_runner(missing_inputs={"effect_0:input"})
-
-        with self.assertRaisesRegex(RuntimeError, "destination port is unavailable"):
-            ensure_mod_ui_audio_links(self.state, runner=runner)
-
-        self.assertEqual(runner.added, [])
-        self.assertFalse(set(self.expected) & runner.links)
-
-
-if __name__ == "__main__":
-    unittest.main()

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.