@tangle-network/agent-bench 2.0.0 → 3.0.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 (215) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +24 -2
  3. package/dist/adapters.d.ts +3 -3
  4. package/dist/adapters.js +3 -5
  5. package/dist/adapters.js.map +1 -1
  6. package/dist/benchmarks/_harness.d.ts +4 -4
  7. package/dist/benchmarks/_harness.js +5 -2
  8. package/dist/benchmarks/_harness.js.map +1 -1
  9. package/dist/benchmarks/aec-bench.d.ts +2 -2
  10. package/dist/benchmarks/aec-bench.js +49 -42
  11. package/dist/benchmarks/aec-bench.js.map +1 -1
  12. package/dist/benchmarks/agentbench.d.ts +2 -2
  13. package/dist/benchmarks/agentbench.js +41 -34
  14. package/dist/benchmarks/agentbench.js.map +1 -1
  15. package/dist/benchmarks/appworld.d.ts +4 -4
  16. package/dist/benchmarks/appworld.js +67 -53
  17. package/dist/benchmarks/appworld.js.map +1 -1
  18. package/dist/benchmarks/bfcl.d.ts +2 -2
  19. package/dist/benchmarks/bfcl.js +52 -44
  20. package/dist/benchmarks/bfcl.js.map +1 -1
  21. package/dist/benchmarks/cad-design.d.ts +2 -2
  22. package/dist/benchmarks/cad-design.js +53 -44
  23. package/dist/benchmarks/cad-design.js.map +1 -1
  24. package/dist/benchmarks/cadbench.d.ts +2 -2
  25. package/dist/benchmarks/cadbench.js +1 -1
  26. package/dist/benchmarks/cadgenbench.d.ts +2 -2
  27. package/dist/benchmarks/cadgenbench.js +1 -1
  28. package/dist/benchmarks/commit0.d.ts +2 -2
  29. package/dist/benchmarks/commit0.js +38 -31
  30. package/dist/benchmarks/commit0.js.map +1 -1
  31. package/dist/benchmarks/crag.d.ts +2 -2
  32. package/dist/benchmarks/crag.js +37 -32
  33. package/dist/benchmarks/crag.js.map +1 -1
  34. package/dist/benchmarks/dabstep.d.ts +2 -2
  35. package/dist/benchmarks/dabstep.js +41 -34
  36. package/dist/benchmarks/dabstep.js.map +1 -1
  37. package/dist/benchmarks/finresearchbench.d.ts +4 -4
  38. package/dist/benchmarks/finresearchbench.js +61 -48
  39. package/dist/benchmarks/finresearchbench.js.map +1 -1
  40. package/dist/benchmarks/finsearchcomp.d.ts +3 -3
  41. package/dist/benchmarks/finsearchcomp.js +54 -43
  42. package/dist/benchmarks/finsearchcomp.js.map +1 -1
  43. package/dist/benchmarks/frames.d.ts +2 -2
  44. package/dist/benchmarks/frames.js +66 -51
  45. package/dist/benchmarks/frames.js.map +1 -1
  46. package/dist/benchmarks/hotpotqa.d.ts +2 -2
  47. package/dist/benchmarks/hotpotqa.js +59 -47
  48. package/dist/benchmarks/hotpotqa.js.map +1 -1
  49. package/dist/benchmarks/humaneval.d.ts +3 -3
  50. package/dist/benchmarks/humaneval.js +39 -35
  51. package/dist/benchmarks/humaneval.js.map +1 -1
  52. package/dist/benchmarks/mcad-bench.d.ts +2 -2
  53. package/dist/benchmarks/mcad-bench.js +68 -56
  54. package/dist/benchmarks/mcad-bench.js.map +1 -1
  55. package/dist/benchmarks/mcad-cq-bench.d.ts +2 -2
  56. package/dist/benchmarks/mcad-cq-bench.js +69 -57
  57. package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
  58. package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
  59. package/dist/benchmarks/mcad-cq-golds.js +1 -1
  60. package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
  61. package/dist/benchmarks/mcad-golds.d.ts +1 -1
  62. package/dist/benchmarks/mcad-golds.js.map +1 -1
  63. package/dist/benchmarks/mind2web.d.ts +3 -3
  64. package/dist/benchmarks/mind2web.js +62 -49
  65. package/dist/benchmarks/mind2web.js.map +1 -1
  66. package/dist/benchmarks/nomiracl.d.ts +2 -2
  67. package/dist/benchmarks/nomiracl.js +43 -36
  68. package/dist/benchmarks/nomiracl.js.map +1 -1
  69. package/dist/benchmarks/open-rag-bench.d.ts +2 -2
  70. package/dist/benchmarks/open-rag-bench.js +37 -32
  71. package/dist/benchmarks/open-rag-bench.js.map +1 -1
  72. package/dist/benchmarks/programbench.d.ts +2 -2
  73. package/dist/benchmarks/programbench.js +28 -23
  74. package/dist/benchmarks/programbench.js.map +1 -1
  75. package/dist/benchmarks/rag-shared.d.ts +2 -2
  76. package/dist/benchmarks/rag-shared.js +15 -13
  77. package/dist/benchmarks/rag-shared.js.map +1 -1
  78. package/dist/benchmarks/ragbench.d.ts +2 -2
  79. package/dist/benchmarks/ragbench.js +34 -29
  80. package/dist/benchmarks/ragbench.js.map +1 -1
  81. package/dist/benchmarks/simpleqa.d.ts +2 -2
  82. package/dist/benchmarks/simpleqa.js +62 -51
  83. package/dist/benchmarks/simpleqa.js.map +1 -1
  84. package/dist/benchmarks/swe-bench.d.ts +4 -4
  85. package/dist/benchmarks/swe-bench.js +47 -41
  86. package/dist/benchmarks/swe-bench.js.map +1 -1
  87. package/dist/benchmarks/t2-ragbench.d.ts +2 -2
  88. package/dist/benchmarks/t2-ragbench.js +37 -32
  89. package/dist/benchmarks/t2-ragbench.js.map +1 -1
  90. package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
  91. package/dist/benchmarks/tau-bench-shared.js +43 -36
  92. package/dist/benchmarks/tau-bench-shared.js.map +1 -1
  93. package/dist/benchmarks/tau2-bench.d.ts +2 -2
  94. package/dist/benchmarks/tau2-bench.js.map +1 -1
  95. package/dist/benchmarks/tau3-banking.d.ts +2 -2
  96. package/dist/benchmarks/tau3-banking.js.map +1 -1
  97. package/dist/benchmarks/terminal-bench.d.ts +2 -2
  98. package/dist/benchmarks/terminal-bench.js +29 -23
  99. package/dist/benchmarks/terminal-bench.js.map +1 -1
  100. package/dist/benchmarks/toollm.d.ts +2 -2
  101. package/dist/benchmarks/toollm.js +40 -34
  102. package/dist/benchmarks/toollm.js.map +1 -1
  103. package/dist/benchmarks/trata-hedge.d.ts +2 -2
  104. package/dist/benchmarks/trata-hedge.js +46 -38
  105. package/dist/benchmarks/trata-hedge.js.map +1 -1
  106. package/dist/benchmarks/types.d.ts +33 -63
  107. package/dist/benchmarks/types.js +36 -1
  108. package/dist/benchmarks/types.js.map +1 -0
  109. package/dist/benchmarks/webarena-verified.d.ts +2 -2
  110. package/dist/benchmarks/webarena-verified.js +29 -24
  111. package/dist/benchmarks/webarena-verified.js.map +1 -1
  112. package/dist/{cadbench-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
  113. package/dist/cadbench-htzAmMaI.js.map +1 -0
  114. package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
  115. package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
  116. package/dist/cli.d.ts +1 -0
  117. package/dist/cli.js +667 -0
  118. package/dist/cli.js.map +1 -0
  119. package/dist/index.d.ts +9 -8
  120. package/dist/index.js +61 -56
  121. package/dist/index.js.map +1 -1
  122. package/package.json +7 -4
  123. package/scripts/enterpriseops-gym-run.sh +82 -0
  124. package/scripts/grade-recorded-evidence.mjs +6 -6
  125. package/scripts/harvey-lab-judge.py +50 -0
  126. package/scripts/harvey-lab-run.sh +53 -0
  127. package/scripts/harvey-lab-sandbox.sh +21 -0
  128. package/scripts/healthbench-professional-run.sh +30 -0
  129. package/scripts/healthbench_professional_run.py +112 -0
  130. package/scripts/mlcr-run.sh +17 -0
  131. package/scripts/mlcr_run.py +133 -0
  132. package/scripts/prbench-run.sh +39 -0
  133. package/scripts/prbench_run.py +53 -0
  134. package/scripts/verify-packed-consumer.mjs +32 -27
  135. package/src/adapters.ts +5 -7
  136. package/src/benchmarks/_harness.test.mts +18 -1
  137. package/src/benchmarks/_harness.ts +12 -7
  138. package/src/benchmarks/aec-bench.test.mts +14 -14
  139. package/src/benchmarks/aec-bench.ts +62 -56
  140. package/src/benchmarks/agent-eval-contract.test.mts +38 -0
  141. package/src/benchmarks/agentbench.ts +44 -37
  142. package/src/benchmarks/appworld.test.mts +7 -7
  143. package/src/benchmarks/appworld.ts +88 -75
  144. package/src/benchmarks/bfcl.ts +60 -53
  145. package/src/benchmarks/cad-design.ts +34 -32
  146. package/src/benchmarks/cadbench.ts +34 -32
  147. package/src/benchmarks/cadgenbench.ts +30 -28
  148. package/src/benchmarks/commit0.test.mts +9 -9
  149. package/src/benchmarks/commit0.ts +50 -43
  150. package/src/benchmarks/crag.ts +45 -40
  151. package/src/benchmarks/dabstep-official.test.mts +8 -8
  152. package/src/benchmarks/dabstep.test.mts +11 -11
  153. package/src/benchmarks/dabstep.ts +47 -40
  154. package/src/benchmarks/external-adapters.test.mts +43 -44
  155. package/src/benchmarks/finresearchbench.ts +57 -47
  156. package/src/benchmarks/finsearchcomp.ts +72 -67
  157. package/src/benchmarks/frames.ts +76 -69
  158. package/src/benchmarks/hotpotqa.ts +69 -64
  159. package/src/benchmarks/humaneval.ts +37 -35
  160. package/src/benchmarks/mcad-bench.test.mts +30 -30
  161. package/src/benchmarks/mcad-bench.ts +66 -60
  162. package/src/benchmarks/mcad-cq-bench.ts +69 -63
  163. package/src/benchmarks/mcad-cq-golds.ts +1 -1
  164. package/src/benchmarks/mcad-cq.test.mts +40 -40
  165. package/src/benchmarks/mcad-golds.ts +1 -1
  166. package/src/benchmarks/mind2web.ts +66 -58
  167. package/src/benchmarks/nomiracl.ts +53 -46
  168. package/src/benchmarks/open-rag-bench.ts +47 -42
  169. package/src/benchmarks/programbench.test.mts +10 -10
  170. package/src/benchmarks/programbench.ts +38 -33
  171. package/src/benchmarks/rag-benchmarks.test.mts +31 -31
  172. package/src/benchmarks/rag-shared.ts +13 -16
  173. package/src/benchmarks/ragbench.ts +44 -39
  174. package/src/benchmarks/simpleqa.ts +78 -73
  175. package/src/benchmarks/swe-bench.test.mts +3 -3
  176. package/src/benchmarks/swe-bench.ts +66 -61
  177. package/src/benchmarks/t2-ragbench.ts +47 -42
  178. package/src/benchmarks/tau-bench-shared.ts +51 -44
  179. package/src/benchmarks/tau-pin.test.mts +1 -1
  180. package/src/benchmarks/tau2-bench.ts +2 -2
  181. package/src/benchmarks/tau3-banking.ts +2 -2
  182. package/src/benchmarks/terminal-bench.test.mts +3 -3
  183. package/src/benchmarks/terminal-bench.ts +41 -36
  184. package/src/benchmarks/toollm.ts +54 -47
  185. package/src/benchmarks/trata-hedge.ts +57 -52
  186. package/src/benchmarks/types.ts +70 -59
  187. package/src/benchmarks/webarena-verified.ts +49 -42
  188. package/src/cli.ts +74 -0
  189. package/src/corpus-replay.mts +9 -9
  190. package/src/examples/benchmark-matrix.mts +13 -10
  191. package/src/gate-cli.mts +5 -5
  192. package/src/gate.test.mts +14 -12
  193. package/src/gate.ts +23 -22
  194. package/src/index.ts +17 -11
  195. package/src/published.test.mts +534 -0
  196. package/src/published.ts +524 -0
  197. package/src/run-benchmarks-cli.mts +2 -2
  198. package/src/run-benchmarks.test.mts +58 -48
  199. package/src/run-benchmarks.ts +64 -57
  200. package/src/swe-bench-env.ts +6 -6
  201. package/src/worker.ts +1 -1
  202. package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
  203. package/dist/benchmarks/enterpriseops-gym.js +0 -236
  204. package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
  205. package/dist/cadbench-Byr5gO1M.js.map +0 -1
  206. package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
  207. package/fixtures/enterpriseops-gym.json +0 -103
  208. package/scripts/enterpriseops_gym_judge.py +0 -281
  209. package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
  210. package/src/benchmarks/enterpriseops-gym.ts +0 -343
  211. package/src/eops-skills/address-every-subtask.md +0 -5
  212. package/src/eops-skills/exact-tools-and-args.md +0 -5
  213. package/src/eops-skills/full-sequence-to-goal.md +0 -5
  214. package/src/eops-skills/ground-every-value.md +0 -5
  215. package/src/eops-skills/honor-the-policies.md +0 -5
@@ -8,23 +8,23 @@
8
8
  * and {response} (the student answer) placeholders. We faithfully REPLICATE the
9
9
  * benchmark's judge — fill the template, run it under the record's system prompt
10
10
  * via the pinned router (temperature 0), and parse the JSON the judge emits. The
11
- * judge returns an `answer_score` field; 1/positive = resolved, else not.
11
+ * judge returns an `answer_score` field; 1/positive = passed, else not.
12
12
  * This matches the FinSearchComp leaderboard (Grok-4-web 68.9%).
13
13
  *
14
14
  * There is NO deterministic Tier-1 path here: the gold answer is prose with
15
15
  * region-specific units, embedded tolerances ("允许1%的误差"), and multi-point
16
16
  * scoring criteria. The benchmark intends its own LLM judge to be the arbiter,
17
17
  * so the judge IS the score — fail loud on unparseable judge output (never
18
- * default to resolved).
18
+ * default to passed).
19
19
  *
20
20
  * SCOPE: T2 (Simple_Historical_Lookup) + T3 (Complex_Historical_Investigation)
21
21
  * are fully self-contained and supported. T1 (Time_Sensitive_Data_Fetching)
22
22
  * needs a live market snapshot / akshare ground truth to fill the judge's
23
- * {ground_truth} slot — it is SKIPPED in loadTasks and flagged in preflight.
23
+ * {ground_truth} slot — it is SKIPPED in loadAll and flagged in preflight.
24
24
  * See {@link T1Seam}.
25
25
  *
26
26
  * Requires for a live run: network access to the GitHub-hosted dataset JSON and
27
- * a TANGLE_API_KEY for the judge. For offline/CI verification, loadTasks falls back
27
+ * a TANGLE_API_KEY for the judge. For offline/CI verification, loadAll falls back
28
28
  * to the committed fixtures (bench/fixtures/finsearchcomp.json) with an explicit
29
29
  * console.warn — never a silent fallback.
30
30
  */
@@ -33,7 +33,7 @@ import { readFile } from 'node:fs/promises'
33
33
  import { join } from 'node:path'
34
34
  import { fileURLToPath } from 'node:url'
35
35
  import { runBenchRouterTurn } from '../router-turn'
36
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
36
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
37
37
 
38
38
  const BENCH_ROOT = fileURLToPath(new URL('../..', import.meta.url))
39
39
  const FIXTURES = join(BENCH_ROOT, 'fixtures', 'finsearchcomp.json')
@@ -64,7 +64,7 @@ const WORKER_CONTRACT = [
64
64
  * live market snapshot the judge consumes via a {ground_truth} template slot;
65
65
  * the adapter does NOT fabricate that snapshot. Wiring T1 means supplying a
66
66
  * resolver that fetches the akshare/market value for the record at judge time
67
- * and filling {ground_truth}. Until then T1 is excluded from loadTasks.
67
+ * and filling {ground_truth}. Until then T1 is excluded from loadAll.
68
68
  */
69
69
  export interface T1Seam {
70
70
  promptId: string
@@ -119,8 +119,7 @@ function recordToTask(rec: FinSearchRecord): BenchTask {
119
119
  }
120
120
  return {
121
121
  id: rec.prompt_id,
122
- split: taskType,
123
- prompt: rec.prompt + WORKER_CONTRACT,
122
+ payload: { prompt: rec.prompt + WORKER_CONTRACT, subset: taskType },
124
123
  metadata: meta as unknown as Record<string, unknown>,
125
124
  }
126
125
  }
@@ -134,7 +133,7 @@ function readMeta(task: BenchTask): FinSearchMeta {
134
133
  typeof md.judgeSystemPrompt !== 'string' ||
135
134
  typeof md.rawPrompt !== 'string'
136
135
  ) {
137
- throw new Error(`FinSearchComp task ${task.id} missing judge metadata — loadTasks did not populate it`)
136
+ throw new Error(`FinSearchComp task ${task.id} missing judge metadata — loadAll did not populate it`)
138
137
  }
139
138
  return md as unknown as FinSearchMeta
140
139
  }
@@ -206,7 +205,7 @@ function parseJudgeOutput(content: string): { resolved: boolean; score: number;
206
205
  }
207
206
 
208
207
  /** Run the record's own judge via the router. Fail loud on transport/parse errors. */
209
- async function runRecordJudge(meta: FinSearchMeta, response: string, router: JudgeRouter): Promise<BenchScore> {
208
+ async function runRecordJudge(meta: FinSearchMeta, response: string, router: JudgeRouter): Promise<BenchEvaluation> {
210
209
  const turn = await runBenchRouterTurn(
211
210
  {
212
211
  routerBaseUrl: router.baseUrl,
@@ -227,15 +226,17 @@ async function runRecordJudge(meta: FinSearchMeta, response: string, router: Jud
227
226
  const content = turn.finalText
228
227
  if (!content) throw new Error('FinSearchComp judge returned no message content')
229
228
  const { resolved, score, raw } = parseJudgeOutput(content)
229
+ const evidence = {
230
+ taskType: meta.taskType,
231
+ region: meta.region,
232
+ answerScore: raw,
233
+ judgeModel: router.model,
234
+ }
230
235
  return {
231
- resolved,
236
+ passed: resolved,
232
237
  score,
233
- detail: JSON.stringify({
234
- taskType: meta.taskType,
235
- region: meta.region,
236
- answerScore: raw,
237
- judgeModel: router.model,
238
- }),
238
+ notes: JSON.stringify(evidence),
239
+ raw: evidence,
239
240
  }
240
241
  }
241
242
 
@@ -243,7 +244,7 @@ function selectRecords(records: FinSearchRecord[], opts: LoadOptions): BenchTask
243
244
  let tasks = records
244
245
  .filter((r) => SUPPORTED_TYPES.has(parseTaskType(r.prompt_id)))
245
246
  .map(recordToTask)
246
- if (opts.split) tasks = tasks.filter((t) => t.split === opts.split)
247
+ if (opts.subset) tasks = tasks.filter((t) => t.payload.subset === opts.subset)
247
248
  if (opts.ids) {
248
249
  const want = new Set(opts.ids)
249
250
  tasks = tasks.filter((t) => want.has(t.id))
@@ -292,45 +293,13 @@ async function fetchDataset(): Promise<FinSearchRecord[]> {
292
293
  return data
293
294
  }
294
295
 
295
- export function createFinsearchcompAdapter(): BenchmarkAdapter {
296
+ export function createFinsearchcompAdapter(): RuntimeBenchmark {
296
297
  const fixturesMode = process.env.FINSEARCHCOMP_FIXTURES === '1'
297
298
 
298
- return {
299
- name: 'finsearchcomp',
299
+ return runtimeBenchmark({
300
+ id: 'finsearchcomp',
300
301
 
301
- async preflight() {
302
- // The per-record LLM judge is the arbiter in both modes — its router
303
- // config must exist or no score can be produced.
304
- judgeRouter()
305
- console.warn(
306
- '[finsearchcomp] T1 (Time_Sensitive_Data_Fetching) is NOT scored: it needs a live ' +
307
- 'market snapshot / akshare ground truth for the judge {ground_truth} slot. ' +
308
- 'loadTasks supports T2 + T3 only; wire T1Seam to add T1.',
309
- )
310
- if (fixturesMode) {
311
- await readFile(FIXTURES, 'utf8').catch((err) => {
312
- throw new Error(
313
- `FINSEARCHCOMP_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`,
314
- )
315
- })
316
- return
317
- }
318
- const res = await fetch(DATASET_URL, { method: 'HEAD' }).catch((err) => {
319
- throw new Error(
320
- `finsearchcomp preflight failed reaching ${DATASET_URL}: ${err instanceof Error ? err.message : err}\n` +
321
- `Fix: ensure network access to raw.githubusercontent.com, or set FINSEARCHCOMP_FIXTURES=1 ` +
322
- `to run against the committed fixtures offline.`,
323
- )
324
- })
325
- if (!res.ok) {
326
- throw new Error(
327
- `finsearchcomp preflight: dataset HEAD ${res.status} for ${DATASET_URL}. ` +
328
- `Set FINSEARCHCOMP_FIXTURES=1 to run against the committed fixtures offline.`,
329
- )
330
- }
331
- },
332
-
333
- async loadTasks(opts: LoadOptions = {}) {
302
+ async loadAll(opts: LoadOptions = {}) {
334
303
  if (fixturesMode) return loadFixtures(opts)
335
304
  let records: FinSearchRecord[]
336
305
  try {
@@ -345,27 +314,63 @@ export function createFinsearchcompAdapter(): BenchmarkAdapter {
345
314
  return selectRecords(records, opts)
346
315
  },
347
316
 
348
- async goldArtifact(task: BenchTask) {
349
- // Gold artifact = the record's response_reference fed back as the student
350
- // answer, so verify-judge proves gold→resolved through the SAME per-record
351
- // judge the real artifact takes. The reference may carry tolerance/criteria
352
- // prose; the judge is built to read the value out of it.
353
- const meta = readMeta(task)
354
- return meta.responseReference
355
- },
356
-
357
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
317
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
358
318
  const meta = readMeta(task)
359
319
  const response = artifact.trim()
360
320
  if (response.length === 0) {
361
321
  // Fail-closed — the benchmark's own judges score an empty answer 0.
322
+ const raw = { taskType: meta.taskType, region: meta.region, reason: 'empty answer' }
362
323
  return {
363
- resolved: false,
324
+ passed: false,
364
325
  score: 0,
365
- detail: JSON.stringify({ taskType: meta.taskType, region: meta.region, reason: 'empty answer' }),
326
+ notes: JSON.stringify(raw),
327
+ raw,
366
328
  }
367
329
  }
368
330
  return runRecordJudge(meta, response, judgeRouter())
369
331
  },
370
- }
332
+
333
+ runtime: {
334
+ async preflight() {
335
+ // The per-record LLM judge is the arbiter in both modes — its router
336
+ // config must exist or no score can be produced.
337
+ judgeRouter()
338
+ console.warn(
339
+ '[finsearchcomp] T1 (Time_Sensitive_Data_Fetching) is NOT scored: it needs a live ' +
340
+ 'market snapshot / akshare ground truth for the judge {ground_truth} slot. ' +
341
+ 'loadAll supports T2 + T3 only; wire T1Seam to add T1.',
342
+ )
343
+ if (fixturesMode) {
344
+ await readFile(FIXTURES, 'utf8').catch((err) => {
345
+ throw new Error(
346
+ `FINSEARCHCOMP_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`,
347
+ )
348
+ })
349
+ return
350
+ }
351
+ const res = await fetch(DATASET_URL, { method: 'HEAD' }).catch((err) => {
352
+ throw new Error(
353
+ `finsearchcomp preflight failed reaching ${DATASET_URL}: ${err instanceof Error ? err.message : err}\n` +
354
+ `Fix: ensure network access to raw.githubusercontent.com, or set FINSEARCHCOMP_FIXTURES=1 ` +
355
+ `to run against the committed fixtures offline.`,
356
+ )
357
+ })
358
+ if (!res.ok) {
359
+ throw new Error(
360
+ `finsearchcomp preflight: dataset HEAD ${res.status} for ${DATASET_URL}. ` +
361
+ `Set FINSEARCHCOMP_FIXTURES=1 to run against the committed fixtures offline.`,
362
+ )
363
+ }
364
+ },
365
+
366
+ async goldArtifact(task: BenchTask) {
367
+ // Gold artifact = the record's response_reference fed back as the student
368
+ // answer, so verify-judge proves gold→passed through the SAME per-record
369
+ // judge the real artifact takes. The reference may carry tolerance/criteria
370
+ // prose; the judge is built to read the value out of it.
371
+ const meta = readMeta(task)
372
+ return meta.responseReference
373
+ },
374
+ },
375
+ })
371
376
  }
@@ -11,9 +11,9 @@
11
11
  * temperature 0), fired ONLY when Tier 1 misses, to absorb the
12
12
  * paraphrase/alias equivalence FRAMES intends to allow.
13
13
  *
14
- * score is binary (resolved ? 1 : 0) — FRAMES has no partial credit. The judge
14
+ * score is binary (passed ? 1 : 0) — FRAMES has no partial credit. The judge
15
15
  * resolves strictly on the Answer value; wiki_links are a SOFT signal surfaced
16
- * in `detail` for the critic, never a hard pass criterion.
16
+ * in `notes` for the critic, never a hard pass criterion.
17
17
  *
18
18
  * Requires for a live run: the bench `.venv` with `datasets` installed and a
19
19
  * JUDGE_MODEL router key. For offline/CI verification set FRAMES_FIXTURES=1 to
@@ -27,7 +27,7 @@ import { fileURLToPath } from 'node:url'
27
27
  import { promisify } from 'node:util'
28
28
  import { runBenchRouterTurn } from '../router-turn'
29
29
  import { FINAL_ANSWER_SENTINEL, parseCitations, parseFinalAnswer } from './rag-shared'
30
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
30
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
31
31
 
32
32
  const execFileAsync = promisify(execFile)
33
33
  const BENCH_ROOT = fileURLToPath(new URL('../..', import.meta.url))
@@ -338,8 +338,7 @@ function rowToTask(row: FramesRow, index: number): BenchTask {
338
338
  }
339
339
  return {
340
340
  id: `frames-${index}`,
341
- split: 'test',
342
- prompt: row.Prompt + WORKER_CONTRACT,
341
+ payload: { prompt: row.Prompt + WORKER_CONTRACT, subset: 'test' },
343
342
  metadata: meta as unknown as Record<string, unknown>,
344
343
  }
345
344
  }
@@ -347,7 +346,7 @@ function rowToTask(row: FramesRow, index: number): BenchTask {
347
346
  function readMeta(task: BenchTask): FramesMeta {
348
347
  const md = task.metadata
349
348
  if (!md || typeof md.gold !== 'string') {
350
- throw new Error(`FRAMES task ${task.id} missing metadata.gold — loadTasks did not populate it`)
349
+ throw new Error(`FRAMES task ${task.id} missing metadata.gold — loadAll did not populate it`)
351
350
  }
352
351
  return md as unknown as FramesMeta
353
352
  }
@@ -365,40 +364,13 @@ async function loadFixtures(opts: LoadOptions): Promise<BenchTask[]> {
365
364
  return tasks
366
365
  }
367
366
 
368
- export function createFramesAdapter(): BenchmarkAdapter {
367
+ export function createFramesAdapter(): RuntimeBenchmark {
369
368
  const fixturesMode = process.env.FRAMES_FIXTURES === '1'
370
369
 
371
- return {
372
- name: 'frames',
373
-
374
- async preflight() {
375
- // Tier-2 judge router config must be present in both modes — the loop's
376
- // citation-coverage stop gate is meaningless without the equivalence judge.
377
- judgeRouter()
378
- if (fixturesMode) {
379
- await readFile(FIXTURES, 'utf8').catch((err) => {
380
- throw new Error(`FRAMES_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`)
381
- })
382
- return
383
- }
384
- try {
385
- await py(
386
- `from datasets import load_dataset
387
- load_dataset(${JSON.stringify(DATASET)}, split='test', revision=${JSON.stringify(DATASET_REVISION)})
388
- print('ok')`,
389
- )
390
- } catch (err) {
391
- const msg = err instanceof Error ? err.message : String(err)
392
- throw new Error(
393
- `frames preflight failed: ${msg}\n` +
394
- `Fix: (1) python3 -m venv bench/.venv && bench/.venv/bin/pip install datasets ; ` +
395
- `(2) ensure network access to Hugging Face for ${DATASET} ; ` +
396
- `or set FRAMES_FIXTURES=1 to run against the committed fixtures offline.`,
397
- )
398
- }
399
- },
370
+ return runtimeBenchmark({
371
+ id: 'frames',
400
372
 
401
- async loadTasks(opts: LoadOptions = {}) {
373
+ async loadAll(opts: LoadOptions = {}) {
402
374
  if (fixturesMode) return loadFixtures(opts)
403
375
  const limit = opts.limit ?? 10
404
376
  const script = `
@@ -427,15 +399,7 @@ print(json.dumps(out))
427
399
  return rows.map((r) => rowToTask(r, r._index))
428
400
  },
429
401
 
430
- async goldArtifact(task: BenchTask) {
431
- // Gold artifact = the worker-contract serialization of the gold Answer, so
432
- // verify-judge proves gold→resolved through the SAME parse path the real
433
- // artifact takes (Tier-1 short-circuits with no model tokens).
434
- const meta = readMeta(task)
435
- return `${FINAL_ANSWER_SENTINEL} ${meta.gold}`
436
- },
437
-
438
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
402
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
439
403
  const meta = readMeta(task)
440
404
  const finalAnswer = parseFinalAnswer(artifact)
441
405
  const citations = parseCitations(artifact)
@@ -443,45 +407,88 @@ print(json.dumps(out))
443
407
 
444
408
  if (finalAnswer.length === 0) {
445
409
  // Fail-closed: distinguish prompt-adherence failure from a wrong answer.
410
+ const raw = {
411
+ tier: 'none',
412
+ reason: 'no parseable answer',
413
+ normalizedGold: normalizeFramesAnswer(meta.gold),
414
+ citationCoverage: coverage,
415
+ }
446
416
  return {
447
- resolved: false,
417
+ passed: false,
448
418
  score: 0,
449
- detail: JSON.stringify({
450
- tier: 'none',
451
- reason: 'no parseable answer',
452
- normalizedGold: normalizeFramesAnswer(meta.gold),
453
- citationCoverage: coverage,
454
- }),
419
+ notes: JSON.stringify(raw),
420
+ raw,
455
421
  }
456
422
  }
457
423
 
458
424
  // Tier 1 — free, deterministic.
459
425
  if (tier1Match(finalAnswer, meta.gold)) {
426
+ const raw = {
427
+ tier: 1,
428
+ normalizedAnswer: normalizeFramesAnswer(finalAnswer),
429
+ normalizedGold: normalizeFramesAnswer(meta.gold),
430
+ citationCoverage: coverage,
431
+ }
460
432
  return {
461
- resolved: true,
433
+ passed: true,
462
434
  score: 1,
463
- detail: JSON.stringify({
464
- tier: 1,
465
- normalizedAnswer: normalizeFramesAnswer(finalAnswer),
466
- normalizedGold: normalizeFramesAnswer(meta.gold),
467
- citationCoverage: coverage,
468
- }),
435
+ notes: JSON.stringify(raw),
436
+ raw,
469
437
  }
470
438
  }
471
439
 
472
440
  // Tier 2 — constrained LLM equivalence gate (fail loud on unparseable output).
473
441
  const verdict = await tier2Judge(meta.rawPrompt, meta.gold, finalAnswer, judgeRouter())
442
+ const raw = {
443
+ tier: 2,
444
+ normalizedAnswer: normalizeFramesAnswer(finalAnswer),
445
+ normalizedGold: normalizeFramesAnswer(meta.gold),
446
+ judgeVerdict: verdict ? 'correct' : 'incorrect',
447
+ citationCoverage: coverage,
448
+ }
474
449
  return {
475
- resolved: verdict,
450
+ passed: verdict,
476
451
  score: verdict ? 1 : 0,
477
- detail: JSON.stringify({
478
- tier: 2,
479
- normalizedAnswer: normalizeFramesAnswer(finalAnswer),
480
- normalizedGold: normalizeFramesAnswer(meta.gold),
481
- judgeVerdict: verdict ? 'correct' : 'incorrect',
482
- citationCoverage: coverage,
483
- }),
452
+ notes: JSON.stringify(raw),
453
+ raw,
484
454
  }
485
455
  },
486
- }
456
+
457
+ runtime: {
458
+ async preflight() {
459
+ // Tier-2 judge router config must be present in both modes — the loop's
460
+ // citation-coverage stop gate is meaningless without the equivalence judge.
461
+ judgeRouter()
462
+ if (fixturesMode) {
463
+ await readFile(FIXTURES, 'utf8').catch((err) => {
464
+ throw new Error(`FRAMES_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`)
465
+ })
466
+ return
467
+ }
468
+ try {
469
+ await py(
470
+ `from datasets import load_dataset
471
+ load_dataset(${JSON.stringify(DATASET)}, split='test', revision=${JSON.stringify(DATASET_REVISION)})
472
+ print('ok')`,
473
+ )
474
+ } catch (err) {
475
+ const msg = err instanceof Error ? err.message : String(err)
476
+ throw new Error(
477
+ `frames preflight failed: ${msg}\n` +
478
+ `Fix: (1) python3 -m venv bench/.venv && bench/.venv/bin/pip install datasets ; ` +
479
+ `(2) ensure network access to Hugging Face for ${DATASET} ; ` +
480
+ `or set FRAMES_FIXTURES=1 to run against the committed fixtures offline.`,
481
+ )
482
+ }
483
+ },
484
+
485
+ async goldArtifact(task: BenchTask) {
486
+ // Gold artifact = the worker-contract serialization of the gold Answer, so
487
+ // verify-judge proves gold→passed through the SAME parse path the real
488
+ // artifact takes (Tier-1 short-circuits with no model tokens).
489
+ const meta = readMeta(task)
490
+ return `${FINAL_ANSWER_SENTINEL} ${meta.gold}`
491
+ },
492
+ },
493
+ })
487
494
  }
@@ -5,8 +5,8 @@
5
5
  * Judge is the official HotpotQA / SQuAD-style metric, FULLY DETERMINISTIC — no
6
6
  * LLM. Both the predicted final answer and the gold are normalized (lowercase,
7
7
  * strip articles a/an/the, strip punctuation, collapse whitespace), then scored
8
- * by exact-match (EM) and token-level F1. resolved = EM OR F1 >= HOTPOTQA_F1_PASS
9
- * (default 0.6); score = the F1 (0..1). detail carries em + f1. This gives the
8
+ * by exact-match (EM) and token-level F1. passed = EM OR F1 >= HOTPOTQA_F1_PASS
9
+ * (default 0.6); score = the F1 (0..1). notes carries em + f1. This gives the
10
10
  * suite a judge that needs no model tokens at all.
11
11
  *
12
12
  * metadata carries the gold answer + supporting_facts (the title/sent_id pairs of
@@ -24,7 +24,7 @@ import { join } from 'node:path'
24
24
  import { fileURLToPath } from 'node:url'
25
25
  import { promisify } from 'node:util'
26
26
  import { FINAL_ANSWER_SENTINEL, parseFinalAnswer } from './rag-shared'
27
- import type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'
27
+ import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
28
28
 
29
29
  const execFileAsync = promisify(execFile)
30
30
  const BENCH_ROOT = fileURLToPath(new URL('../..', import.meta.url))
@@ -154,8 +154,7 @@ function rowToTask(row: HotpotRow): BenchTask {
154
154
  }
155
155
  return {
156
156
  id: `hotpotqa-${row.id}`,
157
- split: DATASET_SPLIT,
158
- prompt: row.question + WORKER_CONTRACT,
157
+ payload: { prompt: row.question + WORKER_CONTRACT, subset: DATASET_SPLIT },
159
158
  metadata: meta as unknown as Record<string, unknown>,
160
159
  }
161
160
  }
@@ -163,7 +162,7 @@ function rowToTask(row: HotpotRow): BenchTask {
163
162
  function readMeta(task: BenchTask): HotpotMeta {
164
163
  const md = task.metadata
165
164
  if (!md || typeof md.gold !== 'string') {
166
- throw new Error(`HotpotQA task ${task.id} missing metadata.gold — loadTasks did not populate it`)
165
+ throw new Error(`HotpotQA task ${task.id} missing metadata.gold — loadAll did not populate it`)
167
166
  }
168
167
  return md as unknown as HotpotMeta
169
168
  }
@@ -183,41 +182,15 @@ async function loadFixtures(opts: LoadOptions): Promise<BenchTask[]> {
183
182
  return tasks
184
183
  }
185
184
 
186
- export function createHotpotqaAdapter(): BenchmarkAdapter {
185
+ export function createHotpotqaAdapter(): RuntimeBenchmark {
187
186
  const fixturesMode = process.env.HOTPOTQA_FIXTURES === '1'
188
187
  // Validate the threshold at construction so a malformed env fails before any run.
189
188
  f1PassThreshold()
190
189
 
191
- return {
192
- name: 'hotpotqa',
193
-
194
- async preflight() {
195
- if (fixturesMode) {
196
- await readFile(FIXTURES, 'utf8').catch((err) => {
197
- throw new Error(
198
- `HOTPOTQA_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`,
199
- )
200
- })
201
- return
202
- }
203
- try {
204
- await py(
205
- `from datasets import load_dataset
206
- load_dataset(${JSON.stringify(DATASET)}, ${JSON.stringify(DATASET_CONFIG)}, split=${JSON.stringify(DATASET_SPLIT)})
207
- print('ok')`,
208
- )
209
- } catch (err) {
210
- const msg = err instanceof Error ? err.message : String(err)
211
- throw new Error(
212
- `hotpotqa preflight failed: ${msg}\n` +
213
- `Fix: (1) python3 -m venv bench/.venv && bench/.venv/bin/pip install datasets ; ` +
214
- `(2) ensure network access to Hugging Face for ${DATASET} (${DATASET_CONFIG}) ; ` +
215
- `or set HOTPOTQA_FIXTURES=1 to run against the committed fixtures offline.`,
216
- )
217
- }
218
- },
190
+ return runtimeBenchmark({
191
+ id: 'hotpotqa',
219
192
 
220
- async loadTasks(opts: LoadOptions = {}) {
193
+ async loadAll(opts: LoadOptions = {}) {
221
194
  if (fixturesMode) return loadFixtures(opts)
222
195
  const limit = opts.limit ?? 10
223
196
  const script = `
@@ -251,29 +224,23 @@ print(json.dumps(out))
251
224
  return rows.map(rowToTask)
252
225
  },
253
226
 
254
- async goldArtifact(task: BenchTask) {
255
- // Gold artifact = the worker-contract serialization of the gold answer, so
256
- // verify-judge proves gold→resolved through the SAME parse path the real
257
- // artifact takes.
258
- const meta = readMeta(task)
259
- return `${FINAL_ANSWER_SENTINEL} ${meta.gold}`
260
- },
261
-
262
- async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
227
+ async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
263
228
  const meta = readMeta(task)
264
229
  const finalAnswer = parseFinalAnswer(artifact)
265
230
 
266
231
  if (finalAnswer.length === 0) {
267
232
  // Fail-closed: distinguish prompt-adherence failure from a wrong answer.
233
+ const raw = {
234
+ reason: 'no parseable answer',
235
+ em: false,
236
+ f1: 0,
237
+ normalizedGold: normalizeHotpotAnswer(meta.gold),
238
+ }
268
239
  return {
269
- resolved: false,
240
+ passed: false,
270
241
  score: 0,
271
- detail: JSON.stringify({
272
- reason: 'no parseable answer',
273
- em: false,
274
- f1: 0,
275
- normalizedGold: normalizeHotpotAnswer(meta.gold),
276
- }),
242
+ notes: JSON.stringify(raw),
243
+ raw,
277
244
  }
278
245
  }
279
246
 
@@ -281,20 +248,58 @@ print(json.dumps(out))
281
248
  const f1 = hotpotTokenF1(finalAnswer, meta.gold)
282
249
  const threshold = f1PassThreshold()
283
250
  const resolved = em || f1 >= threshold
251
+ const raw = {
252
+ em,
253
+ f1,
254
+ threshold,
255
+ normalizedAnswer: normalizeHotpotAnswer(finalAnswer),
256
+ normalizedGold: normalizeHotpotAnswer(meta.gold),
257
+ type: meta.type,
258
+ level: meta.level,
259
+ supportingFacts: meta.supportingFacts,
260
+ }
284
261
  return {
285
- resolved,
262
+ passed: resolved,
286
263
  score: f1,
287
- detail: JSON.stringify({
288
- em,
289
- f1,
290
- threshold,
291
- normalizedAnswer: normalizeHotpotAnswer(finalAnswer),
292
- normalizedGold: normalizeHotpotAnswer(meta.gold),
293
- type: meta.type,
294
- level: meta.level,
295
- supportingFacts: meta.supportingFacts,
296
- }),
264
+ notes: JSON.stringify(raw),
265
+ raw,
297
266
  }
298
267
  },
299
- }
268
+
269
+ runtime: {
270
+ async preflight() {
271
+ if (fixturesMode) {
272
+ await readFile(FIXTURES, 'utf8').catch((err) => {
273
+ throw new Error(
274
+ `HOTPOTQA_FIXTURES=1 but ${FIXTURES} unreadable: ${err instanceof Error ? err.message : err}`,
275
+ )
276
+ })
277
+ return
278
+ }
279
+ try {
280
+ await py(
281
+ `from datasets import load_dataset
282
+ load_dataset(${JSON.stringify(DATASET)}, ${JSON.stringify(DATASET_CONFIG)}, split=${JSON.stringify(DATASET_SPLIT)})
283
+ print('ok')`,
284
+ )
285
+ } catch (err) {
286
+ const msg = err instanceof Error ? err.message : String(err)
287
+ throw new Error(
288
+ `hotpotqa preflight failed: ${msg}\n` +
289
+ `Fix: (1) python3 -m venv bench/.venv && bench/.venv/bin/pip install datasets ; ` +
290
+ `(2) ensure network access to Hugging Face for ${DATASET} (${DATASET_CONFIG}) ; ` +
291
+ `or set HOTPOTQA_FIXTURES=1 to run against the committed fixtures offline.`,
292
+ )
293
+ }
294
+ },
295
+
296
+ async goldArtifact(task: BenchTask) {
297
+ // Gold artifact = the worker-contract serialization of the gold answer, so
298
+ // verify-judge proves gold→passed through the SAME parse path the real
299
+ // artifact takes.
300
+ const meta = readMeta(task)
301
+ return `${FINAL_ANSWER_SENTINEL} ${meta.gold}`
302
+ },
303
+ },
304
+ })
300
305
  }