import type { Check } from '../types.js'; /** * Reads the shim's exit-history.jsonl (see service/shim.ts's * exitHistoryPaths()/appendExitHistory in LAUNCHER_SOURCE) and RED-flags a * crash loop: >= `threshold` consecutive non-zero exits in the tail of the * history. Counting walks backward from the newest entry and stops at the * first exitCode === 0 — a clean run (including the instance lock's healthy * <100ms fast-exit, AC-5) always resets the streak, distinguished from a * real crash purely by exitCode, not durationMs (both exit 0; durationMs is * carried in the record for a human/dashboard to eyeball, not used here as * a gate). */ /** * Consecutive-non-zero-exit threshold shared by two independent consumers so * they can never drift apart: `checkCrashLoop`'s own RED/GREEN finding below, * and the full-tier LLM/embed boot-pass guard in schedule.ts's * `runFullDoctorChecks` (2026-07-13 #226 follow-up finding 2 — a * crash-looping daemon must not keep firing a metered LLM/embed call on * every restart, indefinitely, with no operator in the loop). */ export declare const CRASH_LOOP_THRESHOLD = 3; /** * FEAT-541: self-clear window. A crash-looping daemon restarts every * keepalive cycle and never accumulates uptime — but once the CURRENT process * has stayed up this long without exiting, it is by definition no longer * looping, regardless of how bad the historical tail in exit-history.jsonl * looks. Before this fix the streak walk below was purely historical: a * daemon that crash-looped once, days ago, and has been rock-solid ever * since stayed permanently RED (and kept suppressing `runFullDoctorChecks`'s * LLM/embed probes via `crashLoopStreakLength`'s threshold gate in * schedule.ts — see this constant's other consumer there) because nothing * ever reset the streak short of a clean exit. 15 minutes matches the * frequent 'cheap'-tier doctor cadence (`FREQUENT_DOCTOR_INTERVAL_MS` in * schedule.ts) — long enough that a flapping restart loop can't accidentally * self-clear mid-flap, short enough that a genuinely-recovered daemon isn't * stuck RED for a full day waiting on the 'full' tier. */ export declare const CRASH_LOOP_STABLE_UPTIME_MS: number; /** * Streak length of consecutive non-zero exits at the tail of * exit-history.jsonl — the same walk `checkCrashLoop` performs for its own * finding below, factored out so schedule.ts's crash-loop guard can reuse it * without depending on `CheckResult`'s shape or duplicating the parse logic. * Never throws: an unreadable/missing/malformed history degrades to 0 (no * crash loop) — a doctor-history read glitch must never itself become the * reason a genuine restart's LLM/embed probe silently never fires again. * * FEAT-541: decays to 0 once the current process has been up for * `CRASH_LOOP_STABLE_UPTIME_MS` — see that constant's doc comment. This is * the fix schedule.ts's `runFullDoctorChecks` gate relies on: it calls this * function directly, so a stable-uptime daemon naturally un-suppresses the * LLM/embed probes without schedule.ts itself changing. */ export declare function crashLoopStreakLength(dataDir: string, uptimeMsOverride?: number): number; export declare function checkCrashLoop(dataDir: string, threshold?: number, uptimeMsOverride?: number): Check;