@tangle-network/agent-bench 0.14.4 → 1.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 (187) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +2 -3
  3. package/dist/adapters.d.ts +2 -5
  4. package/dist/adapters.js +3 -4
  5. package/dist/benchmarks/_harness.d.ts +17 -20
  6. package/dist/benchmarks/_harness.js +4 -4
  7. package/dist/benchmarks/_harness.js.map +1 -1
  8. package/dist/benchmarks/aec-bench.d.ts +1 -4
  9. package/dist/benchmarks/aec-bench.js +1 -2
  10. package/dist/benchmarks/agentbench.d.ts +2 -5
  11. package/dist/benchmarks/agentbench.js +1 -2
  12. package/dist/benchmarks/appworld.d.ts +8 -10
  13. package/dist/benchmarks/appworld.js +23 -23
  14. package/dist/benchmarks/appworld.js.map +1 -1
  15. package/dist/benchmarks/bfcl.d.ts +2 -5
  16. package/dist/benchmarks/bfcl.js +1 -2
  17. package/dist/benchmarks/cad-design.d.ts +2 -5
  18. package/dist/benchmarks/cad-design.js +2 -3
  19. package/dist/benchmarks/cad-design.js.map +1 -1
  20. package/dist/benchmarks/cadbench.d.ts +1 -4
  21. package/dist/benchmarks/cadbench.js +1 -2
  22. package/dist/benchmarks/cadgenbench.d.ts +1 -4
  23. package/dist/benchmarks/cadgenbench.js +1 -2
  24. package/dist/benchmarks/commit0.d.ts +2 -5
  25. package/dist/benchmarks/commit0.js +1 -2
  26. package/dist/benchmarks/crag.d.ts +1 -4
  27. package/dist/benchmarks/crag.js +3 -3
  28. package/dist/benchmarks/crag.js.map +1 -1
  29. package/dist/benchmarks/dabstep.d.ts +2 -5
  30. package/dist/benchmarks/dabstep.js +2 -3
  31. package/dist/benchmarks/dabstep.js.map +1 -1
  32. package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
  33. package/dist/benchmarks/enterpriseops-gym.js +1 -2
  34. package/dist/benchmarks/finresearchbench.d.ts +2 -5
  35. package/dist/benchmarks/finresearchbench.js +2 -3
  36. package/dist/benchmarks/finsearchcomp.d.ts +2 -5
  37. package/dist/benchmarks/finsearchcomp.js +4 -4
  38. package/dist/benchmarks/finsearchcomp.js.map +1 -1
  39. package/dist/benchmarks/frames.d.ts +3 -19
  40. package/dist/benchmarks/frames.js +13 -39
  41. package/dist/benchmarks/frames.js.map +1 -1
  42. package/dist/benchmarks/hotpotqa.d.ts +4 -14
  43. package/dist/benchmarks/hotpotqa.js +12 -32
  44. package/dist/benchmarks/hotpotqa.js.map +1 -1
  45. package/dist/benchmarks/humaneval.d.ts +9 -12
  46. package/dist/benchmarks/humaneval.js +2 -3
  47. package/dist/benchmarks/humaneval.js.map +1 -1
  48. package/dist/benchmarks/mcad-bench.d.ts +13 -16
  49. package/dist/benchmarks/mcad-bench.js +2 -3
  50. package/dist/benchmarks/mcad-bench.js.map +1 -1
  51. package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
  52. package/dist/benchmarks/mcad-cq-bench.js +2 -3
  53. package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
  54. package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
  55. package/dist/benchmarks/mcad-cq-golds.js +1 -2
  56. package/dist/benchmarks/mcad-golds.d.ts +1 -4
  57. package/dist/benchmarks/mcad-golds.js +0 -1
  58. package/dist/benchmarks/mcad-tasks.d.ts +5 -8
  59. package/dist/benchmarks/mcad-tasks.js +7 -8
  60. package/dist/benchmarks/mcad-tasks.js.map +1 -1
  61. package/dist/benchmarks/mind2web.d.ts +3 -5
  62. package/dist/benchmarks/mind2web.js +2 -3
  63. package/dist/benchmarks/mind2web.js.map +1 -1
  64. package/dist/benchmarks/nomiracl.d.ts +1 -4
  65. package/dist/benchmarks/nomiracl.js +1 -2
  66. package/dist/benchmarks/open-rag-bench.d.ts +1 -4
  67. package/dist/benchmarks/open-rag-bench.js +3 -3
  68. package/dist/benchmarks/open-rag-bench.js.map +1 -1
  69. package/dist/benchmarks/programbench.d.ts +2 -5
  70. package/dist/benchmarks/programbench.js +1 -2
  71. package/dist/benchmarks/rag-shared.d.ts +30 -22
  72. package/dist/benchmarks/rag-shared.js +8 -2
  73. package/dist/benchmarks/rag-shared.js.map +1 -1
  74. package/dist/benchmarks/ragbench.d.ts +1 -4
  75. package/dist/benchmarks/ragbench.js +3 -3
  76. package/dist/benchmarks/ragbench.js.map +1 -1
  77. package/dist/benchmarks/simpleqa.d.ts +2 -18
  78. package/dist/benchmarks/simpleqa.js +5 -31
  79. package/dist/benchmarks/simpleqa.js.map +1 -1
  80. package/dist/benchmarks/swe-bench.d.ts +7 -10
  81. package/dist/benchmarks/swe-bench.js +4 -4
  82. package/dist/benchmarks/swe-bench.js.map +1 -1
  83. package/dist/benchmarks/t2-ragbench.d.ts +1 -4
  84. package/dist/benchmarks/t2-ragbench.js +3 -3
  85. package/dist/benchmarks/t2-ragbench.js.map +1 -1
  86. package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
  87. package/dist/benchmarks/tau-bench-shared.js +4 -4
  88. package/dist/benchmarks/tau-bench-shared.js.map +1 -1
  89. package/dist/benchmarks/tau2-bench.d.ts +2 -5
  90. package/dist/benchmarks/tau2-bench.js +1 -2
  91. package/dist/benchmarks/tau3-banking.d.ts +1 -4
  92. package/dist/benchmarks/tau3-banking.js +1 -2
  93. package/dist/benchmarks/terminal-bench.d.ts +1 -4
  94. package/dist/benchmarks/terminal-bench.js +4 -4
  95. package/dist/benchmarks/terminal-bench.js.map +1 -1
  96. package/dist/benchmarks/toollm.d.ts +2 -5
  97. package/dist/benchmarks/toollm.js +1 -2
  98. package/dist/benchmarks/trata-hedge.d.ts +1 -4
  99. package/dist/benchmarks/trata-hedge.js +2 -3
  100. package/dist/benchmarks/types.d.ts +6 -9
  101. package/dist/benchmarks/webarena-verified.d.ts +2 -5
  102. package/dist/benchmarks/webarena-verified.js +1 -2
  103. package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
  104. package/dist/cadbench-DhAndllg.js.map +1 -0
  105. package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
  106. package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
  107. package/dist/index.d.ts +8 -18
  108. package/dist/index.js +16 -24
  109. package/dist/index.js.map +1 -1
  110. package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
  111. package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
  112. package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
  113. package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
  114. package/package.json +10 -10
  115. package/pier_agents/tangle_candidate.py +15 -23
  116. package/scripts/run-package-tests.mjs +8 -15
  117. package/src/atom-mcp-e2e.mts +2 -2
  118. package/src/benchmarks/frames.ts +10 -44
  119. package/src/benchmarks/hotpotqa.ts +9 -29
  120. package/src/benchmarks/rag-shared.ts +12 -0
  121. package/src/benchmarks/simpleqa.ts +2 -36
  122. package/src/commit0-prereqs.sh +0 -0
  123. package/src/corpus-replay.mts +8 -8
  124. package/src/corpus-report.mts +21 -21
  125. package/src/corpus.test.mts +5 -5
  126. package/src/corpus.ts +16 -16
  127. package/src/directives.ts +0 -38
  128. package/src/examples/lean-verify.ts +1 -1
  129. package/src/gate.ts +7 -7
  130. package/src/generate-eval/certify.ts +2 -2
  131. package/src/index.ts +1 -0
  132. package/src/refine-loop.ts +5 -5
  133. package/src/resolve-client.ts +1 -1
  134. package/src/router-turn.ts +3 -11
  135. package/src/run-pool.ts +1 -1
  136. package/src/runtime-hook-recorder.ts +2 -2
  137. package/src/search-bench/tasks.ts +1 -1
  138. package/src/selector.test.mts +13 -13
  139. package/src/selector.ts +19 -19
  140. package/src/swe-bench-env.ts +4 -12
  141. package/src/swe-jail.ts +5 -156
  142. package/src/swe-structural-judge-policy.ts +3 -3
  143. package/src/swe-structural-policy.ts +3 -3
  144. package/src/swe-structural-provenance.ts +4 -4
  145. package/src/terminal-compare.ts +10 -10
  146. package/src/worker-blender.ts +2 -106
  147. package/src/worker-build123d.ts +2 -81
  148. package/tb_agents/opencode_router_agent.py +1 -1
  149. package/dist/cadbench-BRF-59Mt.js.map +0 -1
  150. package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
  151. package/dist/router-turn-uTYO6KQ1.js.map +0 -1
  152. package/scripts/cadbench_prepare.py +0 -22
  153. package/scripts/cadgenbench_hard_parts.py +0 -48
  154. package/scripts/clbench_codebase_judge.py +0 -73
  155. package/scripts/render-gate-chart.mjs +0 -176
  156. package/scripts/trata-hedge/README.md +0 -57
  157. package/scripts/trata-hedge/run.sh +0 -64
  158. package/src/cloud-loop.mts +0 -156
  159. package/src/coordination-mcp-container-reach.mts +0 -182
  160. package/src/fleet.mts +0 -143
  161. package/src/hev-structural.mts +0 -697
  162. package/src/humaneval-gate.mts +0 -220
  163. package/src/mbpp-structural.mts +0 -676
  164. package/src/mcp-mount-probe.mts +0 -141
  165. package/src/profiles.ts +0 -128
  166. package/src/research-gate.mts +0 -132
  167. package/src/research-shot.ts +0 -144
  168. package/src/router-executor.ts +0 -51
  169. package/src/sandbox-run.ts +0 -108
  170. package/src/search-bench/bridge.ts +0 -182
  171. package/src/search-bench/export.mts +0 -0
  172. package/src/search-bench/parametric-check.mts +0 -78
  173. package/src/search-bench/profiles.ts +0 -113
  174. package/src/search-bench/run.mts +0 -286
  175. package/src/search-bench/tasks-fresh.ts +0 -688
  176. package/src/smoke-structural-rollout.mts +0 -415
  177. package/src/stats.mts +0 -90
  178. package/src/swe-code-improve.mts +0 -306
  179. package/src/swe-improve.mts +0 -284
  180. package/src/swe-structural.mts +0 -707
  181. package/src/tb-container-executor.mts +0 -266
  182. package/src/tb-container-executor.test.mts +0 -134
  183. package/src/tb-supervisor-sidecar.mts +0 -208
  184. package/src/trata-gepa.mts +0 -381
  185. package/src/trata-hedge-solve.mts +0 -81
  186. package/tb_agents/opencode_refine_agent.py +0 -117
  187. package/tb_agents/opencode_supervisor_agent.py +0 -239
@@ -2,7 +2,7 @@
2
2
  * Cross-benchmark corpus analysis instrument (docs/learning-flywheel.md - the
3
3
  * "corpus" + "measurement" layers).
4
4
  *
5
- * The corpus (one JSONL RunRecord per condition-run) is the flywheel's only durable
5
+ * The corpus (one JSONL BenchRunRecord per condition-run) is the flywheel's only durable
6
6
  * asset. This reads it back and reports, GROUPED BY benchmark x condition, the
7
7
  * numbers the doc says must hold before any rung is "earned":
8
8
  *
@@ -36,7 +36,7 @@
36
36
  import { readFile, stat } from 'node:fs/promises'
37
37
  import { glob } from 'node:fs/promises'
38
38
  import { resolve } from 'node:path'
39
- import type { RunRecord, AttemptRecord } from './corpus.ts'
39
+ import type { BenchRunRecord, AttemptRecord } from './corpus.ts'
40
40
  import { benjaminiHochberg } from '@tangle-network/agent-eval'
41
41
 
42
42
  const DEFAULT_CORPUS = resolve(import.meta.dirname, '..', 'corpus', 'finsearch.jsonl')
@@ -77,9 +77,9 @@ async function resolveCorpusFiles(args: string[]): Promise<string[]> {
77
77
 
78
78
  /** Parse one JSONL file into RunRecords. Throws on a malformed line - corrupt fuel
79
79
  * must surface, never be silently skipped. */
80
- async function loadFile(file: string): Promise<RunRecord[]> {
80
+ async function loadFile(file: string): Promise<BenchRunRecord[]> {
81
81
  const text = await readFile(file, 'utf8')
82
- const out: RunRecord[] = []
82
+ const out: BenchRunRecord[] = []
83
83
  const lines = text.split('\n')
84
84
  for (let i = 0; i < lines.length; i++) {
85
85
  const line = lines[i]
@@ -90,11 +90,11 @@ async function loadFile(file: string): Promise<RunRecord[]> {
90
90
  } catch (err) {
91
91
  throw new Error(`malformed JSONL at ${file}:${i + 1}: ${(err as Error).message}`)
92
92
  }
93
- const r = rec as Partial<RunRecord>
93
+ const r = rec as Partial<BenchRunRecord>
94
94
  if (typeof r.benchmark !== 'string' || typeof r.instanceId !== 'string' || typeof r.condition !== 'string') {
95
- throw new Error(`not a RunRecord at ${file}:${i + 1} (missing benchmark/instanceId/condition)`)
95
+ throw new Error(`not a BenchRunRecord at ${file}:${i + 1} (missing benchmark/instanceId/condition)`)
96
96
  }
97
- out.push(rec as RunRecord)
97
+ out.push(rec as BenchRunRecord)
98
98
  }
99
99
  return out
100
100
  }
@@ -107,8 +107,8 @@ async function loadFile(file: string): Promise<RunRecord[]> {
107
107
  * emitted); the clean-trace cost axis below uses that same latest record so every
108
108
  * reported number comes from one real run. Returns the kept records + how many were
109
109
  * superseded (reported in caveats). */
110
- function dedupeLatest(records: RunRecord[]): { kept: RunRecord[]; superseded: number } {
111
- const byKey = new Map<string, RunRecord>()
110
+ function dedupeLatest(records: BenchRunRecord[]): { kept: BenchRunRecord[]; superseded: number } {
111
+ const byKey = new Map<string, BenchRunRecord>()
112
112
  let superseded = 0
113
113
  for (const r of records) {
114
114
  const key = `${r.benchmark} ${r.instanceId} ${r.condition}`
@@ -160,7 +160,7 @@ function countMeasured(attempts: AttemptRecord[], pick: (a: AttemptRecord) => nu
160
160
  return attempts.reduce((c, a) => c + (typeof pick(a) === 'number' ? 1 : 0), 0)
161
161
  }
162
162
 
163
- function cleanTrace(records: RunRecord[]): CleanTrace {
163
+ function cleanTrace(records: BenchRunRecord[]): CleanTrace {
164
164
  const n = records.length
165
165
  // Tokens are measured as a PAIR (in+out) or not at all — an attempt counts as
166
166
  // measured only when BOTH are present, and the sum includes only those (a
@@ -343,7 +343,7 @@ async function main(): Promise<void> {
343
343
  if (files.length === 0) {
344
344
  throw new Error('no corpus files resolved from the given paths')
345
345
  }
346
- const all: RunRecord[] = []
346
+ const all: BenchRunRecord[] = []
347
347
  for (const f of files) all.push(...(await loadFile(f)))
348
348
  if (all.length === 0) {
349
349
  throw new Error(`corpus is empty (0 RunRecords across ${files.length} file(s)): ${files.join(', ')}`)
@@ -356,7 +356,7 @@ async function main(): Promise<void> {
356
356
  console.log(` bootstrap B=${BOOTSTRAP_N} (paired resample of shared instanceIds)`)
357
357
 
358
358
  // Group by benchmark, then condition.
359
- const benchmarks = new Map<string, RunRecord[]>()
359
+ const benchmarks = new Map<string, BenchRunRecord[]>()
360
360
  for (const r of kept) {
361
361
  const arr = benchmarks.get(r.benchmark) ?? []
362
362
  arr.push(r)
@@ -369,14 +369,14 @@ async function main(): Promise<void> {
369
369
  const tests: TestEntry[] = []
370
370
 
371
371
  for (const benchmark of [...benchmarks.keys()].sort()) {
372
- const benchRecords = benchmarks.get(benchmark) as RunRecord[]
372
+ const benchRecords = benchmarks.get(benchmark) as BenchRunRecord[]
373
373
  console.log(`\n== benchmark: ${benchmark} ==`)
374
374
 
375
375
  // Partition into clean (analyzed) vs infra-errored (excluded but counted).
376
376
  const clean = benchRecords.filter((r) => r.infraError !== true)
377
377
  const erroredCount = benchRecords.length - clean.length
378
378
 
379
- const byCondition = new Map<string, RunRecord[]>()
379
+ const byCondition = new Map<string, BenchRunRecord[]>()
380
380
  for (const r of clean) {
381
381
  const arr = byCondition.get(r.condition) ?? []
382
382
  arr.push(r)
@@ -393,7 +393,7 @@ async function main(): Promise<void> {
393
393
  // (1) + (4): per-condition rates and clean-trace cost.
394
394
  console.log(' per-condition (resolve / blind rate * clean-trace cost):')
395
395
  for (const condition of conditions) {
396
- const recs = byCondition.get(condition) as RunRecord[]
396
+ const recs = byCondition.get(condition) as BenchRunRecord[]
397
397
  const n = recs.length
398
398
  const resolveRate = recs.filter((r) => r.resolved === true).length / n
399
399
  const blindRate = recs.filter((r) => r.blindResolved === true).length / n
@@ -408,12 +408,12 @@ async function main(): Promise<void> {
408
408
 
409
409
  // (2) + (3): the ablation - paired lifts with bootstrap CIs.
410
410
  // Outcome maps keyed by instanceId, per condition.
411
- const resolvedById = (recs: RunRecord[]) => {
411
+ const resolvedById = (recs: BenchRunRecord[]) => {
412
412
  const m = new Map<string, number>()
413
413
  for (const r of recs) m.set(r.instanceId, r.resolved === true ? 1 : 0)
414
414
  return m
415
415
  }
416
- const blindById = (recs: RunRecord[]) => {
416
+ const blindById = (recs: BenchRunRecord[]) => {
417
417
  const m = new Map<string, number>()
418
418
  for (const r of recs) m.set(r.instanceId, r.blindResolved === true ? 1 : 0)
419
419
  return m
@@ -431,7 +431,7 @@ async function main(): Promise<void> {
431
431
  console.log(' ablation: (no random@k condition - cannot isolate the compute control; lifts unmeasurable)')
432
432
  }
433
433
  for (const rc of randomConditions) {
434
- const recs = byCondition.get(rc) as RunRecord[]
434
+ const recs = byCondition.get(rc) as BenchRunRecord[]
435
435
  const lift = pairedLift(blindById(recs), resolvedById(recs))
436
436
  if (lift) tests.push({ benchmark, label: `more-compute (${rc} - blind)`, family: 'more-compute', lift })
437
437
  }
@@ -447,15 +447,15 @@ async function main(): Promise<void> {
447
447
  console.log(` steering (${refc} - random?) - no matching random@k condition`)
448
448
  continue
449
449
  }
450
- const baseline = resolvedById(byCondition.get(matchRandom) as RunRecord[])
451
- const treatment = resolvedById(byCondition.get(refc) as RunRecord[])
450
+ const baseline = resolvedById(byCondition.get(matchRandom) as BenchRunRecord[])
451
+ const treatment = resolvedById(byCondition.get(refc) as BenchRunRecord[])
452
452
  const lift = pairedLift(baseline, treatment)
453
453
  if (lift) tests.push({ benchmark, label: `steering (${refc} - ${matchRandom})`, family: 'steering', lift })
454
454
  }
455
455
 
456
456
  // (5) honest caveats for this benchmark.
457
457
  const totalN = clean.length
458
- const minCondN = conditions.length === 0 ? 0 : Math.min(...conditions.map((c) => (byCondition.get(c) as RunRecord[]).length))
458
+ const minCondN = conditions.length === 0 ? 0 : Math.min(...conditions.map((c) => (byCondition.get(c) as BenchRunRecord[]).length))
459
459
  console.log(' caveats:')
460
460
  console.log(` * clean records: ${totalN} across ${conditions.length} condition(s); smallest condition n=${minCondN}`)
461
461
  console.log(` * infra-errored excluded: ${erroredCount}`)
@@ -5,7 +5,7 @@ import {
5
5
  benchRecordToCorpusRecords,
6
6
  buildRunRecord,
7
7
  buildRunRecordFromAttempts,
8
- type RunRecord,
8
+ type BenchRunRecord,
9
9
  } from './corpus'
10
10
  import { createRuntimeHookRecorder } from './runtime-hook-recorder'
11
11
 
@@ -23,12 +23,12 @@ const measuredAttempt = (round: number, output: string, valid: boolean): Attempt
23
23
  eventTypes: { llm_call: 1, tool_call: 1 },
24
24
  })
25
25
 
26
- const baseRec = (attempts: AttemptRecord[], over: Partial<RunRecord> = {}): RunRecord => ({
26
+ const baseRec = (attempts: AttemptRecord[], over: Partial<BenchRunRecord> = {}): BenchRunRecord => ({
27
27
  ts: '2026-06-03T00:00:00.000Z',
28
28
  benchmark: 'finsearchcomp',
29
29
  instanceId: 'i1',
30
30
  condition: 'random@3',
31
- // canonical RunRecord requires a snapshot-pinned model; bench writes bare
31
+ // canonical BenchRunRecord requires a snapshot-pinned model; bench writes bare
32
32
  // aliases, so the happy path supplies the resolved snapshot via opts.model.
33
33
  model: 'gpt-5',
34
34
  blindResolved: attempts[0]?.valid === true,
@@ -97,7 +97,7 @@ const baseRec = (attempts: AttemptRecord[], over: Partial<RunRecord> = {}): RunR
97
97
  assert.equal(unmappable.length, 0, 'all measured attempts map')
98
98
  assert.equal(records.length, 2, 'one record per attempt')
99
99
  for (const r of records) {
100
- assert.ok(isRunRecord(r), 'each is a valid canonical RunRecord')
100
+ assert.ok(isRunRecord(r), 'each is a valid canonical BenchRunRecord')
101
101
  }
102
102
  const [r0, r1] = records
103
103
  assert.equal(r0?.candidateId, 'random@3', 'candidateId = condition (the gate-pairing arm)')
@@ -151,7 +151,7 @@ const baseRec = (attempts: AttemptRecord[], over: Partial<RunRecord> = {}): RunR
151
151
  )
152
152
  assert.equal(records.length, 0, 'a bare-alias model is not a reproducibility artifact')
153
153
  assert.equal(unmappable.length, 1)
154
- assert.match(unmappable[0]!.reason, /invalid RunRecord/, 'surfaces the validator rejection')
154
+ assert.match(unmappable[0]!.reason, /invalid BenchRunRecord/, 'surfaces the validator rejection')
155
155
  assert.match(unmappable[0]!.reason, /snapshot/, 'reason explains the snapshot-pin requirement')
156
156
  }
157
157
 
package/src/corpus.ts CHANGED
@@ -27,7 +27,7 @@ import type { BenchRuntimeDecisionPoint, BenchRuntimeHookEvent } from './runtime
27
27
  * path). A worker that reports no usage (e.g. a raw opencode-stdout shot)
28
28
  * OMITS them — it never writes a fabricated `0`. Absence means "unmeasured",
29
29
  * which is honest and lets the canonical bridge below refuse to forge a
30
- * RunRecord with phantom economics. (no-fallback: a silent `0` cost reads as a
30
+ * BenchRunRecord with phantom economics. (no-fallback: a silent `0` cost reads as a
31
31
  * free run downstream, which is a lie the gate would then act on.) */
32
32
  export interface AttemptRecord {
33
33
  round: number
@@ -49,7 +49,7 @@ export interface AttemptRecord {
49
49
  }
50
50
 
51
51
  /** One controller-run over a single benchmark instance under one condition. */
52
- export interface RunRecord {
52
+ export interface BenchRunRecord {
53
53
  ts: string
54
54
  benchmark: string
55
55
  instanceId: string
@@ -63,7 +63,7 @@ export interface RunRecord {
63
63
  attempts: AttemptRecord[]
64
64
  infraError: boolean
65
65
  /** Canonical-pairing provenance (optional; writers set when known). These are
66
- * what let a bench record project onto the substrate's `RunRecord` so it can
66
+ * what let a bench record project onto the substrate's `BenchRunRecord` so it can
67
67
  * pair across sweeps and feed `analyzeRuns`/`HeldOutGate`/the RL exporters. */
68
68
  seed?: number
69
69
  splitTag?: RunSplitTag
@@ -106,7 +106,7 @@ function summarizeAttempt<Task, Output>(iter: Iteration<Task, Output>): AttemptR
106
106
  }
107
107
  }
108
108
 
109
- /** Build a RunRecord from a runAgentRounds result. `now` injected for determinism in tests. */
109
+ /** Build a BenchRunRecord from a runAgentRounds result. `now` injected for determinism in tests. */
110
110
  export function buildRunRecord<Task, Output>(args: {
111
111
  benchmark: string
112
112
  instanceId: string
@@ -123,7 +123,7 @@ export function buildRunRecord<Task, Output>(args: {
123
123
  commitSha?: string
124
124
  runtimeEvents?: BenchRuntimeHookEvent[]
125
125
  runtimeDecisionPoints?: BenchRuntimeDecisionPoint[]
126
- }): RunRecord {
126
+ }): BenchRunRecord {
127
127
  const attempts = args.iterations.map(summarizeAttempt)
128
128
  return {
129
129
  ts: (args.now ? args.now() : new Date()).toISOString(),
@@ -148,7 +148,7 @@ export function buildRunRecord<Task, Output>(args: {
148
148
  }
149
149
 
150
150
  /**
151
- * Build a RunRecord from a hand-assembled `AttemptRecord[]` (the gate runners'
151
+ * Build a BenchRunRecord from a hand-assembled `AttemptRecord[]` (the gate runners'
152
152
  * shape — they score attempts directly rather than carrying `Iteration`s).
153
153
  *
154
154
  * The three run-level verdicts derive from the attempts by default:
@@ -177,7 +177,7 @@ export function buildRunRecordFromAttempts(
177
177
  runtimeEvents?: BenchRuntimeHookEvent[]
178
178
  runtimeDecisionPoints?: BenchRuntimeDecisionPoint[]
179
179
  },
180
- ): RunRecord {
180
+ ): BenchRunRecord {
181
181
  const anyScored = attempts.some((a) => a.score !== undefined)
182
182
  const anyValid = attempts.some((a) => a.valid !== undefined)
183
183
  return {
@@ -203,10 +203,10 @@ export function buildRunRecordFromAttempts(
203
203
  }
204
204
 
205
205
  /** Run-level provenance the caller asserts when projecting a bench record onto
206
- * the substrate. `commitSha` is required: a canonical `RunRecord` is a
206
+ * the substrate. `commitSha` is required: a canonical `BenchRunRecord` is a
207
207
  * reproducibility artifact and must name the code that produced it — the
208
208
  * bridge will not invent one. */
209
- export interface CorpusProjectionOpts {
209
+ interface CorpusProjectionOpts {
210
210
  commitSha: string
211
211
  /** Defaults to the record's `benchmark`. */
212
212
  experimentId?: string
@@ -224,12 +224,12 @@ export interface CorpusProjectionOpts {
224
224
  }
225
225
 
226
226
  /** One attempt that could not become a canonical record, with the reason. */
227
- export interface UnmappableAttempt {
227
+ interface UnmappableAttempt {
228
228
  round: number
229
229
  reason: string
230
230
  }
231
231
 
232
- export interface CorpusProjection {
232
+ interface CorpusProjection {
233
233
  records: CorpusRecord[]
234
234
  /** Attempts dropped because they lacked the canonical-mandatory signal
235
235
  * (measured economics / an output). The caller decides whether a non-empty
@@ -250,7 +250,7 @@ export interface CorpusProjection {
250
250
  * measured `runAgentRounds`/sandbox path can, which is the correct, honest constraint.
251
251
  */
252
252
  export async function benchRecordToCorpusRecords(
253
- rec: RunRecord,
253
+ rec: BenchRunRecord,
254
254
  opts: CorpusProjectionOpts,
255
255
  ): Promise<CorpusProjection> {
256
256
  const records: CorpusRecord[] = []
@@ -304,14 +304,14 @@ export async function benchRecordToCorpusRecords(
304
304
  }
305
305
  try {
306
306
  // Validate for the assertion (throws on a malformed record) but keep the
307
- // CorpusRecord superset — the validator returns a RunRecord and may drop
307
+ // CorpusRecord superset — the validator returns a BenchRunRecord and may drop
308
308
  // the `prompt`/`completion` extras the RL exporters want.
309
309
  validateRunRecord(candidate)
310
310
  records.push(candidate)
311
311
  } catch (err) {
312
312
  unmappable.push({
313
313
  round: a.round,
314
- reason: `invalid RunRecord: ${err instanceof Error ? err.message : String(err)}`,
314
+ reason: `invalid BenchRunRecord: ${err instanceof Error ? err.message : String(err)}`,
315
315
  })
316
316
  }
317
317
  }
@@ -319,8 +319,8 @@ export async function benchRecordToCorpusRecords(
319
319
  return { records, unmappable }
320
320
  }
321
321
 
322
- /** Append one RunRecord to the durable corpus (creating the dir if needed). */
323
- export async function appendRunRecord(corpusPath: string, record: RunRecord): Promise<void> {
322
+ /** Append one BenchRunRecord to the durable corpus (creating the dir if needed). */
323
+ export async function appendRunRecord(corpusPath: string, record: BenchRunRecord): Promise<void> {
324
324
  // Fail loud on a real mkdir failure (EACCES, disk-full): recursive:true is
325
325
  // idempotent when the dir already exists, so this throws ONLY on genuine errors
326
326
  // — a silent swallow just made the append fail later with a confusing message.
package/src/directives.ts CHANGED
@@ -33,44 +33,6 @@ const DIVERSE_STRATEGY_LENSES: ReadonlyArray<string> = [
33
33
  'Name the most plausible WRONG answer and the trap that makes it tempting. Rule it out, then commit to the answer that survives.',
34
34
  ]
35
35
 
36
- /** Compose the k diverse strategies for a run: each = an approach lens layered on the
37
- * (optionally GEPA-learned) shared base. Returns exactly `k` distinct strategy prefixes
38
- * (lenses cycle if k exceeds the lens count, but each carries its index so prompts differ). */
39
- export function composeStrategies(base: string, k: number): string[] {
40
- const lenses = DIVERSE_STRATEGY_LENSES
41
- return Array.from({ length: k }, (_, i) => {
42
- const lens = lenses[i % lenses.length] as string
43
- const tag = i < lenses.length ? '' : ` (variant ${Math.floor(i / lenses.length) + 1})`
44
- return `${lens}${tag}\n\n${base}`
45
- })
46
- }
47
-
48
- /** Research (local opencode, model-knowledge) refine directive — hand-written. */
49
- export const DEFAULT_RESEARCH_REFINE_DIRECTIVE =
50
- 'Double-check it for a specific factual or reasoning error. If it is correct, restate the SAME answer unchanged. Change it ONLY if you identify a concrete, specific error — do not change a correct answer. End with the FINAL ANSWER line.'
51
-
52
- /** Sandbox research (live web/market sources) refine directive — hand-written. */
53
- export const DEFAULT_SANDBOX_REFINE_DIRECTIVE =
54
- 'Double-check it: re-verify the figure against live sources and the requested units/precision/tolerance. If it is correct, restate the SAME final answer unchanged. Change it ONLY if you find a concrete error in the value or the source. End with the explicit final answer.'
55
-
56
- /** GEPA-learned sandbox refine directive (bycd31l10, +7.1pp held-out vs the
57
- * hand-written one on the GEPA run, n=8/noisy). Separates the verification note
58
- * from the verbatim-preserved final answer, fixing the blank-reply failure mode. */
59
- export const GEPA_LEARNED_DIRECTIVE =
60
- 'Double-check it: re-verify the fact/value against a reliable, citable source. Provide a brief Verification note naming the source you used (link or title); this note is not part of the final answer. Confirm the requested units/precision/tolerance exactly. If the prior answer is correct, copy the SAME final answer text verbatim with identical formatting—do not add or remove words. Change it ONLY if you find a concrete error in the value or in the cited source; in that case, briefly describe the specific error in the Verification note and provide the corrected value with the requested units/precision/tolerance. If you cannot verify, state that in the Verification note, but do not alter or omit the final answer. Always place the final answer as the last line of your reply, containing only the answer text.'
61
-
62
- /** OpenSCAD authoring directive (CAD design) — the GEPA-optimizable system prompt.
63
- * Minimal on purpose: states the contract (compile, source-only) but not HOW to
64
- * satisfy the geometric spec, leaving headroom for the optimizer. */
65
- export const DEFAULT_CAD_DIRECTIVE =
66
- 'You are an expert OpenSCAD engineer. Output ONLY valid OpenSCAD source — no prose, no markdown fences. The model MUST compile with `openscad -o out.stl model.scad`. Match the brief as closely as you can.'
67
-
68
- /** OpenSCAD authoring directive for the SANDBOX path (solveCadRefine) — a terser
69
- * variant of DEFAULT_CAD_DIRECTIVE (no "match the brief" tail). Kept distinct
70
- * rather than unified to preserve that path's exact prompt. */
71
- export const DEFAULT_CAD_SANDBOX_DIRECTIVE =
72
- 'You are an expert OpenSCAD engineer. Output ONLY valid OpenSCAD source — no prose, no markdown fences. The model must compile with `openscad -o out.stl model.scad`.'
73
-
74
36
  /** Blender bpy authoring directive (BlenderLLM/CADBench) — the GEPA-optimizable
75
37
  * system prompt. States the contract (runs headless, builds mesh(es) at origin,
76
38
  * no cameras/lights) but not how to satisfy the criteria. */
@@ -24,7 +24,7 @@ const IMAGE = process.env.LEAN_IMAGE ?? 'agent-runtime-lean-verify:local'
24
24
  /** A proof that reaches acceptance via an unchecked escape is not a proof — reject it. */
25
25
  const TRUST_ESCAPE = /\b(sorry|admit|sorryAx|native_decide)\b/
26
26
 
27
- export interface LeanResult {
27
+ interface LeanResult {
28
28
  /** Lean accepted the proof AND it used no trust-escape. */
29
29
  readonly passed: boolean
30
30
  /** Lean's compiler output on failure — feed this back to the prover verbatim. */
package/src/gate.ts CHANGED
@@ -67,7 +67,7 @@ export interface SolveTask {
67
67
 
68
68
  /** What `benchSolverRegistry` needs to build a solve-and-grade leaf. The router config is the
69
69
  * cheapest leaf (one chat completion, no box); the adapter supplies the deployable judge. */
70
- export interface BenchSolverOptions {
70
+ interface BenchSolverOptions {
71
71
  readonly adapter: BenchmarkAdapter
72
72
  readonly routerBaseUrl: string
73
73
  readonly routerKey: string
@@ -107,7 +107,7 @@ function extractArtifact(adapter: BenchmarkAdapter, content: string): string {
107
107
  * tokens but still one iteration (never a fabricated priced cost). Fail-loud: a router non-2xx or
108
108
  * a judge throw rejects the leaf (the scope types it into a `down` settlement — never a silent 0).
109
109
  */
110
- export function benchSolveLeaf(opts: BenchSolverOptions, spec: AgentSpec, ctx: ExecutorContext): Executor<unknown> {
110
+ function benchSolveLeaf(opts: BenchSolverOptions, spec: AgentSpec, ctx: ExecutorContext): Executor<unknown> {
111
111
  const inner = createExecutor({
112
112
  backend: 'router',
113
113
  routerBaseUrl: opts.routerBaseUrl,
@@ -138,7 +138,7 @@ export function benchSolveLeaf(opts: BenchSolverOptions, spec: AgentSpec, ctx: E
138
138
  * spec; a shared BYO executor instance would race on its single result slot. `register` throws:
139
139
  * this registry serves exactly one runtime (the bench solve leaf), by intent.
140
140
  */
141
- export function benchSolverRegistry(opts: BenchSolverOptions): ExecutorRegistry {
141
+ function benchSolverRegistry(opts: BenchSolverOptions): ExecutorRegistry {
142
142
  return {
143
143
  register(): void {
144
144
  throw new Error('benchSolverRegistry: register is unsupported (single bench-router runtime)')
@@ -155,7 +155,7 @@ export function benchSolverRegistry(opts: BenchSolverOptions): ExecutorRegistry
155
155
  /** Build the solver `Persona` from the developer's exact `AgentProfile` + a solve-and-grade
156
156
  * registry. The profile still declares its execution identity; `AgentSpec.harness: null` only
157
157
  * says that the supplied registry owns placement instead of a built-in executor. */
158
- export function defineSolverPersona(
158
+ function defineSolverPersona(
159
159
  profile: AgentProfile,
160
160
  registry: ExecutorRegistry,
161
161
  name = 'gate-solver',
@@ -183,7 +183,7 @@ function solveFanout(strategies: ReadonlyArray<string>, instance: BenchTask): Co
183
183
  })
184
184
  }
185
185
 
186
- export interface RunGateOptions {
186
+ interface RunGateOptions {
187
187
  readonly adapter: BenchmarkAdapter
188
188
  /** The ONE specificity: who the solver is (prompt / model / tools). */
189
189
  readonly profile: AgentProfile
@@ -213,7 +213,7 @@ export interface RunGateOptions {
213
213
  /** One arm's aggregate over the n instances. `errored` = runs that ended `no-winner` for an
214
214
  * infra reason (budget/abort) — excluded from the resolve denominator, like an infra-errored
215
215
  * cell. A genuine all-children-down counts as not-resolved (a real failure, kept in n). */
216
- export interface GateArmResult {
216
+ interface GateArmResult {
217
217
  readonly label: string
218
218
  readonly n: number
219
219
  readonly resolved: number
@@ -229,7 +229,7 @@ export interface GateArmResult {
229
229
  readonly sampleBlocker?: string
230
230
  }
231
231
 
232
- export interface GateReport {
232
+ interface GateReport {
233
233
  readonly benchmark: string
234
234
  readonly k: number
235
235
  readonly n: number
@@ -24,7 +24,7 @@ import { execSync } from 'node:child_process'
24
24
  import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
25
25
  import { tmpdir } from 'node:os'
26
26
  import { dirname, join, resolve } from 'node:path'
27
- import { scoreTask, taskToPrompt } from '../search-bench/tasks'
27
+ import { scoreTask, searchTaskPrompt } from '../search-bench/tasks'
28
28
  import { runBenchRouterTurn } from '../router-turn'
29
29
  import { type EvalCertification, type GeneratedEval, generatedEvalSchemaVersion, parseCandidate } from './schema'
30
30
 
@@ -130,7 +130,7 @@ export async function discriminationGate(
130
130
  model: { provider: 'tangle-router', default: model },
131
131
  },
132
132
  },
133
- taskToPrompt(candidate),
133
+ searchTaskPrompt(candidate),
134
134
  )
135
135
  const { score, reasons } = scoreTask(candidate, res.finalText)
136
136
  return score === 0
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ export {
26
26
  ragAnswerOutput,
27
27
  scoreAnswerArtifact,
28
28
  tokenF1,
29
+ type ResearchAnswer,
29
30
  type RagAnswerScore,
30
31
  type RagContext,
31
32
  } from './benchmarks/rag-shared'
@@ -21,16 +21,16 @@
21
21
  *
22
22
  * This is the inference-timescale instance of the spine's atom: `runShot` is the
23
23
  * worker Agent's `act→Output`; `prompt` is the driver Agent's `act→steer`. It is
24
- * deliberately corpus-agnostic — callers map `RefineLoopResult` to a RunRecord.
24
+ * deliberately corpus-agnostic — callers map `RefineLoopResult` to a BenchRunRecord.
25
25
  */
26
26
 
27
27
  /** Minimal per-round verdict — `valid` gates early-stop, `score` is informational. */
28
- export interface RoundVerdict {
28
+ interface RoundVerdict {
29
29
  valid: boolean
30
30
  score?: number
31
31
  }
32
32
 
33
- export interface RoundRecord<Artifact> {
33
+ interface RoundRecord<Artifact> {
34
34
  /** 1-based round index. */
35
35
  round: number
36
36
  prompt: string
@@ -41,7 +41,7 @@ export interface RoundRecord<Artifact> {
41
41
  note?: string
42
42
  }
43
43
 
44
- export interface RefineLoopSpec<Artifact, Ctx = void> {
44
+ interface RefineLoopSpec<Artifact, Ctx = void> {
45
45
  /** Max shots. Always ≥ 1. */
46
46
  rounds: number
47
47
  /** Build the per-task execution context once (clone repo / create box / mkdtemp). */
@@ -62,7 +62,7 @@ export interface RefineLoopSpec<Artifact, Ctx = void> {
62
62
  teardown?: (ctx: Ctx) => Promise<void>
63
63
  }
64
64
 
65
- export interface RefineLoopResult<Artifact> {
65
+ interface RefineLoopResult<Artifact> {
66
66
  /** Every executed round in order. */
67
67
  rounds: RoundRecord<Artifact>[]
68
68
  /** Round 1 — the blind artifact. */
@@ -28,7 +28,7 @@ import {
28
28
  import { Sandbox } from '@tangle-network/sandbox'
29
29
  import { makeSearchExecutor, webSearchTool } from './search-tool'
30
30
 
31
- export interface ResolveBenchClientOptions {
31
+ interface ResolveBenchClientOptions {
32
32
  /** The selector (the `BACKEND` env value): `router` = off-box; anything else = in-box Sandbox. */
33
33
  backend: string
34
34
  routerBaseUrl: string
@@ -13,19 +13,19 @@ import {
13
13
  } from '@tangle-network/agent-runtime/kernel'
14
14
 
15
15
  /** Bench-local target shorthand; Runtime still executes only the exact profile below. */
16
- export interface BenchRouterTarget {
16
+ interface BenchRouterTarget {
17
17
  routerBaseUrl: string
18
18
  routerKey: string
19
19
  profile: AgentProfile
20
20
  }
21
21
 
22
- export interface BenchRouterTurnConfig extends BenchRouterTarget {
22
+ interface BenchRouterTurnConfig extends BenchRouterTarget {
23
23
  tools?: ReadonlyArray<ToolSpec>
24
24
  timeoutMs?: number
25
25
  signal?: AbortSignal
26
26
  }
27
27
 
28
- export interface BenchProfileSettings {
28
+ interface BenchProfileSettings {
29
29
  systemPrompt?: string
30
30
  temperature?: number
31
31
  maxTokens?: number
@@ -95,14 +95,6 @@ export function withBenchProfile(
95
95
  })
96
96
  }
97
97
 
98
- export function benchProfileModel(profile: AgentProfile): string {
99
- const model = profile.model?.default
100
- if (typeof model !== 'string' || model.length === 0 || model === 'runtime-selected') {
101
- throw new Error('benchmark AgentProfile.model.default must be concrete')
102
- }
103
- return model
104
- }
105
-
106
98
  /**
107
99
  * The benchmark-side entry to Runtime's canonical one-turn path.
108
100
  * It is only an ergonomic composition: Runtime still parses the exact profile,
package/src/run-pool.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * the item's position), not completion order.
14
14
  */
15
15
 
16
- export interface PoolOutcome<T, R> {
16
+ interface PoolOutcome<T, R> {
17
17
  index: number
18
18
  item: T
19
19
  ok: boolean
@@ -32,7 +32,7 @@ export interface BenchRuntimeDecisionPoint {
32
32
  metadata?: Record<string, unknown>
33
33
  }
34
34
 
35
- export interface BenchRuntimeHooks {
35
+ interface BenchRuntimeHooks {
36
36
  onEvent?: (
37
37
  event: BenchRuntimeHookEvent,
38
38
  context: { signal?: AbortSignal },
@@ -43,7 +43,7 @@ export interface BenchRuntimeHooks {
43
43
  ) => void | Promise<void>
44
44
  }
45
45
 
46
- export interface RuntimeHookRecorder {
46
+ interface RuntimeHookRecorder {
47
47
  readonly events: BenchRuntimeHookEvent[]
48
48
  readonly decisionPoints: BenchRuntimeDecisionPoint[]
49
49
  readonly hooks: BenchRuntimeHooks
@@ -40,7 +40,7 @@ export interface SearchTask {
40
40
  const ANSWER_CONTRACT =
41
41
  'Answer with the exact code/identifiers requested. Cite the source URL(s) you used. Be precise — exact method, option, and import names matter.'
42
42
 
43
- export function taskToPrompt(task: SearchTask): string {
43
+ export function searchTaskPrompt(task: SearchTask): string {
44
44
  return `${task.prompt}\n\n${ANSWER_CONTRACT}`
45
45
  }
46
46