import { EventEmitter } from 'node:events'; import { CapabilityRegistryManager } from './capability-registry.js'; import { KillSwitch } from './kill-switch.js'; import type { RollbackTrigger, RollbackEvent } from './types.js'; export interface ErrorRateConfig { readonly windowMs: number; readonly threshold: number; readonly minSamples: number; } export declare class RollbackManager extends EventEmitter { private registry; private killSwitch; private logPath; private errorConfig; private errorWindows; private rollbackHistory; constructor(registry: CapabilityRegistryManager, killSwitch: KillSwitch, opts?: { logPath?: string; errorConfig?: Partial; }); /** * Record an operation result for error rate tracking. * If the error rate exceeds the threshold, automatically triggers rollback. */ recordOperation(targetId: string, targetType: 'tool' | 'agent' | 'rule', success: boolean): Promise<{ triggered: boolean; rollback?: RollbackEvent; }>; /** * Manually trigger a rollback. */ triggerRollback(trigger: RollbackTrigger, triggeredBy: string, targetType: 'tool' | 'agent' | 'rule' | 'registry', targetId: string, reason: string): Promise; /** * Handle a Layer 2 integrity violation. * This is the most severe rollback trigger — halts the entire system. */ handleIntegrityViolation(component: string, expectedHash: string, actualHash: string): Promise; /** * Get the rollback history. */ getHistory(): readonly RollbackEvent[]; /** * Get the current error rate for a target. */ getErrorRate(targetId: string): { rate: number; samples: number; } | null; private logEvent; }