import { type LifecycleState } from "../core/lifecycle.js"; import { type ArtifactReference, type ExecutionLimits, type GraphEvent } from "../core/scheduler.js"; import { type CheckpointFailurePoint, type GraphCheckpointLease, type GraphCheckpointPaths } from "../runtime/graphCheckpoint.js"; export interface RunPaths extends GraphCheckpointPaths { spec: string; plan: string; debug: string; journal: string; routing: string; evidence: string; } export interface RoutingTraceRecord { decisionId: string; runId: string; stage: string; recordedAt: string; plan: unknown; attempts: readonly { provider: string; model: string; outcome: "selected" | "unavailable" | "unconfigured"; }[]; } export interface CreateRunOptions { executionLimits?: Readonly; /** Deterministic allocator hook for adversarial collision tests. */ runIdFactory?(): string; } export interface LifecycleMigrationOptions { migrationLimits?: Readonly; } export interface LifecycleWriteOptions extends LifecycleMigrationOptions { owner?: Readonly; } export interface LifecycleAppendOptions { owner: Readonly; /** Failure-injection hook used to exercise a path swap immediately before open. */ beforeOpen?(): void; /** Failure-injection hook used to exercise lease/path changes immediately before write. */ beforeWrite?(): void; } export interface ReleaseRunOptions { beforeCurrentPointerRemove?(): void; beforeRegistryRemove?(): void; } export interface LifecycleNodeResultRecord { schemaVersion: 1; kind: "lifecycle-node-result"; runId: string; nodeId: string; contract: string; nextState: LifecycleState; payload: Record; contentSource: "spec" | "plan" | "debug" | "payload"; contentRef: ArtifactReference; } export declare function createRun(cwd: string, artifactsDir: string, task: string, yolo?: boolean, options?: CreateRunOptions): { runId: string; paths: RunPaths; }; export declare function currentRun(cwd: string, artifactsDir: string): { runId: string; paths: RunPaths; } | undefined; export declare function readState(paths: RunPaths, options?: LifecycleMigrationOptions): LifecycleState | undefined; /** Reads one mutable semantic lifecycle artifact through a bounded, no-follow descriptor. */ export declare function readLifecycleArtifactBounded(paths: RunPaths, path: string): Buffer | undefined; export declare function writeState(paths: RunPaths, state: LifecycleState, options?: LifecycleWriteOptions): void; export declare function ensureLifecycleGraphCheckpoint(paths: RunPaths, owner: Readonly, options?: LifecycleMigrationOptions): void; export declare function writeLifecycleNodeResult(paths: RunPaths, input: { owner: Readonly; graphState: NonNullable; nodeId: string; contract: string; nextState: LifecycleState; payload?: Record; }): ArtifactReference; export declare function readLifecycleNodeResult(paths: RunPaths, reference: Readonly, options?: { verifyLiveArtifact?: boolean; }): LifecycleNodeResultRecord; export declare function writeLifecyclePlanVersionIntent(paths: RunPaths, input: { owner: Readonly; graphState: NonNullable; nodeId: string; }): ArtifactReference; export declare function reconcileLifecycleCheckpoint(paths: RunPaths, options: { owner: Readonly; tempId: string; migrationLimits?: Readonly; }): LifecycleState; export declare function checkpointLifecycleGraphEvent(paths: RunPaths, current: LifecycleState, event: Readonly, options: { owner: Readonly; tempId: string; nextState?: LifecycleState; failAt?(point: CheckpointFailurePoint): void; }): LifecycleState; export declare function appendJournal(paths: RunPaths, line: string, options: LifecycleAppendOptions): void; export declare function appendRoutingTrace(paths: RunPaths, record: RoutingTraceRecord, options: LifecycleAppendOptions): void; export declare function acquireRunLease(paths: RunPaths, owner: string): GraphCheckpointLease; export declare function ownsRunLease(paths: RunPaths, owner: Readonly): boolean; export declare function releaseRunLease(paths: RunPaths, owner: Readonly): boolean; export declare function releaseRun(cwd: string, artifactsDir: string, runId: string, options?: ReleaseRunOptions): boolean; export declare function pathsForRun(cwd: string, artifactsDir: string, runId: string): RunPaths; export declare function assertRunPathsSafe(paths: RunPaths): void;