- Category: B. Software Architecture
- English term: Watchdog Timer / Watchdog Process
- Related: Heartbeat and Failure Detection · Lease (Leased Lock) · Uncertain State / In-Doubt State · Control Plane and Data Plane · Active-Standby Redundancy
General Meaning
Originating in embedded systems, a watchdog timer requires the main program to periodically reset ('pet') it; if the program freezes or crashes and fails to reset the timer, the watchdog times out and forces a recovery action.
In distributed systems and multi-agent operations, a watchdog is an external periodic process that scans workers and active tickets, detecting unresponsive tasks or expired leases and performing automated cleanup and re-queueing.
Why It Matters
- Self-healing without human intervention: Automatically reclaims tasks stalled by worker crashes or network drops so the loop keeps moving.
- Preventing permanent resource lockup: Releases abandoned locks and tickets stuck in
in-progressstate so another runner can take over. - Distinguishing normal long-running work from hung processes: Uses objective criteria such as recent commits, heartbeats, and live PIDs to judge liveness accurately.
How the Site Factory Uses It
In the Site Factory, the dispatcher patrol.py acts as the watchdog every 15 minutes across four targets: (1) Cloud work tickets (ops/cloud/*.md) marked 状態: 進行中 with no git commit for 1 hour (shortened from 6 hours on 2026-10-18) and no active local runner are reset to 待ち (waiting); and (2) Resident service leases in D1 with a 40-minute TTL are reclaimed automatically by a standby Mac when renewals stop.
In addition, (3) A2A execution_jobs whose leases expire are transitioned to uncertain for reconciliation rather than blindly marked success or failure; and (4) Post-merge production deployment checks record failure history and issue fix tickets until recovery is verified.
Caveats & Operational Rules
- Keep the watchdog itself lightweight: If the watchdog runs LLM inference or heavy builds, it will time out and halt system-wide monitoring;
patrol.pyis strictly an AI-free Python script. - Do not prematurely reclaim active tasks: Always check local heartbeats and active PIDs before resetting a ticket based on commit age alone.
- Never erase failure evidence: When recovering a stalled job, preserve error logs and failure indicators until a subsequent check genuinely passes.
Related Terms
- Heartbeat and Failure Detection
- Lease (Leased Lock)
- Uncertain State / In-Doubt State
- Control Plane and Data Plane
- Active-Standby Redundancy
References
- Book: Martin Kleppmann, *Designing Data-Intensive Applications*, Chapter 8 (Faults and Partial Failures: Timeouts and Unbounded Delays)
Verified: 2026-11-08