import type { Check } from '../types.js'; import type { EventLoopLagMonitor } from '../../server/event-loop-lag.js'; /** * RED when the daemon's event-loop p99 delay over the current window * exceeds P99_ALARM_MS. The 2026-07-15 incident stalled the loop 15–219s * with NOTHING measuring it — /health timed out (so the watchdog killed the * daemon) but no surface reported the stall as a number. This check is the * scheduled-doctor half of that measurement; /health's `event_loop` block * is the always-on half. * * Threshold reasoning: measured incident stalls were 15,000–219,000ms; 1s * is ~10x a healthy fast-path handler and 10x BELOW the watchdog's 10s * probe timeout — the alarm fires several escalation steps before the * watchdog would even consider acting. * * Two read paths: * - in-process (scheduled doctor inside the daemon): reads the live * monitor injected via DoctorCheckOpts.eventLoopLag. * - out-of-process (CLI `doctor`): fetches /health and reads the * `event_loop` block the daemon publishes. An unreachable daemon or a * build without the block reports inconclusive — this check did NOT * verify the loop is healthy and must not render as if it had * (catch-must-not-report-healthy discipline). * * Cold-start guard: a window younger than MIN_WINDOW_AGE_MS is * inconclusive, not GREEN — 30s of samples says nothing about a daemon * that stalls every few minutes. */ export declare const P99_ALARM_MS = 1000; /** * Separate alarm on the WORST single delay. monitorEventLoopDelay records * one histogram sample per stall regardless of its length — over a mature * 15-min window (~45k samples at 20ms resolution) a single catastrophic * 219s stall is ~0.002% of samples and moves p99 not at all. p99 catches * FREQUENT moderate lag; max catches the rare-but-severe incident class * that actually got the daemon killed on 2026-07-15. 5s (vs p99's 1s) * because a single one-off ~1s GC pause is normal life on Node, but any * single 5s+ block already ate half the watchdog's 10s probe timeout. */ export declare const MAX_ALARM_MS = 5000; export declare const MIN_WINDOW_AGE_MS = 60000; export declare function checkEventLoopLag(port: number, monitor?: EventLoopLagMonitor, fetchImpl?: typeof fetch): Check;