Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): keep the idle watchdog fed during long segment cooldowns
[._.]/ Adam Eivy8f6c8fe04b17
diff --git a/docs/research/2026-06-13-mflux-training-watchdog-panic.md b/docs/research/2026-06-13-mflux-training-watchdog-panic.mdindex 325e9749e2..85e7bf5118 100644--- a/docs/research/2026-06-13-mflux-training-watchdog-panic.md+++ b/docs/research/2026-06-13-mflux-training-watchdog-panic.md@@ -130,8 +130,12 @@ swap thrash if a run oversubscribes unified memory.trade fewer reloads for a longer sustained window, raise `checkpointEvery`(which raises `save_frequency` = segment size) — but keep it below the~150–300-step crash window.- - The 30-min training idle watchdog (`WATCHDOG_TRAINING_MS`) comfortably- covers a cooldown + model reload, so segmentation does not trip it.+ - The cooldown emits a `STAGE:cooldown:heartbeat:<n>s` keep-alive every 30 s,+ which resets the mediaJobQueue idle watchdog (it only resets on emitted+ runner output). Without it a cooldown tuned above the 30-min+ `WATCHDOG_TRAINING_MS` window — `segmentCooldownSec` validates up to 3600 s —+ would get a healthy run killed mid-pause; with it, any cooldown length is+ safe.### Enabling the telemetry sidecar (passwordless powermetrics)diff --git a/scripts/train_mflux_lora.py b/scripts/train_mflux_lora.pyindex 242d8c22c6..835770423b 100644--- a/scripts/train_mflux_lora.py+++ b/scripts/train_mflux_lora.py@@ -135,14 +135,33 @@ def _terminate_child(timeout: float = 15.0) -> None:CHILD.kill()-def interruptible_sleep(seconds: float) -> None:- """Sleep up to `seconds`, returning early if a SIGTERM cancel arrives —- so the inter-segment cooldown never delays a user-requested stop."""- end = time.monotonic() + seconds+# Cooldown heartbeat cadence. The mediaJobQueue idle watchdog resets only on+# emitted runner output (progress.js emits 'activity' for every non-noise line),+# so a silent cooldown longer than the watchdog window would get a healthy run+# killed mid-pause. segmentCooldownSec is validated up to 3600s — above the 1800s+# default watchdog — so the cooldown MUST keep the watchdog fed itself rather than+# rely on the setting staying small.+HEARTBEAT_INTERVAL_SEC = 30+++def interruptible_sleep(seconds: float, heartbeat_stage: str | None = None) -> None:+ """Sleep up to `seconds`, returning early if a SIGTERM cancel arrives — so+ the inter-segment cooldown never delays a user-requested stop. When+ `heartbeat_stage` is set, emit a `STAGE:<stage>:heartbeat:<elapsed>s`+ keep-alive every HEARTBEAT_INTERVAL_SEC so the idle watchdog sees activity+ during a long pause (the `:heartbeat:` form resets the watchdog without+ emitting a status message or changing the displayed stage)."""+ start = time.monotonic()+ end = start + seconds+ next_beat = start + HEARTBEAT_INTERVAL_SECwhile not STOP_REQUESTED:- remaining = end - time.monotonic()+ now = time.monotonic()+ remaining = end - nowif remaining <= 0:return+ if heartbeat_stage and now >= next_beat:+ log(f"STAGE:{heartbeat_stage}:heartbeat:{int(now - start)}s")+ next_beat = now + HEARTBEAT_INTERVAL_SECtime.sleep(min(1.0, remaining))@@ -570,7 +589,7 @@ def main():final_code = 1breaklog(f"STATUS:segment {segment_index} complete at step {new_step}/{total} — cooling down {cooldown}s")- interruptible_sleep(cooldown)+ interruptible_sleep(cooldown, heartbeat_stage="cooldown")if STOP_REQUESTED:break