/**
 * Pipeline-request domain types.
 *
 * Authored independently of `PipelineRequestSchema` in
 * `packages/core/src/schemas/pipeline-request.ts` so the schema can
 * `satisfies z.ZodType<PipelineRequest>` against this type — making
 * schema/type drift a compile error rather than a silent regression
 * (D0045 / W0187).
 *
 * `PipelineRequestSchema` is the universal pipeline invocation contract,
 * shared between the API gateway (POST /v1/pipeline), the CLI (`--config`
 * flag), and GitHub Actions workflows (`repository_dispatch` payload).
 *
 * Names here are prefixed `PipelineRequest*` to avoid colliding with the
 * existing `DebugOptions` in `core/types/index.ts`, which has a stricter
 * (required `enabled`) shape used by other pipeline code.
 */
import type { EventType, LiteracyVariant, RawEvalMode, RunClassification, RunExecutorSurface } from "../../ailf-shared/index.d.ts";
import type { GeneralizedDocRef } from "./generalized-task.js";
/** Debug-mode options as accepted on the wire (looser than core's `DebugOptions`). */
export interface PipelineRequestDebug {
    enabled?: boolean;
    firstN?: number;
    pattern?: string;
    sample?: number;
}
/** Webhook callback target for API-triggered evaluations. */
export interface PipelineRequestCallback {
    headers?: Record<string, string>;
    url: string;
    /** Events that trigger the callback. Empty/absent = all events. */
    events?: EventType[];
}
/**
 * Git context from the *calling* repository (not the AILF runner repo).
 * Carries provenance across cross-repo dispatches.
 */
export interface PipelineRequestCallerGit {
    branch?: string;
    prNumber?: number;
    repo: string;
    sha?: string;
}
/**
 * Caller-side `RunOwner` payload (D0037). Team is required; individual
 * optional.
 */
export interface PipelineRequestCallerOwner {
    individual?: string;
    team: string;
}
/**
 * Caller-side executor payload — user variant only. System executors are
 * always server-detected; the wire format excludes them. The Zod schema
 * is `.strict()` to reject any unknown key (PII guard).
 */
export interface PipelineRequestCallerExecutor {
    githubActor?: string;
    name?: string;
    surface: RunExecutorSurface;
    type: "user";
}
/** Task-source override (W0077 Phase 6h) — mirrors `RepoConfig.taskSource`. */
export interface PipelineRequestTaskSource {
    repoTasksPath?: string;
    type?: "content-lake" | "repo";
}
/**
 * The universal pipeline invocation contract.
 *
 * The Zod schema at `packages/core/src/schemas/pipeline-request.ts`
 * (`PipelineRequestSchema`) asserts `satisfies z.ZodType<PipelineRequest>`
 * against this type. Field set must match the schema exactly.
 */
export interface PipelineRequest {
    allowedOrigins?: string[];
    areas?: string[];
    backend?: "cloud-run" | "github-actions";
    callback?: PipelineRequestCallback;
    callerGit?: PipelineRequestCallerGit;
    /**
     * Narrowing filter on the task pool: keep only tasks whose
     * `context.docs[*]` matches an entry, dropping tasks with no
     * `context.docs`. A bare `string` entry keeps exact slug-match semantics;
     * a `GeneralizedDocRef` entry matches on its strongest available key (id,
     * then path, then slug) per D0090. The union is additive — every existing
     * `string[]` payload type-checks and behaves identically.
     */
    changedDocs?: (string | GeneralizedDocRef)[];
    classification?: RunClassification;
    compare?: boolean;
    compareBaseline?: string;
    /**
     * Compare against a baseline extracted from a previously-published
     * `ailf.report` document. Takes precedence over `compareBaseline`
     * (local FS path). Dashboard-friendly: a report id is something the
     * user can pick from a list.
     */
    compareBaselineReportId?: string;
    compareThreshold?: number;
    concurrency?: number;
    dataset?: string;
    debug?: PipelineRequestDebug | boolean;
    /**
     * Fetch-time source-set override (the `--sanity-document <id>` path). Each
     * entry is a Sanity `_id`; resolution replaces the canonical doc on a slug
     * match and appends otherwise, exactly as the local `sanityDocumentArgs`
     * override does (`configToSourceOverrides` → `SourceOverrides.documentIds`).
     * Carried on the wire so `ailf run --remote` no longer drops the override
     * (D0090); the server maps it back to `ResolvedConfig.sanityDocumentArgs`.
     */
    documentIds?: string[];
    executor?: PipelineRequestCallerExecutor;
    borderlineReplications?: number;
    gapAnalysis?: boolean;
    graderContext?: "rubric-only" | "with-docs";
    graderReplications?: number;
    headers?: Record<string, string>;
    /**
     * Documentation references to append to every in-scope task's
     * `context.docs[]` at load time (doc-impact evaluation). Same shape as
     * `task.context.docs[]`. Prefer `IdDocRef` ({ id, slug?, path? }) — the
     * `_id` is authoritative; slug/path are informational. Resolution and
     * fetch happen exactly as for an authored doc ref.
     */
    injectContextDocs?: GeneralizedDocRef[];
    inlineTasks?: Record<string, unknown>[];
    jobId?: string;
    labels?: string[];
    mode?: RawEvalMode;
    /**
     * Filter the evaluation cohort to a subset of the configured model IDs.
     *
     * Each entry must match the `id` of a model declared in
     * `packages/eval/config/models.ts`. IDs that don't match are dropped
     * with a structured warning AND surfaced on the job's `error` field so
     * callers can detect typos — silent strips are not acceptable
     * (W0281 acceptance criterion 5).
     */
    models?: string[];
    noAutoScope?: boolean;
    noCache?: boolean;
    noRemoteCache?: boolean;
    owner?: PipelineRequestCallerOwner;
    perspective?: string;
    presets?: string[];
    projectId?: string;
    publish?: boolean;
    publishTag?: string;
    purpose?: string;
    /**
     * Opt-in registration of the submitted task suite into the Content Lake
     * (external-task mirroring). Default (omitted) = false, so every existing
     * caller is unaffected. When true on a cross-repo (`taskSource.type:
     * "repo"`) run, the mirror step writes the suite as `ailf.task` documents
     * under the caller's resolved owning team; the gateway pre-flight and the
     * pipeline gate both refuse with a structured, caller-actionable error
     * rather than skip silently.
     */
    registerTasks?: boolean;
    searchMode?: "off" | "open" | "origin-only";
    source?: string;
    sourceReportId?: string;
    /** Studio origin override — maps to `ResolvedConfig.studioOriginOverride`. */
    studioOrigin?: string;
    taskMode?: "content-lake" | "inline";
    taskSource?: PipelineRequestTaskSource;
    tasks?: string[];
    urls?: string[];
    variant?: LiteracyVariant;
}
