/** * Agentic QE v3 - Early Exit Decision Engine * ADR-033: Lambda-stability decisions with speculative execution * * This module implements the CoherenceEarlyExit class that evaluates * whether to exit early from test pyramid execution based on quality signals. */ import { EarlyExitConfig, EarlyExitDecision, ExitReason, QualitySignal } from './types'; /** * CoherenceEarlyExit - Main decision engine for early exit testing * * Uses lambda stability instead of learned classifiers: * - High lambda + stable lambda-delta = confident exit * - Low lambda or volatile lambda-delta = continue to deeper layers * * @example * ```typescript * const earlyExit = new CoherenceEarlyExit(DEFAULT_EXIT_CONFIG, 4); * * // After each layer execution * const signal = calculateQualitySignal(layerResult, previousSignal); * const decision = earlyExit.shouldExit(signal, currentLayer); * * if (decision.canExit) { * console.log(`Early exit at layer ${decision.exitLayer}: ${decision.explanation}`); * } * ``` */ export declare class CoherenceEarlyExit { private readonly config; private readonly totalLayers; private signalHistory; private decisionHistory; constructor(config: Partial | undefined, totalLayers: number); /** * Evaluate whether to exit early at the given layer * * @param signal - Quality signal from current layer * @param layer - Current layer index (0-indexed) * @returns Decision on whether to exit early */ shouldExit(signal: QualitySignal, layer: number): EarlyExitDecision; /** * Calculate adaptive exit layer based on lambda stability * * Higher stability allows exiting earlier in the pyramid. */ private calculateAdaptiveExitLayer; /** * Evaluate all exit conditions and make decision */ private evaluateExitConditions; /** * Create an early exit decision object */ private createDecision; /** * Get the signal history for analysis */ getSignalHistory(): ReadonlyArray; /** * Get the decision history for analysis */ getDecisionHistory(): ReadonlyArray; /** * Reset the decision engine state */ reset(): void; /** * Get current configuration */ getConfig(): Readonly; /** * Calculate compute savings estimate based on skipped layers * * @param exitLayer - Layer at which exit occurred * @param layerDurations - Historical average durations per layer * @returns Estimated compute savings in milliseconds */ estimateComputeSavings(exitLayer: number, layerDurations?: number[]): number; /** * Get statistics about early exit decisions */ getStatistics(): { totalDecisions: number; earlyExits: number; exitRate: number; avgConfidence: number; exitReasonBreakdown: Record; }; } /** * Create a CoherenceEarlyExit instance with default configuration */ export declare function createEarlyExit(totalLayers?: number): CoherenceEarlyExit; /** * Create a CoherenceEarlyExit instance with aggressive configuration * For fast feedback in development environments */ export declare function createAggressiveEarlyExit(totalLayers?: number): CoherenceEarlyExit; /** * Create a CoherenceEarlyExit instance with conservative configuration * For high-risk changes requiring thorough validation */ export declare function createConservativeEarlyExit(totalLayers?: number): CoherenceEarlyExit; /** * Create a CoherenceEarlyExit instance with custom configuration */ export declare function createCustomEarlyExit(config: Partial, totalLayers?: number): CoherenceEarlyExit; //# sourceMappingURL=early-exit-decision.d.ts.map