/** * reconciliation — restart recovery for task runtime (G-026 M1, ADR-0004 #12). * * Runs at startup. Scans persisted attempts + leases and classifies each * non-terminal attempt: * - resource alive + ownership verifiable → active (restore, do NOT re-dispatch) * - result present + resource gone → converge (roll up to task status) * - resource gone but exit reason unknown → incident (cleanup_unconfirmed) * - ownership cannot be verified (no lease / ambiguous) → frozen * * Never re-dispatches based on missing in-memory handles. Corrupt journal / * unknown runtime schema → fail closed via RuntimeCorruptError. */ import { RuntimeCorruptError, type AttemptMeta, type CleanupIncident, type RuntimeSnapshot, type TaskRuntimeLayout } from "./file-layout.js"; export type ReconcileOutcome = { kind: "ok"; clazz: "active" | "converge" | "incident" | "frozen" | "terminal" | "absent"; attemptId: string; } | { kind: "error"; message: string; attemptId?: string; }; export interface ReconcileResult { ok: boolean; outcomes: ReconcileOutcome[]; incidentsCreated: number; snapshot: RuntimeSnapshot | null; errors: string[]; } export interface ReconcileOptions { /** When true, write the rebuilt runtime.json snapshot after classification (default true). */ writeSnapshot?: boolean; } /** * Run reconciliation for a change. * Safe to call on any layout (new / legacy / mixed / absent). Legacy-only changes * are left untouched (read-only compatibility) except that a runtime index may * be created for observability. */ export declare function reconcile(layout: TaskRuntimeLayout, opts?: ReconcileOptions): Promise; /** Resolve an open incident by explicit action: verify resources gone → resolved. */ export declare function recoverIncident(layout: TaskRuntimeLayout, incidentId: string, opts?: { verification?: string; operator?: string; bypass?: boolean; }): Promise; export { RuntimeCorruptError, type AttemptMeta };