/**
 * HOW the supervisor ends its generation: the single-flight teardown, the child stop, and the order
 * that keeps the record of the child's end ahead of the release of the directory it cites. Split out
 * of `host-lifecycle.ts`, which keeps the supervisor's orchestration (senpi#2566).
 */
import type { ChildProcess } from "node:child_process";
import type { Server } from "node:net";
import type { HostAdmission } from "./host-admission.ts";
import type { HostStopSender } from "./host-crash-record.ts";
import type { HostDaemonPaths, HostGenerationPaths } from "./host-daemon-paths.ts";
import type { SupervisorActivity } from "./host-lifecycle-activity.ts";
import type { SupervisorDrain } from "./host-lifecycle-drain.ts";
import type { RpcPublicEndpoint } from "./rpc-public-key.ts";
import type { SocketFileIdentity } from "./socket-ownership.ts";
export { CHILD_STOP_TIMEOUT_MS } from "./host-stop-intent.ts";
export interface SupervisorState {
    shuttingDown: boolean;
    shutdownReason: string | undefined;
    /** Settles once the child's end is on record; replaced the moment the child exits. */
    childExitRecorded: Promise<void>;
    /** Startup may still publish ownership files after the public listener became reachable. */
    startupComplete: PromiseLike<void>;
    publicSocketOwned: boolean;
    publicSocketIdentity: SocketFileIdentity | undefined;
    /** Another generation's entry replaced the public socket this one bound: its registration is the replacer's now. */
    endpointReplaced: boolean;
}
export interface SupervisorShutdown {
    readonly paths: HostDaemonPaths;
    readonly generation: HostGenerationPaths;
    readonly instanceId: string;
    readonly publicSocket: string;
    readonly server: Server;
    readonly internalDir: string | undefined;
    readonly child: ChildProcess;
    readonly activity: SupervisorActivity;
    readonly drain: SupervisorDrain;
    readonly admission: HostAdmission;
    readonly state: SupervisorState;
    readonly publicEndpoint?: RpcPublicEndpoint;
    /** Stops the idle ticker, the supersession watch and the win32 identity watchdog. */
    readonly stopWatchers: () => void;
}
export declare function supervisorSender(instanceId: string): HostStopSender;
export declare function childExited(child: ChildProcess): boolean;
export declare function performShutdown(context: SupervisorShutdown, reason: string, exitCode: number): Promise<never>;
export declare function waitForChildExit(child: ChildProcess, timeoutMs: number): Promise<boolean>;
/**
 * External stop (ensureHost replacement, tests, QA) must clean up like idle exit; SIGUSR1 is the
 * gentler request - finish what you are doing and leave - that a generation handoff and
 * `stopHost({ drain: true })` both send to a host from before the drain request. It exists on POSIX
 * only: on win32 the drain arrives as a drain request (host-stop-intent.ts), never as a signal.
 */
export declare function registerSupervisorSignals(shutdown: (reason: string, exitCode: number) => Promise<never>, drain: () => void): void;
//# sourceMappingURL=host-lifecycle-shutdown.d.ts.map