/** * Agentic QE v3 - Speculative Test Executor * ADR-033: Lambda-stability decisions with speculative execution * * This module implements speculative prediction and verification for * test layers that are skipped due to early exit decisions. */ import { EarlyExitConfig, EarlyExitDecision, TestLayer, SpeculativeResult, SpeculativeBatch, PredictedOutcome, LayerResult } from './types'; /** * Historical data for a test layer used in prediction */ export interface LayerHistory { /** Layer index */ layerIndex: number; /** Historical pass rate */ avgPassRate: number; /** Historical pass rate variance */ passRateVariance: number; /** Historical flaky rate */ avgFlakyRate: number; /** Number of data points */ dataPoints: number; /** Recent trend (positive = improving, negative = degrading) */ trend: number; } /** * Prediction model interface for extensibility */ export interface IPredictionModel { predict(layer: TestLayer, decision: EarlyExitDecision, history?: LayerHistory): Promise; } /** * SpeculativeExecutor - Generates and verifies predictions for skipped test layers * * When early exit occurs, this executor: * 1. Predicts outcomes for skipped layers based on quality signals and history * 2. Optionally verifies predictions by running actual tests * 3. Tracks prediction accuracy for model improvement * * @example * ```typescript * const executor = new SpeculativeExecutor(config); * * // Generate predictions for skipped layers * const batch = await executor.speculate(exitDecision, skippedLayers); * * // Optionally verify some predictions * const verified = await executor.verify(batch.predictions, skippedLayers, runLayer); * ``` */ export declare class SpeculativeExecutor { private readonly config; private readonly layerHistories; private predictionResults; constructor(config?: Partial); /** * Generate speculative predictions for skipped layers * * @param exitDecision - The early exit decision * @param skippedLayers - Layers that were skipped * @returns Batch of predictions */ speculate(exitDecision: EarlyExitDecision, skippedLayers: TestLayer[]): Promise; /** * Verify speculative predictions by running actual tests * * @param predictions - Original predictions * @param layers - Test layers to verify * @param runLayer - Function to execute a test layer * @returns Verified predictions with actual outcomes */ verify(predictions: SpeculativeResult[], layers: TestLayer[], runLayer: (layer: TestLayer) => Promise): Promise; /** * Predict outcome for a single layer */ private predictLayerOutcome; /** * Predict outcome based on historical data */ private predictFromHistory; /** * Predict outcome based on exit decision confidence */ private predictFromConfidence; /** * Adjust confidence based on historical data */ private adjustConfidenceWithHistory; /** * Determine outcome from layer result */ private determineOutcome; /** * Update layer history with new results */ private updateLayerHistory; /** * Get prediction accuracy statistics */ getAccuracyStats(): { total: number; verified: number; correct: number; accuracy: number; outcomeBreakdown: Record; }; /** * Set historical data for a layer */ setLayerHistory(history: LayerHistory): void; /** * Get historical data for a layer */ getLayerHistory(layerIndex: number): LayerHistory | undefined; /** * Reset executor state */ reset(): void; /** * Clear all state including histories */ clearAll(): void; } /** * Create a SpeculativeExecutor with default configuration */ export declare function createSpeculativeExecutor(config?: Partial): SpeculativeExecutor; //# sourceMappingURL=speculative-executor.d.ts.map