/** * Durable Mission Graph — execution engine, state machines, replay and reboot * recovery (2.0.0). * * Pure and deterministic where possible; I/O is delegated to MissionStore. The * engine enforces the mission policy (scope, dependencies, approvals, * blockers, budgets, leases) and never lets routing, evaluation or objective- * granted authority override it. */ import type { ApprovalDecision, ExternalBlockerState, MissionGraphDocumentV1, MissionOperationResult, MissionStatus, ObjectiveStatus, ProcessRecord, RepositoryLease } from "./types.js"; export interface MissionRuntimeState { missionId: string; graphRevision: number; objectiveStatus: Record; /** gateId -> decision. */ approvals: Record; /** specId -> blocker state. */ blockers: Record; /** objectiveId -> spent cost. */ spentCost: Record; process?: ProcessRecord; createdAtMs: number; updatedAtMs: number; } export interface MissionStatePair { document: MissionGraphDocumentV1; runtime: MissionRuntimeState; } export declare function initializeRuntime(document: MissionGraphDocumentV1, nowMs?: number): MissionRuntimeState; export interface TransitionRequest { objectiveId: string; from: ObjectiveStatus; to: ObjectiveStatus; } export declare function isLegalTransition(from: ObjectiveStatus, to: ObjectiveStatus): boolean; export interface ReadinessView { status: Record; unreadyReasons: Record; } export declare function deriveReadiness(document: MissionGraphDocumentV1, runtime: MissionRuntimeState, nowMs?: number): ReadinessView; export declare function promoteMission(document: MissionGraphDocumentV1, nowMs?: number): MissionOperationResult; export declare function startObjective(document: MissionGraphDocumentV1, runtime: MissionRuntimeState, objectiveId: string, leases: RepositoryLease[], processRecord: Omit, nowMs?: number): MissionOperationResult; export declare function completeObjective(document: MissionGraphDocumentV1, runtime: MissionRuntimeState, objectiveId: string, acceptanceCriterionIds: string[], nowMs?: number): MissionOperationResult; export declare function failObjective(runtime: MissionRuntimeState, objectiveId: string, nowMs?: number): MissionOperationResult; export declare function recordApproval(runtime: MissionRuntimeState, gateId: string, decision: ApprovalDecision): MissionRuntimeState; export declare function recordBlocker(runtime: MissionRuntimeState, specId: string, state: ExternalBlockerState): MissionRuntimeState; export declare function missionStatus(document: MissionGraphDocumentV1, runtime: MissionRuntimeState): MissionStatus; /** * Derive the runtime state deterministically from a list of event ids plus the * authority to re-apply approvals/blockers. Because the engine transitions are * pure and events are append-only, replaying the same events yields the same * state and never performs external effects (no file mutation, no git, no PR). */ export declare function replayRuntime(document: MissionGraphDocumentV1, eventIds: string[], approvals: ApprovalDecision[], blockers: ExternalBlockerState[], nowMs?: number): { runtime: MissionRuntimeState; appliedCount: number; }; export interface RebootReconciliationResult { runtime: MissionRuntimeState; actions: string[]; processRecordedMissing: boolean; } /** * Reconcile a mission after a reboot. Any objective that was IN_PROGRESS is * reverted to READY so it can be re-run (or resumed from its checkpoint) * without duplicating committed external work. Independent completed work is * preserved exactly. Stale process authority is never reused. */ export declare function reconcileAfterReboot(document: MissionGraphDocumentV1, runtime: MissionRuntimeState, processStillExists: boolean, nowMs?: number): RebootReconciliationResult; /** A mission cannot expand its own scope: new declared repos are rejected. */ export declare function canExpandScope(document: MissionGraphDocumentV1, proposedObjectives: MissionGraphDocumentV1["objectives"]): boolean; //# sourceMappingURL=engine.d.ts.map