/** * Agentic QE v3 - Early Exit Controller * ADR-033: Lambda-stability decisions with speculative execution * * This module implements the main controller that orchestrates early exit testing, * combining quality signal calculation, decision making, and speculative execution. */ import { EarlyExitConfig, EarlyExitDecision, TestLayer, TestPyramidResult, LayerResult, SpeculativeResult, QualitySignal, EarlyExitMetrics } from './types'; /** * Layer executor function type */ export type LayerExecutor = (layer: TestLayer) => Promise; /** * Event emitter for progress tracking */ export interface EarlyExitEvents { onLayerStart?: (layer: TestLayer) => void; onLayerComplete?: (layer: TestLayer, result: LayerResult, signal: QualitySignal) => void; onDecision?: (decision: EarlyExitDecision, layer: number) => void; onEarlyExit?: (exitLayer: number, decision: EarlyExitDecision) => void; onSpeculationComplete?: (speculations: SpeculativeResult[]) => void; onComplete?: (result: TestPyramidResult) => void; } /** * EarlyExitController - Main orchestrator for early exit testing * * This controller manages the complete early exit testing workflow: * 1. Executes test layers sequentially * 2. Calculates quality signals after each layer * 3. Makes early exit decisions based on lambda stability * 4. Generates speculative predictions for skipped layers * 5. Optionally verifies speculations * * @example * ```typescript * const controller = new EarlyExitController(config, 4); * * const result = await controller.runWithEarlyExit(layers, async (layer) => { * // Execute actual tests and return result * return await testRunner.run(layer); * }); * * console.log(`Exited at layer ${result.exitLayer}, saved ${result.computeSavings}ms`); * ``` */ export declare class EarlyExitController { private readonly config; private readonly totalLayers; private readonly earlyExit; private readonly speculator; private layerResults; private qualitySignals; private executionMetrics; private events; constructor(config: Partial | undefined, totalLayers: number); /** * Run test pyramid with early exit support * * @param layers - Test layers to execute * @param executor - Function to execute a single layer * @returns Complete test pyramid result with early exit information */ runWithEarlyExit(layers: TestLayer[], executor: LayerExecutor): Promise; /** * Execute a single test layer */ private executeLayer; /** * Create pyramid result object */ private createPyramidResult; /** * Estimate compute savings from early exit */ private estimateComputeSavings; /** * Create default quality signal */ private createDefaultSignal; /** * Create default decision */ private createDefaultDecision; /** * Log decision for debugging */ private logDecision; /** * Initialize metrics */ private initializeMetrics; /** * Update metrics after execution */ private updateMetrics; /** * Set event handlers */ setEvents(events: EarlyExitEvents): void; /** * Get current metrics */ getMetrics(): EarlyExitMetrics; /** * Get layer result by index */ getLayerResult(index: number): LayerResult | undefined; /** * Get quality signal by layer index */ getQualitySignal(index: number): QualitySignal | undefined; /** * Get decision history */ getDecisionHistory(): ReadonlyArray; /** * Get speculation statistics */ getSpeculationStats(): { total: number; verified: number; correct: number; accuracy: number; outcomeBreakdown: Record; }; /** * Reset controller state */ reset(): void; /** * Clear all state including metrics */ clearAll(): void; /** * Get configuration */ getConfig(): Readonly; } /** * Create an EarlyExitController with default configuration */ export declare function createEarlyExitController(totalLayers?: number): EarlyExitController; /** * Create an EarlyExitController with aggressive configuration */ export declare function createAggressiveController(totalLayers?: number): EarlyExitController; /** * Create an EarlyExitController with conservative configuration */ export declare function createConservativeController(totalLayers?: number): EarlyExitController; /** * Create an EarlyExitController with custom configuration */ export declare function createCustomController(config: Partial, totalLayers?: number): EarlyExitController; //# sourceMappingURL=early-exit-controller.d.ts.map