/** * StreamingVerifier — orchestrator for the real-time verification pipeline. * * Wires CodeBuffer (token accumulation + code unit detection) with * StreamingChecks (pattern-based formal + learned checks) into a single * stateful pipeline. Feed it tokens, it buffers them, detects completed * code units, runs checks, and emits verification events. */ import type { CheckSeverity, StreamingVerifierStats, VerificationEvent } from './types.js'; import type { EntropyDetector } from './entropy-detector.js'; export interface StreamingVerifierOptions { language: string; /** Path to project root for loading learned rules catalog */ projectPath?: string; /** Callback fired for each verification event */ onEvent?: (event: VerificationEvent) => void; /** Only auto-correct findings at or above this severity. Default: 'high' */ minCorrectionSeverity?: CheckSeverity; /** * Enable adaptive verification depth based on BAS score. * When true: * - green (BAS < 0.3): skip formal checks for this block * - amber (BAS 0.3–0.7): queue formal checks for async execution * - red (BAS > 0.7): run formal checks immediately * When false (default): run all checks on every block (current behavior). */ adaptiveDepth?: boolean; /** * Optional entropy detector instance. When provided and adaptiveDepth is * true, the verifier consumes BAS depth from the detector to route checks. */ entropyDetector?: EntropyDetector; } export declare class StreamingVerifier { private readonly codeBuffer; private readonly checkSet; private readonly onEvent?; private readonly adaptiveDepth; private readonly entropyDetector?; private events; private unitsProcessed; private checksRun; private findingsCount; private totalTimeMs; private maxLatencyMs; private skippedGreen; private deferredAmber; private immediateRed; private deferredUnits; /** * Tracks the highest endOffset from any code unit we have processed. * Used by flush() to know where unchecked trailing code begins. */ private coveredOffset; constructor(options: StreamingVerifierOptions); /** * Feed tokens from the LLM stream. Returns any verification events triggered. */ push(tokens: string): VerificationEvent[]; /** * Flush the buffer — run checks on any remaining buffered code. * Call at the end of the stream to verify trailing code that never * reached a structural boundary (closing brace, semicolon, etc.). * Also processes any deferred (amber) code units. */ flush(): VerificationEvent[]; /** Get cumulative statistics. */ getStats(): StreamingVerifierStats; /** Get all findings (FAIL events) accumulated so far. */ getFindings(): VerificationEvent[]; /** Get the full generated code accumulated so far. */ getGeneratedCode(): string; /** Reset all state — buffer, events, stats. */ reset(): void; /** * Determine the adaptive verification depth for a code unit. * When adaptiveDepth is disabled or no entropy detector is available, * returns undefined (meaning: check everything). */ private getUnitDepth; /** * Run checks against a list of code units, accumulate stats, fire callbacks. * When adaptiveDepth is enabled, routes based on BAS: * green — skip formal checks (log as pass) * amber — defer checks (queued for later via flushDeferred) * red — run checks immediately */ private processUnits; /** * Process all deferred (amber) code units. Call this when the statement * completes or at stream end to run checks on amber-queued blocks. * Returns any verification events from the deferred checks. */ flushDeferred(): VerificationEvent[]; /** Get adaptive depth routing statistics. */ getDepthStats(): { skippedGreen: number; deferredAmber: number; immediateRed: number; pendingDeferred: number; }; }