/** * Isolated benchmark evaluation: per-cell executor and reviewer LLM calls over * an injected completion seam (defaulting to `ctx.llm.stream` routing with the * input provider/model), strict evidence/score parsing, and failure conversion * into failed cells. The evaluator never touches the harness store, projection, * usage telemetry, skill files, or the audit gate — it reads only the captured * snapshot it is given and writes nothing. * * `CellEvaluation` (this module) is the evaluation-stage outcome: everything * `src/score.ts` needs to build a persisted `CellScore` (kept in `src/benchmark.ts` * as the domain record) plus the executor evidence the run record must store. * It lives here, next to the evaluator that produces it, rather than in * `benchmark.ts`, which owns the persisted record shapes. * @module dsh-continual-harness */ import type { Context } from '@deepseek-ai/cordis'; import type { BenchmarkCase, BenchmarkCriterion, CellScore, ExecutorEvidence, HarnessSnapshot } from './benchmark.ts'; import type { Complete } from './planner.ts'; /** Default output budget for one evaluator call. */ export declare const DEFAULT_EVALUATION_MAX_TOKENS = 8000; /** Default per-phase timeout for one evaluator call. */ export declare const DEFAULT_EVALUATION_TIMEOUT_MS = 60000; /** Hard caps on executor evidence size (spec item 7): bounds run memory and runs.jsonl growth. */ export declare const MAX_EVIDENCE_ARTIFACTS = 20; export declare const MAX_EVIDENCE_TOTAL_BYTES: number; /** Cap on the retained executor-reply tail kept for failure diagnosis. */ export declare const MAX_FAILURE_DETAIL_TAIL = 300; /** Cap on the whole failure diagnostic, so a record can never grow unbounded. */ export declare const MAX_FAILURE_DETAIL = 600; /** Marker error: executor evidence exceeded the hard caps. */ export declare class EvidenceOverflowError extends Error { name: string; } /** * Stable evaluation failure vocabulary. These describe failures that happen * while producing or parsing a cell — distinct from the domain * `CellScoreFailureReason` in `src/benchmark.ts`, which validates an * already-built `CellScore` record. `CellScore.failureReason` is a plain * string, so these values flow through unchanged into the persisted record. */ export type EvaluationFailureReason = 'provider-error' | 'aborted' | 'timeout' | 'malformed-executor-json' | 'malformed-reviewer-json' | 'invalid-reviewer-score' | 'invalid-reviewer-verdicts' | 'empty-reviewer-feedback' | 'evidence-overflow'; /** Per-cell evaluation input: the run identity plus one frozen case/snapshot pair. */ export interface CellEvaluationInput { runId: string; side: 'reference' | 'candidate'; iteration: number; /** Must be a frozen case; its material hash is stamped into the cell. */ benchmarkCase: BenchmarkCase; /** The read-only snapshot this side evaluates against. */ snapshot: HarnessSnapshot; provider: string; model: string; } /** Evaluation call options; tests inject `complete` to stay hermetic. */ export interface CellEvaluationOptions { /** Completion seam; defaults to `ctx.llm.stream` routing with the input provider/model. */ complete?: Complete; /** Abort signal honored by both phases. */ signal?: AbortSignal; /** Per-phase timeout in milliseconds. */ timeoutMs?: number; } /** The reviewer's structured verdict. */ export interface ReviewerScore { score: number; feedback: string; } /** * A criteria-based reviewer reply: one boolean per declared dimension plus * prose. The reviewer never produces the number — `scoreFromVerdicts` does. */ export interface ReviewerVerdicts extends ReviewerScore { verdicts: Array<{ id: string; met: boolean; }>; } /** * Weighted total of per-dimension verdicts, rounded to an integer: * `Σ weight·met / Σ weight · 100`. The store boundary validates the criteria as * non-empty with positive weights, so the divisor cannot be zero. */ export declare function scoreFromVerdicts(criteria: BenchmarkCriterion[], verdicts: Array<{ id: string; met: boolean; }>): number; /** * The evaluation-stage outcome of one cell: the persisted `CellScore` fields * (see `src/benchmark.ts`) plus the executor evidence the run record must * store. A failed cell carries `score: null` (never 0) and a stable * `failureReason`. It lives here, next to the evaluator that produces it, * rather than in `benchmark.ts`, which owns the persisted record shapes. */ export interface CellEvaluation extends CellScore { /** Executor evidence; `null` when the executor phase itself failed. */ evidence: ExecutorEvidence | null; } /** System prompt for the executor phase; deliberately contains no rubric. */ export declare const EXECUTOR_SYSTEM_PROMPT = "You are the executor of a benchmark cell. Complete the statement against the harness state overview, then report structured evidence of what you did.\n\nYou only see the statement and the harness state \u2014 no scoring rubric.\n\nRespond with ONLY a JSON object:\n{\"completed\":true|false,\"summary\":\"one line\",\"actions\":[\"...\"],\"observations\":[\"...\"],\"artifacts\":[{\"name\":\"...\",\"content\":\"...\"}]}"; /** System prompt for the reviewer phase. */ export declare const REVIEWER_SYSTEM_PROMPT = "You are the reviewer of one benchmark cell. Judge the executor's evidence against the case's declared criteria and give one concrete piece of actionable feedback.\n\nNever award a dimension the evidence does not show: require the evidence itself to prove it, not the executor's claim that it happened.\n\nRespond with ONLY the JSON object described under \"Required reply\" \u2014 no prose and no code fences."; /** Build the executor prompt: the case statement plus a snapshot-derived overview ONLY. */ export declare function buildExecutorPrompt(benchmarkCase: BenchmarkCase, snapshot: HarnessSnapshot): string; /** * Build the reviewer prompt: the statement, then either the case's declared * criteria (authoritative, binary-scored) or its legacy free-form rubric, and * this cell's executor evidence ONLY. The required reply shape travels with the * criteria so the two cannot drift apart. */ export declare function buildReviewerPrompt(benchmarkCase: BenchmarkCase, evidence: ExecutorEvidence): string; /** * Parse a criteria-based reviewer reply. Every declared criterion must be * answered exactly once with a boolean: an unanswered dimension would otherwise * read as "not met" and depress the score invisibly, so it fails loudly instead * (never a silent default). */ export declare function parseReviewerVerdicts(text: string, criteria: BenchmarkCriterion[]): ReviewerVerdicts; /** Parse the reviewer verdict: a finite score in 0..100 and non-empty feedback. */ export declare function parseReviewerScore(text: string): ReviewerScore; /** Parse executor output strictly: exactly the documented evidence fields, unknown fields rejected. */ export declare function parseExecutorEvidence(text: string): ExecutorEvidence; /** * Evaluate one cell: the executor completes the case against the snapshot and * produces evidence, then the reviewer scores that evidence against the rubric. * Provider errors, aborts, malformed JSON, and timeouts all convert into * `status: 'failed'`, `score: null` cells with stable failure reasons. * * An empty executor reply is retried once before it is recorded as a failure: * it is a lost observation rather than a judgement about the refinement, and * the acceptance-side sign test (n≥6 consistent pairs) pays for every lost * pair. A reply that is merely malformed is never retried. * * Precondition: `input.benchmarkCase` must be frozen — its material hash is * stamped into the cell via `hashBenchmarkCase`, which rejects drafts. Callers * validate frozen state before evaluation (the `run` action in `src/tool.ts`). */ export declare function runCellEvaluation(ctx: Context, input: CellEvaluationInput, options?: CellEvaluationOptions): Promise; //# sourceMappingURL=evaluate.d.ts.map