niceeval 0.6.1 → 0.7.0

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.
Files changed (378) hide show
  1. package/INDEX.md +23 -23
  2. package/README.zh.md +6 -6
  3. package/dist/agents/types.d.ts +69 -7
  4. package/dist/context/types.d.ts +32 -12
  5. package/dist/i18n/en.d.ts +54 -0
  6. package/dist/i18n/zh-CN.d.ts +57 -3
  7. package/dist/o11y/types.d.ts +16 -2
  8. package/dist/report/aggregate.d.ts +32 -24
  9. package/dist/report/aggregate.js +158 -50
  10. package/dist/report/built-in/index.d.ts +2 -0
  11. package/dist/report/built-in/index.js +8 -0
  12. package/dist/report/components.d.ts +93 -160
  13. package/dist/report/components.js +377 -114
  14. package/dist/report/compute.d.ts +87 -81
  15. package/dist/report/compute.js +597 -417
  16. package/dist/report/flag.d.ts +32 -6
  17. package/dist/report/flag.js +92 -4
  18. package/dist/report/format.d.ts +19 -11
  19. package/dist/report/format.js +30 -13
  20. package/dist/report/index.d.ts +16 -16
  21. package/dist/report/index.js +20 -21
  22. package/dist/report/load.js +3 -2
  23. package/dist/report/locale.d.ts +57 -33
  24. package/dist/report/locale.js +122 -56
  25. package/dist/report/metrics.d.ts +23 -4
  26. package/dist/report/metrics.js +110 -25
  27. package/dist/report/primitives.d.ts +48 -15
  28. package/dist/report/primitives.js +135 -26
  29. package/dist/report/react/AttemptList.d.ts +9 -7
  30. package/dist/report/react/AttemptList.js +17 -10
  31. package/dist/report/react/DeltaTable.js +19 -18
  32. package/dist/report/react/EvalList.d.ts +4 -4
  33. package/dist/report/react/EvalList.js +0 -0
  34. package/dist/report/react/ExperimentComparison.d.ts +10 -0
  35. package/dist/report/react/ExperimentComparison.js +12 -0
  36. package/dist/report/react/ExperimentList.d.ts +4 -3
  37. package/dist/report/react/ExperimentList.js +17 -18
  38. package/dist/report/react/MetricBars.js +5 -4
  39. package/dist/report/react/MetricLine.js +12 -5
  40. package/dist/report/react/MetricMatrix.js +1 -1
  41. package/dist/report/react/MetricScatter.js +59 -28
  42. package/dist/report/react/MetricTable.js +2 -12
  43. package/dist/report/react/ScopeSummary.d.ts +10 -0
  44. package/dist/report/react/ScopeSummary.js +17 -0
  45. package/dist/report/react/Scoreboard.js +6 -6
  46. package/dist/report/react/cell.js +2 -2
  47. package/dist/report/react/chart-math.d.ts +23 -6
  48. package/dist/report/react/chart-math.js +71 -19
  49. package/dist/report/react/fixtures.d.ts +5 -9
  50. package/dist/report/react/fixtures.js +110 -147
  51. package/dist/report/react/index.d.ts +15 -5
  52. package/dist/report/react/index.js +18 -7
  53. package/dist/report/report.d.ts +137 -16
  54. package/dist/report/report.js +259 -28
  55. package/dist/report/text/faces.d.ts +17 -19
  56. package/dist/report/text/faces.js +253 -184
  57. package/dist/report/text/plot.js +1 -1
  58. package/dist/report/text/table.js +38 -7
  59. package/dist/report/tree.d.ts +90 -40
  60. package/dist/report/tree.js +252 -94
  61. package/dist/report/types.d.ts +247 -284
  62. package/dist/report/types.js +4 -3
  63. package/dist/report/web.d.ts +21 -5
  64. package/dist/report/web.js +42 -16
  65. package/dist/results/select.d.ts +38 -16
  66. package/dist/results/select.js +73 -25
  67. package/dist/results/types.d.ts +49 -14
  68. package/dist/runner/feedback/sink.d.ts +110 -0
  69. package/dist/runner/types.d.ts +513 -22
  70. package/dist/sandbox/docker.d.ts +23 -2
  71. package/dist/sandbox/e2b.d.ts +15 -1
  72. package/dist/sandbox/errors.d.ts +30 -3
  73. package/dist/sandbox/io-retry.d.ts +17 -0
  74. package/dist/sandbox/registry.d.ts +2 -0
  75. package/dist/sandbox/resolve.d.ts +18 -5
  76. package/dist/sandbox/retry.d.ts +11 -1
  77. package/dist/sandbox/types.d.ts +39 -5
  78. package/dist/sandbox/vercel.d.ts +7 -1
  79. package/dist/scoring/coverage.d.ts +30 -0
  80. package/dist/scoring/display.d.ts +21 -0
  81. package/dist/scoring/display.js +120 -0
  82. package/dist/scoring/types.d.ts +103 -20
  83. package/dist/shared/aggregate.d.ts +4 -2
  84. package/dist/shared/aggregate.js +8 -7
  85. package/dist/shared/types.d.ts +28 -0
  86. package/dist/tty-line.d.ts +0 -4
  87. package/dist/util.d.ts +23 -0
  88. package/docs-site/zh/README.md +44 -0
  89. package/docs-site/zh/examples/ai-agent-application.mdx +63 -0
  90. package/docs-site/zh/examples/coding-agent-extensions.mdx +57 -0
  91. package/docs-site/zh/examples/index.mdx +50 -0
  92. package/docs-site/zh/{concepts → explanation}/adapter.mdx +31 -13
  93. package/docs-site/zh/{concepts → explanation}/assert.mdx +7 -7
  94. package/docs-site/zh/{concepts → explanation}/drive.mdx +8 -8
  95. package/docs-site/zh/{concepts → explanation}/evals.mdx +4 -4
  96. package/docs-site/zh/{concepts → explanation}/experiment.mdx +8 -8
  97. package/docs-site/zh/{concepts → explanation}/hitl.mdx +8 -8
  98. package/docs-site/zh/{concepts → explanation}/judge.mdx +5 -5
  99. package/docs-site/zh/{concepts → explanation}/overview.mdx +11 -11
  100. package/docs-site/zh/{guides → explanation}/runner.mdx +18 -8
  101. package/docs-site/zh/{concepts → explanation}/tier.mdx +6 -6
  102. package/docs-site/zh/{guides → how-to}/agent-feedback-loop.mdx +35 -33
  103. package/docs-site/zh/{guides → how-to}/authoring.mdx +35 -2
  104. package/docs-site/zh/{guides → how-to}/ci-integration.mdx +23 -12
  105. package/docs-site/zh/{guides → how-to}/connect-otel.mdx +6 -6
  106. package/docs-site/zh/{guides → how-to}/connect-your-agent.mdx +47 -21
  107. package/docs-site/zh/{guides → how-to}/custom-reports.mdx +34 -39
  108. package/docs-site/zh/{guides → how-to}/dataset-fanout.mdx +25 -3
  109. package/docs-site/zh/{guides → how-to}/experiments.mdx +12 -5
  110. package/docs-site/zh/how-to/publish-report.mdx +105 -0
  111. package/docs-site/zh/{guides → how-to}/reporters.mdx +2 -2
  112. package/docs-site/zh/{guides → how-to}/sandbox-agent.mdx +56 -7
  113. package/docs-site/zh/how-to/sandbox-providers.mdx +350 -0
  114. package/docs-site/zh/{guides → how-to}/scoring-guide.mdx +4 -4
  115. package/docs-site/zh/{guides → how-to}/viewing-results.mdx +82 -39
  116. package/docs-site/zh/{guides → how-to}/write-experiment.mdx +6 -4
  117. package/docs-site/zh/{guides → how-to}/write-send.mdx +30 -14
  118. package/docs-site/zh/index.mdx +24 -26
  119. package/docs-site/zh/introduction.mdx +8 -8
  120. package/docs-site/zh/reference/builtin-agents.mdx +32 -5
  121. package/docs-site/zh/reference/capabilities.mdx +8 -8
  122. package/docs-site/zh/reference/cli.mdx +40 -12
  123. package/docs-site/zh/reference/define-agent.mdx +58 -5
  124. package/docs-site/zh/reference/define-config.mdx +1 -1
  125. package/docs-site/zh/reference/define-eval.mdx +42 -9
  126. package/docs-site/zh/reference/events.mdx +3 -3
  127. package/docs-site/zh/reference/expect.mdx +26 -1
  128. package/docs-site/zh/{guides → reference}/official-adapters.mdx +32 -8
  129. package/docs-site/zh/{guides → reference}/report-components.mdx +45 -33
  130. package/docs-site/zh/{guides → reference}/results-data.mdx +21 -13
  131. package/docs-site/zh/troubleshooting/debug-sandbox.mdx +57 -0
  132. package/docs-site/zh/troubleshooting/debugging.mdx +212 -0
  133. package/docs-site/zh/{quickstart.mdx → tutorials/quickstart.mdx} +5 -17
  134. package/package.json +10 -2
  135. package/src/agents/ai-sdk-otel.test.ts +1 -0
  136. package/src/agents/ai-sdk.test.ts +3 -0
  137. package/src/agents/ai-sdk.ts +3 -0
  138. package/src/agents/bub-install-spec.test.ts +34 -0
  139. package/src/agents/bub-install-spec.ts +32 -0
  140. package/src/agents/bub.ts +31 -32
  141. package/src/agents/claude-code.test.ts +130 -9
  142. package/src/agents/claude-code.ts +76 -4
  143. package/src/agents/codex.test.ts +189 -40
  144. package/src/agents/codex.ts +155 -14
  145. package/src/agents/coding-cli-versions.test.ts +15 -0
  146. package/src/agents/coding-cli-versions.ts +3 -0
  147. package/src/agents/index.ts +13 -2
  148. package/src/agents/langgraph.test.ts +204 -0
  149. package/src/agents/langgraph.ts +495 -0
  150. package/src/agents/marketplace.ts +85 -0
  151. package/src/agents/native-config.test.ts +179 -0
  152. package/src/agents/native-config.ts +267 -0
  153. package/src/agents/openai-compat.test.ts +1 -0
  154. package/src/agents/openai-compat.ts +1 -1
  155. package/src/agents/openclaw.test.ts +31 -0
  156. package/src/agents/openclaw.ts +171 -0
  157. package/src/agents/plugin-config.test.ts +1 -0
  158. package/src/agents/sdk-streams.test.ts +79 -0
  159. package/src/agents/sdk-streams.ts +55 -10
  160. package/src/agents/skills.test.ts +1 -0
  161. package/src/agents/streaming.test.ts +3 -9
  162. package/src/agents/streaming.ts +2 -2
  163. package/src/agents/types.ts +71 -8
  164. package/src/agents/ui-message-stream.test.ts +3 -0
  165. package/src/cli.ts +446 -124
  166. package/src/context/context.test.ts +51 -12
  167. package/src/context/context.ts +162 -30
  168. package/src/context/session.test.ts +2 -1
  169. package/src/context/session.ts +115 -7
  170. package/src/context/types.ts +30 -12
  171. package/src/define.test.ts +13 -8
  172. package/src/define.ts +25 -4
  173. package/src/expect/index.ts +53 -23
  174. package/src/i18n/en.ts +81 -17
  175. package/src/i18n/zh-CN.ts +80 -17
  176. package/src/o11y/cost.test.ts +1 -0
  177. package/src/o11y/execution-tree.test.ts +1 -20
  178. package/src/o11y/otlp/mappers/claude-code.test.ts +1 -0
  179. package/src/o11y/otlp/parse.test.ts +1 -0
  180. package/src/o11y/otlp/turn-otel.test.ts +1 -0
  181. package/src/o11y/parsers/bub.test.ts +1 -0
  182. package/src/o11y/parsers/claude-code.test.ts +1 -34
  183. package/src/o11y/parsers/openclaw.test.ts +154 -0
  184. package/src/o11y/parsers/openclaw.ts +310 -0
  185. package/src/o11y/prices.json +746 -311
  186. package/src/o11y/tool-names.test.ts +1 -0
  187. package/src/o11y/types.ts +16 -2
  188. package/src/report/aggregate.ts +178 -61
  189. package/src/report/built-in/index.tsx +9 -0
  190. package/src/report/components.tsx +625 -279
  191. package/src/report/compute.ts +723 -491
  192. package/src/report/dual-render.test.tsx +741 -1024
  193. package/src/report/flag.ts +104 -12
  194. package/src/report/format.ts +32 -12
  195. package/src/report/index.ts +119 -46
  196. package/src/report/load.ts +3 -2
  197. package/src/report/locale.ts +136 -65
  198. package/src/report/metrics.ts +108 -25
  199. package/src/report/primitives.tsx +196 -45
  200. package/src/report/react/AttemptList.tsx +30 -43
  201. package/src/report/react/DeltaTable.tsx +63 -45
  202. package/src/report/react/EvalList.tsx +0 -0
  203. package/src/report/react/ExperimentComparison.tsx +73 -0
  204. package/src/report/react/ExperimentList.tsx +50 -32
  205. package/src/report/react/MetricBars.tsx +5 -4
  206. package/src/report/react/MetricLine.tsx +13 -8
  207. package/src/report/react/MetricMatrix.tsx +2 -2
  208. package/src/report/react/MetricScatter.tsx +86 -34
  209. package/src/report/react/MetricTable.tsx +4 -76
  210. package/src/report/react/ScopeSummary.tsx +86 -0
  211. package/src/report/react/Scoreboard.tsx +28 -10
  212. package/src/report/react/cell.tsx +2 -2
  213. package/src/report/react/chart-math.test.ts +85 -0
  214. package/src/report/react/chart-math.ts +101 -22
  215. package/src/report/react/enhance.js +89 -5
  216. package/src/report/react/fixtures.ts +114 -154
  217. package/src/report/react/index.tsx +24 -39
  218. package/src/report/react/render.test.tsx +138 -158
  219. package/src/report/react/styles.css +243 -82
  220. package/src/report/report.test.ts +779 -841
  221. package/src/report/report.ts +423 -41
  222. package/src/report/text/faces.ts +290 -193
  223. package/src/report/text/plot.ts +1 -1
  224. package/src/report/text/table.ts +44 -7
  225. package/src/report/tree.ts +362 -104
  226. package/src/report/types.ts +261 -271
  227. package/src/report/web.ts +63 -20
  228. package/src/results/annotated-source.test.ts +62 -9
  229. package/src/results/annotated-source.ts +64 -6
  230. package/src/results/attempt-evidence.test.ts +13 -11
  231. package/src/results/attempt-evidence.ts +20 -13
  232. package/src/results/attempt-source.ts +6 -3
  233. package/src/results/copy.ts +150 -60
  234. package/src/results/host-equivalence.test.ts +34 -20
  235. package/src/results/index.ts +12 -4
  236. package/src/results/locator.test.ts +1 -22
  237. package/src/results/open.ts +15 -5
  238. package/src/results/publish.ts +149 -0
  239. package/src/results/results.test.ts +89 -54
  240. package/src/results/select.ts +104 -34
  241. package/src/results/truncate.ts +90 -0
  242. package/src/results/types.ts +43 -14
  243. package/src/results/writer.ts +31 -13
  244. package/src/runner/attempt.test.ts +138 -7
  245. package/src/runner/attempt.ts +603 -104
  246. package/src/runner/discover.test.ts +47 -0
  247. package/src/runner/discover.ts +36 -2
  248. package/src/runner/eval-source.test.ts +1 -27
  249. package/src/runner/feedback/agent.test.ts +504 -0
  250. package/src/runner/feedback/agent.ts +409 -0
  251. package/src/runner/feedback/ci.test.ts +562 -0
  252. package/src/runner/feedback/ci.ts +401 -0
  253. package/src/runner/feedback/coordinator.test.ts +317 -0
  254. package/src/runner/feedback/coordinator.ts +397 -0
  255. package/src/runner/feedback/failure.ts +40 -0
  256. package/src/runner/feedback/human.test.ts +616 -0
  257. package/src/runner/feedback/human.ts +535 -0
  258. package/src/runner/feedback/index.ts +66 -0
  259. package/src/runner/feedback/io.ts +78 -0
  260. package/src/runner/feedback/profile.test.ts +50 -0
  261. package/src/runner/feedback/profile.ts +58 -0
  262. package/src/runner/feedback/reducer.test.ts +395 -0
  263. package/src/runner/feedback/reducer.ts +260 -0
  264. package/src/runner/feedback/renderer.ts +82 -0
  265. package/src/runner/feedback/sink.ts +203 -0
  266. package/src/runner/feedback/testing.ts +106 -0
  267. package/src/runner/ledger.test.ts +230 -0
  268. package/src/runner/ledger.ts +329 -0
  269. package/src/runner/report.test.ts +128 -3
  270. package/src/runner/report.ts +33 -9
  271. package/src/runner/reporters/artifacts.ts +8 -2
  272. package/src/runner/reporters/braintrust.test.ts +8 -7
  273. package/src/runner/reporters/braintrust.ts +9 -2
  274. package/src/runner/reporters/index.ts +2 -2
  275. package/src/runner/reporters/json.test.ts +162 -0
  276. package/src/runner/reporters/json.ts +35 -8
  277. package/src/runner/reporters/shared.ts +1 -5
  278. package/src/runner/run.test.ts +760 -3
  279. package/src/runner/run.ts +243 -37
  280. package/src/runner/sandbox-prep.ts +3 -42
  281. package/src/runner/timing.ts +158 -0
  282. package/src/runner/types.ts +518 -22
  283. package/src/sandbox/checkpoint.test.ts +55 -0
  284. package/src/sandbox/checkpoint.ts +29 -8
  285. package/src/sandbox/cli-commands.ts +407 -0
  286. package/src/sandbox/docker.ts +115 -16
  287. package/src/sandbox/e2b-agent-template.test.ts +56 -0
  288. package/src/sandbox/e2b-agent-template.ts +94 -0
  289. package/src/sandbox/e2b.ts +74 -9
  290. package/src/sandbox/errors.ts +111 -4
  291. package/src/sandbox/index.ts +2 -0
  292. package/src/sandbox/io-retry.test.ts +58 -0
  293. package/src/sandbox/io-retry.ts +45 -0
  294. package/src/sandbox/keep-registry.test.ts +86 -0
  295. package/src/sandbox/keep-registry.ts +142 -0
  296. package/src/sandbox/keep.ts +178 -0
  297. package/src/sandbox/paths.test.ts +1 -0
  298. package/src/sandbox/paths.ts +19 -8
  299. package/src/sandbox/registry.ts +20 -3
  300. package/src/sandbox/resolve.ts +76 -11
  301. package/src/sandbox/retry.test.ts +70 -0
  302. package/src/sandbox/retry.ts +46 -4
  303. package/src/sandbox/types.ts +44 -6
  304. package/src/sandbox/vercel.ts +43 -20
  305. package/src/scoring/collector.ts +60 -17
  306. package/src/scoring/coverage.ts +95 -0
  307. package/src/scoring/diff.ts +81 -0
  308. package/src/scoring/display.test.ts +121 -0
  309. package/src/scoring/display.ts +133 -0
  310. package/src/scoring/evidence.test.ts +189 -0
  311. package/src/scoring/judge.test.ts +142 -0
  312. package/src/scoring/judge.ts +15 -18
  313. package/src/scoring/scoped.ts +217 -50
  314. package/src/scoring/types.ts +117 -20
  315. package/src/scoring/verdict.ts +16 -4
  316. package/src/shared/aggregate.ts +8 -6
  317. package/src/shared/types.ts +31 -0
  318. package/src/show/compose.ts +50 -67
  319. package/src/show/index.ts +127 -56
  320. package/src/show/render.ts +662 -131
  321. package/src/show/report-host.test.ts +188 -0
  322. package/src/show/report-host.ts +375 -0
  323. package/src/show/show.test.ts +320 -54
  324. package/src/tty-line.ts +8 -26
  325. package/src/util.test.ts +1 -0
  326. package/src/util.ts +41 -0
  327. package/src/view/app/App.test.tsx +69 -0
  328. package/src/view/app/App.tsx +144 -48
  329. package/src/view/app/components/AttemptModal.tsx +423 -11
  330. package/src/view/app/components/CodeView.tsx +41 -14
  331. package/src/view/app/components/CopyControls.tsx +2 -2
  332. package/src/view/app/i18n.ts +37 -17
  333. package/src/view/app/lib/attempt-route.test.ts +1 -0
  334. package/src/view/app/lib/verdict.ts +7 -9
  335. package/src/view/app/main.tsx +13 -8
  336. package/src/view/app/pages/{RunsPage.tsx → AttemptsPage.tsx} +6 -6
  337. package/src/view/app/types.ts +4 -1
  338. package/src/view/artifact-serving.test.ts +2 -1
  339. package/src/view/client-dist/app.css +1 -1
  340. package/src/view/client-dist/app.js +17 -17
  341. package/src/view/data.test.ts +10 -3
  342. package/src/view/data.ts +155 -49
  343. package/src/view/index.ts +56 -41
  344. package/src/view/server.ts +37 -15
  345. package/src/view/shared/types.ts +34 -5
  346. package/src/view/styles.css +227 -0
  347. package/src/view/view-report.test.ts +167 -62
  348. package/dist/report/built-ins/experiment-comparison.d.ts +0 -1
  349. package/dist/report/built-ins/experiment-comparison.js +0 -13
  350. package/dist/report/built-ins/index.d.ts +0 -1
  351. package/dist/report/built-ins/index.js +0 -2
  352. package/dist/report/react/GroupSummary.d.ts +0 -8
  353. package/dist/report/react/GroupSummary.js +0 -8
  354. package/dist/report/react/RunOverview.d.ts +0 -8
  355. package/dist/report/react/RunOverview.js +0 -12
  356. package/docs-site/zh/example/ai-agent-application.mdx +0 -152
  357. package/docs-site/zh/example/claude-code-codex-plugin.mdx +0 -167
  358. package/docs-site/zh/example/claude-code-codex-skill.mdx +0 -152
  359. package/docs-site/zh/example/showcase.mdx +0 -39
  360. package/docs-site/zh/guides/publish-report.mdx +0 -91
  361. package/docs-site/zh/guides/sandbox-providers.mdx +0 -102
  362. package/src/report/built-in-user-parity.test.tsx +0 -640
  363. package/src/report/built-ins/experiment-comparison.tsx +0 -19
  364. package/src/report/built-ins/index.ts +0 -2
  365. package/src/report/react/GroupSummary.tsx +0 -66
  366. package/src/report/react/RunOverview.tsx +0 -109
  367. package/src/runner/reporters/console.ts +0 -70
  368. package/src/runner/reporters/live.test.ts +0 -56
  369. package/src/runner/reporters/live.ts +0 -247
  370. package/src/runner/reporters/quiet.test.ts +0 -66
  371. package/src/runner/reporters/quiet.ts +0 -49
  372. package/src/runner/reporters/table.ts +0 -277
  373. /package/docs-site/zh/{example/tier1-ai-sdk-v7.mdx → examples/integrations/ai-sdk-v7.mdx} +0 -0
  374. /package/docs-site/zh/{example/tier1-claude-sdk.mdx → examples/integrations/claude-sdk.mdx} +0 -0
  375. /package/docs-site/zh/{example/tier1-codex-sdk.mdx → examples/integrations/codex-sdk.mdx} +0 -0
  376. /package/docs-site/zh/{example/tier1-langgraph.mdx → examples/integrations/langgraph.mdx} +0 -0
  377. /package/docs-site/zh/{example/tier1-pi-sdk.mdx → examples/integrations/pi-sdk.mdx} +0 -0
  378. /package/docs-site/zh/{guides → how-to}/fixtures.mdx +0 -0
@@ -1,51 +1,52 @@
1
- // niceeval/report 的公开类型:指标(Metric)、维度(Dimension / flag())与计算函数
2
- // 产物(即组件的 data props)。数据契约照 docs/feature/reports/library.md「数据计算与缓存边界」;
3
- // 这些不是持久化格式,没有 format / schemaVersion 信封,兼容性跟随 npm 版本。
1
+ // niceeval/report 的公开类型:指标(Metric)、维度(Dimension / flag() / runConfig())与
2
+ // 计算函数产物(即组件的 data)。数据契约照 docs/feature/reports/library/ 各分篇;
3
+ // 这些不是持久化格式,没有 format / schemaVersion 信封,兼容性跟随 npm 版本
4
+ // (组件消费 data 时校验结构,不符按完整用户反馈报错并提示版本漂移)。
4
5
 
5
- import type { AttemptHandle, SelectionWarning } from "../results/types.ts";
6
+ import type { AttemptHandle, Scope, ScopeWarning, Snapshot } from "../results/types.ts";
6
7
  import type { AttemptLocator } from "../results/locator.ts";
7
- import type { AssertionResult, Verdict } from "../types.ts";
8
- import type { LocalizedLabel, ReportLocale } from "./locale.ts";
8
+ import type { ExperimentRunInfo, JsonValue, Verdict } from "../types.ts";
9
+ import type { LocalizedText, ReportLocale } from "./locale.ts";
9
10
 
10
- export type { SelectionWarning };
11
+ export type { ScopeWarning };
11
12
  export type { AttemptLocator };
12
- export type { LocalizedLabel, ReportLocale };
13
+ export type { LocalizedText, ReportLocale };
14
+
15
+ /** 所有官方计算函数的第一参:Scope(warnings 随行)或手工挑的快照数组(没有挑选过程,自然无警告)。 */
16
+ export type ReportInput = Scope | readonly Snapshot[];
13
17
 
14
18
  // ───────────────────────── 指标与聚合 ─────────────────────────
15
19
 
16
20
  /** 两级聚合里单级的折叠方式。 */
17
- export type Aggregator = "mean" | "sum" | "min" | "max" | ((values: number[]) => number);
21
+ export type Aggregator = "mean" | "sum" | "min" | "max" | ((values: readonly number[]) => number);
18
22
 
19
23
  /**
20
24
  * 两级聚合:「每格 attempt 数相等」是幻觉(earlyExit 让失败的题天然比通过的题样本多),
21
25
  * 平铺求均值会让分数和重试策略纠缠;所以先题内折叠、再跨题折叠,默认宏平均。
22
26
  */
23
27
  export interface MetricAggregate {
24
- /** 第一级:同一 (eval × 快照) 的多 attempt 一个题级值;默认 "mean"。 */
28
+ /** 第一级:同一 experiment × eval 的多个 attempt 先折成题级值;默认 "mean"。 */
25
29
  perEval?: Aggregator;
26
- /** 第二级:分组内的题级值 格子终值;默认 "mean"。 */
27
- across?: Aggregator;
30
+ /** 第二级:题级值再跨 experiment × eval 折成终值;默认 "mean"。 */
31
+ acrossEvals?: Aggregator;
28
32
  }
29
33
 
30
34
  /**
31
35
  * 指标:纯函数,吃一个 AttemptHandle 吐一个值(null = 此 attempt 测不了这个指标,
32
36
  * 不进聚合;0 = 测了结果是零,照常进),外加名字、两级聚合方式和渲染提示。
33
37
  * 内置指标与自定义指标是同一个类型,没有特权。name 走字面量泛型:列键锚在指标
34
- * 对象上(`row.cells[passRate.name]`),拼错列名编译不过。
38
+ * 对象上(`row.cells[taskPassRate.name]`),拼错列名编译不过。
35
39
  */
36
40
  export interface Metric<Name extends string = string> {
37
41
  /** MetricColumn.key 与列头的来源;同一次计算里重名是错误。 */
38
42
  name: Name;
39
- /**
40
- * 列头;省略时用 name。可以给按 locale 的字典({ en, "zh-CN" }),
41
- * 渲染面按宿主 locale 解析,缺项回退 en(display 是 format 产物,不本地化)。
42
- */
43
- label?: LocalizedLabel;
44
- description?: string;
45
- /** 渲染提示:越高越好还是越低越好(排序方向、轴向、涨跌配色用)。 */
46
- better?: "higher" | "lower";
43
+ /** 列头;省略时用 name。渲染面按 locale 解析,缺项走 LocalizedText 回退规则。 */
44
+ label?: LocalizedText;
45
+ description?: LocalizedText;
47
46
  /** 驱动内置格式化:"%" → 87%、"ms" → 1.2s、"$" → $0.31、其余 → 1.2k 缩写。 */
48
47
  unit?: string;
48
+ /** 渲染提示:越高越好还是越低越好(排序方向、轴向、涨跌配色用)。 */
49
+ better?: "higher" | "lower";
49
50
  /**
50
51
  * 声明式前置:不满足 → null,语义等价于在 value 开头 return null。
51
52
  * 单独设字段是因为这一步最容易忘(忘了它,code-golf 会奖励「写得短的坏代码」)。
@@ -53,49 +54,71 @@ export interface Metric<Name extends string = string> {
53
54
  where?: (attempt: AttemptHandle) => boolean;
54
55
  value(attempt: AttemptHandle): number | null | Promise<number | null>;
55
56
  aggregate?: MetricAggregate;
56
- /** 覆盖 unit 驱动的内置格式化。 */
57
- display?: (value: number) => string;
57
+ /** 覆盖 unit 驱动的内置格式化;只格式化同一个终值,不按 locale 分裂计算口径。 */
58
+ display?: (value: number, locale: ReportLocale) => string;
58
59
  }
59
60
 
60
- // ───────────────────────── 维度 ─────────────────────────
61
+ // ───────────────────────── 维度与数值轴 ─────────────────────────
61
62
 
62
63
  /**
63
- * 维度:attempt 分到哪一组。内置维度就是结果已有的身份字段;自定义维度是一个函数。
64
- * - "evalGroup" = eval id 的第一段:"algebra/quadratic" → "algebra"(考试里的「科目」)
65
- * - "snapshot" = "<experimentId> @ <startedAt>",把两次快照并排成行,与 view 的 Compare 同口径
64
+ * 内置维度就是结果已有的身份字段。
65
+ * - "evalGroup" = eval id 的完整父路径("a/b/c" → "a/b";无 "/" 取完整 id,与可比组同一条派生规则)
66
+ * - "snapshot" = "<experimentId> @ <startedAt>",把两次快照并排成行
66
67
  */
67
- export type Dimension =
68
- | "agent"
69
- | "model"
70
- | "experiment"
71
- | "eval"
72
- | "evalGroup"
73
- | "snapshot"
74
- | { name: string; of: (attempt: AttemptHandle) => string };
68
+ export type BuiltInDimension = "agent" | "model" | "experiment" | "eval" | "evalGroup" | "snapshot";
69
+
70
+ /** 自定义维度:一个函数把 attempt 分到组。 */
71
+ export interface CustomDimension {
72
+ name: string;
73
+ of(attempt: AttemptHandle): string;
74
+ }
75
75
 
76
76
  /**
77
- * flag() 的产物:把 experiment 声明的 flags 当维度(series / rows / columns / points
78
- * 槽,按声明值分组)或轴(MetricLine x 槽,要求数值并驱动刻度)。
79
- * 未声明该 flag 的 experiment 不猜:分组如实归「(unset)」,作轴不画点、注脚报数。
77
+ * flag() / runConfig() 的产物:把 experiment 声明的 flag 或顶层运行配置当分组维度。
78
+ * 读取的 JSON 值可能是任意形状,分组显示键按稳定 JSON 规则生成;缺失值显示内置文案
79
+ * `(missing)`,不同原始值撞出同一显示键时计算报错并要求改用 CustomDimension。
80
80
  */
81
- export interface FlagRef {
82
- readonly kind: "flag";
81
+ export interface DimensionRef {
82
+ readonly kind: "flag" | "runConfig";
83
83
  readonly name: string;
84
- /** 组标签 / 轴标签;函数形态把声明值折成组名(如 `(v) => \`${v} agents\``)。 */
85
- readonly label?: string | ((value: string | number | boolean) => string);
84
+ readonly label?: LocalizedText;
86
85
  readonly unit?: string;
87
86
  }
88
87
 
89
- /** 维度槽的输入:内置/自定义维度,或 experiment 声明的 flag。 */
90
- export type DimensionInput = Dimension | FlagRef;
88
+ /** 维度槽的输入:内置维度、自定义维度,或 flag() / runConfig() 的产物。 */
89
+ export type DimensionInput = BuiltInDimension | CustomDimension | DimensionRef;
90
+
91
+ /** MetricLine 的 x 轴:必须是数值;字符串配置显式映射,组件不猜 low < medium < high。 */
92
+ export interface NumericAxis {
93
+ name: string;
94
+ label?: LocalizedText;
95
+ unit?: string;
96
+ of(attempt: AttemptHandle): number | null;
97
+ }
98
+
99
+ export interface DimensionOptions {
100
+ label?: LocalizedText;
101
+ unit?: string;
102
+ }
91
103
 
92
- // ───────────────────────── 计算产物(组件 data props)─────────────────────────
104
+ export interface NumericAxisOptions extends DimensionOptions {}
105
+
106
+ export interface NumericRunConfigAxisOptions extends NumericAxisOptions {
107
+ /** 字符串配置到数值轴的显式映射;数值配置不需要。 */
108
+ map?: Readonly<Record<string, number>>;
109
+ }
110
+
111
+ /** runConfig() 的可用键:ExperimentRunInfo 字段全集,外加桥接到快照顶层权威字段的 model / agent。 */
112
+ export type RunConfigKey = keyof ExperimentRunInfo | "model" | "agent";
113
+
114
+ // ───────────────────────── 计算产物(组件 data)─────────────────────────
93
115
 
94
116
  export interface MetricColumn {
95
117
  /** = metric.name,与 cells 的键对应。 */
96
118
  key: string;
97
- /** 数据层原样携带 metric.label(可本地化);渲染面用 resolveMetricLabel 按 locale 解析。 */
98
- label: LocalizedLabel;
119
+ /** 数据层原样携带 metric.label(可本地化);渲染面按 locale 解析。 */
120
+ label: LocalizedText;
121
+ description?: LocalizedText;
99
122
  unit?: string;
100
123
  /** 渲染提示:排序方向、轴向、涨跌配色。 */
101
124
  better?: "higher" | "lower";
@@ -104,314 +127,281 @@ export interface MetricColumn {
104
127
  export interface MetricCell {
105
128
  /** 聚合后的值;null = 该组没有任何有效样本。 */
106
129
  value: number | null;
107
- /** 已格式化("87%" / "1.2k lines" / "$0.31"),前端可直接渲染。 */
108
- display: string;
109
- /** 有效 attempt 数(值为 null 的不计入) */
130
+ /**
131
+ * 已格式化的显示值;计算函数为官方生成面覆盖的每个 locale(当前 en、zh-CN)生成,
132
+ * renderer LocalizedText 回退规则选择,其它 locale 回退 en
133
+ */
134
+ display: LocalizedText;
135
+ /** 有效 attempt 数(指标返回非 null 的 attempt)。 */
110
136
  samples: number;
111
- /** 组内 attempt 总数;samples < total = 有 attempt 测不了这个指标。 */
137
+ /** 本格子覆盖的 attempt 总数,包含值为 null attempt */
112
138
  total: number;
113
139
  /**
114
- * 这个格子由哪些 attempt 算出 —— 回到证据的引用。必填(可空数组):
140
+ * 本格子覆盖的全部 attempt(包含指标值为 null 的证据)—— 回到证据的引用。必填(可空数组):
115
141
  * 「每个数字点进去就是证据」是页面的核心承诺,可选字段会让深链静默缺失。
116
142
  */
117
143
  refs: AttemptLocator[];
118
144
  }
119
145
 
120
146
  /**
121
- * 榜单行的元信息:rows: "experiment" 时随行(experiment 行天然有唯一的 agent/model 身份、
122
- * eval 级折叠计票与「这行覆盖了多少题/多少次尝试/最近何时跑的」);其它维度不携带。
123
- * web / text 面在 meta 在场时补 Model / Agent / Verdicts 列,`evals`/`attempts`/
124
- * `lastRunAt` 则渲染成行键下的一行紧凑摘要——与 view 原生榜单同一份信息密度。
125
- * `MetricTable` 只表达维度 × 指标,没有实体下钻——要展开到 experiment 的 Eval 或
126
- * Eval 的 Attempt,用 `ExperimentList` / `EvalList`,这里不再有 `subRows`。
147
+ * 数据形状的字段命名规则(docs/feature/reports/library/metric-views.md「共用数据形状」):
148
+ * 维度名字段 = 产生它的选项名 + `Dimension` 后缀,值是解析后的维度 name;
149
+ * 条目数组一律叫 `rows`(Matrix 的稀疏格子叫 `cells`);条目内的 key / series 是维度值,不带后缀。
127
150
  */
128
- export interface TableRowMeta<K extends string = string> {
129
- agent?: string;
130
- model?: string;
131
- /** eval 级折叠计票(foldEvalVerdict 口径,与 view 榜单同一套):每题折成单一判定后计数。 */
132
- verdicts?: { passed: number; failed: number; errored: number; skipped: number };
133
- /**
134
- * `rows: "experiment"` 专属:这一行覆盖的 eval 数(去重后,summarizeItems 口径,与
135
- * `verdicts` 四项之和一致)。其它行维度(agent/eval/自定义…)没有「这一行是几道题」的
136
- * 独立语义(题本身就是行),不携带这个字段。
137
- */
138
- evals?: number;
139
- /**
140
- * `rows: "experiment"` 专属:这一行覆盖的 attempt 总数(原始计数,含多轮重试)。
141
- * 大于 `evals` 说明存在多轮重试(early-exit 复测 / flaky 重跑);等于 `evals` 说明
142
- * 每题只跑了一轮。同上,只在 `rows: "experiment"` 时语义成立。
143
- */
144
- attempts?: number;
145
- /**
146
- * `rows: "experiment"` 专属:这一行覆盖范围内快照 `startedAt` 的最大值(最近一次运行
147
- * 时间,ISO 8601,字符串比较即可比大小)。组内没有任何 item 时缺席。
148
- */
149
- lastRunAt?: string;
150
- }
151
-
152
- /** 列键 K 来自 columns 元组的字面量 name:拼错列名编译不过,不是运行时 undefined。 */
153
- export interface TableData<K extends string = string> {
154
- /** 行维度名,如 "agent"。 */
155
- dimension: string;
151
+ export interface TableData {
152
+ rowDimension: string;
156
153
  columns: MetricColumn[];
157
- rows: { key: string; cells: Record<K, MetricCell>; meta?: TableRowMeta<K> }[];
154
+ rows: Array<{
155
+ key: string;
156
+ cells: Record<string, MetricCell>;
157
+ }>;
158
158
  }
159
159
 
160
160
  export interface MatrixData {
161
- /** 行维度名,如 "eval"。 */
162
- rows: string;
163
- /** 列维度名,如 "agent"。 */
164
- columns: string;
161
+ rowDimension: string;
162
+ columnDimension: string;
165
163
  metric: MetricColumn;
166
- /** 稀疏:没有样本的格子不出现。 */
167
- cells: { row: string; column: string; cell: MetricCell }[];
168
- }
169
-
170
- export interface ScoreboardData {
171
- /**
172
- * 被打分的维度名,如 "agent"。
173
- * (计算函数的维度槽叫 rows,与 MetricTable.data 统一;数据形状上行数组已占用
174
- * rows 一词,维度名沿用 TableData 的 dimension。)
175
- */
176
- dimension: string;
177
- fullMarks: number;
178
- /** 实际生效的权重表(按匹配顺序:最长前缀在前)—— 成绩单可审计。 */
179
- weights: { prefix: string; weight: number }[];
180
- rows: {
181
- key: string;
182
- /** 已折算到 fullMarks。 */
183
- total: { value: number; display: string };
184
- subjects: {
185
- /** 科目(subjects 维度的值)。 */
186
- key: string;
187
- /** 加权得分。 */
188
- earned: number;
189
- /** 科目分值合计。 */
190
- possible: number;
191
- /** 题数。 */
192
- evals: number;
193
- /** 无任何样本、按 0 计的题数 —— 固定分母的如实注脚。 */
194
- missing: number;
195
- }[];
196
- }[];
164
+ /** 稀疏格子:没有 attempt 的组合不生成格子。 */
165
+ cells: Array<{ row: string; column: string; cell: MetricCell }>;
197
166
  }
198
167
 
199
168
  export interface ScatterData {
200
- /** 点维度名,如 "experiment"。 */
201
- points: string;
202
- /** 系列维度名,如 "agent"。 */
203
- series?: string;
204
- /** better: "lower" → 组件反向画轴,「好」的角落恒在右上。 */
169
+ pointDimension: string;
170
+ seriesDimension?: string;
171
+ /** 轴方向跟随 better:lower 反向渲染(值大在左/下),「更好」恒指向右上;刻度显示真实值。 */
205
172
  x: MetricColumn;
206
173
  y: MetricColumn;
207
- rows: {
208
- /** 点的键,如 "compare/bub-high"。 */
174
+ rows: Array<{
209
175
  key: string;
210
- /** 所属系列,如 "bub"。 */
211
176
  series?: string;
212
177
  x: MetricCell;
213
178
  /** 任一为 null 的点组件不画,注脚如实报数(点仍留在 rows 里,可数)。 */
214
179
  y: MetricCell;
215
- }[];
216
- }
217
-
218
- /** MetricLine 的 x 轴:experiment 声明的 flag,数值驱动刻度。 */
219
- export interface LineAxis {
220
- /** flag 名。 */
221
- key: string;
222
- label: string;
223
- unit?: string;
180
+ }>;
224
181
  }
225
182
 
226
183
  export interface LineData {
227
- x: LineAxis;
228
- /** 系列维度名(flag 或普通维度)。 */
229
- series?: string;
184
+ x: { key: string; label: LocalizedText; unit?: string };
185
+ seriesDimension?: string;
230
186
  y: MetricColumn;
231
- rows: {
232
- /** 点的键(experiment id):每个点 = 一个 experiment 的聚合。 */
187
+ rows: Array<{
188
+ /** 点身份 = (series, x):x 值的稳定十进制字符串,同一 series 内唯一。 */
233
189
  key: string;
234
190
  series?: string;
235
- /** flag 声明值;未声明或非数值 → null,点不画、注脚报数。 */
236
191
  x: number | null;
237
- /** 已格式化的 x("300 ms");x 为 null 时为空串。 */
238
- xDisplay: string;
192
+ xDisplay: LocalizedText;
239
193
  y: MetricCell;
240
- }[];
194
+ }>;
241
195
  }
242
196
 
243
- /**
244
- * 一组 experiment(如自定义报告里同一 `<Section>` 内的全部 experiment)的摘要:
245
- * experiment/eval/attempt 数量、eval 级折叠计票、通过率、总成本、最后运行时间——
246
- * 恢复旧 `GroupSelector` 卡片曾展示的信息密度,但通过率是官方 `MetricCell` 形态,
247
- * 不是裸数字,渲染面不用另外拼格式。
248
- */
249
- export interface GroupSummaryData {
250
- /** 组内 experiment 数(去重后的 experimentId 个数)。 */
251
- experiments: number;
252
- /**
253
- * 组内 eval 数,按完整身份键(experimentId + eval id)去重——多 experiment 的组里
254
- * 两个 experiment 各自的同名 eval(如都叫 "algebra/a")算两道题,不会被误合并成一道。
255
- */
256
- evals: number;
257
- /** 组内 attempt 总数(原始计数,一轮 attempt 一票,不折叠)。 */
258
- attempts: number;
259
- /**
260
- * eval 级折叠计票:同一 eval 的多轮 attempt 先折成一个判定(`foldEvalVerdict`,任一轮
261
- * 通过则通过,否则取最严重的),再计数——与 `TableRowMeta.verdicts`、view 榜单同一口径,
262
- * 不是 attempt 原始票数的直接计票。
263
- */
264
- verdicts: { passed: number; failed: number; errored: number; skipped: number };
265
- /**
266
- * 组的通过率:eval 级折叠计票的 `passed / (passed + failed + errored)`(`skipped` 不进
267
- * 分母)——这是旧 `GroupSelector` 卡片的口径,不是 `OverviewData.totals.passRate` 那种
268
- * `computeCell` 两级聚合(两者服务不同问题:「这组题多少算过」vs「整体质量几分」)。
269
- * 分母为 0(组内没有任何已跑的 eval)时 `value` 为 `null`,不编 0%。
270
- */
271
- passRate: MetricCell;
272
- /** 组内可测成本(`attemptCostUSD`)求和;一次 attempt 都没报成本 = `null`,不编 `0`。 */
273
- totalCostUSD: number | null;
274
- /** 组内快照 `startedAt` 的最大值(字符串比较,ISO 8601 天然可比);组内没有任何 item 时缺席。 */
275
- lastRunAt?: string;
276
- }
277
-
278
- export interface OverviewData {
279
- snapshots: { experimentId: string; agent: string; model?: string; startedAt: string }[];
280
- totals: {
281
- evals: number;
282
- attempts: number;
283
- /**
284
- * 四个 attempt 原始判定计票(一个 attempt 一票),独立于 `passRate`:驱动页头的
285
- * 判定计数展示,不是通过率公式的输入——不要从这四个数现场重算百分比。
286
- */
287
- passed: number;
288
- failed: number;
289
- errored: number;
290
- skipped: number;
291
- /**
292
- * 通过率的唯一官方口径:`computeCell(passRate, items)`,与 `MetricTable.data(...,
293
- * columns: [passRate])` 同一台两级聚合引擎(题内折叠 perEval、跨题折叠 across,默认都是
294
- * mean)——一道题内多个 attempt 部分通过,贡献的是小数份额而不是二元票。`samples`/`total`
295
- * 是两级聚合口径下的 attempt 计数(`total` 含 skipped,`samples` 不含),不等于上面四个
296
- * verdict 计票的任何一个之和。
297
- */
298
- passRate: MetricCell;
299
- /** 任一 attempt 报了成本才有;全缺 = null,不编 0。 */
300
- costUSD: number | null;
301
- durationMs: number;
302
- };
303
- /** Selection 的警告随行(结构化,含渲染好的 message),RunOverview 直接渲染。 */
304
- warnings: SelectionWarning[];
197
+ export interface ScoreboardData {
198
+ rowDimension: string;
199
+ questions: string[];
200
+ fullMarks: number;
201
+ /** 实际生效的权重表(最长前缀在前)—— 成绩单可审计。 */
202
+ weights: Array<{ prefix: string; weight: number }>;
203
+ /** Scope 中存在但不在题集内、被忽略的 eval 数(注脚显示)。 */
204
+ ignoredEvals: number;
205
+ rows: Array<{
206
+ key: string;
207
+ total: {
208
+ /** fullMarks × earned / possible。 */
209
+ value: number;
210
+ display: LocalizedText;
211
+ /** 题集中该行完全没有 attempt 的题数( 0 计,分开计数)。 */
212
+ notRun: number;
213
+ /** 有 attempt 但指标为 null(测不了)的题数(按 0 计,分开计数)。 */
214
+ unscorable: number;
215
+ refs: AttemptLocator[];
216
+ };
217
+ subjects: Array<{
218
+ key: string;
219
+ /** 加权后的 [0, 1] 题目分数之和。 */
220
+ earned: number;
221
+ /** 本分科题目的权重之和。 */
222
+ possible: number;
223
+ questions: number;
224
+ notRun: number;
225
+ unscorable: number;
226
+ display: LocalizedText;
227
+ refs: AttemptLocator[];
228
+ }>;
229
+ }>;
305
230
  }
306
231
 
307
- export interface DeltaData<K extends string = string> {
232
+ export interface DeltaData {
233
+ byDimension: string;
308
234
  columns: MetricColumn[];
309
- rows: {
310
- /** pair 的 label,如 "bub"。 */
235
+ /** FlagPairs 派生形态下的配对域实验数;字面 pairs 不携带(空态文案用)。 */
236
+ experiments?: number;
237
+ rows: Array<{
311
238
  key: string;
312
- /** 基线侧:experiment id 或快照键 "<experimentId> @ <startedAt>"。 */
313
- a: { experimentId: string };
314
- /** 对比侧。 */
315
- b: { experimentId: string };
239
+ /** 作者在 DeltaPair 里声明(或派生规则生成)的 label,原样透传;renderer 据此显示行名。 */
240
+ label: LocalizedText;
241
+ a: { key: string };
242
+ b: { key: string };
316
243
  cells: Record<
317
- K,
244
+ string,
318
245
  {
319
246
  a: MetricCell;
320
247
  b: MetricCell;
321
- /** b.value - a.value;任一侧 null → null,不硬算。 */
248
+ /** b.value - a.value;任一侧缺失则为 null */
322
249
  delta: number | null;
323
- /** 已带符号("+12%" / "-$0.80" / "±0"),涨跌好坏由 better 判定。 */
324
- display: string;
250
+ display: LocalizedText;
251
+ outcome: "improved" | "regressed" | "unchanged" | "unavailable";
325
252
  }
326
253
  >;
327
- }[];
254
+ }>;
255
+ }
256
+
257
+ export interface DeltaPair {
258
+ label: LocalizedText;
259
+ a: string;
260
+ b: string;
261
+ }
262
+
263
+ /** pairsByFlag() 的产物:按一个 flag 机械导出全部 A/B 对;只在 by 为 "experiment" 时成立。 */
264
+ export interface FlagPairs {
265
+ readonly kind: "flagPairs";
266
+ readonly flag: string;
267
+ /** a 侧的 flag 取值;缺省表示「未声明该 flag」的实验作 a。 */
268
+ readonly baseline?: JsonValue;
269
+ }
270
+
271
+ // ───────────────────────── 概览(ScopeSummary / ExperimentComparison)─────────────────────────
272
+
273
+ export interface VerdictTally {
274
+ passed: number;
275
+ failed: number;
276
+ errored: number;
277
+ skipped: number;
278
+ }
279
+
280
+ /**
281
+ * 一个范围的摘要:快照时间窗、experiment / eval / attempt 数、两级判定计票、端到端成功率
282
+ * 和总成本。eval 的身份键是 experimentId + evalId;data 恒携带两级计票,渲染面显示哪一级
283
+ * 由呈现 prop `votes` 决定,不改变 data(docs/feature/reports/library/summaries.md)。
284
+ */
285
+ export interface ScopeSummaryData {
286
+ /** 贡献当前数据的快照时间范围;空范围为 null,不编造当前时间。 */
287
+ range: { earliestStartedAt: string | null; latestStartedAt: string | null };
288
+ experiments: number;
289
+ /** experimentId + evalId 的去重计数,与 evalVerdicts 同分母。 */
290
+ evals: number;
291
+ attempts: number;
292
+ /** 每个 experimentId + evalId 先折成最终 verdict 后计票。 */
293
+ evalVerdicts: VerdictTally;
294
+ /** attempt 原始计票,不折叠。 */
295
+ attemptVerdicts: VerdictTally;
296
+ /** 官方两级 endToEndPassRate,不从任一计票重算。 */
297
+ endToEndPassRate: MetricCell;
298
+ /** costUSD 按 attempt 求和;缺失成本不伪造为 0。 */
299
+ totalCostUSD: MetricCell;
300
+ }
301
+
302
+ /** 一个可比组的数据;三个子块都只消费本组快照,不能含其它父目录的引用。 */
303
+ export interface ExperimentComparisonGroupData {
304
+ /** experiment id 的完整父路径;根目录 experiment 使用完整 id。 */
305
+ key: string;
306
+ summary: ScopeSummaryData;
307
+ scatter: ScatterData;
308
+ experiments: ExperimentListItem[];
309
+ }
310
+
311
+ export interface ExperimentComparisonData {
312
+ groups: ExperimentComparisonGroupData[];
328
313
  }
329
314
 
330
315
  // ───────────────────────── 实体列表(ExperimentList / EvalList / AttemptList)─────────────────────────
331
316
  //
332
317
  // 三个组件按「experiment → experimentId × eval → attempt」逐级下钻,固定展示实体事实,
333
- // 没有列配置(docs/feature/reports/library.md「实体列表」)。每一级都以下一级的 `AttemptListItem[]`
334
- // 收尾——同一个类型既是 `AttemptList` 自己的 items,也是 `ExperimentListEvalRow.attempts` /
335
- // `EvalListItem.attempts` 的元素,报告作者可以直接把这些嵌套数组喂给 `<AttemptList items={...} />`。
318
+ // 没有列配置。每一级都以下一级的 `AttemptListItem[]` 收尾——同一个类型既是 `AttemptList`
319
+ // 自己的 data,也是 `ExperimentListEvalRow.attempts` / `EvalListItem.attempts` 的元素。
336
320
 
337
321
  /**
338
- * `AttemptList` 一项 = 一个 Attempt:身份、判定、断言、error、耗时、成本和 locator。
339
- * `ExperimentList` / `EvalList` 的下钻数组复用同一个类型,不是各自的精简版。
322
+ * `AttemptList` 一项 = 一次 attempt:身份、判定、算好的单行结果摘要与证据引用。
323
+ * 完整 assertions、Judge evidence、diagnostics、cause 与 stack 不进列表 data;
324
+ * 需要完整结构时经 locator 回读取面(resolveLocator → AttemptHandle)。
340
325
  */
341
326
  export interface AttemptListItem {
342
- evalId: string;
343
327
  experimentId: string;
328
+ evalId: string;
344
329
  attempt: number;
345
330
  agent: string;
346
331
  verdict: Verdict;
347
- error?: string;
348
- assertions: AssertionResult[];
332
+ /**
333
+ * 该轮的单行结果摘要,已按 Scoring display 契约折好:failed 取主失败断言摘要,
334
+ * errored 取结构化 error 的一层摘要(phase · code · message),passed / skipped 为 null。
335
+ * 渲染面只做宽度截断,不重算摘要。
336
+ */
337
+ failureSummary: string | null;
338
+ /** 主失败之外还有几条失败断言("+N more failures" 的 N);无失败为 0。 */
339
+ moreFailures: number;
340
+ /** 当前 attempt 的 examScore 与证据引用。 */
341
+ examScore: MetricCell;
349
342
  durationMs: number;
350
- costUSD?: number;
343
+ /** 缺失为 null(测不了),不伪造 0;attempt 级条目的缺失一律用 null,不用省略字段。 */
344
+ costUSD: number | null;
351
345
  locator: AttemptLocator;
352
346
  }
353
347
 
354
348
  /**
355
- * `ExperimentList` 一项里,一个 Eval 的展开行:折叠判定(`foldEvalVerdict`)、失败原因摘要
356
- * (`error` `skipReason` → 未通过的 gate 断言,`reasonFor` 的口径,soft 断言永不进入)、
357
- * 该 Eval 内 attempt 的平均耗时/成本(两级聚合引擎在单一 eval 上退化成组内均值),以及这道题
358
- * 的全部 Attempt(升序,供进一步展开到 `AttemptList`)。
349
+ * `EvalList` 一项 = 一个 `experimentId + evalId`(同一个 Eval 跑在两个 experiment 上是
350
+ * 两条不同结果,不合并)。失败原因只存在于各 AttemptListItem,不在 Eval 父项重复一份。
359
351
  */
352
+ export interface EvalListItem {
353
+ experimentId: string;
354
+ evalId: string;
355
+ /** 任一轮 passed 即 passed,否则 failed > errored > skipped。 */
356
+ verdict: Verdict;
357
+ examScore: MetricCell;
358
+ durationMs: MetricCell;
359
+ costUSD: MetricCell;
360
+ attempts: AttemptListItem[];
361
+ }
362
+
363
+ /** `ExperimentList` 一项里,一个 Eval 的展开行。 */
360
364
  export interface ExperimentListEvalRow {
361
365
  evalId: string;
362
- /** 折叠判定(任一 attempt 通过则通过,否则取最严重的)。 */
363
366
  verdict: Verdict;
364
- reason?: string;
365
- /** 这道题内 attempt 的平均耗时(`computeCell(durationMs, …)`,单一 eval 分组下即均值)。 */
366
- duration: MetricCell;
367
- /** 这道题内 attempt 的平均成本。 */
368
- cost: MetricCell;
369
- /** 这道题的全部 Attempt,按 attempt 序号升序。 */
367
+ durationMs: MetricCell;
368
+ costUSD: MetricCell;
370
369
  attempts: AttemptListItem[];
371
370
  }
372
371
 
373
372
  /**
374
- * `ExperimentList.data(selection)` 的一项 = 一个 experiment:身份(experimentId/agent/model)、
375
- * 声明的 flags、Eval 判定构成(`foldEvalVerdict` 计票,与 view 榜单同一口径)、官方两级聚合
376
- * 汇总指标(passRate/cost/duration/tokens,直接来自 `computeCell`,不现场重算),以及展开到
377
- * 这个 experiment 每道 Eval 的 `evalRows`(按 eval id 升序)。
373
+ * `experimentListData` 的一项 = 一个 experiment:身份(experimentId/agent/model)、
374
+ * 声明的 flags、eval 级最终 verdict 计票、官方两级聚合汇总指标,以及展开到每道 Eval 的
375
+ * `evalRows`(按 eval id 升序)。一行只有一套 agent / model / flags 是输入约束:
376
+ * 同一 experiment 混入不一致可比性配置时计算按完整用户反馈失败。
378
377
  */
379
378
  export interface ExperimentListItem {
380
379
  experimentId: string;
381
380
  agent: string;
382
381
  model?: string;
383
- flags?: Record<string, unknown>;
384
- /** eval 级折叠计票(foldEvalVerdict 口径,与 `TableRowMeta.verdicts`、view 榜单同一套)。 */
385
- verdicts: { passed: number; failed: number; errored: number; skipped: number };
386
- /** 官方两级聚合口径,与 `MetricTable.data(..., columns: [passRate])` 同一台引擎。 */
387
- passRate: MetricCell;
388
- cost: MetricCell;
389
- duration: MetricCell;
382
+ flags?: Record<string, JsonValue>;
383
+ /** eval 级最终 verdict 计票(Result 列的构成)。 */
384
+ evalVerdicts: VerdictTally;
385
+ endToEndPassRate: MetricCell;
386
+ costUSD: MetricCell;
387
+ durationMs: MetricCell;
390
388
  tokens: MetricCell;
391
- /** 这个 experiment 覆盖的 eval 数(去重后,与 `verdicts` 四项之和一致)。 */
389
+ /** 这个 experiment 覆盖的 eval 数(去重后,与 evalVerdicts 四项之和一致)。 */
392
390
  evals: number;
393
391
  /** 这个 experiment 覆盖的 attempt 总数(原始计数,含多轮重试)。 */
394
392
  attempts: number;
395
393
  /** 所含快照中最近的 startedAt。 */
396
394
  lastRunAt: string;
397
- /** 展开到这个 experiment 的 Eval,按 eval id 升序。 */
398
395
  evalRows: ExperimentListEvalRow[];
399
396
  }
400
397
 
401
- /**
402
- * `EvalList.data(selection)` 的一项 = 一个 `experimentId + evalId`(同一个 Eval 跑在两个
403
- * experiment 上是两条不同结果,不合并)。判定、分数(examScore 的两级聚合)、这道题内 attempt
404
- * 的平均耗时/成本,失败原因摘要(与 `ExperimentListEvalRow.reason` 同一口径),外加展开到这道题
405
- * 全部 Attempt 的 `attempts`(按 attempt 序号升序)
406
- */
407
- export interface EvalListItem {
408
- evalId: string;
409
- experimentId: string;
410
- verdict: Verdict;
411
- reason?: string;
412
- /** examScore 的两级聚合;单一 eval 分组下即这道题的题级分数。 */
413
- score: MetricCell;
414
- duration: MetricCell;
415
- cost: MetricCell;
416
- attempts: AttemptListItem[];
398
+ /** 三个实体列表共用的计算选项。 */
399
+ export interface EntityListDataOptions {
400
+ /**
401
+ * 展示层遮蔽:只改写这次组件数据中的自由文本——条目本身与任何嵌套 attempt 条目的
402
+ * `failureSummary`;身份与分类字段(experimentId、evalId、locator、数值指标)不经它。
403
+ * 只作用于这次计算产出的组件数据,不改盘上或任何导出目录里的 artifact;
404
+ * 发布 artifact 的脱敏用 copySnapshots({ redact })。
405
+ */
406
+ redact?: (text: string) => string;
417
407
  }