Module heartbeat

Module heartbeat 

Source
Expand description

Heartbeat worker: every 60s posts to /v1/agent/heartbeat with current_closure + uptime_secs + last_event_seq_by_rollout. Reads CP’s X-Nixfleet-Replay-From response header; on drift the intent is to walk the durable outbound queue from that seq and re-POST the missed events.

v0.2 scope: real POST loop only. The Replay-From walk-and-replay is intentionally deferred — when CP signals drift today we log a warning so operators see it. The durable queue (7d) and the outbound drainer (7c) already give us crash-safe at-least-once delivery for forward progress; Replay-From is a recovery optimization for the case where CP lost state, which the recovery handshake (7f) also covers on agent restart.

Constants§

ERROR_BACKOFF 🔒
HEARTBEAT_INTERVAL 🔒
60s heartbeat cadence. Plan 06 + RFC-0005 §4.3 — same window as the long-poll’s wait window so a stuck agent stops heartbeating within roughly one polling interval.
HTTP_TIMEOUT 🔒

Functions§

heartbeat_once 🔒
spawn