@tangle-network/agent-bench 0.3.7 → 0.3.8

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 (191) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/HARNESS.md +43 -0
  3. package/dist/adapters.js +23 -23
  4. package/dist/benchmarks/_harness.d.ts +1 -1
  5. package/dist/benchmarks/_harness.js +1 -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-CKUVRZ2T.js → chunk-3U5TXJZS.js} +2 -2
  28. package/dist/{chunk-YCGY7UIZ.js → chunk-7GRVHU22.js} +2 -2
  29. package/dist/{chunk-Z7ML6L77.js → chunk-HWST3SED.js} +2 -2
  30. package/dist/{chunk-SYDW647C.js → chunk-IA2FBTWC.js} +2 -2
  31. package/dist/{chunk-R67DFVLO.js → chunk-IFVINJ4B.js} +2 -2
  32. package/dist/{chunk-R36V2VP7.js → chunk-IZ5M6OAC.js} +2 -2
  33. package/dist/{chunk-ODT47UAY.js → chunk-K3BQGZCT.js} +2 -2
  34. package/dist/{chunk-IFAV6KEM.js → chunk-KP5KD6EN.js} +2 -2
  35. package/dist/{chunk-ZEWMTR5M.js → chunk-MQMRLGOG.js} +2 -2
  36. package/dist/{chunk-TSWPNOYM.js → chunk-NQG5XDSB.js} +2 -2
  37. package/dist/{chunk-7WSD27QQ.js → chunk-PB64GYIG.js} +2 -2
  38. package/dist/{chunk-HBSWHQNJ.js → chunk-RCYQEFNX.js} +3 -3
  39. package/dist/{chunk-J3KDJNX2.js → chunk-RH5F53JT.js} +2 -2
  40. package/dist/{chunk-UAIOHCUK.js → chunk-SFLA7OH3.js} +3 -3
  41. package/dist/{chunk-Y6O2OCUO.js → chunk-SHM6MRRF.js} +2 -2
  42. package/dist/{chunk-KDIKRJGB.js → chunk-SHYIRB7I.js} +2 -2
  43. package/dist/{chunk-HHXFIHXC.js → chunk-SVR2LKYI.js} +2 -2
  44. package/dist/{chunk-PWQVGAJB.js → chunk-V7AEBY6U.js} +21 -21
  45. package/dist/{chunk-LRRD7NAG.js → chunk-WSKWVEQB.js} +18 -2
  46. package/dist/chunk-WSKWVEQB.js.map +1 -0
  47. package/dist/{chunk-2PVVP7GN.js → chunk-XKEFIFIC.js} +2 -2
  48. package/dist/{chunk-JRWWGMK7.js → chunk-XYA4XSNU.js} +2 -2
  49. package/dist/{chunk-X5YKXC6V.js → chunk-YSMEKBTD.js} +2 -2
  50. package/dist/{chunk-2XU6OGEN.js → chunk-Z4TZ76N7.js} +2 -2
  51. package/dist/index.js +23 -23
  52. package/package.json +4 -4
  53. package/scripts/verify-packed-consumer.mjs +1 -1
  54. package/src/benchmarks/_harness.ts +20 -2
  55. package/src/benchmarks/humaneval.test.mts +2 -2
  56. package/src/quant-arena/README.md +144 -0
  57. package/src/quant-arena/backtest.test.mts +135 -0
  58. package/src/quant-arena/backtest.ts +218 -0
  59. package/src/quant-arena/data.test.mts +44 -0
  60. package/src/quant-arena/data.ts +141 -0
  61. package/src/quant-arena/driver.test.mts +253 -0
  62. package/src/quant-arena/driver.ts +219 -0
  63. package/src/quant-arena/fixtures/data/PROVENANCE.md +26 -0
  64. package/src/quant-arena/fixtures/data/holdout/IDX.csv +523 -0
  65. package/src/quant-arena/fixtures/data/holdout/S01.csv +523 -0
  66. package/src/quant-arena/fixtures/data/holdout/S02.csv +523 -0
  67. package/src/quant-arena/fixtures/data/holdout/S03.csv +523 -0
  68. package/src/quant-arena/fixtures/data/holdout/S04.csv +523 -0
  69. package/src/quant-arena/fixtures/data/holdout/S05.csv +523 -0
  70. package/src/quant-arena/fixtures/data/holdout/S06.csv +523 -0
  71. package/src/quant-arena/fixtures/data/holdout/S07.csv +523 -0
  72. package/src/quant-arena/fixtures/data/holdout/S08.csv +523 -0
  73. package/src/quant-arena/fixtures/data/holdout/S09.csv +523 -0
  74. package/src/quant-arena/fixtures/data/holdout/S10.csv +523 -0
  75. package/src/quant-arena/fixtures/data/insample/IDX.csv +2087 -0
  76. package/src/quant-arena/fixtures/data/insample/S01.csv +2087 -0
  77. package/src/quant-arena/fixtures/data/insample/S02.csv +2087 -0
  78. package/src/quant-arena/fixtures/data/insample/S03.csv +2087 -0
  79. package/src/quant-arena/fixtures/data/insample/S04.csv +2087 -0
  80. package/src/quant-arena/fixtures/data/insample/S05.csv +2087 -0
  81. package/src/quant-arena/fixtures/data/insample/S06.csv +2087 -0
  82. package/src/quant-arena/fixtures/data/insample/S07.csv +2087 -0
  83. package/src/quant-arena/fixtures/data/insample/S08.csv +2087 -0
  84. package/src/quant-arena/fixtures/data/insample/S09.csv +2087 -0
  85. package/src/quant-arena/fixtures/data/insample/S10.csv +2087 -0
  86. package/src/quant-arena/fixtures/demo-campaign/cost-ledger.jsonl +16 -0
  87. package/src/quant-arena/fixtures/demo-campaign/notebook.jsonl +5 -0
  88. package/src/quant-arena/fixtures/demo-campaign/rollout-manifest.json +171 -0
  89. package/src/quant-arena/fixtures/demo-campaign/strategies/cand-001-default-author/strategy.ts +119 -0
  90. package/src/quant-arena/fixtures/demo-campaign/strategies/cand-002-default-author/strategy.ts +119 -0
  91. package/src/quant-arena/fixtures/demo-campaign/strategies/cand-003-quant-researcher/strategy.ts +105 -0
  92. package/src/quant-arena/fixtures/demo-campaign/strategies/cand-004-quant-researcher/strategy.ts +102 -0
  93. package/src/quant-arena/fixtures/demo-campaign-v2/cost-ledger.jsonl +4 -0
  94. package/src/quant-arena/fixtures/demo-campaign-v2/notebook.jsonl +2 -0
  95. package/src/quant-arena/fixtures/demo-campaign-v2/rollout-manifest.json +84 -0
  96. package/src/quant-arena/fixtures/demo-campaign-v2/strategies/cand-001-quant-researcher/strategy.ts +117 -0
  97. package/src/quant-arena/holdout-certify.mts +206 -0
  98. package/src/quant-arena/holdout-certify.test.mts +82 -0
  99. package/src/quant-arena/leak-audit.test.mts +79 -0
  100. package/src/quant-arena/leak-audit.ts +95 -0
  101. package/src/quant-arena/make-fixtures.mts +161 -0
  102. package/src/quant-arena/multiplicity.test.mts +68 -0
  103. package/src/quant-arena/multiplicity.ts +87 -0
  104. package/src/quant-arena/nautilus-certify.ts +31 -0
  105. package/src/quant-arena/oms.ts +90 -0
  106. package/src/quant-arena/profiles/quant-researcher.profile.json +7 -0
  107. package/src/quant-arena/python/pyproject.toml +8 -0
  108. package/src/quant-arena/python/uv.lock +1297 -0
  109. package/src/quant-arena/python/vbt-worker.py +192 -0
  110. package/src/quant-arena/quant-loop.mts +813 -0
  111. package/src/quant-arena/quant-loop.test.mts +75 -0
  112. package/src/quant-arena/strategies/buy-hold-index/strategy.ts +11 -0
  113. package/src/quant-arena/strategies/equal-weight/strategy.ts +20 -0
  114. package/src/quant-arena/strategies/sma-crossover/strategy.ts +42 -0
  115. package/src/quant-arena/types.ts +133 -0
  116. package/src/quant-arena/vbt-client.ts +321 -0
  117. package/src/quant-arena/vbt-parity.test.mts +183 -0
  118. package/src/quant-arena/windows.test.mts +45 -0
  119. package/src/quant-arena/windows.ts +54 -0
  120. package/src/rollout-ledger/backfill-swe-arena.mts +606 -0
  121. package/src/rollout-ledger/backfill-swe-arena.test.mts +338 -0
  122. package/src/rollout-ledger/settle-capture.mts +442 -0
  123. package/src/rollout-ledger/settle-capture.test.mts +270 -0
  124. package/src/swe-arena/activation.mts +228 -0
  125. package/src/swe-arena/activation.test.mts +303 -0
  126. package/src/swe-arena/arms.ts +30 -14
  127. package/src/swe-arena/briefing.mts +217 -0
  128. package/src/swe-arena/briefing.test.mts +178 -0
  129. package/src/swe-arena/calibrate.ts +102 -1
  130. package/src/swe-arena/cell-evidence.mts +41 -9
  131. package/src/swe-arena/factory-command-container.ts +284 -0
  132. package/src/swe-arena/factory-judge-child.mts +228 -0
  133. package/src/swe-arena/factory.test.mts +643 -0
  134. package/src/swe-arena/fixtures/factory/agent-eval-309/calibration.md +51 -0
  135. package/src/swe-arena/fixtures/factory/agent-eval-309/manifest.json +29 -0
  136. package/src/swe-arena/fixtures/factory/agent-eval-309/spec.md +64 -0
  137. package/src/swe-arena/fixtures/factory/agent-runtime-232/calibration.md +48 -0
  138. package/src/swe-arena/fixtures/factory/agent-runtime-232/manifest.json +29 -0
  139. package/src/swe-arena/fixtures/factory/agent-runtime-232/spec.md +48 -0
  140. package/src/swe-arena/fixtures/factory/loops-28/calibration.md +47 -0
  141. package/src/swe-arena/fixtures/factory/loops-28/manifest.json +30 -0
  142. package/src/swe-arena/fixtures/factory/loops-28/spec.md +50 -0
  143. package/src/swe-arena/fixtures/run-report/README.md +43 -0
  144. package/src/swe-arena/fixtures/run-report/factory-agent-eval-309-FSUP0.json +173 -0
  145. package/src/swe-arena/fixtures/run-report/factory-agent-eval-309-FSUP0.md +100 -0
  146. package/src/swe-arena/fixtures/run-report/gen3-rollup.json +551 -0
  147. package/src/swe-arena/fixtures/run-report/gen3-rollup.md +64 -0
  148. package/src/swe-arena/fixtures.ts +135 -2
  149. package/src/swe-arena/gepa-seat.mts +583 -0
  150. package/src/swe-arena/gepa-seat.test.mts +635 -0
  151. package/src/swe-arena/ledger-orphans.mts +77 -0
  152. package/src/swe-arena/ledger-orphans.test.mts +147 -0
  153. package/src/swe-arena/lineage-record.mts +164 -0
  154. package/src/swe-arena/lineage-record.test.mts +115 -0
  155. package/src/swe-arena/outer-loop.mts +677 -27
  156. package/src/swe-arena/premeasured-from-cells.mts +281 -0
  157. package/src/swe-arena/premeasured-from-cells.test.mts +180 -0
  158. package/src/swe-arena/proposer-fanout.mts +295 -14
  159. package/src/swe-arena/proposer-fanout.test.mts +247 -0
  160. package/src/swe-arena/proposer-provenance.mts +177 -0
  161. package/src/swe-arena/proposer-provenance.test.mts +106 -0
  162. package/src/swe-arena/run-experiment.mts +367 -1
  163. package/src/swe-arena/run-report.mts +75 -0
  164. package/src/swe-arena/run-supervisor.test.mts +5 -3
  165. package/src/swe-arena/score-split.mts +140 -0
  166. package/src/swe-arena/score-split.test.mts +123 -0
  167. package/src/swe-arena/types.ts +52 -0
  168. package/src/swe-structural.mts +245 -837
  169. package/dist/chunk-LRRD7NAG.js.map +0 -1
  170. /package/dist/{chunk-CKUVRZ2T.js.map → chunk-3U5TXJZS.js.map} +0 -0
  171. /package/dist/{chunk-YCGY7UIZ.js.map → chunk-7GRVHU22.js.map} +0 -0
  172. /package/dist/{chunk-Z7ML6L77.js.map → chunk-HWST3SED.js.map} +0 -0
  173. /package/dist/{chunk-SYDW647C.js.map → chunk-IA2FBTWC.js.map} +0 -0
  174. /package/dist/{chunk-R67DFVLO.js.map → chunk-IFVINJ4B.js.map} +0 -0
  175. /package/dist/{chunk-R36V2VP7.js.map → chunk-IZ5M6OAC.js.map} +0 -0
  176. /package/dist/{chunk-ODT47UAY.js.map → chunk-K3BQGZCT.js.map} +0 -0
  177. /package/dist/{chunk-IFAV6KEM.js.map → chunk-KP5KD6EN.js.map} +0 -0
  178. /package/dist/{chunk-ZEWMTR5M.js.map → chunk-MQMRLGOG.js.map} +0 -0
  179. /package/dist/{chunk-TSWPNOYM.js.map → chunk-NQG5XDSB.js.map} +0 -0
  180. /package/dist/{chunk-7WSD27QQ.js.map → chunk-PB64GYIG.js.map} +0 -0
  181. /package/dist/{chunk-HBSWHQNJ.js.map → chunk-RCYQEFNX.js.map} +0 -0
  182. /package/dist/{chunk-J3KDJNX2.js.map → chunk-RH5F53JT.js.map} +0 -0
  183. /package/dist/{chunk-UAIOHCUK.js.map → chunk-SFLA7OH3.js.map} +0 -0
  184. /package/dist/{chunk-Y6O2OCUO.js.map → chunk-SHM6MRRF.js.map} +0 -0
  185. /package/dist/{chunk-KDIKRJGB.js.map → chunk-SHYIRB7I.js.map} +0 -0
  186. /package/dist/{chunk-HHXFIHXC.js.map → chunk-SVR2LKYI.js.map} +0 -0
  187. /package/dist/{chunk-PWQVGAJB.js.map → chunk-V7AEBY6U.js.map} +0 -0
  188. /package/dist/{chunk-2PVVP7GN.js.map → chunk-XKEFIFIC.js.map} +0 -0
  189. /package/dist/{chunk-JRWWGMK7.js.map → chunk-XYA4XSNU.js.map} +0 -0
  190. /package/dist/{chunk-X5YKXC6V.js.map → chunk-YSMEKBTD.js.map} +0 -0
  191. /package/dist/{chunk-2XU6OGEN.js.map → chunk-Z4TZ76N7.js.map} +0 -0
@@ -6,8 +6,11 @@ import type { AnalystFinding } from '@tangle-network/agent-eval'
6
6
  import { afterEach, beforeEach, describe, expect, it } from 'vitest'
7
7
  import {
8
8
  defaultGen3Config,
9
+ defaultGen4Config,
10
+ defaultGen5Config,
9
11
  defaultRound4Config,
10
12
  GEN3_IMPROVEMENT_SET,
13
+ GEN3_PARETO_PARENTS,
11
14
  GEN3_SPARE_POOL,
12
15
  resolveSmokeInstance,
13
16
  type OuterLoopConfig,
@@ -17,9 +20,14 @@ import {
17
20
  defaultProposers,
18
21
  fanOutLoopsGenerator,
19
22
  loadAuthorProfile,
23
+ materializeParetoParents,
24
+ mergeAuthorPrompt,
25
+ parentsPromptSection,
20
26
  PROFILES_DIR,
21
27
  proposerBuildPrompt,
28
+ resolveAuthorProfile,
22
29
  sliceFindings,
30
+ type ParetoParentContext,
23
31
  type ProposerSpec,
24
32
  type SmokeRunner,
25
33
  } from './proposer-fanout.mts'
@@ -77,6 +85,134 @@ describe('proposerBuildPrompt', () => {
77
85
  })
78
86
  })
79
87
 
88
+ // ---------------------------------------------------------------------------
89
+ // GEN-4: pinned models, Pareto-parent seeding, and the merge seat.
90
+ // ---------------------------------------------------------------------------
91
+
92
+ const PARENTS: ParetoParentContext[] = [
93
+ {
94
+ commit: 'aaaa111122223333aaaa111122223333aaaa1111',
95
+ label: 'parent-a',
96
+ resolvedInstances: ['pydata__xarray-4687', 'sphinx-doc__sphinx-9658'],
97
+ note: 'mechanical risk scan',
98
+ diff: 'diff --git a/src/worker-evidence.ts b/src/worker-evidence.ts\n+scan',
99
+ },
100
+ {
101
+ commit: 'bbbb111122223333bbbb111122223333bbbb1111',
102
+ label: 'parent-b',
103
+ resolvedInstances: ['django__django-11532'],
104
+ diff: 'diff --git a/extensions/pi/prompts/supervisor-system.md b/...\n+hidden suite',
105
+ },
106
+ ]
107
+
108
+ describe('resolveAuthorProfile (pinned models)', () => {
109
+ it('merges the spec model into the loaded profile as model.default', () => {
110
+ const spec: ProposerSpec = {
111
+ name: 'x',
112
+ profile: 'default-author.profile.json',
113
+ harness: 'claude',
114
+ model: 'claude-fable-5',
115
+ }
116
+ const profile = resolveAuthorProfile(spec)
117
+ expect(profile?.name).toBe('swe-arena-default-author')
118
+ expect(profile?.model?.default).toBe('claude-fable-5')
119
+ })
120
+
121
+ it('synthesizes a minimal named profile for a pinned model without a profile path', () => {
122
+ const profile = resolveAuthorProfile({ name: 'glm-author', harness: 'opencode', model: 'zai-coding-plan/glm-5.2' })
123
+ expect(profile?.name).toBe('glm-author-pinned')
124
+ expect(profile?.model?.default).toBe('zai-coding-plan/glm-5.2')
125
+ })
126
+
127
+ it('is byte-identical to loadAuthorProfile without a pin (gen-3 seats unchanged)', () => {
128
+ const spec: ProposerSpec = { name: 'x', profile: 'default-author.profile.json', harness: 'claude' }
129
+ expect(resolveAuthorProfile(spec)).toEqual(loadAuthorProfile(spec))
130
+ expect(resolveAuthorProfile({ name: 'bare', harness: 'claude' })).toBeUndefined()
131
+ })
132
+ })
133
+
134
+ describe('proposerBuildPrompt with pareto parents', () => {
135
+ it('appends the parents section (evidence + diffs) after the protocol prompt and lens', () => {
136
+ const spec: ProposerSpec = { name: 'x', harness: 'claude', lens: 'Prefer code-path fixes.' }
137
+ const prompt = proposerBuildPrompt({ report: undefined, findings: [] }, spec, PARENTS)
138
+ expect(prompt).toContain('DECLARED CHANGE-SPACE')
139
+ expect(prompt).toContain('PARETO PARENTS')
140
+ expect(prompt.indexOf('YOUR AUTHORING LENS')).toBeLessThan(prompt.indexOf('PARETO PARENTS'))
141
+ expect(prompt).toContain('parent-a (aaaa111122) — resolved: pydata__xarray-4687, sphinx-doc__sphinx-9658')
142
+ expect(prompt).toContain('mechanical risk scan')
143
+ expect(prompt).toContain('+scan')
144
+ expect(prompt).toContain('+hidden suite')
145
+ })
146
+
147
+ it('leaves the prompt untouched when no parents are seeded (gen-3 behavior)', () => {
148
+ const spec: ProposerSpec = { name: 'x', harness: 'claude' }
149
+ expect(proposerBuildPrompt({ report: undefined, findings: [] }, spec)).not.toContain('PARETO PARENTS')
150
+ expect(parentsPromptSection(PARENTS)).toContain('measured evidence')
151
+ })
152
+ })
153
+
154
+ describe('mergeAuthorPrompt', () => {
155
+ const spec: ProposerSpec = { name: 'merge-author', harness: 'claude', merge: true }
156
+
157
+ it('keeps the change-space contract and presents BOTH parent diffs with the coherent-union task', () => {
158
+ const prompt = proposerBuildPrompt({ report: undefined, findings: [] }, spec, PARENTS)
159
+ expect(prompt).toContain('DECLARED CHANGE-SPACE')
160
+ expect(prompt).toContain('MERGE SEAT')
161
+ expect(prompt).toContain('UNION of the')
162
+ expect(prompt).toContain('KEEPING BOTH BEHAVIORS')
163
+ expect(prompt).toContain('=== parent parent-a (aaaa111122) ===')
164
+ expect(prompt).toContain('=== parent parent-b (bbbb111122) ===')
165
+ expect(prompt).toContain('+scan')
166
+ expect(prompt).toContain('+hidden suite')
167
+ // Per-instance evidence rides along for both parents.
168
+ expect(prompt).toContain('resolved: django__django-11532')
169
+ })
170
+
171
+ it('fails loud with fewer than two parents', () => {
172
+ expect(() => mergeAuthorPrompt({ report: undefined, findings: [] }, spec, [PARENTS[0]!])).toThrow(/>=2/)
173
+ expect(() => proposerBuildPrompt({ report: undefined, findings: [] }, spec, [])).toThrow(/>=2/)
174
+ })
175
+ })
176
+
177
+ describe('defaultGen4Config', () => {
178
+ const config = defaultGen4Config()
179
+
180
+ it('seats four proposers (one candidate slot each) with the pinned glm model and the merge seat', () => {
181
+ expect(config.proposers).toHaveLength(4)
182
+ expect(config.populationSize).toBe(4)
183
+ const byName = Object.fromEntries(config.proposers!.map((p) => [p.name, p]))
184
+ expect(byName['claude-author']).toMatchObject({ harness: 'claude', profile: 'default-author.profile.json' })
185
+ expect(byName['claude-author']!.model).toBeUndefined()
186
+ expect(byName['glm-author']).toMatchObject({ harness: 'opencode', model: 'zai-coding-plan/glm-5.2' })
187
+ expect(byName['codex-author']).toMatchObject({ harness: 'codex' })
188
+ expect(byName['merge-author']).toMatchObject({ harness: 'claude', merge: true })
189
+ })
190
+
191
+ it('drops the codex seat (and shrinks the population) when includeCodex is false', () => {
192
+ const noCodex = defaultGen4Config(undefined, { includeCodex: false })
193
+ expect(noCodex.proposers!.map((p) => p.name)).toEqual(['claude-author', 'glm-author', 'merge-author'])
194
+ expect(noCodex.populationSize).toBe(3)
195
+ })
196
+
197
+ it('seeds the gen-3 frontier as pareto parents and points at a fresh gen4 outDir + baseline artifact', () => {
198
+ expect(config.paretoParents).toEqual(GEN3_PARETO_PARENTS)
199
+ expect(config.paretoParents!.map((p) => p.commit.slice(0, 10))).toEqual(['cc0d95584c', 'a7a2a982e5'])
200
+ expect(config.outDir).toContain('gen4')
201
+ expect(config.premeasuredBaselinePath).toContain('gen4')
202
+ expect(config.premeasuredBaselinePath).not.toBe(defaultGen3Config().premeasuredBaselinePath)
203
+ })
204
+
205
+ it('keeps the gen-3 protocol frame: 6-instance set, 2 reps, 1 generation, prefilter, 2-rep holdout', () => {
206
+ expect(config.instances).toEqual([...GEN3_IMPROVEMENT_SET])
207
+ expect(config.repsPerInstance).toBe(2)
208
+ expect(config.generations).toBe(1)
209
+ expect(config.prefilter).toEqual({ enabled: true, smokeInstance: 'cheapest-of-set', requireResolved: false })
210
+ expect(config.holdoutRepsPerInstance).toBe(2)
211
+ expect(config.holdoutBaseline).toBe('measure')
212
+ for (const iid of config.instances) expect(config.holdoutInstances).not.toContain(iid)
213
+ })
214
+ })
215
+
80
216
  describe('loadAuthorProfile', () => {
81
217
  it('loads the committed default-author profile (bare: no prompt, no model)', () => {
82
218
  const profile = loadAuthorProfile({ name: 'a', profile: 'default-author.profile.json', harness: 'claude' })
@@ -360,6 +496,40 @@ describe('fanOutLoopsGenerator', () => {
360
496
  await expect(gen.generate(generatorArgs(1))).rejects.toThrow(/populationSize must equal/)
361
497
  })
362
498
 
499
+ it('materializes pareto parents from real commits (full diff, truncation, missing-commit fail-loud)', async () => {
500
+ await writeFile(join(loopsRepo, 'src.ts'), 'base\nchanged\n')
501
+ await git(['add', '-A'], loopsRepo)
502
+ await git(['commit', '-q', '-m', 'parent change'], loopsRepo)
503
+ const commit = await git(['rev-parse', 'HEAD'], loopsRepo)
504
+ const seed = { commit, label: 'p1', resolvedInstances: ['inst-a'] }
505
+ const [parent] = await materializeParetoParents(loopsRepo, [seed])
506
+ expect(parent).toMatchObject(seed)
507
+ expect(parent!.diff).toContain('parent change')
508
+ expect(parent!.diff).toContain('+changed')
509
+ const [truncated] = await materializeParetoParents(loopsRepo, [seed], 40)
510
+ expect(truncated!.diff).toContain('[... diff truncated at 40 chars ...]')
511
+ await expect(
512
+ materializeParetoParents(loopsRepo, [{ commit: 'deadbeef'.repeat(5), label: 'ghost', resolvedInstances: [] }]),
513
+ ).rejects.toThrow(/not found/)
514
+ })
515
+
516
+ it('refuses a merge seat without >=2 materialized parents', () => {
517
+ const config = baseConfig([{ name: 'merge-author', harness: 'claude', merge: true }])
518
+ expect(() => fanOutLoopsGenerator(config, { author: async () => ({ applied: false, summary: '' }) })).toThrow(
519
+ /merge proposer/,
520
+ )
521
+ expect(() =>
522
+ fanOutLoopsGenerator(config, {
523
+ author: async () => ({ applied: false, summary: '' }),
524
+ parents: [PARENTS[0]!],
525
+ }),
526
+ ).toThrow(/needs >=2|merge proposer/)
527
+ // With two parents the generator constructs.
528
+ expect(() =>
529
+ fanOutLoopsGenerator(config, { author: async () => ({ applied: false, summary: '' }), parents: PARENTS }),
530
+ ).not.toThrow()
531
+ })
532
+
363
533
  it('rejects duplicate proposer names and empty proposer lists', () => {
364
534
  expect(() =>
365
535
  fanOutLoopsGenerator(baseConfig([
@@ -370,3 +540,80 @@ describe('fanOutLoopsGenerator', () => {
370
540
  expect(() => fanOutLoopsGenerator({ ...defaultRound4Config(), loopsRepo, outDir })).toThrow(/empty/)
371
541
  })
372
542
  })
543
+
544
+ // ---------------------------------------------------------------------------
545
+ // GEN-5: config bundle + prompt sections (MAP+TOOLBOX briefing, activation
546
+ // contract) on every seat, merge included.
547
+ // ---------------------------------------------------------------------------
548
+
549
+ describe('defaultGen5Config', () => {
550
+ const config = defaultGen5Config()
551
+
552
+ it('keeps the full gen-4 shape (seats, parents, 2 reps, deferred holdout) under a fresh gen5 outDir', () => {
553
+ expect(config.proposers!.map((p) => p.name)).toEqual(
554
+ defaultGen4Config().proposers!.map((p) => p.name),
555
+ )
556
+ expect(config.populationSize).toBe(config.proposers!.length)
557
+ expect(config.paretoParents).toEqual(GEN3_PARETO_PARENTS)
558
+ expect(config.repsPerInstance).toBe(2)
559
+ expect(config.generations).toBe(1)
560
+ expect(config.holdoutRepsPerInstance).toBe(2)
561
+ expect(config.outDir).toContain('gen5')
562
+ expect(config.premeasuredBaselinePath).toContain('gen5')
563
+ })
564
+
565
+ it('turns on the five gen-5 mechanisms as a unit', () => {
566
+ expect(config.scoreSplit).toEqual({ publicCount: 4 })
567
+ expect(config.briefing).toBe('map-toolbox-v1')
568
+ expect(config.activationGate).toBe(true)
569
+ expect(config.rolloutLedger).toEqual({ enabled: true })
570
+ expect(config.lineage).toBe(true)
571
+ expect(config.priorEvidenceDirs!.some((d) => d.includes('gen4'))).toBe(true)
572
+ })
573
+
574
+ it('drops the codex seat when includeCodex is false (population follows)', () => {
575
+ const noCodex = defaultGen5Config(undefined, { includeCodex: false })
576
+ expect(noCodex.proposers!.map((p) => p.name)).toEqual(['claude-author', 'glm-author', 'merge-author'])
577
+ expect(noCodex.populationSize).toBe(3)
578
+ })
579
+ })
580
+
581
+ describe('gen-5 prompt sections', () => {
582
+ const briefing = {
583
+ indexPath: '/tmp/out/evidence-index.md',
584
+ briefingText: 'TOOLBOX: traces CLI, analysts, AxLLM. PERMISSION: subagents.',
585
+ briefingSource: 'default' as const,
586
+ }
587
+
588
+ it('appends EVIDENCE MAP + briefing + activation contract after the protocol prompt', () => {
589
+ const spec: ProposerSpec = { name: 'x', harness: 'claude' }
590
+ const prompt = proposerBuildPrompt({ report: undefined, findings: [] }, spec, [], {
591
+ briefing,
592
+ activationGate: true,
593
+ })
594
+ expect(prompt).toContain('DECLARED CHANGE-SPACE')
595
+ expect(prompt).toContain('EVIDENCE MAP: /tmp/out/evidence-index.md')
596
+ expect(prompt).toContain('TOOLBOX')
597
+ expect(prompt).toContain('ACTIVATION PREDICATE')
598
+ expect(prompt.indexOf('DECLARED CHANGE-SPACE')).toBeLessThan(prompt.indexOf('EVIDENCE MAP'))
599
+ })
600
+
601
+ it('the merge seat gets the gen-5 sections too', () => {
602
+ const spec: ProposerSpec = { name: 'merge-author', harness: 'claude', merge: true }
603
+ const prompt = proposerBuildPrompt({ report: undefined, findings: [] }, spec, PARENTS, {
604
+ briefing,
605
+ activationGate: true,
606
+ })
607
+ expect(prompt).toContain('MERGE SEAT')
608
+ expect(prompt).toContain('EVIDENCE MAP')
609
+ expect(prompt).toContain('ACTIVATION PREDICATE')
610
+ })
611
+
612
+ it('leaves gen-3/gen-4 prompts byte-identical when no extras are passed', () => {
613
+ const spec: ProposerSpec = { name: 'x', harness: 'claude' }
614
+ const legacy = proposerBuildPrompt({ report: undefined, findings: [] }, spec, PARENTS)
615
+ expect(legacy).not.toContain('EVIDENCE MAP')
616
+ expect(legacy).not.toContain('ACTIVATION PREDICATE')
617
+ expect(proposerBuildPrompt({ report: undefined, findings: [] }, spec, PARENTS, {})).toBe(legacy)
618
+ })
619
+ })
@@ -0,0 +1,177 @@
1
+ /**
2
+ * GEN-4 proposer-model provenance — pin each author seat's MODEL IDENTITY in
3
+ * the run record at t=0, before any author shot fires.
4
+ *
5
+ * Why: a proposer spec may pin a model explicitly (`spec.model` → the harness
6
+ * CLI's `-m` flag via the author profile's `model.default`), but the claude
7
+ * seat deliberately does NOT pass `-m` — the CLI runs on its logged-in
8
+ * account, whose resolved model comes from its own settings. Verified against
9
+ * claude CLI 2.1.217: `--model` IS supported headless (`-p`), but the run's
10
+ * provenance must not depend on a flag we chose not to send. So the capture
11
+ * records what is VERIFIABLE at launch for every configured harness:
12
+ *
13
+ * - `<harness> --version` output (the exact CLI build that authored),
14
+ * - the claude settings default model (`~/.claude/settings.json` `model`),
15
+ * - `codex login status` (the codex seat must be authed or the run refuses
16
+ * at t=0 — a mid-run auth failure would silently kill one candidate slot),
17
+ * - the spec's pinned model id (null when the seat rides the CLI default).
18
+ *
19
+ * The capture FAILS LOUD on a missing/broken harness binary: populationSize
20
+ * must equal proposers.length, so a dead seat cannot be skipped at runtime —
21
+ * the config decides membership, this guard proves it at launch.
22
+ */
23
+
24
+ import { readFileSync } from 'node:fs'
25
+ import { homedir } from 'node:os'
26
+ import { join } from 'node:path'
27
+ import {
28
+ DEFAULT_GEPA_PYTHON,
29
+ isGepaSeat,
30
+ loadGepaMethodFactory,
31
+ probeGepaRuntime,
32
+ type CampaignModuleImport,
33
+ } from './gepa-seat.mts'
34
+ import { run } from './proc.ts'
35
+ import type { ProposerSpec } from './proposer-fanout.mts'
36
+
37
+ export interface ProposerModelProvenance {
38
+ name: string
39
+ /** Absent on a GEN-6 engine seat (see `engine`). */
40
+ harness: ProposerSpec['harness']
41
+ /** Explicit model pin from the spec (threaded as `-m`), or null when the
42
+ * seat runs the CLI's own resolved default. */
43
+ pinnedModel: string | null
44
+ /** `<harness> --version` stdout (trimmed). For a GEN-6 gepa seat this is
45
+ * the bridge python's `--version` output — the runtime that authors. */
46
+ harnessVersion: string
47
+ /** claude seats only: the settings default model the logged-in CLI resolves
48
+ * when no `-m` is passed. Null when unreadable (recorded, never fatal —
49
+ * the version capture is the hard gate). */
50
+ settingsModel: string | null
51
+ /** codex seats only: `codex login status` stdout (trimmed). */
52
+ authStatus: string | null
53
+ merge: boolean
54
+ /** GEN-6 gepa seat: the engine name from the spec. */
55
+ engine?: 'gepa' | 'omni'
56
+ /** GEN-6 gepa seat: the ONE change-space file GEPA optimizes. */
57
+ surface?: string
58
+ /** GEN-6 gepa seat: installed gepa version ('source' for a source pin). */
59
+ gepaVersion?: string
60
+ /** GEN-6 gepa seat: the Python bridge module the seat runs. */
61
+ bridge?: string
62
+ }
63
+
64
+ export interface ProvenanceCaptureRecord {
65
+ schema: 'swe-arena.proposer-provenance.v1'
66
+ capturedAt: string
67
+ proposers: ProposerModelProvenance[]
68
+ }
69
+
70
+ /** Exec seam — test-injectable. Mirrors `run` from proc.ts. */
71
+ export type VersionExec = (
72
+ command: string,
73
+ args: string[],
74
+ ) => Promise<{ code: number | null; stdout: string; stderr: string }>
75
+
76
+ const defaultExec: VersionExec = async (command, args) => {
77
+ const res = await run(command, args, { timeoutMs: 30_000 })
78
+ return { code: res.code, stdout: res.stdout, stderr: res.stderr }
79
+ }
80
+
81
+ /** Read the claude CLI's settings default model. Pure over injected reader. */
82
+ export function claudeSettingsModel(
83
+ readFile: (path: string) => string = (p) => readFileSync(p, 'utf8'),
84
+ settingsPath = join(homedir(), '.claude', 'settings.json'),
85
+ ): string | null {
86
+ try {
87
+ const parsed = JSON.parse(readFile(settingsPath)) as { model?: unknown }
88
+ return typeof parsed.model === 'string' && parsed.model.length > 0 ? parsed.model : null
89
+ } catch {
90
+ return null
91
+ }
92
+ }
93
+
94
+ /** Capture per-proposer model provenance. Throws when any configured harness
95
+ * binary is missing/broken, when a codex seat is not logged in, or — GEN-6 —
96
+ * when a gepa seat's runtime is incomplete: the installed agent-eval must
97
+ * export `gepaOptimizationMethod` and the Python bridge + GEPA engine must
98
+ * import (probeGepaRuntime carries the exact install instructions). A dead
99
+ * seat fails the launch at t=0, never a mid-run candidate slot. */
100
+ export async function captureProposerProvenance(
101
+ proposers: ProposerSpec[],
102
+ deps: {
103
+ exec?: VersionExec
104
+ readSettingsModel?: () => string | null
105
+ importCampaign?: CampaignModuleImport
106
+ } = {},
107
+ ): Promise<ProvenanceCaptureRecord> {
108
+ const exec = deps.exec ?? defaultExec
109
+ const readSettingsModel = deps.readSettingsModel ?? (() => claudeSettingsModel())
110
+ const versionByHarness = new Map<string, string>()
111
+ const authByHarness = new Map<string, string>()
112
+ const gepaBySeat = new Map<string, { pythonVersion: string; gepaVersion: string }>()
113
+ const gepaSeats = proposers.filter(isGepaSeat)
114
+ if (gepaSeats.length > 0) {
115
+ // Node side first: the adapter export (fails loud with upgrade hint).
116
+ await loadGepaMethodFactory(...(deps.importCampaign ? [deps.importCampaign] : []))
117
+ for (const seat of gepaSeats) {
118
+ gepaBySeat.set(seat.name, await probeGepaRuntime(seat.python ?? DEFAULT_GEPA_PYTHON, exec, seat.name))
119
+ }
120
+ }
121
+ const harnesses = [...new Set(proposers.map((p) => p.harness))].filter(
122
+ (h): h is NonNullable<ProposerSpec['harness']> => h !== undefined,
123
+ )
124
+ for (const harness of harnesses) {
125
+ const res = await exec(harness, ['--version'])
126
+ if (res.code !== 0) {
127
+ throw new Error(
128
+ `proposer provenance: '${harness} --version' failed (rc=${res.code}) — the ${harness} seat cannot author. ` +
129
+ `stderr: ${res.stderr.slice(0, 300)}`,
130
+ )
131
+ }
132
+ versionByHarness.set(harness, res.stdout.trim())
133
+ if (harness === 'codex') {
134
+ const auth = await exec('codex', ['login', 'status'])
135
+ const authOut = auth.stdout + auth.stderr
136
+ const authed = /logged in/i.test(authOut) && !/not logged in/i.test(authOut)
137
+ if (auth.code !== 0 || !authed) {
138
+ throw new Error(
139
+ `proposer provenance: codex seat configured but 'codex login status' says not authed ` +
140
+ `(rc=${auth.code}, out=${(auth.stdout + auth.stderr).trim().slice(0, 200)})`,
141
+ )
142
+ }
143
+ authByHarness.set('codex', (auth.stdout + auth.stderr).trim())
144
+ }
145
+ }
146
+ return {
147
+ schema: 'swe-arena.proposer-provenance.v1',
148
+ capturedAt: new Date().toISOString(),
149
+ proposers: proposers.map((spec): ProposerModelProvenance => {
150
+ if (isGepaSeat(spec)) {
151
+ const probe = gepaBySeat.get(spec.name)!
152
+ return {
153
+ name: spec.name,
154
+ harness: undefined,
155
+ pinnedModel: null,
156
+ harnessVersion: probe.pythonVersion,
157
+ settingsModel: null,
158
+ authStatus: null,
159
+ merge: false,
160
+ engine: spec.engine,
161
+ surface: spec.surface,
162
+ gepaVersion: probe.gepaVersion,
163
+ bridge: 'agent_eval_rpc.gepa_bridge',
164
+ }
165
+ }
166
+ return {
167
+ name: spec.name,
168
+ harness: spec.harness,
169
+ pinnedModel: spec.model ?? null,
170
+ harnessVersion: versionByHarness.get(spec.harness!)!,
171
+ settingsModel: spec.harness === 'claude' && !spec.model ? readSettingsModel() : null,
172
+ authStatus: (spec.harness !== undefined ? authByHarness.get(spec.harness) : undefined) ?? null,
173
+ merge: spec.merge === true,
174
+ }
175
+ }),
176
+ }
177
+ }
@@ -0,0 +1,106 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import {
3
+ captureProposerProvenance,
4
+ claudeSettingsModel,
5
+ type VersionExec,
6
+ } from './proposer-provenance.mts'
7
+ import type { ProposerSpec } from './proposer-fanout.mts'
8
+
9
+ const ok = (stdout: string) => ({ code: 0, stdout, stderr: '' })
10
+
11
+ const gen4ish: ProposerSpec[] = [
12
+ { name: 'claude-author', profile: 'default-author.profile.json', harness: 'claude' },
13
+ { name: 'glm-author', harness: 'opencode', model: 'zai-coding-plan/glm-5.2' },
14
+ { name: 'codex-author', harness: 'codex' },
15
+ { name: 'merge-author', profile: 'default-author.profile.json', harness: 'claude', merge: true },
16
+ ]
17
+
18
+ describe('captureProposerProvenance', () => {
19
+ const exec: VersionExec = async (command, args) => {
20
+ if (args[0] === '--version') return ok(`${command}-version 9.9.9`)
21
+ if (command === 'codex' && args[0] === 'login') return ok('Logged in using ChatGPT')
22
+ throw new Error(`unexpected exec ${command} ${args.join(' ')}`)
23
+ }
24
+
25
+ it('records pinned model, harness version, settings model, and codex auth per seat', async () => {
26
+ const record = await captureProposerProvenance(gen4ish, {
27
+ exec,
28
+ readSettingsModel: () => 'claude-fable-5',
29
+ })
30
+ expect(record.schema).toBe('swe-arena.proposer-provenance.v1')
31
+ const byName = Object.fromEntries(record.proposers.map((p) => [p.name, p]))
32
+ // Claude seat: no pin — the CLI's resolved settings model is the record.
33
+ expect(byName['claude-author']).toMatchObject({
34
+ harness: 'claude',
35
+ pinnedModel: null,
36
+ settingsModel: 'claude-fable-5',
37
+ harnessVersion: 'claude-version 9.9.9',
38
+ authStatus: null,
39
+ merge: false,
40
+ })
41
+ // Pinned opencode seat: explicit model id, settings model not consulted.
42
+ expect(byName['glm-author']).toMatchObject({
43
+ harness: 'opencode',
44
+ pinnedModel: 'zai-coding-plan/glm-5.2',
45
+ settingsModel: null,
46
+ harnessVersion: 'opencode-version 9.9.9',
47
+ })
48
+ // Codex seat: version + auth status captured.
49
+ expect(byName['codex-author']).toMatchObject({
50
+ harness: 'codex',
51
+ pinnedModel: null,
52
+ authStatus: 'Logged in using ChatGPT',
53
+ })
54
+ expect(byName['merge-author']!.merge).toBe(true)
55
+ })
56
+
57
+ it('fails loud when a configured harness binary is missing', async () => {
58
+ const broken: VersionExec = async (command, args) =>
59
+ command === 'codex' ? { code: 127, stdout: '', stderr: 'not found' } : exec(command, args)
60
+ await expect(
61
+ captureProposerProvenance(gen4ish, { exec: broken, readSettingsModel: () => null }),
62
+ ).rejects.toThrow(/'codex --version' failed/)
63
+ })
64
+
65
+ it('fails loud when the codex seat is not logged in', async () => {
66
+ const loggedOut: VersionExec = async (command, args) => {
67
+ if (args[0] === '--version') return ok(`${command} 1.0.0`)
68
+ return ok('Not logged in')
69
+ }
70
+ await expect(
71
+ captureProposerProvenance([{ name: 'codex-author', harness: 'codex' }], {
72
+ exec: loggedOut,
73
+ readSettingsModel: () => null,
74
+ }),
75
+ ).rejects.toThrow(/not authed/)
76
+ })
77
+
78
+ it('runs one version probe per harness, not per proposer', async () => {
79
+ const calls: string[] = []
80
+ const counting: VersionExec = async (command, args) => {
81
+ calls.push(`${command} ${args.join(' ')}`)
82
+ if (args[0] === '--version') return ok(`${command} 1`)
83
+ return ok('Logged in using ChatGPT')
84
+ }
85
+ await captureProposerProvenance(gen4ish, { exec: counting, readSettingsModel: () => null })
86
+ expect(calls.filter((c) => c === 'claude --version')).toHaveLength(1)
87
+ expect(calls.filter((c) => c === 'codex --version')).toHaveLength(1)
88
+ expect(calls.filter((c) => c === 'codex login status')).toHaveLength(1)
89
+ })
90
+ })
91
+
92
+ describe('claudeSettingsModel', () => {
93
+ it('reads the settings model field', () => {
94
+ expect(claudeSettingsModel(() => JSON.stringify({ model: 'claude-fable-5' }), '/x')).toBe('claude-fable-5')
95
+ })
96
+
97
+ it('returns null on unreadable/missing/blank settings', () => {
98
+ expect(
99
+ claudeSettingsModel(() => {
100
+ throw new Error('ENOENT')
101
+ }, '/x'),
102
+ ).toBeNull()
103
+ expect(claudeSettingsModel(() => JSON.stringify({}), '/x')).toBeNull()
104
+ expect(claudeSettingsModel(() => JSON.stringify({ model: '' }), '/x')).toBeNull()
105
+ })
106
+ })