import { type WorkerContextForkReference } from "../orchestration/worker-context-fork-reference.ts"; import type { SanitizedContextForkMessage } from "./sanitized-context-fork.ts"; export declare const MAX_RETAINED_WORKER_CONTEXT_FORK_SNAPSHOTS: number; export type WorkerContextForkStoreErrorCode = "capacity_reached" | "identity_conflict" | "identity_claimed" | "snapshot_corrupt" | "snapshot_missing"; /** Stable failure classification for controller admission and recovery wiring. */ export declare class WorkerContextForkStoreError extends Error { readonly code: WorkerContextForkStoreErrorCode; constructor(code: WorkerContextForkStoreErrorCode, message: string, cause?: unknown); } export interface WorkerContextForkSnapshot extends WorkerContextForkReference { parentSessionId: string; logicalAgentId: string; messages: SanitizedContextForkMessage[]; } export interface CaptureWorkerContextForkRequest { /** * Newly admitted persistent specialist. Follow-up tasks reuse its durable conversation and must * reopen, never replace, this one birth snapshot. */ logicalAgentId: string; messages: readonly SanitizedContextForkMessage[]; } export interface OpenWorkerContextForkRequest { logicalAgentId: string; reference: WorkerContextForkReference; } /** * Cross-process transaction input for the capture-before-dispatch boundary. The durable-reference * reader is invoked while the capture lock is held, so reclamation never relies on a stale snapshot * gathered before lock acquisition. `prepare` must synchronously persist or adopt the dispatch. */ export interface CaptureAndPrepareWorkerContextForkRequest extends CaptureWorkerContextForkRequest { readDurableReferences: () => readonly WorkerContextForkReference[]; /** Rechecked under the capture lock so a fresh start never adopts another caller's dispatch. */ isLogicalIdentityClaimed?: () => boolean; prepare: (reference: WorkerContextForkReference) => T; } export interface CaptureAndPrepareWorkerContextForkResult { reference: WorkerContextForkReference; value: T; } /** * Immutable, per-session store for the exact sanitized message snapshot inherited by a new logical * worker. Capture is synchronous so the caller can commit the snapshot before admitting dispatch. * Identity is deliberately `(parentSessionId, logicalAgentId)`: persistent-agent follow-up tasks * continue the existing transcript and cannot install a second birth context. */ export declare class WorkerContextForkStore { private readonly agentDir; private readonly parentSessionId; private readonly directory; private readonly lockFile; constructor(options: { agentDir: string; parentSessionId: string; }); capture(request: CaptureWorkerContextForkRequest): WorkerContextForkReference; /** * Hold the capture lock across orphan classification, capture, and synchronous durable prepare. * A callback failure removes only a file created by this invocation, and only after a refreshed * lifecycle reference read still proves the logical identity unbound. A process crash can leave * an orphan, which the next transaction may reclaim under the same proof and lock. */ captureAndPrepare(request: CaptureAndPrepareWorkerContextForkRequest): CaptureAndPrepareWorkerContextForkResult; open(request: OpenWorkerContextForkRequest): WorkerContextForkSnapshot; private prepareCapture; private captureLocked; private rollbackCreatedSnapshot; private readSnapshot; } //# sourceMappingURL=worker-context-fork-store.d.ts.map