diff --git a/scripts/start-online-verse-daemons.ps1 b/scripts/start-online-verse-daemons.ps1 index a7df8e1..f220f13 100644 --- a/scripts/start-online-verse-daemons.ps1 +++ b/scripts/start-online-verse-daemons.ps1 @@ -13,9 +13,7 @@ param( [int]$MoveFps = 120, [int]$MoveFftSize = 256, [string[]]$Move = @( - "move-00-07-04-a3-97-72-usb=/dev/hidraw1:#35ff6c", - "move-00-07-04-a6-be-5f=/dev/hidraw2:#ff2a00", - "move-00-06-f5-23-e2-d1=/dev/hidraw3:#00a8ff" + "move-00-07-04-a3-97-72-usb=/dev/hidraw1:#35ff6c" ), [switch]$SkipRuntime, [switch]$SkipFensalir, @@ -308,6 +306,8 @@ if (-not $SkipMoves) { $moveArgs += "0.18" $moveArgs += "--bioacoustic-max-active-calls" $moveArgs += "3" + $moveArgs += "--bioacoustic-render-timeout-seconds" + $moveArgs += "15" foreach ($spec in $Move) { $moveArgs += "--move" $moveArgs += $spec diff --git a/src/Mimir.FensalirDaemon/Program.cs b/src/Mimir.FensalirDaemon/Program.cs index c02d418..06e6d14 100644 --- a/src/Mimir.FensalirDaemon/Program.cs +++ b/src/Mimir.FensalirDaemon/Program.cs @@ -1286,13 +1286,13 @@ internal sealed class FensalirDaemonEveServer(FensalirDaemonOptions options, Fen internal static class FensalirDaemonObserver { - private static readonly (string Id, string Name, string[] PidFiles)[] LocalDaemons = + private static readonly (string Id, string Name, string[] PidFiles, string[] ProcessNames)[] LocalDaemons = [ - ("verse-relay", "Verse relay", ["verse-relay-direct.pid", "verse-relay.pid"]), - ("verse-recorder", "Verse recorder", ["verse-recorder.pid"]), - ("mimir-well", "Mimir Well", ["mimir-well-rebased.pid", "mimir-well-fixed.pid", "mimir-well.pid"]), - ("move-sync", "Move sync", ["move-sync-lean.pid", "move-sync.pid"]), - ("fensalir", "Fensalir", ["fensalir-daemon.pid"]), + ("verse-relay", "Verse relay", ["verse-relay-direct.pid", "verse-relay.pid"], ["dotnet", "Mimir.EveSensorReceiver"]), + ("verse-recorder", "Verse recorder", ["verse-recorder.pid"], ["dotnet", "Mimir.VerseRecorder"]), + ("mimir-well", "Mimir Well", ["mimir-well-rebased.pid", "mimir-well-fixed.pid", "mimir-well.pid"], ["dotnet", "Mimir.Well"]), + ("move-sync", "Move sync", ["move-sync-lean.pid", "move-sync.pid"], ["python", "python3", "py"]), + ("fensalir", "Fensalir", ["fensalir-daemon.pid"], ["dotnet", "Mimir.FensalirDaemon"]), ]; public static IReadOnlyList Collect(FensalirDaemonOptions options) @@ -1310,7 +1310,7 @@ internal static class FensalirDaemonObserver foreach (var daemon in LocalDaemons) { - statuses.Add(ObserveLocal(runDir, daemon.Id, daemon.Name, daemon.PidFiles)); + statuses.Add(ObserveLocal(runDir, daemon.Id, daemon.Name, daemon.PidFiles, daemon.ProcessNames)); } return statuses @@ -1320,7 +1320,12 @@ internal static class FensalirDaemonObserver .ToArray(); } - private static ObservedDaemonStatus ObserveLocal(string runDir, string id, string name, IReadOnlyList pidFiles) + private static ObservedDaemonStatus ObserveLocal( + string runDir, + string id, + string name, + IReadOnlyList pidFiles, + IReadOnlyList expectedProcessNames) { foreach (var pidFile in pidFiles) { @@ -1339,7 +1344,18 @@ internal static class FensalirDaemonObserver try { using var process = Process.GetProcessById(pid); - return new ObservedDaemonStatus(id, name, pid, process.HasExited ? "stopped" : "online", pidFile); + if (process.HasExited) + { + return new ObservedDaemonStatus(id, name, pid, "stopped", pidFile); + } + + var processName = process.ProcessName; + if (!expectedProcessNames.Any(expected => processName.Equals(expected, StringComparison.OrdinalIgnoreCase))) + { + return new ObservedDaemonStatus(id, name, pid, "stale-pid", $"{pidFile} now belongs to {processName}"); + } + + return new ObservedDaemonStatus(id, name, pid, "online", $"{pidFile} {processName}"); } catch (ArgumentException) { diff --git a/state/evidence.jsonl b/state/evidence.jsonl index a2420b4..f598314 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -373,3 +373,4 @@ {"ts": "2026-06-03T05:13:42+01:00", "type": "implementation", "status": "ok", "note": "Presentation availability cut: MimirPresentationControlState now keeps user Enabled/Solo intent separate from derived Available/SampleCount. IncludesVideo requires live samples, so configured-but-starved video sources no longer occupy program output. Live Well verification after restart showed Kiyo Pro, Raven display, and Eve camera available=false/included=false, while Leap and Kiyo basic were available=true/included=true and synchronized frame stayed 6/6 Ready at 40 ms."} {"ts": "2026-06-03T05:20:09+01:00", "type": "implementation", "status": "ok", "note": "Mimir Well shakedown now defaults to the latest monotonic Well run instead of aggregating restarted ledgers; verified 20260602-233914 latest run at 1609 snapshots, 6/6 Ready after 120s and after 300s, recent presentation delay 40 ms. Remaining unavailable sources are source-health/device/network issues, not synchronized-frame collapse."} {"ts": "2026-06-03T05:25:36+01:00", "type": "implementation", "status": "ok", "note": "Well stream pressure now includes Mimir.Well sender-loop telemetry at the websocket send authority. Live restart of 20260602-233914 reached after-120 readiness 1.0 with 6/6 Ready, recent presentation delay 40 ms, sender queue depth 0, sender max about 10 ms, and no drops; historical enqueue max is not active wire pressure."} +{"ts": "2026-06-03T05:33:56+01:00", "type": "implementation", "status": "ok", "note": "Daemon-status cut: Fensalir now validates pid-file process identity before reporting local daemons online, so reused PIDs surface as stale-pid instead of false health. Move sync remote receiver imports errno, degrades on HID write failures, and bioacoustic render preflight has a timeout. Live supervisor now has relay, recorder, Fensalir, Well, and Move sync resolving to dotnet/exe/python identities; Well remains 6/6 Ready at 40 ms. Current Move sync is online but waiting on Realtek loopback frames, not crashed."} diff --git a/tools/online_move_music_sync.py b/tools/online_move_music_sync.py index 6e9832a..ee14050 100644 --- a/tools/online_move_music_sync.py +++ b/tools/online_move_music_sync.py @@ -32,6 +32,7 @@ MINOR_KEY_PROFILE = np.asarray([6.33, 2.68, 3.52, 5.38, 2.60, 3.53, 2.54, 4.75, REMOTE_MULTI_RECEIVER = r""" +import errno import os import sys import time @@ -1281,7 +1282,22 @@ class BioacousticRealtekTrigger: "--song", args.bioacoustic_song, ] - render = subprocess.run(render_cmd, cwd=Path(__file__).resolve().parents[1], capture_output=True, text=True) + try: + render = subprocess.run( + render_cmd, + cwd=Path(__file__).resolve().parents[1], + capture_output=True, + text=True, + timeout=max(1.0, float(args.bioacoustic_render_timeout_seconds)), + ) + except subprocess.TimeoutExpired as ex: + trigger.close() + render_out.append(f"## {role} seconds={seconds:.6f}\n{ex.stdout or ''}") + render_err.append(f"## {role} seconds={seconds:.6f}\n{ex.stderr or ''}\nrender timed out") + (out_dir / "bioacoustic-render.out.log").write_text("\n".join(render_out), encoding="utf-8") + (out_dir / "bioacoustic-render.err.log").write_text("\n".join(render_err), encoding="utf-8") + print(f"bioacoustic Realtek trigger disabled: {role} render timed out", file=sys.stderr, flush=True) + return None render_out.append(f"## {role} seconds={seconds:.6f}\n{render.stdout}") render_err.append(f"## {role} seconds={seconds:.6f}\n{render.stderr}") if render.returncode != 0 or not path.exists(): @@ -1483,6 +1499,7 @@ def main() -> int: parser.add_argument("--bioacoustic-loop-seconds", type=float, default=0.42) parser.add_argument("--bioacoustic-min-interval-seconds", type=float, default=0.18) parser.add_argument("--bioacoustic-max-active-calls", type=int, default=3) + parser.add_argument("--bioacoustic-render-timeout-seconds", type=float, default=15.0) args = parser.parse_args() out_dir = Path(args.out_dir) @@ -1540,6 +1557,7 @@ def main() -> int: trace_path = out_dir / "online-sync.jsonl" start = time.monotonic() frames = 0 + move_output_available = True try: with trace_path.open("w", encoding="utf-8") as trace: while time.monotonic() - start < args.duration: @@ -1579,12 +1597,22 @@ def main() -> int: for index, move in enumerate(moves): rgb = move_rgb(move, index, len(moves), state, args) rgbs[move.name] = rgb - ssh.stdin.write(f"{move.name} {rgb[0]} {rgb[1]} {rgb[2]}\n".encode("ascii")) + if move_output_available: + try: + ssh.stdin.write(f"{move.name} {rgb[0]} {rgb[1]} {rgb[2]}\n".encode("ascii")) + except OSError as ex: + move_output_available = False + print(f"move-output disabled during write: {ex}", file=sys.stderr, flush=True) for event in score_voice_events: move_index = int(event["move_index"]) if 0 <= move_index < len(moves): event["move_name"] = moves[move_index].name - ssh.stdin.flush() + if move_output_available: + try: + ssh.stdin.flush() + except OSError as ex: + move_output_available = False + print(f"move-output disabled during flush: {ex}", file=sys.stderr, flush=True) frames += 1 record = { "kind": "mimir.online_move_music_sync_frame.v1", @@ -1616,9 +1644,10 @@ def main() -> int: ) finally: try: - for move in moves: - ssh.stdin.write(f"{move.name} 0 0 0\n".encode("ascii")) - ssh.stdin.close() + if move_output_available: + for move in moves: + ssh.stdin.write(f"{move.name} 0 0 0\n".encode("ascii")) + ssh.stdin.close() except Exception: pass for proc in (wasapi, ssh):