/**
 * Storage schema types for Content Lake documents.
 *
 * All AILF document types include `schemaVersion` for forward-compatible
 * migration. Full trace data goes to blob storage (GCP/local); only
 * sanitized summaries are stored in Content Lake.
 *
 * SECURITY: The `next` dataset is publicly accessible. Never store
 * sensitive data (API keys, full tool call arguments, raw outputs with
 * PII) in Content Lake. Use blob storage + traceDataUri references.
 *
 * @see docs/design-docs/architecture-overhaul/storage-schema.md
 */
import type { ErrorClassification } from "../services/error-classification.js";
import type { VariableEnvelope } from "./variable-envelope.js";
/**
 * One task where every model × variant expansion errored (produced no
 * gradeable output). Carried on {@link ErrorSummary.fullyErroredTasks}.
 */
export interface FullyErroredTask {
    /** Task id (variant suffix stripped — `(gold)` / `(baseline)` collapsed). */
    taskId: string;
    /** Resolved feature area for the task. */
    area: string;
    /** Classification of the first errored expansion's error string. */
    classification: ErrorClassification;
    /** First error message for the task, truncated to ~280 chars. */
    sampleError: string;
}
/**
 * Typed error signal on `report.summary` (eval failure observability, slice
 * B1). Distinct from `summary.failureModes`: `failureModes` classifies graded
 * doc-quality judgments; `errorSummary` is about tests that produced NO
 * gradeable output at all.
 *
 * Optional + additive — absent on reports published before the field existed;
 * consumers treat a missing `errorSummary` as "no error data". Because
 * cache-served runs inherit the summary, `errorSummary` rides along
 * unchanged across cache hits.
 *
 * Authored independently of the Zod schema so the schema can assert
 * `satisfies z.ZodType<ErrorSummary>` and turn drift into a build error
 * (D0045).
 *
 * @see docs/design-docs/eval-failure-observability.md — Data model and
 *      classification (shared keystone)
 */
export interface ErrorSummary {
    /** All results this run produced, including errored ones. */
    totalTestCount: number;
    /** Results with no gradingResult (errored before grading). */
    erroredTestCount: number;
    /** `erroredTestCount / totalTestCount`, in `[0, 1]`. `0` when total is 0. */
    errorRate: number;
    /** Tasks where every model × variant expansion errored. */
    fullyErroredTasks: FullyErroredTask[];
    /** Errored-result counts bucketed by {@link ErrorClassification}. */
    byClassification: Record<ErrorClassification, number>;
}
/** Current schema version for all AILF document types */
export declare const CURRENT_SCHEMA_VERSION = 1;
/** Schema-versioned document base */
export interface SchemaVersioned {
    /** Schema version for forward-compatible migration */
    schemaVersion: number;
}
/** An evaluation run — one execution of the pipeline */
export interface StoredRun extends SchemaVersioned {
    _type: "ailf.run";
    _id: string;
    /** ISO timestamp when the run started */
    startedAt: string;
    /** ISO timestamp when the run completed */
    completedAt?: string;
    /** Run status */
    status: "completed" | "failed" | "running";
    /** Evaluation mode used */
    mode: string;
    /** Models evaluated */
    models: {
        id: string;
        label: string;
    }[];
    /** Grader model used */
    graderModel: string;
    /** Number of tasks evaluated */
    taskCount: number;
    /** Run-level aggregate score (0-100) */
    overallScore?: number;
    /** Per-area scores */
    areaScores?: {
        areaId: string;
        score: number;
    }[];
    /** Pipeline configuration fingerprint (for cache invalidation) */
    configFingerprint?: string;
    /** Git context at run time */
    git?: {
        branch: string;
        sha: string;
        repo: string;
    };
    /** Run metadata */
    metadata?: Record<string, unknown>;
}
/** Result for one task × one model */
export interface StoredTaskResult extends SchemaVersioned {
    _type: "ailf.taskResult";
    _id: string;
    /** Reference to parent run */
    runRef: {
        _type: "reference";
        _ref: string;
    };
    /** Reference to task definition */
    taskRef: {
        _type: "reference";
        _ref: string;
    };
    /** Task ID (denormalized for querying) */
    taskId: string;
    /** Model that produced this result */
    modelId: string;
    /** Overall task score (0-100) */
    score: number;
    /** Per-dimension scores */
    dimensions: {
        dimensionId: string;
        score: number;
        weight: number;
        assertionCount: number;
        passCount: number;
    }[];
    /** Whether task passed its quality threshold */
    passesThreshold: boolean;
    /** Input variable envelope (provenance tracking) */
    inputEnvelope?: VariableEnvelope;
    /** Output variable envelope */
    outputEnvelope?: VariableEnvelope;
    /** URI to full trace payload in blob storage */
    traceDataUri?: string;
    /** Sanitized trace summary (safe for public dataset) */
    traceSummary?: {
        toolCallCount: number;
        toolCallCategories: Record<string, number>;
        totalTokens: number;
        costEstimate: number;
        durationMs: number;
    };
    /** Evaluation mode */
    mode: string;
    /** Mode-specific metadata */
    modeMetadata?: Record<string, unknown>;
}
/** Aggregated report for a run */
export interface StoredReport extends SchemaVersioned {
    _type: "ailf.report";
    _id: string;
    /** Reference to parent run */
    runRef: {
        _type: "reference";
        _ref: string;
    };
    /** ISO timestamp */
    createdAt: string;
    /** Report tag/label */
    tag?: string;
    /** Overall score */
    overallScore: number;
    /** Per-area breakdown */
    areas: {
        areaId: string;
        score: number;
        taskCount: number;
        passingCount: number;
    }[];
    /** Per-model breakdown */
    models: {
        modelId: string;
        score: number;
    }[];
    /** Human-readable markdown summary */
    summary?: string;
}
/** Baseline snapshot for comparison */
export interface StoredBaseline extends SchemaVersioned {
    _type: "ailf.baseline";
    _id: string;
    /** ISO timestamp when baseline was saved */
    savedAt: string;
    /** Label for this baseline */
    label?: string;
    /** Reference to the run this baseline was taken from */
    runRef: {
        _type: "reference";
        _ref: string;
    };
    /** Per-task scores at baseline time */
    taskScores: {
        taskId: string;
        score: number;
        dimensions: Record<string, number>;
    }[];
    /** Per-area scores at baseline time */
    areaScores: {
        areaId: string;
        score: number;
    }[];
}
/** Trace summary document in Content Lake */
export interface StoredTrace extends SchemaVersioned {
    _type: "ailf.trace";
    _id: string;
    /** Reference to parent run */
    runRef: {
        _type: "reference";
        _ref: string;
    };
    /** Reference to task result */
    taskResultRef: {
        _type: "reference";
        _ref: string;
    };
    /** URI to full trace payload in blob storage */
    traceDataUri: string;
    /** Task ID (denormalized) */
    taskId: string;
    /** Model ID */
    modelId: string;
    /** Tool call count */
    toolCallCount: number;
    /** Tool call category breakdown */
    toolCallCategories: Record<string, number>;
    /** Total tokens consumed */
    totalTokens: number;
    /** Cost estimate in USD */
    costEstimate: number;
    /** Duration in milliseconds */
    durationMs: number;
}
/** Check if a document is schema-versioned */
export declare function isSchemaVersioned(doc: unknown): doc is SchemaVersioned;
/** Migrate a document to the current schema version (no-op for v1) */
export declare function migrateDocument<T extends SchemaVersioned>(doc: T): T;
