import type { PersistedDeliveryEntry } from './core/delivery.js'; import type { AttentionLevel } from './types.js'; export declare const SUPERVISOR_SCHEMA_VERSION: 1; export declare const SUPERVISOR_POLICY_STATE_SCHEMA_VERSION: 1; export type SupervisorHostStatus = 'ready' | 'degraded' | 'unreachable'; export type SupervisorState = 'inactive' | 'starting' | 'standby' | 'running' | 'degraded' | 'blocked' | 'stopped'; export interface SupervisorSessionState { sessionRef: string; attentionLevel: AttentionLevel; pendingCount: number; lastEvidenceAt?: string; } export interface SupervisorPolicyState { schemaVersion: typeof SUPERVISOR_POLICY_STATE_SCHEMA_VERSION; policyVersion: string; dedupe: Array<{ keyHash: string; acceptedAt: string; }>; interruptConsumedAt: string[]; } export interface SupervisorSnapshot { schemaVersion: typeof SUPERVISOR_SCHEMA_VERSION; revision: number; generatedAt: string; host: { runtimeVersion: string; status: SupervisorHostStatus; }; sessions: SupervisorSessionState[]; pending: string[]; policyState?: SupervisorPolicyState; /** Bounded cross-sink delivery state; values contain hashes, enums and time only. */ deliveryLedger?: PersistedDeliveryEntry[]; } export interface SupervisorLease { schemaVersion: typeof SUPERVISOR_SCHEMA_VERSION; instanceId: string; pid: number; startedAt: string; heartbeatAt: string; } export interface SupervisorMetrics { startupMs: number | null; restoreMs: number | null; writeCount: number; heartbeatCount: number; wakeCount: number; stateBytes: number; stateDirectoryBytes: number; rssBytes: number; peakRssBytes: number; } export interface PersistentSupervisorStatus { schemaVersion: typeof SUPERVISOR_SCHEMA_VERSION; state: SupervisorState; instanceId: string; leaseHeld: boolean; restored: boolean; staleLeaseRecovered: boolean; revision: number; lastSnapshotAt?: string; lastHeartbeatAt?: string; metrics: SupervisorMetrics; } export interface PersistentSupervisorOptions { stateDir: string; runtimeVersion: string; staleLeaseMs?: number; /** Retry interval while another live supervisor owns the lease. */ standbyRetryMs?: number; heartbeatMs?: number; maxSessions?: number; maxPending?: number; now?: () => number; pid?: number; instanceId?: string; } export declare class SupervisorStore { readonly directory: string; readonly snapshotFile: string; readonly leaseFile: string; readonly lockFile: string; constructor(stateDir: string); load(runtimeVersion: string, now: number, maxSessions?: number, maxPending?: number): Promise; /** * Commit a snapshot while holding the same local filesystem lock used by * lease changes. The lease check and the atomic rename therefore form one * fenced operation: a stale owner cannot write after a takeover has won the * lock. */ saveOwned(snapshot: SupervisorSnapshot, expected: SupervisorLease): Promise; loadLease(): Promise; private loadLeaseUnlocked; tryCreateLease(lease: SupervisorLease): Promise; replaceLease(expected: SupervisorLease, next: SupervisorLease): Promise; archiveStaleLease(expected: SupervisorLease, now: number): Promise; releaseLease(expected: SupervisorLease): Promise; measureStateBytes(): Promise; private writeAtomic; private quarantine; private withOperationLock; } export declare class PersistentSupervisor { readonly store: SupervisorStore; readonly instanceId: string; readonly runtimeVersion: string; private readonly options; private snapshotValue; private lease; private lifecycle; private restored; private staleLeaseRecovered; private lastSnapshotAt; private lastHeartbeatAt; private startupMs; private restoreMs; private writeCount; private heartbeatCount; private wakeCount; private stateBytes; private stateDirectoryBytes; private peakRssBytes; private heartbeatTimer; private standbyTimer; private persistTimer; private saveChain; private startTask; private stopTask; private disposed; private stopping; constructor(options: PersistentSupervisorOptions); start(): Promise; private startOnce; update(snapshot: SupervisorSnapshot): void; snapshot(): SupervisorSnapshot; status(): PersistentSupervisorStatus; flush(): Promise; stop(): Promise; private stopOnce; private isStale; private scheduleStandbyRetry; private schedulePersist; private persistNow; private heartbeat; } export declare function supervisorSnapshotFor(runtimeVersion: string, hostStatus: SupervisorHostStatus, revision: number, sessions: readonly SupervisorSessionState[], pending: readonly string[], now?: number, maxPending?: number, policyState?: SupervisorPolicyState, deliveryLedger?: readonly PersistedDeliveryEntry[]): SupervisorSnapshot; //# sourceMappingURL=supervisor.d.ts.map