/**
 * Repo-level configuration types for the AI Literacy Framework.
 *
 * These describe `.ailf/config.yaml` (`RepoConfig`) and the structural
 * contract on `.github/workflows/ailf-eval.yml` (`AilfEvalWorkflow`) used
 * by `ailf init` and the Tier 1 init contract test.
 *
 * Authored independently of the Zod schemas in
 * `packages/eval/src/adapters/task-sources/repo-schemas.ts` so the schemas
 * can `satisfies z.ZodType<...>` against them — making schema/type drift a
 * compile error rather than a silent regression (D0045 / W0187).
 *
 * Note on optionality: schema fields declared with `.optional()` produce
 * `T | undefined` from `z.infer`; we mirror that with `?:` properties.
 * Top-level `RepoConfig` itself has all optional groups because a
 * `.ailf/config.yaml` may legitimately omit any of them.
 */
import type { ProvenancePolicy } from "../services/provenance-policy.js";
/** Mode of an evaluation trigger — drives whether the run executes or just validates. */
export type TriggerMode = "validate-only" | "eval";
export interface TriggerConfig {
    blocking?: boolean;
    compare?: boolean;
    mode: TriggerMode;
    notify?: boolean;
    paths?: string[];
}
export interface ScheduleTriggerConfig extends TriggerConfig {
    cron: string;
}
/** Documentation source — which Sanity project's docs the eval reads. */
export interface RepoSourceConfig {
    baseUrl?: string;
    dataset?: string;
    projectId?: string;
    studioOrigin?: string;
}
/**
 * Documentation source setting — either the NAME of a registered source
 * (preset `production`/`branch`/`local`, or a `config/sources` entry) or
 * the inline-location object.
 *
 * Both `RepoConfig.source` and `EvalConfig.source` accept this union
 * (D0060 mitigation #2), so a source block copied between the two config
 * files stays valid. Prefer the named form: a name resolves through the
 * source registry, so run provenance records the registered
 * `source.name`. Inline values the registry cannot account for are
 * recorded as `source.name = "env-override"` and re-classified
 * `experimental` by the D0059 Tier-1 rule (excluded from default trusted
 * views) — the inline object is the escape hatch for genuinely custom
 * doc sites, not the default.
 */
export type RepoSourceSetting = string | RepoSourceConfig;
/** Report-store destination — which Sanity project receives `ailf.report` documents. */
export interface RepoReportStoreConfig {
    dataset: string;
    projectId: string;
}
/** Publish policy — when `ailf run` writes a report without an explicit flag. */
export interface RepoPublishConfig {
    auto?: "always" | "full-runs" | "never";
    tag?: string;
}
/** Execution-tier knobs — replaces the retired `--concurrency` / `--api-url` flags. */
export interface RepoExecutionConfig {
    apiUrl?: string;
    /**
     * Plan 03-04 GRAD-04 — replications per borderline judgment for the
     * intra-grader consensus pass. Default 3 (set in composition-root).
     * A judgment is "borderline" when its score lies within ±5 of any
     * severity boundary (30/50/60). Non-borderline judgments are not
     * re-graded.
     */
    borderlineReplications?: number;
    concurrency?: number;
    gapAnalysis?: boolean;
    graderReplications?: number;
}
/** Grader configuration. */
export interface RepoGraderConfig {
    /**
     * Grader context policy. Defaults to `"with-docs"` (W0200 flip after
     * DOC-2117 validation); set to `"rubric-only"` to opt back into the
     * legacy behavior.
     *
     * - `"rubric-only"` — grader sees only the rubric template + criteria +
     *   candidate response.
     * - `"with-docs"` — canonical reference content for each task is injected
     *   into the assertion's `rubricPrompt` so the grader has authoritative
     *   ground truth.
     */
    context?: "rubric-only" | "with-docs";
}
/** Where the pipeline writes results (replaces `--output-dir`). */
export interface RepoOutputConfig {
    dir?: string;
}
/** Run-attribution defaults (replaces `--owner-team` / `--owner-individual`). */
export interface RepoOwnerConfig {
    individual?: string;
    team?: string;
}
/**
 * Project-level run-provenance policy overrides. A project may only
 * *strengthen* the server floor (`mergeProvenancePolicy` takes the stricter
 * of the two per field and unions rules), never weaken it — so this is a
 * partial of the canonical {@link ProvenancePolicy}. Absent = the floor.
 *
 * @see packages/core/src/services/provenance-policy.ts
 * @see docs/design-docs/run-provenance-ownership-enforcement.md (§5 hybrid hook)
 */
export type RepoProvenanceConfig = Partial<ProvenancePolicy>;
/** Agentic-mode runtime config (replaces `--header` / `--allowed-origin`). */
export interface RepoAgenticConfig {
    allowedOrigins?: string[];
    headers?: Record<string, string>;
}
/** Artifact-writer config (replaces `--no-artifacts` / `--artifacts-dir` / `--artifacts-exclude`). */
export interface RepoArtifactsConfig {
    dir?: string;
    enabled?: boolean;
    exclude?: string[];
}
/** Task-source config (replaces `--task-source` / `--repo-tasks-path`). */
export interface RepoTaskSourceConfig {
    repoTasksPath?: string;
    type?: "content-lake" | "repo";
}
/** Trigger overrides keyed by trigger name. */
export interface RepoTriggersConfig {
    main?: TriggerConfig;
    pr?: TriggerConfig;
    "pr-task-change"?: TriggerConfig;
    schedule?: ScheduleTriggerConfig;
}
/**
 * Post-run diagnosis summary policy (Phase 6 / DIAG-06).
 * Controls whether `ailf run` auto-fires the in-process diagnosis runner
 * at the end of a published pipeline. Precedence is resolved at the CLI
 * layer — see `shouldRunPostSummary()` in `pipeline-action.ts`.
 */
export interface RepoSummaryConfig {
    /**
     * - `"auto"`   — fire only when `process.stdout.isTTY === true` AND
     *                `CI !== "true"`.
     * - `"always"` — fire unconditionally (bypasses TTY check).
     * - `"never"`  — never fire.
     */
    onRun?: "auto" | "always" | "never";
}
/**
 * Parsed shape of `.ailf/config.yaml`.
 *
 * Every field is optional at the top level because a config file may omit
 * any group. The Zod schema at `packages/eval/src/adapters/task-sources/repo-schemas.ts`
 * (`RepoConfigSchema`) asserts `satisfies z.ZodType<RepoConfig>` against
 * this type.
 */
export interface RepoConfig {
    agentic?: RepoAgenticConfig;
    artifacts?: RepoArtifactsConfig;
    execution?: RepoExecutionConfig;
    grader?: RepoGraderConfig;
    output?: RepoOutputConfig;
    owner?: RepoOwnerConfig;
    provenance?: RepoProvenanceConfig;
    publish?: RepoPublishConfig;
    reportStore?: RepoReportStoreConfig;
    source?: RepoSourceSetting;
    summary?: RepoSummaryConfig;
    taskSource?: RepoTaskSourceConfig;
    triggers?: RepoTriggersConfig;
}
/**
 * One step inside a GitHub Actions workflow job. Loose by design — this is
 * a structural contract, not a literal-byte one. Extra fields are accepted.
 */
export interface AilfEvalWorkflowStep {
    [extra: string]: unknown;
    env?: Record<string, unknown>;
    id?: string;
    if?: string;
    name?: string;
    run?: string;
    uses?: string;
    with?: Record<string, unknown>;
}
/**
 * One job entry inside a GitHub Actions workflow. Loose by design.
 */
export interface AilfEvalWorkflowJob {
    [extra: string]: unknown;
    name?: string;
    permissions?: Record<string, unknown>;
    "runs-on": string | string[];
    steps: AilfEvalWorkflowStep[];
}
/**
 * Structural shape of the `ailf-eval.yml` workflow template emitted by
 * `ailf init`. Validates the consumer-visible contract: a workflow with a
 * non-empty `name`, an `on` trigger spec, and at least one job. The
 * literal YAML body is intentionally not pinned — comments, step
 * ordering, and option flags can shift without breaking consumers.
 *
 * The Zod schema at `packages/eval/src/adapters/task-sources/repo-schemas.ts`
 * (`AilfEvalWorkflowSchema`) asserts `satisfies z.ZodType<AilfEvalWorkflow>`
 * against this type.
 */
export interface AilfEvalWorkflow {
    [extra: string]: unknown;
    jobs: Record<string, AilfEvalWorkflowJob>;
    name: string;
    on: unknown;
}
