@tangle-network/agent-eval 0.221.8 → 0.222.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 (579) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/adapters/http.d.ts +3 -5
  3. package/dist/adapters/http.d.ts.map +1 -1
  4. package/dist/adapters/http.js +1 -2
  5. package/dist/{adversarial-smnADNFS.d.ts → adversarial-DnQQFqTR.d.ts} +1 -3
  6. package/dist/adversarial-DnQQFqTR.d.ts.map +1 -0
  7. package/dist/{agent-profile-CNmwfaqq.d.ts → agent-profile-CoD1Dotf.d.ts} +4 -10
  8. package/dist/agent-profile-CoD1Dotf.d.ts.map +1 -0
  9. package/dist/agent-profile-Dngk3LZ0.js +153 -0
  10. package/dist/agent-profile-Dngk3LZ0.js.map +1 -0
  11. package/dist/{agent-profile-cell-BcpFbNd5.d.ts → agent-profile-cell-3kYxUsK2.d.ts} +3 -5
  12. package/dist/agent-profile-cell-3kYxUsK2.d.ts.map +1 -0
  13. package/dist/{agent-profile-cell-B1V1gUZs.js → agent-profile-cell-CT5JYueM.js} +5 -7
  14. package/dist/{agent-profile-cell-B1V1gUZs.js.map → agent-profile-cell-CT5JYueM.js.map} +1 -1
  15. package/dist/{agreement-irr-BhAqjluA.js → agreement-irr-BTjDN0i6.js} +4 -5
  16. package/dist/{agreement-irr-BhAqjluA.js.map → agreement-irr-BTjDN0i6.js.map} +1 -1
  17. package/dist/analyst/index.d.ts +95 -159
  18. package/dist/analyst/index.d.ts.map +1 -1
  19. package/dist/analyst/index.js +28 -39
  20. package/dist/analyst/index.js.map +1 -1
  21. package/dist/{analyze-runs-DfX6dHP0.d.ts → analyze-runs-C-pP1sK9.d.ts} +7 -13
  22. package/dist/analyze-runs-C-pP1sK9.d.ts.map +1 -0
  23. package/dist/{analyze-runs-CHmsykNJ.js → analyze-runs-CTheASYV.js} +23 -32
  24. package/dist/{analyze-runs-CHmsykNJ.js.map → analyze-runs-CTheASYV.js.map} +1 -1
  25. package/dist/{attribute-vocabulary-CcXqHODT.d.ts → attribute-vocabulary-5oo8ykIx.d.ts} +2 -4
  26. package/dist/attribute-vocabulary-5oo8ykIx.d.ts.map +1 -0
  27. package/dist/authenticity/index.d.ts +0 -2
  28. package/dist/authenticity/index.d.ts.map +1 -1
  29. package/dist/authenticity/index.js +1 -2
  30. package/dist/{benchmark-command-Cnjfo0Zh.js → benchmark-command-jYWR2gya.js} +61 -94
  31. package/dist/benchmark-command-jYWR2gya.js.map +1 -0
  32. package/dist/benchmarks/index.d.ts +5 -15
  33. package/dist/benchmarks/index.d.ts.map +1 -1
  34. package/dist/benchmarks/index.js +27 -38
  35. package/dist/benchmarks/index.js.map +1 -1
  36. package/dist/{bounded-process-Cj9YjXbE.js → bounded-process-BZrWXIKW.js} +2 -3
  37. package/dist/{bounded-process-Cj9YjXbE.js.map → bounded-process-BZrWXIKW.js.map} +1 -1
  38. package/dist/builder-eval/index.d.ts +5 -14
  39. package/dist/builder-eval/index.d.ts.map +1 -1
  40. package/dist/builder-eval/index.js +11 -17
  41. package/dist/builder-eval/index.js.map +1 -1
  42. package/dist/{calibration-CTwxpJ-t.js → calibration-6usfVYYo.js} +4 -5
  43. package/dist/{calibration-CTwxpJ-t.js.map → calibration-6usfVYYo.js.map} +1 -1
  44. package/dist/campaign/index.d.ts +9 -9
  45. package/dist/campaign/index.js +15 -14
  46. package/dist/{campaign-uddTlFg5.js → campaign-ddr1N3yD.js} +61 -58
  47. package/dist/campaign-ddr1N3yD.js.map +1 -0
  48. package/dist/{campaign-evidence-DunzcJGv.js → campaign-evidence-DN8rWuBj.js} +20 -322
  49. package/dist/campaign-evidence-DN8rWuBj.js.map +1 -0
  50. package/dist/{canonical-Dq2hOQ8L.js → canonical-CicJlINA.js} +3 -4
  51. package/dist/{canonical-Dq2hOQ8L.js.map → canonical-CicJlINA.js.map} +1 -1
  52. package/dist/{canonical-CFpojCN5.d.ts → canonical-gLeHiqzd.d.ts} +2 -4
  53. package/dist/canonical-gLeHiqzd.d.ts.map +1 -0
  54. package/dist/{cell-spend-DEWR3nj-.js → cell-spend-zxmzg4GH.js} +3 -4
  55. package/dist/{cell-spend-DEWR3nj-.js.map → cell-spend-zxmzg4GH.js.map} +1 -1
  56. package/dist/{chat-client-BNATB3rJ.js → chat-client-CO3uB33i.js} +3 -4
  57. package/dist/{chat-client-BNATB3rJ.js.map → chat-client-CO3uB33i.js.map} +1 -1
  58. package/dist/{chat-json-call-BzWYp18J.js → chat-json-call-8yUv4LFO.js} +4 -5
  59. package/dist/{chat-json-call-BzWYp18J.js.map → chat-json-call-8yUv4LFO.js.map} +1 -1
  60. package/dist/{claim-BPVuyHuy.js → claim-Dod_mjk3.js} +5 -6
  61. package/dist/{claim-BPVuyHuy.js.map → claim-Dod_mjk3.js.map} +1 -1
  62. package/dist/cli.js +179 -23
  63. package/dist/cli.js.map +1 -1
  64. package/dist/{client-hwo3cJjR.d.ts → client-BIFwUg7I.d.ts} +6 -12
  65. package/dist/client-BIFwUg7I.d.ts.map +1 -0
  66. package/dist/{cluster-bootstrap-DEwwhl0C.js → cluster-bootstrap-SbaeM44s.js} +4 -5
  67. package/dist/{cluster-bootstrap-DEwwhl0C.js.map → cluster-bootstrap-SbaeM44s.js.map} +1 -1
  68. package/dist/completion-verifier-7KEfroqx.d.ts +168 -0
  69. package/dist/completion-verifier-7KEfroqx.d.ts.map +1 -0
  70. package/dist/{completion-verifier-asaV1nSj.js → completion-verifier-rqbMh5-4.js} +9 -160
  71. package/dist/completion-verifier-rqbMh5-4.js.map +1 -0
  72. package/dist/contract/index.d.ts +13 -13
  73. package/dist/contract/index.js +41 -60
  74. package/dist/contract/index.js.map +1 -1
  75. package/dist/{cost-ledger-BGZB6yY2.js → cost-ledger-CS8R3IZj.js} +10 -17
  76. package/dist/{cost-ledger-BGZB6yY2.js.map → cost-ledger-CS8R3IZj.js.map} +1 -1
  77. package/dist/{cost-ledger-C1W3ICmP.d.ts → cost-ledger-Czro9wmo.d.ts} +1 -5
  78. package/dist/cost-ledger-Czro9wmo.d.ts.map +1 -0
  79. package/dist/{dataset-DQqhOCPt.d.ts → dataset-DThC1S6G.d.ts} +1 -3
  80. package/dist/dataset-DThC1S6G.d.ts.map +1 -0
  81. package/dist/{decision-point-0nJubuoM.js → decision-point-lhMgODOR.js} +14 -18
  82. package/dist/{decision-point-0nJubuoM.js.map → decision-point-lhMgODOR.js.map} +1 -1
  83. package/dist/{deep-freeze-CurcOQg3.js → deep-freeze-CK8-2W7p.js} +2 -3
  84. package/dist/{deep-freeze-CurcOQg3.js.map → deep-freeze-CK8-2W7p.js.map} +1 -1
  85. package/dist/{default-registry-CLG5YqGS.d.ts → default-registry-B1DstPYg.d.ts} +53 -61
  86. package/dist/default-registry-B1DstPYg.d.ts.map +1 -0
  87. package/dist/{default-registry-BBTDgkDM.js → default-registry-C1tPEjZ4.js} +29 -45
  88. package/dist/{default-registry-BBTDgkDM.js.map → default-registry-C1tPEjZ4.js.map} +1 -1
  89. package/dist/{define-agent-eval-CCbT7Kfr.js → define-agent-eval-BLoP4Lf9.js} +15 -18
  90. package/dist/{define-agent-eval-CCbT7Kfr.js.map → define-agent-eval-BLoP4Lf9.js.map} +1 -1
  91. package/dist/{define-agent-eval-JKt3gMQr.d.ts → define-agent-eval-CAffiFbN.d.ts} +19 -27
  92. package/dist/define-agent-eval-CAffiFbN.d.ts.map +1 -0
  93. package/dist/{descriptive-CVNy48rR.js → descriptive-cPwITVfy.js} +30 -8
  94. package/dist/descriptive-cPwITVfy.js.map +1 -0
  95. package/dist/diagnosis/index.d.ts +5 -15
  96. package/dist/diagnosis/index.d.ts.map +1 -1
  97. package/dist/diagnosis/index.js +13 -19
  98. package/dist/diagnosis/index.js.map +1 -1
  99. package/dist/{dspy-rlm-engine-DN1p_5jx.js → dspy-rlm-engine-jDiWkul6.js} +7 -10
  100. package/dist/{dspy-rlm-engine-DN1p_5jx.js.map → dspy-rlm-engine-jDiWkul6.js.map} +1 -1
  101. package/dist/{emitter-DbMXUIVP.js → emitter-DhQ65mza.js} +3 -4
  102. package/dist/{emitter-DbMXUIVP.js.map → emitter-DhQ65mza.js.map} +1 -1
  103. package/dist/{emitter-DABYYTcH.d.ts → emitter-mAXC5PSN.d.ts} +3 -5
  104. package/dist/emitter-mAXC5PSN.d.ts.map +1 -0
  105. package/dist/{engine-dtRVeuQs.d.ts → engine-CaHaCc3W.d.ts} +10 -18
  106. package/dist/engine-CaHaCc3W.d.ts.map +1 -0
  107. package/dist/{equal-terms-DbPGcVtI.js → equal-terms-K11VHmR3.js} +3 -4
  108. package/dist/{equal-terms-DbPGcVtI.js.map → equal-terms-K11VHmR3.js.map} +1 -1
  109. package/dist/{errors-BcOs5MKW.js → errors-DeEEV9Vx.js} +2 -3
  110. package/dist/{errors-BcOs5MKW.js.map → errors-DeEEV9Vx.js.map} +1 -1
  111. package/dist/{errors-DEE6u6ot.d.ts → errors-E9I2hldP.d.ts} +1 -3
  112. package/dist/errors-E9I2hldP.d.ts.map +1 -0
  113. package/dist/{eval-campaign-DoX5vz3E.js → eval-campaign-Cgixrvf7.js} +8 -9
  114. package/dist/{eval-campaign-DoX5vz3E.js.map → eval-campaign-Cgixrvf7.js.map} +1 -1
  115. package/dist/{evaluation-wdGyZ7jV.js → evaluation-B8H3GYej.js} +4 -6
  116. package/dist/{evaluation-wdGyZ7jV.js.map → evaluation-B8H3GYej.js.map} +1 -1
  117. package/dist/{evaluation-DblGquCB.d.ts → evaluation-BPqUvZ66.d.ts} +4 -6
  118. package/dist/evaluation-BPqUvZ66.d.ts.map +1 -0
  119. package/dist/evaluation.d.ts +1 -1
  120. package/dist/evaluation.js +1 -2
  121. package/dist/{exact-types-Do63KoKn.d.ts → exact-types-D98BKpxo.d.ts} +8 -10
  122. package/dist/exact-types-D98BKpxo.d.ts.map +1 -0
  123. package/dist/{exec-CpbtOXVt.js → exec-C0_AkLUv.js} +3 -5
  124. package/dist/{exec-CpbtOXVt.js.map → exec-C0_AkLUv.js.map} +1 -1
  125. package/dist/{execution-tracks-CpgFPpS5.js → execution-tracks-DaDXYwAq.js} +2 -3
  126. package/dist/{execution-tracks-CpgFPpS5.js.map → execution-tracks-DaDXYwAq.js.map} +1 -1
  127. package/dist/experiment/index.d.ts +9 -37
  128. package/dist/experiment/index.d.ts.map +1 -1
  129. package/dist/experiment/index.js +29 -40
  130. package/dist/experiment/index.js.map +1 -1
  131. package/dist/{exporters-Dk3oEbK_.d.ts → exporters-B5Ze_RKh.d.ts} +4 -4
  132. package/dist/exporters-B5Ze_RKh.d.ts.map +1 -0
  133. package/dist/{exporters-DWvM16LE.js → exporters-ByLcILYU.js} +23 -5
  134. package/dist/exporters-ByLcILYU.js.map +1 -0
  135. package/dist/{external-optimizer-process-DEzJ2CGX.js → external-optimizer-process-BRVmaDFe.js} +5 -6
  136. package/dist/{external-optimizer-process-DEzJ2CGX.js.map → external-optimizer-process-BRVmaDFe.js.map} +1 -1
  137. package/dist/{external-optimizer-subprocess-B_ukPtRD.js → external-optimizer-subprocess-U616hV_l.js} +24 -37
  138. package/dist/{external-optimizer-subprocess-B_ukPtRD.js.map → external-optimizer-subprocess-U616hV_l.js.map} +1 -1
  139. package/dist/{extract-usage-BZLU01kR.js → extract-usage-ISFqhfDz.js} +2 -3
  140. package/dist/{extract-usage-BZLU01kR.js.map → extract-usage-ISFqhfDz.js.map} +1 -1
  141. package/dist/{failure-cluster-DN0t63Z0.d.ts → failure-cluster-DOoa7CBg.d.ts} +3 -7
  142. package/dist/failure-cluster-DOoa7CBg.d.ts.map +1 -0
  143. package/dist/{failure-taxonomy-Bx5oWqaW.js → failure-taxonomy-9eQfXKoW.js} +2 -3
  144. package/dist/{failure-taxonomy-Bx5oWqaW.js.map → failure-taxonomy-9eQfXKoW.js.map} +1 -1
  145. package/dist/{feedback-trajectory-CYVJXolG.d.ts → feedback-trajectory-SBGncrCP.d.ts} +7 -13
  146. package/dist/feedback-trajectory-SBGncrCP.d.ts.map +1 -0
  147. package/dist/{finding-composition-8n0fFgVI.js → finding-composition-DlvE1Qul.js} +4 -6
  148. package/dist/{finding-composition-8n0fFgVI.js.map → finding-composition-DlvE1Qul.js.map} +1 -1
  149. package/dist/{findings-store-Bg4sdS-e.js → findings-store-B75Dspaq.js} +11 -14
  150. package/dist/{findings-store-Bg4sdS-e.js.map → findings-store-B75Dspaq.js.map} +1 -1
  151. package/dist/fuzz.d.ts +3 -17
  152. package/dist/fuzz.d.ts.map +1 -1
  153. package/dist/fuzz.js +30 -29
  154. package/dist/fuzz.js.map +1 -1
  155. package/dist/{hf-dataset-CKxIJQba.js → hf-dataset-DPVQXW5n.js} +362 -21
  156. package/dist/hf-dataset-DPVQXW5n.js.map +1 -0
  157. package/dist/hosted/index.d.ts +2 -6
  158. package/dist/hosted/index.d.ts.map +1 -1
  159. package/dist/hosted/index.js +1 -2
  160. package/dist/{index-CalAsXMR.d.ts → index-B1Bm9oJA.d.ts} +3 -15
  161. package/dist/index-B1Bm9oJA.d.ts.map +1 -0
  162. package/dist/{index-CdEVr8-O.d.ts → index-B7v2QHlD.d.ts} +24 -299
  163. package/dist/index-B7v2QHlD.d.ts.map +1 -0
  164. package/dist/{index-CTIRz-AB.d.ts → index-CUjeTDPv.d.ts} +14 -36
  165. package/dist/index-CUjeTDPv.d.ts.map +1 -0
  166. package/dist/{index-CfJULcW5.d.ts → index-DAk2quYu.d.ts} +18 -38
  167. package/dist/index-DAk2quYu.d.ts.map +1 -0
  168. package/dist/{index-D7fmC-1K.d.ts → index-DUn0GNiZ.d.ts} +183 -36
  169. package/dist/index-DUn0GNiZ.d.ts.map +1 -0
  170. package/dist/{index-CHxwfW5g.d.ts → index-DwUGehqX.d.ts} +3 -9
  171. package/dist/index-DwUGehqX.d.ts.map +1 -0
  172. package/dist/{index-jnuFLxOs.d.ts → index-aDPVYBIM.d.ts} +11 -39
  173. package/dist/index-aDPVYBIM.d.ts.map +1 -0
  174. package/dist/index.d.ts +55 -188
  175. package/dist/index.d.ts.map +1 -1
  176. package/dist/index.js +122 -195
  177. package/dist/index.js.map +1 -1
  178. package/dist/{integrity-D-s2iHiT.js → integrity-B1V6klyO.js} +12 -363
  179. package/dist/integrity-B1V6klyO.js.map +1 -0
  180. package/dist/{integrity-D9lBnv_K.d.ts → integrity-BAdVzT8u.d.ts} +4 -6
  181. package/dist/integrity-BAdVzT8u.d.ts.map +1 -0
  182. package/dist/{integrity-W4CADcFc.js → integrity-DOHt1mwU.js} +3 -4
  183. package/dist/{integrity-W4CADcFc.js.map → integrity-DOHt1mwU.js.map} +1 -1
  184. package/dist/{internal-BTK91Bqt.js → internal-v6XfOeJW.js} +6 -8
  185. package/dist/{internal-BTK91Bqt.js.map → internal-v6XfOeJW.js.map} +1 -1
  186. package/dist/{interval-Dq9gt7jx.js → interval-Bd2f4CRT.js} +6 -8
  187. package/dist/{interval-Dq9gt7jx.js.map → interval-Bd2f4CRT.js.map} +1 -1
  188. package/dist/{interval-ohuOJurX.d.ts → interval-CWyxqDpE.d.ts} +1 -5
  189. package/dist/interval-CWyxqDpE.d.ts.map +1 -0
  190. package/dist/{journal-C7om8Gum.js → journal-C1uLJi0w.js} +115 -121
  191. package/dist/{journal-C7om8Gum.js.map → journal-C1uLJi0w.js.map} +1 -1
  192. package/dist/{json-BhdsJaOQ.js → json-DtvZNAU9.js} +4 -6
  193. package/dist/{json-BhdsJaOQ.js.map → json-DtvZNAU9.js.map} +1 -1
  194. package/dist/json-recovery-DK4MDm5r.js +296 -0
  195. package/dist/json-recovery-DK4MDm5r.js.map +1 -0
  196. package/dist/{judge-calibration-BkXMIWA4.js → judge-calibration-DGqlfWW8.js} +5 -6
  197. package/dist/{judge-calibration-BkXMIWA4.js.map → judge-calibration-DGqlfWW8.js.map} +1 -1
  198. package/dist/{judge-calibration-DFtEMlde.d.ts → judge-calibration-DnrbQaXI.d.ts} +1 -3
  199. package/dist/judge-calibration-DnrbQaXI.d.ts.map +1 -0
  200. package/dist/{judge-gate-BVvmP00P.js → judge-gate-C2BCOt-M.js} +8 -12
  201. package/dist/{judge-gate-BVvmP00P.js.map → judge-gate-C2BCOt-M.js.map} +1 -1
  202. package/dist/judges-BLxg5p8E.js +20 -0
  203. package/dist/judges-BLxg5p8E.js.map +1 -0
  204. package/dist/{kind-factory-Dl0PmNQL.js → kind-factory-VKysp1ds.js} +23 -39
  205. package/dist/{kind-factory-Dl0PmNQL.js.map → kind-factory-VKysp1ds.js.map} +1 -1
  206. package/dist/ledger-core/index.d.ts +2 -2
  207. package/dist/ledger-core/index.js +3 -3
  208. package/dist/ledger-core/lock-holder.d.ts +1 -1
  209. package/dist/ledger-core/lock-holder.js +1 -2
  210. package/dist/{ledger-core-CAxUdDk0.js → ledger-core-CfT-FzPf.js} +5 -6
  211. package/dist/{ledger-core-CAxUdDk0.js.map → ledger-core-CfT-FzPf.js.map} +1 -1
  212. package/dist/{llm-client-b1ysZVIU.js → llm-client-kJ9EOqjt.js} +22 -30
  213. package/dist/{llm-client-b1ysZVIU.js.map → llm-client-kJ9EOqjt.js.map} +1 -1
  214. package/dist/{llm-judge-Cybq29bL.js → llm-judge-cgbhTKQp.js} +108 -164
  215. package/dist/llm-judge-cgbhTKQp.js.map +1 -0
  216. package/dist/{lock-holder-DaJbfpci.d.ts → lock-holder-DoxlZFkQ.d.ts} +1 -3
  217. package/dist/lock-holder-DoxlZFkQ.d.ts.map +1 -0
  218. package/dist/matrix/index.d.ts +3 -3
  219. package/dist/matrix/index.js +2 -2
  220. package/dist/{matrix-DtkZLD_3.d.ts → matrix-CBUzIZs4.d.ts} +4 -12
  221. package/dist/matrix-CBUzIZs4.d.ts.map +1 -0
  222. package/dist/{matrix-B8l-Nsxd.js → matrix-CgpX8wdm.js} +8 -13
  223. package/dist/matrix-CgpX8wdm.js.map +1 -0
  224. package/dist/{mean-BbA_JCzW.js → mean-CdDYG-us.js} +6 -9
  225. package/dist/{mean-BbA_JCzW.js.map → mean-CdDYG-us.js.map} +1 -1
  226. package/dist/meta-eval/index.d.ts +3 -3
  227. package/dist/meta-eval/index.js +17 -21
  228. package/dist/meta-eval/index.js.map +1 -1
  229. package/dist/{metrics-BKaPBtIG.js → metrics-DNCAUtuB.js} +2 -3
  230. package/dist/{metrics-BKaPBtIG.js.map → metrics-DNCAUtuB.js.map} +1 -1
  231. package/dist/{mint-CbdwjTPW.js → mint-D9ZysYtY.js} +7 -8
  232. package/dist/{mint-CbdwjTPW.js.map → mint-D9ZysYtY.js.map} +1 -1
  233. package/dist/{multi-layer-verifier-DEgMUk6v.d.ts → multi-layer-verifier-lM4aVN78.d.ts} +2 -4
  234. package/dist/multi-layer-verifier-lM4aVN78.d.ts.map +1 -0
  235. package/dist/{multiplicity-Sg0U7h8j.js → multiplicity-DAd4xaDC.js} +3 -4
  236. package/dist/{multiplicity-Sg0U7h8j.js.map → multiplicity-DAd4xaDC.js.map} +1 -1
  237. package/dist/{multiplicity-DIWHvysC.d.ts → multiplicity-D_SEsc5j.d.ts} +1 -3
  238. package/dist/multiplicity-D_SEsc5j.d.ts.map +1 -0
  239. package/dist/multishot/golden/index.d.ts +1 -17
  240. package/dist/multishot/golden/index.d.ts.map +1 -1
  241. package/dist/multishot/golden/index.js +10 -17
  242. package/dist/multishot/golden/index.js.map +1 -1
  243. package/dist/multishot/index.d.ts +2 -10
  244. package/dist/multishot/index.d.ts.map +1 -1
  245. package/dist/multishot/index.js +11 -18
  246. package/dist/multishot/index.js.map +1 -1
  247. package/dist/{nonnegative-number-DvdMxg_f.js → nonnegative-number-lEYbOsuh.js} +2 -3
  248. package/dist/{nonnegative-number-DvdMxg_f.js.map → nonnegative-number-lEYbOsuh.js.map} +1 -1
  249. package/dist/openapi.json +1 -1
  250. package/dist/{otel-spans-64hmQqON.js → otel-spans-BsGzTWIK.js} +5 -6
  251. package/dist/{otel-spans-64hmQqON.js.map → otel-spans-BsGzTWIK.js.map} +1 -1
  252. package/dist/{otlp-attributes-D9ptWaIJ.js → otlp-attributes-Boeb7gtH.js} +2 -3
  253. package/dist/{otlp-attributes-D9ptWaIJ.js.map → otlp-attributes-Boeb7gtH.js.map} +1 -1
  254. package/dist/{outcome-observations-FLmRpgYa.js → outcome-observations-D4snOtUb.js} +4 -5
  255. package/dist/{outcome-observations-FLmRpgYa.js.map → outcome-observations-D4snOtUb.js.map} +1 -1
  256. package/dist/{outcome-store-DUcMj-3D.js → outcome-store-TarrcfHG.js} +2 -3
  257. package/dist/{outcome-store-DUcMj-3D.js.map → outcome-store-TarrcfHG.js.map} +1 -1
  258. package/dist/{package-version-D7lQHt_-.js → package-version-CJl_pY9W.js} +2 -3
  259. package/dist/{package-version-D7lQHt_-.js.map → package-version-CJl_pY9W.js.map} +1 -1
  260. package/dist/{paired-arms-B2ttLc0_.js → paired-arms-D-54hO-k.js} +10 -14
  261. package/dist/{paired-arms-B2ttLc0_.js.map → paired-arms-D-54hO-k.js.map} +1 -1
  262. package/dist/{paired-binary-B_nejA44.js → paired-binary-BR0nwHOA.js} +3 -4
  263. package/dist/{paired-binary-B_nejA44.js.map → paired-binary-BR0nwHOA.js.map} +1 -1
  264. package/dist/{paired-promotion-decision-CQMJ5xGN.d.ts → paired-promotion-decision-BDnqepZ1.d.ts} +1 -5
  265. package/dist/paired-promotion-decision-BDnqepZ1.d.ts.map +1 -0
  266. package/dist/{paired-promotion-decision-D0SHb-ZL.js → paired-promotion-decision-FGvHA4p_.js} +5 -7
  267. package/dist/{paired-promotion-decision-D0SHb-ZL.js.map → paired-promotion-decision-FGvHA4p_.js.map} +1 -1
  268. package/dist/{pareto-BiBnQXAE.js → pareto-B9udAt2i.js} +28 -50
  269. package/dist/pareto-B9udAt2i.js.map +1 -0
  270. package/dist/pipelines/index.d.ts +5 -11
  271. package/dist/pipelines/index.d.ts.map +1 -1
  272. package/dist/pipelines/index.js +6 -8
  273. package/dist/pipelines/index.js.map +1 -1
  274. package/dist/{power-and-mde-CQX-0weG.js → power-and-mde-ClI6RWw4.js} +4 -5
  275. package/dist/{power-and-mde-CQX-0weG.js.map → power-and-mde-ClI6RWw4.js.map} +1 -1
  276. package/dist/{predicate-FdKmElA_.js → predicate-BYHA4MBn.js} +2 -3
  277. package/dist/{predicate-FdKmElA_.js.map → predicate-BYHA4MBn.js.map} +1 -1
  278. package/dist/{prime-bridge-transport-6feEglLf.d.ts → prime-bridge-transport-Cfqir_Im.d.ts} +1 -3
  279. package/dist/prime-bridge-transport-Cfqir_Im.d.ts.map +1 -0
  280. package/dist/{prime-bridge-transport-Z3cpKGoV.js → prime-bridge-transport-Csd5SQg7.js} +2 -3
  281. package/dist/{prime-bridge-transport-Z3cpKGoV.js.map → prime-bridge-transport-Csd5SQg7.js.map} +1 -1
  282. package/dist/{prime-protocol-BGxjfhM4.d.ts → prime-protocol-COFkxas6.d.ts} +4 -8
  283. package/dist/prime-protocol-COFkxas6.d.ts.map +1 -0
  284. package/dist/{prime-protocol-BFgGrEMP.js → prime-protocol-CrhpXRz9.js} +4 -6
  285. package/dist/{prime-protocol-BFgGrEMP.js.map → prime-protocol-CrhpXRz9.js.map} +1 -1
  286. package/dist/profile-cell.d.ts +1 -1
  287. package/dist/profile-cell.js +1 -2
  288. package/dist/{promotion-gate-CkVZHagC.d.ts → promotion-gate-CixshGI8.d.ts} +5 -11
  289. package/dist/promotion-gate-CixshGI8.d.ts.map +1 -0
  290. package/dist/{promotion-policy-6A8osGr_.js → promotion-policy-CBYeD4zi.js} +5 -6
  291. package/dist/{promotion-policy-6A8osGr_.js.map → promotion-policy-CBYeD4zi.js.map} +1 -1
  292. package/dist/{proposal-findings-DqLUWsAG.js → proposal-findings-WFQrxnfe.js} +3 -4
  293. package/dist/{proposal-findings-DqLUWsAG.js.map → proposal-findings-WFQrxnfe.js.map} +1 -1
  294. package/dist/{quantile--0yb07pD.js → quantile-CncXP-Ss.js} +2 -3
  295. package/dist/{quantile--0yb07pD.js.map → quantile-CncXP-Ss.js.map} +1 -1
  296. package/dist/{query-B_RZ36an.js → query-CGXzO9d4.js} +5 -6
  297. package/dist/{query-B_RZ36an.js.map → query-CGXzO9d4.js.map} +1 -1
  298. package/dist/{query-Cmv_U8vf.d.ts → query-UD0B08Sb.d.ts} +4 -6
  299. package/dist/query-UD0B08Sb.d.ts.map +1 -0
  300. package/dist/{random-DGEyr3zG.d.ts → random-BN150Q_X.d.ts} +1 -5
  301. package/dist/random-BN150Q_X.d.ts.map +1 -0
  302. package/dist/{random-DDDcC7YU.js → random-DrzcgC7F.js} +3 -4
  303. package/dist/{random-DDDcC7YU.js.map → random-DrzcgC7F.js.map} +1 -1
  304. package/dist/{raw-provider-sink-75w4FWBj.js → raw-provider-sink-DDLkP_eF.js} +3 -4
  305. package/dist/{raw-provider-sink-75w4FWBj.js.map → raw-provider-sink-DDLkP_eF.js.map} +1 -1
  306. package/dist/{record-id-DUgsK5qp.js → record-id-CWZXFh58.js} +2 -3
  307. package/dist/{record-id-DUgsK5qp.js.map → record-id-CWZXFh58.js.map} +1 -1
  308. package/dist/{redact-DXdlFb_U.d.ts → redact-C_wzC4c_.d.ts} +1 -3
  309. package/dist/redact-C_wzC4c_.d.ts.map +1 -0
  310. package/dist/{redact-mtkTiJVk.js → redact-D6APJS1d.js} +3 -5
  311. package/dist/{redact-mtkTiJVk.js.map → redact-D6APJS1d.js.map} +1 -1
  312. package/dist/{registry-BcdJmyoU.d.ts → registry-dhdDoAV8.d.ts} +5 -11
  313. package/dist/registry-dhdDoAV8.d.ts.map +1 -0
  314. package/dist/{release-confidence-CYIFH-fp.js → release-confidence-CTUJz5mM.js} +10 -16
  315. package/dist/release-confidence-CTUJz5mM.js.map +1 -0
  316. package/dist/{render-BhJqXoBH.js → render-pfAZ7IR4.js} +266 -33
  317. package/dist/render-pfAZ7IR4.js.map +1 -0
  318. package/dist/{reporting-html-Kvlc8oMt.js → reporting-html-DMXIjATy.js} +2 -3
  319. package/dist/{reporting-html-Kvlc8oMt.js.map → reporting-html-DMXIjATy.js.map} +1 -1
  320. package/dist/reporting.d.ts +6 -6
  321. package/dist/reporting.js +7 -7
  322. package/dist/{researcher-DKWtoMWk.d.ts → researcher-CLnNJ7Or.d.ts} +8 -12
  323. package/dist/researcher-CLnNJ7Or.d.ts.map +1 -0
  324. package/dist/{reward-nw2xZGZG.js → reward-P0VD_Aft.js} +2 -3
  325. package/dist/{reward-nw2xZGZG.js.map → reward-P0VD_Aft.js.map} +1 -1
  326. package/dist/{reward-BeUgVVC_.d.ts → reward-ST4PXNXF.d.ts} +2 -4
  327. package/dist/reward-ST4PXNXF.d.ts.map +1 -0
  328. package/dist/{reward-hacking-WTxUbtbb.d.ts → reward-hacking-C9hPVT0Q.d.ts} +4 -8
  329. package/dist/reward-hacking-C9hPVT0Q.d.ts.map +1 -0
  330. package/dist/{reward-hacking-ByuETaIb.js → reward-hacking-DZzHZlS1.js} +5 -7
  331. package/dist/{reward-hacking-ByuETaIb.js.map → reward-hacking-DZzHZlS1.js.map} +1 -1
  332. package/dist/rl.d.ts +26 -63
  333. package/dist/rl.d.ts.map +1 -1
  334. package/dist/rl.js +35 -52
  335. package/dist/rl.js.map +1 -1
  336. package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
  337. package/dist/rollout/index.d.ts +6 -6
  338. package/dist/rollout/index.js +7 -7
  339. package/dist/{rollout-Dd1ucT_M.js → rollout-BhkMpAJT.js} +279 -16
  340. package/dist/rollout-BhkMpAJT.js.map +1 -0
  341. package/dist/{terminal-record-CB9BFtjS.js → rollout-nodes-BHR9Q5jP.js} +351 -11
  342. package/dist/rollout-nodes-BHR9Q5jP.js.map +1 -0
  343. package/dist/{round-decimal-COrKglMh.js → round-decimal-ZmjAQPo1.js} +2 -3
  344. package/dist/{round-decimal-COrKglMh.js.map → round-decimal-ZmjAQPo1.js.map} +1 -1
  345. package/dist/{rubric-predictive-validity-Cd5SCtAf.d.ts → rubric-predictive-validity-B3RzbwOx.d.ts} +2 -8
  346. package/dist/rubric-predictive-validity-B3RzbwOx.d.ts.map +1 -0
  347. package/dist/{rubric-predictive-validity-CeKW2GQN.js → rubric-predictive-validity-CQp_M0vy.js} +3 -4
  348. package/dist/{rubric-predictive-validity-CeKW2GQN.js.map → rubric-predictive-validity-CQp_M0vy.js.map} +1 -1
  349. package/dist/{run-record-CysKLB93.js → run-record-CZy4-TnZ.js} +4 -5
  350. package/dist/{run-record-CysKLB93.js.map → run-record-CZy4-TnZ.js.map} +1 -1
  351. package/dist/{run-record-C3awiXPf.d.ts → run-record-D2BFMPGl.d.ts} +5 -7
  352. package/dist/run-record-D2BFMPGl.d.ts.map +1 -0
  353. package/dist/{run-record-DhEJgoPz.js → run-record-DEjx43cI.js} +6 -7
  354. package/dist/{run-record-DhEJgoPz.js.map → run-record-DEjx43cI.js.map} +1 -1
  355. package/dist/{sandbox-harness-BlSOu4LX.d.ts → sandbox-harness-B3Kx1fOA.d.ts} +1 -3
  356. package/dist/sandbox-harness-B3Kx1fOA.d.ts.map +1 -0
  357. package/dist/{schema-D6EVKzTB.d.ts → schema-CkIvnmLU.d.ts} +2 -43
  358. package/dist/schema-CkIvnmLU.d.ts.map +1 -0
  359. package/dist/{schema-Bt2vLFm3.js → schema-D-xu3MU_.js} +2 -3
  360. package/dist/{schema-Bt2vLFm3.js.map → schema-D-xu3MU_.js.map} +1 -1
  361. package/dist/{schema-C-ziyJD7.d.ts → schema-DkFJr3Y8.d.ts} +111 -48
  362. package/dist/schema-DkFJr3Y8.d.ts.map +1 -0
  363. package/dist/{schema-CvhfLjtZ.js → schema-YUIXT8iW.js} +37 -7
  364. package/dist/schema-YUIXT8iW.js.map +1 -0
  365. package/dist/search/index.d.ts +3 -35
  366. package/dist/search/index.d.ts.map +1 -1
  367. package/dist/search/index.js +4 -5
  368. package/dist/{search-kernel-CctpiDd2.d.ts → search-kernel-CBdwFZ05.d.ts} +10 -36
  369. package/dist/search-kernel-CBdwFZ05.d.ts.map +1 -0
  370. package/dist/{search-ledger-CZRqtFbW.js → search-ledger-BsVi-Ngv.js} +17 -26
  371. package/dist/{search-ledger-CZRqtFbW.js.map → search-ledger-BsVi-Ngv.js.map} +1 -1
  372. package/dist/{search-ledger-file-Bd5Tioq6.js → search-ledger-file-DTBD6X-y.js} +6 -8
  373. package/dist/{search-ledger-file-Bd5Tioq6.js.map → search-ledger-file-DTBD6X-y.js.map} +1 -1
  374. package/dist/{search-ledger-types-p2xKfiDJ.d.ts → search-ledger-types-qiYRUo_N.d.ts} +5 -9
  375. package/dist/search-ledger-types-qiYRUo_N.d.ts.map +1 -0
  376. package/dist/{search-shipper-Dn3NLsuH.js → search-shipper-pdg4viK7.js} +8 -13
  377. package/dist/{search-shipper-Dn3NLsuH.js.map → search-shipper-pdg4viK7.js.map} +1 -1
  378. package/dist/{search-summary-D4bwYnAE.js → search-summary-Ct7SrmVc.js} +6 -7
  379. package/dist/{search-summary-D4bwYnAE.js.map → search-summary-Ct7SrmVc.js.map} +1 -1
  380. package/dist/{sequential-CimQrbjv.js → sequential-B1I0tRfL.js} +6 -7
  381. package/dist/{sequential-CimQrbjv.js.map → sequential-B1I0tRfL.js.map} +1 -1
  382. package/dist/{sequential-KwGspfeR.d.ts → sequential-Bb_pdTqG.d.ts} +1 -3
  383. package/dist/sequential-Bb_pdTqG.d.ts.map +1 -0
  384. package/dist/{sequential-BVv1sjsw.js → sequential-Bjs5roiK.js} +2 -3
  385. package/dist/{sequential-BVv1sjsw.js.map → sequential-Bjs5roiK.js.map} +1 -1
  386. package/dist/{sequential-eprocess-DodI6RoF.js → sequential-eprocess-C1YLwFaz.js} +3 -4
  387. package/dist/{sequential-eprocess-DodI6RoF.js.map → sequential-eprocess-C1YLwFaz.js.map} +1 -1
  388. package/dist/{server-ChhXPCgX.js → server-DA6h3co5.js} +11 -17
  389. package/dist/{server-ChhXPCgX.js.map → server-DA6h3co5.js.map} +1 -1
  390. package/dist/{single-run-lock-Dekd8_Wv.js → single-run-lock-BGlW3OSk.js} +3 -4
  391. package/dist/{single-run-lock-Dekd8_Wv.js.map → single-run-lock-BGlW3OSk.js.map} +1 -1
  392. package/dist/{skillopt-optimization-method-sB_-yi1G.js → skillopt-optimization-method-qB1M554K.js} +38 -57
  393. package/dist/{skillopt-optimization-method-sB_-yi1G.js.map → skillopt-optimization-method-qB1M554K.js.map} +1 -1
  394. package/dist/{spans-CVngGij3.d.ts → spans-vZoW__3q.d.ts} +2 -4
  395. package/dist/spans-vZoW__3q.d.ts.map +1 -0
  396. package/dist/{statistical-heldout-BjzSOmLH.d.ts → statistical-heldout-Cei036nE.d.ts} +9 -37
  397. package/dist/statistical-heldout-Cei036nE.d.ts.map +1 -0
  398. package/dist/{statistical-heldout-Bksv92Th.js → statistical-heldout-TP6ndL0B.js} +4 -5
  399. package/dist/{statistical-heldout-Bksv92Th.js.map → statistical-heldout-TP6ndL0B.js.map} +1 -1
  400. package/dist/{steps-DlepJPwD.d.ts → steps-B8fYY_Vo.d.ts} +1 -3
  401. package/dist/steps-B8fYY_Vo.d.ts.map +1 -0
  402. package/dist/{store-B3nWRy3B.d.ts → store-CMs5wGXP.d.ts} +2 -4
  403. package/dist/store-CMs5wGXP.d.ts.map +1 -0
  404. package/dist/{store-BhNuLdJw.js → store-ZykIyQmy.js} +2 -3
  405. package/dist/{store-BhNuLdJw.js.map → store-ZykIyQmy.js.map} +1 -1
  406. package/dist/{store-otlp-CFf27E8_.js → store-otlp-DmLm65XW.js} +8 -13
  407. package/dist/{store-otlp-CFf27E8_.js.map → store-otlp-DmLm65XW.js.map} +1 -1
  408. package/dist/{store-tool-spans-DxsFwtdr.d.ts → store-tool-spans-B3i3fl0A.d.ts} +11 -29
  409. package/dist/store-tool-spans-B3i3fl0A.d.ts.map +1 -0
  410. package/dist/{store-tool-spans-BK_8FjGG.js → store-tool-spans-C2g8UYm-.js} +17 -41
  411. package/dist/{store-tool-spans-BK_8FjGG.js.map → store-tool-spans-C2g8UYm-.js.map} +1 -1
  412. package/dist/storyboard/index.d.ts +1 -5
  413. package/dist/storyboard/index.d.ts.map +1 -1
  414. package/dist/storyboard/index.js +3 -5
  415. package/dist/storyboard/index.js.map +1 -1
  416. package/dist/{summary-report-C8V49Jt3.d.ts → summary-report-0La5vejY.d.ts} +5 -13
  417. package/dist/summary-report-0La5vejY.d.ts.map +1 -0
  418. package/dist/{summary-report-DHDWxe6p.js → summary-report-CPfsrLac.js} +21 -30
  419. package/dist/summary-report-CPfsrLac.js.map +1 -0
  420. package/dist/supervisor-run/index.d.ts +30 -29
  421. package/dist/supervisor-run/index.d.ts.map +1 -1
  422. package/dist/supervisor-run/index.js +6 -7
  423. package/dist/{systemone-CHnqwmYg.d.ts → systemone-Cw2txK5m.d.ts} +12 -24
  424. package/dist/systemone-Cw2txK5m.d.ts.map +1 -0
  425. package/dist/{systemone-protocol-Bl2EI2KQ.d.ts → systemone-protocol-C4t7JH4Y.d.ts} +1 -3
  426. package/dist/systemone-protocol-C4t7JH4Y.d.ts.map +1 -0
  427. package/dist/systemone-protocol.d.ts +1 -1
  428. package/dist/systemone-protocol.js +2 -3
  429. package/dist/{systemone-review-cQ9acAsb.d.ts → systemone-review-BLgxt-4Q.d.ts} +8 -10
  430. package/dist/systemone-review-BLgxt-4Q.d.ts.map +1 -0
  431. package/dist/{systemone-review-DFGtIUcf.js → systemone-review-S49gsy_y.js} +5 -6
  432. package/dist/{systemone-review-DFGtIUcf.js.map → systemone-review-S49gsy_y.js.map} +1 -1
  433. package/dist/systemone.d.ts +4 -4
  434. package/dist/systemone.js +3 -3
  435. package/dist/{task-failure-attributes-oIK3BhCR.js → task-failure-attributes-CC6VuIpk.js} +7 -10
  436. package/dist/{task-failure-attributes-oIK3BhCR.js.map → task-failure-attributes-CC6VuIpk.js.map} +1 -1
  437. package/dist/{tool-groups-b3oU_D88.d.ts → tool-groups-C3K-d3gd.d.ts} +3 -5
  438. package/dist/tool-groups-C3K-d3gd.d.ts.map +1 -0
  439. package/dist/{tool-waste-CkjzWmeY.d.ts → tool-waste-BFG1vwTV.d.ts} +4 -16
  440. package/dist/tool-waste-BFG1vwTV.d.ts.map +1 -0
  441. package/dist/{tool-waste-DLsjS_p-.js → tool-waste-CLJ46AbT.js} +10 -26
  442. package/dist/{tool-waste-DLsjS_p-.js.map → tool-waste-CLJ46AbT.js.map} +1 -1
  443. package/dist/trace-attributes.d.ts +1 -1
  444. package/dist/trace-attributes.js +1 -2
  445. package/dist/{trace-questions-BmT8M6UQ.d.ts → trace-questions-ej5AEJ5X.d.ts} +4 -6
  446. package/dist/trace-questions-ej5AEJ5X.d.ts.map +1 -0
  447. package/dist/trace-repair/index.d.ts +46 -92
  448. package/dist/trace-repair/index.d.ts.map +1 -1
  449. package/dist/trace-repair/index.js +32 -54
  450. package/dist/trace-repair/index.js.map +1 -1
  451. package/dist/traces.d.ts +13 -29
  452. package/dist/traces.d.ts.map +1 -1
  453. package/dist/traces.js +18 -22
  454. package/dist/traces.js.map +1 -1
  455. package/dist/{trajectory-D_7rLrvE.js → trajectory-O3GDHmev.js} +2 -3
  456. package/dist/{trajectory-D_7rLrvE.js.map → trajectory-O3GDHmev.js.map} +1 -1
  457. package/dist/trajectory-replay/index.d.ts +2 -22
  458. package/dist/trajectory-replay/index.d.ts.map +1 -1
  459. package/dist/trajectory-replay/index.js +19 -30
  460. package/dist/trajectory-replay/index.js.map +1 -1
  461. package/dist/{tree-DSqwJpL9.js → tree-DrIChF4a.js} +39 -68
  462. package/dist/{tree-DSqwJpL9.js.map → tree-DrIChF4a.js.map} +1 -1
  463. package/dist/{types-B_IFcKp5.d.ts → types-0KglnQ9o.d.ts} +3 -15
  464. package/dist/types-0KglnQ9o.d.ts.map +1 -0
  465. package/dist/{types-DZ0mYVw9.d.ts → types-0oMg7zee.d.ts} +3 -5
  466. package/dist/types-0oMg7zee.d.ts.map +1 -0
  467. package/dist/{types-CnWmj8NW.js → types-BK0blWhe.js} +3 -4
  468. package/dist/{types-CnWmj8NW.js.map → types-BK0blWhe.js.map} +1 -1
  469. package/dist/{types-CmXY0PQf.d.ts → types-C-aOqgt2.d.ts} +2 -5
  470. package/dist/types-C-aOqgt2.d.ts.map +1 -0
  471. package/dist/{types-M6eF9m-r.d.ts → types-C54Uk_a1.d.ts} +84 -24
  472. package/dist/types-C54Uk_a1.d.ts.map +1 -0
  473. package/dist/{types-BXgASBCL.js → types-DK4vNv5q.js} +2 -3
  474. package/dist/{types-BXgASBCL.js.map → types-DK4vNv5q.js.map} +1 -1
  475. package/dist/{types-6Lfdlshp.d.ts → types-DzCO-S1m.d.ts} +50 -62
  476. package/dist/types-DzCO-S1m.d.ts.map +1 -0
  477. package/dist/{verdict-BGQmxQ8A.js → verdict-C8TcdwfD.js} +3 -4
  478. package/dist/{verdict-BGQmxQ8A.js.map → verdict-C8TcdwfD.js.map} +1 -1
  479. package/dist/{verdict-C24NELtN.d.ts → verdict-D_qiBQ6_.d.ts} +1 -5
  480. package/dist/verdict-D_qiBQ6_.d.ts.map +1 -0
  481. package/dist/{verdict-cache-CL_7tePD.js → verdict-cache-BVH-fl18.js} +3 -4
  482. package/dist/{verdict-cache-CL_7tePD.js.map → verdict-cache-BVH-fl18.js.map} +1 -1
  483. package/dist/wire/index.d.ts +43 -51
  484. package/dist/wire/index.d.ts.map +1 -1
  485. package/dist/wire/index.js +1 -2
  486. package/docs/eval-surface-map.md +15 -0
  487. package/docs/rollout.md +132 -6
  488. package/package.json +18 -18
  489. package/dist/adversarial-smnADNFS.d.ts.map +0 -1
  490. package/dist/agent-profile-CNmwfaqq.d.ts.map +0 -1
  491. package/dist/agent-profile-cell-BcpFbNd5.d.ts.map +0 -1
  492. package/dist/analyze-runs-DfX6dHP0.d.ts.map +0 -1
  493. package/dist/attribute-vocabulary-CcXqHODT.d.ts.map +0 -1
  494. package/dist/benchmark-command-Cnjfo0Zh.js.map +0 -1
  495. package/dist/campaign-evidence-DunzcJGv.js.map +0 -1
  496. package/dist/campaign-uddTlFg5.js.map +0 -1
  497. package/dist/canonical-CFpojCN5.d.ts.map +0 -1
  498. package/dist/client-hwo3cJjR.d.ts.map +0 -1
  499. package/dist/completion-verifier-asaV1nSj.js.map +0 -1
  500. package/dist/cost-ledger-C1W3ICmP.d.ts.map +0 -1
  501. package/dist/dataset-DQqhOCPt.d.ts.map +0 -1
  502. package/dist/default-registry-CLG5YqGS.d.ts.map +0 -1
  503. package/dist/define-agent-eval-JKt3gMQr.d.ts.map +0 -1
  504. package/dist/descriptive-B2iPaT9J.d.ts +0 -89
  505. package/dist/descriptive-B2iPaT9J.d.ts.map +0 -1
  506. package/dist/descriptive-CVNy48rR.js.map +0 -1
  507. package/dist/emitter-DABYYTcH.d.ts.map +0 -1
  508. package/dist/engine-dtRVeuQs.d.ts.map +0 -1
  509. package/dist/errors-DEE6u6ot.d.ts.map +0 -1
  510. package/dist/evaluation-DblGquCB.d.ts.map +0 -1
  511. package/dist/exact-types-Do63KoKn.d.ts.map +0 -1
  512. package/dist/exporters-DWvM16LE.js.map +0 -1
  513. package/dist/exporters-Dk3oEbK_.d.ts.map +0 -1
  514. package/dist/failure-cluster-DN0t63Z0.d.ts.map +0 -1
  515. package/dist/feedback-trajectory-CYVJXolG.d.ts.map +0 -1
  516. package/dist/hf-dataset-CKxIJQba.js.map +0 -1
  517. package/dist/index-CHxwfW5g.d.ts.map +0 -1
  518. package/dist/index-CTIRz-AB.d.ts.map +0 -1
  519. package/dist/index-CalAsXMR.d.ts.map +0 -1
  520. package/dist/index-CdEVr8-O.d.ts.map +0 -1
  521. package/dist/index-CfJULcW5.d.ts.map +0 -1
  522. package/dist/index-D7fmC-1K.d.ts.map +0 -1
  523. package/dist/index-jnuFLxOs.d.ts.map +0 -1
  524. package/dist/integrity-D-s2iHiT.js.map +0 -1
  525. package/dist/integrity-D9lBnv_K.d.ts.map +0 -1
  526. package/dist/interval-ohuOJurX.d.ts.map +0 -1
  527. package/dist/judge-calibration-DFtEMlde.d.ts.map +0 -1
  528. package/dist/llm-judge-Cybq29bL.js.map +0 -1
  529. package/dist/lock-holder-DaJbfpci.d.ts.map +0 -1
  530. package/dist/matrix-B8l-Nsxd.js.map +0 -1
  531. package/dist/matrix-DtkZLD_3.d.ts.map +0 -1
  532. package/dist/mint-CkzpVPdz.d.ts +0 -81
  533. package/dist/mint-CkzpVPdz.d.ts.map +0 -1
  534. package/dist/multi-layer-verifier-DEgMUk6v.d.ts.map +0 -1
  535. package/dist/multiplicity-DIWHvysC.d.ts.map +0 -1
  536. package/dist/paired-promotion-decision-CQMJ5xGN.d.ts.map +0 -1
  537. package/dist/pareto-BiBnQXAE.js.map +0 -1
  538. package/dist/prime-bridge-transport-6feEglLf.d.ts.map +0 -1
  539. package/dist/prime-protocol-BGxjfhM4.d.ts.map +0 -1
  540. package/dist/promotion-gate-CkVZHagC.d.ts.map +0 -1
  541. package/dist/query-Cmv_U8vf.d.ts.map +0 -1
  542. package/dist/random-DGEyr3zG.d.ts.map +0 -1
  543. package/dist/redact-DXdlFb_U.d.ts.map +0 -1
  544. package/dist/registry-BcdJmyoU.d.ts.map +0 -1
  545. package/dist/release-confidence-CYIFH-fp.js.map +0 -1
  546. package/dist/render-BhJqXoBH.js.map +0 -1
  547. package/dist/researcher-DKWtoMWk.d.ts.map +0 -1
  548. package/dist/reward-BeUgVVC_.d.ts.map +0 -1
  549. package/dist/reward-hacking-WTxUbtbb.d.ts.map +0 -1
  550. package/dist/rollout-Dd1ucT_M.js.map +0 -1
  551. package/dist/rubric-predictive-validity-Cd5SCtAf.d.ts.map +0 -1
  552. package/dist/run-record-C3awiXPf.d.ts.map +0 -1
  553. package/dist/sandbox-harness-BlSOu4LX.d.ts.map +0 -1
  554. package/dist/schema-C-ziyJD7.d.ts.map +0 -1
  555. package/dist/schema-CvhfLjtZ.js.map +0 -1
  556. package/dist/schema-D6EVKzTB.d.ts.map +0 -1
  557. package/dist/search-kernel-CctpiDd2.d.ts.map +0 -1
  558. package/dist/search-ledger-types-p2xKfiDJ.d.ts.map +0 -1
  559. package/dist/sequential-KwGspfeR.d.ts.map +0 -1
  560. package/dist/spans-CVngGij3.d.ts.map +0 -1
  561. package/dist/statistical-heldout-BjzSOmLH.d.ts.map +0 -1
  562. package/dist/steps-DlepJPwD.d.ts.map +0 -1
  563. package/dist/store-B3nWRy3B.d.ts.map +0 -1
  564. package/dist/store-tool-spans-DxsFwtdr.d.ts.map +0 -1
  565. package/dist/summary-report-C8V49Jt3.d.ts.map +0 -1
  566. package/dist/summary-report-DHDWxe6p.js.map +0 -1
  567. package/dist/systemone-CHnqwmYg.d.ts.map +0 -1
  568. package/dist/systemone-protocol-Bl2EI2KQ.d.ts.map +0 -1
  569. package/dist/systemone-review-cQ9acAsb.d.ts.map +0 -1
  570. package/dist/terminal-record-CB9BFtjS.js.map +0 -1
  571. package/dist/tool-groups-b3oU_D88.d.ts.map +0 -1
  572. package/dist/tool-waste-CkjzWmeY.d.ts.map +0 -1
  573. package/dist/trace-questions-BmT8M6UQ.d.ts.map +0 -1
  574. package/dist/types-6Lfdlshp.d.ts.map +0 -1
  575. package/dist/types-B_IFcKp5.d.ts.map +0 -1
  576. package/dist/types-CmXY0PQf.d.ts.map +0 -1
  577. package/dist/types-DZ0mYVw9.d.ts.map +0 -1
  578. package/dist/types-M6eF9m-r.d.ts.map +0 -1
  579. package/dist/verdict-C24NELtN.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"eval-campaign-DoX5vz3E.js","names":[],"sources":["../src/eval-campaign.ts"],"sourcesContent":["/**\n * EvalCampaign — opinionated matrix runner that wires the four\n * capture-integrity directives by construction.\n *\n * The canonical benchmark shape — matrix runner → for each\n * (variant, scenario, seed) → start a TraceEmitter → call LLMs → end the\n * run → analyze — has a bug class at the integration boundary: raw\n * events not captured, route silently wrong, integrity not asserted,\n * analyst never run. The directives in `SKILL.md § Capture integrity`\n * are the mitigations.\n *\n * `EvalCampaign` is the structural fix — consumers don't wire the\n * integrity surface themselves; the campaign owns it. Specifically:\n *\n * - constructs a per-run `TraceStore` and `RawProviderSink` via factories\n * - builds the run's `ChatClient` through `chatFactory`, handing it the\n * run's raw sink and trace context — a transport built any other way has\n * no raw HTTP envelope, and `assertRunCaptured` says so\n * - calls `assertRunCaptured` after every `endRun` and routes failures\n * through a configurable policy (`throw` / `mark_failed` / `log`)\n * - assembles per-run `RunRecord`s and runs `researchReport` at the end\n * so the campaign artifact is launch-decision-grade by default\n * - embeds the campaign fingerprint (a SHA-256 over the canonicalised\n * run set) and optional `preregistrationHash` in the report\n *\n * The runner contract is intentionally narrow: produce a `CampaignRunOutcome`\n * given a fully-wired `CampaignRunContext`. Everything orchestration-shaped\n * lives in the campaign. This is the inversion-of-control point — consumers\n * stop writing matrix runners and start writing scenario-runners.\n *\n * Out of scope for v1 (tracked in `docs/research-report-methodology.md`):\n *\n * - Distributed/cluster execution (concurrency is local async)\n * - Adaptive sampling / sequential interim looks\n * - Resume from partial state across crashes\n * - LLM-call retry beyond what the caller's transport already does\n */\n\nimport {\n type AgentProfileCell,\n type AgentProfileCellInput,\n buildAgentProfileCell,\n verifyAgentProfileCell,\n} from './agent-profile-cell'\nimport type { ChatClient } from './analyst/chat-client'\nimport { hashJson } from './pre-registration'\nimport type {\n JudgeScoresRecord,\n RunCostProvenance,\n RunJudgeMetadata,\n RunOutcome,\n RunRecord,\n RunSplitTag,\n RunTaskFailure,\n RunTokenUsage,\n} from './run-record'\nimport { validateRunRecord } from './run-record'\nimport { type ResearchReport, type ResearchReportOptions, researchReport } from './summary-report'\nimport type { RunCompleteHook } from './trace/emitter'\nimport { TraceEmitter } from './trace/emitter'\nimport {\n assertRunCaptured,\n RunIntegrityError,\n type RunIntegrityExpectations,\n type RunIntegrityReport,\n} from './trace/integrity'\nimport { FileSystemRawProviderSink, type RawProviderSink } from './trace/raw-provider-sink'\nimport type { TraceStore } from './trace/store'\n\n// ── Public types ─────────────────────────────────────────────────────────\n\nexport interface CampaignVariant<V> {\n id: string\n payload: V\n}\n\nexport interface CampaignScenario {\n scenarioId: string\n /** Free-form metadata propagated to runs and reports. */\n tags?: Record<string, string>\n}\n\nexport interface CampaignRunContext<V> {\n /** Stable run id. The campaign generates this; the runner does not. */\n runId: string\n /** Logical experiment id (campaignId by default; overridable per-run via opts). */\n experimentId: string\n variant: V\n variantId: string\n scenarioId: string\n scenarioTags: Record<string, string>\n seed: number\n splitTag: RunSplitTag\n /**\n * The TraceEmitter for this run, with `onRunComplete` hooks pre-wired\n * (analyst auto-execution if configured, plus integrity check). The\n * runner MUST call `emitter.startRun` before doing any work and either\n * `emitter.endRun` or `emitter.abortRun` before returning.\n */\n emitter: TraceEmitter\n store: TraceStore\n rawSink: RawProviderSink\n /**\n * The run's model transport, built by `chatFactory` with this run's\n * `rawSink` and `runId` already bound.\n */\n chat: ChatClient\n}\n\n/** What the campaign binds into the run's transport. */\nexport interface CampaignChatWiring {\n /**\n * Raw provider sink for this run. Bind it into the transport: the campaign's\n * integrity check requires every LLM span to carry a matching raw request\n * event, so a transport built without it fails `assertRunCaptured`.\n */\n rawSink: RawProviderSink\n runId: string\n}\n\ninterface CampaignRunOutcomeFields {\n /** Did the run pass? Mirrors `RunOutcome.pass` semantics. */\n pass: boolean\n /** Score for the run on its split. Maps to `searchScore` or `holdoutScore`. */\n score: number\n /** Cost in USD, or null when the runner could not capture it. */\n costUsd: number | null\n /** Source of the cost amount. */\n costProvenance: RunCostProvenance\n tokenUsage: RunTokenUsage\n /** Snapshot model id (e.g. `claude-sonnet-4-6@2025-04-15`). */\n model: string\n /** sha256 of the effective prompt sent to the model. */\n promptHash: string\n /** sha256 of the effective config (model, temperature, tools, judges, splits). */\n configHash: string\n /** Optional extra numeric metrics to land in `outcome.raw`. */\n raw?: Record<string, number>\n /** Optional judge metadata when a judge was used. */\n judgeMetadata?: RunJudgeMetadata\n /**\n * Optional per-judge / per-dim breakdown for ensemble-judged runs.\n * Propagated to `outcome.judgeScores` on the resulting `RunRecord`.\n * Single-judge or scalar-only runs leave this unset.\n */\n judgeScores?: JudgeScoresRecord\n /**\n * Agent profile cell observed by the runner. When supplied, it overrides\n * `EvalCampaignOptions.agentProfile` for this run and must match the\n * outcome's `model` and `promptHash`.\n */\n agentProfile?: AgentProfileCell | AgentProfileCellInput\n}\n\n/** Campaign result with the same task-failure invariant as `RunRecord`. */\nexport type CampaignRunOutcome = CampaignRunOutcomeFields & RunTaskFailure\n\nexport type CampaignRunner<V> = (ctx: CampaignRunContext<V>) => Promise<CampaignRunOutcome>\n\nexport type CampaignIntegrityPolicy = 'throw' | 'mark_failed' | 'log'\n\nexport interface EvalCampaignOptions<V> {\n /**\n * Stable id for the campaign. Used as the default `experimentId` on\n * every run, and folded into the campaign fingerprint.\n */\n campaignId: string\n variants: CampaignVariant<V>[]\n scenarios: CampaignScenario[]\n /** Default `[0, 1, 2]`. */\n seeds?: number[]\n /** Default `'holdout'` — the split that anchors a launch decision. */\n splitTag?: RunSplitTag\n /** Git SHA the campaign is run against. Mandatory; `RunRecord` rejects unset. */\n commitSha: string\n /**\n * Build the model transport for one run. agent-eval executes no paid model:\n * the caller owns the transport and the credential never enters this\n * package. The campaign calls this once per run and passes the run's raw\n * provider sink and `runId`, so a transport that binds them captures the\n * raw HTTP envelope `assertRunCaptured` checks for.\n */\n chatFactory: (wiring: CampaignChatWiring) => ChatClient\n /**\n * Caller-declared identity of the execution route, folded into the campaign\n * fingerprint so two campaigns run against different endpoints do not share\n * one identity. agent-eval no longer knows the endpoint; the owner of\n * execution names it.\n */\n executionRef?: string\n /**\n * Per-run TraceStore factory. Common shape: a fresh store per run keyed\n * on `runId`. Implementations that share a store across the campaign\n * are valid — the campaign only writes through `emitter`.\n */\n storeFactory: (params: CampaignFactoryParams) => TraceStore\n /**\n * Per-run RawProviderSink factory. Defaults to `FileSystemRawProviderSink`\n * rooted at `${workDir}/raw-events/${runId}` if `workDir` is supplied;\n * otherwise required. Forensic capture is non-negotiable in a campaign\n * run — pass `NoopRawProviderSink` explicitly if you want to opt out.\n */\n rawSinkFactory?: (params: CampaignFactoryParams) => RawProviderSink\n /**\n * Filesystem root for default `rawSinkFactory`. Ignored if\n * `rawSinkFactory` is supplied.\n */\n workDir?: string\n /**\n * Extra `onRunComplete` hooks the campaign appends (after its own\n * integrity-check hook). Pass `traceAnalystOnRunComplete(...)` here.\n */\n onRunComplete?: RunCompleteHook[]\n /**\n * Per-run integrity expectations. Defaults to:\n * `{ llmSpansMin: 1, requireRawCoverageOfLlmSpans: true, requireOutcome: true }`.\n * Override (e.g. `{ llmSpansMin: 0 }`) for runs that don't call LLMs.\n */\n integrity?: RunIntegrityExpectations\n /** Behaviour when integrity fails. Default `'mark_failed'`. */\n onIntegrityFailure?: CampaignIntegrityPolicy\n /**\n * Per-run runner. Receives a fully-wired context; produces an outcome\n * the campaign converts into a `RunRecord`.\n */\n runner: CampaignRunner<V>\n /**\n * If set, the campaign computes `researchReport` at the end. `comparator`\n * is a `variantId`. Other fields are forwarded verbatim.\n */\n report?: { comparator?: string } & Omit<\n ResearchReportOptions,\n 'comparator' | 'preregistrationHash' | 'generatedAt'\n >\n /**\n * Hash of a signed `HypothesisManifest` (see `pre-registration.ts`).\n * Embedded in the campaign fingerprint and the research report.\n */\n preregistrationHash?: string\n /** Local concurrency. Default `1` (sequential). */\n concurrency?: number\n /**\n * Override the time source. Tests pass a mock to make wallMs deterministic.\n */\n now?: () => number\n /** Override the runId generator. Tests pin this. */\n runId?: (params: CampaignFactoryParams) => string\n /**\n * Agent profile cell for campaign runs. Static profiles can pass an object;\n * routers or variant-specific harnesses can pass a factory. The campaign\n * stamps the built cell onto every `RunRecord` and rejects profile/model or\n * profile/prompt contradictions.\n */\n agentProfile?:\n | AgentProfileCell\n | AgentProfileCellInput\n | ((\n params: CampaignFactoryParams & {\n variant: V\n scenarioTags: Record<string, string>\n },\n ) =>\n | AgentProfileCell\n | AgentProfileCellInput\n | Promise<AgentProfileCell | AgentProfileCellInput>)\n}\n\nexport interface CampaignFactoryParams {\n campaignId: string\n runId: string\n variantId: string\n scenarioId: string\n seed: number\n}\n\nexport interface FailedRun {\n runId: string\n variantId: string\n scenarioId: string\n seed: number\n reason: string\n error?: string\n}\n\nexport interface EvalCampaignResult {\n campaignId: string\n /** SHA-256 over canonicalised `(variantIds, scenarioIds, seeds, comparator, splitTag, executionRef, preregistrationHash)`. */\n campaignFingerprint: string\n preregistrationHash: string | null\n /** Successful runs only. Failed runs land in `failedRuns`. */\n runs: RunRecord[]\n /** Integrity reports for every successful run. */\n integrityReports: RunIntegrityReport[]\n failedRuns: FailedRun[]\n /** Computed when `report` is set on options. */\n report?: ResearchReport\n startedAt: string\n endedAt: string\n}\n\n// ── Implementation ───────────────────────────────────────────────────────\n\nconst DEFAULT_INTEGRITY: RunIntegrityExpectations = {\n llmSpansMin: 1,\n requireRawCoverageOfLlmSpans: true,\n requireOutcome: true,\n}\n\ntype CampaignCell<V> = { variant: CampaignVariant<V>; scenario: CampaignScenario; seed: number }\n\ntype CampaignRunResult = { record: RunRecord; integrity: RunIntegrityReport }\n\n/** Resolved options shared by every step of one campaign. */\ninterface CampaignSettings {\n seeds: number[]\n splitTag: RunSplitTag\n concurrency: number\n integrity: RunIntegrityExpectations\n onIntegrityFailure: CampaignIntegrityPolicy\n now: () => number\n executionRef: string | null\n preregistrationHash: string | null\n rawSinkFactory: (params: CampaignFactoryParams) => RawProviderSink\n}\n\n/**\n * Mutable state of one campaign's worker pool.\n *\n * A genuine (non-CellExecutionError) error from any worker is a bug, not a\n * run-level failure. We must NOT let `Promise.all` reject mid-flight and\n * orphan the other workers' in-progress runs (emitters never finalized,\n * sinks/handles leak, partial work silently discarded). Instead: capture the\n * first genuine error, stop dispatching new cells so in-flight workers wind\n * down, finalize every still-open run, then re-throw the aggregated error.\n */\ninterface CampaignPool<V> {\n opts: EvalCampaignOptions<V>\n settings: CampaignSettings\n cells: CampaignCell<V>[]\n cursor: number\n aborting: boolean\n genuineErrors: unknown[]\n /**\n * Emitters for runs that are currently mid-flight, keyed by runId. A worker\n * registers its emitter before invoking the runner and removes it once the\n * run is finalized (via endRun/abortRun, success or failure). Anything left\n * here after the pool settles is an orphan we must abort.\n */\n openRuns: Map<string, TraceEmitter>\n runs: RunRecord[]\n integrityReports: RunIntegrityReport[]\n failedRuns: FailedRun[]\n}\n\nexport async function runEvalCampaign<V>(\n opts: EvalCampaignOptions<V>,\n): Promise<EvalCampaignResult> {\n assertCampaignPreflight(opts)\n const settings = resolveCampaignSettings(opts)\n const campaignFingerprint = await fingerprintCampaign(opts, settings)\n\n const startedAt = new Date(settings.now()).toISOString()\n const pool: CampaignPool<V> = {\n opts,\n settings,\n cells: planCampaignCells(opts, settings.seeds),\n cursor: 0,\n aborting: false,\n genuineErrors: [],\n openRuns: new Map(),\n runs: [],\n integrityReports: [],\n failedRuns: [],\n }\n await drainCampaignPool(pool)\n\n const report = await buildCampaignReport(opts, settings, pool.runs)\n const endedAt = new Date(settings.now()).toISOString()\n\n return {\n campaignId: opts.campaignId,\n campaignFingerprint,\n preregistrationHash: settings.preregistrationHash,\n runs: pool.runs,\n integrityReports: pool.integrityReports,\n failedRuns: pool.failedRuns,\n report,\n startedAt,\n endedAt,\n }\n}\n\n/** Reject structurally invalid campaigns before any work starts. */\nfunction assertCampaignPreflight<V>(opts: EvalCampaignOptions<V>): void {\n if (opts.variants.length === 0) {\n throw new Error('runEvalCampaign: variants must be non-empty.')\n }\n if (opts.scenarios.length === 0) {\n throw new Error('runEvalCampaign: scenarios must be non-empty.')\n }\n const variantIds = new Set<string>()\n for (const v of opts.variants) {\n if (variantIds.has(v.id)) {\n throw new Error(`runEvalCampaign: duplicate variant id \"${v.id}\".`)\n }\n variantIds.add(v.id)\n }\n const scenarioIds = new Set<string>()\n for (const s of opts.scenarios) {\n if (scenarioIds.has(s.scenarioId)) {\n throw new Error(`runEvalCampaign: duplicate scenarioId \"${s.scenarioId}\".`)\n }\n scenarioIds.add(s.scenarioId)\n }\n if (opts.report?.comparator && !variantIds.has(opts.report.comparator)) {\n throw new Error(\n `runEvalCampaign: report.comparator \"${opts.report.comparator}\" is not a configured variantId.`,\n )\n }\n if (!opts.commitSha) {\n throw new Error('runEvalCampaign: commitSha is required (every RunRecord needs it).')\n }\n}\n\n/** Apply defaults to the optional campaign options. */\nfunction resolveCampaignSettings<V>(opts: EvalCampaignOptions<V>): CampaignSettings {\n return {\n seeds: opts.seeds ?? [0, 1, 2],\n splitTag: opts.splitTag ?? 'holdout',\n concurrency: Math.max(1, opts.concurrency ?? 1),\n integrity: { ...DEFAULT_INTEGRITY, ...(opts.integrity ?? {}) },\n onIntegrityFailure: opts.onIntegrityFailure ?? 'mark_failed',\n now: opts.now ?? (() => Date.now()),\n executionRef: opts.executionRef ?? null,\n preregistrationHash: opts.preregistrationHash ?? null,\n rawSinkFactory: opts.rawSinkFactory ?? defaultRawSinkFactory(opts.workDir),\n }\n}\n\n/** SHA-256 over the canonicalised matrix definition. */\nfunction fingerprintCampaign<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n): Promise<string> {\n return hashJson({\n campaignId: opts.campaignId,\n variants: opts.variants.map((v) => v.id).sort(),\n scenarios: opts.scenarios.map((s) => s.scenarioId).sort(),\n seeds: [...settings.seeds].sort((a, b) => a - b),\n splitTag: settings.splitTag,\n comparator: opts.report?.comparator ?? null,\n executionRef: settings.executionRef,\n preregistrationHash: settings.preregistrationHash,\n })\n}\n\n/** Expand variants x scenarios x seeds, variant-major. */\nfunction planCampaignCells<V>(opts: EvalCampaignOptions<V>, seeds: number[]): CampaignCell<V>[] {\n const cells: CampaignCell<V>[] = []\n for (const variant of opts.variants) {\n for (const scenario of opts.scenarios) {\n for (const seed of seeds) {\n cells.push({ variant, scenario, seed })\n }\n }\n }\n return cells\n}\n\n/**\n * Run the bounded-concurrency worker pool to completion, finalize any run left\n * open, and re-throw the genuine errors the workers captured.\n */\nasync function drainCampaignPool<V>(pool: CampaignPool<V>): Promise<void> {\n const workers = Array.from(\n { length: Math.min(pool.settings.concurrency, pool.cells.length) },\n () => campaignWorker(pool),\n )\n // allSettled (not all): a genuine error in one worker must not reject the\n // pool mid-flight and orphan the others. Each worker captures its own\n // genuine error into `genuineErrors` and returns; we re-throw below.\n await Promise.allSettled(workers)\n\n // Finalize any run still open after the pool wound down. With the\n // stop-dispatch flag these are the runs that were mid-flight in peer workers\n // when the first genuine error fired — abort them so their emitters finalize\n // (hooks fire, store records a terminal status) instead of leaking.\n for (const [runId, emitter] of pool.openRuns) {\n await finalizeAbort(emitter, runId, 'campaign aborted: genuine error in a sibling run')\n }\n pool.openRuns.clear()\n\n if (pool.genuineErrors.length > 0) {\n throw pool.genuineErrors.length === 1\n ? pool.genuineErrors[0]\n : new AggregateError(\n pool.genuineErrors,\n `runEvalCampaign: ${pool.genuineErrors.length} runs failed with genuine (non-run-level) errors`,\n )\n }\n}\n\n/** Pull cells off the shared cursor until none remain or the pool is aborting. */\nasync function campaignWorker<V>(pool: CampaignPool<V>): Promise<void> {\n while (!pool.aborting) {\n const i = pool.cursor++\n if (i >= pool.cells.length) return\n const cell = pool.cells[i]!\n try {\n const result = await runCampaignCell(pool, cell)\n pool.runs.push(result.record)\n pool.integrityReports.push(result.integrity)\n } catch (err) {\n if (err instanceof CellExecutionError) {\n pool.failedRuns.push(err.failed)\n if (err.integrity) pool.integrityReports.push(err.integrity)\n } else {\n // Genuine bug — not a runner failure, not an integrity failure.\n // Capture it and stop dispatching so peers wind down gracefully;\n // re-thrown after the pool settles. Do not surface here — that would\n // reject Promise.all and orphan the other workers' runs.\n pool.genuineErrors.push(err)\n pool.aborting = true\n return\n }\n }\n }\n}\n\n/** Run one matrix cell: runner, integrity check, then the validated RunRecord. */\nasync function runCampaignCell<V>(\n pool: CampaignPool<V>,\n cell: CampaignCell<V>,\n): Promise<CampaignRunResult> {\n const { opts, settings } = pool\n const runId = (opts.runId ?? defaultRunId)({\n campaignId: opts.campaignId,\n runId: '', // unused by default generator\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n })\n const factoryParams: CampaignFactoryParams = {\n campaignId: opts.campaignId,\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n }\n const store = opts.storeFactory(factoryParams)\n const rawSink = settings.rawSinkFactory(factoryParams)\n\n const emitter = new TraceEmitter(store, {\n runId,\n now: opts.now,\n onRunComplete: opts.onRunComplete,\n })\n // Track this run as open so a genuine error elsewhere in the pool can\n // finalize it instead of orphaning it. Removed in the finally below.\n pool.openRuns.set(runId, emitter)\n\n const chat = opts.chatFactory({ rawSink, runId })\n\n const ctx: CampaignRunContext<V> = {\n runId,\n experimentId: opts.campaignId,\n variant: cell.variant.payload,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n scenarioTags: cell.scenario.tags ?? {},\n seed: cell.seed,\n splitTag: settings.splitTag,\n emitter,\n store,\n rawSink,\n chat,\n }\n\n try {\n const wallStart = settings.now()\n const outcome = await invokeCampaignRunner(opts, cell, ctx)\n const wallMs = settings.now() - wallStart\n\n const integrityReport = await assertRunCaptured(store, runId, {\n ...settings.integrity,\n rawSink,\n })\n if (!integrityReport.ok) admitOrRejectIntegrity(settings, cell, runId, integrityReport)\n\n const record = buildCampaignRunRecord(opts, settings, cell, runId, outcome, wallMs)\n await stampAgentProfile(opts, cell, record, runId, outcome)\n return { record: validateRunRecord(record), integrity: integrityReport }\n } finally {\n // This run's worker has finished with it (success, run-level failure, or\n // genuine error). It is no longer the pool's job to finalize — drop it so\n // the post-settle sweep doesn't double-abort a finalized run.\n pool.openRuns.delete(runId)\n }\n}\n\n/** Invoke the runner; a throw aborts the run and becomes a run-level failure. */\nasync function invokeCampaignRunner<V>(\n opts: EvalCampaignOptions<V>,\n cell: CampaignCell<V>,\n ctx: CampaignRunContext<V>,\n): Promise<CampaignRunOutcome> {\n try {\n return await opts.runner(ctx)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n // The runner threw mid-execution. Abort the run so the emitter\n // finalizes. The only benign abortRun failure is \"the runner never\n // started the run\" (nothing to finalize). A store-write failure (disk\n // full, FS error) is a genuine diagnostic — surface it rather than\n // masking it as a plain runner failure.\n await finalizeAbort(ctx.emitter, ctx.runId, message)\n throw new CellExecutionError({\n runId: ctx.runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n reason: 'runner_threw',\n error: message,\n })\n }\n}\n\n/** Apply the integrity-failure policy to a report that is not ok. */\nfunction admitOrRejectIntegrity<V>(\n settings: CampaignSettings,\n cell: CampaignCell<V>,\n runId: string,\n integrityReport: RunIntegrityReport,\n): void {\n switch (settings.onIntegrityFailure) {\n case 'throw':\n throw new RunIntegrityError(integrityReport)\n case 'mark_failed':\n throw new CellExecutionError(\n {\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n reason: 'integrity_failed',\n error: integrityReport.issues.map((i) => i.code).join(', '),\n },\n integrityReport,\n )\n case 'log':\n // Caller wants the run admitted with a flagged report; fall through.\n break\n }\n}\n\n/** Assemble the RunRecord for a successful run, before profile stamping. */\nfunction buildCampaignRunRecord<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n cell: CampaignCell<V>,\n runId: string,\n outcome: CampaignRunOutcome,\n wallMs: number,\n): RunRecord {\n const recordOutcome: RunOutcome = {\n raw: outcome.raw ?? {},\n }\n if (settings.splitTag === 'holdout') recordOutcome.holdoutScore = outcome.score\n else recordOutcome.searchScore = outcome.score\n if (outcome.judgeScores !== undefined) recordOutcome.judgeScores = outcome.judgeScores\n\n return {\n runId,\n experimentId: opts.campaignId,\n candidateId: cell.variant.id,\n seed: cell.seed,\n model: outcome.model,\n promptHash: outcome.promptHash,\n configHash: outcome.configHash,\n commitSha: opts.commitSha,\n wallMs,\n costUsd: outcome.costUsd,\n costProvenance: outcome.costProvenance,\n tokenUsage: outcome.tokenUsage,\n terminalOutcome: 'succeeded',\n judgeMetadata: outcome.judgeMetadata,\n outcome: recordOutcome,\n ...(outcome.failureClass ? { failureClass: outcome.failureClass } : {}),\n failureMode: outcome.failureMode,\n splitTag: settings.splitTag,\n scenarioId: cell.scenario.scenarioId,\n }\n}\n\n/** Resolve the run's agent profile (outcome first, then options) and stamp it on the record. */\nasync function stampAgentProfile<V>(\n opts: EvalCampaignOptions<V>,\n cell: CampaignCell<V>,\n record: RunRecord,\n runId: string,\n outcome: CampaignRunOutcome,\n): Promise<void> {\n const profileSource =\n outcome.agentProfile ??\n (typeof opts.agentProfile === 'function'\n ? await opts.agentProfile({\n campaignId: opts.campaignId,\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n variant: cell.variant.payload,\n scenarioTags: cell.scenario.tags ?? {},\n })\n : opts.agentProfile)\n if (profileSource !== undefined) {\n const agentProfile = await resolveAgentProfileCell(profileSource)\n assertAgentProfileMatchesRun(agentProfile, outcome.model, outcome.promptHash)\n record.agentProfile = agentProfile\n }\n}\n\n/** Build the optional research report over the successful runs. */\nasync function buildCampaignReport<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n runs: RunRecord[],\n): Promise<ResearchReport | undefined> {\n if (!opts.report) return undefined\n const reportOpts: ResearchReportOptions = {\n ...opts.report,\n comparator: opts.report.comparator,\n split: settings.splitTag === 'dev' ? 'search' : settings.splitTag,\n generatedAt: new Date(settings.now()).toISOString(),\n preregistrationHash: settings.preregistrationHash ?? undefined,\n }\n return researchReport(runs, reportOpts)\n}\n\n// ── Internal ─────────────────────────────────────────────────────────────\n\nclass CellExecutionError extends Error {\n readonly failed: FailedRun\n readonly integrity?: RunIntegrityReport\n constructor(failed: FailedRun, integrity?: RunIntegrityReport) {\n super(`cell ${failed.variantId}/${failed.scenarioId}@${failed.seed} failed: ${failed.reason}`)\n this.failed = failed\n this.integrity = integrity\n }\n}\n\n/**\n * Abort a run whose owning work threw or was orphaned by a sibling's genuine\n * error, finalizing the emitter so hooks fire and the store records a terminal\n * status. Safe to call unconditionally: it only aborts runs that are still\n * `running`. Two no-op cases are intentional and benign:\n *\n * - the run was never started (absent from the store) — nothing to finalize\n * - the run is already terminal (`completed` / `failed` / `aborted`) —\n * finalizing again would overwrite the real outcome (e.g. flip a passed run\n * to `aborted` with `{ pass: false, notes: reason }`), so we leave it alone\n *\n * Any OTHER failure of the store read or the abort write (disk full, FS fault,\n * backend down) is a genuine diagnostic and propagates rather than being\n * swallowed.\n */\nasync function finalizeAbort(emitter: TraceEmitter, runId: string, reason: string): Promise<void> {\n const existing = await emitter.traceStore.getRun(runId)\n if (existing === undefined) return // run never started; nothing to abort\n if (existing.status !== 'running') return // already finalized; never overwrite a real outcome\n // The emitter never throws on a failed store write; it counts it. A failed\n // abort write is a genuine diagnostic here, so read the count and surface it.\n const droppedBefore = emitter.captureStats().dropped\n await emitter.abortRun(reason)\n const after = emitter.captureStats()\n if (after.dropped > droppedBefore) {\n throw new Error(`finalizeAbort: run ${runId} could not be finalized: ${after.lastError}`)\n }\n}\n\nfunction defaultRawSinkFactory(workDir: string | undefined) {\n return (params: CampaignFactoryParams): RawProviderSink => {\n if (!workDir) {\n throw new Error(\n 'runEvalCampaign: rawSinkFactory not supplied and workDir not set. Pass either to enable raw provider capture, or pass `new NoopRawProviderSink()` via rawSinkFactory to opt out explicitly.',\n )\n }\n return new FileSystemRawProviderSink({\n dir: `${workDir}/raw-events/${params.runId}`,\n })\n }\n}\n\nasync function resolveAgentProfileCell(\n input: AgentProfileCell | AgentProfileCellInput,\n): Promise<AgentProfileCell> {\n if (isAgentProfileCell(input)) {\n if (!(await verifyAgentProfileCell(input))) {\n throw new Error(`runEvalCampaign: agentProfile.cellId does not match its content`)\n }\n return input\n }\n return buildAgentProfileCell(input)\n}\n\nfunction isAgentProfileCell(\n input: AgentProfileCell | AgentProfileCellInput,\n): input is AgentProfileCell {\n return 'schemaVersion' in input && 'cellId' in input\n}\n\nfunction assertAgentProfileMatchesRun(\n profile: AgentProfileCell,\n model: string,\n promptHash: string,\n): void {\n if (profile.model !== undefined && profile.model !== model) {\n throw new Error(\n `runEvalCampaign: agentProfile.model \"${profile.model}\" does not match outcome.model \"${model}\"`,\n )\n }\n if (profile.promptHash !== undefined && profile.promptHash !== promptHash) {\n throw new Error(\n `runEvalCampaign: agentProfile.promptHash \"${profile.promptHash}\" does not match outcome.promptHash \"${promptHash}\"`,\n )\n }\n}\n\nfunction defaultRunId(params: CampaignFactoryParams): string {\n // Stable across re-runs: fingerprint of (campaignId, variantId, scenarioId, seed).\n // Caller can override via opts.runId for non-deterministic IDs.\n const base = `${params.campaignId}::${params.variantId}::${params.scenarioId}::${params.seed}`\n // TWO 32-bit FNV-1a accumulators with different offsets, concatenated for a\n // 64-bit-wide id. Not crypto-grade; stability and uniqueness are what this\n // needs. Frozen: the value names a persisted cell, and the second\n // accumulator's offset is part of the identity, so no single-accumulator\n // helper can replace it.\n let h1 = 0x811c9dc5\n let h2 = 0x12345678\n for (let i = 0; i < base.length; i++) {\n const c = base.charCodeAt(i)\n h1 = Math.imul(h1 ^ c, 0x01000193) >>> 0\n h2 = Math.imul(h2 ^ c, 0x9e3779b1) >>> 0\n }\n return `run-${h1.toString(16).padStart(8, '0')}${h2.toString(16).padStart(8, '0')}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8SA,MAAM,oBAA8C;CAClD,aAAa;CACb,8BAA8B;CAC9B,gBAAgB;AAClB;AAgDA,eAAsB,gBACpB,MAC6B;CAC7B,wBAAwB,IAAI;CAC5B,MAAM,WAAW,wBAAwB,IAAI;CAC7C,MAAM,sBAAsB,MAAM,oBAAoB,MAAM,QAAQ;CAEpE,MAAM,YAAY,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,YAAY;CACvD,MAAM,OAAwB;EAC5B;EACA;EACA,OAAO,kBAAkB,MAAM,SAAS,KAAK;EAC7C,QAAQ;EACR,UAAU;EACV,eAAe,CAAC;EAChB,0BAAU,IAAI,IAAI;EAClB,MAAM,CAAC;EACP,kBAAkB,CAAC;EACnB,YAAY,CAAC;CACf;CACA,MAAM,kBAAkB,IAAI;CAE5B,MAAM,SAAS,MAAM,oBAAoB,MAAM,UAAU,KAAK,IAAI;CAClE,MAAM,UAAU,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,YAAY;CAErD,OAAO;EACL,YAAY,KAAK;EACjB;EACA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M,IAAI,MACR,6CAA6C,QAAQ,WAAW,uCAAuC,WAAW,EACpH;AAEJ;AAEA,SAAS,aAAa,QAAuC;CAG3D,MAAM,OAAO,GAAG,OAAO,WAAW,IAAI,OAAO,UAAU,IAAI,OAAO,WAAW,IAAI,OAAO;CAMxF,IAAI,KAAK;CACT,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,IAAI,KAAK,WAAW,CAAC;EAC3B,KAAK,KAAK,KAAK,KAAK,GAAG,QAAU,MAAM;EACvC,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU,MAAM;CACzC;CACA,OAAO,OAAO,GAAG,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AAClF"}
1
+ {"version":3,"file":"eval-campaign-Cgixrvf7.js","names":[],"sources":["../src/eval-campaign.ts"],"sourcesContent":["/**\n * EvalCampaign — opinionated matrix runner that wires the four\n * capture-integrity directives by construction.\n *\n * The canonical benchmark shape — matrix runner → for each\n * (variant, scenario, seed) → start a TraceEmitter → call LLMs → end the\n * run → analyze — has a bug class at the integration boundary: raw\n * events not captured, route silently wrong, integrity not asserted,\n * analyst never run. The directives in `SKILL.md § Capture integrity`\n * are the mitigations.\n *\n * `EvalCampaign` is the structural fix — consumers don't wire the\n * integrity surface themselves; the campaign owns it. Specifically:\n *\n * - constructs a per-run `TraceStore` and `RawProviderSink` via factories\n * - builds the run's `ChatClient` through `chatFactory`, handing it the\n * run's raw sink and trace context — a transport built any other way has\n * no raw HTTP envelope, and `assertRunCaptured` says so\n * - calls `assertRunCaptured` after every `endRun` and routes failures\n * through a configurable policy (`throw` / `mark_failed` / `log`)\n * - assembles per-run `RunRecord`s and runs `researchReport` at the end\n * so the campaign artifact is launch-decision-grade by default\n * - embeds the campaign fingerprint (a SHA-256 over the canonicalised\n * run set) and optional `preregistrationHash` in the report\n *\n * The runner contract is intentionally narrow: produce a `CampaignRunOutcome`\n * given a fully-wired `CampaignRunContext`. Everything orchestration-shaped\n * lives in the campaign. This is the inversion-of-control point — consumers\n * stop writing matrix runners and start writing scenario-runners.\n *\n * Out of scope for v1 (tracked in `docs/research-report-methodology.md`):\n *\n * - Distributed/cluster execution (concurrency is local async)\n * - Adaptive sampling / sequential interim looks\n * - Resume from partial state across crashes\n * - LLM-call retry beyond what the caller's transport already does\n */\n\nimport {\n type AgentProfileCell,\n type AgentProfileCellInput,\n buildAgentProfileCell,\n verifyAgentProfileCell,\n} from './agent-profile-cell'\nimport type { ChatClient } from './analyst/chat-client'\nimport { hashJson } from './pre-registration'\nimport type {\n JudgeScoresRecord,\n RunCostProvenance,\n RunJudgeMetadata,\n RunOutcome,\n RunRecord,\n RunSplitTag,\n RunTaskFailure,\n RunTokenUsage,\n} from './run-record'\nimport { validateRunRecord } from './run-record'\nimport { type ResearchReport, type ResearchReportOptions, researchReport } from './summary-report'\nimport type { RunCompleteHook } from './trace/emitter'\nimport { TraceEmitter } from './trace/emitter'\nimport {\n assertRunCaptured,\n RunIntegrityError,\n type RunIntegrityExpectations,\n type RunIntegrityReport,\n} from './trace/integrity'\nimport { FileSystemRawProviderSink, type RawProviderSink } from './trace/raw-provider-sink'\nimport type { TraceStore } from './trace/store'\n\n// ── Public types ─────────────────────────────────────────────────────────\n\nexport interface CampaignVariant<V> {\n id: string\n payload: V\n}\n\nexport interface CampaignScenario {\n scenarioId: string\n /** Free-form metadata propagated to runs and reports. */\n tags?: Record<string, string>\n}\n\nexport interface CampaignRunContext<V> {\n /** Stable run id. The campaign generates this; the runner does not. */\n runId: string\n /** Logical experiment id (campaignId by default; overridable per-run via opts). */\n experimentId: string\n variant: V\n variantId: string\n scenarioId: string\n scenarioTags: Record<string, string>\n seed: number\n splitTag: RunSplitTag\n /**\n * The TraceEmitter for this run, with `onRunComplete` hooks pre-wired\n * (analyst auto-execution if configured, plus integrity check). The\n * runner MUST call `emitter.startRun` before doing any work and either\n * `emitter.endRun` or `emitter.abortRun` before returning.\n */\n emitter: TraceEmitter\n store: TraceStore\n rawSink: RawProviderSink\n /**\n * The run's model transport, built by `chatFactory` with this run's\n * `rawSink` and `runId` already bound.\n */\n chat: ChatClient\n}\n\n/** What the campaign binds into the run's transport. */\nexport interface CampaignChatWiring {\n /**\n * Raw provider sink for this run. Bind it into the transport: the campaign's\n * integrity check requires every LLM span to carry a matching raw request\n * event, so a transport built without it fails `assertRunCaptured`.\n */\n rawSink: RawProviderSink\n runId: string\n}\n\ninterface CampaignRunOutcomeFields {\n /** Did the run pass? Mirrors `RunOutcome.pass` semantics. */\n pass: boolean\n /** Score for the run on its split. Maps to `searchScore` or `holdoutScore`. */\n score: number\n /** Cost in USD, or null when the runner could not capture it. */\n costUsd: number | null\n /** Source of the cost amount. */\n costProvenance: RunCostProvenance\n tokenUsage: RunTokenUsage\n /** Snapshot model id (e.g. `claude-sonnet-4-6@2025-04-15`). */\n model: string\n /** sha256 of the effective prompt sent to the model. */\n promptHash: string\n /** sha256 of the effective config (model, temperature, tools, judges, splits). */\n configHash: string\n /** Optional extra numeric metrics to land in `outcome.raw`. */\n raw?: Record<string, number>\n /** Optional judge metadata when a judge was used. */\n judgeMetadata?: RunJudgeMetadata\n /**\n * Optional per-judge / per-dim breakdown for ensemble-judged runs.\n * Propagated to `outcome.judgeScores` on the resulting `RunRecord`.\n * Single-judge or scalar-only runs leave this unset.\n */\n judgeScores?: JudgeScoresRecord\n /**\n * Agent profile cell observed by the runner. When supplied, it overrides\n * `EvalCampaignOptions.agentProfile` for this run and must match the\n * outcome's `model` and `promptHash`.\n */\n agentProfile?: AgentProfileCell | AgentProfileCellInput\n}\n\n/** Campaign result with the same task-failure invariant as `RunRecord`. */\nexport type CampaignRunOutcome = CampaignRunOutcomeFields & RunTaskFailure\n\nexport type CampaignRunner<V> = (ctx: CampaignRunContext<V>) => Promise<CampaignRunOutcome>\n\nexport type CampaignIntegrityPolicy = 'throw' | 'mark_failed' | 'log'\n\nexport interface EvalCampaignOptions<V> {\n /**\n * Stable id for the campaign. Used as the default `experimentId` on\n * every run, and folded into the campaign fingerprint.\n */\n campaignId: string\n variants: CampaignVariant<V>[]\n scenarios: CampaignScenario[]\n /** Default `[0, 1, 2]`. */\n seeds?: number[]\n /** Default `'holdout'` — the split that anchors a launch decision. */\n splitTag?: RunSplitTag\n /** Git SHA the campaign is run against. Mandatory; `RunRecord` rejects unset. */\n commitSha: string\n /**\n * Build the model transport for one run. agent-eval executes no paid model:\n * the caller owns the transport and the credential never enters this\n * package. The campaign calls this once per run and passes the run's raw\n * provider sink and `runId`, so a transport that binds them captures the\n * raw HTTP envelope `assertRunCaptured` checks for.\n */\n chatFactory: (wiring: CampaignChatWiring) => ChatClient\n /**\n * Caller-declared identity of the execution route, folded into the campaign\n * fingerprint so two campaigns run against different endpoints do not share\n * one identity. agent-eval no longer knows the endpoint; the owner of\n * execution names it.\n */\n executionRef?: string\n /**\n * Per-run TraceStore factory. Common shape: a fresh store per run keyed\n * on `runId`. Implementations that share a store across the campaign\n * are valid — the campaign only writes through `emitter`.\n */\n storeFactory: (params: CampaignFactoryParams) => TraceStore\n /**\n * Per-run RawProviderSink factory. Defaults to `FileSystemRawProviderSink`\n * rooted at `${workDir}/raw-events/${runId}` if `workDir` is supplied;\n * otherwise required. Forensic capture is non-negotiable in a campaign\n * run — pass `NoopRawProviderSink` explicitly if you want to opt out.\n */\n rawSinkFactory?: (params: CampaignFactoryParams) => RawProviderSink\n /**\n * Filesystem root for default `rawSinkFactory`. Ignored if\n * `rawSinkFactory` is supplied.\n */\n workDir?: string\n /**\n * Extra `onRunComplete` hooks the campaign appends (after its own\n * integrity-check hook). Pass `traceAnalystOnRunComplete(...)` here.\n */\n onRunComplete?: RunCompleteHook[]\n /**\n * Per-run integrity expectations. Defaults to:\n * `{ llmSpansMin: 1, requireRawCoverageOfLlmSpans: true, requireOutcome: true }`.\n * Override (e.g. `{ llmSpansMin: 0 }`) for runs that don't call LLMs.\n */\n integrity?: RunIntegrityExpectations\n /** Behaviour when integrity fails. Default `'mark_failed'`. */\n onIntegrityFailure?: CampaignIntegrityPolicy\n /**\n * Per-run runner. Receives a fully-wired context; produces an outcome\n * the campaign converts into a `RunRecord`.\n */\n runner: CampaignRunner<V>\n /**\n * If set, the campaign computes `researchReport` at the end. `comparator`\n * is a `variantId`. Other fields are forwarded verbatim.\n */\n report?: { comparator?: string } & Omit<\n ResearchReportOptions,\n 'comparator' | 'preregistrationHash' | 'generatedAt'\n >\n /**\n * Hash of a signed `HypothesisManifest` (see `pre-registration.ts`).\n * Embedded in the campaign fingerprint and the research report.\n */\n preregistrationHash?: string\n /** Local concurrency. Default `1` (sequential). */\n concurrency?: number\n /**\n * Override the time source. Tests pass a mock to make wallMs deterministic.\n */\n now?: () => number\n /** Override the runId generator. Tests pin this. */\n runId?: (params: CampaignFactoryParams) => string\n /**\n * Agent profile cell for campaign runs. Static profiles can pass an object;\n * routers or variant-specific harnesses can pass a factory. The campaign\n * stamps the built cell onto every `RunRecord` and rejects profile/model or\n * profile/prompt contradictions.\n */\n agentProfile?:\n | AgentProfileCell\n | AgentProfileCellInput\n | ((\n params: CampaignFactoryParams & {\n variant: V\n scenarioTags: Record<string, string>\n },\n ) =>\n | AgentProfileCell\n | AgentProfileCellInput\n | Promise<AgentProfileCell | AgentProfileCellInput>)\n}\n\nexport interface CampaignFactoryParams {\n campaignId: string\n runId: string\n variantId: string\n scenarioId: string\n seed: number\n}\n\nexport interface FailedRun {\n runId: string\n variantId: string\n scenarioId: string\n seed: number\n reason: string\n error?: string\n}\n\nexport interface EvalCampaignResult {\n campaignId: string\n /** SHA-256 over canonicalised `(variantIds, scenarioIds, seeds, comparator, splitTag, executionRef, preregistrationHash)`. */\n campaignFingerprint: string\n preregistrationHash: string | null\n /** Successful runs only. Failed runs land in `failedRuns`. */\n runs: RunRecord[]\n /** Integrity reports for every successful run. */\n integrityReports: RunIntegrityReport[]\n failedRuns: FailedRun[]\n /** Computed when `report` is set on options. */\n report?: ResearchReport\n startedAt: string\n endedAt: string\n}\n\n// ── Implementation ───────────────────────────────────────────────────────\n\nconst DEFAULT_INTEGRITY: RunIntegrityExpectations = {\n llmSpansMin: 1,\n requireRawCoverageOfLlmSpans: true,\n requireOutcome: true,\n}\n\ntype CampaignCell<V> = { variant: CampaignVariant<V>; scenario: CampaignScenario; seed: number }\n\ntype CampaignRunResult = { record: RunRecord; integrity: RunIntegrityReport }\n\n/** Resolved options shared by every step of one campaign. */\ninterface CampaignSettings {\n seeds: number[]\n splitTag: RunSplitTag\n concurrency: number\n integrity: RunIntegrityExpectations\n onIntegrityFailure: CampaignIntegrityPolicy\n now: () => number\n executionRef: string | null\n preregistrationHash: string | null\n rawSinkFactory: (params: CampaignFactoryParams) => RawProviderSink\n}\n\n/**\n * Mutable state of one campaign's worker pool.\n *\n * A genuine (non-CellExecutionError) error from any worker is a bug, not a\n * run-level failure. We must NOT let `Promise.all` reject mid-flight and\n * orphan the other workers' in-progress runs (emitters never finalized,\n * sinks/handles leak, partial work silently discarded). Instead: capture the\n * first genuine error, stop dispatching new cells so in-flight workers wind\n * down, finalize every still-open run, then re-throw the aggregated error.\n */\ninterface CampaignPool<V> {\n opts: EvalCampaignOptions<V>\n settings: CampaignSettings\n cells: CampaignCell<V>[]\n cursor: number\n aborting: boolean\n genuineErrors: unknown[]\n /**\n * Emitters for runs that are currently mid-flight, keyed by runId. A worker\n * registers its emitter before invoking the runner and removes it once the\n * run is finalized (via endRun/abortRun, success or failure). Anything left\n * here after the pool settles is an orphan we must abort.\n */\n openRuns: Map<string, TraceEmitter>\n runs: RunRecord[]\n integrityReports: RunIntegrityReport[]\n failedRuns: FailedRun[]\n}\n\nexport async function runEvalCampaign<V>(\n opts: EvalCampaignOptions<V>,\n): Promise<EvalCampaignResult> {\n assertCampaignPreflight(opts)\n const settings = resolveCampaignSettings(opts)\n const campaignFingerprint = await fingerprintCampaign(opts, settings)\n\n const startedAt = new Date(settings.now()).toISOString()\n const pool: CampaignPool<V> = {\n opts,\n settings,\n cells: planCampaignCells(opts, settings.seeds),\n cursor: 0,\n aborting: false,\n genuineErrors: [],\n openRuns: new Map(),\n runs: [],\n integrityReports: [],\n failedRuns: [],\n }\n await drainCampaignPool(pool)\n\n const report = await buildCampaignReport(opts, settings, pool.runs)\n const endedAt = new Date(settings.now()).toISOString()\n\n return {\n campaignId: opts.campaignId,\n campaignFingerprint,\n preregistrationHash: settings.preregistrationHash,\n runs: pool.runs,\n integrityReports: pool.integrityReports,\n failedRuns: pool.failedRuns,\n report,\n startedAt,\n endedAt,\n }\n}\n\n/** Reject structurally invalid campaigns before any work starts. */\nfunction assertCampaignPreflight<V>(opts: EvalCampaignOptions<V>): void {\n if (opts.variants.length === 0) {\n throw new Error('runEvalCampaign: variants must be non-empty.')\n }\n if (opts.scenarios.length === 0) {\n throw new Error('runEvalCampaign: scenarios must be non-empty.')\n }\n const variantIds = new Set<string>()\n for (const v of opts.variants) {\n if (variantIds.has(v.id)) {\n throw new Error(`runEvalCampaign: duplicate variant id \"${v.id}\".`)\n }\n variantIds.add(v.id)\n }\n const scenarioIds = new Set<string>()\n for (const s of opts.scenarios) {\n if (scenarioIds.has(s.scenarioId)) {\n throw new Error(`runEvalCampaign: duplicate scenarioId \"${s.scenarioId}\".`)\n }\n scenarioIds.add(s.scenarioId)\n }\n if (opts.report?.comparator && !variantIds.has(opts.report.comparator)) {\n throw new Error(\n `runEvalCampaign: report.comparator \"${opts.report.comparator}\" is not a configured variantId.`,\n )\n }\n if (!opts.commitSha) {\n throw new Error('runEvalCampaign: commitSha is required (every RunRecord needs it).')\n }\n}\n\n/** Apply defaults to the optional campaign options. */\nfunction resolveCampaignSettings<V>(opts: EvalCampaignOptions<V>): CampaignSettings {\n return {\n seeds: opts.seeds ?? [0, 1, 2],\n splitTag: opts.splitTag ?? 'holdout',\n concurrency: Math.max(1, opts.concurrency ?? 1),\n integrity: { ...DEFAULT_INTEGRITY, ...(opts.integrity ?? {}) },\n onIntegrityFailure: opts.onIntegrityFailure ?? 'mark_failed',\n now: opts.now ?? (() => Date.now()),\n executionRef: opts.executionRef ?? null,\n preregistrationHash: opts.preregistrationHash ?? null,\n rawSinkFactory: opts.rawSinkFactory ?? defaultRawSinkFactory(opts.workDir),\n }\n}\n\n/** SHA-256 over the canonicalised matrix definition. */\nfunction fingerprintCampaign<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n): Promise<string> {\n return hashJson({\n campaignId: opts.campaignId,\n variants: opts.variants.map((v) => v.id).sort(),\n scenarios: opts.scenarios.map((s) => s.scenarioId).sort(),\n seeds: [...settings.seeds].sort((a, b) => a - b),\n splitTag: settings.splitTag,\n comparator: opts.report?.comparator ?? null,\n executionRef: settings.executionRef,\n preregistrationHash: settings.preregistrationHash,\n })\n}\n\n/** Expand variants x scenarios x seeds, variant-major. */\nfunction planCampaignCells<V>(opts: EvalCampaignOptions<V>, seeds: number[]): CampaignCell<V>[] {\n const cells: CampaignCell<V>[] = []\n for (const variant of opts.variants) {\n for (const scenario of opts.scenarios) {\n for (const seed of seeds) {\n cells.push({ variant, scenario, seed })\n }\n }\n }\n return cells\n}\n\n/**\n * Run the bounded-concurrency worker pool to completion, finalize any run left\n * open, and re-throw the genuine errors the workers captured.\n */\nasync function drainCampaignPool<V>(pool: CampaignPool<V>): Promise<void> {\n const workers = Array.from(\n { length: Math.min(pool.settings.concurrency, pool.cells.length) },\n () => campaignWorker(pool),\n )\n // allSettled (not all): a genuine error in one worker must not reject the\n // pool mid-flight and orphan the others. Each worker captures its own\n // genuine error into `genuineErrors` and returns; we re-throw below.\n await Promise.allSettled(workers)\n\n // Finalize any run still open after the pool wound down. With the\n // stop-dispatch flag these are the runs that were mid-flight in peer workers\n // when the first genuine error fired — abort them so their emitters finalize\n // (hooks fire, store records a terminal status) instead of leaking.\n for (const [runId, emitter] of pool.openRuns) {\n await finalizeAbort(emitter, runId, 'campaign aborted: genuine error in a sibling run')\n }\n pool.openRuns.clear()\n\n if (pool.genuineErrors.length > 0) {\n throw pool.genuineErrors.length === 1\n ? pool.genuineErrors[0]\n : new AggregateError(\n pool.genuineErrors,\n `runEvalCampaign: ${pool.genuineErrors.length} runs failed with genuine (non-run-level) errors`,\n )\n }\n}\n\n/** Pull cells off the shared cursor until none remain or the pool is aborting. */\nasync function campaignWorker<V>(pool: CampaignPool<V>): Promise<void> {\n while (!pool.aborting) {\n const i = pool.cursor++\n if (i >= pool.cells.length) return\n const cell = pool.cells[i]!\n try {\n const result = await runCampaignCell(pool, cell)\n pool.runs.push(result.record)\n pool.integrityReports.push(result.integrity)\n } catch (err) {\n if (err instanceof CellExecutionError) {\n pool.failedRuns.push(err.failed)\n if (err.integrity) pool.integrityReports.push(err.integrity)\n } else {\n // Genuine bug — not a runner failure, not an integrity failure.\n // Capture it and stop dispatching so peers wind down gracefully;\n // re-thrown after the pool settles. Do not surface here — that would\n // reject Promise.all and orphan the other workers' runs.\n pool.genuineErrors.push(err)\n pool.aborting = true\n return\n }\n }\n }\n}\n\n/** Run one matrix cell: runner, integrity check, then the validated RunRecord. */\nasync function runCampaignCell<V>(\n pool: CampaignPool<V>,\n cell: CampaignCell<V>,\n): Promise<CampaignRunResult> {\n const { opts, settings } = pool\n const runId = (opts.runId ?? defaultRunId)({\n campaignId: opts.campaignId,\n runId: '', // unused by default generator\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n })\n const factoryParams: CampaignFactoryParams = {\n campaignId: opts.campaignId,\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n }\n const store = opts.storeFactory(factoryParams)\n const rawSink = settings.rawSinkFactory(factoryParams)\n\n const emitter = new TraceEmitter(store, {\n runId,\n now: opts.now,\n onRunComplete: opts.onRunComplete,\n })\n // Track this run as open so a genuine error elsewhere in the pool can\n // finalize it instead of orphaning it. Removed in the finally below.\n pool.openRuns.set(runId, emitter)\n\n const chat = opts.chatFactory({ rawSink, runId })\n\n const ctx: CampaignRunContext<V> = {\n runId,\n experimentId: opts.campaignId,\n variant: cell.variant.payload,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n scenarioTags: cell.scenario.tags ?? {},\n seed: cell.seed,\n splitTag: settings.splitTag,\n emitter,\n store,\n rawSink,\n chat,\n }\n\n try {\n const wallStart = settings.now()\n const outcome = await invokeCampaignRunner(opts, cell, ctx)\n const wallMs = settings.now() - wallStart\n\n const integrityReport = await assertRunCaptured(store, runId, {\n ...settings.integrity,\n rawSink,\n })\n if (!integrityReport.ok) admitOrRejectIntegrity(settings, cell, runId, integrityReport)\n\n const record = buildCampaignRunRecord(opts, settings, cell, runId, outcome, wallMs)\n await stampAgentProfile(opts, cell, record, runId, outcome)\n return { record: validateRunRecord(record), integrity: integrityReport }\n } finally {\n // This run's worker has finished with it (success, run-level failure, or\n // genuine error). It is no longer the pool's job to finalize — drop it so\n // the post-settle sweep doesn't double-abort a finalized run.\n pool.openRuns.delete(runId)\n }\n}\n\n/** Invoke the runner; a throw aborts the run and becomes a run-level failure. */\nasync function invokeCampaignRunner<V>(\n opts: EvalCampaignOptions<V>,\n cell: CampaignCell<V>,\n ctx: CampaignRunContext<V>,\n): Promise<CampaignRunOutcome> {\n try {\n return await opts.runner(ctx)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n // The runner threw mid-execution. Abort the run so the emitter\n // finalizes. The only benign abortRun failure is \"the runner never\n // started the run\" (nothing to finalize). A store-write failure (disk\n // full, FS error) is a genuine diagnostic — surface it rather than\n // masking it as a plain runner failure.\n await finalizeAbort(ctx.emitter, ctx.runId, message)\n throw new CellExecutionError({\n runId: ctx.runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n reason: 'runner_threw',\n error: message,\n })\n }\n}\n\n/** Apply the integrity-failure policy to a report that is not ok. */\nfunction admitOrRejectIntegrity<V>(\n settings: CampaignSettings,\n cell: CampaignCell<V>,\n runId: string,\n integrityReport: RunIntegrityReport,\n): void {\n switch (settings.onIntegrityFailure) {\n case 'throw':\n throw new RunIntegrityError(integrityReport)\n case 'mark_failed':\n throw new CellExecutionError(\n {\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n reason: 'integrity_failed',\n error: integrityReport.issues.map((i) => i.code).join(', '),\n },\n integrityReport,\n )\n case 'log':\n // Caller wants the run admitted with a flagged report; fall through.\n break\n }\n}\n\n/** Assemble the RunRecord for a successful run, before profile stamping. */\nfunction buildCampaignRunRecord<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n cell: CampaignCell<V>,\n runId: string,\n outcome: CampaignRunOutcome,\n wallMs: number,\n): RunRecord {\n const recordOutcome: RunOutcome = {\n raw: outcome.raw ?? {},\n }\n if (settings.splitTag === 'holdout') recordOutcome.holdoutScore = outcome.score\n else recordOutcome.searchScore = outcome.score\n if (outcome.judgeScores !== undefined) recordOutcome.judgeScores = outcome.judgeScores\n\n return {\n runId,\n experimentId: opts.campaignId,\n candidateId: cell.variant.id,\n seed: cell.seed,\n model: outcome.model,\n promptHash: outcome.promptHash,\n configHash: outcome.configHash,\n commitSha: opts.commitSha,\n wallMs,\n costUsd: outcome.costUsd,\n costProvenance: outcome.costProvenance,\n tokenUsage: outcome.tokenUsage,\n terminalOutcome: 'succeeded',\n judgeMetadata: outcome.judgeMetadata,\n outcome: recordOutcome,\n ...(outcome.failureClass ? { failureClass: outcome.failureClass } : {}),\n failureMode: outcome.failureMode,\n splitTag: settings.splitTag,\n scenarioId: cell.scenario.scenarioId,\n }\n}\n\n/** Resolve the run's agent profile (outcome first, then options) and stamp it on the record. */\nasync function stampAgentProfile<V>(\n opts: EvalCampaignOptions<V>,\n cell: CampaignCell<V>,\n record: RunRecord,\n runId: string,\n outcome: CampaignRunOutcome,\n): Promise<void> {\n const profileSource =\n outcome.agentProfile ??\n (typeof opts.agentProfile === 'function'\n ? await opts.agentProfile({\n campaignId: opts.campaignId,\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n variant: cell.variant.payload,\n scenarioTags: cell.scenario.tags ?? {},\n })\n : opts.agentProfile)\n if (profileSource !== undefined) {\n const agentProfile = await resolveAgentProfileCell(profileSource)\n assertAgentProfileMatchesRun(agentProfile, outcome.model, outcome.promptHash)\n record.agentProfile = agentProfile\n }\n}\n\n/** Build the optional research report over the successful runs. */\nasync function buildCampaignReport<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n runs: RunRecord[],\n): Promise<ResearchReport | undefined> {\n if (!opts.report) return undefined\n const reportOpts: ResearchReportOptions = {\n ...opts.report,\n comparator: opts.report.comparator,\n split: settings.splitTag === 'dev' ? 'search' : settings.splitTag,\n generatedAt: new Date(settings.now()).toISOString(),\n preregistrationHash: settings.preregistrationHash ?? undefined,\n }\n return researchReport(runs, reportOpts)\n}\n\n// ── Internal ─────────────────────────────────────────────────────────────\n\nclass CellExecutionError extends Error {\n readonly failed: FailedRun\n readonly integrity?: RunIntegrityReport\n constructor(failed: FailedRun, integrity?: RunIntegrityReport) {\n super(`cell ${failed.variantId}/${failed.scenarioId}@${failed.seed} failed: ${failed.reason}`)\n this.failed = failed\n this.integrity = integrity\n }\n}\n\n/**\n * Abort a run whose owning work threw or was orphaned by a sibling's genuine\n * error, finalizing the emitter so hooks fire and the store records a terminal\n * status. Safe to call unconditionally: it only aborts runs that are still\n * `running`. Two no-op cases are intentional and benign:\n *\n * - the run was never started (absent from the store) — nothing to finalize\n * - the run is already terminal (`completed` / `failed` / `aborted`) —\n * finalizing again would overwrite the real outcome (e.g. flip a passed run\n * to `aborted` with `{ pass: false, notes: reason }`), so we leave it alone\n *\n * Any OTHER failure of the store read or the abort write (disk full, FS fault,\n * backend down) is a genuine diagnostic and propagates rather than being\n * swallowed.\n */\nasync function finalizeAbort(emitter: TraceEmitter, runId: string, reason: string): Promise<void> {\n const existing = await emitter.traceStore.getRun(runId)\n if (existing === undefined) return // run never started; nothing to abort\n if (existing.status !== 'running') return // already finalized; never overwrite a real outcome\n // The emitter never throws on a failed store write; it counts it. A failed\n // abort write is a genuine diagnostic here, so read the count and surface it.\n const droppedBefore = emitter.captureStats().dropped\n await emitter.abortRun(reason)\n const after = emitter.captureStats()\n if (after.dropped > droppedBefore) {\n throw new Error(`finalizeAbort: run ${runId} could not be finalized: ${after.lastError}`)\n }\n}\n\nfunction defaultRawSinkFactory(workDir: string | undefined) {\n return (params: CampaignFactoryParams): RawProviderSink => {\n if (!workDir) {\n throw new Error(\n 'runEvalCampaign: rawSinkFactory not supplied and workDir not set. Pass either to enable raw provider capture, or pass `new NoopRawProviderSink()` via rawSinkFactory to opt out explicitly.',\n )\n }\n return new FileSystemRawProviderSink({\n dir: `${workDir}/raw-events/${params.runId}`,\n })\n }\n}\n\nasync function resolveAgentProfileCell(\n input: AgentProfileCell | AgentProfileCellInput,\n): Promise<AgentProfileCell> {\n if (isAgentProfileCell(input)) {\n if (!(await verifyAgentProfileCell(input))) {\n throw new Error(`runEvalCampaign: agentProfile.cellId does not match its content`)\n }\n return input\n }\n return buildAgentProfileCell(input)\n}\n\nfunction isAgentProfileCell(\n input: AgentProfileCell | AgentProfileCellInput,\n): input is AgentProfileCell {\n return 'schemaVersion' in input && 'cellId' in input\n}\n\nfunction assertAgentProfileMatchesRun(\n profile: AgentProfileCell,\n model: string,\n promptHash: string,\n): void {\n if (profile.model !== undefined && profile.model !== model) {\n throw new Error(\n `runEvalCampaign: agentProfile.model \"${profile.model}\" does not match outcome.model \"${model}\"`,\n )\n }\n if (profile.promptHash !== undefined && profile.promptHash !== promptHash) {\n throw new Error(\n `runEvalCampaign: agentProfile.promptHash \"${profile.promptHash}\" does not match outcome.promptHash \"${promptHash}\"`,\n )\n }\n}\n\nfunction defaultRunId(params: CampaignFactoryParams): string {\n // Stable across re-runs: fingerprint of (campaignId, variantId, scenarioId, seed).\n // Caller can override via opts.runId for non-deterministic IDs.\n const base = `${params.campaignId}::${params.variantId}::${params.scenarioId}::${params.seed}`\n // TWO 32-bit FNV-1a accumulators with different offsets, concatenated for a\n // 64-bit-wide id. Not crypto-grade; stability and uniqueness are what this\n // needs. Frozen: the value names a persisted cell, and the second\n // accumulator's offset is part of the identity, so no single-accumulator\n // helper can replace it.\n let h1 = 0x811c9dc5\n let h2 = 0x12345678\n for (let i = 0; i < base.length; i++) {\n const c = base.charCodeAt(i)\n h1 = Math.imul(h1 ^ c, 0x01000193) >>> 0\n h2 = Math.imul(h2 ^ c, 0x9e3779b1) >>> 0\n }\n return `run-${h1.toString(16).padStart(8, '0')}${h2.toString(16).padStart(8, '0')}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8SA,MAAM,oBAA8C;CAClD,aAAa;CACb,8BAA8B;CAC9B,gBAAgB;AAClB;AAgDA,eAAsB,gBACpB,MAC6B;CAC7B,wBAAwB,IAAI;CAC5B,MAAM,WAAW,wBAAwB,IAAI;CAC7C,MAAM,sBAAsB,MAAM,oBAAoB,MAAM,QAAQ;CAEpE,MAAM,YAAY,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,YAAY;CACvD,MAAM,OAAwB;EAC5B;EACA;EACA,OAAO,kBAAkB,MAAM,SAAS,KAAK;EAC7C,QAAQ;EACR,UAAU;EACV,eAAe,CAAC;EAChB,0BAAU,IAAI,IAAI;EAClB,MAAM,CAAC;EACP,kBAAkB,CAAC;EACnB,YAAY,CAAC;CACf;CACA,MAAM,kBAAkB,IAAI;CAE5B,MAAM,SAAS,MAAM,oBAAoB,MAAM,UAAU,KAAK,IAAI;CAClE,MAAM,UAAU,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,YAAY;CAErD,OAAO;EACL,YAAY,KAAK;EACjB;EACA,qBAAqB,SAAS;EAC9B,MAAM,KAAK;EACX,kBAAkB,KAAK;EACvB,YAAY,KAAK;EACjB;EACA;EACA;CACF;AACF;;AAGA,SAAS,wBAA2B,MAAoC;CACtE,IA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O,UAAU,IAAI,OAAO,WAAW,IAAI,OAAO;CAMxF,IAAI,KAAK;CACT,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,IAAI,KAAK,WAAW,CAAC;EAC3B,KAAK,KAAK,KAAK,KAAK,GAAG,QAAU,MAAM;EACvC,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU,MAAM;CACzC;CACA,OAAO,OAAO,GAAG,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AAClF"}
@@ -1,5 +1,5 @@
1
- import { t as CostLedger } from "./cost-ledger-BGZB6yY2.js";
2
- //#region src/analyst/evaluation-context.ts
1
+ import { t as CostLedger } from "./cost-ledger-CS8R3IZj.js";
2
+ // src/analyst/evaluation-context.ts
3
3
  /** One deadline, spending authority and usage bridge for every evaluation-backed analyst. */
4
4
  function analystEvaluationContext(context, actor) {
5
5
  const signals = context.signal ? [context.signal] : [];
@@ -44,8 +44,7 @@ function analystEvaluationContext(context, actor) {
44
44
  }
45
45
  };
46
46
  }
47
- //#endregion
48
- //#region src/evaluation.ts
47
+ // src/evaluation.ts
49
48
  /** A metered function, independent of providers, question formats, and application policy. */
50
49
  function createEvaluator(options) {
51
50
  const defaults = { ...options };
@@ -141,7 +140,6 @@ function asAnalyst(options) {
141
140
  }
142
141
  };
143
142
  }
144
- //#endregion
145
143
  export { analystEvaluationContext as i, asJudge as n, createEvaluator as r, asAnalyst as t };
146
144
 
147
- //# sourceMappingURL=evaluation-wdGyZ7jV.js.map
145
+ //# sourceMappingURL=evaluation-B8H3GYej.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"evaluation-wdGyZ7jV.js","names":[],"sources":["../src/analyst/evaluation-context.ts","../src/evaluation.ts"],"sourcesContent":["import { CostLedger } from '../cost-ledger'\nimport type { EvaluationContext } from '../evaluation'\nimport type { AnalystContext } from './types'\n\n/** One deadline, spending authority and usage bridge for every evaluation-backed analyst. */\nexport function analystEvaluationContext(\n context: AnalystContext,\n actor: string,\n): {\n evaluation: EvaluationContext\n analystContext: AnalystContext & { signal: AbortSignal }\n} {\n const signals = context.signal ? [context.signal] : []\n if (context.deadlineMs !== undefined) {\n const remaining = context.deadlineMs - Date.now()\n if (!Number.isFinite(remaining)) throw new TypeError('Analyst deadline must be finite')\n if (remaining <= 0) throw new DOMException('Analyst deadline exceeded', 'TimeoutError')\n signals.push(AbortSignal.timeout(Math.ceil(remaining)))\n }\n const signal = AbortSignal.any(signals)\n signal.throwIfAborted()\n return {\n analystContext: { ...context, signal },\n evaluation: {\n signal,\n // No implicit account overrides an evaluator's configured spending authority.\n costLedger:\n context.costLedger ??\n (context.budgetUsd === undefined\n ? undefined\n : new CostLedger({ costCeilingUsd: context.budgetUsd })),\n actor,\n channel: 'analyst',\n costPhase: context.costPhase,\n costTags: { ...context.tags, runId: context.runId, correlationId: context.correlationId },\n onReceipt: (receipt) =>\n context.recordUsage?.({\n calls: 1,\n tokens: receipt.usageUnknown\n ? null\n : { input: receipt.inputTokens, output: receipt.outputTokens },\n cost: receipt.costUnknown\n ? { kind: 'uncaptured', usd: null }\n : {\n kind: receipt.actualCostUsd === undefined ? 'estimated' : 'observed',\n usd: receipt.costUsd,\n },\n }),\n },\n }\n}\n","import { analystEvaluationContext } from './analyst/evaluation-context'\nimport type { Analyst, AnalystContext, AnalystFinding } from './analyst/types'\nimport type { JudgeConfig, JudgeScore, Scenario } from './campaign/types'\nimport type {\n CostChannel,\n CostLedgerHandle,\n CostReceipt,\n CostReceiptInput,\n MaximumCharge,\n} from './cost-ledger'\nimport { CostLedger } from './cost-ledger'\n\nexport interface EvaluationResult<T> {\n value: T\n receipt: CostReceipt\n durationMs: number\n}\n\nexport interface EvaluationContext {\n /** Physical paid-call identity, forwarded through the existing ledger and transport.\n * Reusing it in one ledger conflicts; it is not an automatic result-replay policy. */\n callId?: string\n signal?: AbortSignal\n costLedger?: CostLedgerHandle\n actor?: string\n channel?: CostChannel\n costPhase?: string\n costTags?: Record<string, string>\n maximumCharge?: MaximumCharge\n /** Awaited after accounting and before validation or result delivery. */\n onReceipt?: (receipt: CostReceipt) => void | Promise<void>\n}\n\nexport type CostedEvaluator<I, O> = (\n input: I,\n context?: EvaluationContext,\n) => Promise<EvaluationResult<O>>\n\nexport interface EvaluatorOptions<I, O> {\n execute: (input: I, context: { signal: AbortSignal; idempotencyKey: string }) => Promise<O>\n receipt: (value: O) => CostReceiptInput\n receiptFromError?: (error: Error) => CostReceiptInput | undefined\n model?: string | ((input: I) => string)\n costLedger?: CostLedgerHandle\n maximumCharge?: MaximumCharge\n /** Awaited after accounting, so invalid output never erases paid work. */\n validate?: (value: O, input: I) => void | Promise<void>\n}\n\n/** A metered function, independent of providers, question formats, and application policy. */\nexport function createEvaluator<I, O>(options: EvaluatorOptions<I, O>): CostedEvaluator<I, O> {\n const defaults = { ...options }\n const ledger = defaults.costLedger ?? new CostLedger()\n return async (input, context = {}) => {\n context.signal?.throwIfAborted()\n const started = performance.now()\n const paid = await (context.costLedger ?? ledger).runPaidCall({\n callId: context.callId,\n actor: context.actor ?? 'evaluation',\n channel: context.channel ?? 'evaluation',\n phase: context.costPhase ?? 'evaluation',\n tags: context.costTags,\n model: typeof defaults.model === 'function' ? defaults.model(input) : defaults.model,\n signal: context.signal,\n maximumCharge: context.maximumCharge ?? defaults.maximumCharge,\n execute: (signal, idempotencyKey) => defaults.execute(input, { signal, idempotencyKey }),\n receipt: defaults.receipt,\n receiptFromError: defaults.receiptFromError,\n })\n if (paid.receipt) await context.onReceipt?.(paid.receipt)\n if (!paid.succeeded) throw paid.error\n // A transport can complete after cancellation. Keep its paid receipt, not a live decision.\n context.signal?.throwIfAborted()\n await defaults.validate?.(paid.value, input)\n context.signal?.throwIfAborted()\n return { value: paid.value, receipt: paid.receipt, durationMs: performance.now() - started }\n }\n}\n\nexport interface EvaluationJudgeOptions<A, S extends Scenario, O> {\n name: string\n version: string\n dimensions: JudgeConfig<A, S>['dimensions']\n evaluate: CostedEvaluator<{ artifact: A; scenario: S }, O>\n map: (value: O, input: { artifact: A; scenario: S }) => JudgeScore | Promise<JudgeScore>\n /** Persist the complete observation before reducing it to a verdict. */\n record?: (\n result: EvaluationResult<O>,\n input: { artifact: A; scenario: S },\n ) => void | Promise<void>\n appliesTo?: (scenario: S) => boolean\n}\n\n/** Return the existing contract. Mapping never performs another inference call. */\nexport function asJudge<A, S extends Scenario, O>(\n options: EvaluationJudgeOptions<A, S, O>,\n): JudgeConfig<A, S> {\n // The version describes these callbacks, not later mutations of the caller's options.\n const config = { ...options, dimensions: structuredClone(options.dimensions) }\n return {\n name: config.name,\n judgeVersion: config.version,\n dimensions: config.dimensions,\n appliesTo: config.appliesTo,\n async score({ artifact, scenario, signal, costLedger, costPhase, costTags }) {\n signal.throwIfAborted()\n const input = { artifact, scenario }\n const result = await config.evaluate(input, {\n signal,\n costLedger,\n actor: config.name,\n channel: 'judge',\n costPhase,\n costTags: { ...costTags, scenarioId: scenario.id },\n })\n await config.record?.(result, input)\n signal.throwIfAborted()\n const score = await config.map(result.value, input)\n signal.throwIfAborted()\n return score\n },\n }\n}\n\nexport interface EvaluationAnalystOptions<I, O> {\n id: string\n version: string\n description: string\n inputKind: Analyst<I>['inputKind']\n cost: Analyst<I>['cost']\n evaluate: (\n input: I,\n context: EvaluationContext,\n analystContext: AnalystContext,\n ) => Promise<EvaluationResult<O>>\n map: (value: O, input: I, context: AnalystContext) => AnalystFinding[] | Promise<AnalystFinding[]>\n record?: (result: EvaluationResult<O>, input: I, context: AnalystContext) => void | Promise<void>\n}\n\n/** Registry, graph, and trace consumers keep the same Analyst interface. */\nexport function asAnalyst<I, O>(options: EvaluationAnalystOptions<I, O>): Analyst<I> {\n const config = { ...options, cost: structuredClone(options.cost) }\n return {\n id: config.id,\n version: config.version,\n description: config.description,\n inputKind: config.inputKind,\n cost: config.cost,\n async analyze(input, context) {\n const { evaluation, analystContext } = analystEvaluationContext(context, config.id)\n const signal = analystContext.signal\n const result = await config.evaluate(input, evaluation, analystContext)\n await config.record?.(result, input, analystContext)\n signal.throwIfAborted()\n const findings = await config.map(result.value, input, analystContext)\n signal.throwIfAborted()\n return findings\n },\n }\n}\n"],"mappings":";;;AAKA,SAAgB,yBACd,SACA,OAIA;CACA,MAAM,UAAU,QAAQ,SAAS,CAAC,QAAQ,MAAM,IAAI,CAAC;CACrD,IAAI,QAAQ,eAAe,KAAA,GAAW;EACpC,MAAM,YAAY,QAAQ,aAAa,KAAK,IAAI;EAChD,IAAI,CAAC,OAAO,SAAS,SAAS,GAAG,MAAM,IAAI,UAAU,iCAAiC;EACtF,IAAI,aAAa,GAAG,MAAM,IAAI,aAAa,6BAA6B,cAAc;EACtF,QAAQ,KAAK,YAAY,QAAQ,KAAK,KAAK,SAAS,CAAC,CAAC;CACxD;CACA,MAAM,SAAS,YAAY,IAAI,OAAO;CACtC,OAAO,eAAe;CACtB,OAAO;EACL,gBAAgB;GAAE,GAAG;GAAS;EAAO;EACrC,YAAY;GACV;GAEA,YACE,QAAQ,eACP,QAAQ,cAAc,KAAA,IACnB,KAAA,IACA,IAAI,WAAW,EAAE,gBAAgB,QAAQ,UAAU,CAAC;GAC1D;GACA,SAAS;GACT,WAAW,QAAQ;GACnB,UAAU;IAAE,GAAG,QAAQ;IAAM,OAAO,QAAQ;IAAO,eAAe,QAAQ;GAAc;GACxF,YAAY,YACV,QAAQ,cAAc;IACpB,OAAO;IACP,QAAQ,QAAQ,eACZ,OACA;KAAE,OAAO,QAAQ;KAAa,QAAQ,QAAQ;IAAa;IAC/D,MAAM,QAAQ,cACV;KAAE,MAAM;KAAc,KAAK;IAAK,IAChC;KACE,MAAM,QAAQ,kBAAkB,KAAA,IAAY,cAAc;KAC1D,KAAK,QAAQ;IACf;GACN,CAAC;EACL;CACF;AACF;;;;ACAA,SAAgB,gBAAsB,SAAwD;CAC5F,MAAM,WAAW,EAAE,GAAG,QAAQ;CAC9B,MAAM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A,UAAU;KAAE,GAAG;KAAU,YAAY,SAAS;IAAG;GACnD,CAAC;GACD,MAAM,OAAO,SAAS,QAAQ,KAAK;GACnC,OAAO,eAAe;GACtB,MAAM,QAAQ,MAAM,OAAO,IAAI,OAAO,OAAO,KAAK;GAClD,OAAO,eAAe;GACtB,OAAO;EACT;CACF;AACF;;AAkBA,SAAgB,UAAgB,SAAqD;CACnF,MAAM,SAAS;EAAE,GAAG;EAAS,MAAM,gBAAgB,QAAQ,IAAI;CAAE;CACjE,OAAO;EACL,IAAI,OAAO;EACX,SAAS,OAAO;EAChB,aAAa,OAAO;EACpB,WAAW,OAAO;EAClB,MAAM,OAAO;EACb,MAAM,QAAQ,OAAO,SAAS;GAC5B,MAAM,EAAE,YAAY,mBAAmB,yBAAyB,SAAS,OAAO,EAAE;GAClF,MAAM,SAAS,eAAe;GAC9B,MAAM,SAAS,MAAM,OAAO,SAAS,OAAO,YAAY,cAAc;GACtE,MAAM,OAAO,SAAS,QAAQ,OAAO,cAAc;GACnD,OAAO,eAAe;GACtB,MAAM,WAAW,MAAM,OAAO,IAAI,OAAO,OAAO,OAAO,cAAc;GACrE,OAAO,eAAe;GACtB,OAAO;EACT;CACF;AACF"}
1
+ {"version":3,"file":"evaluation-B8H3GYej.js","names":[],"sources":["../src/analyst/evaluation-context.ts","../src/evaluation.ts"],"sourcesContent":["import { CostLedger } from '../cost-ledger'\nimport type { EvaluationContext } from '../evaluation'\nimport type { AnalystContext } from './types'\n\n/** One deadline, spending authority and usage bridge for every evaluation-backed analyst. */\nexport function analystEvaluationContext(\n context: AnalystContext,\n actor: string,\n): {\n evaluation: EvaluationContext\n analystContext: AnalystContext & { signal: AbortSignal }\n} {\n const signals = context.signal ? [context.signal] : []\n if (context.deadlineMs !== undefined) {\n const remaining = context.deadlineMs - Date.now()\n if (!Number.isFinite(remaining)) throw new TypeError('Analyst deadline must be finite')\n if (remaining <= 0) throw new DOMException('Analyst deadline exceeded', 'TimeoutError')\n signals.push(AbortSignal.timeout(Math.ceil(remaining)))\n }\n const signal = AbortSignal.any(signals)\n signal.throwIfAborted()\n return {\n analystContext: { ...context, signal },\n evaluation: {\n signal,\n // No implicit account overrides an evaluator's configured spending authority.\n costLedger:\n context.costLedger ??\n (context.budgetUsd === undefined\n ? undefined\n : new CostLedger({ costCeilingUsd: context.budgetUsd })),\n actor,\n channel: 'analyst',\n costPhase: context.costPhase,\n costTags: { ...context.tags, runId: context.runId, correlationId: context.correlationId },\n onReceipt: (receipt) =>\n context.recordUsage?.({\n calls: 1,\n tokens: receipt.usageUnknown\n ? null\n : { input: receipt.inputTokens, output: receipt.outputTokens },\n cost: receipt.costUnknown\n ? { kind: 'uncaptured', usd: null }\n : {\n kind: receipt.actualCostUsd === undefined ? 'estimated' : 'observed',\n usd: receipt.costUsd,\n },\n }),\n },\n }\n}\n","import { analystEvaluationContext } from './analyst/evaluation-context'\nimport type { Analyst, AnalystContext, AnalystFinding } from './analyst/types'\nimport type { JudgeConfig, JudgeScore, Scenario } from './campaign/types'\nimport type {\n CostChannel,\n CostLedgerHandle,\n CostReceipt,\n CostReceiptInput,\n MaximumCharge,\n} from './cost-ledger'\nimport { CostLedger } from './cost-ledger'\n\nexport interface EvaluationResult<T> {\n value: T\n receipt: CostReceipt\n durationMs: number\n}\n\nexport interface EvaluationContext {\n /** Physical paid-call identity, forwarded through the existing ledger and transport.\n * Reusing it in one ledger conflicts; it is not an automatic result-replay policy. */\n callId?: string\n signal?: AbortSignal\n costLedger?: CostLedgerHandle\n actor?: string\n channel?: CostChannel\n costPhase?: string\n costTags?: Record<string, string>\n maximumCharge?: MaximumCharge\n /** Awaited after accounting and before validation or result delivery. */\n onReceipt?: (receipt: CostReceipt) => void | Promise<void>\n}\n\nexport type CostedEvaluator<I, O> = (\n input: I,\n context?: EvaluationContext,\n) => Promise<EvaluationResult<O>>\n\nexport interface EvaluatorOptions<I, O> {\n execute: (input: I, context: { signal: AbortSignal; idempotencyKey: string }) => Promise<O>\n receipt: (value: O) => CostReceiptInput\n receiptFromError?: (error: Error) => CostReceiptInput | undefined\n model?: string | ((input: I) => string)\n costLedger?: CostLedgerHandle\n maximumCharge?: MaximumCharge\n /** Awaited after accounting, so invalid output never erases paid work. */\n validate?: (value: O, input: I) => void | Promise<void>\n}\n\n/** A metered function, independent of providers, question formats, and application policy. */\nexport function createEvaluator<I, O>(options: EvaluatorOptions<I, O>): CostedEvaluator<I, O> {\n const defaults = { ...options }\n const ledger = defaults.costLedger ?? new CostLedger()\n return async (input, context = {}) => {\n context.signal?.throwIfAborted()\n const started = performance.now()\n const paid = await (context.costLedger ?? ledger).runPaidCall({\n callId: context.callId,\n actor: context.actor ?? 'evaluation',\n channel: context.channel ?? 'evaluation',\n phase: context.costPhase ?? 'evaluation',\n tags: context.costTags,\n model: typeof defaults.model === 'function' ? defaults.model(input) : defaults.model,\n signal: context.signal,\n maximumCharge: context.maximumCharge ?? defaults.maximumCharge,\n execute: (signal, idempotencyKey) => defaults.execute(input, { signal, idempotencyKey }),\n receipt: defaults.receipt,\n receiptFromError: defaults.receiptFromError,\n })\n if (paid.receipt) await context.onReceipt?.(paid.receipt)\n if (!paid.succeeded) throw paid.error\n // A transport can complete after cancellation. Keep its paid receipt, not a live decision.\n context.signal?.throwIfAborted()\n await defaults.validate?.(paid.value, input)\n context.signal?.throwIfAborted()\n return { value: paid.value, receipt: paid.receipt, durationMs: performance.now() - started }\n }\n}\n\nexport interface EvaluationJudgeOptions<A, S extends Scenario, O> {\n name: string\n version: string\n dimensions: JudgeConfig<A, S>['dimensions']\n evaluate: CostedEvaluator<{ artifact: A; scenario: S }, O>\n map: (value: O, input: { artifact: A; scenario: S }) => JudgeScore | Promise<JudgeScore>\n /** Persist the complete observation before reducing it to a verdict. */\n record?: (\n result: EvaluationResult<O>,\n input: { artifact: A; scenario: S },\n ) => void | Promise<void>\n appliesTo?: (scenario: S) => boolean\n}\n\n/** Return the existing contract. Mapping never performs another inference call. */\nexport function asJudge<A, S extends Scenario, O>(\n options: EvaluationJudgeOptions<A, S, O>,\n): JudgeConfig<A, S> {\n // The version describes these callbacks, not later mutations of the caller's options.\n const config = { ...options, dimensions: structuredClone(options.dimensions) }\n return {\n name: config.name,\n judgeVersion: config.version,\n dimensions: config.dimensions,\n appliesTo: config.appliesTo,\n async score({ artifact, scenario, signal, costLedger, costPhase, costTags }) {\n signal.throwIfAborted()\n const input = { artifact, scenario }\n const result = await config.evaluate(input, {\n signal,\n costLedger,\n actor: config.name,\n channel: 'judge',\n costPhase,\n costTags: { ...costTags, scenarioId: scenario.id },\n })\n await config.record?.(result, input)\n signal.throwIfAborted()\n const score = await config.map(result.value, input)\n signal.throwIfAborted()\n return score\n },\n }\n}\n\nexport interface EvaluationAnalystOptions<I, O> {\n id: string\n version: string\n description: string\n inputKind: Analyst<I>['inputKind']\n cost: Analyst<I>['cost']\n evaluate: (\n input: I,\n context: EvaluationContext,\n analystContext: AnalystContext,\n ) => Promise<EvaluationResult<O>>\n map: (value: O, input: I, context: AnalystContext) => AnalystFinding[] | Promise<AnalystFinding[]>\n record?: (result: EvaluationResult<O>, input: I, context: AnalystContext) => void | Promise<void>\n}\n\n/** Registry, graph, and trace consumers keep the same Analyst interface. */\nexport function asAnalyst<I, O>(options: EvaluationAnalystOptions<I, O>): Analyst<I> {\n const config = { ...options, cost: structuredClone(options.cost) }\n return {\n id: config.id,\n version: config.version,\n description: config.description,\n inputKind: config.inputKind,\n cost: config.cost,\n async analyze(input, context) {\n const { evaluation, analystContext } = analystEvaluationContext(context, config.id)\n const signal = analystContext.signal\n const result = await config.evaluate(input, evaluation, analystContext)\n await config.record?.(result, input, analystContext)\n signal.throwIfAborted()\n const findings = await config.map(result.value, input, analystContext)\n signal.throwIfAborted()\n return findings\n },\n }\n}\n"],"mappings":";;;AAKA,SAAgB,yBACd,SACA,OAIA;CACA,MAAM,UAAU,QAAQ,SAAS,CAAC,QAAQ,MAAM,IAAI,CAAC;CACrD,IAAI,QAAQ,eAAe,KAAA,GAAW;EACpC,MAAM,YAAY,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;EACL,IAAI,OAAO;EACX,SAAS,OAAO;EAChB,aAAa,OAAO;EACpB,WAAW,OAAO;EAClB,MAAM,OAAO;EACb,MAAM,QAAQ,OAAO,SAAS;GAC5B,MAAM,EAAE,YAAY,mBAAmB,yBAAyB,SAAS,OAAO,EAAE;GAClF,MAAM,SAAS,eAAe;GAC9B,MAAM,SAAS,MAAM,OAAO,SAAS,OAAO,YAAY,cAAc;GACtE,MAAM,OAAO,SAAS,QAAQ,OAAO,cAAc;GACnD,OAAO,eAAe;GACtB,MAAM,WAAW,MAAM,OAAO,IAAI,OAAO,OAAO,OAAO,cAAc;GACrE,OAAO,eAAe;GACtB,OAAO;EACT;CACF;AACF"}
@@ -1,7 +1,6 @@
1
- import { d as CostReceipt, f as CostReceiptInput, h as MaximumCharge, i as CostChannel, o as CostLedgerHandle } from "./cost-ledger-C1W3ICmP.js";
2
- import { i as AnalystFinding, n as AnalystContext, t as Analyst } from "./types-6Lfdlshp.js";
3
- import { R as Scenario, S as JudgeConfig, w as JudgeScore } from "./types-M6eF9m-r.js";
4
- //#region src/evaluation.d.ts
1
+ import { d as CostReceipt, f as CostReceiptInput, h as MaximumCharge, i as CostChannel, o as CostLedgerHandle } from "./cost-ledger-Czro9wmo.js";
2
+ import { i as AnalystFinding, n as AnalystContext, t as Analyst } from "./types-DzCO-S1m.js";
3
+ import { R as Scenario, S as JudgeConfig, w as JudgeScore } from "./types-C54Uk_a1.js";
5
4
  interface EvaluationResult<T> {
6
5
  value: T;
7
6
  receipt: CostReceipt;
@@ -70,6 +69,5 @@ interface EvaluationAnalystOptions<I, O> {
70
69
  }
71
70
  /** Registry, graph, and trace consumers keep the same Analyst interface. */
72
71
  declare function asAnalyst<I, O>(options: EvaluationAnalystOptions<I, O>): Analyst<I>;
73
- //#endregion
74
72
  export { EvaluationResult as a, asJudge as c, EvaluationJudgeOptions as i, createEvaluator as l, EvaluationAnalystOptions as n, EvaluatorOptions as o, EvaluationContext as r, asAnalyst as s, CostedEvaluator as t };
75
- //# sourceMappingURL=evaluation-DblGquCB.d.ts.map
73
+ //# sourceMappingURL=evaluation-BPqUvZ66.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation-BPqUvZ66.d.ts","names":[],"sources":["../src/evaluation.ts"],"mappings":";;;UAYiB,iBAAiB;EAChC,OAAO;EACP,SAAS;EACT;;UAGe;;;EAGf;EACA,SAAS;EACT,aAAa;EACb;EACA,UAAU;EACV;EACA,WAAW;EACX,gBAAgB;;EAEhB,aAAa,SAAS,uBAAuB;;KAGnC,gBAAgB,GAAG,MAC7B,OAAO,GACP,UAAU,sBACP,QAAQ,iBAAiB;UAEb,iBAAiB,GAAG;EACnC,UAAU,OAAO,GAAG;IAAW,QAAQ;IAAa;QAA6B,QAAQ;EACzF,UAAU,OAAO,MAAM;EACvB,oBAAoB,OAAO,UAAU;EACrC,mBAAmB,OAAO;EAC1B,aAAa;EACb,gBAAgB;;EAEhB,YAAY,OAAO,GAAG,OAAO,aAAa;;;iBAI5B,gBAAgB,GAAG,GAAG,SAAS,iBAAiB,GAAG,KAAK,gBAAgB,GAAG;UA6B1E,uBAAuB,GAAG,UAAU,UAAU;EAC7D;EACA;EACA,YAAY,YAAY,GAAG;EAC3B,UAAU;IAAkB,UAAU;IAAG,UAAU;KAAK;EACxD,MAAM,OAAO,GAAG;IAAS,UAAU;IAAG,UAAU;QAAQ,aAAa,QAAQ;;EAE7E,UACE,QAAQ,iBAAiB,IACzB;IAAS,UAAU;IAAG,UAAU;eACtB;EACZ,aAAa,UAAU;;;iBAIT,QAAQ,GAAG,UAAU,UAAU,GAC7C,SAAS,uBAAuB,GAAG,GAAG,KACrC,YAAY,GAAG;UA4BD,yBAAyB,GAAG;EAC3C;EACA;EACA;EACA,WAAW,QAAQ;EACnB,MAAM,QAAQ;EACd,WACE,OAAO,GACP,SAAS,mBACT,gBAAgB,mBACb,QAAQ,iBAAiB;EAC9B,MAAM,OAAO,GAAG,OAAO,GAAG,SAAS,mBAAmB,mBAAmB,QAAQ;EACjF,UAAU,QAAQ,iBAAiB,IAAI,OAAO,GAAG,SAAS,0BAA0B;;;iBAItE,UAAU,GAAG,GAAG,SAAS,yBAAyB,GAAG,KAAK,QAAQ"}
@@ -1,2 +1,2 @@
1
- import { a as EvaluationResult, c as asJudge, i as EvaluationJudgeOptions, l as createEvaluator, n as EvaluationAnalystOptions, o as EvaluatorOptions, r as EvaluationContext, s as asAnalyst, t as CostedEvaluator } from "./evaluation-DblGquCB.js";
1
+ import { a as EvaluationResult, c as asJudge, i as EvaluationJudgeOptions, l as createEvaluator, n as EvaluationAnalystOptions, o as EvaluatorOptions, r as EvaluationContext, s as asAnalyst, t as CostedEvaluator } from "./evaluation-BPqUvZ66.js";
2
2
  export { CostedEvaluator, EvaluationAnalystOptions, EvaluationContext, EvaluationJudgeOptions, EvaluationResult, EvaluatorOptions, asAnalyst, asJudge, createEvaluator };
@@ -1,2 +1 @@
1
- import { n as asJudge, r as createEvaluator, t as asAnalyst } from "./evaluation-wdGyZ7jV.js";
2
- export { asAnalyst, asJudge, createEvaluator };
1
+ export { t as asAnalyst, n as asJudge, r as createEvaluator } from "./evaluation-B8H3GYej.js";
@@ -1,6 +1,5 @@
1
- import { c as AnalystRunEvent, d as AnalystRunSummary, t as Analyst, u as AnalystRunResult } from "./types-6Lfdlshp.js";
1
+ import { c as AnalystRunEvent, d as AnalystRunSummary, t as Analyst, u as AnalystRunResult } from "./types-DzCO-S1m.js";
2
2
  import { z } from "zod";
3
- //#region src/analyst/exact-types.d.ts
4
3
  /** Analyst metadata required before the exact registry path will execute it. */
5
4
  interface ExactCapableAnalyst<TInput = unknown> extends Analyst<TInput> {
6
5
  /** Canonical JSON for every effective behavior knob not already bound by `version`. */
@@ -65,11 +64,11 @@ declare const analystSnapshotSchema: z.ZodObject<{
65
64
  id: z.ZodString;
66
65
  version: z.ZodString;
67
66
  input_kind: z.ZodEnum<{
68
- "artifact-dir": "artifact-dir";
69
67
  custom: "custom";
70
- "judge-input": "judge-input";
71
- "run-record": "run-record";
72
68
  "trace-store": "trace-store";
69
+ "artifact-dir": "artifact-dir";
70
+ "run-record": "run-record";
71
+ "judge-input": "judge-input";
73
72
  }>;
74
73
  cost: z.ZodDiscriminatedUnion<[z.ZodObject<{
75
74
  kind: z.ZodLiteral<"deterministic">;
@@ -155,11 +154,11 @@ declare const exactExecutionPlanSchema: z.ZodObject<{
155
154
  id: z.ZodString;
156
155
  version: z.ZodString;
157
156
  input_kind: z.ZodEnum<{
158
- "artifact-dir": "artifact-dir";
159
157
  custom: "custom";
160
- "judge-input": "judge-input";
161
- "run-record": "run-record";
162
158
  "trace-store": "trace-store";
159
+ "artifact-dir": "artifact-dir";
160
+ "run-record": "run-record";
161
+ "judge-input": "judge-input";
163
162
  }>;
164
163
  cost: z.ZodDiscriminatedUnion<[z.ZodObject<{
165
164
  kind: z.ZodLiteral<"deterministic">;
@@ -229,6 +228,5 @@ declare const exactExecutionPlanSchema: z.ZodObject<{
229
228
  }, z.core.$strict>;
230
229
  digest: z.ZodString;
231
230
  }, z.core.$strict>;
232
- //#endregion
233
231
  export { ExactAnalystRunPolicySnapshot as a, ExactAnalystSnapshot as c, ExactExecutionComponentSnapshot as d, ExactAnalystRunEvent as i, ExactCapableAnalyst as l, ExactAnalystExecutionPlanSnapshot as n, ExactAnalystRunResult as o, ExactAnalystRunCompletion as r, ExactAnalystRunSummary as s, ExactAnalystBudgetSnapshot as t, ExactExecutionComponentIdentity as u };
234
- //# sourceMappingURL=exact-types-Do63KoKn.d.ts.map
232
+ //# sourceMappingURL=exact-types-D98BKpxo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact-types-D98BKpxo.d.ts","names":[],"sources":["../src/analyst/exact-types.ts"],"mappings":";;;UAMiB,oBAAoB,0BAA0B,QAAQ;;WAE5D,iBAAiB,SAAS;;KAGhC,aAAa,KAAK,0BAA0B,mBACpC,aAAa,UACtB,+BACc,aAAa,IAAI,aAAa,EAAE,WAC5C;KAEM,uBAAuB,aAAa,EAAE,aAAa;KACnD,6BAA6B,aAAa,EAAE,aAAa;;UAGpD;EACf;EACA;EACA,QAAQ,SAAS;;;UAIF;EACf;EACA;EACA;;KAyBU,gCAAgC,aAAa,EAAE,aAAa;KAC5D,oCAAoC,aAC9C,EAAE,aAAa;KAGL,yBAAyB;;EAEnC;;KAGU;EACN;;EAEA;EACA;IAAS;IAAe;;;UAGb,8BAA8B;EAC7C,aAAa;EACb,gBAAgB;EAChB,YAAY;;;KAIF,wBACP,QAAQ;EAAmB;;EAC1B,gBAAgB;MAEjB,KAAK,QAAQ;EAAmB;;EAC/B,SAAS;KAEX,QAAQ;EAAmB;MAC1B,KAAK,QAAQ;EAAmB;;EAC/B,SAAS;MAEV,KAAK,QAAQ;EAAmB;;EAC/B,QAAQ;;cAwCR,uBAAqB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAOzB,EAAA,KAAA;cAII,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;GAaxB,EAAA,KAAA;cAiBI,sBAAoB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYxB,EAAA,KAAA;cAEI,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+E1B,EAAA,KAAA"}
@@ -1,4 +1,4 @@
1
- //#region src/trajectory-replay/steps.ts
1
+ // src/trajectory-replay/steps.ts
2
2
  /** Recorded returncode of a step, or null when the observation carries none. */
3
3
  function parseRecordedReturncode(observation) {
4
4
  if (!observation) return null;
@@ -168,8 +168,7 @@ function finalRecordedOutcome(steps) {
168
168
  reason: kind
169
169
  };
170
170
  }
171
- //#endregion
172
- //#region src/trajectory-replay/exec.ts
171
+ // src/trajectory-replay/exec.ts
173
172
  /**
174
173
  * mini-SWE runs every action as a fresh /bin/sh subshell from a fixed
175
174
  * workdir. Reproduce that exactly — and stay quote-proof for arbitrary
@@ -180,7 +179,6 @@ function wrapActionForExec(action, cwd) {
180
179
  const b64 = Buffer.from(action, "utf8").toString("base64");
181
180
  return `cd ${`'${cwd.replaceAll("'", `'\\''`)}'`} && printf %s ${b64} | base64 -d | sh`;
182
181
  }
183
- //#endregion
184
182
  export { classifyObservation as a, finalRecordedOutcome as c, isSubmitOnlyAction as d, parseObservationOutput as f, TIMEOUT_OBSERVATION_MARKER as i, isRecordedTimeout as l, FORMAT_ERROR_OBSERVATION_PREFIX as n, decodeRecordedTurns as o, parseRecordedReturncode as p, SUBMIT_ACTION_SIGNATURE as r, deriveFailureSignature as s, wrapActionForExec as t, isSubmitAction as u };
185
183
 
186
- //# sourceMappingURL=exec-CpbtOXVt.js.map
184
+ //# sourceMappingURL=exec-C0_AkLUv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec-CpbtOXVt.js","names":[],"sources":["../src/trajectory-replay/steps.ts","../src/trajectory-replay/exec.ts"],"sourcesContent":["/**\n * Recorded shell-trajectory steps and the observation grammar they carry.\n *\n * A recorded trajectory is the action/observation sequence an agent actually\n * ran. Scaffolds that execute one shell command per step (mini-SWE and the\n * CodeTracer-normalized corpora built from it) tag each observation with the\n * command's returncode and its combined output:\n *\n * <returncode>2</returncode>\n * <output>\n * …command output…\n * </output>\n *\n * That is one of four shapes a recorded turn carries, and the other three are\n * not command results at all:\n *\n * - a timeout notice, when the environment killed the command at its bound;\n * - a format-error notice, when the scaffold rejected the turn and ran\n * nothing;\n * - an elision marker `$<hex>`, when the published dump dropped the string.\n *\n * A turn also carries no observation when it is the run's last turn, because\n * the scaffold records an observation only when it hands one back to the model.\n *\n * The parsers here are the only place that grammar is decoded. Everything\n * downstream — replay verdicts, corpus enumeration, admission funnels, fix\n * prompts — reads the returncode, the output, and the failure signature through\n * these functions. A second decoder elsewhere is how a corpus reads as\n * unreplayable when it is not.\n */\n\n/**\n * One step of a recorded shell trajectory. Structural: any richer step record\n * (file refs, thinking text, tool type) satisfies it.\n */\nexport interface RecordedTrajectoryStep {\n /** 1-based position in the trajectory. */\n readonly step_id: number\n readonly action: string\n /** Null when the step recorded no observation (terminal submit steps). */\n readonly observation: string | null\n}\n\n/** Recorded returncode of a step, or null when the observation carries none. */\nexport function parseRecordedReturncode(observation: string | null): number | null {\n if (!observation) return null\n const m = /<returncode>(-?\\d+)<\\/returncode>/.exec(observation)\n return m ? Number(m[1]) : null\n}\n\n/** Text between the observation's <output> tags, or the raw observation when\n * the tags are absent. */\nexport function parseObservationOutput(observation: string | null): string {\n if (!observation) return ''\n const m = /<output>\\n?([\\s\\S]*?)\\n?<\\/output>/.exec(observation)\n return m ? m[1]! : observation\n}\n\n/**\n * Stable failure-signature candidate: the first error line, or a shell\n * command-not-found suffix. Null when neither exists — a verdict then falls\n * back to returncode-only matching and says so.\n * Pass an explicit signature to override (compiler quote glyphs vary with\n * locale, so a hand-picked ASCII substring is often more robust).\n */\nexport function deriveFailureSignature(observation: string | null): string | null {\n for (const line of parseObservationOutput(observation).split('\\n')) {\n if (/\\berror\\b/i.test(line)) return line.trim().slice(0, 200)\n // The shell prefix differs between recorded bash and replayed /bin/sh.\n const missingCommand = /([A-Za-z0-9_.+/-]+: (?:command )?not found)\\b/.exec(line)\n if (missingCommand) return missingCommand[1]!.slice(0, 200)\n }\n return null\n}\n\n/** mini-SWE's end-of-run submit convention: the agent echoes this sentinel\n * and dumps the diff. A label on this step marks a bad SUBMIT DECISION, not a\n * failed command — there is no executable failure to reproduce, so it is\n * never a counterfactual replay target. */\nexport const SUBMIT_ACTION_SIGNATURE = 'COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT'\n\nexport function isSubmitAction(action: string): boolean {\n return action.includes(SUBMIT_ACTION_SIGNATURE)\n}\n\n/**\n * True when the action is the sentinel echo and nothing else.\n *\n * The distinction decides whether a step may be dropped. An agent is told to\n * issue the sentinel alone, and 5.7% of recorded runs end on a command that\n * writes files or edits them and then echoes it. Dropping such a step because\n * it holds the sentinel would remove the run's last state change from the\n * replay, so the recorded end state and the replayed one would differ.\n */\nexport function isSubmitOnlyAction(action: string): boolean {\n return /^echo\\s+(?:\"COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT\"|'COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT'|COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT)$/.test(\n action.trim(),\n )\n}\n\n// ── Fields the published dump dropped ────────────────────────────────\n\n/**\n * A field the dump replaced with a counter instead of its text.\n *\n * The counter is hexadecimal and rises by one per dropped string in document\n * order, so a decimal-only reading (`$12`) accepts every marker that carries a\n * letter (`$3a`) as if it were real text. A command read that way replays as\n * the literal two-to-four characters `$3a`, which is not the command the run\n * executed.\n *\n * Nothing in the dump maps a marker back to its text: the same marker carries\n * different content in different rows, so there is no dictionary to read. A\n * field that matches is unrecoverable, so a caller rejects the row that holds\n * it rather than replaying the marker.\n */\nconst RECORDED_ELISION_PATTERN = /^\\$[0-9a-f]+$/\n\nexport function isElidedField(value: string | null | undefined): boolean {\n return typeof value === 'string' && RECORDED_ELISION_PATTERN.test(value)\n}\n\n// ── Observation grammar ──────────────────────────────────────────────\n\n/** Substring the timeout notice always carries, whatever the command was. */\nexport const TIMEOUT_OBSERVATION_MARKER = 'timed out and has been killed'\n\n/** Opening of the notice the scaffold writes when a turn held no single action. */\nexport const FORMAT_ERROR_OBSERVATION_PREFIX =\n 'Please always provide EXACTLY ONE action in triple backticks, found '\n\n/**\n * What a recorded observation is.\n *\n * `command-result` is the only kind that carries an exit status. `timeout` and\n * `format-error` are the scaffold speaking rather than a command: the first\n * says the environment killed the command, the second says no command ran at\n * all. `elided` and `absent` carry no information about the step, and\n * `unreadable` is a shape this grammar does not know — never assumed to be\n * anything.\n */\nexport type RecordedObservationKind =\n | 'command-result'\n | 'timeout'\n | 'format-error'\n | 'elided'\n | 'absent'\n | 'unreadable'\n\nexport function classifyObservation(observation: string | null): RecordedObservationKind {\n if (observation === null) return 'absent'\n if (isElidedField(observation)) return 'elided'\n if (parseRecordedReturncode(observation) !== null) return 'command-result'\n if (observation.startsWith(FORMAT_ERROR_OBSERVATION_PREFIX)) return 'format-error'\n if (observation.includes(TIMEOUT_OBSERVATION_MARKER)) return 'timeout'\n return 'unreadable'\n}\n\n/** True when the recording shows the environment killed this step at its\n * wall-clock bound. Such a step carries no returncode, so no replay can\n * confirm or contradict it. */\nexport function isRecordedTimeout(observation: string | null): boolean {\n return classifyObservation(observation) === 'timeout'\n}\n\n// ── Turns to steps ───────────────────────────────────────────────────\n\n/**\n * One turn as the published trajectory dump holds it.\n *\n * A turn is not a step: the system prompt, the task statement and every turn\n * the scaffold rejected are turns that executed nothing.\n */\nexport interface RecordedTrajectoryTurn {\n readonly src?: string | null\n readonly msg?: string | null\n readonly tools?: readonly { readonly cmd?: string | null }[] | null\n readonly obs?: string | null\n}\n\nexport interface DecodedTrajectory {\n /** Executed commands in recorded order, each holding its OWN observation. */\n readonly steps: readonly RecordedTrajectoryStep[]\n /** Turns the scaffold rejected before anything ran. */\n readonly formatErrorTurns: number\n /**\n * Executed commands whose text the dump dropped.\n *\n * The step stays in `steps` carrying the marker, because the run did execute\n * a command there and a shorter list would misreport the trajectory. The\n * marker is not a command, so any count above zero means this trajectory\n * cannot be replayed: gate on it, or call `assertReplayableTrajectory`.\n */\n readonly elidedCommands: number\n /** True when the run's last turn was the submit sentinel with no observation. */\n readonly endedOnSubmitSentinel: boolean\n /** Turns carrying an observation this grammar cannot read. */\n readonly unreadableTurns: number\n}\n\n/**\n * Pair every recorded command with the observation of its own turn.\n *\n * Collecting commands and observations into two lists and zipping them is the\n * decode that looks right and is not: a turn the scaffold rejected carries an\n * observation of its own, so from the first such turn onward every observation\n * belongs to a different command than the one it is read against.\n *\n * A rejected turn executed nothing, so it is never a step — including when the\n * dump recorded a command for it. The scaffold rejects a turn holding several\n * bash blocks and runs none of them, while the dump keeps one of the blocks in\n * the command field. Replaying that field would execute a command the recorded\n * run did not, which is a worse corpus than a smaller one.\n *\n * A rejected turn is recognised by its observation, so a rejected turn whose\n * observation the dump elided is indistinguishable from an executed command\n * whose observation it elided. Both read as a step. Nothing in the dump\n * separates them, and the row-level defence is the share of unreadable exits a\n * caller admits: a row with no elided observation cannot hold this case at all.\n *\n * A trailing step that echoes the sentinel and nothing else, with no\n * observation, is dropped from `steps` and reported as `endedOnSubmitSentinel`.\n * The scaffold records an observation only when it hands one to the model, and\n * the sentinel ends the run, so the missing observation is the end of the\n * transcript rather than a gap in it. Echoing the sentinel changes no state, so\n * the recorded end state is the state the step before it left.\n *\n * A step that DID get an observation stays a step: the run continued past it.\n * So does a step that echoes the sentinel after doing real work — its state\n * change is part of the recorded end state, and with no observation its exit is\n * unknown, which `finalRecordedOutcome` reports rather than hides.\n */\nexport function decodeRecordedTurns(turns: readonly RecordedTrajectoryTurn[]): DecodedTrajectory {\n const steps: RecordedTrajectoryStep[] = []\n let formatErrorTurns = 0\n let unreadableTurns = 0\n for (const turn of turns) {\n const command = turn.tools?.[0]?.cmd ?? null\n const observation = turn.obs ?? null\n const kind = classifyObservation(observation)\n if (kind === 'format-error') {\n formatErrorTurns += 1\n continue\n }\n if (command === null) {\n if (kind === 'unreadable' || kind === 'elided') unreadableTurns += 1\n continue\n }\n steps.push({ step_id: steps.length + 1, action: command, observation })\n }\n const last = steps[steps.length - 1]\n const endedOnSubmitSentinel =\n last !== undefined && last.observation === null && isSubmitOnlyAction(last.action)\n if (endedOnSubmitSentinel) steps.pop()\n return {\n steps,\n formatErrorTurns,\n elidedCommands: steps.filter((step) => isElidedField(step.action)).length,\n endedOnSubmitSentinel,\n unreadableTurns,\n }\n}\n\n// ── The state a trajectory ended in ──────────────────────────────────\n\n/**\n * How the recorded run's last executed command ended.\n *\n * `killed` is a measured outcome, not a missing one: the environment stopped\n * the command at its bound and wrote a notice instead of an exit status.\n * `unreadable` names the observation kind that blocked the read, so a funnel\n * can report which shape cost it the row.\n */\nexport type RecordedFinalOutcome =\n | { readonly kind: 'returncode'; readonly value: number }\n | { readonly kind: 'killed' }\n | { readonly kind: 'unreadable'; readonly reason: RecordedObservationKind }\n\n/**\n * The outcome of the last step, or `null` when the trajectory has no steps.\n *\n * Reads only the last step. `decodeRecordedTurns` has already removed the turns\n * that executed nothing, so the last step is the last command the run ran.\n */\nexport function finalRecordedOutcome(\n steps: readonly RecordedTrajectoryStep[],\n): RecordedFinalOutcome | null {\n const last = steps[steps.length - 1]\n if (last === undefined) return null\n const kind = classifyObservation(last.observation)\n if (kind === 'command-result') {\n return { kind: 'returncode', value: parseRecordedReturncode(last.observation)! }\n }\n if (kind === 'timeout') return { kind: 'killed' }\n return { kind: 'unreadable', reason: kind }\n}\n\n/**\n * Steps whose recorded exit a replay cannot check.\n *\n * A killed step counts: the recording holds no exit status to compare a replay\n * against, so agreement on it cannot be measured either way.\n */\nexport function unreadableExitCount(steps: readonly RecordedTrajectoryStep[]): number {\n return steps.filter((step) => classifyObservation(step.observation) !== 'command-result').length\n}\n\n/**\n * Throw unless every recorded command survived the dump.\n *\n * A replay executes `steps` verbatim, so one elision marker in an action means\n * the replay runs the literal two-to-four characters of the marker instead of\n * the command the run executed. The guard is here so a replayer needs one call\n * rather than a field check it can forget.\n */\nexport function assertReplayableTrajectory(decoded: DecodedTrajectory): void {\n if (decoded.elidedCommands === 0) return\n const markers = decoded.steps\n .filter((step) => isElidedField(step.action))\n .map((step) => step.action)\n throw new Error(\n `trajectory holds ${decoded.elidedCommands} command(s) the dump elided (${markers.slice(0, 5).join(', ')}); ` +\n 'no dictionary maps a marker back to its text, so this trajectory cannot be replayed',\n )\n}\n","/**\n * The execution boundary replay runs across.\n *\n * A replay needs one thing from its environment: a session that runs a shell\n * command inside the trajectory's own image and reports the exit code and\n * output. That is the whole contract. Concrete backends — a sandbox platform\n * client, a docker exec, an SSH shell — live with the consumer that owns the\n * infrastructure, so this package depends on no sandbox client.\n */\n\nexport interface ReplayExecResult {\n exitCode: number\n stdout: string\n stderr: string\n}\n\nexport interface ReplayExecSession {\n exec(command: string, timeoutMs: number): Promise<ReplayExecResult>\n close(): Promise<void>\n}\n\nexport interface ReplayExecBackend {\n /** One fresh execution environment per call; the caller closes it. */\n open(): Promise<ReplayExecSession>\n}\n\n/** Builds a backend pinned to one image. Callers that resolve images\n * internally (batch, corpus wire, finding verification) take this instead of\n * a backend, so every case runs against its own image. */\nexport type ReplayExecBackendFactory = (image: string) => ReplayExecBackend\n\n/**\n * mini-SWE runs every action as a fresh /bin/sh subshell from a fixed\n * workdir. Reproduce that exactly — and stay quote-proof for arbitrary\n * recorded actions — by piping the base64 of the action into `sh` after\n * cd-ing to the workdir. Exit code is sh's, i.e. the action's.\n */\nexport function wrapActionForExec(action: string, cwd: string): string {\n const b64 = Buffer.from(action, 'utf8').toString('base64')\n const quotedCwd = `'${cwd.replaceAll(\"'\", `'\\\\''`)}'`\n return `cd ${quotedCwd} && printf %s ${b64} | base64 -d | sh`\n}\n"],"mappings":";;AA4CA,SAAgB,wBAAwB,aAA2C;CACjF,IAAI,CAAC,aAAa,OAAO;CACzB,MAAM,IAAI,oCAAoC,KAAK,WAAW;CAC9D,OAAO,IAAI,OAAO,EAAE,EAAE,IAAI;AAC5B;;;AAIA,SAAgB,uBAAuB,aAAoC;CACzE,IAAI,CAAC,aAAa,OAAO;CACzB,MAAM,IAAI,qCAAqC,KAAK,WAAW;CAC/D,OAAO,IAAI,EAAE,KAAM;AACrB;;;;;;;;AASA,SAAgB,uBAAuB,aAA2C;CAChF,KAAK,MAAM,QAAQ,uBAAuB,WAAW,CAAC,CAAC,MAAM,IAAI,GAAG;EAClE,IAAI,aAAa,KAAK,IAAI,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM,GAAG,GAAG;EAE5D,MAAM,iBAAiB,gDAAgD,KAAK,IAAI;EAChF,IAAI,gBAAgB,OAAO,eAAe,EAAE,CAAE,MAAM,GAAG,GAAG;CAC5D;CACA,OAAO;AACT;;;;;AAMA,MAAa,0BAA0B;AAEvC,SAAgB,eAAe,QAAyB;CACtD,OAAO,OAAO,SAAS,uBAAuB;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AO;EACL;EACA;EACA,gBAAgB,MAAM,QAAQ,SAAS,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC;EACnE;EACA;CACF;AACF;;;;;;;AAuBA,SAAgB,qBACd,OAC6B;CAC7B,MAAM,OAAO,MAAM,MAAM,SAAS;CAClC,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,MAAM,OAAO,oBAAoB,KAAK,WAAW;CACjD,IAAI,SAAS,kBACX,OAAO;EAAE,MAAM;EAAc,OAAO,wBAAwB,KAAK,WAAW;CAAG;CAEjF,IAAI,SAAS,WAAW,OAAO,EAAE,MAAM,SAAS;CAChD,OAAO;EAAE,MAAM;EAAc,QAAQ;CAAK;AAC5C;;;;;;;;;AClQA,SAAgB,kBAAkB,QAAgB,KAAqB;CACrE,MAAM,MAAM,OAAO,KAAK,QAAQ,MAAM,CAAC,CAAC,SAAS,QAAQ;CAEzD,OAAO,MAAM,IADS,IAAI,WAAW,KAAK,OAAO,EAAE,GAC5B,gBAAgB,IAAI;AAC7C"}
1
+ {"version":3,"file":"exec-C0_AkLUv.js","names":[],"sources":["../src/trajectory-replay/steps.ts","../src/trajectory-replay/exec.ts"],"sourcesContent":["/**\n * Recorded shell-trajectory steps and the observation grammar they carry.\n *\n * A recorded trajectory is the action/observation sequence an agent actually\n * ran. Scaffolds that execute one shell command per step (mini-SWE and the\n * CodeTracer-normalized corpora built from it) tag each observation with the\n * command's returncode and its combined output:\n *\n * <returncode>2</returncode>\n * <output>\n * …command output…\n * </output>\n *\n * That is one of four shapes a recorded turn carries, and the other three are\n * not command results at all:\n *\n * - a timeout notice, when the environment killed the command at its bound;\n * - a format-error notice, when the scaffold rejected the turn and ran\n * nothing;\n * - an elision marker `$<hex>`, when the published dump dropped the string.\n *\n * A turn also carries no observation when it is the run's last turn, because\n * the scaffold records an observation only when it hands one back to the model.\n *\n * The parsers here are the only place that grammar is decoded. Everything\n * downstream — replay verdicts, corpus enumeration, admission funnels, fix\n * prompts — reads the returncode, the output, and the failure signature through\n * these functions. A second decoder elsewhere is how a corpus reads as\n * unreplayable when it is not.\n */\n\n/**\n * One step of a recorded shell trajectory. Structural: any richer step record\n * (file refs, thinking text, tool type) satisfies it.\n */\nexport interface RecordedTrajectoryStep {\n /** 1-based position in the trajectory. */\n readonly step_id: number\n readonly action: string\n /** Null when the step recorded no observation (terminal submit steps). */\n readonly observation: string | null\n}\n\n/** Recorded returncode of a step, or null when the observation carries none. */\nexport function parseRecordedReturncode(observation: string | null): number | null {\n if (!observation) return null\n const m = /<returncode>(-?\\d+)<\\/returncode>/.exec(observation)\n return m ? Number(m[1]) : null\n}\n\n/** Text between the observation's <output> tags, or the raw observation when\n * the tags are absent. */\nexport function parseObservationOutput(observation: string | null): string {\n if (!observation) return ''\n const m = /<output>\\n?([\\s\\S]*?)\\n?<\\/output>/.exec(observation)\n return m ? m[1]! : observation\n}\n\n/**\n * Stable failure-signature candidate: the first error line, or a shell\n * command-not-found suffix. Null when neither exists — a verdict then falls\n * back to returncode-only matching and says so.\n * Pass an explicit signature to override (compiler quote glyphs vary with\n * locale, so a hand-picked ASCII substring is often more robust).\n */\nexport function deriveFailureSignature(observation: string | null): string | null {\n for (const line of parseObservationOutput(observation).split('\\n')) {\n if (/\\berror\\b/i.test(line)) return line.trim().slice(0, 200)\n // The shell prefix differs between recorded bash and replayed /bin/sh.\n const missingCommand = /([A-Za-z0-9_.+/-]+: (?:command )?not found)\\b/.exec(line)\n if (missingCommand) return missingCommand[1]!.slice(0, 200)\n }\n return null\n}\n\n/** mini-SWE's end-of-run submit convention: the agent echoes this sentinel\n * and dumps the diff. A label on this step marks a bad SUBMIT DECISION, not a\n * failed command — there is no executable failure to reproduce, so it is\n * never a counterfactual replay target. */\nexport const SUBMIT_ACTION_SIGNATURE = 'COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT'\n\nexport function isSubmitAction(action: string): boolean {\n return action.includes(SUBMIT_ACTION_SIGNATURE)\n}\n\n/**\n * True when the action is the sentinel echo and nothing else.\n *\n * The distinction decides whether a step may be dropped. An agent is told to\n * issue the sentinel alone, and 5.7% of recorded runs end on a command that\n * writes files or edits them and then echoes it. Dropping such a step because\n * it holds the sentinel would remove the run's last state change from the\n * replay, so the recorded end state and the replayed one would differ.\n */\nexport function isSubmitOnlyAction(action: string): boolean {\n return /^echo\\s+(?:\"COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT\"|'COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT'|COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT)$/.test(\n action.trim(),\n )\n}\n\n// ── Fields the published dump dropped ────────────────────────────────\n\n/**\n * A field the dump replaced with a counter instead of its text.\n *\n * The counter is hexadecimal and rises by one per dropped string in document\n * order, so a decimal-only reading (`$12`) accepts every marker that carries a\n * letter (`$3a`) as if it were real text. A command read that way replays as\n * the literal two-to-four characters `$3a`, which is not the command the run\n * executed.\n *\n * Nothing in the dump maps a marker back to its text: the same marker carries\n * different content in different rows, so there is no dictionary to read. A\n * field that matches is unrecoverable, so a caller rejects the row that holds\n * it rather than replaying the marker.\n */\nconst RECORDED_ELISION_PATTERN = /^\\$[0-9a-f]+$/\n\nexport function isElidedField(value: string | null | undefined): boolean {\n return typeof value === 'string' && RECORDED_ELISION_PATTERN.test(value)\n}\n\n// ── Observation grammar ──────────────────────────────────────────────\n\n/** Substring the timeout notice always carries, whatever the command was. */\nexport const TIMEOUT_OBSERVATION_MARKER = 'timed out and has been killed'\n\n/** Opening of the notice the scaffold writes when a turn held no single action. */\nexport const FORMAT_ERROR_OBSERVATION_PREFIX =\n 'Please always provide EXACTLY ONE action in triple backticks, found '\n\n/**\n * What a recorded observation is.\n *\n * `command-result` is the only kind that carries an exit status. `timeout` and\n * `format-error` are the scaffold speaking rather than a command: the first\n * says the environment killed the command, the second says no command ran at\n * all. `elided` and `absent` carry no information about the step, and\n * `unreadable` is a shape this grammar does not know — never assumed to be\n * anything.\n */\nexport type RecordedObservationKind =\n | 'command-result'\n | 'timeout'\n | 'format-error'\n | 'elided'\n | 'absent'\n | 'unreadable'\n\nexport function classifyObservation(observation: string | null): RecordedObservationKind {\n if (observation === null) return 'absent'\n if (isElidedField(observation)) return 'elided'\n if (parseRecordedReturncode(observation) !== null) return 'command-result'\n if (observation.startsWith(FORMAT_ERROR_OBSERVATION_PREFIX)) return 'format-error'\n if (observation.includes(TIMEOUT_OBSERVATION_MARKER)) return 'timeout'\n return 'unreadable'\n}\n\n/** True when the recording shows the environment killed this step at its\n * wall-clock bound. Such a step carries no returncode, so no replay can\n * confirm or contradict it. */\nexport function isRecordedTimeout(observation: string | null): boolean {\n return classifyObservation(observation) === 'timeout'\n}\n\n// ── Turns to steps ───────────────────────────────────────────────────\n\n/**\n * One turn as the published trajectory dump holds it.\n *\n * A turn is not a step: the system prompt, the task statement and every turn\n * the scaffold rejected are turns that executed nothing.\n */\nexport interface RecordedTrajectoryTurn {\n readonly src?: string | null\n readonly msg?: string | null\n readonly tools?: readonly { readonly cmd?: string | null }[] | null\n readonly obs?: string | null\n}\n\nexport interface DecodedTrajectory {\n /** Executed commands in recorded order, each holding its OWN observation. */\n readonly steps: readonly RecordedTrajectoryStep[]\n /** Turns the scaffold rejected before anything ran. */\n readonly formatErrorTurns: number\n /**\n * Executed commands whose text the dump dropped.\n *\n * The step stays in `steps` carrying the marker, because the run did execute\n * a command there and a shorter list would misreport the trajectory. The\n * marker is not a command, so any count above zero means this trajectory\n * cannot be replayed: gate on it, or call `assertReplayableTrajectory`.\n */\n readonly elidedCommands: number\n /** True when the run's last turn was the submit sentinel with no observation. */\n readonly endedOnSubmitSentinel: boolean\n /** Turns carrying an observation this grammar cannot read. */\n readonly unreadableTurns: number\n}\n\n/**\n * Pair every recorded command with the observation of its own turn.\n *\n * Collecting commands and observations into two lists and zipping them is the\n * decode that looks right and is not: a turn the scaffold rejected carries an\n * observation of its own, so from the first such turn onward every observation\n * belongs to a different command than the one it is read against.\n *\n * A rejected turn executed nothing, so it is never a step — including when the\n * dump recorded a command for it. The scaffold rejects a turn holding several\n * bash blocks and runs none of them, while the dump keeps one of the blocks in\n * the command field. Replaying that field would execute a command the recorded\n * run did not, which is a worse corpus than a smaller one.\n *\n * A rejected turn is recognised by its observation, so a rejected turn whose\n * observation the dump elided is indistinguishable from an executed command\n * whose observation it elided. Both read as a step. Nothing in the dump\n * separates them, and the row-level defence is the share of unreadable exits a\n * caller admits: a row with no elided observation cannot hold this case at all.\n *\n * A trailing step that echoes the sentinel and nothing else, with no\n * observation, is dropped from `steps` and reported as `endedOnSubmitSentinel`.\n * The scaffold records an observation only when it hands one to the model, and\n * the sentinel ends the run, so the missing observation is the end of the\n * transcript rather than a gap in it. Echoing the sentinel changes no state, so\n * the recorded end state is the state the step before it left.\n *\n * A step that DID get an observation stays a step: the run continued past it.\n * So does a step that echoes the sentinel after doing real work — its state\n * change is part of the recorded end state, and with no observation its exit is\n * unknown, which `finalRecordedOutcome` reports rather than hides.\n */\nexport function decodeRecordedTurns(turns: readonly RecordedTrajectoryTurn[]): DecodedTrajectory {\n const steps: RecordedTrajectoryStep[] = []\n let formatErrorTurns = 0\n let unreadableTurns = 0\n for (const turn of turns) {\n const command = turn.tools?.[0]?.cmd ?? null\n const observation = turn.obs ?? null\n const kind = classifyObservation(observation)\n if (kind === 'format-error') {\n formatErrorTurns += 1\n continue\n }\n if (command === null) {\n if (kind === 'unreadable' || kind === 'elided') unreadableTurns += 1\n continue\n }\n steps.push({ step_id: steps.length + 1, action: command, observation })\n }\n const last = steps[steps.length - 1]\n const endedOnSubmitSentinel =\n last !== undefined && last.observation === null && isSubmitOnlyAction(last.action)\n if (endedOnSubmitSentinel) steps.pop()\n return {\n steps,\n formatErrorTurns,\n elidedCommands: steps.filter((step) => isElidedField(step.action)).length,\n endedOnSubmitSentinel,\n unreadableTurns,\n }\n}\n\n// ── The state a trajectory ended in ──────────────────────────────────\n\n/**\n * How the recorded run's last executed command ended.\n *\n * `killed` is a measured outcome, not a missing one: the environment stopped\n * the command at its bound and wrote a notice instead of an exit status.\n * `unreadable` names the observation kind that blocked the read, so a funnel\n * can report which shape cost it the row.\n */\nexport type RecordedFinalOutcome =\n | { readonly kind: 'returncode'; readonly value: number }\n | { readonly kind: 'killed' }\n | { readonly kind: 'unreadable'; readonly reason: RecordedObservationKind }\n\n/**\n * The outcome of the last step, or `null` when the trajectory has no steps.\n *\n * Reads only the last step. `decodeRecordedTurns` has already removed the turns\n * that executed nothing, so the last step is the last command the run ran.\n */\nexport function finalRecordedOutcome(\n steps: readonly RecordedTrajectoryStep[],\n): RecordedFinalOutcome | null {\n const last = steps[steps.length - 1]\n if (last === undefined) return null\n const kind = classifyObservation(last.observation)\n if (kind === 'command-result') {\n return { kind: 'returncode', value: parseRecordedReturncode(last.observation)! }\n }\n if (kind === 'timeout') return { kind: 'killed' }\n return { kind: 'unreadable', reason: kind }\n}\n\n/**\n * Steps whose recorded exit a replay cannot check.\n *\n * A killed step counts: the recording holds no exit status to compare a replay\n * against, so agreement on it cannot be measured either way.\n */\nexport function unreadableExitCount(steps: readonly RecordedTrajectoryStep[]): number {\n return steps.filter((step) => classifyObservation(step.observation) !== 'command-result').length\n}\n\n/**\n * Throw unless every recorded command survived the dump.\n *\n * A replay executes `steps` verbatim, so one elision marker in an action means\n * the replay runs the literal two-to-four characters of the marker instead of\n * the command the run executed. The guard is here so a replayer needs one call\n * rather than a field check it can forget.\n */\nexport function assertReplayableTrajectory(decoded: DecodedTrajectory): void {\n if (decoded.elidedCommands === 0) return\n const markers = decoded.steps\n .filter((step) => isElidedField(step.action))\n .map((step) => step.action)\n throw new Error(\n `trajectory holds ${decoded.elidedCommands} command(s) the dump elided (${markers.slice(0, 5).join(', ')}); ` +\n 'no dictionary maps a marker back to its text, so this trajectory cannot be replayed',\n )\n}\n","/**\n * The execution boundary replay runs across.\n *\n * A replay needs one thing from its environment: a session that runs a shell\n * command inside the trajectory's own image and reports the exit code and\n * output. That is the whole contract. Concrete backends — a sandbox platform\n * client, a docker exec, an SSH shell — live with the consumer that owns the\n * infrastructure, so this package depends on no sandbox client.\n */\n\nexport interface ReplayExecResult {\n exitCode: number\n stdout: string\n stderr: string\n}\n\nexport interface ReplayExecSession {\n exec(command: string, timeoutMs: number): Promise<ReplayExecResult>\n close(): Promise<void>\n}\n\nexport interface ReplayExecBackend {\n /** One fresh execution environment per call; the caller closes it. */\n open(): Promise<ReplayExecSession>\n}\n\n/** Builds a backend pinned to one image. Callers that resolve images\n * internally (batch, corpus wire, finding verification) take this instead of\n * a backend, so every case runs against its own image. */\nexport type ReplayExecBackendFactory = (image: string) => ReplayExecBackend\n\n/**\n * mini-SWE runs every action as a fresh /bin/sh subshell from a fixed\n * workdir. Reproduce that exactly — and stay quote-proof for arbitrary\n * recorded actions — by piping the base64 of the action into `sh` after\n * cd-ing to the workdir. Exit code is sh's, i.e. the action's.\n */\nexport function wrapActionForExec(action: string, cwd: string): string {\n const b64 = Buffer.from(action, 'utf8').toString('base64')\n const quotedCwd = `'${cwd.replaceAll(\"'\", `'\\\\''`)}'`\n return `cd ${quotedCwd} && printf %s ${b64} | base64 -d | sh`\n}\n"],"mappings":";;AA4CA,SAAgB,wBAAwB,aAA2C;CACjF,IAAI,CAAC,aAAa,OAAO;CACzB,MAAM,IAAI,oCAAoC,KAAK,WAAW;CAC9D,OAAO,IAAI,OAAO,EAAE,EAAE,IAAI;AAC5B;;;AAIA,SAAgB,uBAAuB,aAAoC;CACzE,IAAI,CAAC,aAAa,OAAO;CACzB,MAAM,IAAI,qCAAqC,KAAK,WAAW;CAC/D,OAAO,IAAI,EAAE,KAAM;AACrB;;;;;;;;AASA,SAAgB,uBAAuB,aAA2C;CAChF,KAAK,MAAM,QAAQ,uBAAuB,WAAW,CAAC,CAAC,MAAM,IAAI,GAAG;EAClE,IAAI,aAAa,KAAK,IAAI,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM,GAAG,GAAG;EAE5D,MAAM,iBAAiB,gDAAgD,KAAK,IAAI;EAChF,IAAI,gBAAgB,OAAO,eAAe,EAAE,CAAE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,SAAS;CAClC,MAAM,wBACJ,SAAS,KAAA,KAAa,KAAK,gBAAgB,QAAQ,mBAAmB,KAAK,MAAM;CACnF,IAAI,uBAAuB,MAAM,IAAI;CACrC,OAAO;EACL;EACA;EACA,gBAAgB,MAAM,QAAQ,SAAS,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC;EACnE;EACA;CACF;AACF;;;;;;;AAuBA,SAAgB,qBACd,OAC6B;CAC7B,MAAM,OAAO,MAAM,MAAM,SAAS;CAClC,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,MAAM,OAAO,oBAAoB,KAAK,WAAW;CACjD,IAAI,SAAS,kBACX,OAAO;EAAE,MAAM;EAAc,OAAO,wBAAwB,KAAK,WAAW;CAAG;CAEjF,IAAI,SAAS,WAAW,OAAO,EAAE,MAAM,SAAS;CAChD,OAAO;EAAE,MAAM;EAAc,QAAQ;CAAK;AAC5C;;;;;;;;AClQA,SAAgB,kBAAkB,QAAgB,KAAqB;CACrE,MAAM,MAAM,OAAO,KAAK,QAAQ,MAAM,CAAC,CAAC,SAAS,QAAQ;CAEzD,OAAO,MAAM,IADS,IAAI,WAAW,KAAK,OAAO,EAAE,GAC5B,gBAAgB,IAAI;AAC7C"}
@@ -1,4 +1,4 @@
1
- //#region src/trace/execution-tracks.ts
1
+ // src/trace/execution-tracks.ts
2
2
  /** Assign lanes to serial tracks without joining concurrent or ambiguously timed work. */
3
3
  function executionTrackByLane(lanes) {
4
4
  const unique = /* @__PURE__ */ new Map();
@@ -87,7 +87,6 @@ function upperBound(sorted, target) {
87
87
  }
88
88
  return low;
89
89
  }
90
- //#endregion
91
90
  export { executionTrackByLane as t };
92
91
 
93
- //# sourceMappingURL=execution-tracks-CpgFPpS5.js.map
92
+ //# sourceMappingURL=execution-tracks-DaDXYwAq.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-tracks-CpgFPpS5.js","names":[],"sources":["../src/trace/execution-tracks.ts"],"sourcesContent":["interface ExecutionLane {\n key: string\n scopeKey: string\n start: number | null\n end: number | null\n}\n\n/** Assign lanes to serial tracks without joining concurrent or ambiguously timed work. */\nexport function executionTrackByLane(lanes: readonly ExecutionLane[]): Map<string, string> {\n const unique = new Map<string, ExecutionLane>()\n for (const lane of lanes) {\n const existing = unique.get(lane.key)\n if (existing && !sameLane(existing, lane)) {\n throw new Error(`execution lane '${lane.key}' has conflicting scope or timing`)\n }\n unique.set(lane.key, lane)\n }\n\n const trackByLane = new Map<string, string>()\n const lanesByScope = new Map<string, ExecutionLane[]>()\n for (const lane of unique.values()) {\n const scoped = lanesByScope.get(lane.scopeKey) ?? []\n scoped.push(lane)\n lanesByScope.set(lane.scopeKey, scoped)\n }\n\n for (const [scopeKey, scoped] of lanesByScope) {\n if (scoped.some((lane) => lane.start === null && lane.end === null)) {\n for (const lane of scoped) trackByLane.set(lane.key, trackId('lane', lane.key))\n continue\n }\n const incompleteKeys = new Set<string>()\n const boundarySet = new Set<number>()\n for (const lane of scoped) {\n if (lane.start !== null && lane.end !== null && lane.end > lane.start) continue\n incompleteKeys.add(lane.key)\n const boundary = lane.start ?? lane.end\n if (boundary !== null) boundarySet.add(boundary)\n trackByLane.set(lane.key, trackId('lane', lane.key))\n }\n const boundaries = [...boundarySet].sort((a, b) => a - b)\n const completeBySegment = new Map<number, ExecutionLane[]>()\n for (const lane of scoped) {\n if (incompleteKeys.has(lane.key)) continue\n const segment = upperBound(boundaries, lane.start!)\n const nextBoundary = boundaries[segment]\n if (nextBoundary !== undefined && nextBoundary < lane.end!) {\n trackByLane.set(lane.key, trackId('lane', lane.key))\n continue\n }\n const complete = completeBySegment.get(segment) ?? []\n complete.push(lane)\n completeBySegment.set(segment, complete)\n }\n\n let serialTrack = 0\n for (const [, segment] of [...completeBySegment].sort(([a], [b]) => a - b)) {\n const ordered = [...segment].sort(\n (a, b) => a.start! - b.start! || a.end! - b.end! || a.key.localeCompare(b.key),\n )\n let component: ExecutionLane[] = []\n let componentEnd = Number.NEGATIVE_INFINITY\n const flush = () => {\n if (component.length === 1) {\n trackByLane.set(component[0]!.key, trackId('serial', scopeKey, serialTrack))\n } else if (component.length > 1) {\n for (const lane of component) trackByLane.set(lane.key, trackId('lane', lane.key))\n serialTrack += 1\n }\n component = []\n componentEnd = Number.NEGATIVE_INFINITY\n }\n\n for (const lane of ordered) {\n if (component.length > 0 && lane.start! >= componentEnd) flush()\n component.push(lane)\n componentEnd = Math.max(componentEnd, lane.end!)\n }\n flush()\n serialTrack += 1\n }\n }\n\n return trackByLane\n}\n\nfunction sameLane(a: ExecutionLane, b: ExecutionLane): boolean {\n return a.scopeKey === b.scopeKey && a.start === b.start && a.end === b.end\n}\n\nfunction trackId(kind: string, key: string, index?: number): string {\n return JSON.stringify(index === undefined ? [kind, key] : [kind, key, index])\n}\n\nfunction upperBound(sorted: readonly number[], target: number): number {\n let low = 0\n let high = sorted.length\n while (low < high) {\n const middle = (low + high) >>> 1\n if (sorted[middle]! <= target) low = middle + 1\n else high = middle\n }\n return low\n}\n"],"mappings":";;AAQA,SAAgB,qBAAqB,OAAsD;CACzF,MAAM,yBAAS,IAAI,IAA2B;CAC9C,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,OAAO,IAAI,KAAK,GAAG;EACpC,IAAI,YAAY,CAAC,SAAS,UAAU,IAAI,GACtC,MAAM,IAAI,MAAM,mBAAmB,KAAK,IAAI,kCAAkC;EAEhF,OAAO,IAAI,KAAK,KAAK,IAAI;CAC3B;CAEA,MAAM,8BAAc,IAAI,IAAoB;CAC5C,MAAM,+BAAe,IAAI,IAA6B;CACtD,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG;EAClC,MAAM,SAAS,aAAa,IAAI,KAAK,QAAQ,KAAK,CAAC;EACnD,OAAO,KAAK,IAAI;EAChB,aAAa,IAAI,KAAK,UAAU,MAAM;CACxC;CAEA,KAAK,MAAM,CAAC,UAAU,WAAW,cAAc;EAC7C,IAAI,OAAO,MAAM,SAAS,KAAK,UAAU,QAAQ,KAAK,QAAQ,I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AC/E;GACA,IAAI,YAA6B,CAAC;GAClC,IAAI,eAAe,OAAO;GAC1B,MAAM,cAAc;IAClB,IAAI,UAAU,WAAW,GACvB,YAAY,IAAI,UAAU,EAAE,CAAE,KAAK,QAAQ,UAAU,UAAU,WAAW,CAAC;SACtE,IAAI,UAAU,SAAS,GAAG;KAC/B,KAAK,MAAM,QAAQ,WAAW,YAAY,IAAI,KAAK,KAAK,QAAQ,QAAQ,KAAK,GAAG,CAAC;KACjF,eAAe;IACjB;IACA,YAAY,CAAC;IACb,eAAe,OAAO;GACxB;GAEA,KAAK,MAAM,QAAQ,SAAS;IAC1B,IAAI,UAAU,SAAS,KAAK,KAAK,SAAU,cAAc,MAAM;IAC/D,UAAU,KAAK,IAAI;IACnB,eAAe,KAAK,IAAI,cAAc,KAAK,GAAI;GACjD;GACA,MAAM;GACN,eAAe;EACjB;CACF;CAEA,OAAO;AACT;AAEA,SAAS,SAAS,GAAkB,GAA2B;CAC7D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE;AACzE;AAEA,SAAS,QAAQ,MAAc,KAAa,OAAwB;CAClE,OAAO,KAAK,UAAU,UAAU,KAAA,IAAY,CAAC,MAAM,GAAG,IAAI;EAAC;EAAM;EAAK;CAAK,CAAC;AAC9E;AAEA,SAAS,WAAW,QAA2B,QAAwB;CACrE,IAAI,MAAM;CACV,IAAI,OAAO,OAAO;CAClB,OAAO,MAAM,MAAM;EACjB,MAAM,SAAU,MAAM,SAAU;EAChC,IAAI,OAAO,WAAY,QAAQ,MAAM,SAAS;OACzC,OAAO;CACd;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"execution-tracks-DaDXYwAq.js","names":[],"sources":["../src/trace/execution-tracks.ts"],"sourcesContent":["interface ExecutionLane {\n key: string\n scopeKey: string\n start: number | null\n end: number | null\n}\n\n/** Assign lanes to serial tracks without joining concurrent or ambiguously timed work. */\nexport function executionTrackByLane(lanes: readonly ExecutionLane[]): Map<string, string> {\n const unique = new Map<string, ExecutionLane>()\n for (const lane of lanes) {\n const existing = unique.get(lane.key)\n if (existing && !sameLane(existing, lane)) {\n throw new Error(`execution lane '${lane.key}' has conflicting scope or timing`)\n }\n unique.set(lane.key, lane)\n }\n\n const trackByLane = new Map<string, string>()\n const lanesByScope = new Map<string, ExecutionLane[]>()\n for (const lane of unique.values()) {\n const scoped = lanesByScope.get(lane.scopeKey) ?? []\n scoped.push(lane)\n lanesByScope.set(lane.scopeKey, scoped)\n }\n\n for (const [scopeKey, scoped] of lanesByScope) {\n if (scoped.some((lane) => lane.start === null && lane.end === null)) {\n for (const lane of scoped) trackByLane.set(lane.key, trackId('lane', lane.key))\n continue\n }\n const incompleteKeys = new Set<string>()\n const boundarySet = new Set<number>()\n for (const lane of scoped) {\n if (lane.start !== null && lane.end !== null && lane.end > lane.start) continue\n incompleteKeys.add(lane.key)\n const boundary = lane.start ?? lane.end\n if (boundary !== null) boundarySet.add(boundary)\n trackByLane.set(lane.key, trackId('lane', lane.key))\n }\n const boundaries = [...boundarySet].sort((a, b) => a - b)\n const completeBySegment = new Map<number, ExecutionLane[]>()\n for (const lane of scoped) {\n if (incompleteKeys.has(lane.key)) continue\n const segment = upperBound(boundaries, lane.start!)\n const nextBoundary = boundaries[segment]\n if (nextBoundary !== undefined && nextBoundary < lane.end!) {\n trackByLane.set(lane.key, trackId('lane', lane.key))\n continue\n }\n const complete = completeBySegment.get(segment) ?? []\n complete.push(lane)\n completeBySegment.set(segment, complete)\n }\n\n let serialTrack = 0\n for (const [, segment] of [...completeBySegment].sort(([a], [b]) => a - b)) {\n const ordered = [...segment].sort(\n (a, b) => a.start! - b.start! || a.end! - b.end! || a.key.localeCompare(b.key),\n )\n let component: ExecutionLane[] = []\n let componentEnd = Number.NEGATIVE_INFINITY\n const flush = () => {\n if (component.length === 1) {\n trackByLane.set(component[0]!.key, trackId('serial', scopeKey, serialTrack))\n } else if (component.length > 1) {\n for (const lane of component) trackByLane.set(lane.key, trackId('lane', lane.key))\n serialTrack += 1\n }\n component = []\n componentEnd = Number.NEGATIVE_INFINITY\n }\n\n for (const lane of ordered) {\n if (component.length > 0 && lane.start! >= componentEnd) flush()\n component.push(lane)\n componentEnd = Math.max(componentEnd, lane.end!)\n }\n flush()\n serialTrack += 1\n }\n }\n\n return trackByLane\n}\n\nfunction sameLane(a: ExecutionLane, b: ExecutionLane): boolean {\n return a.scopeKey === b.scopeKey && a.start === b.start && a.end === b.end\n}\n\nfunction trackId(kind: string, key: string, index?: number): string {\n return JSON.stringify(index === undefined ? [kind, key] : [kind, key, index])\n}\n\nfunction upperBound(sorted: readonly number[], target: number): number {\n let low = 0\n let high = sorted.length\n while (low < high) {\n const middle = (low + high) >>> 1\n if (sorted[middle]! <= target) low = middle + 1\n else high = middle\n }\n return low\n}\n"],"mappings":";;AAQA,SAAgB,qBAAqB,OAAsD;CACzF,MAAM,yBAAS,IAAI,IAA2B;CAC9C,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,OAAO,IAAI,KAAK,GAAG;EACpC,IAAI,YAAY,CAAC,SAAS,UAAU,IAAI,GACtC,MAAM,IAAI,MAAM,mBAAmB,KAAK,IAAI,kCAAkC;EAEhF,OAAO,IAAI,KAAK,KAAK,IAAI;CAC3B;CAEA,MAAM,8BAAc,IAAI,IAAoB;CAC5C,MAAM,+BAAe,IAAI,IAA6B;CACtD,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG;EAClC,MAAM,SAAS,aAAa,IAAI,KAAK,QAAQ,KAAK,CAAC;EACnD,OAAO,KAAK,IAAI;EAChB,aAAa,IAAI,KAAK,UAAU,MAAM;CACxC;CAEA,KAAK,MAAM,CAAC,UAAU,WAAW,cAAc;EAC7C,IAAI,OAAO,MAAM,SAAS,KAAK,UAAU,QAAQ,KAAK,QAAQ,IAAI,GAAG;GACnE,KAAK,MAAM,QAAQ,QAAQ,YAAY,IAAI,KAAK,KAAK,QAAQ,QAAQ,KAAK,GAAG,CAAC;GAC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