export interface SessionLease { ownerId: string; sessionId: string; pid: number; leaseTokenHash: string; endpoint: { kind: "unix-socket" | "fifo"; path: string; } | null; eventsPath: string; heartbeatAt: string; expiresAt: string; leaseEpoch: number; writer: { ownerId: string; leaseEpoch: number; }; } export declare class LeaseError extends Error { readonly code: string; constructor(message: string, code: string); } export type LeaseStatus = "missing" | "live" | "expiredAlive" | "dead" | "epermAlive"; type PidStatus = "alive" | "dead" | "eperm"; export declare function readLease(root: string, sessionId: string): Promise; export declare function isExpired(lease: SessionLease, clock?: () => number): boolean; export declare function classifyLeaseStatus(lease: SessionLease | null, opts?: { clock?: () => number; probe?: (pid: number) => PidStatus; }): LeaseStatus; /** Liveness probe via signal 0. Defaults to the real process table; injectable for tests. */ export declare function isOwnerAlive(pid: number, probe?: (pid: number) => boolean): boolean; export declare function isStale(lease: SessionLease, opts?: { clock?: () => number; probe?: (pid: number) => boolean; }): boolean; export interface AcquireOptions { ownerId: string; pid: number; endpoint?: SessionLease["endpoint"]; eventsPath: string; ttlMs: number; clock?: () => number; probe?: (pid: number) => boolean | PidStatus; } export interface AcquiredLease { lease: SessionLease; token: string; } /** * Acquire (or take over a stale) lease. Fails closed with `lease_held` when a live, * unexpired lease is held by a different owner. Re-acquiring as the current owner refreshes. */ export declare function acquireLease(root: string, sessionId: string, opts: AcquireOptions): Promise; /** Refresh the lease expiry. Only the recorded owner may heartbeat (single-writer). */ export declare function heartbeat(root: string, sessionId: string, ownerId: string, ttlMs: number, clock?: () => number): Promise; /** Whether `ownerId` is the live, unexpired single writer permitted to append events. */ export declare function canWriteEvents(lease: SessionLease, ownerId: string, clock?: () => number): boolean; /** Release the lease (owner shutdown). Only the holder may release. */ export declare function releaseLease(root: string, sessionId: string, ownerId: string): Promise; export declare function reapDeadOwnerArtifacts(root: string, sessionId: string, expectedOwnerId: string, expectedEpoch: number, opts?: { clock?: () => number; probe?: (pid: number) => PidStatus; }): Promise; export {};