/** * Agentic QE v3 - Defect Investigation Protocol * * Orchestrates multi-agent investigation of test failures. * Trigger: Test failure event * Participants: Defect Predictor, RCA, Flaky Hunter, Regression * Actions: Check flakiness, analyze root cause, predict related failures */ import { Result } from '../../shared/types'; import { EventBus, MemoryBackend } from '../../kernel/interfaces'; import { RootCauseAnalysis, RegressionRisk } from '../../domains/defect-intelligence/interfaces'; import { ImpactAnalysis } from '../../domains/code-intelligence/interfaces'; /** * Input for defect investigation - a test failure to investigate */ export interface TestFailure { testId: string; testName: string; file: string; error: string; stack?: string; duration: number; runId: string; timestamp: Date; context?: TestFailureContext; } export interface TestFailureContext { precedingTests?: string[]; environment?: Record; parallelWorkers?: number; retryAttempt?: number; } /** * Result of a complete defect investigation */ export interface DefectInvestigationResult { investigationId: string; testFailure: TestFailure; isFlaky: boolean; flakyAnalysis?: FlakyTestAnalysis; rootCause?: RootCauseAnalysis; regressionAnalysis?: RegressionRisk; relatedFailures: RelatedFailure[]; impactAnalysis?: ImpactAnalysis; coverageContext?: CoverageContext; recommendations: DefectRecommendation[]; confidence: number; duration: number; } export interface FlakyTestAnalysis { isFlaky: boolean; confidence: number; pattern?: 'timing' | 'ordering' | 'resource' | 'async' | 'unknown'; failureRate?: number; recommendation?: string; } export interface RelatedFailure { testId: string; testName: string; file: string; similarity: number; reason: string; } export interface CoverageContext { file: string; lineCoverage: number; branchCoverage: number; uncoveredLines: number[]; riskScore: number; } export interface DefectRecommendation { type: 'fix' | 'investigate' | 'retry' | 'skip' | 'quarantine'; priority: 'critical' | 'high' | 'medium' | 'low'; description: string; action: string; effort: 'low' | 'medium' | 'high'; confidence: number; } export interface DefectInvestigationStartedPayload { investigationId: string; testId: string; testFile: string; error: string; runId: string; } export interface FlakinessDetectedPayload { investigationId: string; testId: string; pattern: string; failureRate: number; confidence: number; } export interface RootCauseIdentifiedPayload { investigationId: string; testId: string; rootCause: string; confidence: number; contributingFactors: string[]; } export interface RelatedFailuresPredictedPayload { investigationId: string; testId: string; relatedTests: string[]; similarityScores: number[]; } export interface DefectInvestigationCompletedPayload { investigationId: string; testId: string; isFlaky: boolean; rootCause?: string; relatedFailuresCount: number; recommendationsCount: number; confidence: number; duration: number; } export declare const DefectInvestigationEvents: { readonly DefectInvestigationStarted: "coordination.DefectInvestigationStarted"; readonly FlakinessDetected: "coordination.FlakinessDetected"; readonly RootCauseIdentified: "coordination.RootCauseIdentified"; readonly RelatedFailuresPredicted: "coordination.RelatedFailuresPredicted"; readonly DefectInvestigationCompleted: "coordination.DefectInvestigationCompleted"; }; export interface DefectInvestigationConfig { /** Maximum time to spend on investigation (ms) */ maxDuration: number; /** Minimum confidence threshold to report findings */ minConfidence: number; /** Number of historical runs to check for flakiness */ flakinessHistorySize: number; /** Failure rate threshold to consider test flaky */ flakinessThreshold: number; /** Maximum related failures to predict */ maxRelatedFailures: number; /** Enable deep root cause analysis */ enableDeepAnalysis: boolean; /** Skip investigation for known flaky tests */ skipKnownFlaky: boolean; /** Namespace for storing investigation data */ namespace: string; } /** * DefectInvestigationProtocol orchestrates multi-agent investigation of test failures. * * Investigation workflow: * 1. Check if test is known flaky (return early if yes) * 2. Analyze root cause * 3. Check for regression patterns * 4. Predict related failures * 5. Generate remediation suggestions */ export declare class DefectInvestigationProtocol { private readonly eventBus; private readonly memory; private readonly config; private readonly source; constructor(eventBus: EventBus, memory: MemoryBackend, config?: Partial); /** * Execute the full defect investigation protocol */ execute(testFailure: TestFailure): Promise>; /** * Check if the test failure is due to flakiness */ checkFlakiness(investigationId: string, testFailure: TestFailure): Promise; /** * Analyze root cause of the test failure */ analyzeRootCause(investigationId: string, testFailure: TestFailure): Promise; /** * Predict tests that may have related failures */ predictRelatedFailures(investigationId: string, testFailure: TestFailure, rootCause: RootCauseAnalysis | null): Promise; /** * Generate fix recommendations based on investigation findings */ suggestFixes(testFailure: TestFailure, flakyAnalysis: FlakyTestAnalysis, rootCause: RootCauseAnalysis | null, regressionAnalysis: RegressionRisk | null, relatedFailures: RelatedFailure[]): DefectRecommendation[]; /** * Update defect patterns for learning from this investigation */ updateDefectPatterns(result: DefectInvestigationResult): Promise; private publishEvent; private completeInvestigation; private buildEarlyFlakyResult; private detectFlakinessPattern; private calculateFlakinessConfidence; private getFlakyRecommendation; private extractSymptoms; private performRootCauseAnalysis; private getRootCauseRecommendations; private analyzeRegression; private getCoverageContext; private getImpactAnalysis; private findTestsInSameFile; private findTestsWithSimilarErrors; private findDependentTests; private createFlakyRecommendation; private createRootCauseRecommendations; private calculateOverallConfidence; private riskToSeverity; private average; } //# sourceMappingURL=defect-investigation.d.ts.map