Component evidence

watchdogDecision (core/process-watchdog.ts)

gbrain · src/core/process-watchdog.ts · typescript · MIT
infratag:knn-classified

Pure decision logic for process watchdog timers and progress deadlines.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/garrytan/gbrain | License: MIT | Copyright 2026 Garry Tan
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Out-of-band hard-deadline watchdog (#1633).
 *
 * THE PROBLEM. A `gbrain sync` that spins (e.g. synchronous catastrophic-regex
 * in pack link-inference) STARVES the main event loop. When the loop never
 * yields, the SIGTERM handler (process-cleanup.ts) can't run, a `--timeout`
 * `setTimeout` can't fire, and the abort-flag checks between import iterations
 * can't run either. The process becomes unkillable-by-SIGTERM and, under cron,
 * orphans pile up for 24h+ (the reported incident). The ONLY thing that kills a
 * loop-starved process is an OS signal delivered from OUTSIDE that loop.
 *
 * THE MECHANISM. A Bun `worker_threads` W

... (truncated -- full source via MCP)