/** * The in-flight probe: is a dispatch in flight right now? * * THE DISPATCH LEDGER IS THE SOURCE OF TRUTH. The session's ledger — the * `active-dispatches.json` index plus the dispatch record each row names — is * the artifact that records what the auto-compact deferral is about: a * sub-agent that is running right now. The workflow graphs never carried that * fact. A dispatch node sits at `prepared` and no writer stamps a heartbeat * onto it, so a graph-backed probe could only ever answer "no"; the deferral * was unreachable in production for that reason alone. * * WHERE THE BOUNDARY SITS. This module is the pure half: it opens no file, * reads no clock of its own, and decides from the facts the reader hands it. * The reader lives in `../dispatch/dispatch-ledger-reader.js` and produces * plain data for the types below. That split is what keeps the decision * testable without a filesystem, and it is the reason the reader and the probe * are two modules rather than one. * * THE DIRECTION OF THE ANSWER. A wrongly deferred compaction is an * inconvenience; a compaction that lands in the middle of a batch is a lost * batch. So every unknown — a ledger that cannot be enumerated, a record that * cannot be read, a status this probe does not recognise, a freshness signal * that cannot be parsed — answers "in flight" and defers the compaction. */ /** * The freshness bound, shared with the deferral that uses it. A dispatch whose * freshness signal is older than this is not in flight any more. */ export declare const FRESH_RUNNING_THRESHOLD_MS: number; /** The dispatch record carried no freshness signal this probe could read. */ export declare const PEAKS_HEARTBEAT_MISSING = "PEAKS_HEARTBEAT_MISSING"; /** The ledger, or one of the records it names, could not be read. */ export declare const PEAKS_DISPATCH_LEDGER_UNREADABLE = "PEAKS_DISPATCH_LEDGER_UNREADABLE"; /** The record's status is not one this probe recognises. */ export declare const PEAKS_DISPATCH_STATUS_UNKNOWN = "PEAKS_DISPATCH_STATUS_UNKNOWN"; /** * One dispatch's ledger facts, as the reader found them. * * `absent` means the record file is gone, so no dispatch is running behind it — * the record IS the artifact that proves liveness, and without it there is * nothing running. `unreadable` means the record is there but cannot be * believed, which is an unknown, not an absence. */ export type LedgerDispatchFact = { readonly kind: 'absent'; readonly recordPath: string; } | { readonly kind: 'unreadable'; readonly recordPath: string; } | { readonly kind: 'record'; readonly recordPath: string; readonly status: string; readonly outcome: string; readonly lastBeatAt: string | null; readonly createdAt: string; readonly disposed: boolean; }; /** What the reader found in one session's dispatch ledger. */ export interface LedgerFacts { /** `absent` = the session has no ledger; `unreadable` = the ledger cannot be enumerated. */ readonly ledgerState: 'absent' | 'unreadable' | 'readable'; readonly dispatches: readonly LedgerDispatchFact[]; } export interface ProbeInput { readonly now: string; readonly ledger: LedgerFacts; readonly redLine?: boolean; } export interface ProbeWarning { readonly code: string; readonly message: string; readonly recordPath?: string; } export interface ProbeResult { readonly inFlightBatch: boolean; readonly shouldCompact: boolean; readonly deferPreCompact: boolean; readonly warnings: readonly ProbeWarning[]; readonly errors: readonly ProbeWarning[]; readonly reason: string; } /** * The decision. Pure: the ledger's facts go in, the answer comes out. * * Red-line compaction overrides the in-flight deferral, so a session at the * red line still asks the harness to compact. */ export declare function probeInFlightBatch(input: ProbeInput): ProbeResult;