export declare const LEASE_RECORD_VERSION = 2;
export interface LeaseSelfIdentity {
    readonly pid: number;
    readonly bootAtMs: number;
    readonly processStartedAtMs: number;
}
/**
 * `startedAtMs` duplicates `acquiredAtMs` on purpose: a senpi build that still runs the v1 lease
 * reader parses `{pid, startedAtMs}` and must not see this file as unparseable (which it reclaims).
 */
export interface LeaseRecord {
    readonly v?: number;
    readonly token?: string;
    readonly pid: number;
    readonly startedAtMs: number;
    readonly bootAtMs?: number;
    readonly processStartedAtMs?: number;
    readonly acquiredAtMs?: number;
}
export interface LeaseHolder {
    readonly pid: number;
    readonly startedAtMs: number;
    readonly bootAtMs?: number;
}
export type AcquireTerminalLeaseOptions = {
    dir: string;
    encodedSessionId: string;
    pid?: number;
    now?: () => number;
    self?: LeaseSelfIdentity;
    isProcessAlive?: (pid: number) => boolean;
    readProcessStartMs?: (pid: number) => Promise<number | undefined>;
};
export type AcquireTerminalLeaseResult = {
    acquired: true;
    path: string;
    pid: number;
    token: string;
} | {
    acquired: false;
    holder: LeaseHolder;
};
export type LeaseClassification = "self" | "dead" | "reused" | "live-foreign";
export declare function currentLeaseToken(encodedSessionId: string): string | undefined;
/** Mark a generation's token dead the moment its shutdown starts, before any slow flush. */
export declare function retireLeaseToken(token: string): void;
export declare function readLeaseRecord(raw: string): LeaseRecord | "unparseable";
/**
 * Decide what an existing lease is. A pid alone is never trusted: the holder is alive only when
 * its pid answers AND its recorded start instant matches the process now wearing that pid
 * (probed on this cold path only). A boot mismatch alone never reclaims an alive pid. Our own
 * pid is "self" only when the file carries the token this process minted for the session (or a
 * legacy record without one): a multi-session host holds many sessions under one pid, and a
 * lease another live generation in this process owns is a live holder, not a re-entry.
 */
export declare function classifyLease(existing: LeaseRecord, self: LeaseSelfIdentity, probes: {
    readonly isProcessAlive?: (pid: number) => boolean;
    readonly readProcessStartMs: (pid: number) => Promise<number | undefined>;
    readonly liveTokens?: ReadonlySet<string>;
}): Promise<LeaseClassification>;
export declare function acquireTerminalLease(options: AcquireTerminalLeaseOptions): Promise<AcquireTerminalLeaseResult>;
/** Release only the generation that acquired: a stale release from an earlier generation is a no-op. */
export declare function releaseTerminalLease(handle: {
    path: string;
    pid: number;
    token?: string;
}): Promise<void>;
//# sourceMappingURL=manifest-lease.d.ts.map