import type { ProcessHost } from './ProcessHost.ts'; import type { RuntimeSessionState } from './RuntimeSession.ts'; /** Process boundary retained for fatal-error escalation. */ export type GlobalErrorHost = Pick; /** Session surface the escalation drives; `stop` must be the owner's full teardown. */ export interface EscalatableSession { readonly state: RuntimeSessionState; requestExit(host: Pick, exitCode: number): Promise; stop(): Promise; } export interface GlobalErrorEscalationParams { /** Maximum graceful-cleanup delay before a fatal error requests hard process termination. */ readonly exitTimeoutMs?: number; /** * Returns true when a fatal notification should be ignored because an * orderly shutdown is already in progress. A throwing predicate cannot * suppress the notification. */ readonly isShutdownInProgress?: () => boolean; readonly session: EscalatableSession; } /** * Escalates a fatal out-of-band error signal — a health reporter entering an * error state, a supervisor declaring the run unrecoverable — into process * termination that stays serialized with normal lifecycle cleanup. * * The escalation runs in two phases so a fatal signal raised during command * startup cannot race the synchronous failure path: * * - {@link arm} retains the process boundary while startup is still running. * From this point a non-cooperative startup cannot suppress termination * forever: a retained notification arms the exit watchdog even before * activation. * - {@link activate} enables the graceful path once startup has completed; * any notification retained in the meantime is handled here. * * On escalation the session is stopped (cleanup failures are reported, never * rethrown) and exit code 1 is requested. Once fatal cleanup owns the shutdown, * the watchdog remains active until that cleanup settles. A retained startup * notification is discarded if external shutdown takes over first. An owner * may call {@link clearExitTimer} to cancel promptly after external cleanup; * this session interface does not expose an external stop-settlement event. */ export declare class GlobalErrorEscalation { #private; constructor(params: GlobalErrorEscalationParams); /** * Enables process termination for fatal errors after startup has completed. * Any notification retained while startup was still in progress is handled * here instead of racing the synchronous failure path. */ activate(host: GlobalErrorHost): Promise; /** * Retains the process boundary while startup is running. Fatal errors stay * serialized with normal lifecycle cleanup, but a non-cooperative startup * cannot suppress process termination forever. */ arm(host: GlobalErrorHost): void; /** Cancels a pending watchdog, including from an external owner's settled-stop hook. */ clearExitTimer(): void; /** Reports one fatal out-of-band error signal. Idempotent; ignored after shutdown has begun. */ notify(): void; } //# sourceMappingURL=GlobalErrorEscalation.d.ts.map