import type { PluginCoreLike } from "./service.ts"; /** * Per-service restart tracking state. * Captures attempt count, timing, backoff, and final degradation flag. */ export interface ServiceRestartState { attempts: number; firstAttemptTime: number; lastAttemptTime: number; backoffUntil: number; status: "ok" | "backoff" | "permanently_degraded"; } /** * Default supervisor configuration constants. * - maxRestartsPerWindow: max restart attempts before permanent degradation * - windowMs: sliding time window for counting attempts * - baseBackoffMs: initial backoff duration (doubles per attempt) * - backoffFactor: exponential multiplier applied per failed attempt * - maxBackoffMs: ceiling for backoff duration */ export declare const SUPERVISOR_DEFAULTS: { readonly maxRestartsPerWindow: 3; readonly windowMs: 60000; readonly baseBackoffMs: 1000; readonly backoffFactor: 2; readonly maxBackoffMs: 30000; }; /** * Micro-kernel supervisor that governs service restart discipline. * * Implements sliding-window rate limiting, exponential backoff, and * permanent degradation to prevent restart storms. Every public method * is wrapped in try/catch so the supervisor itself never causes a crash * (always-bootable principle). */ export declare class ServiceSupervisor { private states; private core; constructor(core: PluginCoreLike); /** * Attempt a supervised restart of the named service. * * Rules (in order): * 1. permanently_degraded → no-op. * 2. In backoff (now < backoffUntil) → skip + log.debug. * 3. Window expired (now - firstAttemptTime > windowMs) → reset budget. * 4. Under budget (attempts < maxRestartsPerWindow) → call core.restartService(). * - Success → reset tracking. * - Failure → increment attempts, apply backoff or mark degraded. * 5. All errors within the supervisor are caught — never propagate. */ tryRestart(name: string): Promise; /** * Return the current restart tracking state for a service. * When no tracking record exists, returns a default 'ok' state. */ getStatus(name: string): ServiceRestartState; } //# sourceMappingURL=service-supervisor.d.ts.map