import { D as DatasetSplit, c as DatasetManifest, a as DatasetScenario } from './dataset-BbGkaN2I.js';
import { m as GateDecision } from './summary-report-CInXwsza.js';
import { R as RunRecord, a as RunSplitTag } from './run-record-CP2ObebC.js';

/**
 * Release confidence gate.
 *
 * This is the production-facing composition layer over the lower-level
 * primitives:
 *   - Dataset manifests prove corpus/version coverage.
 *   - RunRecord rows prove reproducible search/holdout outcomes.
 *   - Multi-shot trace evidence carries turn counts and ASI diagnostics.
 *   - HeldOutGate decisions remain the paired promotion authority.
 *
 * The gate is intentionally pure and conservative. Missing declared evidence
 * fails closed instead of being treated as a neutral zero.
 */

/** Severity of an actionable finding attached to a run/trace. */
type AsiSeverity = 'info' | 'warning' | 'error' | 'critical';
/** Actionable side-info — a diagnosed finding the loop can act on. */
interface ActionableSideInfo {
    /** Stable expectation/check id when available. */
    expectationId?: string;
    /** Human-readable diagnosis of what happened. */
    message: string;
    severity?: AsiSeverity;
    /** Concrete trace excerpt, file path, tool call, screenshot id, etc. */
    evidence?: string;
    /** Prompt/tool/context surface likely responsible. */
    responsibleSurface?: string;
    /** Suggested fix in natural language. */
    suggestion?: string;
    /** Whether this expectation was satisfied. Defaults to false for ASI rows. */
    matched?: boolean;
    metadata?: Record<string, unknown>;
}
type ReleaseConfidenceStatus = 'pass' | 'warn' | 'fail';
type ReleaseConfidenceAxisName = 'corpus' | 'quality' | 'generalization' | 'diagnostics' | 'efficiency';
interface ReleaseTraceEvidence {
    scenarioId: string;
    candidateId?: string;
    split?: RunSplitTag;
    score?: number;
    ok?: boolean;
    turnCount?: number;
    costUsd?: number;
    durationMs?: number;
    failureMode?: string;
    asi?: ActionableSideInfo[];
    metadata?: Record<string, unknown>;
}
interface ReleaseConfidenceThresholds {
    /** Require a Dataset manifest or explicit scenarios. Default true. */
    requireCorpus?: boolean;
    minScenarioCount?: number;
    minSearchRuns?: number;
    minHoldoutRuns?: number;
    /** Require at least one holdout scenario/run. Default true. */
    requireHoldout?: boolean;
    minPassRate?: number;
    minMeanScore?: number;
    /** Search mean may exceed holdout mean by at most this much. */
    maxOverfitGap?: number;
    maxMeanCostUsd?: number;
    maxP95WallMs?: number;
    /** Low-score/failed rows must carry ASI. Default true. */
    requireAsiForFailures?: boolean;
    /** Score below this is considered a failure for ASI coverage. Default 0.5. */
    failureScoreThreshold?: number;
}
interface ReleaseConfidenceInput {
    target: string;
    candidateId?: string;
    baselineId?: string;
    dataset?: DatasetManifest;
    scenarios?: readonly DatasetScenario[];
    runs?: readonly RunRecord[];
    traces?: readonly ReleaseTraceEvidence[];
    gateDecision?: GateDecision | null;
    thresholds?: ReleaseConfidenceThresholds;
}
interface ReleaseConfidenceAxis {
    name: ReleaseConfidenceAxisName;
    status: ReleaseConfidenceStatus;
    score: number;
    detail: string;
}
interface ReleaseConfidenceIssue {
    axis: ReleaseConfidenceAxisName;
    severity: 'critical' | 'warning';
    code: string;
    detail: string;
}
interface ReleaseConfidenceMetrics {
    scenarioCount: number;
    searchRuns: number;
    holdoutRuns: number;
    passRate: number;
    meanScore: number;
    searchMeanScore: number;
    holdoutMeanScore: number;
    overfitGap: number;
    meanCostUsd: number;
    p95WallMs: number;
    failedRows: number;
    failuresWithAsi: number;
    singleShotTraces: number;
    multiShotTraces: number;
    splitCounts: Record<DatasetSplit, number>;
    domainCounts: Record<string, number>;
    failureModeCounts: Record<string, number>;
    responsibleSurfaceCounts: Record<string, number>;
}
interface ReleaseConfidenceScorecard {
    target: string;
    candidateId: string | null;
    baselineId: string | null;
    status: ReleaseConfidenceStatus;
    promote: boolean;
    axes: ReleaseConfidenceAxis[];
    issues: ReleaseConfidenceIssue[];
    metrics: ReleaseConfidenceMetrics;
    dataset: DatasetManifest | null;
    gateDecision: GateDecision | null;
    summary: string;
}
declare function evaluateReleaseConfidence(input: ReleaseConfidenceInput): ReleaseConfidenceScorecard;
declare function assertReleaseConfidence(input: ReleaseConfidenceInput): ReleaseConfidenceScorecard;

/**
 * Bootstrap-CI promotion gate.
 *
 * In any iterative-improvement loop (GEPA, prompt evolution, dataset
 * curation), the question is "did this generation actually improve, or are
 * we celebrating noise?". With small N and noisy outcomes, point-estimate
 * deltas lie. Bootstrap confidence intervals tell the operator whether the
 * delta is real before code or prompts get promoted.
 *
 * This module is pure functions — no I/O, no model calls. Easy to unit-test
 * and to compose into any verdict gate.
 *
 * Default gate:
 *   - Bootstrap mean baseline vs candidate (1k resamples).
 *   - Compute the delta distribution; pass if the lower CI bound > 0.
 *   - Tunable confidence (default 95%) and resample count.
 *
 * Verdict semantics intentionally match the existing `experiments.jsonl`
 * vocabulary:
 *   - ADVANCE: candidate's CI lower bound > baseline mean (real win)
 *   - KEEP:    overlap, but candidate point estimate >= baseline (neutral)
 *   - REVERT:  candidate's CI upper bound < baseline mean (real regression)
 *   - INCONCLUSIVE: not enough samples or CI straddles zero with no signal
 */
type Verdict = 'ADVANCE' | 'KEEP' | 'REVERT' | 'INCONCLUSIVE';
interface BootstrapResult {
    baselineMean: number;
    candidateMean: number;
    /** candidateMean - baselineMean, point estimate. */
    delta: number;
    /** Lower bound of the (1 - alpha) CI on the delta. */
    ciLower: number;
    /** Upper bound of the (1 - alpha) CI on the delta. */
    ciUpper: number;
    /** Number of bootstrap resamples used. */
    iterations: number;
    alpha: number;
    verdict: Verdict;
}
interface BootstrapOptions {
    /** Confidence level alpha (default 0.05 → 95% CI). */
    alpha?: number;
    /** Number of resamples (default 1000). */
    iterations?: number;
    /**
     * Minimum total samples (baseline + candidate) below which we always
     * return INCONCLUSIVE — bootstrap with too few samples is meaningless.
     * Default 6 (combined).
     */
    minTotalSamples?: number;
    /** RNG seed for reproducibility. Default: Math.random. */
    seed?: number;
}
/**
 * Compute the bootstrap CI on (candidateMean - baselineMean) and a verdict.
 *
 * Uses simple percentile bootstrap on the difference of resampled means.
 * That's the standard non-parametric primitive — no distributional
 * assumptions, robust to skew, easy to reason about.
 */
declare function bootstrapCi(baseline: number[], candidate: number[], options?: BootstrapOptions): BootstrapResult;
/**
 * Judge-replay promotion gate.
 *
 * The cheap inner-loop judge that drives an evolution run is by definition
 * fast and noisy. When you're about to promote a winning variant to the
 * canonical default, you want a STRONGER judge (a more expensive model, a
 * human grader, a separately-trained reward model) to confirm the win
 * generalises beyond the inner loop.
 *
 * This helper takes raw winner + baseline outputs, scores both through the
 * stronger judge, and applies `bootstrapCi`. ADVANCE means the stronger
 * judge agrees the winner is real with the configured confidence. Doesn't
 * matter what shape your "output" is — pass a string, an object, anything
 * the judge can read.
 */
interface JudgeReplayGateArgs<TOutput> {
    baselineOutputs: TOutput[];
    candidateOutputs: TOutput[];
    /** Stronger judge — async to allow LLM calls. Return a 0..N scalar score. */
    judge: (output: TOutput) => Promise<number> | number;
    alpha?: number;
    iterations?: number;
    /** RNG seed for reproducibility. */
    seed?: number;
    /** Maximum concurrent judge calls. Default 4. */
    judgeConcurrency?: number;
}
declare function judgeReplayGate<TOutput>(args: JudgeReplayGateArgs<TOutput>): Promise<BootstrapResult & {
    baselineSamples: number;
    candidateSamples: number;
}>;

interface RenderReleaseReportOptions {
    title?: string;
    runs?: readonly RunRecord[];
    comparator?: string;
    traceAnalystFindings?: readonly string[];
    nextActions?: readonly string[];
}
declare function renderReleaseReport(scorecard: ReleaseConfidenceScorecard, options?: RenderReleaseReportOptions): string;

export { type ActionableSideInfo as A, type BootstrapOptions as B, type JudgeReplayGateArgs as J, type ReleaseConfidenceAxis as R, type Verdict as V, type BootstrapResult as a, type ReleaseConfidenceAxisName as b, type ReleaseConfidenceInput as c, type ReleaseConfidenceIssue as d, type ReleaseConfidenceMetrics as e, type ReleaseConfidenceScorecard as f, type ReleaseConfidenceStatus as g, type ReleaseConfidenceThresholds as h, type ReleaseTraceEvidence as i, type RenderReleaseReportOptions as j, assertReleaseConfidence as k, bootstrapCi as l, evaluateReleaseConfidence as m, judgeReplayGate as n, type AsiSeverity as o, renderReleaseReport as r };
