fix(fleet): heartbeat consistency — honor MOSAIC_HOME + MOSAIC_HEARTBEAT_INTERVAL
Some checks failed
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was canceled

F3 milestone 1 — the two pre-existing HB bugs (from #584) flagged in the #590 review:
- writer (start-agent-session.sh): MOSAIC_HEARTBEAT_RUN_DIR now defaults to
  ${MOSAIC_HOME:-$HOME/.config/mosaic}/fleet/run, matching the path `fleet ps`
  reads (heartbeatPath uses the resolved mosaicHome). Fixes false "stale/unknown"
  HB on custom MOSAIC_HOME deployments.
- reader (fleet.ts): new heartbeatIntervalMs() honors MOSAIC_HEARTBEAT_INTERVAL
  (seconds); parseHeartbeat's freshness threshold now matches the writer's actual
  cadence instead of a hardcoded 15s. + vitest coverage.

Validated: custom-home writer dir == reader path; interval 30 -> 30000ms, unset
-> 15000ms; prettier clean.

Refs #542 #588

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-21 18:16:48 -05:00
parent 31e7a4d25e
commit 6a80378e73
3 changed files with 29 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ MOSAIC_TMUX_SOCKET=${MOSAIC_TMUX_SOCKET:-mosaic-factory}
MOSAIC_AGENT_RUNTIME=${MOSAIC_AGENT_RUNTIME:-pi}
MOSAIC_AGENT_WORKDIR=${MOSAIC_AGENT_WORKDIR:-$HOME}
MOSAIC_AGENT_COMMAND=${MOSAIC_AGENT_COMMAND:-}
MOSAIC_HEARTBEAT_RUN_DIR=${MOSAIC_HEARTBEAT_RUN_DIR:-$HOME/.config/mosaic/fleet/run}
MOSAIC_HEARTBEAT_RUN_DIR=${MOSAIC_HEARTBEAT_RUN_DIR:-${MOSAIC_HOME:-$HOME/.config/mosaic}/fleet/run}
MOSAIC_HEARTBEAT_INTERVAL=${MOSAIC_HEARTBEAT_INTERVAL:-15}
if [ -z "$AGENT_NAME" ]; then