import { C as CaptureIntegrityError } from './errors-CzMUYo7b.js';
import { R as RawProviderSink } from './raw-provider-sink-C46HDghv.js';
import { T as TraceStore } from './store-BcFXE6LG.js';

/**
 * Run-completion integrity check — at end of run, verify the expected event
 * types were actually captured. The point is the launch-review failure mode:
 * a run *appears* successful but the raw provider events were never written,
 * so a downstream reviewer can't reconstruct what happened.
 *
 * Pattern:
 *
 *   const report = await assertRunCaptured(store, runId, {
 *     llmSpansMin: 1,
 *     judgeSpansMin: 1,
 *     rawSink: providerSink,                  // must have ≥ 1 event for this run
 *     requireRawCoverageOfLlmSpans: true,     // every llm span has matching raw events
 *   })
 *   if (!report.ok) throwIfRunIncomplete(report)  // or mark run failed and continue
 *
 * The function is read-only on the store and returns a structured report;
 * the caller chooses the failure mode (throw, mark run failed, log warning).
 * `throwIfRunIncomplete` is the convenient strict mode.
 */

interface RunIntegrityExpectations {
    /** Minimum LLM span count. Default 0 (no requirement). */
    llmSpansMin?: number;
    /** Minimum judge span count. Default 0. */
    judgeSpansMin?: number;
    /** Minimum tool span count. Default 0. */
    toolSpansMin?: number;
    /**
     * Raw provider sink to consult for capture verification. When present,
     * the check requires at least one raw event for the run.
     */
    rawSink?: RawProviderSink;
    /** Minimum raw provider event count. Default 0; ignored when `rawSink` absent. */
    rawProviderEventsMin?: number;
    /**
     * Every LLM span must have at least one matching raw `request` event
     * (matched by spanId). Catches the common bug where the structured span
     * was emitted but the raw HTTP capture was wired to a different sink.
     */
    requireRawCoverageOfLlmSpans?: boolean;
    /** Run outcome must be set (not null/undefined). Default false. */
    requireOutcome?: boolean;
}
type RunIntegrityIssueCode = 'no_run' | 'missing_llm_spans' | 'missing_judge_spans' | 'missing_tool_spans' | 'missing_raw_events' | 'no_raw_sink' | 'orphan_llm_span' | 'missing_outcome';
interface RunIntegrityIssue {
    code: RunIntegrityIssueCode;
    message: string;
    detail?: Record<string, unknown>;
}
interface RunIntegrityReport {
    ok: boolean;
    runId: string;
    llmSpanCount: number;
    judgeSpanCount: number;
    toolSpanCount: number;
    rawProviderEventCount: number;
    /**
     * Coverage of LLM spans by raw provider events keyed on spanId.
     * `total` is the number of LLM spans; `covered` is the count with at
     * least one matching `request` raw event.
     */
    rawSpanCoverage: {
        covered: number;
        total: number;
    };
    issues: RunIntegrityIssue[];
}
declare class RunIntegrityError extends CaptureIntegrityError {
    readonly report: RunIntegrityReport;
    constructor(report: RunIntegrityReport);
}
declare function assertRunCaptured(store: TraceStore, runId: string, expectations?: RunIntegrityExpectations): Promise<RunIntegrityReport>;
/** Strict mode: throws `RunIntegrityError` when the report isn't ok. */
declare function throwIfRunIncomplete(report: RunIntegrityReport): void;

export { type RunIntegrityExpectations as R, type RunIntegrityReport as a, RunIntegrityError as b, type RunIntegrityIssue as c, type RunIntegrityIssueCode as d, assertRunCaptured as e, throwIfRunIncomplete as t };
