/** * Agentic QE v3 - Defect Prediction Service * ML-based defect prediction using code metrics and historical data * Uses GitAnalyzer for real git history analysis */ import { Result } from '../../../shared/types'; import { MemoryBackend } from '../../../kernel/interfaces'; import { PredictRequest, PredictionResult, RegressionRequest, RegressionRisk } from '../interfaces'; /** * Interface for the defect prediction service */ export interface IDefectPredictorService { predictDefects(request: PredictRequest): Promise>; analyzeRegressionRisk(request: RegressionRequest): Promise>; updateModel(feedback: PredictionFeedback): Promise>; getModelMetrics(): Promise; } /** * Prediction feedback for model improvement */ export interface PredictionFeedback { predictionId: string; file: string; predictedProbability: number; actualDefect: boolean; defectType?: string; } /** * Model performance metrics */ export interface ModelMetrics { accuracy: number; precision: number; recall: number; f1Score: number; totalPredictions: number; lastUpdated: Date; } /** * Configuration for the defect predictor */ export interface DefectPredictorConfig { defaultThreshold: number; maxPredictionsPerBatch: number; enableHistoricalAnalysis: boolean; modelNamespace: string; featureWeights: Record; } /** * Defect Prediction Service Implementation * Uses ML-based heuristics to predict defect probability in code files */ export declare class DefectPredictorService implements IDefectPredictorService { private readonly memory; private readonly config; private readonly gitAnalyzer; private readonly fileReader; private readonly tsParser; private modelMetrics; constructor(memory: MemoryBackend, config?: Partial); /** * Predict defect probability for given files */ predictDefects(request: PredictRequest): Promise>; /** * Analyze regression risk for a changeset */ analyzeRegressionRisk(request: RegressionRequest): Promise>; /** * Update the prediction model with feedback */ updateModel(feedback: PredictionFeedback): Promise>; /** * Get current model performance metrics */ getModelMetrics(): Promise; private predictForFile; private extractFileMetrics; /** * Calculate code complexity using TypeScript AST analysis * Falls back to path-based heuristics if file cannot be parsed */ private calculateComplexity; /** * Estimate complexity based on file path heuristics (fallback) */ private estimateComplexityFromPath; /** * Get change frequency for a file using git history * Falls back to memory cache if git is not available */ private getChangeFrequency; /** * Get developer experience score for a file using git blame * Falls back to memory cache if git is not available */ private getDeveloperExperience; /** * Get test coverage for a file from coverage reports */ private getTestCoverage; /** * Get code age for a file using git history * Falls back to memory cache if git is not available */ private getCodeAge; /** * Get bug history for a file using git commit messages * Falls back to memory cache if git is not available */ private getBugHistory; private probabilityToRisk; private riskToSeverity; private generateRecommendations; private analyzeFileImpact; private categorizeFile; private analyzeDependencies; /** * Resolve a relative import path to an absolute file path */ private resolveRelativeImport; private getBaselineRisk; private generateTestRecommendations; private calculateModelConfidence; private calculateVariance; private storePrediction; private recalculateMetrics; } //# sourceMappingURL=defect-predictor.d.ts.map