export interface LeaseRecord { leaseId: string; workspaceId: string; ownerRunId: string; processId: number; acquiredAt: number; lastHeartbeat: number; expiresAt: number; timeoutMs: number; recovered?: boolean; } export type LeaseResult = { ok: true; lease: LeaseRecord; } | { ok: false; reason: "lease_held"; lease: LeaseRecord; } | { ok: false; reason: "io_error"; message: string; }; export type LeaseStatus = LeaseRecord | null; export interface LeaseStoreOptions { /** Absolute directory where lease records are stored. */ storageDir: string; /** Timeout after which a lease is considered stale and recoverable. */ timeoutMs?: number; /** Heartbeat interval. */ heartbeatMs?: number; /** Injectable now() for deterministic tests. */ now?: () => number; /** Injectable process-liveness checker (default: process.kill(pid, 0)). */ isProcessAlive?: (pid: number) => boolean; } export declare class WorkspaceLeaseError extends Error { readonly code: string; readonly lease?: LeaseRecord; constructor(code: string, message: string, lease?: LeaseRecord); } /** * Exclusive workspace mutation lease. * * Uses an atomic exclusive-create lockfile so that only one authoritative * mutating transaction may hold the workspace lease. Read-only work can remain * concurrent. A crashed owner does not permanently lock the workspace: stale * leases are recovered only after a positive liveness check. Release is * idempotent. Unrelated workspaces are independent (per-workspace key). */ export declare class WorkspaceLeaseStore { private readonly timeoutMs; private readonly heartbeatMs; private readonly now; private readonly isProcessAlive; readonly storageDir: string; constructor(options: LeaseStoreOptions); private leasePath; acquire(workspaceId: string, ownerRunId: string): Promise; heartbeat(workspaceId: string): Promise; /** Idempotent release. Only the owner (or recovery) can clear the lease. */ release(workspaceId: string, ownerRunId: string | null): Promise; status(workspaceId: string): Promise; /** Stale-lease recovery with positive liveness check. */ recoverIfStale(workspaceId: string, _ownerRunId: string): Promise; private readRecord; } /** Convenience to derive a lease when the owner also wants a checkout of state. */ export declare function workspaceKeyFromRoot(root: string): string; //# sourceMappingURL=lease.d.ts.map