import { type FSWatcher } from "node:fs"; type WatchDirectory = (directory: string, options: { persistent: boolean; }, listener: (eventType: string, fileName: string | Buffer | null) => void) => FSWatcher; export interface WorkerWriteReservationWorkspace { /** Canonical repository/workspace root shared by primary and isolated worktrees. */ repositoryRoot: string; /** Actual checkout used by this attempt. A non-primary checkout requires an isolation identity. */ executionRoot: string; /** Durable worktree identity supplied by the worktree owner, never a model-provided label. */ isolatedWorktreeId?: string; } export interface WorkerWriteReservationRequest { parentSessionId: string; /** Exact pi-owned process instance that acquired this reservation. */ ownerId: string; taskId: string; attemptId: string; fencingToken: number; access: "read" | "write"; workspace: WorkerWriteReservationWorkspace; /** Absolute authorized write roots. They are resolved before persistence. */ writeScopes: readonly string[]; } export interface WorkerWriteReservationLease { filePath: string; reservationId: string; parentSessionId: string; ownerId: string; taskId: string; attemptId: string; fencingToken: number; repositoryRoot: string; executionRoot: string; executionIdentity: string; isolatedWorktreeId?: string; writeScopes: readonly string[]; } export type WorkerWriteReservationAcquireResult = { kind: "granted"; lease?: WorkerWriteReservationLease; } | { kind: "blocked"; reasonCode: "overlapping_write_scope" | "attempt_reservation_conflict" | "reservation_capacity_reached"; conflictingReservationIds?: readonly string[]; }; export type WorkerWriteReservationReleaseResult = { kind: "released"; } | { kind: "stale_fence"; } | { kind: "not_found"; }; export type WorkerWriteReservationEvidenceState = "live" | "not_live" | "unknown"; export interface WorkerWriteReservationRecoveryEvidence { reservationId: string; state: WorkerWriteReservationEvidenceState; } export interface WorkerWriteReservationRecoveryRequest { workspace: WorkerWriteReservationWorkspace; /** Caller-owned lease observations. This store never polls process state or worker output. */ evidence: readonly WorkerWriteReservationRecoveryEvidence[]; } export interface WorkerWriteReservationRecoveryOutcome { kind: "active" | "stale" | "inspection_required"; reservationId: string; lease: WorkerWriteReservationLease; } /** * Cross-process, agent-owned admission seam for concurrent worker mutations. It owns only * reservations; lifecycle, process liveness, and terminal status remain controller concerns. */ export declare class WorkerWriteReservationStore { private readonly agentDir; private readonly watchDirectory; constructor(options: { agentDir: string; watchDirectory?: WatchDirectory; }); acquire(request: WorkerWriteReservationRequest): WorkerWriteReservationAcquireResult; release(lease: WorkerWriteReservationLease): WorkerWriteReservationReleaseResult; /** Event-driven cross-process wakeup for queued write admission; caller owns disposal. */ watchAvailability(workspace: WorkerWriteReservationWorkspace, listener: () => void): () => void; recover(request: WorkerWriteReservationRecoveryRequest): { outcomes: WorkerWriteReservationRecoveryOutcome[]; }; private readLocked; } export {}; //# sourceMappingURL=worker-write-reservation.d.ts.map