/**
 * Multi-layer verifier — ordered pipeline of verification layers.
 *
 * Different contract from {@link JudgeRunner} (which runs parallel
 * specs against a sandbox). MultiLayerVerifier is a DAG of layers
 * (install → typecheck → build → lint → serve → semantic → …) with
 * dependency-based skip, per-layer findings, soft-fail semantics, and
 * an aggregated `blendedScore` across all passed layers.
 *
 * Use when you want:
 *   - ordered stages where a failing upstream stage skips downstream ones
 *   - each stage produces rich `findings` (severity + message + evidence)
 *   - a single composite score across stages with per-stage weights
 *   - soft-fail stages whose failure doesn't abort the pipeline
 *
 * Use {@link JudgeRunner} when you want:
 *   - N independent judges running in parallel against the same artifact
 *   - no inter-judge dependencies
 *   - boolean `passed` per judge + overall
 *
 * Both primitives compose — JudgeRunner can be invoked as a single
 * layer inside a MultiLayerVerifier if that suits the caller.
 */
import type { DefaultVerdict } from './verdict';
export type LayerStatus = 'pass' | 'fail' | 'skipped' | 'error' | 'timeout';
export type Severity = 'critical' | 'major' | 'minor' | 'info';
export interface Finding {
    severity: Severity;
    message: string;
    evidence?: string;
    /** Optional layer name the finding belongs to (set by the verifier if omitted). */
    layer?: string;
    /**
     * Free-form structured payload — used by `multiToolchainLayer` to attach
     * `{ adapter: 'pnpm' }`, by judges to attach evidence pointers, etc.
     * Renderers MAY interrogate; agent-eval primitives never assume shape.
     */
    detail?: Record<string, unknown>;
}
export interface LayerResult {
    layer: string;
    status: LayerStatus;
    /** 0..1 score, optional — layers that don't produce a numeric score omit. */
    score?: number;
    durationMs: number;
    findings: Finding[];
    /** Short human-readable summary (one line). */
    reason?: string;
    /**
     * Numeric layer-level diagnostics: error counts, warning counts,
     * cyclomatic complexity, total adapter wall-time, etc. Keyed by
     * diagnostic name; null = "diagnostic not applicable / not measured."
     * Renderers that know the keys can display them; ones that don't,
     * ignore. Free-form on purpose — consumers type the value shape in
     * their own namespace.
     */
    diagnostics?: Record<string, number | null>;
    /** Any rich per-layer detail — rendered as-is by consumers that know the layer. */
    detail?: Record<string, unknown>;
}
export interface VerifyContext<Env = unknown> {
    /** Per-run opaque context the caller provides. Layers destructure what they need. */
    env: Env;
    /** Previously-computed results from layers that already ran. */
    prior: Record<string, LayerResult>;
    /** Signal — if aborted, layers MUST bail within reasonable wall. */
    signal: AbortSignal;
}
export interface Layer<Env = unknown> {
    name: string;
    /** Stages that must have `status: 'pass'` before this layer runs. */
    dependsOn?: string[];
    /**
     * Weight in the composite `blendedScore`. Default 1.0. Layers with weight 0
     * contribute findings but not score.
     */
    weight?: number;
    /**
     * If true, a `fail` status contributes to `blendedScore` (as 0) instead of
     * being dropped — use for layers whose failure is a real signal. Default:
     * fail drops from numerator + denominator, matching VB's existing semantics.
     */
    failContributesToScore?: boolean;
    /** Optional per-layer wall-cap in ms. Honored by the verifier (AbortSignal). */
    capMs?: number;
    run: (ctx: VerifyContext<Env>) => Promise<LayerResult> | LayerResult;
}
export interface VerifyOptions<Env = unknown> {
    env: Env;
    /**
     * Overall wall cap. Default: sum of layer capMs, or Infinity if any layer
     * omits a cap. The verifier short-circuits remaining layers on overall cap.
     */
    overallCapMs?: number;
    /** Called with each layer result as it completes. */
    onLayer?: (result: LayerResult) => void;
}
/** Extends the substrate verdict spine: `valid` = `allPass` and `score` =
 *  `blendedScore` — derived where the report is aggregated, so spine
 *  consumers (drivers, gates) read this report without an adapter. */
export interface VerificationReport extends DefaultVerdict {
    layers: LayerResult[];
    passCount: number;
    failCount: number;
    skippedCount: number;
    errorCount: number;
    /** True iff at least one scored layer ran AND every scored layer passed. */
    allPass: boolean;
    /**
     * Weighted mean of `score` across contributing layers. 0 when no layers
     * contributed. See {@link Layer.failContributesToScore} for fail semantics.
     */
    blendedScore: number;
    durationMs: number;
    startedAt: string;
    finishedAt: string;
}
/**
 * Grade a semantic-concept-style judge result into a single layer status.
 *
 * Pass when overall score >= threshold AND no critical-severity concept gap.
 * Fail otherwise. Use inside a `Layer.run` when wrapping a concept judge.
 *
 * Generalized from VerticalBench H3 fix: `failingConcepts.length === 0` was
 * too strict — a single concept at 6/10 failed the entire layer despite
 * overall score being >= 0.7. Now we trust the judge's own `severity` field:
 * `critical` findings veto; `major`/`minor` reduce the score but don't veto.
 */
export declare function gradeSemanticStatus(input: {
    score: number;
    findings: Array<{
        severity: Severity;
        present?: boolean;
        score?: number;
    }>;
    available: boolean;
    threshold?: number;
}): LayerStatus;
export declare class MultiLayerVerifier<Env = unknown> {
    private readonly layers;
    constructor(layers: Layer<Env>[]);
    run(opts: VerifyOptions<Env>): Promise<VerificationReport>;
}
//# sourceMappingURL=multi-layer-verifier.d.ts.map