/** * Mission Store — C2 durable persistence. * * Layout under /missions//: * mission.json — rebuildable snapshot/cache (NOT the authority) * ledger.jsonl — append-only, SHA-256 hash-chained event log (authority) * ledger-chain.json — chain head hash for tamper detection * .lock — cross-process exclusive lock (created with O_EXCL) * * Rules: * - Ledger is always written before mission.json is updated. * - mission.json is written atomically (temp file → rename). * - Cross-process lock is held during every write; stale locks (>8s) are removed. * - CAS revision must match before any write is accepted. * - Corrupt or unverifiable ledger data fails closed. * - Workspace isolation: all paths are under caller-supplied runsRoot. */ import type { MissionDecision, MissionEvent, MissionRecord, MissionRunRole, MissionStatus } from "../../contracts/index.js"; export declare function missionDir(runsRoot: string, missionId: string): string; /** * Read the current mission snapshot. * Returns null when no mission exists at this path. * Fails closed when the snapshot schema version is not recognised. */ export declare function readMission(runsRoot: string, missionId: string): Promise; export declare function readMissionLedger(runsRoot: string, missionId: string): Promise; export interface LedgerIntegrityResult { ok: boolean; reason?: string; entryCount: number; } /** * Verify the stored chain head matches a full replay of the ledger. * Returns ok=false when the ledger has been tampered with or entries are missing. */ export declare function verifyMissionLedger(runsRoot: string, missionId: string): Promise; export declare function createMission(runsRoot: string, mission: MissionRecord): Promise; export interface AttachRunOptions { loopId: string; role: MissionRunRole; verifiedOutcome?: boolean; actualUsd?: number; now?: () => string; /** Expected revision for CAS enforcement. */ expectedRevision: number; } export declare function attachRun(runsRoot: string, missionId: string, options: AttachRunOptions): Promise; export interface ChangeMissionStatusOptions { toStatus: MissionStatus; expectedRevision: number; decidedBy?: string; decision?: MissionDecision; note?: string; now?: () => string; } export declare function changeMissionStatus(runsRoot: string, missionId: string, options: ChangeMissionStatusOptions): Promise;