dsh-eval 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -13
- package/README.zh.md +99 -10
- package/lib/agreement.js +46 -0
- package/lib/argv.js +66 -0
- package/lib/atomic-write.js +38 -0
- package/lib/benchmark.js +116 -19
- package/lib/calibration.js +90 -0
- package/lib/command.js +202 -10
- package/lib/compare.js +310 -31
- package/lib/dashboard.js +260 -0
- package/lib/digest.js +118 -0
- package/lib/export.js +50 -0
- package/lib/gate.js +293 -0
- package/lib/import.js +17 -6
- package/lib/index.js +174 -12
- package/lib/judge.js +30 -7
- package/lib/leaderboard.js +222 -0
- package/lib/precision.js +50 -0
- package/lib/rejudge.js +107 -0
- package/lib/reliability.js +107 -0
- package/lib/report.js +285 -11
- package/lib/runner.js +189 -33
- package/lib/safe-regex.js +74 -0
- package/lib/segments.js +15 -0
- package/lib/stats.js +63 -0
- package/lib/trace.js +19 -2
- package/lib/types/agreement.d.ts +33 -0
- package/lib/types/argv.d.ts +19 -0
- package/lib/types/atomic-write.d.ts +15 -0
- package/lib/types/benchmark.d.ts +9 -2
- package/lib/types/calibration.d.ts +45 -0
- package/lib/types/command.d.ts +58 -0
- package/lib/types/compare.d.ts +82 -2
- package/lib/types/dashboard.d.ts +24 -0
- package/lib/types/digest.d.ts +38 -0
- package/lib/types/export.d.ts +17 -0
- package/lib/types/gate.d.ts +87 -0
- package/lib/types/index.d.ts +8 -4
- package/lib/types/judge.d.ts +4 -1
- package/lib/types/leaderboard.d.ts +70 -0
- package/lib/types/precision.d.ts +44 -0
- package/lib/types/rejudge.d.ts +22 -0
- package/lib/types/reliability.d.ts +85 -0
- package/lib/types/report.d.ts +18 -5
- package/lib/types/runner.d.ts +8 -1
- package/lib/types/safe-regex.d.ts +24 -0
- package/lib/types/segments.d.ts +12 -0
- package/lib/types/stats.d.ts +56 -0
- package/lib/types/trace.d.ts +7 -0
- package/lib/types/types.d.ts +55 -6
- package/lib/types/validate.d.ts +57 -0
- package/lib/validate.js +155 -0
- package/package.json +2 -2
- package/src/agreement.ts +60 -0
- package/src/argv.ts +63 -0
- package/src/atomic-write.ts +38 -0
- package/src/benchmark.ts +139 -13
- package/src/calibration.ts +113 -0
- package/src/command.ts +297 -10
- package/src/compare.ts +392 -37
- package/src/dashboard.ts +287 -0
- package/src/digest.ts +144 -0
- package/src/export.ts +57 -0
- package/src/gate.ts +383 -0
- package/src/import.ts +18 -6
- package/src/index.ts +192 -12
- package/src/judge.ts +30 -6
- package/src/leaderboard.ts +272 -0
- package/src/precision.ts +85 -0
- package/src/rejudge.ts +112 -0
- package/src/reliability.ts +166 -0
- package/src/report.ts +303 -11
- package/src/runner.ts +182 -35
- package/src/safe-regex.ts +79 -0
- package/src/segments.ts +16 -0
- package/src/stats.ts +104 -0
- package/src/trace.ts +19 -2
- package/src/types.ts +56 -6
- package/src/validate.ts +177 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reliability metrics over repeated trials of the same case.
|
|
3
|
+
*
|
|
4
|
+
* A pooled success rate hides the shape of failure: three trials of one case
|
|
5
|
+
* can all fail while three other cases pass every time, and both report the
|
|
6
|
+
* same 66.7%. `pass@k`, `pass^k`, and the flaky-case list make that shape
|
|
7
|
+
* visible. The metrics are derived at render time from the persisted trials,
|
|
8
|
+
* so reports written before this module existed gain them on next render.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-eval/reliability
|
|
11
|
+
*/
|
|
12
|
+
import type { EvalRun } from './types.ts';
|
|
13
|
+
/** The grading dimension a reliability summary describes. */
|
|
14
|
+
export type ReliabilityDimension = 'task' | 'tool-selection';
|
|
15
|
+
/** Trial accounting for one run, including trials that produced no grade. */
|
|
16
|
+
export interface RunCoverage {
|
|
17
|
+
/** Every trial in the run, completed or not. */
|
|
18
|
+
total: number;
|
|
19
|
+
/** Trials with a harvested trace. */
|
|
20
|
+
completed: number;
|
|
21
|
+
/** Trials that failed before producing a usable trace. */
|
|
22
|
+
errors: number;
|
|
23
|
+
/** Trials killed by the timeout. */
|
|
24
|
+
timeouts: number;
|
|
25
|
+
/** Trials that never produced a grade (`total - completed`). */
|
|
26
|
+
unscored: number;
|
|
27
|
+
}
|
|
28
|
+
/** Reliability of one case across its graded trials. */
|
|
29
|
+
export interface CaseReliability {
|
|
30
|
+
/** Benchmark case id. */
|
|
31
|
+
caseId: string;
|
|
32
|
+
/** Number of graded trials observed for the case. */
|
|
33
|
+
trials: number;
|
|
34
|
+
/** Every trial for the case, including errors and timeouts. */
|
|
35
|
+
total: number;
|
|
36
|
+
/** Number of those trials that passed. */
|
|
37
|
+
passes: number;
|
|
38
|
+
/** `passes / trials`. */
|
|
39
|
+
rate: number;
|
|
40
|
+
}
|
|
41
|
+
/** Reliability of one grading dimension across the whole run. */
|
|
42
|
+
export interface ReliabilitySummary {
|
|
43
|
+
/** Which grade field was summarized. */
|
|
44
|
+
dimension: ReliabilityDimension;
|
|
45
|
+
/** Trials per case configured for the run. */
|
|
46
|
+
k: number;
|
|
47
|
+
/** Cases with at least one graded trial. */
|
|
48
|
+
cases: number;
|
|
49
|
+
/** Every trial in the run, completed or not. */
|
|
50
|
+
total: number;
|
|
51
|
+
/** Fraction of all graded trials that passed. */
|
|
52
|
+
passAt1: number;
|
|
53
|
+
/** Passes over every trial, including errors and timeouts: the unbiased rate. */
|
|
54
|
+
strictPassAt1: number;
|
|
55
|
+
/** Trials that never produced a grade for this dimension. */
|
|
56
|
+
unscored: number;
|
|
57
|
+
/** Fraction of cases with at least one passing trial. */
|
|
58
|
+
passAtK: number;
|
|
59
|
+
/** Fraction of cases where every graded trial passed. */
|
|
60
|
+
passAllK: number;
|
|
61
|
+
/** Cases whose trials disagreed, in case order. */
|
|
62
|
+
flaky: readonly CaseReliability[];
|
|
63
|
+
/** Up to three weakest cases, by pass rate then case id. */
|
|
64
|
+
hardest: readonly CaseReliability[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Count every trial in a run, including those that never produced a grade.
|
|
68
|
+
* A rate computed only over completed trials is biased whenever some trials
|
|
69
|
+
* error or time out, so the denominator must be visible alongside it.
|
|
70
|
+
* @param run - the run to account for.
|
|
71
|
+
* @returns counts whose `unscored` field is the trials missing from all rates.
|
|
72
|
+
*/
|
|
73
|
+
export declare function computeCoverage(run: EvalRun): RunCoverage;
|
|
74
|
+
/**
|
|
75
|
+
* Fold a run's trials into reliability metrics for one grading dimension.
|
|
76
|
+
*
|
|
77
|
+
* Every trial for a case contributes to `total`, even an error or timeout.
|
|
78
|
+
* `passAt1` keeps its historical graded-only denominator; `strictPassAt1`
|
|
79
|
+
* divides by all trials so a model that times out on hard cases cannot look
|
|
80
|
+
* better than one that finishes and fails.
|
|
81
|
+
* @param run - the run to summarize.
|
|
82
|
+
* @param dimension - `task` (default) or `tool-selection` grading.
|
|
83
|
+
* @returns the summary, or null when no trial carried that grade.
|
|
84
|
+
*/
|
|
85
|
+
export declare function computeReliability(run: EvalRun, dimension?: ReliabilityDimension): ReliabilitySummary | null;
|
package/lib/types/report.d.ts
CHANGED
|
@@ -6,20 +6,33 @@
|
|
|
6
6
|
import type { EvalRun } from './types.ts';
|
|
7
7
|
/**
|
|
8
8
|
* Write a run report as indented JSON with a trailing newline.
|
|
9
|
+
*
|
|
10
|
+
* The JSON is staged in a sibling temporary file and renamed into place, so a
|
|
11
|
+
* crash or a full disk cannot leave a half-written report that looks valid.
|
|
9
12
|
* @param run - the run record to persist.
|
|
10
13
|
* @param path - output path; parent directories are created.
|
|
11
14
|
*/
|
|
12
15
|
export declare function writeRunReport(run: EvalRun, path: string): Promise<void>;
|
|
13
16
|
/**
|
|
14
|
-
* Load a persisted run report,
|
|
17
|
+
* Load a persisted run report, validating its full shape before use.
|
|
15
18
|
* @param path - path to the run JSON.
|
|
16
19
|
* @returns the loaded run record.
|
|
20
|
+
* @throws with the offending field path when the document is malformed.
|
|
17
21
|
*/
|
|
18
22
|
export declare function loadRunReport(path: string): Promise<EvalRun>;
|
|
19
23
|
/**
|
|
20
|
-
* Render a
|
|
21
|
-
*
|
|
22
|
-
* @param run - the run record to
|
|
23
|
-
* @returns
|
|
24
|
+
* Render a compact terminal summary of a run. Unlike the markdown report this
|
|
25
|
+
* omits the per-trial table, so a hundred-trial run still fits on one screen.
|
|
26
|
+
* @param run - the run record to summarize.
|
|
27
|
+
* @returns a short markdown fragment ending in a newline.
|
|
28
|
+
*/
|
|
29
|
+
export declare function renderBriefReport(run: EvalRun): string;
|
|
30
|
+
/**
|
|
31
|
+
* Render a run as machine-readable JSON, including every derived block shown
|
|
32
|
+
* in the markdown report. Raw trial results are kept so consumers can drill
|
|
33
|
+
* into a single case without parsing another file.
|
|
34
|
+
* @param run - the run record.
|
|
35
|
+
* @returns a JSON string ending in a newline.
|
|
24
36
|
*/
|
|
37
|
+
export declare function renderReportJson(run: EvalRun): string;
|
|
25
38
|
export declare function renderMarkdownReport(run: EvalRun): string;
|
package/lib/types/runner.d.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module dsh-eval/runner
|
|
14
14
|
*/
|
|
15
|
-
import type { Benchmark, EvalRun } from './types.ts';
|
|
15
|
+
import type { Benchmark, EvalRun, EvalTrialResult } from './types.ts';
|
|
16
|
+
import type { EvalRunGrading } from './types.ts';
|
|
16
17
|
import { type JudgeChat } from './judge.ts';
|
|
17
18
|
/** Runtime overrides applied to a loaded benchmark. */
|
|
18
19
|
export interface RunOptions {
|
|
@@ -24,11 +25,17 @@ export interface RunOptions {
|
|
|
24
25
|
trials?: number;
|
|
25
26
|
/** Override the benchmark's in-flight trial limit. */
|
|
26
27
|
concurrency?: number;
|
|
28
|
+
/** Override the benchmark's base seed. */
|
|
29
|
+
seed?: number;
|
|
27
30
|
/** Root for trial directories; defaults to the platform temp dir. */
|
|
28
31
|
tempRoot?: string;
|
|
29
32
|
/** LLM-judge chat seam; required when the benchmark configures a judge. */
|
|
30
33
|
judgeChat?: JudgeChat;
|
|
34
|
+
/** Called once per finished trial, including errors, with 1-based progress. */
|
|
35
|
+
onProgress?: (result: EvalTrialResult, finished: number, total: number) => void;
|
|
31
36
|
}
|
|
37
|
+
/** Reduce completed trials' grades into pooled run-level rates. */
|
|
38
|
+
export declare function aggregateGrading(results: readonly EvalTrialResult[]): EvalRunGrading | null;
|
|
32
39
|
/**
|
|
33
40
|
* Run every case x trial through a bounded worker pool and aggregate the
|
|
34
41
|
* completed trials.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time-boxed regular-expression tests for agent-controlled text.
|
|
3
|
+
*
|
|
4
|
+
* A benchmark author can write a catastrophic backtracking pattern, and the
|
|
5
|
+
* matched text comes from the agent under evaluation. Running such a pattern on
|
|
6
|
+
* the main thread would hang the whole evaluator, so each test runs in a
|
|
7
|
+
* disposable worker and is terminated when it exceeds its budget. The budget
|
|
8
|
+
* includes worker startup, so it is generous enough for high concurrency.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-eval/safe-regex
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Test a validated pattern against one untrusted input with a hard time budget.
|
|
14
|
+
* @throws when the pattern is invalid or the budget is exceeded.
|
|
15
|
+
*/
|
|
16
|
+
export declare function safeRegexTest(pattern: string, input: string, timeoutMs?: number): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Test a pattern against several inputs, giving each its own worker and budget.
|
|
19
|
+
* A pathological early input must not consume the budget of later inputs that
|
|
20
|
+
* would otherwise match.
|
|
21
|
+
*
|
|
22
|
+
* @throws when the pattern is invalid for any input.
|
|
23
|
+
*/
|
|
24
|
+
export declare function safeRegexTestAny(pattern: string, inputs: readonly string[], timeoutMs?: number): Promise<boolean>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared case-id to temp-directory-segment normalization.
|
|
3
|
+
*
|
|
4
|
+
* The runner uses this to name each trial's private directory (and its replay
|
|
5
|
+
* fixture); the benchmark loader uses the same function to reject ids that
|
|
6
|
+
* would collapse onto one segment. One implementation keeps validation from
|
|
7
|
+
* drifting away from the directories it protects.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-eval/segments
|
|
10
|
+
*/
|
|
11
|
+
/** Reduce a case id to one safe temp-directory segment. */
|
|
12
|
+
export declare function caseSegment(value: string): string;
|
package/lib/types/stats.d.ts
CHANGED
|
@@ -34,6 +34,62 @@ export interface PairedDelta {
|
|
|
34
34
|
/** Pairs contributing to the mean. */
|
|
35
35
|
pairs: number;
|
|
36
36
|
}
|
|
37
|
+
/** Power ceiling of an exact sign test with a finite number of discordant pairs. */
|
|
38
|
+
export interface SignTestPower {
|
|
39
|
+
/** Discordant pairs the test actually has. */
|
|
40
|
+
discordant: number;
|
|
41
|
+
/** Number of quantities in the printed inference family. */
|
|
42
|
+
comparisons: number;
|
|
43
|
+
/** Family-wise error rate the family controls. */
|
|
44
|
+
alpha: number;
|
|
45
|
+
/** Smallest raw p-value any outcome with this sample could produce. */
|
|
46
|
+
bestRawP: number;
|
|
47
|
+
/** Smallest Bonferroni-adjusted p-value any outcome could produce. */
|
|
48
|
+
bestAdjustedP: number;
|
|
49
|
+
/** Wins in the favoured direction needed for significance, or null when impossible. */
|
|
50
|
+
minimumWins: number | null;
|
|
51
|
+
/** Smallest discordant sample that could reach the corrected alpha. */
|
|
52
|
+
minimumDiscordant: number;
|
|
53
|
+
/** Whether the current sample can reach the corrected alpha at all. */
|
|
54
|
+
detectable: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Report how much a finite paired sample can ever say under an exact sign test.
|
|
58
|
+
*
|
|
59
|
+
* With `n` discordant pairs the strongest evidence is a clean sweep, whose
|
|
60
|
+
* two-sided p-value is `2^(1-n)`; the printed Bonferroni family multiplies it.
|
|
61
|
+
* Below that floor no observed outcome can reach alpha, so a non-significant
|
|
62
|
+
* result is uninformative rather than evidence of no difference.
|
|
63
|
+
* @param discordant - number of win/loss pairs; ties drop out.
|
|
64
|
+
* @param comparisons - size of the inference family, at least one.
|
|
65
|
+
* @param alpha - family-wise error rate, default `0.05`.
|
|
66
|
+
* @returns the achievable p-value floor, required wins and minimum sample size.
|
|
67
|
+
*/
|
|
68
|
+
export declare function signTestPower(discordant: number, comparisons: number, alpha?: number): SignTestPower;
|
|
69
|
+
/** Bonferroni family-wise correction shared by a p-value and its sibling intervals. */
|
|
70
|
+
export interface FamilyWiseCorrection {
|
|
71
|
+
/** Number of inference quantities in the family (the p-value plus intervals). */
|
|
72
|
+
comparisons: number;
|
|
73
|
+
/** Family-wise error rate the family controls. */
|
|
74
|
+
alpha: number;
|
|
75
|
+
/** Adjusted p-value: raw p times the family size, capped at 1. */
|
|
76
|
+
adjustedPValue: number;
|
|
77
|
+
/** Per-interval confidence that keeps family-wise coverage at `1 - alpha`. */
|
|
78
|
+
intervalConfidence: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Apply a Bonferroni correction across a family of inference quantities.
|
|
82
|
+
*
|
|
83
|
+
* A comparison report prints a sign-test p-value alongside several paired
|
|
84
|
+
* intervals. Testing each at 5% inflates the chance that at least one is a
|
|
85
|
+
* false discovery; dividing the error rate by the family size keeps that
|
|
86
|
+
* chance at `alpha` without any distributional assumption.
|
|
87
|
+
* @param pValue - raw p-value of the family's primary test.
|
|
88
|
+
* @param comparisons - number of quantities in the family; at least one.
|
|
89
|
+
* @param alpha - family-wise error rate, default `0.05`.
|
|
90
|
+
* @returns the adjusted p-value and the confidence each interval must use.
|
|
91
|
+
*/
|
|
92
|
+
export declare function bonferroni(pValue: number, comparisons: number, alpha?: number): FamilyWiseCorrection;
|
|
37
93
|
/** Knobs for {@link pairedDelta}; defaults keep reports reproducible. */
|
|
38
94
|
export interface BootstrapOptions {
|
|
39
95
|
/** Interval confidence, default `0.95`. */
|
package/lib/types/trace.d.ts
CHANGED
|
@@ -43,3 +43,10 @@ export declare function findSessionLogs(root: string): Promise<string[]>;
|
|
|
43
43
|
* @returns the merged trace.
|
|
44
44
|
*/
|
|
45
45
|
export declare function mergeTraces(traces: readonly EvalTrace[]): EvalTrace;
|
|
46
|
+
/**
|
|
47
|
+
* Stable SHA-256 digest of a merged trace, used to prove that an offline
|
|
48
|
+
* re-judge reads the same evidence the original run harvested.
|
|
49
|
+
* @param trace - the merged trace.
|
|
50
|
+
* @returns a lowercase hex digest.
|
|
51
|
+
*/
|
|
52
|
+
export declare function traceDigest(trace: EvalTrace): string;
|
package/lib/types/types.d.ts
CHANGED
|
@@ -25,15 +25,33 @@ export interface BenchmarkCase {
|
|
|
25
25
|
prompt: string;
|
|
26
26
|
/** Absolute path to a workspace tree copied into each trial, when provided. */
|
|
27
27
|
workspace?: string;
|
|
28
|
+
/** Per-case timeout in milliseconds; overrides the benchmark timeout. */
|
|
29
|
+
timeoutMs?: number;
|
|
28
30
|
/** Scripted grading annotations, when the case is graded. */
|
|
29
31
|
expected?: BenchmarkExpectation;
|
|
30
32
|
}
|
|
31
33
|
/** Expected-tool and check-command annotations for scripted grading. */
|
|
32
34
|
export interface BenchmarkExpectation {
|
|
33
|
-
/**
|
|
35
|
+
/** Legacy substring matched against every recorded tool call name. */
|
|
34
36
|
tool?: string;
|
|
35
|
-
/**
|
|
37
|
+
/** Every listed substring must appear in at least one tool call name. */
|
|
38
|
+
tools?: readonly string[];
|
|
39
|
+
/** At least one listed substring must appear in a tool call name. */
|
|
40
|
+
toolAnyOf?: readonly string[];
|
|
41
|
+
/** A validated regular expression that must match at least one tool call name. */
|
|
42
|
+
toolRegex?: string;
|
|
43
|
+
/** None of the listed substrings may appear in any tool call name. */
|
|
44
|
+
toolNot?: readonly string[];
|
|
45
|
+
/** Legacy command string split on whitespace (and quotes) into argv; exit 0 means task success. */
|
|
36
46
|
check?: string;
|
|
47
|
+
/** Preferred structured argv for a check command; no shell interpretation. */
|
|
48
|
+
checkArgv?: readonly string[];
|
|
49
|
+
/** Opt-in shell command for checks needing pipes/redirection; benchmark files must be trusted. */
|
|
50
|
+
checkShell?: string;
|
|
51
|
+
/** Known-correct final answer handed to the LLM judge, when the task has one. */
|
|
52
|
+
answer?: string;
|
|
53
|
+
/** Regex the final assistant answer must match; sets task success when no check command is configured. */
|
|
54
|
+
answerRegex?: string;
|
|
37
55
|
}
|
|
38
56
|
/** LLM-judge configuration: scores final answers and flags hallucinations. */
|
|
39
57
|
export interface BenchmarkJudge {
|
|
@@ -71,8 +89,12 @@ export interface Benchmark {
|
|
|
71
89
|
concurrency: number;
|
|
72
90
|
/** Per-trial timeout in milliseconds. */
|
|
73
91
|
timeoutMs: number;
|
|
74
|
-
/**
|
|
92
|
+
/** Deterministic seed; trial n receives `DSH_EVAL_SEED = seed + n - 1`. */
|
|
75
93
|
seed: number;
|
|
94
|
+
/** SHA-256 of the YAML source plus resolved prompt/workspace/replay inputs. */
|
|
95
|
+
sourceSha256?: string;
|
|
96
|
+
/** Permit referenced paths outside the benchmark directory; trusted files only. */
|
|
97
|
+
allowExternalPaths?: boolean;
|
|
76
98
|
/** The benchmark's cases, in order. */
|
|
77
99
|
cases: readonly BenchmarkCase[];
|
|
78
100
|
/** Pricing keyed by model id; an absent model reports `costUsd: null`. */
|
|
@@ -157,6 +179,8 @@ export interface EvalTrialResult {
|
|
|
157
179
|
tracePath?: string;
|
|
158
180
|
/** Absolute paths of every harvested session log, primary first. */
|
|
159
181
|
tracePaths?: readonly string[];
|
|
182
|
+
/** SHA-256 of the merged trace; lets offline re-judging detect altered logs. */
|
|
183
|
+
traceSha256?: string;
|
|
160
184
|
/** The child process's exit code, or null when it was killed. */
|
|
161
185
|
exitCode: number | null;
|
|
162
186
|
/** Whether the trial hit its timeout and killed the child. */
|
|
@@ -170,7 +194,7 @@ export interface EvalTrialResult {
|
|
|
170
194
|
}
|
|
171
195
|
/** Scripted grading outcome for one trial. */
|
|
172
196
|
export interface EvalGrade {
|
|
173
|
-
/** Whether the check command exited 0
|
|
197
|
+
/** Whether the check command exited 0 or the answer regex matched; null when neither is configured. */
|
|
174
198
|
taskSuccess: boolean | null;
|
|
175
199
|
/** Whether an expected tool was called, or null when no tool is configured. */
|
|
176
200
|
toolSelectionAccuracy: boolean | null;
|
|
@@ -183,10 +207,12 @@ export interface EvalJudgeVerdict {
|
|
|
183
207
|
hallucination: boolean | null;
|
|
184
208
|
/** Judge rationale, when the model returned one. */
|
|
185
209
|
rationale?: string;
|
|
210
|
+
/** Why this verdict is unusable — a failed call or an unparsable reply. */
|
|
211
|
+
judgeError?: string;
|
|
186
212
|
}
|
|
187
213
|
/** Pooled grading rates over completed trials. */
|
|
188
214
|
export interface EvalRunGrading {
|
|
189
|
-
/** Pooled task-success rate, or null when no trial carried a check. */
|
|
215
|
+
/** Pooled task-success rate, or null when no trial carried a check or answer regex. */
|
|
190
216
|
taskSuccessRate: number | null;
|
|
191
217
|
/** Pooled tool-selection-accuracy rate, or null when no trial carried an expected tool. */
|
|
192
218
|
toolSelectionAccuracyRate: number | null;
|
|
@@ -194,6 +220,17 @@ export interface EvalRunGrading {
|
|
|
194
220
|
finalAnswerScore: number | null;
|
|
195
221
|
/** Pooled hallucination rate over judged trials, or null when nothing was judged. */
|
|
196
222
|
hallucinationRate: number | null;
|
|
223
|
+
/** Judge calls that failed or returned unusable output, when a judge was configured. */
|
|
224
|
+
judgeFailures?: number;
|
|
225
|
+
}
|
|
226
|
+
/** Minimal case input needed to re-judge a stored trial without the benchmark file. */
|
|
227
|
+
export interface EvalCaseInput {
|
|
228
|
+
/** Case id matching the trial results. */
|
|
229
|
+
caseId: string;
|
|
230
|
+
/** Task text handed to the agent and the judge. */
|
|
231
|
+
prompt: string;
|
|
232
|
+
/** Gold answer handed to the judge, when the case had one. */
|
|
233
|
+
answer?: string;
|
|
197
234
|
}
|
|
198
235
|
/** A persisted eval run. */
|
|
199
236
|
export interface EvalRun {
|
|
@@ -201,11 +238,21 @@ export interface EvalRun {
|
|
|
201
238
|
benchmark: string;
|
|
202
239
|
/** Model id the benchmark targeted. */
|
|
203
240
|
model: string;
|
|
241
|
+
/** SHA-256 of the benchmark YAML, resolved inputs and CLI overrides, when known. */
|
|
242
|
+
benchmarkSha256?: string;
|
|
243
|
+
/** CLI overrides that changed the effective benchmark configuration. */
|
|
244
|
+
benchmarkOverrides?: {
|
|
245
|
+
trials?: number;
|
|
246
|
+
concurrency?: number;
|
|
247
|
+
seed?: number;
|
|
248
|
+
profile?: string;
|
|
249
|
+
dshCommand?: readonly string[];
|
|
250
|
+
};
|
|
204
251
|
/** Run creation time, epoch milliseconds. */
|
|
205
252
|
createdAt: number;
|
|
206
253
|
/** Trials per case actually executed. */
|
|
207
254
|
trials: number;
|
|
208
|
-
/** Benchmark seed. */
|
|
255
|
+
/** Benchmark seed; also the base for per-trial `DSH_EVAL_SEED` values. */
|
|
209
256
|
seed: number;
|
|
210
257
|
/** Resolved pricing for the benchmark model, or null without one. */
|
|
211
258
|
pricing: BenchmarkPricing | null;
|
|
@@ -215,6 +262,8 @@ export interface EvalRun {
|
|
|
215
262
|
tempRoot: string;
|
|
216
263
|
/** Per-trial outcomes in execution order. */
|
|
217
264
|
cases: readonly EvalTrialResult[];
|
|
265
|
+
/** Case prompts and gold answers, so a stored run can be re-judged. */
|
|
266
|
+
caseInputs?: readonly EvalCaseInput[];
|
|
218
267
|
/** Mean/pooled metrics over completed trials, or null when none completed. */
|
|
219
268
|
aggregate: EvalCaseMetrics | null;
|
|
220
269
|
/** Pooled scripted-grading rates over completed trials, or null when ungraded. */
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Benchmark preflight for dsh-eval.
|
|
3
|
+
*
|
|
4
|
+
* A malformed benchmark is best caught before a run spawns agents and spends
|
|
5
|
+
* tokens. Parsing already rejects invalid YAML, regexes and conflicting check
|
|
6
|
+
* modes; this module turns the validated document into a readable summary plus
|
|
7
|
+
* warnings for configurations that run but produce weak evidence.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-eval/validate
|
|
10
|
+
*/
|
|
11
|
+
import type { Benchmark } from './types.ts';
|
|
12
|
+
/** Structured preflight result, shared by the markdown and JSON renderers. */
|
|
13
|
+
export interface BenchmarkSummary {
|
|
14
|
+
name: string;
|
|
15
|
+
/** SHA-256 of the benchmark YAML source, when parsed from text. */
|
|
16
|
+
sourceSha256: string | null;
|
|
17
|
+
model: string;
|
|
18
|
+
profile: string;
|
|
19
|
+
command: readonly string[];
|
|
20
|
+
trials: number;
|
|
21
|
+
concurrency: number;
|
|
22
|
+
timeoutMs: number;
|
|
23
|
+
seed: number;
|
|
24
|
+
cases: number;
|
|
25
|
+
gradedCases: number;
|
|
26
|
+
goldAnswers: number;
|
|
27
|
+
checks: number;
|
|
28
|
+
toolConstraints: number;
|
|
29
|
+
/** Cases with a per-case timeout override. */
|
|
30
|
+
caseTimeouts: number;
|
|
31
|
+
judge: {
|
|
32
|
+
provider: string;
|
|
33
|
+
model: string;
|
|
34
|
+
maxScore: number;
|
|
35
|
+
} | null;
|
|
36
|
+
replay: string | null;
|
|
37
|
+
pricing: boolean;
|
|
38
|
+
warnings: string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Derive a structured preflight summary from a validated benchmark.
|
|
42
|
+
* @param benchmark - a parsed benchmark document.
|
|
43
|
+
* @returns counts, configuration and actionable warnings.
|
|
44
|
+
*/
|
|
45
|
+
export declare function summarizeBenchmark(benchmark: Benchmark): BenchmarkSummary;
|
|
46
|
+
/**
|
|
47
|
+
* Render a validated benchmark summary with actionable warnings.
|
|
48
|
+
* @param benchmark - a parsed benchmark document.
|
|
49
|
+
* @returns markdown ending in a newline.
|
|
50
|
+
*/
|
|
51
|
+
export declare function renderBenchmarkSummary(benchmark: Benchmark): string;
|
|
52
|
+
/**
|
|
53
|
+
* Render a preflight summary as machine-readable JSON.
|
|
54
|
+
* @param benchmark - a parsed benchmark document.
|
|
55
|
+
* @returns a JSON string ending in a newline.
|
|
56
|
+
*/
|
|
57
|
+
export declare function renderBenchmarkJson(benchmark: Benchmark): string;
|
package/lib/validate.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Benchmark preflight for dsh-eval.
|
|
3
|
+
*
|
|
4
|
+
* A malformed benchmark is best caught before a run spawns agents and spends
|
|
5
|
+
* tokens. Parsing already rejects invalid YAML, regexes and conflicting check
|
|
6
|
+
* modes; this module turns the validated document into a readable summary plus
|
|
7
|
+
* warnings for configurations that run but produce weak evidence.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-eval/validate
|
|
10
|
+
*/
|
|
11
|
+
import { signTestPower } from "./stats.js";
|
|
12
|
+
/**
|
|
13
|
+
* Derive a structured preflight summary from a validated benchmark.
|
|
14
|
+
* @param benchmark - a parsed benchmark document.
|
|
15
|
+
* @returns counts, configuration and actionable warnings.
|
|
16
|
+
*/
|
|
17
|
+
export function summarizeBenchmark(benchmark) {
|
|
18
|
+
let checks = 0;
|
|
19
|
+
let toolConstraints = 0;
|
|
20
|
+
let gradedCases = 0;
|
|
21
|
+
let goldAnswers = 0;
|
|
22
|
+
let shellChecks = 0;
|
|
23
|
+
let caseTimeouts = 0;
|
|
24
|
+
const warnings = [];
|
|
25
|
+
const caseIds = new Set();
|
|
26
|
+
const duplicateIds = new Set();
|
|
27
|
+
for (const item of benchmark.cases) {
|
|
28
|
+
if (item.timeoutMs !== undefined)
|
|
29
|
+
caseTimeouts += 1;
|
|
30
|
+
if (caseIds.has(item.id))
|
|
31
|
+
duplicateIds.add(item.id);
|
|
32
|
+
caseIds.add(item.id);
|
|
33
|
+
const expected = item.expected;
|
|
34
|
+
if (expected === undefined)
|
|
35
|
+
continue;
|
|
36
|
+
gradedCases += 1;
|
|
37
|
+
if (expected.answer !== undefined)
|
|
38
|
+
goldAnswers += 1;
|
|
39
|
+
if (expected.check !== undefined)
|
|
40
|
+
checks += 1;
|
|
41
|
+
if (expected.checkArgv !== undefined)
|
|
42
|
+
checks += 1;
|
|
43
|
+
const hasCheck = expected.check !== undefined || expected.checkArgv !== undefined
|
|
44
|
+
|| expected.checkShell !== undefined;
|
|
45
|
+
if (expected.answerRegex !== undefined) {
|
|
46
|
+
if (hasCheck) {
|
|
47
|
+
warnings.push(`case ${item.id} combines a check command with answerRegex — the regex is ignored`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
checks += 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (expected.checkShell !== undefined) {
|
|
54
|
+
checks += 1;
|
|
55
|
+
shellChecks += 1;
|
|
56
|
+
}
|
|
57
|
+
toolConstraints += [expected.tool, expected.tools, expected.toolAnyOf, expected.toolRegex, expected.toolNot]
|
|
58
|
+
.filter(value => value !== undefined).length;
|
|
59
|
+
}
|
|
60
|
+
if (duplicateIds.size > 0) {
|
|
61
|
+
warnings.push(`duplicate case ids (${[...duplicateIds].slice(0, 5).join(', ')}) break pairing and case-input lookup`);
|
|
62
|
+
}
|
|
63
|
+
if (benchmark.trials < 2) {
|
|
64
|
+
warnings.push('one trial per case cannot measure flakiness or pass@k; use at least 2 trials');
|
|
65
|
+
}
|
|
66
|
+
if (gradedCases === 0 && benchmark.judge === undefined) {
|
|
67
|
+
warnings.push('no case has scripted expectations and no judge is configured — the run cannot produce a quality score');
|
|
68
|
+
}
|
|
69
|
+
else if (gradedCases === 0) {
|
|
70
|
+
warnings.push('no case has scripted expectations — results depend entirely on the judge');
|
|
71
|
+
}
|
|
72
|
+
if (checks === 0 && toolConstraints === 0 && benchmark.judge === undefined) {
|
|
73
|
+
warnings.push('no case checks tool use or task success — the run will produce only cost and latency data');
|
|
74
|
+
}
|
|
75
|
+
if (benchmark.judge !== undefined && goldAnswers === 0) {
|
|
76
|
+
warnings.push('judge is configured but no case supplies a gold answer — score calibration will be weak');
|
|
77
|
+
}
|
|
78
|
+
if (shellChecks > 0) {
|
|
79
|
+
warnings.push(`${shellChecks} shell check(s) need a trusted benchmark file (pipes and redirection are enabled)`);
|
|
80
|
+
}
|
|
81
|
+
const maxPairs = benchmark.cases.length * benchmark.trials;
|
|
82
|
+
// Preflight cannot know whether trials will carry step/token metrics, so it
|
|
83
|
+
// assumes the largest inference family the comparison may print.
|
|
84
|
+
const minimumDiscordant = signTestPower(0, benchmark.judge === undefined ? 3 : 4).minimumDiscordant;
|
|
85
|
+
if (maxPairs < minimumDiscordant) {
|
|
86
|
+
warnings.push(`at most ${maxPairs} paired trials; a Bonferroni-corrected sign test needs ≥${minimumDiscordant} discordant pairs to reach α=0.05`);
|
|
87
|
+
}
|
|
88
|
+
if (benchmark.replay !== undefined && benchmark.judge === undefined) {
|
|
89
|
+
warnings.push('replay runs have no live judge; use `dsh eval rejudge` after the run if judge scores are needed');
|
|
90
|
+
}
|
|
91
|
+
const judge = benchmark.judge;
|
|
92
|
+
return {
|
|
93
|
+
name: benchmark.name,
|
|
94
|
+
sourceSha256: benchmark.sourceSha256 ?? null,
|
|
95
|
+
model: benchmark.model,
|
|
96
|
+
profile: benchmark.profile,
|
|
97
|
+
command: benchmark.command,
|
|
98
|
+
trials: benchmark.trials,
|
|
99
|
+
concurrency: benchmark.concurrency,
|
|
100
|
+
timeoutMs: benchmark.timeoutMs,
|
|
101
|
+
seed: benchmark.seed,
|
|
102
|
+
cases: benchmark.cases.length,
|
|
103
|
+
gradedCases,
|
|
104
|
+
goldAnswers,
|
|
105
|
+
checks,
|
|
106
|
+
toolConstraints,
|
|
107
|
+
caseTimeouts,
|
|
108
|
+
judge: judge === undefined ? null : {
|
|
109
|
+
provider: judge.provider, model: judge.model, maxScore: judge.maxScore,
|
|
110
|
+
},
|
|
111
|
+
replay: benchmark.replay === undefined ? null : benchmark.replay.dir,
|
|
112
|
+
pricing: benchmark.pricing !== undefined,
|
|
113
|
+
warnings,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Render a validated benchmark summary with actionable warnings.
|
|
118
|
+
* @param benchmark - a parsed benchmark document.
|
|
119
|
+
* @returns markdown ending in a newline.
|
|
120
|
+
*/
|
|
121
|
+
export function renderBenchmarkSummary(benchmark) {
|
|
122
|
+
const summary = summarizeBenchmark(benchmark);
|
|
123
|
+
const lines = [
|
|
124
|
+
`# Benchmark: ${summary.name}`,
|
|
125
|
+
'',
|
|
126
|
+
`- model: ${summary.model}`,
|
|
127
|
+
...(summary.sourceSha256 === null ? [] : [`- source sha256: ${summary.sourceSha256}`]),
|
|
128
|
+
`- profile: ${summary.profile}`,
|
|
129
|
+
`- command: ${summary.command.join(' ')}`,
|
|
130
|
+
`- trials per case: ${summary.trials}`,
|
|
131
|
+
`- concurrency: ${summary.concurrency}`,
|
|
132
|
+
`- timeout: ${summary.timeoutMs} ms${summary.caseTimeouts === 0 ? '' : ` (${summary.caseTimeouts} per-case override(s))`}`,
|
|
133
|
+
`- seed: ${summary.seed} (trial n receives DSH_EVAL_SEED = ${summary.seed} + n - 1)`,
|
|
134
|
+
`- cases: ${summary.cases} (${summary.gradedCases} graded, ${summary.goldAnswers} with gold answers)`,
|
|
135
|
+
`- expectations: ${summary.checks} check(s), ${summary.toolConstraints} tool constraint(s)`,
|
|
136
|
+
`- judge: ${summary.judge === null ? 'none' : `${summary.judge.model} on ${summary.judge.provider} (max ${summary.judge.maxScore})`}`,
|
|
137
|
+
`- replay: ${summary.replay ?? 'live'}`,
|
|
138
|
+
`- pricing: ${summary.pricing ? 'configured' : 'none'}`,
|
|
139
|
+
'',
|
|
140
|
+
`Validated: ${summary.name} is ready to run.`,
|
|
141
|
+
'',
|
|
142
|
+
];
|
|
143
|
+
if (summary.warnings.length > 0) {
|
|
144
|
+
lines.push('## Warnings', '', ...summary.warnings.map(warning => `- ${warning}`), '');
|
|
145
|
+
}
|
|
146
|
+
return lines.join('\n');
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Render a preflight summary as machine-readable JSON.
|
|
150
|
+
* @param benchmark - a parsed benchmark document.
|
|
151
|
+
* @returns a JSON string ending in a newline.
|
|
152
|
+
*/
|
|
153
|
+
export function renderBenchmarkJson(benchmark) {
|
|
154
|
+
return `${JSON.stringify(summarizeBenchmark(benchmark))}\n`;
|
|
155
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-eval",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.
|
|
3
|
+
"description": "Evidence-grade agent evaluation for deepseek-harness: headless benchmarks, paired statistics, provenance, CI gates and standalone HTML dashboards",
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|