소스 검색

fix startup

Johan Le Baut 1 주 전
부모
커밋
4dd4cc8407

+ 1 - 1
AGENTS.md

@@ -15,7 +15,7 @@ The current target is Debian GNU/Linux 13 on AArch64 with a Behringer UMC404HD 1
 - `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.
+- `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.

+ 1 - 1
README.md

@@ -150,7 +150,7 @@ Remove the service with `./scripts/deploy.sh uninstall sooperlooper`.
 
 `scripts/generate_mod_ui_pedalboard.py` builds the reference bundle from the YAML: one NAM defaulting to Vox AC15 Crystal Clean TB, one LSP mono IR using the Vox AC30 asset, the declared NAM output level, the guitar NAM→IR chain, and three mod-ui-owned passthrough arcs. During `install mod-ui`, deployment copies the declared NAM models into Rigforge's dedicated `MOD_USER_FILES_DIR/NAM Models/Rigforge` directory and generates a target-specific bundle whose model path points there; the model copies are fingerprinted and removed only if unchanged when mod-ui is uninstalled. The reference bundle is also target-specific, fingerprinted, and protected from local edits. mod-ui resumes its last saved board across service restarts within the same boot. `./scripts/deploy.sh reset mod-ui` explicitly restores the generated reference and backs up any prior default board and last-state file as adjacent `.rigforge-reset-backup` paths.
 
-On each system boot, `rigforge-mod-ui.service` now runs `scripts/prepare_mod_ui_pedalboard.py` before launching mod-ui. It regenerates and validates the content-addressed reference bundle from the checkout, replaces the mutable `default.pedalboard` with that clean board, and moves any previous default and last-state file into `mod-ui/boot-backups`, outside the pedalboard scan directory. It also migrates older Rigforge backups out of that scan directory. A marker under the user runtime directory makes this happen only once per boot; a mod-ui service restart during the same boot preserves in-session changes. If generation or validation fails, mod-ui does not start with a blank board. At readiness, the service waits for both guitar PipeWire boundary links; saved-board connection restoration retries briefly while mod-host plugin ports appear. These changes are covered by repository tests but have not yet been deployed or verified on the target.
+On each system boot, `rigforge-mod-ui.service` runs `scripts/prepare_mod_ui_pedalboard.py` before launching mod-ui. It regenerates and validates the content-addressed reference bundle from the checkout, replaces the mutable `default.pedalboard` with that clean board, and moves any previous default and last-state file into `mod-ui/boot-backups`, outside the pedalboard scan directory. It also migrates older Rigforge backups out of that scan directory. A marker under the user runtime directory makes this happen only once per boot; a mod-ui service restart during the same boot preserves in-session changes. If generation or validation fails, mod-ui does not start with a blank board. During pedalboard loading, the mod-ui integration retries PipeWire boundary links asynchronously so plugin-port creation can proceed on its event loop. The service then waits up to 35 seconds for both guitar links before reporting readiness. This behavior is covered by repository tests but has not yet been deployed or verified on the target.
 
 If `install mod-ui` refuses a changed but registry-managed reference bundle, first inspect why it differs. To explicitly replace only that bundle while preserving its current contents, use `./scripts/deploy.sh install mod-ui --force-reference`; the old bundle is retained in an adjacent `.rigforge-force-backup` path. This flag does not override local edits to the systemd unit, model files, or other managed paths.
 

+ 39 - 8
artifacts/mod-ui/arm64/current/app/mod/host.py

@@ -4368,6 +4368,36 @@ class Host(object):
 
             self.monitor_cpu_load_new_plugin(instance_id)
 
+    def _rigforge_restore_pipewire_boundary(
+        self, pipewire_link, port_from, port_to, connection_list, attempts_left
+    ):
+        if self.connections is not connection_list:
+            return
+
+        if connect_link(*pipewire_link):
+            edge = (port_from, port_to)
+            if edge not in connection_list:
+                connection_list.append(edge)
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            return
+
+        if attempts_left <= 1:
+            logging.error(
+                "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
+                pipewire_link[0], pipewire_link[1]
+            )
+            return
+
+        IOLoop.instance().call_later(
+            0.5,
+            self._rigforge_restore_pipewire_boundary,
+            pipewire_link,
+            port_from,
+            port_to,
+            connection_list,
+            attempts_left - 1
+        )
+
     def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
                                                mappedNewMidiIns, mappedNewMidiOuts):
         for c in connections:
@@ -4403,14 +4433,15 @@ class Host(object):
                     continue
                 pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
                 if pipewire_link is not None:
-                    if not connect_link(*pipewire_link, retries=60, retry_interval=0.1):
-                        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._rigforge_restore_pipewire_boundary(
+                        pipewire_link,
+                        port_from,
+                        port_to,
+                        self.connections,
+                        attempts_left=60
+                    )
+                    continue
+                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))
 

+ 1 - 1
artifacts/mod-ui/arm64/current/provenance.json

@@ -9,7 +9,7 @@
   "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": "d2f8a85b8b73975cd78f37b4d0f9ebc5bc8f743d74aee1f66c7c5cb5215e9418",
+  "rigforge_integration_patch_sha256": "495933893df4df7b2b5e6942b23e279a8128dfa1aaf4d80fb656da52356b8e3b",
   "license": "AGPL-3.0-or-later",
   "rigforge_pipewire_helper": "build/arm64/mod_ui_pipewire.py",
   "rigforge_pipewire_helper_sha256": "f95fd65e0a7352dc90a178b3afbce084a95db583b3ee67a7472afaebbc0d74e2"

+ 70 - 2
build/arm64/patch_mod_ui_rigforge.py

@@ -247,9 +247,45 @@ def apply(source_root):
     )
     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))
+        '''    def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
+                                               mappedNewMidiIns, mappedNewMidiOuts):
 ''',
+        '''    def _rigforge_restore_pipewire_boundary(
+        self, pipewire_link, port_from, port_to, connection_list, attempts_left
+    ):
+        if self.connections is not connection_list:
+            return
+
+        if connect_link(*pipewire_link):
+            edge = (port_from, port_to)
+            if edge not in connection_list:
+                connection_list.append(edge)
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            return
+
+        if attempts_left <= 1:
+            logging.error(
+                "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
+                pipewire_link[0], pipewire_link[1]
+            )
+            return
+
+        IOLoop.instance().call_later(
+            0.5,
+            self._rigforge_restore_pipewire_boundary,
+            pipewire_link,
+            port_from,
+            port_to,
+            connection_list,
+            attempts_left - 1
+        )
+
+    def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
+                                               mappedNewMidiIns, mappedNewMidiOuts):
+''',
+    )
+    replace_if_present(
+        app / "mod" / "host.py",
         '''                pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
                 if pipewire_link is not None:
                     if not connect_link(*pipewire_link, retries=60, retry_interval=0.1):
@@ -261,6 +297,38 @@ def apply(source_root):
                 else:
                     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:
+                    self._rigforge_restore_pipewire_boundary(
+                        pipewire_link,
+                        port_from,
+                        port_to,
+                        self.connections,
+                        attempts_left=60
+                    )
+                    continue
+                self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
+                self.connections.append((port_from, port_to))
+''',
+    )
+    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:
+                    self._rigforge_restore_pipewire_boundary(
+                        pipewire_link,
+                        port_from,
+                        port_to,
+                        self.connections,
+                        attempts_left=60
+                    )
+                    continue
+                self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
+                self.connections.append((port_from, port_to))
 ''',
     )
     replace_once(

+ 4 - 0
scripts/run_mod_ui_service.py

@@ -13,6 +13,9 @@ from mod_ui_websocket import ModUiWebSocketClient
 from observe_pipewire import parse_pw_link_output
 
 
+PIPEWIRE_BOUNDARY_TIMEOUT = 35
+
+
 def guitar_boundary_links(capture_ports, playback_ports):
     captures = [port.strip() for port in capture_ports if port.strip()]
     playbacks = [port.strip() for port in playback_ports if port.strip()]
@@ -118,6 +121,7 @@ def run_service(
                     capture_ports,
                     playback_ports,
                     runner=pw_link_runner,
+                    timeout=PIPEWIRE_BOUNDARY_TIMEOUT,
                 )
             print("mod-ui pedalboard loaded; keeping its mod-host session active")
         while not stopping[0]:

+ 4 - 4
tests/test_mod_ui_pipewire.py

@@ -152,10 +152,10 @@ class ModUiPipeWireTests(unittest.TestCase):
 
         self.assertEqual(helper_artifact.read_bytes(), helper_source)
         self.assertIn("from mod.rigforge_pipewire import", host_source)
-        self.assertIn(
-            "connect_link(*pipewire_link, retries=60, retry_interval=0.1)",
-            host_source,
-        )
+        self.assertIn("def _rigforge_restore_pipewire_boundary(", host_source)
+        self.assertIn("IOLoop.instance().call_later(", host_source)
+        self.assertIn("attempts_left=60", host_source)
+        self.assertNotIn("retries=60, retry_interval=0.1", host_source)
         self.assertEqual(host_source.count("PipeWire backend failed to restore ports"), 1)
         self.assertIn("disconnect_link(*pipewire_link)", host_source)
         self.assertEqual(