/** * CorrectionInjector — decides whether to correct a finding mid-stream * and builds the prompt messages for re-generation. * * Strategy: Prefill technique (Option B). * When a finding triggers: * 1. Stop the current stream * 2. Take all text generated so far as the assistant's partial response (prefill) * 3. Add a user message explaining the issue and requesting a fix * 4. Resume generation — the LLM continues from where it left off */ import type { CheckSeverity, VerificationEvent } from './types.js'; declare const SEVERITY_RANK: Record; export interface CorrectionInjectorOptions { /** Only correct findings at or above this severity. Default: 'high' */ minSeverity?: CheckSeverity; /** Maximum corrections per stream to avoid infinite loops. Default: 5 */ maxCorrections?: number; } export interface CorrectionMessage { role: 'user' | 'assistant'; content: string; } export declare class CorrectionInjector { private readonly minSeverity; private readonly maxCorrections; private correctionCount; constructor(options?: CorrectionInjectorOptions); /** * Decide if this finding warrants stopping and correcting. * * Returns false when: * - verdict is not FAIL * - severity is below minSeverity * - maxCorrections has been reached */ shouldCorrect(event: VerificationEvent): boolean; /** * Build the messages array for the correction re-generation. * * Uses the Anthropic API prefill technique: * 1. Original user prompt * 2. Assistant prefill (everything generated so far) * 3. User message explaining the issue * * The system prompt is passed separately to the API, not included here. */ buildCorrectionMessages(generatedSoFar: string, event: VerificationEvent, _originalSystemPrompt: string, originalUserPrompt: string): CorrectionMessage[]; /** Record that a correction was made (for tracking max corrections). */ recordCorrection(_event: VerificationEvent): void; /** Get number of corrections made so far. */ getCorrectionCount(): number; /** Reset correction counter (e.g. for a new stream). */ reset(): void; } export { SEVERITY_RANK };