export interface LaunchLock {
    file: string;
    nonce: string;
    pid: number;
    start?: string;
}
export type WorkerLiveness = "alive" | "gone" | "unknown";
export declare const SUBMITTED_GRACE_MS = 120000;
export declare function workerFilePath(id: string): string;
export declare function launchLockFile(id: string): string;
export declare function submittedFilePath(id: string): string;
/** Mark a launch as submitted before its command is typed or spawned. */
export declare function markSubmitted(id: string, at?: Date): Promise<string>;
/** The process's start time, or undefined when no process has that PID. Throws when ps itself fails. */
export declare function processStartTime(pid: number): Promise<string | undefined>;
/** Whether the PID still belongs to the process that wrote `start`. */
export declare function processMatches(pid: number, start: string | undefined): Promise<WorkerLiveness>;
/** The recorded worker process, if the identity file is readable and well-formed. */
export declare function workerPid(id: string, file?: string): Promise<{
    pid: number;
    start: string;
} | undefined>;
/** A held launch lock whose owner is alive means the launch is still placing. */
export declare function launchInProgress(id: string): Promise<boolean>;
export type WorkerScan = {
    ok: true;
    worker?: {
        pid: number;
        start: string;
    };
} | {
    ok: false;
};
type ProcessScanner = (file: string) => Promise<WorkerScan>;
/** Only for tests: replace the real same-user process scan. */
export declare function setWorkerProcessScan(scanner: ProcessScanner | undefined): void;
/**
 * The worker's liveness. A present identity file is authoritative. Without one,
 * a same-user process carrying this launch's worker-file marker is adopted;
 * otherwise the submitted marker and the launch lock decide whether no worker
 * can still be starting.
 */
export declare function workerAlive(id: string, file?: string, submittedAt?: string): Promise<WorkerLiveness>;
/** Hold the launch lock for one keyed dispatch; a stale lock is replaced. */
export declare function acquireLaunchLock(id: string): Promise<LaunchLock>;
export declare function releaseLaunchLock(lock: LaunchLock): Promise<void>;
/** Remove the worker identity and its temporary file after a confirmed termination. */
export declare function removeWorkerFile(id: string): Promise<void>;
/** SIGTERM the recorded process, then SIGKILL it if the same process is still alive after 10 s. */
export declare function terminateWorker(pid: number, start: string): Promise<void>;
export {};
