/** * TaskWatchdogManager — 3-tier timer orchestration for the dispatch subsystem. * * Replaces the old GlobalPoller's inline timer management with a dedicated * coordinator that operates purely via dependency-injected callbacks. * * Tier 1: Per-task reconcile watchdog (setTimeout, self-resetting) * Tier 2: Global sweep (setInterval, starts/ends with task count) * Tier 3: Idle debounce (setTimeout, per-task) * * No imports from SDK or manager.ts — this is pure timer management. */ export interface TaskWatchdogDeps { /** Called when a task's reconcile watchdog fires. */ onReconcile: (taskId: string) => void | Promise; /** Called for every running task on each global sweep tick. */ onSweep: (taskId: string) => void | Promise; /** Called when a task's idle debounce timer elapses. */ onDebounceElapsed: (taskId: string) => void | Promise; } export interface TaskWatchdogConfig { /** Per-task reconcile watchdog interval (ms). */ watchdogIntervalMs: number; /** Global sweep interval (ms). */ globalSweepIntervalMs: number; /** Idle debounce delay (ms). */ idleDebounceMs: number; } export declare class TaskWatchdogManager { private deps; private config; /** Per-task reconcile watchdog timeout handles. */ private watchdogTimers; /** Per-task idle debounce timeout handles. */ private debounceTimers; /** Tasks with a currently-pending debounce timer. */ private pendingDebounce; /** Registered task IDs. */ private registeredTasks; /** Global sweep interval handle. */ private sweepInterval; /** Track whether dispose() was called to prevent re-entry. */ private disposed; constructor(deps: TaskWatchdogDeps, config: TaskWatchdogConfig); /** * Register a running task: start its watchdog. * Starts the global sweep if this is the first task. * Idempotent — calling twice for the same taskId is a no-op. */ registerTask(taskId: string): void; /** * Remove a task: clear its watchdog and debounce timers. * Stops the global sweep if this was the last task. */ unregisterTask(taskId: string): void; /** Reset a task's watchdog timer (called on every routed event). No-op if not registered. */ resetWatchdog(taskId: string): void; /** Start the idle-debounce timer for a task. Replaces any existing one. */ startDebounce(taskId: string): void; /** Cancel a task's debounce timer (task resumed). No-op if none. */ cancelDebounce(taskId: string): void; /** True if a debounce timer is currently pending for this task. */ isDebouncing(taskId: string): boolean; /** Clear ALL timers (watchdogs, debounces, global sweep). Safe to call multiple times. */ dispose(): void; /** Directly fire the reconcile callback for a task, emulating a watchdog timeout. */ triggerWatchdog(taskId: string): void | Promise; /** Directly fire the sweep callback for all registered tasks. */ triggerSweep(): void | Promise; /** Directly fire the debounce callback for a task, emulating debounce timer expiry. */ triggerDebounce(taskId: string): void | Promise; /** Return a snapshot of currently-registered task IDs (for test assertions). */ getRegisteredTaskIds(): string[]; /** Start the per-task reconcile watchdog (self-resetting setTimeout). */ private _startWatchdog; /** Clear a task's watchdog timer. */ private _clearWatchdog; /** Clear a task's debounce timer and remove from pending set. */ private _clearDebounce; /** Start the global sweep setInterval. */ private _startGlobalSweep; /** Stop the global sweep setInterval. */ private _stopGlobalSweep; /** Wrap a callback to catch and silence errors (prevents unhandled rejections in timers). */ private _runSafe; } //# sourceMappingURL=watchdog.d.ts.map