import type { GoldenPatch, GoldenTrajectory, GoldenCustomMetrics, Stimulus, StimulusGraderConfig, ReasoningEffort, JudgeProviderSpec } from "../eval/types.js"; import type { GraderRegistry } from "../graders/registry.js"; import type { GraderResult } from "../graders/types.js"; import type { AtifTrajectory } from "../trajectory/atif-types.js"; import type { Trajectory } from "../trajectory/types.js"; import { type GradeTrajectoryOptions } from "./grading.js"; export interface OracleGradingOptions { /** Grader configs to run (typically `stimulus.graders`). */ graders: StimulusGraderConfig[]; /** Grader registry. Defaults to the built-in registry inside `gradeTrajectory`. */ registry?: GraderRegistry; /** Default model for LLM judge graders. */ judgeModel?: string; /** Reasoning effort for the LLM judge model. */ judgeReasoningEffort?: ReasoningEffort; /** BYOK provider for the LLM judge (`defaults.judge_provider`). */ judgeProvider?: JudgeProviderSpec; /** Grader weights from `scoring.weights`. */ weights?: Record; /** Per-grader progress callbacks (forwarded to {@link gradeTrajectory}). */ onGraderStart?: GradeTrajectoryOptions["onGraderStart"]; onGraderComplete?: GradeTrajectoryOptions["onGraderComplete"]; } export interface OracleOptions { /** The (resolved) stimulus whose golden inputs are materialized. */ stimulus: Stimulus; /** Base dir for resolving relative paths in the environment and golden inputs. */ baseDir?: string; /** Apply golden patch, trajectory, and custom metrics. Defaults to `true`. */ applyGoldenInputs?: boolean; /** Pass grading options to run graders, or `false` to stop after materialization. */ grading: false | OracleGradingOptions; /** Keep the materialized workspace when materialization or grading throws. */ keepWorkspaceOnError?: boolean; /** * Materialize into this caller-owned directory instead of a temp dir. The * directory is created if missing and never deleted by {@link OracleResult.cleanup} * — the caller controls its lifecycle (mirrors `eval --workspace`). */ workspaceDir?: string; } export type OracleResult = { /** The trajectory describing the materialized golden inputs. */ trajectory: Trajectory; /** The materialized golden inputs represented as an ATIF document. */ atif: AtifTrajectory; /** The materialized workspace directory. */ workDir: string; /** Whether the golden patch was applied. */ patched: boolean; /** Idempotent cleanup — removes the workspace and any git worktree. */ cleanup: () => Promise; } & (Graded extends true ? { graded: true; gradeResult: GraderResult; } : { graded: false; gradeResult: null; }); /** Resolve a golden patch to its unified-diff text, or `undefined` if unset. */ export declare function resolveGoldenPatch(goldenPatch: GoldenPatch | undefined, baseDir?: string): Promise; /** * Resolve a golden trajectory to a validated ATIF document, or `undefined` if * unset. `inline` is validated directly; `path` is read from a confined JSON * file (same confinement rules as golden patches) and parsed before validation. */ export declare function resolveGoldenTrajectory(goldenTrajectory: GoldenTrajectory | undefined, baseDir?: string): Promise; /** * Resolve golden custom metrics to a plain object, or `undefined` if unset. * `inline` is returned directly; `path` is read from a confined JSON file (same * confinement as golden patches) and parsed. The value is the document the * `custom-metrics` grader reads (a flat object, or an envelope nesting them * under `values`). */ export declare function resolveGoldenCustomMetrics(goldenCustomMetrics: GoldenCustomMetrics | undefined, baseDir?: string): Promise | undefined>; /** * Apply a unified-diff patch to `workDir` via `git apply` (works inside and * outside a git repo). The patch file is written outside `workDir` so it * can't accidentally match its own paths. */ export declare function applyGoldenPatch(patch: string, workDir: string): Promise; /** Graders that read `trajectory.output` — oracle sets that to the patch diff, not an agent answer. */ export declare const OUTPUT_SCOPED_GRADER_TYPES: ReadonlySet; /** * Graders that inspect the agent's events, metrics, or conversation transcript — * oracle's synthesized trajectory has none of these. */ export declare const TRAJECTORY_SCOPED_GRADER_TYPES: ReadonlySet; /** * Grader types oracle can grade meaningfully (file-state, diff, and LLM judges). * Oracle exposes the golden patch as the workspace diff, so diff graders grade * the patch itself. Together with the two reject sets above, these partition * every default grader — the drift-guard test enforces it. */ export declare const ORACLE_SUPPORTED_GRADER_TYPES: ReadonlySet; /** * Whether an ATIF document has user-delimited turns. Turn stamping advances only * on root `user` steps, so an ATIF with none collapses every event to turn 0 — * turn-scoped grading against it would mis-slice. */ export declare function atifHasUserTurns(atif: AtifTrajectory): boolean; /** Validates every grader config is supported under oracle. Throws a clear, actionable error if not. */ export declare function assertOracleGraders(graderConfigs: StimulusGraderConfig[], options?: { /** * Whether the stimulus supplies a golden_trajectory (real events/output per * turn) AND it is being applied. Defaults to `false`. In baseline mode * (`applyGoldenInputs: false`) the golden trajectory is withheld, so pass * `false` here even when the stimulus defines one — the baseline check runs * first regardless, but keeping this consistent avoids ambiguity. */ hasGoldenTrajectory?: boolean; /** Whether that golden_trajectory delimits user turns; required for turn-scoped graders. Defaults to `false`. */ goldenTrajectoryHasTurns?: boolean; /** * Whether golden inputs are being applied (apply mode). Defaults to `true` * — only an explicit `false` selects baseline (`--no-golden-input`) mode, * where trajectory-/output-scoped graders are permitted so they can run and * fail against the empty baseline as a negative control. This mode check * takes precedence over `hasGoldenTrajectory`. */ applyGoldenInputs?: boolean; }): void; /** How a single grader behaved under the oracle baseline (negative control). */ export type OracleBaselineGraderOutcome = "expected-fail" | "n/a" | "unexpected-pass" | "error"; export interface OracleBaselineGraderVerdict { name: string; graderType?: string; passed: boolean; outcome: OracleBaselineGraderOutcome; } export interface OracleBaselineVerdict { /** * True when no grader trivially passed and none errored — every grader either * failed as expected or passed as an N/A absence assertion. Drives the exit code. */ ok: boolean; graders: OracleBaselineGraderVerdict[]; } /** * Classify a baseline (`--no-golden-input`) grade result as a negative control. * * The golden solution is withheld, so a healthy grader should FAIL (proving it * depends on the solution). Each grader detail is paired 1:1 with its config — * `runGraders` emits exactly one result per config, in order — and classified: * * - errored → `error`: a grader that couldn't produce a verdict (e.g. invalid * regex, thrown exception) reports `passed: false`, but that failure is a * harness fault, not the negative control holding. It must not be mistaken for * a healthy `expected-fail`, so it is called out separately and fails the run. * - failed → `expected-fail` (healthy). * - passed and {@link Grader.assertsAbsence} → `n/a`: an absence assertion * (e.g. `disallowed`-only `tool-calls`, `output-not-contains`) is satisfied by * the empty baseline, so passing is correct and exempt from the control. * - passed and asserts presence → `unexpected-pass`: the grader does not depend * on the golden solution, so it is trivially passing. * * The stimulus is `ok` unless at least one grader is `unexpected-pass` or * `error`. A stimulus whose graders are all absence assertions (nothing to * withhold, e.g. a "no action needed" task) is therefore reported N/A and passes. */ export declare function evaluateOracleBaseline(gradeResult: GraderResult, graderConfigs: StimulusGraderConfig[], registry: GraderRegistry): OracleBaselineVerdict; export declare function runOracle(options: OracleOptions & { grading: false; }): Promise>; export declare function runOracle(options: OracleOptions & { grading: OracleGradingOptions; }): Promise>; export declare function runOracle(options: OracleOptions): Promise; //# sourceMappingURL=oracle.d.ts.map