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
package/README.md
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-eval)
|
|
6
|
+
[](https://github.com/hccccc01333/dsh-eval/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
**Evidence-grade agent evaluation for [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness).** One `benchmark.yaml` in; auditable JSON, Markdown, CSV and self-contained HTML out.
|
|
12
|
+
|
|
13
|
+
| | |
|
|
14
|
+
|---|---|
|
|
15
|
+
| **Honest rates** | Strict pass@1 keeps timeouts and errors in the denominator |
|
|
16
|
+
| **Real inference** | Paired sign tests, power floors, bootstrap intervals, Bonferroni correction |
|
|
17
|
+
| **Auditable runs** | YAML + prompts + workspaces + overrides folded into one digest |
|
|
18
|
+
| **Judge QA** | Agreement, kappa, separation, ranking accuracy and Brier score |
|
|
19
|
+
| **CI-ready** | `--require-significance` gate with hard cost/latency budgets |
|
|
20
|
+
| **Zero-asset reports** | Standalone dark-mode HTML dashboards with no external dependencies |
|
|
6
21
|
|
|
7
22
|
The package is a bundle and a command-line app. Install it into a profile and run benchmarks with:
|
|
8
23
|
|
|
@@ -11,12 +26,31 @@ dsh plugin --profile eval add dsh-eval
|
|
|
11
26
|
dsh eval run benchmark.yaml
|
|
12
27
|
dsh eval report eval-run.json
|
|
13
28
|
dsh eval compare eval-v1.json eval-v2.json
|
|
29
|
+
dsh eval provenance eval-run.json benchmark.yaml
|
|
14
30
|
```
|
|
15
31
|
|
|
32
|
+
`dsh eval provenance <run.json> <benchmark.yaml>` re-hashes the benchmark YAML, its prompt files, workspace trees and replay logs and compares the result with the run's `benchmarkSha256`. It prints `match`, `missing` or `mismatch`, supports `--json`, and exits 1 unless the digests match, so CI can reject reports whose inputs changed after the run. Effective CLI overrides (`--trials`, `--concurrency`, `--profile`, `--dsh`) are persisted as `benchmarkOverrides` and folded into that digest, so a run with altered settings cannot verify against the unchanged YAML.
|
|
33
|
+
|
|
16
34
|
`dsh eval` is a launcher alias for `--profile eval`; the eval profile composes `dsh-base` plus this bundle. Each trial spawns the benchmark-configured `dsh` command (default `dsh`) against the benchmark-configured profile (default `headless`) with a private temp workspace, an isolated `DSH_HOME`, and a patch overlay forcing plain-JSONL persistence and non-interactive workspace-write/never-approval permissions. The harvested primary session log becomes the trial's trace, and subagent child logs under the trial's `DSH_HOME` are merged into it before the metric fold.
|
|
17
35
|
|
|
18
36
|
Trials are independent — private temp workspace, isolated `DSH_HOME`, own patch overlay — so `concurrency` runs that many of them at once. The run record still lists results in case-then-trial order whatever the interleaving, and `--concurrency` overrides the document. Raising it trades wall time for peak CPU, memory, and concurrent model quota.
|
|
19
37
|
|
|
38
|
+
While a run is in flight, each finished trial writes one bounded line to stderr, e.g. `[eval] 3/12 golden #1 task pass, 1204 ms`. Errors print their sanitized message, and agent-controlled case ids cannot inject newlines. Pass `--quiet` for scripts that want only the final stdout summary.
|
|
39
|
+
|
|
40
|
+
## See it in action
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
*Two-run dashboard: paired comparison, confirmed case changes and judge calibration in one self-contained file.*
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
*Three-plus-run leaderboard with strict pass@1 ranking and paired verdicts against the leader.*
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
*Bounded progress lines and a CI gate that fails on confirmed per-case regressions.*
|
|
53
|
+
|
|
20
54
|
## Benchmark document
|
|
21
55
|
|
|
22
56
|
```yaml
|
|
@@ -51,11 +85,13 @@ pricing:
|
|
|
51
85
|
| `trials` | `1` | Trials per case. |
|
|
52
86
|
| `concurrency` | `1` | Case x trial executions allowed in flight at once; `1` keeps the run strictly serial. |
|
|
53
87
|
| `timeoutMs` | `600000` | Per-trial timeout; the direct child is killed on expiry. |
|
|
54
|
-
| `seed` | `0` |
|
|
88
|
+
| `seed` | `0` | Base seed: trial n receives `DSH_EVAL_SEED=seed+n-1` in its environment, and the value also seeds report bootstraps. A harness must read that variable for deterministic sampling. |
|
|
89
|
+
| `allowExternalPaths` | `false` | Ignored inside the YAML itself. The trusted operator enables external `promptFile`, `workspace` and `replay.dir` paths with `dsh --profile eval run <file> --allow-external-paths` (also accepted by `validate`); third-party documents are contained by default. |
|
|
55
90
|
| `cases[].id` | required | Stable case id. |
|
|
56
91
|
| `cases[].prompt` / `cases[].promptFile` | exactly one | Task text, inline or relative to the benchmark file. |
|
|
57
92
|
| `cases[].workspace` | absent | Workspace tree copied into each trial, relative or absolute. |
|
|
58
|
-
| `cases[].
|
|
93
|
+
| `cases[].timeoutMs` | absent | Positive per-case timeout overriding the benchmark `timeoutMs` for both the agent child and scripted checks. |
|
|
94
|
+
| `cases[].expected` | absent | Scripted grading: `tool` (legacy substring), `tools` (all listed substrings), `toolAnyOf` (at least one), `toolRegex` (validated at load) and `toolNot` (none) all combine against recorded tool-call names; `checkArgv` (preferred), `check` (legacy string, quotes supported), or `checkShell` (explicit opt-in, pipes/redirection) runs in the trial workspace after the agent exits (exit 0 = task success); `answer` is a gold answer passed to the judge, while `answerRegex` (validated at load) matches the final assistant answer and sets `taskSuccess` when no check command is configured, giving deterministic grading without a judge. Only the first 4096 characters of the final answer are matched in a time-boxed worker, so a catastrophic benchmark regex cannot hang the evaluator, and a case combining a check command with `answerRegex` is flagged by `validate` because the regex is ignored. At least one field is required, and at most one check mode. Check processes are detached and killed as a group at the trial timeout. |
|
|
59
95
|
| `pricing` | absent | Per-million-token USD prices keyed by model id; absent models report `costUsd: null`. |
|
|
60
96
|
|
|
61
97
|
### Judge
|
|
@@ -77,6 +113,8 @@ judge:
|
|
|
77
113
|
| `rubric` | absent | Task rubric appended to the judging prompt. |
|
|
78
114
|
| `maxScore` | `10` | Maximum final-answer score. |
|
|
79
115
|
|
|
116
|
+
When a case sets `expected.answer`, the judge receives it as the reference answer and is instructed to score factual agreement with it rather than fluency. If a judge call fails or returns an unusable reply, the verdict carries `judgeError` and the run's `grading.judgeFailures` counts it; the report prints the count instead of silently dropping the score from the mean.
|
|
117
|
+
|
|
80
118
|
The judge builds a strict-JSON prompt from the case and the merged trace. A
|
|
81
119
|
trial carries its verdict (`finalAnswerScore`, `hallucination`, `rationale`)
|
|
82
120
|
when the reply parses; unusable output or a chat failure reads as null verdict
|
|
@@ -85,7 +123,7 @@ starting when the host exposes no LLM chat seam.
|
|
|
85
123
|
|
|
86
124
|
## Metrics
|
|
87
125
|
|
|
88
|
-
The metric fold computes the automatic metrics directly from the session log: `turns`, `steps`, `toolCalls`, `toolResults`, `toolSuccess` plus `toolSuccessRate`, `invalidToolCalls` (results carrying an internal failure identity), `retries` (`llm/retry`), disjoint token buckets and totals, billed context tokens, `llmMs`/`toolMs`/`ttftMs`/`latencyMs`, and `costUsd` when pricing is configured. Scripted grading adds per-trial `taskSuccess` (check-command exit 0) and `toolSelectionAccuracy` (
|
|
126
|
+
The metric fold computes the automatic metrics directly from the session log: `turns`, `steps`, `toolCalls`, `toolResults`, `toolSuccess` plus `toolSuccessRate`, `invalidToolCalls` (results carrying an internal failure identity), `retries` (`llm/retry`), disjoint token buckets and totals, billed context tokens, `llmMs`/`toolMs`/`ttftMs`/`latencyMs`, and `costUsd` when pricing is configured. Scripted grading adds per-trial `taskSuccess` (check-command exit 0, or an `answerRegex` match on the final answer when no check command is configured) and `toolSelectionAccuracy` (all configured tool constraints hold) and pools them into run-level rates. `checkArgv` avoids shell interpretation entirely; `checkShell` is for trusted benchmark files that need pipes or redirection. A hung check is terminated with its whole process group at the trial timeout, so one bad verifier cannot stall a run.
|
|
89
127
|
|
|
90
128
|
Child session logs under the trial's DSH_HOME are merged into the trial trace
|
|
91
129
|
before the fold, so delegated subagent work counts toward steps, tokens, tool
|
|
@@ -95,13 +133,134 @@ hallucination rate.
|
|
|
95
133
|
|
|
96
134
|
## Run report
|
|
97
135
|
|
|
98
|
-
`dsh eval run --out run.json` writes one JSON document per run: benchmark and model identity, per-trial outcomes with absolute trace paths, aggregate metrics (means for counts and wall times, pooled success rate), and pooled grading rates. `dsh eval report run.json` renders the run as markdown. Trial workspaces and traces stay under the run's `tempRoot` (a private temp directory) and are not deleted; remove them when the run is no longer needed.
|
|
136
|
+
`dsh eval run benchmark.yaml --out run.json` writes one JSON document per run: benchmark and model identity, per-trial outcomes with absolute trace paths, aggregate metrics (means for counts and wall times, pooled success rate), and pooled grading rates. `dsh eval report run.json` renders the run as markdown. Trial workspaces and traces stay under the run's `tempRoot` (a private temp directory) and are not deleted; remove them when the run is no longer needed. `--seed N`, `--trials N`, `--concurrency N`, `--profile name` and `--dsh "cmd"` override the YAML for one run; every override is recorded in `benchmarkOverrides` and folded into `benchmarkSha256` so `provenance` cannot report a match against a differently configured run.
|
|
137
|
+
|
|
138
|
+
The markdown report appends a **Reliability** block for each graded dimension (task success and tool-selection accuracy). A pooled rate cannot tell a benchmark where every case is 66% stable from one where two cases always pass and a third always fails; the block therefore reports `pass@1` (trial-level), `pass@k` (cases with at least one pass), and `pass^k` (cases that pass every trial), plus the flaky cases whose trials disagreed and the hardest cases by pass rate. The header also shows trial coverage (`completed / total`, unscored, timeouts) and the Reliability block prints **strict pass@1** beside the graded-only figure: an error or timeout stays in the denominator, so a model that times out on hard cases cannot outrank one that finishes and fails. All of it is computed from the stored trials at render time, so reports written before this feature gain the new view without being regenerated. `dsh eval run` exits nonzero if *any* trial fails, not only when every trial does.
|
|
139
|
+
|
|
140
|
+
`dsh eval report run.json --brief` prints a compact terminal summary instead: trial coverage, per-trial tool/step/token/cost figures, the task rate with pass@k/pass^k, the error-inclusive strict pass@1, the bootstrap interval, and the judge-failure count. The per-trial table is omitted so a hundred-trial run still fits on one screen.
|
|
141
|
+
|
|
142
|
+
`dsh eval dashboard a.json [b.json ...] --out report.html [--metric strictPassAt1]` writes a standalone HTML view (the metric flag applies to the 3+ run leaderboard only):
|
|
143
|
+
summary cards for coverage, pass@1/pass@k, latency p95 and cost, followed by
|
|
144
|
+
reliability, precision, judge/script agreement and a per-trial table. It has no
|
|
145
|
+
external CSS, fonts or scripts, respects the OS light/dark preference, and
|
|
146
|
+
HTML-escapes benchmark ids, case ids and error strings — an agent-produced
|
|
147
|
+
error message cannot inject markup into the page. Every file output (run JSON,
|
|
148
|
+
Markdown, CSV, HTML) is staged and renamed into place, so an interrupted write
|
|
149
|
+
cannot leave a truncated report. Supplying a second run adds a
|
|
150
|
+
comparison table built from the same rows as `dsh eval compare`, including
|
|
151
|
+
signed `B − A` deltas and the Bonferroni-corrected paired inference rows. Three
|
|
152
|
+
or more runs instead produce a leaderboard page using the same ranking as
|
|
153
|
+
`dsh eval leaderboard`, with task/strict/tool/judge rates and gap to leader;
|
|
154
|
+
`--metric strictPassAt1` ranks that page by the error-inclusive rate too.
|
|
155
|
+
All paths share one escaped, self-contained stylesheet.
|
|
156
|
+
|
|
157
|
+
A **Precision** block follows Reliability in the full report. It bootstraps the observed task/tool rates over the graded trials with the run's `seed` (2000 seeded resamples by default), printing a 95% percentile interval beside each rate and a `n=` count. A single trial reports the rate without an interval, since no resample can create uncertainty from one observation. The block also prints latency `p50/p95` from the trial metrics. This makes a three-trial smoke run look like the weak evidence it is instead of a precise-looking percentage.
|
|
158
|
+
|
|
159
|
+
The **Judge / script agreement** block pairs scripted `taskSuccess` with the
|
|
160
|
+
judge's "no hallucination" verdict on trials carrying both. It prints observed
|
|
161
|
+
agreement and Cohen's kappa, which subtracts the agreement expected from the two
|
|
162
|
+
marginals — an LLM judge that passes everything can otherwise look impressive
|
|
163
|
+
when the scripted checks pass everything too. Trials with an unusable verdict or
|
|
164
|
+
no check are excluded, and the block is omitted when no trial has both signals.
|
|
165
|
+
The same one-line statistic appears in `--brief` output.
|
|
99
166
|
|
|
100
167
|
## Comparison
|
|
101
168
|
|
|
102
|
-
`dsh eval compare run-v1.json run-v2.json` renders both runs as a markdown table: benchmark/model identity, completed trials, steps, tool/task/tool-selection rates, invalid calls, retries, tokens, cost, and latency, with signed `B - A` deltas. When both runs complete the same case x trial keys, the table appends paired statistics: trial count, win/lose/tie on the first available metric (task success, tool selection accuracy, or final-answer score), and mean `B - A` deltas for steps, tokens, and judge score.
|
|
103
|
-
|
|
104
|
-
Because a paired eval sample is small and its deltas are not normal, the paired block also carries inference rather than point estimates alone: an exact two-sided **sign test** over the discordant pairs (ties drop out, as the test requires) for the primary metric, and a seeded **bootstrap
|
|
169
|
+
`dsh eval compare run-v1.json run-v2.json` renders both runs as a markdown table: benchmark/model identity, completed trials, steps, tool/task/tool-selection rates, pass@k and pass^k for both grading dimensions, invalid calls, retries, tokens, cost, and latency, with signed `B - A` deltas. When both runs complete the same case x trial keys, the table appends paired statistics: trial count, win/lose/tie on the first available metric (task success, tool selection accuracy, or final-answer score), and mean `B - A` deltas for steps, tokens, and judge score. Each run's `seed` is both recorded provenance and injected into every trial as `DSH_EVAL_SEED`; determinism still depends on the harness reading that variable.
|
|
170
|
+
|
|
171
|
+
Because a paired eval sample is small and its deltas are not normal, the paired block also carries inference rather than point estimates alone: an exact two-sided **sign test** over the discordant pairs (ties drop out, as the test requires) for the primary metric, and a seeded **bootstrap interval** beside each mean delta. Nothing is assumed about the shape of the delta distribution, and the PRNG seed is fixed, so re-running `compare` on the same reports prints a byte-identical table. The sign-test p-value and every printed interval form one inference family, corrected together by **Bonferroni** at family-wise `alpha = 0.05`: the p row is labelled with the family size it was multiplied by, and each interval is widened to `1 - 0.05/k` confidence (for example, 98.8% when the p-value and three intervals are all present). A sign test still needs discordant pairs to say anything — when every pair ties it reports `p = 1`. A **power row** now states the best corrected p-value the current sample could ever produce and, when it cannot reach `alpha`, the minimum number of discordant pairs required (6 with one comparison, 8 with the usual four), so `p = 1` is no longer mistaken for evidence of no difference. `validate` warns before a run whose maximum possible pairs fall below that floor.
|
|
172
|
+
|
|
173
|
+
`dsh eval compare` also appends **Paired case outcomes**: every completed
|
|
174
|
+
case x trial classified on the same primary metric as the sign test, with
|
|
175
|
+
candidate wins listed before losses, capped at 20 rows. This makes a
|
|
176
|
+
significant p-value traceable to the specific cases responsible. The two-run
|
|
177
|
+
HTML dashboard shows the same discordant cases under **Changed cases**, and
|
|
178
|
+
adds a **Confirmed case changes** table for cases whose per-case corrected
|
|
179
|
+
significance is conclusive.
|
|
180
|
+
|
|
181
|
+
**Per-case paired significance** goes one step further: it aggregates those
|
|
182
|
+
trial outcomes by case, runs an exact sign test for each case, and corrects
|
|
183
|
+
across the tested cases as a separate Bonferroni family. The markdown block
|
|
184
|
+
lists only confirmed improvements/regressions (capped at 20 rows); `--json`
|
|
185
|
+
emits every case with `pairs`, `wins`, `losses`, `adjustedP`, `detectable`,
|
|
186
|
+
`requiredPairs` and its `verdict`. Power is evaluated against the whole case
|
|
187
|
+
family: with many cases tested at once, even a clean sweep may need more
|
|
188
|
+
discordant pairs to clear the corrected threshold. Those cases are labelled
|
|
189
|
+
`underpowered` and the report states how many pairs the family requires, so a
|
|
190
|
+
small win is never mistaken for a proven fix.
|
|
191
|
+
|
|
192
|
+
## Judge calibration
|
|
193
|
+
|
|
194
|
+
Agreement and kappa answer "do the judge and the scripted check decide the
|
|
195
|
+
same thing?"; calibration answers "is the judge's score actually useful for
|
|
196
|
+
ranking?" `computeCalibration` (rendered in full reports and the HTML
|
|
197
|
+
dashboard, and summarized in `--brief`) reports the mean normalized judge score
|
|
198
|
+
on scripted passes and failures, their separation, a ranking-accuracy score
|
|
199
|
+
equivalent to AUC (ties count as half), and a Brier score (mean squared error
|
|
200
|
+
against the scripted verdict, lower is better). It also lists up to five cases where the
|
|
201
|
+
two views disagree, so a rubric can be corrected from concrete examples instead
|
|
202
|
+
of a single aggregate number. Trials with a null score still contribute via
|
|
203
|
+
their hallucination flag; trials with neither signal are counted as ungraded
|
|
204
|
+
rather than guessed.
|
|
205
|
+
|
|
206
|
+
## Benchmark preflight
|
|
207
|
+
|
|
208
|
+
`dsh eval validate benchmark.yaml` parses a benchmark exactly as `run` does,
|
|
209
|
+
then prints a summary of cases, trials, concurrency, timeout, seed, judge,
|
|
210
|
+
replay and pricing. It also warns about configurations that run but produce
|
|
211
|
+
weak evidence: no scripted expectations, no checks or tool constraints, a judge
|
|
212
|
+
without gold answers, shell checks in an untrusted file, or replay runs that
|
|
213
|
+
will need `rejudge` for judge scores. Catching these before a run avoids
|
|
214
|
+
spending tokens on a benchmark that cannot answer its own question.
|
|
215
|
+
|
|
216
|
+
## Leaderboard
|
|
217
|
+
|
|
218
|
+
`dsh eval leaderboard a.json b.json c.json ...` ranks any number of runs by
|
|
219
|
+
pooled task success, with strict pass@1, tool selection, normalized judge
|
|
220
|
+
score, cost, latency and a gap-to-leader column. Pass
|
|
221
|
+
`--metric strictPassAt1` to rank by the error-inclusive rate instead; JSON
|
|
222
|
+
reports carry the chosen metric as `rankedBy`. Ties share a rank and missing
|
|
223
|
+
metrics sort last instead of being invented. It is explicitly a screening
|
|
224
|
+
view: the output points users back to `dsh eval compare` for paired inference
|
|
225
|
+
between two close runs.
|
|
226
|
+
|
|
227
|
+
## CI quality gate
|
|
228
|
+
|
|
229
|
+
`dsh eval gate candidate.json --baseline base.json --max-drop 0.05` turns a run
|
|
230
|
+
comparison into a build verdict. It checks completed-trial and unscored-trial
|
|
231
|
+
counts, then task success, tool selection accuracy, strict pass@1 and judge
|
|
232
|
+
score. Rates and judge scores are all normalized to 0..1 (the score is divided
|
|
233
|
+
by its run's `maxScore`), so one tolerance applies to every quality metric. The
|
|
234
|
+
command prints a markdown PASS/FAIL table and exits 1 on any regression beyond
|
|
235
|
+
the tolerance, making it suitable as a required CI step. It also lists
|
|
236
|
+
**confirmed case regressions**: cases whose paired evidence survives the
|
|
237
|
+
per-case Bonferroni family, so a CI log points at the specific cases to fix.
|
|
238
|
+
Each case needs several trial pairs to be confirmable — with the usual one
|
|
239
|
+
trial per case, no case can clear the corrected threshold. In significance
|
|
240
|
+
mode a confirmed case regression also fails the gate, so a PASS report can
|
|
241
|
+
never advertise one.
|
|
242
|
+
|
|
243
|
+
Optional `--max-cost-increase 0.1` and `--max-latency-increase 0.2` add
|
|
244
|
+
relative resource budgets, so a candidate that keeps quality but costs 2x more
|
|
245
|
+
still fails. Budget rows print absolute values with a relative delta; a missing
|
|
246
|
+
baseline metric skips that budget, while a missing candidate metric fails
|
|
247
|
+
closed. A tiny relative tolerance absorbs floating-point noise at 1e-9 of the
|
|
248
|
+
baseline without masking a real overrun. Add `--json` to emit the same verdict
|
|
249
|
+
as a single JSON object (`passed`, thresholds, `checks`, `regressions`) for CI
|
|
250
|
+
dashboards and automation. `--require-significance` adds a paired-sign-test
|
|
251
|
+
row: a quality drop only fails the gate when the sign test confirms a
|
|
252
|
+
regression, while an unpaired, underpowered or otherwise undecidable comparison
|
|
253
|
+
fails closed rather than silently passing a noisy drop. Each of the four
|
|
254
|
+
quality metrics is tested independently, so a clean task-success result cannot
|
|
255
|
+
hide a tool-selection or judge-score regression.
|
|
256
|
+
|
|
257
|
+
When paired trials exist, the verdict also lists up to five case x trials that
|
|
258
|
+
flipped from pass to fail (or lost judge score), with case ids sanitized for
|
|
259
|
+
markdown, so a failing gate points at what to investigate instead of only a
|
|
260
|
+
percentage. Metrics absent from the baseline are treated as "baseline ungraded" and pass;
|
|
261
|
+
metrics absent from the candidate fail rather than being silently skipped. Pass
|
|
262
|
+
`--allow-incomplete` to ignore trial-coverage differences when a benchmark
|
|
263
|
+
intentionally varies its trial count.
|
|
105
264
|
|
|
106
265
|
## Replay (keyless CI)
|
|
107
266
|
|
|
@@ -119,7 +278,50 @@ The directory holds one tree per trial named `<caseId>-<trial>/`, with child
|
|
|
119
278
|
logs riding alongside: `recorded/fix-tests-001-1/session.jsonl`. A missing
|
|
120
279
|
fixture fails that trial, and `judge` cannot be combined with `replay` in one
|
|
121
280
|
run. The npm release of the replay plugin lags the source workspace, so replay
|
|
122
|
-
runs require a source-mode harness checkout.
|
|
281
|
+
runs require a source-mode harness checkout. Trace paths are re-read from the
|
|
282
|
+
report during re-judging and must be absolute `.jsonl` files inside `tempRoot`,
|
|
283
|
+
so an edited report cannot make the judge ship an arbitrary local file to an
|
|
284
|
+
LLM.
|
|
285
|
+
|
|
286
|
+
## Offline re-judging
|
|
287
|
+
|
|
288
|
+
Because `judge` and `replay` cannot share a run, judge a recorded run in a
|
|
289
|
+
second phase:
|
|
290
|
+
|
|
291
|
+
```sh
|
|
292
|
+
dsh eval rejudge recorded-run.json --out judged-run.json
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
`rejudge` loads the run's harvested traces and its persisted `caseInputs`,
|
|
296
|
+
rebuilds each verdict through the injected judge seam, and re-aggregates the
|
|
297
|
+
grading summary. Metrics, scripted grades, trial outcomes, and error details are
|
|
298
|
+
untouched; only `judge` verdicts and `grading` change. The input report is never
|
|
299
|
+
overwritten (`--out` must differ). Reports written before `caseInputs` existed
|
|
300
|
+
are rejected with a field-specific diagnostic rather than silently judged with
|
|
301
|
+
an empty prompt.
|
|
302
|
+
|
|
303
|
+
A judge can be supplied or replaced at re-judge time, which is what makes the
|
|
304
|
+
replay workflow usable (a replay run has no stored judge config):
|
|
305
|
+
|
|
306
|
+
```sh
|
|
307
|
+
dsh eval rejudge recorded-run.json --out judged.json \
|
|
308
|
+
--judge-model deepseek-v4 --judge-provider deepseek \
|
|
309
|
+
--judge-rubric "Prefer concise, correct fixes." --judge-max-score 10
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Only `--judge-model` is required to override; the other flags default to
|
|
313
|
+
`deepseek`, `10`, and no rubric. The effective config is written into the new
|
|
314
|
+
report. If a judge call fails, an already usable verdict is kept with a
|
|
315
|
+
`judgeError` marker instead of being erased by an outage.
|
|
316
|
+
|
|
317
|
+
## Trial-level CSV export
|
|
318
|
+
|
|
319
|
+
`dsh eval export run.json [--out trials.csv]` flattens every trial into one CSV
|
|
320
|
+
row: case id, trial, status, error, scripted and judge verdicts, folded token
|
|
321
|
+
and latency metrics, cost, and the trace digest. Without `--out` the CSV goes
|
|
322
|
+
to stdout. Agent-controlled strings are CSV-escaped and prefixed with `'` when
|
|
323
|
+
they start with a spreadsheet formula marker, so a hostile case id cannot
|
|
324
|
+
execute on export.
|
|
123
325
|
|
|
124
326
|
## Importing external traces
|
|
125
327
|
|
|
@@ -146,11 +348,10 @@ None; this package neither assembles nor sends a provider request, so no request
|
|
|
146
348
|
|
|
147
349
|
## Known Limitations and Deferred Work
|
|
148
350
|
|
|
149
|
-
- **Judge output is best-effort** — a
|
|
150
|
-
- **Paired comparison pairs as-is** — trials pair by case id and trial index; `seed` is recorded provenance,
|
|
151
|
-
- **
|
|
351
|
+
- **Judge output is best-effort but no longer silent** — a failed or unparsable verdict carries `judgeError` and is counted in `grading.judgeFailures`; judge calls consume model quota outside the trial's measured cost.
|
|
352
|
+
- **Paired comparison pairs as-is** — trials pair by case id and trial index; `seed` is passed to each trial as `DSH_EVAL_SEED` and recorded as provenance, but determinism depends on the harness honoring it; per-arm leaderboards are not rendered.
|
|
353
|
+
- **Bonferroni is conservative** — it controls the family-wise error rate across the printed sign test and intervals without assuming independence, at the cost of wider intervals; a sign test also needs discordant pairs to say anything, so a run where every pair ties reports `p = 1`.
|
|
152
354
|
- **Replay binds by first-call order** — the replay plugin keys recorded scripts to live sessions by first-call order, so concurrent subagents replay non-deterministically.
|
|
153
355
|
- **Imported traces lack token usage** — Codex and Claude Code logs do not record provider usage, so imported runs report zero tokens and no cost.
|
|
154
356
|
- **Direct-child timeout only** — a timed-out trial kills the direct dsh process; on Windows its descendants may survive.
|
|
155
357
|
- **Windows launcher commands** — the spawned command runs without a shell, so `.cmd`/`.bat` shims need a direct executable or `node <path>` override (`--dsh "node C:/.../apps/cli/lib/bin.js"`).
|
|
156
|
-
- **No atomic report write** — the run JSON is written in place; a crash mid-write can truncate the report.
|
package/README.zh.md
CHANGED
|
@@ -2,7 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-eval)
|
|
6
|
+
[](https://github.com/hccccc01333/dsh-eval/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
**面向 [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) 的有证据 Agent 评测。** 一份 `benchmark.yaml` 进,可审计的 JSON、Markdown、CSV 与自包含 HTML 出。
|
|
12
|
+
|
|
13
|
+
> 没有不确定性、配对证据与来源摘要的准确率数字,只是猜测。dsh-eval 让报告里的每个结论都能追溯到 trial、提示词与 benchmark 文件哈希。
|
|
14
|
+
|
|
15
|
+
| | |
|
|
16
|
+
|---|---|
|
|
17
|
+
| **诚实的比率** | 严格 pass@1 把超时和错误留在分母里 |
|
|
18
|
+
| **真正的推断** | 配对符号检验、功效下限、bootstrap 区间、Bonferroni 校正 |
|
|
19
|
+
| **可审计的 run** | YAML、提示词、工作区与 CLI 覆盖项折叠成一个摘要 |
|
|
20
|
+
| **判官质检** | 一致率、kappa、区分度、排序准确率、Brier |
|
|
21
|
+
| **面向 CI** | `--require-significance` 门禁 + 硬成本/延迟预算 |
|
|
22
|
+
| **零外部资源报告** | 自包含、适配深色模式的 HTML 仪表盘 |
|
|
23
|
+
|
|
24
|
+
`dsh-eval@0.5.1` · 305 个测试 · `src` 语句/分支/函数/行覆盖率 100% · 类型检查干净 · Linux 与 Windows 双平台 CI。
|
|
6
25
|
|
|
7
26
|
本包同时是一个 bundle 和一个命令行应用。装进 profile 后即可运行评测:
|
|
8
27
|
|
|
@@ -17,6 +36,22 @@ dsh eval compare eval-v1.json eval-v2.json
|
|
|
17
36
|
|
|
18
37
|
trial 之间彼此独立——各自的临时工作区、隔离的 `DSH_HOME`、各自的补丁层——所以 `concurrency` 可以让这么多个 trial 同时跑。无论并发如何交错,run 记录仍按 case、再按 trial 的顺序列出结果;`--concurrency` 可覆盖文档里的值。调高它是用墙钟时间换峰值 CPU、内存与并发的模型额度。
|
|
19
38
|
|
|
39
|
+
run 进行中时,每个完成的 trial 会向 stderr 写一行有长度上限的进度,例如 `[eval] 3/12 golden #1 task pass, 1204 ms`。错误会输出净化后的消息,agent 控制的 case id 无法注入换行。只想要最终 stdout 摘要的脚本可以传 `--quiet`。
|
|
40
|
+
|
|
41
|
+
## 实际效果
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
*双 run 仪表盘:配对对比、确认 case 变化与判官校准集中在一个自包含文件里。*
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
*三个及以上 run 的排行榜,按严格 pass@1 排序并给出对领先者的配对判定。*
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
*有长度上限的进度行,以及会因确认的逐 case 回退而失败的 CI 门禁。*
|
|
54
|
+
|
|
20
55
|
## Benchmark 文档
|
|
21
56
|
|
|
22
57
|
```yaml
|
|
@@ -51,11 +86,11 @@ pricing:
|
|
|
51
86
|
| `trials` | `1` | 每个 case 的 trial 数。 |
|
|
52
87
|
| `concurrency` | `1` | 同时在跑的 case × trial 数;`1` 表示严格串行。 |
|
|
53
88
|
| `timeoutMs` | `600000` | 每个 trial 的超时;到期杀掉直接子进程。 |
|
|
54
|
-
| `seed` | `0` |
|
|
89
|
+
| `seed` | `0` | 基础种子:第 n 个 trial 的环境变量为 `DSH_EVAL_SEED=seed+n-1`,该值同时用于报告 bootstrap。harness 需读取该变量才能实现确定性采样。 |
|
|
55
90
|
| `cases[].id` | 必填 | 稳定的 case id。 |
|
|
56
91
|
| `cases[].prompt` / `cases[].promptFile` | 二选一 | 任务文本,内联或相对 benchmark 文件解析。 |
|
|
57
92
|
| `cases[].workspace` | 缺省 | 复制进每个 trial 的工作区树,相对或绝对路径。 |
|
|
58
|
-
| `cases[].expected` | 缺省 |
|
|
93
|
+
| `cases[].expected` | 缺省 | 脚本化评分:对记录到的工具调用名匹配 —— `tool`(旧子串)、`tools`(全部列出的子串)、`toolAnyOf`(至少一个)、`toolRegex`(加载时校验)、`toolNot`(都不出现),所有配置同时成立才算命中;`checkArgv`(推荐)、`check`(旧字符串形式,支持引号)或 `checkShell`(显式启用,支持管道/重定向)是 agent 退出后在 trial 工作区运行的命令(退出码 0 = 任务成功);`answer` 是交给 judge 的金标答案;`answerRegex`(加载时校验)匹配最终 assistant 回复,在没有配置 check 命令时决定 `taskSuccess`,从而无需 judge 也能做确定性评分。只匹配最终回答的前 4096 个字符;同时配置 check 命令与 `answerRegex` 会被 `validate` 警告,因为此时正则会被忽略。填了就必须至少给一个,且最多一种 check 模式。check 进程以独立进程组运行,超时整组终止。 |
|
|
59
94
|
| `pricing` | 缺省 | 以模型 id 为键的每百万 token 美元价;未配置的模型报 `costUsd: null`。 |
|
|
60
95
|
|
|
61
96
|
### Judge
|
|
@@ -77,23 +112,57 @@ judge:
|
|
|
77
112
|
| `rubric` | 缺省 | 追加到评审 prompt 的任务评分标准。 |
|
|
78
113
|
| `maxScore` | `10` | 最终答案得分的上限。 |
|
|
79
114
|
|
|
115
|
+
case 配了 `expected.answer` 时,judge 会收到该参考答案,并被要求按事实一致性而非表达流畅度打分。judge 调用失败或返回不可用内容时,裁决带 `judgeError`,run 的 `grading.judgeFailures` 会计数;报告会打印该计数,不再让分数悄悄从均值里消失。
|
|
116
|
+
|
|
80
117
|
judge 用 case 与合并后的 trace 构造一个严格 JSON 的 prompt。回复可解析时,trial 带上裁决字段(`finalAnswerScore`、`hallucination`、`rationale`);输出不可用或 chat 调用失败只记为空的裁决字段,绝不记为失败的 trial。配置了 judge 但宿主没有暴露 LLM chat seam 时,run 在启动前就失败。
|
|
81
118
|
|
|
82
119
|
## 指标
|
|
83
120
|
|
|
84
|
-
指标折叠直接从 session 日志计算自动指标:`turns`、`steps`、`toolCalls`、`toolResults`、`toolSuccess` 与 `toolSuccessRate`、`invalidToolCalls`(携带内部失败身份的 result)、`retries`(`llm/retry`)、互不重叠的 token 桶与合计、计费上下文 token、`llmMs`/`toolMs`/`ttftMs`/`latencyMs`,以及配置了定价后的 `costUsd`。脚本化评分增加每个 trial 的 `taskSuccess`(check 命令退出码 0
|
|
121
|
+
指标折叠直接从 session 日志计算自动指标:`turns`、`steps`、`toolCalls`、`toolResults`、`toolSuccess` 与 `toolSuccessRate`、`invalidToolCalls`(携带内部失败身份的 result)、`retries`(`llm/retry`)、互不重叠的 token 桶与合计、计费上下文 token、`llmMs`/`toolMs`/`ttftMs`/`latencyMs`,以及配置了定价后的 `costUsd`。脚本化评分增加每个 trial 的 `taskSuccess`(check 命令退出码 0;未配置 check 时由最终答案的 `answerRegex` 匹配决定)与 `toolSelectionAccuracy`(所有配置的工具约束同时成立),并合并为 run 级比率。`checkArgv` 完全不经过 shell;`checkShell` 仅用于可信 benchmark 文件中需要管道或重定向的场景。卡住的 check 会在 trial 超时时连同整个进程组一起终止,不会拖住整个 run。
|
|
85
122
|
|
|
86
123
|
trial `DSH_HOME` 下的子 session 日志在折叠前合并进 trial trace,因此委派给子 agent 的工作也计入 steps、token、工具调用、重试与延迟。judge 裁决增加每个 trial 的 `finalAnswerScore` 与 `hallucination`,并合并为 run 级平均分与幻觉率。
|
|
87
124
|
|
|
88
125
|
## 运行报告
|
|
89
126
|
|
|
90
|
-
`dsh eval run --out run.json` 每次运行写一份 JSON:benchmark 与模型标识、每个 trial 的结果与绝对 trace 路径、聚合指标(计数与耗时为均值,成功率为合并值)、合并后的评分比率。`dsh eval report run.json` 把 run 渲染为 Markdown。trial 工作区与 trace 保留在 run 的 `tempRoot`(私有临时目录)中且不会被删除,run 不再需要时自行清理。
|
|
127
|
+
`dsh eval run benchmark.yaml --out run.json` 每次运行写一份 JSON:benchmark 与模型标识、每个 trial 的结果与绝对 trace 路径、聚合指标(计数与耗时为均值,成功率为合并值)、合并后的评分比率。`dsh eval report run.json` 把 run 渲染为 Markdown。trial 工作区与 trace 保留在 run 的 `tempRoot`(私有临时目录)中且不会被删除,run 不再需要时自行清理。
|
|
128
|
+
|
|
129
|
+
Markdown 报告会为每个评分维度(任务成功、工具选择准确率)追加**可靠性**区块。合并比率无法区分"每个 case 都稳定在 66%"与"两个 case 全过、第三个全挂";因此区块给出 `pass@1`(trial 级)、`pass@k`(至少一个 trial 成功的 case 比例)、`pass^k`(全部 trial 成功的 case 比例),以及结果不一致的不稳定 case 和按通过率排序的最难 case。报告头部还会给出 trial 覆盖率(完成/总数、未评分、超时数),可靠性区块在"仅已评分"的通过率旁并列 **严格 pass@1**:超时与失败 trial 留在分母里,因此"难题上超时"的模型不会显得比"跑完但答错"的模型更好。这些指标在渲染时从已保存的 trial 现算,旧报告无需重跑就能获得新区块。`dsh eval run` 只要有任何 trial 失败就以非零码退出,而非等到全部失败。
|
|
130
|
+
|
|
131
|
+
`dsh eval report run.json --brief` 改为输出紧凑的终端摘要:试验覆盖率、每个 trial 的工具/步数/token/成本、任务通过率与 pass@k/pass^k、bootstrap 区间、判官失败数。省略逐 trial 表格,百次 run 也能一屏看完。
|
|
132
|
+
|
|
133
|
+
`dsh eval dashboard a.json [b.json ...] --out report.html` 写出独立的 HTML 视图:覆盖率、pass@1/pass@k、延迟 p95 与成本的摘要卡片,以及可靠性、精度、判官/脚本一致性和逐 trial 表格。无外部 CSS、字体或脚本,自动跟随系统亮/暗主题;benchmark id、case id 与错误字符串都做 HTML 转义,agent 产生的错误信息无法向页面注入标记。提供第二个 run 时会追加对比表,数据与 `dsh eval compare` 完全一致,包括带符号的 `B − A` 差值和 Bonferroni 校正后的配对推断行。三个及以上 run 则生成排行榜页面,排名规则与 `dsh eval leaderboard` 一致,包含任务/strict/工具/判官比率及与领先者的差距。所有路径共用同一份转义过的自包含样式。
|
|
134
|
+
|
|
135
|
+
完整报告里,可靠性区块之后是**精度**区块:用 run 的 `seed` 对已评分 trial 的 0/1 结果做 bootstrap(默认 2000 次固定种子重采样),给出任务/工具通过率的 95% 百分位区间与样本数 `n=`。只有一个 trial 时只报通过率、不报区间 —— 单个观测无法重采样出不确定性。区块同时给出 trial 延迟的 p50/p95,让三 trial 的冒烟测试看起来就是薄弱证据,而不是一个看似精确的百分比。
|
|
136
|
+
|
|
137
|
+
**判官 / 脚本一致性**区块把脚本的 `taskSuccess` 与判官的"未检出幻觉"结论配对(仅统计两者都存在的 trial),给出观察一致率与 Cohen's kappa。kappa 扣除了由两边边缘分布带来的偶然一致 —— 否则一个"什么都判通过"的判官,在脚本检查也全部通过时会显得很准。判官输出不可用或没有检查的 trial 会被排除;没有任何配对时该区块不渲染。`--brief` 输出同样包含一行该指标。
|
|
91
138
|
|
|
92
139
|
## 对比
|
|
93
140
|
|
|
94
|
-
`dsh eval compare run-v1.json run-v2.json` 把两个 run 渲染成 Markdown 表:benchmark/模型标识、完成的 trial 数、steps
|
|
141
|
+
`dsh eval compare run-v1.json run-v2.json` 把两个 run 渲染成 Markdown 表:benchmark/模型标识、完成的 trial 数、steps、工具/任务/工具选择成功率、两个评分维度的 pass@k 与 pass^k、无效调用、重试、token、成本与延迟,并给出带符号的 `B - A` 差值。当两个 run 完成的 case × trial 键完全一致时,表尾追加配对统计:trial 数、按第一个可用指标(任务成功、工具选择准确率、最终答案得分)的胜/负/平,以及 steps、token、judge 得分的 `B - A` 均值差。每个 run 的 `seed` 既是配对的可追溯出处,也注入到每个 trial 的 `DSH_EVAL_SEED`;是否确定性仍取决于 harness 是否读取该变量。
|
|
142
|
+
|
|
143
|
+
配对样本量小、差值不服从正态,所以配对区块除了点估计还给出推断:对主指标的不一致对做**精确双侧符号检验**(同分的对按要求剔除),并在每个均值差旁给出**固定种子 bootstrap 区间**。不对差值分布的形状做任何假设,PRNG 种子固定,因此同一对报告重跑 `compare` 输出逐字节一致。符号检验的 p 值与输出的每个区间构成一个推断族,用 **Bonferroni** 在族错误率 `alpha = 0.05` 下一并校正:p 值所在行标注其乘上的族大小,每个区间放宽到 `1 - 0.05/k` 置信度(例如 p 值与三个区间同时存在时为 98.8%)。符号检验仍需要不一致对才能给出结论:全部同分的 run 报 `p = 1`。新增的**统计功效行**会说明当前样本在最理想结果下能达到的最佳校正 p 值;若根本达不到 `alpha`,则给出所需的最少不一致对数(单项比较为 6,常见四项比较为 8),避免把 `p = 1` 误读为"没有差异"。`validate` 也会在 benchmark 能提供的最大配对数低于该门槛时提前警告。
|
|
144
|
+
|
|
145
|
+
`dsh eval compare` 还会追加 **Paired case outcomes**:每个完成的 case x trial 用与符号检验相同的主指标分类,候选胜出排在失败之前,最多显示 20 行。这样显著的 p 值可以直接追溯到造成差异的具体 case。双 run HTML 仪表盘也在 **Changed cases** 下展示相同的不一致案例。
|
|
95
146
|
|
|
96
|
-
|
|
147
|
+
## 判官校准
|
|
148
|
+
|
|
149
|
+
一致率与 kappa 回答"判官和脚本是否得出相同结论",校准回答"判官的分数对排序是否真的有用"。`computeCalibration`(渲染在完整报告与 HTML 仪表盘中,`--brief` 输出摘要)给出脚本通过与失败 trial 的判官归一化均分、两者差值,以及等价于 AUC 的排序准确率(并列计半)。它还会列出最多 5 个两种视图不一致的 case,便于直接按实例修正 rubric,而不是只盯着一个聚合数字。分数缺失的 trial 仍可通过幻觉标记参与判断;两者都缺失的 trial 记为未评分,不做猜测。
|
|
150
|
+
|
|
151
|
+
## Benchmark 预检
|
|
152
|
+
|
|
153
|
+
`dsh eval validate benchmark.yaml` 用与 `run` 完全相同的解析器验证 benchmark,然后输出 case、trial、并发、超时、seed、判官、回放与定价摘要。它还会警告那些能跑但证据薄弱的配置:没有脚本期望、没有检查或工具约束、判官没有标准答案、不可信文件中的 shell 检查,以及需要 `rejudge` 才有判官分数的回放 run。在运行前发现这些问题,可以避免把 token 花在无法回答自身问题的 benchmark 上。
|
|
154
|
+
|
|
155
|
+
## 排行榜
|
|
156
|
+
|
|
157
|
+
`dsh eval leaderboard a.json b.json c.json ...` 按合并任务成功率给任意数量的 run 排名,同时给出 strict pass@1、工具选择、归一化判官分数、成本、延迟和与领先者的差距。并列共享名次,缺失指标排在末尾且不会被臆造。它明确只是筛选视图:输出会提示用 `dsh eval compare` 对接近的两个 run 做配对推断。
|
|
158
|
+
|
|
159
|
+
## CI 质量门禁
|
|
160
|
+
|
|
161
|
+
`dsh eval gate candidate.json --baseline base.json --max-drop 0.05` 把 run 对比变成构建判定。它先检查完成 trial 数与未评分 trial 数,再检查任务成功率、工具选择准确率、strict pass@1 与判官得分。所有质量指标都归一化到 0..1(判官得分除以对应 run 的 `maxScore`),因此一个容差适用于所有指标。命令输出 PASS/FAIL 表格,任何指标回退超过容差即以 1 退出,可直接作为 CI 必需步骤。
|
|
162
|
+
|
|
163
|
+
可选的 `--max-cost-increase 0.1` 与 `--max-latency-increase 0.2` 增加相对资源预算:质量不变但成本翻倍的候选同样会失败。预算行显示绝对值与相对差值;基线缺失该指标时跳过,候选缺失则判失败。极小的相对容差(基数的 1e-9)只用于吸收浮点噪声,不会掩盖真实超限。加 `--json` 可把同一判定输出为单个 JSON 对象(`passed`、各阈值、`checks`、`regressions`),便于 CI 仪表盘和自动化消费。`--require-significance` 增加配对符号检验判定行:只有统计确认的回退才会让门禁失败;没有配对样本、检验功效不足或其他无法判定的情况会直接失败,不会把噪声波动悄悄放过。四个质量指标各自独立检验,任务成功率持平不会掩盖工具选择或判官分数的显著回退。
|
|
164
|
+
|
|
165
|
+
存在配对 trial 时,判定还会列出最多 5 个从通过翻转为失败(或判官分数下降)的 case x trial,case id 会做 markdown 净化;失败的门禁因此能直接指出该查哪里,而不只是一个百分比。基线缺失的指标记为 "baseline ungraded" 并通过;候选 run 缺失的指标则判失败,不会被悄悄跳过。若 benchmark 有意改变 trial 数量,可传 `--allow-incomplete` 跳过覆盖度检查。
|
|
97
166
|
|
|
98
167
|
## 回放(keyless CI)
|
|
99
168
|
|
|
@@ -106,6 +175,26 @@ replay:
|
|
|
106
175
|
|
|
107
176
|
该目录下每个 trial 一棵树,命名为 `<caseId>-<trial>/`,子日志与其并列:`recorded/fix-tests-001-1/session.jsonl`。缺夹具会让该 trial 失败;`judge` 不能与 `replay` 出现在同一个 run 里。回放插件的 npm 发布版滞后于源码工作区,因此回放需要源码模式的 harness 检出。
|
|
108
177
|
|
|
178
|
+
## 离线重评分
|
|
179
|
+
|
|
180
|
+
由于 `judge` 与 `replay` 不能在同一个 run 里共存,可把评审拆成两阶段:
|
|
181
|
+
|
|
182
|
+
```sh
|
|
183
|
+
dsh eval rejudge recorded-run.json --out judged-run.json
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
`rejudge` 从报告记录的 trace 路径与 `caseInputs` 重建判官 prompt,为每个 trial 重新生成裁决,并重新汇总 grading。指标、脚本评分、trial 结果与错误详情保持不变,只有 `judge` 裁决与 `grading` 变化。输入报告不会被覆盖(`--out` 必须不同)。没有 `caseInputs` 的旧报告会收到明确诊断,而不会用空 prompt 悄悄重评。trace 路径必须是 `tempRoot` 内的绝对 `.jsonl` 路径,避免被篡改的报告诱使判官把本地任意文件发给 LLM。
|
|
187
|
+
|
|
188
|
+
重评时可以指定或替换判官配置 —— 这是回放工作流可用的前提(回放 run 没有保存 judge 配置):
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
dsh eval rejudge recorded-run.json --out judged.json \
|
|
192
|
+
--judge-model deepseek-v4 --judge-provider deepseek \
|
|
193
|
+
--judge-rubric "答案正确且简洁" --judge-max-score 10
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
覆盖配置只需 `--judge-model`,其余默认 `deepseek`、`10` 与无 rubric;实际使用的配置会写入新报告。若判官调用失败,已有的有效裁决会被保留并标注 `judgeError`,不会被一次故障抹掉。
|
|
197
|
+
|
|
109
198
|
## 导入外部 trace
|
|
110
199
|
|
|
111
200
|
`dsh eval import codex|claude-code <session.jsonl> --out run.json` 把 Codex 或 Claude Code 的 session 日志导入成一个单 trial 的 run,并折叠出指标:
|
|
@@ -130,9 +219,9 @@ replay:
|
|
|
130
219
|
|
|
131
220
|
## 已知限制与延后项
|
|
132
221
|
|
|
133
|
-
- **judge
|
|
134
|
-
- **配对对比按现状配对** —— trial 按 case id 与 trial 序号配对;`seed`
|
|
135
|
-
-
|
|
222
|
+
- **judge 输出尽力而为但不再静默** —— 失败或无法解析的裁决带 `judgeError` 并计入 `grading.judgeFailures`;judge 调用消耗的模型额度不计入 trial 的计量成本。
|
|
223
|
+
- **配对对比按现状配对** —— trial 按 case id 与 trial 序号配对;`seed` 传入每个 trial 的 `DSH_EVAL_SEED` 并作为出处记录,但确定性取决于 harness 是否遵守该变量;按实验组(arm)的排行榜尚未渲染。
|
|
224
|
+
- **Bonferroni 偏保守** —— 它在不假设各推断独立的前提下控制族错误率,代价是区间更宽;符号检验仍需要不一致对才能给出结论,全部同分的 run 报 `p = 1`。
|
|
136
225
|
- **回放按首次调用顺序绑定** —— 回放插件按首次调用顺序把录制脚本对应到实时 session,因此并发子 agent 的回放是非确定性的。
|
|
137
226
|
- **导入的 trace 没有 token 用量** —— Codex 与 Claude Code 日志不记录 provider 用量,导入的 run 报零 token 且无成本。
|
|
138
227
|
- **超时只杀直接子进程** —— 超时的 trial 只杀直接 dsh 进程;在 Windows 上它的后代进程可能存活。
|
package/lib/agreement.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Judge / script agreement for dsh-eval.
|
|
3
|
+
*
|
|
4
|
+
* A scripted check and an LLM judge are two independent views of the same
|
|
5
|
+
* trial. Observed agreement alone is misleading when one view almost always
|
|
6
|
+
* passes, so we also report Cohen's kappa, which subtracts the agreement
|
|
7
|
+
* expected from the two marginals. The judge signal used here is
|
|
8
|
+
* "no hallucination flagged", paired with scripted `taskSuccess`.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-eval/agreement
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Compute judge/script agreement for a run.
|
|
14
|
+
* @param run - a persisted run record.
|
|
15
|
+
* @returns the summary, or null when no trial carries both signals.
|
|
16
|
+
*/
|
|
17
|
+
export function computeAgreement(run) {
|
|
18
|
+
let pairs = 0;
|
|
19
|
+
let agreements = 0;
|
|
20
|
+
let judgePassed = 0;
|
|
21
|
+
let scriptPassed = 0;
|
|
22
|
+
for (const result of run.cases) {
|
|
23
|
+
const script = result.grade?.taskSuccess;
|
|
24
|
+
const judge = result.judge?.hallucination;
|
|
25
|
+
if (script === undefined || script === null || judge === undefined || judge === null)
|
|
26
|
+
continue;
|
|
27
|
+
pairs += 1;
|
|
28
|
+
const judgePass = !judge;
|
|
29
|
+
if (judgePass)
|
|
30
|
+
judgePassed += 1;
|
|
31
|
+
if (script)
|
|
32
|
+
scriptPassed += 1;
|
|
33
|
+
if (judgePass === script)
|
|
34
|
+
agreements += 1;
|
|
35
|
+
}
|
|
36
|
+
if (pairs === 0)
|
|
37
|
+
return null;
|
|
38
|
+
const rate = agreements / pairs;
|
|
39
|
+
const judgeRate = judgePassed / pairs;
|
|
40
|
+
const scriptRate = scriptPassed / pairs;
|
|
41
|
+
const chance = judgeRate * scriptRate + (1 - judgeRate) * (1 - scriptRate);
|
|
42
|
+
// A degenerate marginal (everyone passes) leaves kappa undefined at 0/0;
|
|
43
|
+
// in that case perfect observed agreement is the only sensible answer.
|
|
44
|
+
const kappa = 1 - chance < Number.EPSILON ? rate : (rate - chance) / (1 - chance);
|
|
45
|
+
return { pairs, agreements, rate, kappa, judgePassed, scriptPassed };
|
|
46
|
+
}
|
package/lib/argv.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small, dependency-free command-line splitter shared by the CLI `--dsh`
|
|
3
|
+
* override and benchmark check commands.
|
|
4
|
+
*
|
|
5
|
+
* Whitespace-only splitting silently breaks paths with spaces and quoted
|
|
6
|
+
* arguments: `node "my script.mjs" --flag "a b"` used to become five argv
|
|
7
|
+
* entries. This parser supports single/double quotes, backslash escapes and
|
|
8
|
+
* escaped whitespace, without pretending to be a full POSIX shell (redirection
|
|
9
|
+
* and pipes stay the job of explicit opt-in `checkShell`).
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-eval/argv
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Split a command string into argv tokens.
|
|
15
|
+
* @param value - the command line as written by the user.
|
|
16
|
+
* @returns argv tokens with quotes and escapes removed.
|
|
17
|
+
* @throws on an unterminated quote, which is a typo rather than an empty command.
|
|
18
|
+
*/
|
|
19
|
+
export function splitArgv(value) {
|
|
20
|
+
const tokens = [];
|
|
21
|
+
let token = '';
|
|
22
|
+
let started = false;
|
|
23
|
+
let quote;
|
|
24
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
25
|
+
const char = value[index];
|
|
26
|
+
if (quote !== undefined) {
|
|
27
|
+
if (char === quote) {
|
|
28
|
+
quote = undefined;
|
|
29
|
+
}
|
|
30
|
+
else if (char === '\\' && quote === '"' && index + 1 < value.length) {
|
|
31
|
+
token += value[index + 1];
|
|
32
|
+
index += 1;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
token += char;
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (char === '"' || char === "'") {
|
|
40
|
+
quote = char;
|
|
41
|
+
started = true;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (char === '\\' && index + 1 < value.length && /\s/u.test(value[index + 1])) {
|
|
45
|
+
token += value[index + 1];
|
|
46
|
+
started = true;
|
|
47
|
+
index += 1;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (/\s/u.test(char)) {
|
|
51
|
+
if (started) {
|
|
52
|
+
tokens.push(token);
|
|
53
|
+
token = '';
|
|
54
|
+
started = false;
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
token += char;
|
|
59
|
+
started = true;
|
|
60
|
+
}
|
|
61
|
+
if (quote !== undefined)
|
|
62
|
+
throw new Error('unterminated quote in command');
|
|
63
|
+
if (started)
|
|
64
|
+
tokens.push(token);
|
|
65
|
+
return tokens;
|
|
66
|
+
}
|