import { type CompiledGraph, type GraphDefinition } from "../core/graph.js"; import { type ArtifactReference, type GraphCheckpointRef, type GraphEvent, type GraphExecutionState, type SchedulerMetadata } from "../core/scheduler.js"; export interface GraphCheckpointPaths { root: string; state: string; graph: string; events: string; nodes: string; mutations: string; executionLease: string; } export interface GraphCheckpointLease { owner: string; nonce: string; pid: number; createdAt: string; dev: number | bigint; ino: number | bigint; } export interface CheckpointMutationOptions { owner: Readonly; /** Deterministic race-injection hook; production callers leave this unset. */ beforeAppend?(): void; } export type CheckpointFailurePoint = "after-event-append" | "after-snapshot-temp-write" | "after-snapshot-rename"; export interface SnapshotWriteOptions extends CheckpointMutationOptions { tempId: string; expectedRevision?: number; expectedSnapshotHash?: string; failAt?(point: CheckpointFailurePoint): void; } export interface LeaseOptions { now: string; pid: number; nonce?: string; isProcessAlive?(pid: number): boolean; beforeStaleLeaseRemove?(): void; } export interface LeaseReleaseOptions { beforeLeaseRemove?(): void; } export interface ImmutableGraphCheckpoint { schemaVersion: 1; graphDigest: string; metadataFingerprint: string; runId: string; genesisHash: string; genesisState: GraphExecutionState; definition: GraphDefinition; schedulerMetadata: SchedulerMetadata; graph: CompiledGraph; } export declare const MAX_GRAPH_CHECKPOINT_BYTES: number; export declare const MAX_GRAPH_SNAPSHOT_BYTES: number; export declare const MAX_GRAPH_EVENT_BYTES: number; export declare const MAX_GRAPH_EVENT_LOG_BYTES: number; export declare const MAX_GRAPH_EVENTS = 8192; export declare const MAX_NODE_ARTIFACT_BYTES: number; export declare function createGraphCheckpointPaths(root: string): GraphCheckpointPaths; export declare function assertGraphCheckpointPathsSafe(paths: GraphCheckpointPaths): void; export declare function acquireGraphCheckpointLease(paths: GraphCheckpointPaths, owner: string, options: LeaseOptions): GraphCheckpointLease; export declare function ownsGraphCheckpointLease(paths: GraphCheckpointPaths, lease: Readonly): boolean; export declare function releaseGraphCheckpointLease(paths: GraphCheckpointPaths, lease: Readonly, options?: LeaseReleaseOptions): boolean; export declare function writeImmutableGraphCheckpoint(paths: GraphCheckpointPaths, graph: CompiledGraph, metadata: SchedulerMetadata, genesisState: Readonly, options: CheckpointMutationOptions): void; export declare function readImmutableGraphCheckpoint(paths: GraphCheckpointPaths): ImmutableGraphCheckpoint; export declare function writeNodeArtifact(paths: GraphCheckpointPaths, input: { owner: Readonly; planVersion: number; nodeId: string; contract: string; bytes: Uint8Array; }): ArtifactReference; export declare function readNodeArtifact(paths: GraphCheckpointPaths, reference: Readonly): Buffer; export declare function writeGraphMutationArtifact(paths: GraphCheckpointPaths, input: { owner: Readonly; mutationId: string; bytes: Uint8Array; }): GraphCheckpointRef; export declare function readGraphMutationArtifact(paths: GraphCheckpointPaths, reference: Readonly): Buffer; export declare function appendGraphEvent(paths: GraphCheckpointPaths, event: Readonly, options: CheckpointMutationOptions): void; export declare function readGraphEvents(paths: GraphCheckpointPaths): GraphEvent[]; export declare function writeGraphSnapshot(paths: GraphCheckpointPaths, graph: CompiledGraph, state: Readonly, options: SnapshotWriteOptions): void; export declare function readGraphSnapshot(paths: GraphCheckpointPaths, graph?: CompiledGraph): GraphExecutionState; export declare function replayGraphEvents(graph: CompiledGraph, snapshot: Readonly, events: readonly Readonly[], genesis: Readonly): GraphExecutionState; export declare function graphSnapshotDigest(state: Readonly): string; export declare function checkpointGraphEvent(input: { graph: CompiledGraph; paths: GraphCheckpointPaths; state: Readonly; event: Readonly; owner: Readonly; tempId: string; failAt?(point: CheckpointFailurePoint): void; }): GraphExecutionState; /** * Durably reserves the next scheduler artifact namespace before any re-plan * provider spend. This does not approve or replace a business-level plan. */ export declare function checkpointPlanVersionReservation(input: { graph: CompiledGraph; paths: GraphCheckpointPaths; state: Readonly; nodeId: string; activationRef: Readonly; checkpointRef?: Readonly; eventId: string; timestamp: string; unattended: boolean; owner: Readonly; tempId: string; failAt?(point: CheckpointFailurePoint): void; }): GraphExecutionState;