/**
 * Replay-validated repair — WHAT SHOULD HAVE HAPPENED?
 *
 * Takes the blamed steps from a `CausalResponsibilityReport`, asks a
 * consumer-supplied `proposeFix` (LLM-backed in live use) for candidate
 * mutations, and machine-verifies each candidate by replaying the run
 * WITH the mutation applied (through the same `runCounterfactual` seam
 * the sweep uses).
 *
 * A repair is "what should have happened" ONLY when every validation
 * replay crosses `flipThreshold` — a prescription is never speculated,
 * it is demonstrated. Candidates that don't flip, or whose replay
 * errors, land in `rejected` with a typed reason; nothing is dropped
 * silently.
 */
import { type CounterfactualMutation, type CounterfactualRunner } from '../counterfactual';
import type { TraceStore } from '../trace/store';
import { type Trajectory, type TrajectoryStep } from '../trajectory';
import type { StepRef, StepResponsibility } from './causal-sweep';
/** Context handed to `proposeFix` so an LLM-backed proposer can see the
 *  full trajectory plus the responsibility evidence for the blamed step. */
export interface RepairContext {
    runId: string;
    trajectory: Trajectory;
    originalScore: number;
    responsibility: StepResponsibility;
}
export interface PrescribeRepairOptions {
    store: TraceStore;
    /** The failed run the sweep diagnosed. */
    runId: string;
    /** Execution seam — same `CounterfactualRunner` contract as the sweep. */
    runner: CounterfactualRunner;
    /** Blamed steps from `causalSweep` — typically `report.steps.slice(0, k)`. */
    blamed: StepResponsibility[];
    /** Candidate-fix generator. Consumer-supplied; LLM-backed in live use.
     *  Returned mutations MUST target the blamed step's index. */
    proposeFix: (step: TrajectoryStep, context: RepairContext) => Promise<CounterfactualMutation[]>;
    /** Score every validation replay must reach for the repair to count. Default 0.5. */
    flipThreshold?: number;
    /** Validation replays per candidate mutation. Default 3. */
    repsToValidate?: number;
    /** Max candidate mutations tried per step. Default: all proposed. */
    maxAttemptsPerStep?: number;
}
export interface ValidatedRepair {
    stepRef: StepRef;
    mutation: CounterfactualMutation;
    /** Always true — presence in `repairs` IS the machine-verified claim. */
    validated: true;
    /** Mean counterfactual score across the validation reps. */
    meanScore: number;
    /** meanScore − originalScore. */
    deltaScore: number;
    reps: number;
    /** Replay run ids backing the validation — audit trail. */
    counterfactualRunIds: string[];
}
export interface RejectedRepair {
    stepRef: StepRef;
    mutation: CounterfactualMutation;
    reason: 'did-not-flip' | 'error';
    /** Present for 'did-not-flip': mean delta over the reps that ran. */
    deltaScore?: number;
    /** Present for 'error': the message, preserved for diagnosis. */
    error?: string;
}
export interface RepairReport {
    runId: string;
    originalScore: number;
    flipThreshold: number;
    repairs: ValidatedRepair[];
    rejected: RejectedRepair[];
    replaysUsed: number;
}
export declare function prescribeRepair(opts: PrescribeRepairOptions): Promise<RepairReport>;
//# sourceMappingURL=repair.d.ts.map