/** * Pattern Health Tracker (FEAT-002) * * Monitors learned pattern health over time and detects degradation. * Provides notifications when patterns start failing so users can * re-learn or investigate issues. * * Features: * - Success rate tracking * - Degradation detection * - Health status classification * - Historical trend analysis * - Actionable recommendations * * @example * ```typescript * const tracker = new PatternHealthTracker(); * * // Record pattern usage * tracker.recordSuccess(domain, endpoint); * tracker.recordFailure(domain, endpoint, failureType); * * // Check health * const health = tracker.getHealth(domain, endpoint); * if (health.status === 'degraded') { * console.log('Pattern degraded:', health.recommendedActions); * } * * // Get notifications for all degraded patterns * const notifications = tracker.getAllNotifications(); * ``` */ import type { PatternHealth, PatternHealthConfig, PatternHealthNotification, HealthCheckOptions, HealthCheckResult } from '../types/pattern-health.js'; /** * Tracks pattern health and detects degradation. */ export declare class PatternHealthTracker { /** Health data for each pattern (keyed by domain:endpoint) */ private healthData; /** Recent notifications (for deduplication) */ private recentNotifications; /** Configuration */ private config; constructor(config?: Partial); /** * Generate key for pattern lookup */ private getKey; /** * Initialize health data for a pattern if not exists */ private ensureHealthData; /** * Calculate success rate from verification and failure counts */ private calculateSuccessRate; /** * Determine health status based on success rate and consecutive failures */ private determineStatus; /** * Get recommended actions based on health status */ private getRecommendedActions; /** * Create a health snapshot for historical tracking */ private createSnapshot; /** * Prune old snapshots based on retention policy */ private pruneHistory; /** * Record a successful pattern use */ recordSuccess(domain: string, endpoint: string, verificationCount: number, failureCount: number): void; /** * Record a pattern failure */ recordFailure(domain: string, endpoint: string, verificationCount: number, failureCount: number, failureType?: string): PatternHealthNotification | null; /** * Perform health check for a pattern */ checkHealth(domain: string, endpoint: string, verificationCount: number, failureCount: number, options?: HealthCheckOptions): HealthCheckResult; /** * Get current health for a pattern */ getHealth(domain: string, endpoint: string): PatternHealth | null; /** * Get all patterns with non-healthy status */ getUnhealthyPatterns(): Array<{ domain: string; endpoint: string; health: PatternHealth; }>; /** * Get all recent notifications */ getAllNotifications(): PatternHealthNotification[]; /** * Clear all notifications */ clearNotifications(): void; /** * Prune old notifications (keep last 100, last 24 hours) */ private pruneNotifications; /** * Export all health data for persistence */ exportHealthData(): Record; /** * Import health data from persistence */ importHealthData(data: Record): void; /** * Get health statistics summary */ getHealthStats(): { total: number; healthy: number; degraded: number; failing: number; broken: number; }; } //# sourceMappingURL=pattern-health-tracker.d.ts.map