import type { BreakerCellRow } from "./circuit-breaker.js"; export type { BreakerCellRow } from "./circuit-breaker.js"; /** Bumped when the MEANING of an existing field changes, never when an optional field is added. */ export declare const CURRENT_BREAKER_STATE_VERSION = 1; export interface BreakerStateFile { version: number; rows: BreakerCellRow[]; } export declare function getBreakerStatePath(): string; /** * Read all valid rows. Absent file, unreadable file, wrong version, or an envelope * that is not `{version, rows: []}` all yield an empty list — never a throw, and never a partial * cooldown built from a shape we did not recognize. * * Expired rows are KEPT — a lapsed cooldown restores as lapsed, and its escalation counter * stays with it. The running process does not discard a lapsed cooldown's counter. */ export declare function loadBreakerState(opts?: { path?: string; }): BreakerCellRow[]; export declare function saveBreakerState(rows: readonly BreakerCellRow[], opts?: { path?: string; }): void; export interface BreakerPersistenceHandle { /** Rows applied at install — the count a caller can report, as before. */ readonly restored: number; /** Write NOW when a change is still unflushed; a clean timer writes nothing. True when it wrote. */ flush(): boolean; } /** * Wire a breaker to the file: restore every cell, then flush on every change. * * Writes are debounced through the shared `WriteBehindTimer` — the same scheduler the catalog, * probe cache and runtime telemetry use — so a burst of outcomes costs one write, not one per * outcome. The handle's `flush()` and the module-level `flushBreakerPersistence()` are the same * mechanism (`WriteBehindTimer.flushNow`), so a test and a shutdown cannot disagree about what a * flush does. */ export declare function installBreakerPersistence(breaker: { restoreState(rows: readonly BreakerCellRow[]): number; exportState(): BreakerCellRow[]; onStateChanged(listener: () => void): void; }, opts?: { path?: string; }): BreakerPersistenceHandle; /** * The shutdown seam: write every dirty breaker file NOW. `runProxy` calls it beside the sibling * flushes in both shutdown sites. Returns how many files were written. */ export declare function flushBreakerPersistence(): number;