Heartbeat and Failure Detection

A periodic liveness signal ('pulse') sent by a process or machine to prove it is still running healthily, paired with a mechanism to declare failure when the signal stops.

General Meaning

Background daemons and distributed nodes cannot announce 'I just crashed' when they suffer a power loss, kernel panic, or network cut.

Instead, each process periodically sends a small liveness signal—a heartbeat—to a monitor or central store. If no heartbeat arrives within a configured timeout window, the monitor detects a failure and triggers recovery actions such as restarting the process, failing over to a standby node, or reclaiming stalled tasks.

Why It Matters

  • Early detection of silent failures: Reliably catches freezes, power outages, and network drops that produce no error logs.
  • Preventing premature reclamation of live tasks: Proves that a worker running a long job is still alive, preventing a watchdog from launching a duplicate instance.
  • Providing objective operational evidence: Grounds health checks in recorded timestamps and error lists rather than guesswork.

How the Site Factory Uses It

The Site Factory uses heartbeats across its patrol loop and workers: patrol.py updates ops/watchdog/heartbeat.json every 15 minutes with updated_at, ok: true, merged PR lists, errors, and scanned repository counts. To keep Git history clean, heartbeat-only Git commits are forbidden—updates piggyback on real task commits, occur only when error/hold states change, or at most once per day.

When reclaiming tickets stuck in 進行中 for 1 hour without commits, the watchdog checks local heartbeats so live processes are never disrupted. Even when D1 free-tier circuit breakers pause new job dispatch, workers send an empty-capability heartbeat every 5 minutes so they are not mistaken for dead. Crucially, ops/progress_check.md mandates that a healthy heartbeat alone never proves the overall plan is on track.

Caveats & Operational Rules

  • A healthy heartbeat does not mean real work is progressing: A process can enter a 'zombie state' where its heartbeat loop keeps ticking while the underlying AI inference or task pipeline is stuck; always verify actual deliverable receipts (receipt).
  • Avoid hair-trigger timeouts on transient network blips: Declaring failure after a single delayed pulse causes unnecessary restarts and duplicate execution; always include a reasonable timeout grace period.
  • Never pollute Git history with raw heartbeats: Pushing a commit every few minutes just to record liveness bloats the repository; keep frequent heartbeats local or in D1 and commit to Git only on state changes.

Related Terms

References

  • Book: Martin Kleppmann, *Designing Data-Intensive Applications*, Chapter 8 (Unreliable Networks: Detecting Faults); Michael T. Nygard, *Release It!*

Verified: 2026-11-08