/** * Agentic QE v3 - Circuit Breaker * ADR-011: Resilient LLM Provider System * * Implements the circuit breaker pattern to prevent cascading failures * when LLM providers become unavailable or unreliable. * * States: * - CLOSED: Normal operation, requests pass through * - OPEN: Failures exceeded threshold, requests rejected immediately * - HALF-OPEN: Testing recovery, limited requests allowed */ import { CircuitBreakerConfig, CircuitBreakerState, CircuitBreakerStats, LLMProviderType } from './interfaces'; /** * Default circuit breaker configuration */ export declare const DEFAULT_CIRCUIT_BREAKER_CONFIG: CircuitBreakerConfig; /** * Circuit breaker for protecting LLM provider calls */ export declare class CircuitBreaker { private state; private failures; private successCount; private totalRequests; private totalSuccesses; private totalFailures; private rejectedCount; private lastFailureTime?; private lastSuccessTime?; private openedAt?; private halfOpenSuccesses; private readonly config; private readonly providerType; constructor(providerType: LLMProviderType, config?: Partial); /** * Get current circuit breaker state */ getState(): CircuitBreakerState; /** * Check if requests are allowed through */ canExecute(): boolean; /** * Execute a function with circuit breaker protection */ execute(fn: () => Promise): Promise; /** * Record a successful request */ recordSuccess(): void; /** * Record a failed request */ recordFailure(error: Error): void; /** * Get circuit breaker statistics */ getStats(): CircuitBreakerStats; /** * Manually reset the circuit breaker to closed state */ reset(): void; /** * Force the circuit to open (for testing or manual intervention) */ forceOpen(): void; /** * Force the circuit to half-open (for testing) */ forceHalfOpen(): void; /** * Get recent failure messages */ getRecentFailures(count?: number): string[]; /** * Transition to a new state */ private transitionTo; /** * Clean failures outside the time window */ private cleanOldFailures; /** * Get time until next state transition */ private getTimeUntilTransition; } /** * Circuit breaker manager for multiple providers */ export declare class CircuitBreakerManager { private breakers; private readonly defaultConfig; constructor(defaultConfig?: Partial); /** * Get or create a circuit breaker for a provider */ getBreaker(providerType: LLMProviderType, config?: Partial): CircuitBreaker; /** * Get all circuit breaker statistics */ getAllStats(): Record; /** * Get providers that are currently available (circuit not open) */ getAvailableProviders(): LLMProviderType[]; /** * Reset all circuit breakers */ resetAll(): void; /** * Reset a specific provider's circuit breaker */ reset(providerType: LLMProviderType): void; } //# sourceMappingURL=circuit-breaker.d.ts.map