/** * Agentic QE v3 - Causal Root Cause Analyzer Service * ADR-035: STDP-based spike timing correlation for root cause analysis * * Integrates the causal discovery engine with the defect-intelligence domain * to provide automated, learning-based root cause analysis. */ import { Result } from '../../../shared/types'; import { MemoryBackend } from '../../../kernel/interfaces'; import { TestEvent, TestEventType, CausalSummary, CausalDiscoveryConfig } from '../../../causal-discovery'; /** * Configuration for the causal root cause analyzer */ export interface CausalRootCauseAnalyzerConfig { /** Namespace for memory storage */ namespace: string; /** Whether to auto-persist learned patterns */ autoPersist: boolean; /** Persistence interval in milliseconds */ persistIntervalMs: number; /** Causal discovery configuration */ causalConfig: Partial; /** Minimum confidence for analysis results */ minConfidence: number; } /** * Default configuration */ export declare const DEFAULT_CAUSAL_ANALYZER_CONFIG: CausalRootCauseAnalyzerConfig; /** * Request for causal root cause analysis */ export interface CausalAnalysisRequest { /** The event type to analyze (what happened?) */ targetEvent: TestEventType; /** Optional: specific test or file context */ context?: { testId?: string; file?: string; environment?: string; }; /** Include indirect causes in analysis */ includeIndirect?: boolean; /** Maximum intervention points to return */ maxInterventions?: number; } /** * Response from causal root cause analysis */ export interface CausalAnalysisResponse { /** The analyzed event */ targetEvent: TestEventType; /** Most likely root cause */ rootCause: { event: TestEventType; strength: number; confidence: number; } | null; /** All direct causes ranked by strength */ directCauses: Array<{ event: TestEventType; strength: number; observations: number; }>; /** Indirect causes with paths */ indirectCauses: Array<{ event: TestEventType; strength: number; path: TestEventType[]; }>; /** Recommended intervention points */ interventions: Array<{ event: TestEventType; score: number; reason: string; }>; /** Overall confidence in the analysis */ confidence: number; /** Number of observations used */ observationCount: number; /** Human-readable summary */ summary: string; } /** * Service interface for causal root cause analysis */ export interface ICausalRootCauseAnalyzerService { /** Observe a test event for learning */ observeEvent(event: TestEvent): void; /** Observe a batch of events */ observeEvents(events: TestEvent[]): void; /** Analyze root cause of a target event */ analyzeRootCause(request: CausalAnalysisRequest): Promise>; /** Get the current causal summary */ getSummary(): CausalSummary; /** Predict likely causes for an event type */ predictCauses(eventType: TestEventType): TestEventType[]; /** Persist learned patterns to memory */ persist(): Promise>; /** Restore learned patterns from memory */ restore(): Promise>; /** Reset all learned patterns */ reset(): void; } /** * Causal Root Cause Analyzer Service * * Uses STDP-based causal discovery to learn relationships between events * and provide intelligent root cause analysis. */ export declare class CausalRootCauseAnalyzerService implements ICausalRootCauseAnalyzerService { private readonly memory; private readonly engine; private readonly config; private lastPersist; constructor(memory: MemoryBackend, config?: Partial); /** * Observe a single test event for learning */ observeEvent(event: TestEvent): void; /** * Observe a batch of events */ observeEvents(events: TestEvent[]): void; /** * Analyze root cause of a target event */ analyzeRootCause(request: CausalAnalysisRequest): Promise>; /** * Generate a human-readable summary of the analysis */ private generateSummary; /** * Get summary statistics */ getSummary(): CausalSummary; /** * Predict likely causes for an event type */ predictCauses(eventType: TestEventType): TestEventType[]; /** * Predict what events might be caused by a source event */ predictEffects(eventType: TestEventType): TestEventType[]; /** * Persist learned patterns to memory */ persist(): Promise>; /** * Restore learned patterns from memory */ restore(): Promise>; /** * Reset all learned patterns */ reset(): void; /** * Apply decay to prevent weight explosion */ decay(): void; /** * Get the observation count */ getObservationCount(): number; } /** * Create a causal root cause analyzer with default configuration */ export declare function createCausalRootCauseAnalyzer(memory: MemoryBackend, config?: Partial): CausalRootCauseAnalyzerService; /** * Create a test event from common test scenarios */ export declare function createTestEvent(type: TestEventType, options?: { testId?: string; file?: string; data?: Record; }): TestEvent; /** * Convert test execution results to causal events */ export declare function testResultToEvents(result: { testId: string; file: string; passed: boolean; duration: number; error?: string; }): TestEvent[]; //# sourceMappingURL=causal-root-cause-analyzer.d.ts.map