@tangle-network/agent-bench 0.3.8 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +7 -0
  3. package/dist/adapters.js +23 -23
  4. package/dist/benchmarks/_harness.d.ts +4 -1
  5. package/dist/benchmarks/_harness.js +3 -1
  6. package/dist/benchmarks/aec-bench.js +2 -2
  7. package/dist/benchmarks/agentbench.js +2 -2
  8. package/dist/benchmarks/appworld.js +2 -2
  9. package/dist/benchmarks/bfcl.js +2 -2
  10. package/dist/benchmarks/commit0.js +2 -2
  11. package/dist/benchmarks/crag.js +2 -2
  12. package/dist/benchmarks/dabstep.js +2 -2
  13. package/dist/benchmarks/enterpriseops-gym.js +2 -2
  14. package/dist/benchmarks/finresearchbench.js +2 -2
  15. package/dist/benchmarks/nomiracl.js +2 -2
  16. package/dist/benchmarks/open-rag-bench.js +2 -2
  17. package/dist/benchmarks/programbench.js +2 -2
  18. package/dist/benchmarks/ragbench.js +2 -2
  19. package/dist/benchmarks/swe-bench.js +2 -2
  20. package/dist/benchmarks/t2-ragbench.js +2 -2
  21. package/dist/benchmarks/tau-bench-shared.js +2 -2
  22. package/dist/benchmarks/tau2-bench.js +3 -3
  23. package/dist/benchmarks/tau3-banking.js +3 -3
  24. package/dist/benchmarks/terminal-bench.js +2 -2
  25. package/dist/benchmarks/toollm.js +2 -2
  26. package/dist/benchmarks/webarena-verified.js +2 -2
  27. package/dist/{chunk-YSMEKBTD.js → chunk-5FEQDSCT.js} +2 -2
  28. package/dist/{chunk-PB64GYIG.js → chunk-67ACKDCX.js} +2 -2
  29. package/dist/{chunk-NQG5XDSB.js → chunk-7FKBWOQT.js} +2 -2
  30. package/dist/{chunk-K3BQGZCT.js → chunk-BEN6IF2X.js} +2 -2
  31. package/dist/{chunk-SHYIRB7I.js → chunk-BZY5QARD.js} +2 -2
  32. package/dist/{chunk-KP5KD6EN.js → chunk-CLIKAXKH.js} +2 -2
  33. package/dist/{chunk-XKEFIFIC.js → chunk-CWIOBFSP.js} +2 -2
  34. package/dist/{chunk-IA2FBTWC.js → chunk-CXDUTWQE.js} +2 -2
  35. package/dist/{chunk-RH5F53JT.js → chunk-DWALFME7.js} +2 -2
  36. package/dist/{chunk-V7AEBY6U.js → chunk-EEOC6QPJ.js} +21 -21
  37. package/dist/{chunk-WSKWVEQB.js → chunk-EIETHPD5.js} +7 -3
  38. package/dist/chunk-EIETHPD5.js.map +1 -0
  39. package/dist/{chunk-SHM6MRRF.js → chunk-GC2EPS6L.js} +2 -2
  40. package/dist/{chunk-IZ5M6OAC.js → chunk-GCHL6XPM.js} +2 -2
  41. package/dist/{chunk-IFVINJ4B.js → chunk-HQ5HCCKF.js} +2 -2
  42. package/dist/{chunk-7GRVHU22.js → chunk-HVW25KSX.js} +2 -2
  43. package/dist/{chunk-3U5TXJZS.js → chunk-J6BU3NTM.js} +2 -2
  44. package/dist/{chunk-XYA4XSNU.js → chunk-JSQOUKXS.js} +4 -3
  45. package/dist/chunk-JSQOUKXS.js.map +1 -0
  46. package/dist/{chunk-SVR2LKYI.js → chunk-NRMGT25X.js} +2 -2
  47. package/dist/{chunk-MQMRLGOG.js → chunk-QZZEAHWJ.js} +2 -2
  48. package/dist/{chunk-RCYQEFNX.js → chunk-WG7TM7UV.js} +3 -3
  49. package/dist/{chunk-HWST3SED.js → chunk-XXFF3RRD.js} +2 -2
  50. package/dist/{chunk-SFLA7OH3.js → chunk-ZFNOM7WR.js} +3 -3
  51. package/dist/{chunk-Z4TZ76N7.js → chunk-ZNCCYTFG.js} +2 -2
  52. package/dist/index.js +23 -23
  53. package/package.json +4 -4
  54. package/pier_agents/candidate_contract.py +238 -24
  55. package/pier_agents/tangle_candidate.py +75 -5
  56. package/scripts/trata-hedge/README.md +6 -5
  57. package/scripts/verify-packed-consumer.mjs +65 -1
  58. package/scripts/verify-pier-agent.mts +6 -4
  59. package/src/benchmarks/_harness.test.mts +16 -1
  60. package/src/benchmarks/_harness.ts +9 -2
  61. package/src/benchmarks/terminal-bench.ts +2 -1
  62. package/src/gate.ts +1 -1
  63. package/src/hev-eval.mts +5 -2
  64. package/src/hev-improve.mts +118 -73
  65. package/src/official-optimizer-config.mts +89 -0
  66. package/src/official-optimizer-config.test.mts +88 -0
  67. package/src/profiles.ts +2 -2
  68. package/src/rollout-ledger/backfill-swe-arena.test.mts +28 -24
  69. package/src/smoke-structural-rollout.mts +15 -9
  70. package/src/swe-arena/activation.mts +1 -4
  71. package/src/swe-arena/activation.test.mts +10 -13
  72. package/src/swe-arena/gepa-seat.mts +425 -131
  73. package/src/swe-arena/gepa-seat.test.mts +524 -100
  74. package/src/swe-arena/implementation-ref.test.mts +64 -0
  75. package/src/swe-arena/implementation-ref.ts +62 -0
  76. package/src/swe-arena/outer-loop.mts +103 -76
  77. package/src/swe-arena/proposer-fanout.mts +51 -36
  78. package/src/swe-arena/proposer-fanout.test.mts +0 -1
  79. package/src/swe-arena/proposer-provenance.mts +11 -16
  80. package/src/swe-arena/scratch-worktree.test.mts +55 -0
  81. package/src/swe-arena/scratch-worktree.ts +34 -0
  82. package/src/swe-code-improve.mts +24 -25
  83. package/src/swe-improve.mts +129 -96
  84. package/src/swe-local-proof.mts +6 -1
  85. package/src/swe-stream.mts +4 -2
  86. package/src/tb-container-executor.test.mts +30 -6
  87. package/src/tb-supervisor-sidecar.mts +2 -1
  88. package/src/trata-gepa.mts +182 -245
  89. package/dist/chunk-WSKWVEQB.js.map +0 -1
  90. package/dist/chunk-XYA4XSNU.js.map +0 -1
  91. package/src/live-improve-campaign-mbpp.mts +0 -641
  92. package/src/live-improve-campaign.mts +0 -500
  93. package/src/swe-arena/lineage-record.mts +0 -164
  94. package/src/swe-arena/lineage-record.test.mts +0 -115
  95. /package/dist/{chunk-YSMEKBTD.js.map → chunk-5FEQDSCT.js.map} +0 -0
  96. /package/dist/{chunk-PB64GYIG.js.map → chunk-67ACKDCX.js.map} +0 -0
  97. /package/dist/{chunk-NQG5XDSB.js.map → chunk-7FKBWOQT.js.map} +0 -0
  98. /package/dist/{chunk-K3BQGZCT.js.map → chunk-BEN6IF2X.js.map} +0 -0
  99. /package/dist/{chunk-SHYIRB7I.js.map → chunk-BZY5QARD.js.map} +0 -0
  100. /package/dist/{chunk-KP5KD6EN.js.map → chunk-CLIKAXKH.js.map} +0 -0
  101. /package/dist/{chunk-XKEFIFIC.js.map → chunk-CWIOBFSP.js.map} +0 -0
  102. /package/dist/{chunk-IA2FBTWC.js.map → chunk-CXDUTWQE.js.map} +0 -0
  103. /package/dist/{chunk-RH5F53JT.js.map → chunk-DWALFME7.js.map} +0 -0
  104. /package/dist/{chunk-V7AEBY6U.js.map → chunk-EEOC6QPJ.js.map} +0 -0
  105. /package/dist/{chunk-SHM6MRRF.js.map → chunk-GC2EPS6L.js.map} +0 -0
  106. /package/dist/{chunk-IZ5M6OAC.js.map → chunk-GCHL6XPM.js.map} +0 -0
  107. /package/dist/{chunk-IFVINJ4B.js.map → chunk-HQ5HCCKF.js.map} +0 -0
  108. /package/dist/{chunk-7GRVHU22.js.map → chunk-HVW25KSX.js.map} +0 -0
  109. /package/dist/{chunk-3U5TXJZS.js.map → chunk-J6BU3NTM.js.map} +0 -0
  110. /package/dist/{chunk-SVR2LKYI.js.map → chunk-NRMGT25X.js.map} +0 -0
  111. /package/dist/{chunk-MQMRLGOG.js.map → chunk-QZZEAHWJ.js.map} +0 -0
  112. /package/dist/{chunk-RCYQEFNX.js.map → chunk-WG7TM7UV.js.map} +0 -0
  113. /package/dist/{chunk-HWST3SED.js.map → chunk-XXFF3RRD.js.map} +0 -0
  114. /package/dist/{chunk-SFLA7OH3.js.map → chunk-ZFNOM7WR.js.map} +0 -0
  115. /package/dist/{chunk-Z4TZ76N7.js.map → chunk-ZNCCYTFG.js.map} +0 -0
@@ -199,14 +199,25 @@ async function runTask(t: HumanEvalTask): Promise<TaskRow> {
199
199
  `${t.taskId}: ${result.selection.length} receipts vs ${scored.length} scored candidates`,
200
200
  )
201
201
  }
202
- for (const r of result.selection) {
202
+ const receipts = result.selection.map((receipt) => {
203
+ if (receipt.score === undefined || receipt.reason === undefined) {
204
+ throw new Error(`${t.taskId}: receipt #${receipt.candidateIndex} is missing score or reason`)
205
+ }
206
+ return {
207
+ candidateIndex: receipt.candidateIndex,
208
+ selected: receipt.selected,
209
+ score: receipt.score,
210
+ reason: receipt.reason,
211
+ }
212
+ })
213
+ for (const r of receipts) {
203
214
  const rec = scored[r.candidateIndex]
204
215
  if (!rec || Math.abs(r.score - visibleCheckScore(rec.outcome)) > 1e-9) {
205
216
  throw new Error(`${t.taskId}: receipt #${r.candidateIndex} score ${r.score} does not match the recorded outcome`)
206
217
  }
207
218
  }
208
219
 
209
- const sampleCount = result.selection.filter((r) => r.reason.startsWith('sample')).length
220
+ const sampleCount = receipts.filter((r) => r.reason.startsWith('sample')).length
210
221
  const samples = scored.slice(0, sampleCount)
211
222
  if (samples.length === 0) throw new Error(`${t.taskId}: no sample candidates settled`)
212
223
 
@@ -223,7 +234,7 @@ async function runTask(t: HumanEvalTask): Promise<TaskRow> {
223
234
  const sampleHidden = await Promise.all(samples.map((s) => grade(s.candidate)))
224
235
  const selectedIdx = selectBestIndex(samples.map((s) => s.outcome))
225
236
  const selectedHidden = sampleHidden[selectedIdx] as number
226
- const winner = result.selection.find((r) => r.selected)
237
+ const winner = receipts.find((r) => r.selected)
227
238
  if (!winner) throw new Error(`${t.taskId}: no receipt marked selected`)
228
239
  const finalIdx = winner.candidateIndex
229
240
  const finalHidden = await grade((scored[finalIdx] as ScoredCandidate).candidate)
@@ -241,12 +252,7 @@ async function runTask(t: HumanEvalTask): Promise<TaskRow> {
241
252
  finalIdx,
242
253
  finalHidden,
243
254
  selectedVisible: visibleCheckScore((samples[selectedIdx] as ScoredCandidate).outcome),
244
- receipts: result.selection.map((r) => ({
245
- candidateIndex: r.candidateIndex,
246
- selected: r.selected,
247
- score: r.score,
248
- reason: r.reason,
249
- })),
255
+ receipts,
250
256
  tokens: result.tokens,
251
257
  usd: result.usd,
252
258
  ms: result.ms,
@@ -26,7 +26,6 @@ import { run } from './proc.ts'
26
26
  export const ACTIVATION_PREDICATE_RELPATH = '.improve/activation.json'
27
27
 
28
28
  export interface ActivationPredicate {
29
- version: 'v1'
30
29
  /** One sentence: which mechanism this proves fired. */
31
30
  description: string
32
31
  kind: 'grep' | 'script'
@@ -53,7 +52,6 @@ export function parseActivationPredicate(raw: string): ParsedPredicate {
53
52
  return { ok: false, error: 'must be a JSON object' }
54
53
  }
55
54
  const p = value as Record<string, unknown>
56
- if (p.version !== 'v1') return { ok: false, error: `version must be "v1", got ${JSON.stringify(p.version)}` }
57
55
  if (typeof p.description !== 'string' || p.description.trim().length === 0) {
58
56
  return { ok: false, error: 'description must be a non-empty string' }
59
57
  }
@@ -90,13 +88,12 @@ export function activationPredicateInstruction(): string {
90
88
  '',
91
89
  'Template (kind "grep" — a RegExp tested over the run artifacts):',
92
90
  ' {',
93
- ' "version": "v1",',
94
91
  ' "description": "patchRiskWarnings emitted in at least one settle",',
95
92
  ' "kind": "grep",',
96
93
  ' "pattern": "patchRiskWarnings|patch-risk",',
97
94
  ' "files": ["journal.jsonl", "workers/"]',
98
95
  ' }',
99
- 'Or kind "script": {"version":"v1","description":"...","kind":"script","script":"grep -rq NEW_SECTION ws/.loops"}',
96
+ 'Or kind "script": {"description":"...","kind":"script","script":"grep -rq NEW_SECTION ws/.loops"}',
100
97
  '(exit 0 in any run dir = fired).',
101
98
  'Pick a pattern that can ONLY appear when your mechanism ran — not one that matches the diff itself.',
102
99
  ].join('\n')
@@ -26,7 +26,6 @@ describe('parseActivationPredicate', () => {
26
26
  it('accepts a valid grep predicate (with optional files filters)', () => {
27
27
  const parsed = parseActivationPredicate(
28
28
  JSON.stringify({
29
- version: 'v1',
30
29
  description: 'patchRiskWarnings emitted in at least one settle',
31
30
  kind: 'grep',
32
31
  pattern: 'patchRiskWarnings|patch-risk',
@@ -38,7 +37,7 @@ describe('parseActivationPredicate', () => {
38
37
 
39
38
  it('accepts a valid script predicate', () => {
40
39
  const parsed = parseActivationPredicate(
41
- JSON.stringify({ version: 'v1', description: 'x', kind: 'script', script: 'grep -rq X .' }),
40
+ JSON.stringify({ description: 'x', kind: 'script', script: 'grep -rq X .' }),
42
41
  )
43
42
  expect(parsed.ok).toBe(true)
44
43
  })
@@ -46,13 +45,12 @@ describe('parseActivationPredicate', () => {
46
45
  it.each([
47
46
  ['not json', 'not valid JSON'],
48
47
  ['[]', 'JSON object'],
49
- [JSON.stringify({ version: 'v2', description: 'x', kind: 'grep', pattern: 'a' }), 'version'],
50
- [JSON.stringify({ version: 'v1', description: '', kind: 'grep', pattern: 'a' }), 'description'],
51
- [JSON.stringify({ version: 'v1', description: 'x', kind: 'grep' }), 'pattern'],
52
- [JSON.stringify({ version: 'v1', description: 'x', kind: 'grep', pattern: '(' }), 'RegExp'],
53
- [JSON.stringify({ version: 'v1', description: 'x', kind: 'grep', pattern: 'a', files: [1] }), 'files'],
54
- [JSON.stringify({ version: 'v1', description: 'x', kind: 'script' }), 'script'],
55
- [JSON.stringify({ version: 'v1', description: 'x', kind: 'sql' }), 'kind'],
48
+ [JSON.stringify({ description: '', kind: 'grep', pattern: 'a' }), 'description'],
49
+ [JSON.stringify({ description: 'x', kind: 'grep' }), 'pattern'],
50
+ [JSON.stringify({ description: 'x', kind: 'grep', pattern: '(' }), 'RegExp'],
51
+ [JSON.stringify({ description: 'x', kind: 'grep', pattern: 'a', files: [1] }), 'files'],
52
+ [JSON.stringify({ description: 'x', kind: 'script' }), 'script'],
53
+ [JSON.stringify({ description: 'x', kind: 'sql' }), 'kind'],
56
54
  ])('rejects %s', (raw, want) => {
57
55
  const parsed = parseActivationPredicate(raw)
58
56
  expect(parsed.ok).toBe(false)
@@ -84,7 +82,6 @@ describe('runActivationPredicate', () => {
84
82
  })
85
83
 
86
84
  const grep = (pattern: string, files?: string[]) => ({
87
- version: 'v1' as const,
88
85
  description: 'd',
89
86
  kind: 'grep' as const,
90
87
  pattern,
@@ -127,7 +124,7 @@ describe('runActivationPredicate', () => {
127
124
  })
128
125
 
129
126
  it('script kind fires on rc=0 in any run dir, not-fired otherwise', async () => {
130
- const script = (s: string) => ({ version: 'v1' as const, description: 'd', kind: 'script' as const, script: s })
127
+ const script = (s: string) => ({ description: 'd', kind: 'script' as const, script: s })
131
128
  const hit = await runActivationPredicate(script('grep -q patchRiskWarnings driver.log'), [runA, runB])
132
129
  expect(hit.fired).toBe(true)
133
130
  expect(hit.evidence[0]).toContain(runB)
@@ -261,11 +258,11 @@ describe('activation-predicate prefilter', () => {
261
258
  await mkdir(join(args.worktreePath, '.improve'), { recursive: true })
262
259
  await writeFile(
263
260
  join(args.worktreePath, ACTIVATION_PREDICATE_RELPATH),
264
- JSON.stringify({ version: 'v1', description: 'd', kind: 'grep', pattern: 'x' }),
261
+ JSON.stringify({ description: 'd', kind: 'grep', pattern: 'x' }),
265
262
  )
266
263
  } else if (proposer.name === 'invalid-predicate') {
267
264
  await mkdir(join(args.worktreePath, '.improve'), { recursive: true })
268
- await writeFile(join(args.worktreePath, ACTIVATION_PREDICATE_RELPATH), '{"version":"v1"}')
265
+ await writeFile(join(args.worktreePath, ACTIVATION_PREDICATE_RELPATH), '{}')
269
266
  }
270
267
  return { applied: true, summary: `${proposer.name} edit` }
271
268
  },