@tangle-network/agent-eval 0.150.1 → 0.161.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 (353) hide show
  1. package/CHANGELOG.md +178 -1
  2. package/README.md +7 -3
  3. package/dist/{active-curriculum-C4mk67HP.js → active-curriculum-CD5TU2yW.js} +3 -13
  4. package/dist/active-curriculum-CD5TU2yW.js.map +1 -0
  5. package/dist/{agent-profile-cell-BkcRDikH.d.ts → agent-profile-cell-CTOZJUuE.d.ts} +4 -2
  6. package/dist/agent-profile-cell-CTOZJUuE.d.ts.map +1 -0
  7. package/dist/analyst/index.d.ts +19 -36
  8. package/dist/analyst/index.d.ts.map +1 -1
  9. package/dist/analyst/index.js +8 -8
  10. package/dist/analyst/index.js.map +1 -1
  11. package/dist/{backend-integrity-DOCa_QrR.d.ts → backend-integrity-DxuQCu_A.d.ts} +4 -3
  12. package/dist/backend-integrity-DxuQCu_A.d.ts.map +1 -0
  13. package/dist/{benchmark-BtAWA8nT.d.ts → benchmark-CGPp-kDC.d.ts} +3 -3
  14. package/dist/{benchmark-BtAWA8nT.d.ts.map → benchmark-CGPp-kDC.d.ts.map} +1 -1
  15. package/dist/{benchmark-command-CAFwbH0L.js → benchmark-command-BVtaq_ve.js} +26 -31
  16. package/dist/benchmark-command-BVtaq_ve.js.map +1 -0
  17. package/dist/benchmarks/index.d.ts +6 -19
  18. package/dist/benchmarks/index.d.ts.map +1 -1
  19. package/dist/benchmarks/index.js +4 -4
  20. package/dist/benchmarks/index.js.map +1 -1
  21. package/dist/builder-eval/index.d.ts +3 -3
  22. package/dist/builder-eval/index.js +3 -3
  23. package/dist/campaign/index.d.ts +9 -9
  24. package/dist/campaign/index.js +7 -7
  25. package/dist/{campaign-CN_7xJdV.js → campaign-BSmOwskD.js} +77 -795
  26. package/dist/campaign-BSmOwskD.js.map +1 -0
  27. package/dist/{canonical-D-XsTQ6_.js → canonical-IL-Bu-14.js} +26 -2
  28. package/dist/canonical-IL-Bu-14.js.map +1 -0
  29. package/dist/{capture-fetch-BBVFzhkk.d.ts → capture-fetch-CqwsJkkG.d.ts} +3 -3
  30. package/dist/{capture-fetch-BBVFzhkk.d.ts.map → capture-fetch-CqwsJkkG.d.ts.map} +1 -1
  31. package/dist/{chat-client-2bVfrzhN.js → chat-client-DlMlAeYI.js} +5 -55
  32. package/dist/{chat-client-2bVfrzhN.js.map → chat-client-DlMlAeYI.js.map} +1 -1
  33. package/dist/chat-json-call-6g5sJobJ.js +53 -0
  34. package/dist/chat-json-call-6g5sJobJ.js.map +1 -0
  35. package/dist/cli.js +54 -19
  36. package/dist/cli.js.map +1 -1
  37. package/dist/{client-LIuo-KPv.js → client-CX7KqIdB.js} +3 -3
  38. package/dist/client-CX7KqIdB.js.map +1 -0
  39. package/dist/{client-kPQYT_56.d.ts → client-L9VVPkim.d.ts} +4 -4
  40. package/dist/{client-kPQYT_56.d.ts.map → client-L9VVPkim.d.ts.map} +1 -1
  41. package/dist/contract/index.d.ts +13 -27
  42. package/dist/contract/index.d.ts.map +1 -1
  43. package/dist/contract/index.js +14 -17
  44. package/dist/contract/index.js.map +1 -1
  45. package/dist/{counterfactual--bpysZF0.d.ts → counterfactual-BaFUWK3H.d.ts} +4 -4
  46. package/dist/{counterfactual--bpysZF0.d.ts.map → counterfactual-BaFUWK3H.d.ts.map} +1 -1
  47. package/dist/{counterfactual-lDfCx0Uz.js → counterfactual-D_VWavVm.js} +2 -2
  48. package/dist/{counterfactual-lDfCx0Uz.js.map → counterfactual-D_VWavVm.js.map} +1 -1
  49. package/dist/{dataset-CJjKqQfA.d.ts → dataset-DQqhOCPt.d.ts} +5 -4
  50. package/dist/{dataset-CJjKqQfA.d.ts.map → dataset-DQqhOCPt.d.ts.map} +1 -1
  51. package/dist/{default-registry-Cw0Ohdoj.d.ts → default-registry-G9CKMNkc.d.ts} +7 -8
  52. package/dist/{default-registry-Cw0Ohdoj.d.ts.map → default-registry-G9CKMNkc.d.ts.map} +1 -1
  53. package/dist/{define-agent-eval-CEQWL9Hy.d.ts → define-agent-eval-Dx1JnPEa.d.ts} +26 -6
  54. package/dist/define-agent-eval-Dx1JnPEa.d.ts.map +1 -0
  55. package/dist/{define-agent-eval-rqNyVhVV.js → define-agent-eval-h-s-sI-v.js} +17 -11
  56. package/dist/define-agent-eval-h-s-sI-v.js.map +1 -0
  57. package/dist/{descriptive-B5MwKfbf.js → descriptive-jDOuI6mz.js} +22 -2
  58. package/dist/descriptive-jDOuI6mz.js.map +1 -0
  59. package/dist/{dspy-rlm-engine-DHI0WrUU.js → dspy-rlm-engine-DptEII26.js} +95 -15
  60. package/dist/dspy-rlm-engine-DptEII26.js.map +1 -0
  61. package/dist/{emitter-CPBAhxum.js → emitter-BpYFQPj4.js} +2 -18
  62. package/dist/emitter-BpYFQPj4.js.map +1 -0
  63. package/dist/{emitter-DGQGoLyj.d.ts → emitter-D_jYSGRd.d.ts} +4 -20
  64. package/dist/{emitter-DGQGoLyj.d.ts.map → emitter-D_jYSGRd.d.ts.map} +1 -1
  65. package/dist/{engine-BLzhNzoY.d.ts → engine-Cu5qD5Fc.d.ts} +9 -11
  66. package/dist/{engine-BLzhNzoY.d.ts.map → engine-Cu5qD5Fc.d.ts.map} +1 -1
  67. package/dist/{eval-campaign-C4jmuM-b.js → eval-campaign-BsXWL2-2.js} +17 -28
  68. package/dist/eval-campaign-BsXWL2-2.js.map +1 -0
  69. package/dist/{exact-types-ccQAyut1.d.ts → exact-types-qnexxJ1Z.d.ts} +2 -2
  70. package/dist/{exact-types-ccQAyut1.d.ts.map → exact-types-qnexxJ1Z.d.ts.map} +1 -1
  71. package/dist/{exec-y-DCLqK7.js → exec-D9WpA2p-.js} +2 -2
  72. package/dist/exec-D9WpA2p-.js.map +1 -0
  73. package/dist/experiment/index.d.ts +45 -11
  74. package/dist/experiment/index.d.ts.map +1 -1
  75. package/dist/experiment/index.js +30 -11
  76. package/dist/experiment/index.js.map +1 -1
  77. package/dist/{experiment-tracker-0MhuPArU.d.ts → experiment-tracker-DCO6Cz4s.d.ts} +2 -2
  78. package/dist/{experiment-tracker-0MhuPArU.d.ts.map → experiment-tracker-DCO6Cz4s.d.ts.map} +1 -1
  79. package/dist/{exporters-q9iL-2Jf.js → exporters-Df7TgHFv.js} +3 -3
  80. package/dist/exporters-Df7TgHFv.js.map +1 -0
  81. package/dist/{external-optimizer-contracts-DbLsm4Po.d.ts → external-optimizer-contracts-szBJ_1vh.d.ts} +2 -2
  82. package/dist/{external-optimizer-contracts-DbLsm4Po.d.ts.map → external-optimizer-contracts-szBJ_1vh.d.ts.map} +1 -1
  83. package/dist/{external-optimizer-process-Bhmzngf-.js → external-optimizer-process-WosTBChy.js} +4 -4
  84. package/dist/{external-optimizer-process-Bhmzngf-.js.map → external-optimizer-process-WosTBChy.js.map} +1 -1
  85. package/dist/{external-optimizer-subprocess-Dn90UqN2.js → external-optimizer-subprocess-BIWbHpgD.js} +10 -6
  86. package/dist/external-optimizer-subprocess-BIWbHpgD.js.map +1 -0
  87. package/dist/{failure-cluster-BLURuWG4.d.ts → failure-cluster-CXL8NbEw.d.ts} +3 -3
  88. package/dist/{failure-cluster-BLURuWG4.d.ts.map → failure-cluster-CXL8NbEw.d.ts.map} +1 -1
  89. package/dist/{feedback-trajectory-DpTTjo0q.d.ts → feedback-trajectory-B3ZHaHV_.d.ts} +7 -7
  90. package/dist/{feedback-trajectory-DpTTjo0q.d.ts.map → feedback-trajectory-B3ZHaHV_.d.ts.map} +1 -1
  91. package/dist/fuzz.js +1 -1
  92. package/dist/{hf-dataset-XggBupCr.js → hf-dataset-D8_RNIis.js} +4 -4
  93. package/dist/{hf-dataset-XggBupCr.js.map → hf-dataset-D8_RNIis.js.map} +1 -1
  94. package/dist/hosted/index.d.ts +3 -14
  95. package/dist/hosted/index.d.ts.map +1 -1
  96. package/dist/hosted/index.js +2 -2
  97. package/dist/{index-CTKpu9ry.d.ts → index-CGtH1piv.d.ts} +48 -26
  98. package/dist/index-CGtH1piv.d.ts.map +1 -0
  99. package/dist/{index-BNPtkBPf.d.ts → index-D-IiQIBB.d.ts} +5 -10
  100. package/dist/index-D-IiQIBB.d.ts.map +1 -0
  101. package/dist/{index-IQccV3Ou.d.ts → index-D-V8gCs_.d.ts} +13 -90
  102. package/dist/index-D-V8gCs_.d.ts.map +1 -0
  103. package/dist/{index-B8Ui1mr1.d.ts → index-lfaSeKSD.d.ts} +18 -2
  104. package/dist/index-lfaSeKSD.d.ts.map +1 -0
  105. package/dist/index-vrJugRal.d.ts +1 -0
  106. package/dist/index.d.ts +68 -125
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +61 -112
  109. package/dist/index.js.map +1 -1
  110. package/dist/{insight-report-BeT8KCgI.d.ts → insight-report-DRe8LB6d.d.ts} +4 -4
  111. package/dist/{insight-report-BeT8KCgI.d.ts.map → insight-report-DRe8LB6d.d.ts.map} +1 -1
  112. package/dist/{integrity-DysDBWDu.js → integrity-CyWSSoQS.js} +17 -4
  113. package/dist/integrity-CyWSSoQS.js.map +1 -0
  114. package/dist/{integrity-B0dZ96EO.d.ts → integrity-DUNX9Fao.d.ts} +3 -3
  115. package/dist/{integrity-B0dZ96EO.d.ts.map → integrity-DUNX9Fao.d.ts.map} +1 -1
  116. package/dist/{judge-calibration-DZkWrm5H.js → judge-calibration-zZjLz8hr.js} +2 -2
  117. package/dist/{judge-calibration-DZkWrm5H.js.map → judge-calibration-zZjLz8hr.js.map} +1 -1
  118. package/dist/{kind-factory-DmAa0h3K.js → kind-factory-DY8FdoXf.js} +3 -71
  119. package/dist/kind-factory-DY8FdoXf.js.map +1 -0
  120. package/dist/ledger-core/index.d.ts +2 -2
  121. package/dist/ledger-core/index.js +3 -3
  122. package/dist/{ledger-core-DTae9rv_.js → ledger-core-BOzlRygb.js} +2 -2
  123. package/dist/{ledger-core-DTae9rv_.js.map → ledger-core-BOzlRygb.js.map} +1 -1
  124. package/dist/{llm-client-Bg32RW0j.js → llm-client-hgDieDNN.js} +53 -98
  125. package/dist/llm-client-hgDieDNN.js.map +1 -0
  126. package/dist/{llm-judge-CVq33oz1.js → llm-judge-BhasIPFT.js} +1136 -78
  127. package/dist/llm-judge-BhasIPFT.js.map +1 -0
  128. package/dist/{matrix-DrVnRp4G.d.ts → matrix-eXKRMHnL.d.ts} +74 -72
  129. package/dist/matrix-eXKRMHnL.d.ts.map +1 -0
  130. package/dist/meta-eval/index.d.ts +8 -6
  131. package/dist/meta-eval/index.d.ts.map +1 -1
  132. package/dist/meta-eval/index.js +9 -7
  133. package/dist/meta-eval/index.js.map +1 -1
  134. package/dist/{mint-BV6tLVWl.js → mint-DfODW1KW.js} +3 -3
  135. package/dist/{mint-BV6tLVWl.js.map → mint-DfODW1KW.js.map} +1 -1
  136. package/dist/multishot/golden/index.d.ts +2 -8
  137. package/dist/multishot/golden/index.d.ts.map +1 -1
  138. package/dist/multishot/golden/index.js +56 -86
  139. package/dist/multishot/golden/index.js.map +1 -1
  140. package/dist/multishot/index.d.ts +11 -46
  141. package/dist/multishot/index.d.ts.map +1 -1
  142. package/dist/multishot/index.js +30 -83
  143. package/dist/multishot/index.js.map +1 -1
  144. package/dist/openapi.json +1 -1
  145. package/dist/{opencode-sqlite-DJWAXLms.js → opencode-sqlite-eK6HW6dr.js} +2 -6
  146. package/dist/{opencode-sqlite-DJWAXLms.js.map → opencode-sqlite-eK6HW6dr.js.map} +1 -1
  147. package/dist/pipelines/index.d.ts +5 -5
  148. package/dist/pipelines/index.js +3 -3
  149. package/dist/{pre-registration-zFSLEiFU.d.ts → pre-registration-CzFCcwYk.d.ts} +55 -40
  150. package/dist/pre-registration-CzFCcwYk.d.ts.map +1 -0
  151. package/dist/pre-registration-KN9jkh58.js +110 -0
  152. package/dist/pre-registration-KN9jkh58.js.map +1 -0
  153. package/dist/{produced-state-jfk8Du3b.js → produced-state-DZ89riy5.js} +8 -8
  154. package/dist/produced-state-DZ89riy5.js.map +1 -0
  155. package/dist/profile-cell.d.ts +1 -1
  156. package/dist/profile-cell.js +31 -5
  157. package/dist/profile-cell.js.map +1 -1
  158. package/dist/{promotion-policy-DLOUkYhI.d.ts → promotion-policy-DtnOIZvk.d.ts} +2 -2
  159. package/dist/{promotion-policy-DLOUkYhI.d.ts.map → promotion-policy-DtnOIZvk.d.ts.map} +1 -1
  160. package/dist/{query-Di7eEQ79.js → query-CHmMP42p.js} +20 -11
  161. package/dist/query-CHmMP42p.js.map +1 -0
  162. package/dist/{query-CJ_DX8vl.d.ts → query-DxPYqpmT.d.ts} +10 -4
  163. package/dist/query-DxPYqpmT.d.ts.map +1 -0
  164. package/dist/raw-provider-sink-BU29Sh8h.d.ts +134 -0
  165. package/dist/raw-provider-sink-BU29Sh8h.d.ts.map +1 -0
  166. package/dist/{registry-BQwrSYpC.d.ts → registry-8You7OK1.d.ts} +5 -7
  167. package/dist/{registry-BQwrSYpC.d.ts.map → registry-8You7OK1.d.ts.map} +1 -1
  168. package/dist/{release-confidence-BknrpBnO.js → release-confidence-DKfD2RYU.js} +28 -14
  169. package/dist/release-confidence-DKfD2RYU.js.map +1 -0
  170. package/dist/{release-confidence-4XrqlpFD.d.ts → release-confidence-Dqt0NFep.d.ts} +7 -6
  171. package/dist/release-confidence-Dqt0NFep.d.ts.map +1 -0
  172. package/dist/reporting.d.ts +3 -3
  173. package/dist/reporting.js +3 -3
  174. package/dist/{researcher-DJnoUE8c.d.ts → researcher-Cz565b7D.d.ts} +34 -21
  175. package/dist/researcher-Cz565b7D.d.ts.map +1 -0
  176. package/dist/{reward-hacking-62tojkQd.d.ts → reward-hacking-MBf7qpSB.d.ts} +2 -2
  177. package/dist/{reward-hacking-62tojkQd.d.ts.map → reward-hacking-MBf7qpSB.d.ts.map} +1 -1
  178. package/dist/{reward-hacking-DKI9T52l.js → reward-hacking-t4lB1yt8.js} +3 -3
  179. package/dist/{reward-hacking-DKI9T52l.js.map → reward-hacking-t4lB1yt8.js.map} +1 -1
  180. package/dist/rl.d.ts +11 -42
  181. package/dist/rl.d.ts.map +1 -1
  182. package/dist/rl.js +41 -24
  183. package/dist/rl.js.map +1 -1
  184. package/dist/rollout/index.d.ts +3 -3
  185. package/dist/rollout/index.js +7 -7
  186. package/dist/{rollout-ytVQ7WT8.js → rollout-Dm2tSdiQ.js} +6 -6
  187. package/dist/{rollout-ytVQ7WT8.js.map → rollout-Dm2tSdiQ.js.map} +1 -1
  188. package/dist/{rubric-predictive-validity-Cwwyd7ah.js → rubric-predictive-validity-CK8SCOg-.js} +6 -16
  189. package/dist/rubric-predictive-validity-CK8SCOg-.js.map +1 -0
  190. package/dist/{rubric-predictive-validity-C7LnNvF2.d.ts → rubric-predictive-validity-CxycqzX5.d.ts} +4 -3
  191. package/dist/rubric-predictive-validity-CxycqzX5.d.ts.map +1 -0
  192. package/dist/{run-record-D2lDdSAz.js → run-record-BC0ebuRP.js} +2 -2
  193. package/dist/{run-record-D2lDdSAz.js.map → run-record-BC0ebuRP.js.map} +1 -1
  194. package/dist/{run-record-DVV82Gwh.d.ts → run-record-VVy4T9OW.d.ts} +3 -3
  195. package/dist/{run-record-DVV82Gwh.d.ts.map → run-record-VVy4T9OW.d.ts.map} +1 -1
  196. package/dist/{schema-BtVldJ3T.d.ts → schema-Bjgdsn73.d.ts} +2 -4
  197. package/dist/{schema-BtVldJ3T.d.ts.map → schema-Bjgdsn73.d.ts.map} +1 -1
  198. package/dist/{schema-Cef2cFmb.d.ts → schema-BzWDXhOR.d.ts} +2 -5
  199. package/dist/schema-BzWDXhOR.d.ts.map +1 -0
  200. package/dist/{schema-C6DW4ZHR.js → schema-C1aaAxTf.js} +2 -2
  201. package/dist/schema-C1aaAxTf.js.map +1 -0
  202. package/dist/{schema-CRhEY1SO.js → schema-k6ZBftVv.js} +2 -8
  203. package/dist/{schema-CRhEY1SO.js.map → schema-k6ZBftVv.js.map} +1 -1
  204. package/dist/{semantic-concept-judge-laMCnTLn.js → semantic-concept-judge-BSkKKHeq.js} +14 -38
  205. package/dist/semantic-concept-judge-BSkKKHeq.js.map +1 -0
  206. package/dist/{sequential-eprocess-CbUt2htw.js → sequential-eprocess-D1jKoihe.js} +49 -2
  207. package/dist/sequential-eprocess-D1jKoihe.js.map +1 -0
  208. package/dist/{sequential-C458DXNf.js → sequential-rYW-Ophm.js} +41 -16
  209. package/dist/sequential-rYW-Ophm.js.map +1 -0
  210. package/dist/{series-convergence-BxKEgBwA.d.ts → series-convergence-D9WgpXGi.d.ts} +2 -2
  211. package/dist/{series-convergence-BxKEgBwA.d.ts.map → series-convergence-D9WgpXGi.d.ts.map} +1 -1
  212. package/dist/{server-dIWwF3j_.js → server-BtFd4uzB.js} +19 -42
  213. package/dist/server-BtFd4uzB.js.map +1 -0
  214. package/dist/{skillopt-optimization-method-DLeUcK-K.js → skillopt-optimization-method-DbaekMcn.js} +794 -8
  215. package/dist/skillopt-optimization-method-DbaekMcn.js.map +1 -0
  216. package/dist/{skillopt-optimization-method-BDD_o1xE.d.ts → skillopt-optimization-method-x7TTF23P.d.ts} +20 -7
  217. package/dist/{skillopt-optimization-method-BDD_o1xE.d.ts.map → skillopt-optimization-method-x7TTF23P.d.ts.map} +1 -1
  218. package/dist/{statistical-heldout-_woZ9q9j.d.ts → statistical-heldout-Cy3EhjlC.d.ts} +21 -8
  219. package/dist/statistical-heldout-Cy3EhjlC.d.ts.map +1 -0
  220. package/dist/{steps-AmkT-GIM.d.ts → steps-CiNVJry_.d.ts} +2 -17
  221. package/dist/steps-CiNVJry_.d.ts.map +1 -0
  222. package/dist/{store-CT9YIIve.d.ts → store-B06JdC56.d.ts} +2 -2
  223. package/dist/{store-CT9YIIve.d.ts.map → store-B06JdC56.d.ts.map} +1 -1
  224. package/dist/{store-otlp-CDYWW_8N.js → store-otlp-C_Rq5I4D.js} +2 -2
  225. package/dist/{store-otlp-CDYWW_8N.js.map → store-otlp-C_Rq5I4D.js.map} +1 -1
  226. package/dist/{store-tool-spans-Br2_IUhm.d.ts → store-tool-spans-DPUG7UUY.d.ts} +6 -6
  227. package/dist/{store-tool-spans-Br2_IUhm.d.ts.map → store-tool-spans-DPUG7UUY.d.ts.map} +1 -1
  228. package/dist/{store-tool-spans-CykkbOlv.js → store-tool-spans-Dlh9vkFK.js} +3 -3
  229. package/dist/{store-tool-spans-CykkbOlv.js.map → store-tool-spans-Dlh9vkFK.js.map} +1 -1
  230. package/dist/storyboard/index.d.ts +1 -1
  231. package/dist/{summary-report-Blysd6Z2.js → summary-report-BI5hUtvK.js} +7 -17
  232. package/dist/summary-report-BI5hUtvK.js.map +1 -0
  233. package/dist/{summary-report-B__Y5ub3.d.ts → summary-report-CC07PhEL.d.ts} +6 -5
  234. package/dist/summary-report-CC07PhEL.d.ts.map +1 -0
  235. package/dist/supervisor-run/index.d.ts +27 -18
  236. package/dist/supervisor-run/index.d.ts.map +1 -1
  237. package/dist/supervisor-run/index.js +104 -26
  238. package/dist/supervisor-run/index.js.map +1 -1
  239. package/dist/{task-failure-attributes--ZTP3tYO.js → task-failure-attributes-DTl-7-Kw.js} +3 -3
  240. package/dist/{task-failure-attributes--ZTP3tYO.js.map → task-failure-attributes-DTl-7-Kw.js.map} +1 -1
  241. package/dist/{tool-groups-B4tqh8jB.d.ts → tool-groups-Ci8i9ErB.d.ts} +3 -3
  242. package/dist/tool-groups-Ci8i9ErB.d.ts.map +1 -0
  243. package/dist/{tool-waste-BDdBZG1F.js → tool-waste-BqzmVdJk.js} +4 -4
  244. package/dist/{tool-waste-BDdBZG1F.js.map → tool-waste-BqzmVdJk.js.map} +1 -1
  245. package/dist/{tool-waste-DjRDEsuI.d.ts → tool-waste-Dro0gJi3.d.ts} +4 -4
  246. package/dist/{tool-waste-DjRDEsuI.d.ts.map → tool-waste-Dro0gJi3.d.ts.map} +1 -1
  247. package/dist/trace-repair/index.d.ts +4 -77
  248. package/dist/trace-repair/index.d.ts.map +1 -1
  249. package/dist/trace-repair/index.js +5 -15
  250. package/dist/trace-repair/index.js.map +1 -1
  251. package/dist/traces.d.ts +13 -23
  252. package/dist/traces.d.ts.map +1 -1
  253. package/dist/traces.js +9 -20
  254. package/dist/traces.js.map +1 -1
  255. package/dist/{trajectory-YC15QDYQ.d.ts → trajectory-Bi157Gun.d.ts} +3 -3
  256. package/dist/{trajectory-YC15QDYQ.d.ts.map → trajectory-Bi157Gun.d.ts.map} +1 -1
  257. package/dist/trajectory-replay/index.d.ts +5 -5
  258. package/dist/trajectory-replay/index.js +5 -5
  259. package/dist/{provenance-oA4-zUqm.d.ts → transient-failure-DKF5Mofa.d.ts} +468 -13
  260. package/dist/transient-failure-DKF5Mofa.d.ts.map +1 -0
  261. package/dist/types-B3jzCp0p.js.map +1 -1
  262. package/dist/{types-CLAwnY-L.d.ts → types-BPb2Kf_C2.d.ts} +3 -3
  263. package/dist/types-BPb2Kf_C2.d.ts.map +1 -0
  264. package/dist/types-Bfk0uxRj.d.ts +443 -0
  265. package/dist/types-Bfk0uxRj.d.ts.map +1 -0
  266. package/dist/{types-DdFNuyxQ.d.ts → types-D4s7Z6nq.d.ts} +30 -6
  267. package/dist/types-D4s7Z6nq.d.ts.map +1 -0
  268. package/dist/{types-B2NsbrNy.d.ts → types-D9ssmxKL.d.ts} +3 -3
  269. package/dist/{types-B2NsbrNy.d.ts.map → types-D9ssmxKL.d.ts.map} +1 -1
  270. package/dist/{types-yLK8gXE9.d.ts → types-DeIUdzNd.d.ts} +160 -10
  271. package/dist/types-DeIUdzNd.d.ts.map +1 -0
  272. package/dist/{verdict-BndeTAh_.js → verdict-B0xltqu6.js} +2 -2
  273. package/dist/{verdict-BndeTAh_.js.map → verdict-B0xltqu6.js.map} +1 -1
  274. package/dist/verdict-cache-CdVVTVmn.js +88 -0
  275. package/dist/verdict-cache-CdVVTVmn.js.map +1 -0
  276. package/dist/wire/index.d.ts +21 -111
  277. package/dist/wire/index.d.ts.map +1 -1
  278. package/dist/wire/index.js +2 -2
  279. package/docs/adapters-observability.md +9 -23
  280. package/docs/building-doctrine.md +3 -3
  281. package/docs/campaign-proposers.md +54 -15
  282. package/docs/concepts.md +3 -4
  283. package/docs/design/statistics-decisions.md +89 -1
  284. package/docs/eval-surface-map.md +14 -0
  285. package/docs/experiment.md +19 -2
  286. package/docs/feedback-trajectories.md +1 -1
  287. package/docs/multishot-golden-records.md +4 -4
  288. package/docs/public-api.md +1616 -0
  289. package/docs/research-report-methodology.md +1 -1
  290. package/docs/search-history-receipts.md +39 -1
  291. package/docs/trace-analysis.md +1 -1
  292. package/docs/trace-repair-admission.md +1 -1
  293. package/docs/trace-repair-continuation.md +1 -1
  294. package/docs/verdicts.md +24 -0
  295. package/docs/wire-protocol.md +1 -1
  296. package/package.json +6 -2
  297. package/dist/active-curriculum-C4mk67HP.js.map +0 -1
  298. package/dist/agent-profile-cell-BkcRDikH.d.ts.map +0 -1
  299. package/dist/backend-integrity-DOCa_QrR.d.ts.map +0 -1
  300. package/dist/benchmark-command-CAFwbH0L.js.map +0 -1
  301. package/dist/campaign-CN_7xJdV.js.map +0 -1
  302. package/dist/canonical-D-XsTQ6_.js.map +0 -1
  303. package/dist/client-LIuo-KPv.js.map +0 -1
  304. package/dist/define-agent-eval-CEQWL9Hy.d.ts.map +0 -1
  305. package/dist/define-agent-eval-rqNyVhVV.js.map +0 -1
  306. package/dist/descriptive-B5MwKfbf.js.map +0 -1
  307. package/dist/dspy-rlm-engine-DHI0WrUU.js.map +0 -1
  308. package/dist/emitter-CPBAhxum.js.map +0 -1
  309. package/dist/eval-campaign-C4jmuM-b.js.map +0 -1
  310. package/dist/exec-y-DCLqK7.js.map +0 -1
  311. package/dist/exporters-q9iL-2Jf.js.map +0 -1
  312. package/dist/external-optimizer-subprocess-Dn90UqN2.js.map +0 -1
  313. package/dist/index-B8Ui1mr1.d.ts.map +0 -1
  314. package/dist/index-BNPtkBPf.d.ts.map +0 -1
  315. package/dist/index-C1ravkGA.d.ts +0 -1
  316. package/dist/index-CTKpu9ry.d.ts.map +0 -1
  317. package/dist/index-IQccV3Ou.d.ts.map +0 -1
  318. package/dist/integrity-DysDBWDu.js.map +0 -1
  319. package/dist/kind-factory-DmAa0h3K.js.map +0 -1
  320. package/dist/llm-client-Bg32RW0j.js.map +0 -1
  321. package/dist/llm-judge-CVq33oz1.js.map +0 -1
  322. package/dist/matrix-DrVnRp4G.d.ts.map +0 -1
  323. package/dist/pre-registration-DakwTRXk.js +0 -96
  324. package/dist/pre-registration-DakwTRXk.js.map +0 -1
  325. package/dist/pre-registration-zFSLEiFU.d.ts.map +0 -1
  326. package/dist/produced-state-jfk8Du3b.js.map +0 -1
  327. package/dist/provenance-oA4-zUqm.d.ts.map +0 -1
  328. package/dist/query-CJ_DX8vl.d.ts.map +0 -1
  329. package/dist/query-Di7eEQ79.js.map +0 -1
  330. package/dist/release-confidence-4XrqlpFD.d.ts.map +0 -1
  331. package/dist/release-confidence-BknrpBnO.js.map +0 -1
  332. package/dist/researcher-DJnoUE8c.d.ts.map +0 -1
  333. package/dist/rubric-predictive-validity-C7LnNvF2.d.ts.map +0 -1
  334. package/dist/rubric-predictive-validity-Cwwyd7ah.js.map +0 -1
  335. package/dist/schema-C6DW4ZHR.js.map +0 -1
  336. package/dist/schema-Cef2cFmb.d.ts.map +0 -1
  337. package/dist/semantic-concept-judge-laMCnTLn.js.map +0 -1
  338. package/dist/sequential-C458DXNf.js.map +0 -1
  339. package/dist/sequential-eprocess-CbUt2htw.js.map +0 -1
  340. package/dist/server-dIWwF3j_.js.map +0 -1
  341. package/dist/skillopt-optimization-method-DLeUcK-K.js.map +0 -1
  342. package/dist/statistical-heldout-_woZ9q9j.d.ts.map +0 -1
  343. package/dist/steps-AmkT-GIM.d.ts.map +0 -1
  344. package/dist/summary-report-B__Y5ub3.d.ts.map +0 -1
  345. package/dist/summary-report-Blysd6Z2.js.map +0 -1
  346. package/dist/tool-groups-B4tqh8jB.d.ts.map +0 -1
  347. package/dist/types-CLAwnY-L.d.ts.map +0 -1
  348. package/dist/types-DdFNuyxQ.d.ts.map +0 -1
  349. package/dist/types-jUBXJ7Iz.d.ts +0 -884
  350. package/dist/types-jUBXJ7Iz.d.ts.map +0 -1
  351. package/dist/types-yLK8gXE9.d.ts.map +0 -1
  352. package/dist/verdict-cache-mZf5FEiY.js +0 -107
  353. package/dist/verdict-cache-mZf5FEiY.js.map +0 -1
@@ -1,24 +1,23 @@
1
1
  import { s as ValidationError, t as AgentEvalError } from "./errors-Dngq5h35.js";
2
- import { c as agentProfileId, d as harnessAxisOf, i as verifyCompletion, l as agentProfileModelId, s as agentProfileHash, t as extractProducedState } from "./produced-state-jfk8Du3b.js";
2
+ import { c as agentProfileId, d as harnessAxisOf, i as verifyCompletion, l as agentProfileModelId, s as agentProfileHash, t as extractProducedState } from "./produced-state-DZ89riy5.js";
3
3
  import { buildAgentProfileCell } from "./profile-cell.js";
4
+ import { c as mulberry32 } from "./internal-BDHPCnjk.js";
4
5
  import { t as comparePairedArms } from "./paired-arms-D-XRF_fy.js";
5
6
  import { r as pairedBootstrap } from "./paired-tests-BHIhYVdu.js";
6
- import { c as validateRunRecord, i as modelHasSnapshot, n as UNKNOWN_MODEL, s as runTaskScore } from "./run-record-D2lDdSAz.js";
7
- import { n as contentHash, t as canonicalJson } from "./verdict-cache-mZf5FEiY.js";
8
- import { at as assertRealBackend, et as runCampaign, h as labelTrustRank, k as surfaceContentHash, lt as campaignScenarioIdentity, mt as computeManifestHash, nt as resolveRunDir, ot as summarizeBackendIntegrity, pt as cellCachePath, st as assertCampaignDesign, tt as planCampaignRun, w as assertCodeSurfaceIdentity } from "./llm-judge-CVq33oz1.js";
9
- import { a as campaignCellCostProvenance, l as campaignCellToRunRecord, u as projectCampaignCellQuality } from "./reward-hacking-DKI9T52l.js";
7
+ import { c as validateRunRecord, i as modelHasSnapshot, n as UNKNOWN_MODEL, s as runTaskScore } from "./run-record-BC0ebuRP.js";
8
+ import { n as contentHash, t as canonicalJson } from "./verdict-cache-CdVVTVmn.js";
9
+ import { N as surfaceContentHash, S as paretoFrontierWithCrowding, _ as labelTrustRank, ct as summarizeBackendIntegrity, dt as campaignScenarioIdentity, gt as computeManifestHash, ht as cellCachePath, it as resolveRunDir, k as assertCodeSurfaceIdentity, lt as assertCampaignDesign, nt as runCampaign, rt as planCampaignRun, st as assertRealBackend } from "./llm-judge-BhasIPFT.js";
10
+ import { a as campaignCellCostProvenance, l as campaignCellToRunRecord, u as projectCampaignCellQuality } from "./reward-hacking-t4lB1yt8.js";
10
11
  import { t as CostAccountingIncompleteError } from "./cost-ledger-B1qx30B4.js";
11
- import { t as FileLedgerJournal, u as mapConcurrent } from "./ledger-core-DTae9rv_.js";
12
- import { r as canonicalString } from "./canonical-D-XsTQ6_.js";
13
- import { C as SEARCH_LEDGER_FILE_CONTEXT, E as SearchLedgerIntegrityError, T as SearchLedgerError, w as SearchLedgerConflictError, x as fsCampaignStorage } from "./external-optimizer-subprocess-Dn90UqN2.js";
12
+ import { u as mapConcurrent } from "./ledger-core-BOzlRygb.js";
13
+ import { x as fsCampaignStorage } from "./external-optimizer-subprocess-BIWbHpgD.js";
14
14
  import { o as pairHoldout } from "./power-preflight-DEw-uC7q.js";
15
- import { l as costReceiptFromLlm, s as callLlm, u as costReceiptFromLlmError } from "./llm-client-Bg32RW0j.js";
16
15
  import { a as scoreAnalystFindings } from "./benchmark-BhT16ep9.js";
17
- import "./external-optimizer-process-Bhmzngf-.js";
18
- import "./skillopt-optimization-method-DLeUcK-K.js";
16
+ import "./external-optimizer-process-WosTBChy.js";
17
+ import "./skillopt-optimization-method-DbaekMcn.js";
18
+ import "./sequential-rYW-Ophm.js";
19
19
  import { createHash } from "node:crypto";
20
20
  import { closeSync, constants, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
21
- import { z } from "zod";
22
21
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
23
22
  import { devNull, tmpdir } from "node:os";
24
23
  import { execFileSync } from "node:child_process";
@@ -210,7 +209,7 @@ function validateCandidate(candidate, componentById, componentIndex, baselineCan
210
209
  assertNonEmpty(candidate.candidateId, "candidateId");
211
210
  assertNonEmpty(candidate.contentHash, `contentHash for candidate '${candidate.candidateId}'`);
212
211
  if (!Number.isInteger(candidate.artifactBytes) || candidate.artifactBytes < 0) throw new ValidationError(`analyzeCrossSurfaceInteractions: artifactBytes for candidate '${candidate.candidateId}' must be a non-negative integer`);
213
- assertUnique$1(candidate.componentIds, `componentIds for candidate '${candidate.candidateId}'`);
212
+ assertUnique(candidate.componentIds, `componentIds for candidate '${candidate.candidateId}'`);
214
213
  for (const componentId of candidate.componentIds) if (!componentById.has(componentId)) throw new ValidationError(`analyzeCrossSurfaceInteractions: candidate '${candidate.candidateId}' names unknown component '${componentId}'`);
215
214
  const canonical = [...candidate.componentIds].sort((left, right) => componentIndex.get(left) - componentIndex.get(right));
216
215
  if (!arraysEqual(candidate.componentIds, canonical)) throw new ValidationError(`analyzeCrossSurfaceInteractions: candidate '${candidate.candidateId}' components must follow componentOrder`);
@@ -258,10 +257,10 @@ function indexUnique(items, id, label) {
258
257
  }
259
258
  function assertNonEmptyUnique(values, label) {
260
259
  if (values.length === 0) throw new ValidationError(`analyzeCrossSurfaceInteractions: ${label} is empty`);
261
- assertUnique$1(values, label);
260
+ assertUnique(values, label);
262
261
  for (const value of values) assertNonEmpty(value, label);
263
262
  }
264
- function assertUnique$1(values, label) {
263
+ function assertUnique(values, label) {
265
264
  if (new Set(values).size !== values.length) throw new ValidationError(`analyzeCrossSurfaceInteractions: ${label} contains duplicates`);
266
265
  }
267
266
  function assertNonEmpty(value, label) {
@@ -1334,86 +1333,72 @@ function neutralizeText(content) {
1334
1333
  return content.replace(/\S/g, FILLER);
1335
1334
  }
1336
1335
  //#endregion
1337
- //#region src/campaign/openai-compatible-execution-owner.ts
1336
+ //#region src/campaign/parent-selection.ts
1338
1337
  /**
1339
- * Execution owner for the metered optimizer-model path, backed by any
1340
- * OpenAI-compatible `/chat/completions` endpoint.
1338
+ * Parent selection for `runOptimization`.
1341
1339
  *
1342
- * The loopback proxy owns admission, budgets, identity checks, and
1343
- * cost-ledger recording. This owner only executes the exact admitted
1344
- * request and resolves with a typed outcome: a canonical response plus a
1345
- * JSON-clean receipt on success, or a public error plus an honest receipt
1346
- * on failure. It never rejects, because a rejection loses the execution
1347
- * record and fails the optimizer attempt.
1348
- *
1349
- * Canonical `tools`/`toolChoice` pass through to the wire as
1350
- * `tools`/`tool_choice`; response `tool_calls` come back as canonical
1351
- * `toolCalls`. A response that carries none when tools were sent is a valid
1352
- * model answer, not an error.
1340
+ * Each generation mutates one parent surface. The default parent is the
1341
+ * global incumbent, so the search is a hill-climb and the lineage recorded in
1342
+ * `GenerationCandidate.parentSurfaceHash` is a chain. A `ParentSelector` draws
1343
+ * the parent from the Pareto frontier instead, so the recorded lineage becomes
1344
+ * a tree. Promotion is unchanged: a candidate still has to beat the incumbent.
1353
1345
  */
1354
- function createOpenAiCompatibleExecutionOwner(options) {
1355
- for (const field of [
1356
- "baseUrl",
1357
- "apiKey",
1358
- "model"
1359
- ]) {
1360
- const value = options[field];
1361
- if (typeof value !== "string" || !value.trim() || value.trim() !== value) throw new Error(`createOpenAiCompatibleExecutionOwner: ${field} must be a trimmed, non-empty string`);
1362
- }
1363
- const { baseUrl, apiKey, model, pricing, timeoutMs, maximumAttempts, fetch: fetchImpl } = options;
1364
- return async ({ callId, request, signal }) => {
1365
- const transportRequest = structuredClone(request);
1366
- try {
1367
- const wireResponse = await callLlm(transportRequest, {
1368
- baseUrl,
1369
- apiKey,
1370
- signal,
1371
- idempotencyKey: callId,
1372
- maximumAttempts: maximumAttempts ?? 2,
1373
- ...timeoutMs === void 0 ? {} : { defaultTimeoutMs: timeoutMs },
1374
- ...pricing ? { customTokenPricing: pricing } : {},
1375
- ...fetchImpl ? { fetch: fetchImpl } : {}
1376
- });
1377
- const response = wireResponse.finishReason === "tool_calls" ? {
1378
- ...wireResponse,
1379
- finishReason: "tool_use"
1380
- } : wireResponse;
1381
- return {
1382
- succeeded: true,
1383
- response,
1384
- receipt: costReceiptFromLlm(response, pricing),
1385
- execution: {
1386
- owner: "openai-compatible",
1387
- endpoint: baseUrl,
1388
- model: response.model,
1389
- callId,
1390
- durationMs: response.durationMs
1391
- }
1392
- };
1393
- } catch (error) {
1394
- const cause = error instanceof Error ? error : new Error(String(error));
1395
- const receipt = costReceiptFromLlmError(cause, pricing) ?? {
1396
- model,
1397
- inputTokens: 0,
1398
- outputTokens: 0,
1399
- costUnknown: true,
1400
- usageUnknown: true
1401
- };
1402
- return {
1403
- succeeded: false,
1404
- error: cause.message,
1405
- receipt,
1406
- execution: {
1407
- owner: "openai-compatible",
1408
- endpoint: baseUrl,
1409
- model,
1410
- callId,
1411
- failed: true
1412
- }
1413
- };
1414
- }
1346
+ /**
1347
+ * NSGA-II crowded tournament selection over the frontier. Each generation
1348
+ * draws two distinct frontier members with a PRNG seeded from `seed` and the
1349
+ * generation index, and keeps the one with the larger crowding distance (more
1350
+ * isolated on the frontier). Boundary parents carry infinite distance, so a
1351
+ * boundary parent always beats an interior one. A tie on distance falls back
1352
+ * to the higher mean composite, then to the smaller surface hash. A frontier
1353
+ * of one member returns that member.
1354
+ */
1355
+ function crowdedFrontierParent(options) {
1356
+ const { seed } = options;
1357
+ if (!Number.isInteger(seed)) throw new TypeError(`crowdedFrontierParent: seed must be an integer, got ${String(seed)}`);
1358
+ return ({ frontier, generation }) => {
1359
+ if (frontier.length === 0) throw new Error("crowdedFrontierParent: frontier is empty");
1360
+ if (frontier.length === 1) return frontier[0];
1361
+ const distances = /* @__PURE__ */ new Map();
1362
+ for (const { candidate, distance } of paretoFrontierWithCrowding([...frontier], frontierObjectives(frontier))) distances.set(candidate, distance);
1363
+ const rng = mulberry32(tournamentSeed(seed, generation));
1364
+ const first = Math.floor(rng() * frontier.length);
1365
+ const offset = Math.floor(rng() * (frontier.length - 1));
1366
+ const second = offset >= first ? offset + 1 : offset;
1367
+ const a = frontier[first];
1368
+ const b = frontier[second];
1369
+ return compareCrowded(a, distanceOf(distances, a), b, distanceOf(distances, b)) <= 0 ? a : b;
1415
1370
  };
1416
1371
  }
1372
+ function distanceOf(distances, parent) {
1373
+ const distance = distances.get(parent);
1374
+ if (distance === void 0) throw new Error(`crowdedFrontierParent: frontier member "${parent.surfaceHash}" is dominated or has a non-finite objective`);
1375
+ return distance;
1376
+ }
1377
+ /** Negative when `a` wins the tournament, positive when `b` wins. */
1378
+ function compareCrowded(a, da, b, db) {
1379
+ if (da !== db) return da > db ? -1 : 1;
1380
+ if (a.composite !== b.composite) return a.composite > b.composite ? -1 : 1;
1381
+ if (a.surfaceHash === b.surfaceHash) return 0;
1382
+ return a.surfaceHash < b.surfaceHash ? -1 : 1;
1383
+ }
1384
+ /** One `maximize` objective per scenario id present on the frontier. */
1385
+ function frontierObjectives(frontier) {
1386
+ const ids = /* @__PURE__ */ new Set();
1387
+ for (const parent of frontier) for (const id of Object.keys(parent.objectives)) ids.add(id);
1388
+ if (ids.size === 0) throw new Error("crowdedFrontierParent: frontier parents carry no objectives");
1389
+ return [...ids].sort().map((id) => ({
1390
+ name: id,
1391
+ direction: "maximize",
1392
+ value: (parent) => {
1393
+ const value = parent.objectives[id];
1394
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`crowdedFrontierParent: frontier member "${parent.surfaceHash}" has no finite objective "${id}"`);
1395
+ return value;
1396
+ }
1397
+ }));
1398
+ }
1399
+ function tournamentSeed(seed, generation) {
1400
+ return seed ^ Math.imul(generation + 1, 2654435761) | 0;
1401
+ }
1417
1402
  //#endregion
1418
1403
  //#region src/campaign/presets/playback.ts
1419
1404
  /**
@@ -2411,709 +2396,6 @@ function selectDiscriminative(signals, k, opts) {
2411
2396
  return [...nonTied, ...fill].map((s) => s.scenarioId);
2412
2397
  }
2413
2398
  //#endregion
2414
- //#region src/campaign/search-ledger.ts
2415
- /**
2416
- * Durable append-only audit log for improvement searches.
2417
- *
2418
- * Existing campaign artifacts keep their own rich records: `RunRecord` owns a
2419
- * measured run and `CostLedger` owns per-call accounting. This ledger does not
2420
- * copy those structures. It binds their immutable ids and receipts into one replayable event stream so a
2421
- * search can answer, after a crash, exactly which candidates and task attempts
2422
- * existed, which surfaces actually fired, what they cost, and why they were
2423
- * selected or rejected.
2424
- *
2425
- * The file format is canonical JSONL with a SHA-256 hash chain. Every append is
2426
- * serialized across processes, fsynced before acknowledgement, and idempotent
2427
- * by `eventId`. A malformed, non-canonical, truncated, reordered, or conflicting
2428
- * log fails loudly; the implementation never skips a bad row.
2429
- *
2430
- * The journal machinery itself (hash chain, locking, fsync, idempotent append)
2431
- * is the generic `ledger-core` journal; this module supplies the campaign
2432
- * codec: event schemas, canonical event ordering, and the search state machine.
2433
- */
2434
- const SEARCH_LEDGER_SCHEMA = "tangle.search-ledger.v1";
2435
- const NON_EMPTY = z.string().min(1).refine((value) => value.trim() === value, "must not contain surrounding whitespace");
2436
- const HASH = z.string().regex(/^sha256:[a-f0-9]{64}$/);
2437
- const LINEAGE_NODE_ID = z.string().regex(/^[a-f0-9]{16}$/);
2438
- const IMMUTABLE_REVISION = z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64}|sha256:[a-f0-9]{64}|sha512:[A-Za-z0-9+/=]+)$/);
2439
- const ISO_TIMESTAMP = z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/).refine((value) => Number.isFinite(Date.parse(value)), "invalid timestamp");
2440
- const NON_NEGATIVE_INT = z.number().int().nonnegative().safe();
2441
- const FINITE_NUMBER = z.number().finite();
2442
- const ArtifactRefSchema = z.object({
2443
- role: NON_EMPTY,
2444
- uri: NON_EMPTY,
2445
- sha256: HASH,
2446
- byteLength: NON_NEGATIVE_INT
2447
- }).strict();
2448
- const SourceRefSchema = z.object({
2449
- uri: NON_EMPTY,
2450
- revision: IMMUTABLE_REVISION
2451
- }).strict();
2452
- const FailureReasonSchema = z.object({
2453
- code: NON_EMPTY,
2454
- message: NON_EMPTY
2455
- }).strict();
2456
- const EventBaseShape = {
2457
- eventId: NON_EMPTY,
2458
- occurredAt: ISO_TIMESTAMP,
2459
- artifacts: z.array(ArtifactRefSchema).min(1)
2460
- };
2461
- const OperationKindSchema = z.enum([
2462
- "candidate-generation",
2463
- "analysis",
2464
- "selection",
2465
- "judge",
2466
- "other"
2467
- ]);
2468
- const SearchPlannedSchema = z.object({
2469
- ...EventBaseShape,
2470
- kind: z.literal("search-planned"),
2471
- plan: z.object({
2472
- candidateSlots: z.array(z.object({
2473
- slotId: NON_EMPTY,
2474
- generationOperationId: NON_EMPTY
2475
- }).strict()).min(1),
2476
- tasks: z.array(z.object({
2477
- taskId: NON_EMPTY,
2478
- source: SourceRefSchema,
2479
- benchmark: SourceRefSchema,
2480
- maxAttempts: z.number().int().positive().safe()
2481
- }).strict()).min(1),
2482
- operations: z.array(z.object({
2483
- operationId: NON_EMPTY,
2484
- kind: OperationKindSchema
2485
- }).strict()).min(1)
2486
- }).strict()
2487
- }).strict();
2488
- const CandidateRegisteredSchema = z.object({
2489
- ...EventBaseShape,
2490
- kind: z.literal("candidate-registered"),
2491
- slotId: NON_EMPTY,
2492
- generationOperationId: NON_EMPTY,
2493
- candidateId: NON_EMPTY,
2494
- lineage: z.object({
2495
- lineageNodeId: LINEAGE_NODE_ID,
2496
- parentCandidateIds: z.array(NON_EMPTY),
2497
- generation: NON_NEGATIVE_INT,
2498
- proposer: NON_EMPTY,
2499
- proposerSource: SourceRefSchema
2500
- }).strict(),
2501
- surfaces: z.array(z.object({
2502
- surfaceId: NON_EMPTY,
2503
- kind: z.enum([
2504
- "prompt",
2505
- "tool-contract",
2506
- "runtime-config",
2507
- "memory",
2508
- "knowledge",
2509
- "agent-profile",
2510
- "code",
2511
- "deployment"
2512
- ]),
2513
- artifact: ArtifactRefSchema
2514
- }).strict()).min(1)
2515
- }).strict();
2516
- const CandidateSlotClosedSchema = z.object({
2517
- ...EventBaseShape,
2518
- kind: z.literal("candidate-slot-closed"),
2519
- slotId: NON_EMPTY,
2520
- generationOperationId: NON_EMPTY,
2521
- reason: FailureReasonSchema
2522
- }).strict();
2523
- const KnownTokensSchema = z.object({
2524
- status: z.literal("known"),
2525
- inputTokens: NON_NEGATIVE_INT,
2526
- outputTokens: NON_NEGATIVE_INT,
2527
- cachedTokens: NON_NEGATIVE_INT
2528
- }).strict();
2529
- const UnknownSchema = z.object({
2530
- status: z.literal("unknown"),
2531
- reason: NON_EMPTY
2532
- }).strict();
2533
- const KnownCostSchema = z.object({
2534
- status: z.literal("known"),
2535
- usd: z.number().finite().nonnegative(),
2536
- source: z.enum([
2537
- "provider",
2538
- "pricing-table",
2539
- "free"
2540
- ])
2541
- }).strict().superRefine((cost, ctx) => {
2542
- if (cost.source === "free" && cost.usd !== 0) ctx.addIssue({
2543
- code: "custom",
2544
- message: "free cost source must have usd 0"
2545
- });
2546
- });
2547
- const UnknownCostSchema = z.object({
2548
- status: z.literal("unknown"),
2549
- knownLowerBoundUsd: z.number().finite().nonnegative(),
2550
- reason: NON_EMPTY
2551
- }).strict();
2552
- const AccountingSchema = z.object({
2553
- tokens: z.discriminatedUnion("status", [KnownTokensSchema, UnknownSchema]),
2554
- cost: z.discriminatedUnion("status", [KnownCostSchema, UnknownCostSchema])
2555
- }).strict();
2556
- const MetricsSchema = z.record(NON_EMPTY, FINITE_NUMBER).superRefine((metrics, ctx) => {
2557
- for (const key of Object.keys(metrics)) if (key === "__proto__" || key === "constructor" || key === "prototype") ctx.addIssue({
2558
- code: "custom",
2559
- message: `unsafe metric key ${key}`
2560
- });
2561
- });
2562
- const OutcomeSchema = z.discriminatedUnion("status", [
2563
- z.object({
2564
- status: z.literal("passed"),
2565
- score: FINITE_NUMBER,
2566
- metrics: MetricsSchema
2567
- }).strict(),
2568
- z.object({
2569
- status: z.literal("failed"),
2570
- score: FINITE_NUMBER,
2571
- metrics: MetricsSchema,
2572
- failure: FailureReasonSchema
2573
- }).strict(),
2574
- z.object({
2575
- status: z.literal("errored"),
2576
- metrics: MetricsSchema,
2577
- error: FailureReasonSchema.extend({ retryable: z.boolean() }).strict()
2578
- }).strict()
2579
- ]);
2580
- const EffectSchema = z.discriminatedUnion("status", [z.object({
2581
- status: z.literal("measured"),
2582
- metric: NON_EMPTY,
2583
- baselineValue: FINITE_NUMBER,
2584
- candidateValue: FINITE_NUMBER,
2585
- delta: FINITE_NUMBER
2586
- }).strict().superRefine((effect, ctx) => {
2587
- const expected = effect.candidateValue - effect.baselineValue;
2588
- const tolerance = Number.EPSILON * Math.max(1, Math.abs(expected), Math.abs(effect.delta)) * 8;
2589
- if (Math.abs(effect.delta - expected) > tolerance) ctx.addIssue({
2590
- code: "custom",
2591
- message: "delta must equal candidateValue - baselineValue"
2592
- });
2593
- }), z.object({
2594
- status: z.literal("not-measured"),
2595
- reason: NON_EMPTY
2596
- }).strict()]);
2597
- const SurfaceEvidenceSchema = z.object({
2598
- surfaceId: NON_EMPTY,
2599
- fired: z.boolean(),
2600
- firingCount: NON_NEGATIVE_INT,
2601
- effect: EffectSchema,
2602
- evidence: z.array(ArtifactRefSchema).min(1)
2603
- }).strict().superRefine((evidence, ctx) => {
2604
- if (evidence.fired && evidence.firingCount === 0) ctx.addIssue({
2605
- code: "custom",
2606
- message: "a fired surface must have firingCount >= 1"
2607
- });
2608
- if (!evidence.fired && evidence.firingCount !== 0) ctx.addIssue({
2609
- code: "custom",
2610
- message: "a surface that did not fire must have firingCount 0"
2611
- });
2612
- if (!evidence.fired && evidence.effect.status === "measured" && evidence.effect.delta !== 0) ctx.addIssue({
2613
- code: "custom",
2614
- message: "a surface that did not fire cannot claim non-zero effect"
2615
- });
2616
- });
2617
- const TaskAttemptedSchema = z.object({
2618
- ...EventBaseShape,
2619
- kind: z.literal("task-attempted"),
2620
- candidateId: NON_EMPTY,
2621
- runId: NON_EMPTY,
2622
- attemptIndex: NON_NEGATIVE_INT,
2623
- task: z.object({
2624
- taskId: NON_EMPTY,
2625
- source: SourceRefSchema
2626
- }).strict(),
2627
- identity: z.object({
2628
- model: z.object({
2629
- provider: NON_EMPTY,
2630
- snapshot: NON_EMPTY.refine(modelHasSnapshot, "model must include an immutable snapshot")
2631
- }).strict(),
2632
- agent: SourceRefSchema,
2633
- benchmark: SourceRefSchema
2634
- }).strict(),
2635
- outcome: OutcomeSchema,
2636
- accounting: AccountingSchema,
2637
- surfaceEvidence: z.array(SurfaceEvidenceSchema).min(1)
2638
- }).strict();
2639
- const SearchOperationRecordedSchema = z.object({
2640
- ...EventBaseShape,
2641
- kind: z.literal("search-operation-recorded"),
2642
- operationId: NON_EMPTY,
2643
- operationKind: OperationKindSchema,
2644
- execution: z.discriminatedUnion("kind", [z.object({
2645
- kind: z.literal("model"),
2646
- model: z.object({
2647
- provider: NON_EMPTY,
2648
- snapshot: NON_EMPTY.refine(modelHasSnapshot, "model must include an immutable snapshot")
2649
- }).strict(),
2650
- source: SourceRefSchema
2651
- }).strict(), z.object({
2652
- kind: z.literal("deterministic"),
2653
- source: SourceRefSchema
2654
- }).strict()]),
2655
- outcome: z.discriminatedUnion("status", [
2656
- z.object({ status: z.literal("completed") }).strict(),
2657
- z.object({
2658
- status: z.literal("partial"),
2659
- failure: FailureReasonSchema
2660
- }).strict(),
2661
- z.object({
2662
- status: z.literal("failed"),
2663
- failure: FailureReasonSchema
2664
- }).strict()
2665
- ]),
2666
- accounting: AccountingSchema
2667
- }).strict();
2668
- const CandidateDecidedSchema = z.object({
2669
- ...EventBaseShape,
2670
- kind: z.literal("candidate-decided"),
2671
- candidateId: NON_EMPTY,
2672
- decision: z.discriminatedUnion("status", [z.object({ status: z.literal("selected") }).strict(), z.object({
2673
- status: z.literal("rejected"),
2674
- reason: FailureReasonSchema
2675
- }).strict()])
2676
- }).strict();
2677
- const SearchCompletedSchema = z.object({
2678
- ...EventBaseShape,
2679
- kind: z.literal("search-completed"),
2680
- result: z.discriminatedUnion("status", [z.object({
2681
- status: z.literal("selected"),
2682
- candidateId: NON_EMPTY
2683
- }).strict(), z.object({
2684
- status: z.literal("all-rejected"),
2685
- reason: FailureReasonSchema
2686
- }).strict()])
2687
- }).strict();
2688
- const EventSchema = z.discriminatedUnion("kind", [
2689
- SearchPlannedSchema,
2690
- CandidateRegisteredSchema,
2691
- CandidateSlotClosedSchema,
2692
- TaskAttemptedSchema,
2693
- SearchOperationRecordedSchema,
2694
- CandidateDecidedSchema,
2695
- SearchCompletedSchema
2696
- ]);
2697
- const EntrySchema = z.object({
2698
- schema: z.literal(SEARCH_LEDGER_SCHEMA),
2699
- campaignId: NON_EMPTY,
2700
- sequence: NON_NEGATIVE_INT,
2701
- previousHash: z.union([HASH, z.null()]),
2702
- event: EventSchema,
2703
- entryHash: HASH
2704
- }).strict();
2705
- /** Validate and return a canonical copy. Arrays whose order is not semantic are
2706
- * sorted so retries from different processes produce byte-identical events. */
2707
- function validateSearchLedgerEvent(input) {
2708
- const parsed = EventSchema.safeParse(input);
2709
- if (!parsed.success) throw new SearchLedgerError(`invalid search ledger event: ${formatZodError(parsed.error)}`);
2710
- return normalizeEvent(parsed.data);
2711
- }
2712
- /** Open a durable filesystem search ledger. Construction performs no I/O; the
2713
- * first `append` or `replay` validates the complete existing file. */
2714
- function openSearchLedger(options) {
2715
- if (options.path.trim().length === 0) throw new SearchLedgerError("ledger path is empty");
2716
- return new FileSearchLedger(options.path, options.campaignId, options.trustedHead);
2717
- }
2718
- function searchLedgerCodec(campaignId) {
2719
- return {
2720
- ...SEARCH_LEDGER_FILE_CONTEXT,
2721
- header: {
2722
- schema: SEARCH_LEDGER_SCHEMA,
2723
- campaignId
2724
- },
2725
- conflictError: (message) => new SearchLedgerConflictError(message),
2726
- parseEntry: parseSearchLedgerEntry,
2727
- checkEntryHeader: (entry, index) => {
2728
- if (entry.campaignId !== campaignId) throw new SearchLedgerIntegrityError(`entry ${index} belongs to campaign ${entry.campaignId}, expected ${campaignId}`);
2729
- },
2730
- createProjector: () => createSearchLedgerProjector(campaignId)
2731
- };
2732
- }
2733
- /** Append-only file-backed search ledger with idempotent writes and replay. */
2734
- var FileSearchLedger = class {
2735
- path;
2736
- campaignId;
2737
- trustedHeadPath;
2738
- trustedHeadMode;
2739
- journal;
2740
- constructor(path, campaignId, trustedHead = "pin") {
2741
- if (path.trim().length === 0) throw new SearchLedgerError("ledger path is empty");
2742
- if (campaignId.length === 0) throw new SearchLedgerError("campaignId is empty");
2743
- if (campaignId.trim() !== campaignId) throw new SearchLedgerError("campaignId must not contain surrounding whitespace");
2744
- this.campaignId = campaignId;
2745
- this.trustedHeadMode = trustedHead;
2746
- this.journal = new FileLedgerJournal(path, searchLedgerCodec(campaignId), { requireTrustedHead: trustedHead === "require" });
2747
- this.path = this.journal.path;
2748
- this.trustedHeadPath = this.journal.trustedHeadPath;
2749
- }
2750
- async replay() {
2751
- return (await this.journal.replay()).projection;
2752
- }
2753
- async append(input) {
2754
- const event = validateSearchLedgerEvent(input);
2755
- const { entry, appended, projection } = await this.journal.append(event, { pinHead: this.trustedHeadMode !== "off" });
2756
- return {
2757
- entry,
2758
- appended,
2759
- replay: projection
2760
- };
2761
- }
2762
- async trustedHead() {
2763
- return this.journal.trustedHead();
2764
- }
2765
- async pinTrustedHead() {
2766
- return this.journal.pinTrustedHead();
2767
- }
2768
- async clearTrustedHead() {
2769
- return this.journal.clearTrustedHead();
2770
- }
2771
- };
2772
- function parseSearchLedgerEntry(raw, context) {
2773
- const parsed = EntrySchema.safeParse(raw);
2774
- if (!parsed.success) throw new SearchLedgerIntegrityError(`search ledger ${context.path} has a malformed entry at line ${context.line}: ${formatZodError(parsed.error)}`);
2775
- const entry = parsed.data;
2776
- if (canonicalString(validateSearchLedgerEvent(entry.event)) !== canonicalString(entry.event)) throw new SearchLedgerIntegrityError(`search ledger ${context.path} has non-canonical event ordering at line ${context.line}`);
2777
- return entry;
2778
- }
2779
- /** Replay the campaign search state machine over chain-verified entries. The
2780
- * generic journal owns sequence, hash, and eventId-uniqueness checks; this
2781
- * projector owns every campaign invariant and builds the replay projection. */
2782
- function createSearchLedgerProjector(campaignId) {
2783
- const candidates = /* @__PURE__ */ new Map();
2784
- const candidateBySlot = /* @__PURE__ */ new Map();
2785
- const closedSlots = /* @__PURE__ */ new Map();
2786
- const lineageNodes = /* @__PURE__ */ new Map();
2787
- const runIds = /* @__PURE__ */ new Set();
2788
- const attemptKeys = /* @__PURE__ */ new Set();
2789
- const candidateEvents = [];
2790
- const closedSlotEvents = [];
2791
- const attempts = [];
2792
- const operationEvents = [];
2793
- const operationsById = /* @__PURE__ */ new Map();
2794
- const decisions = [];
2795
- let planEvent = null;
2796
- let completion = null;
2797
- let previousOccurredAt = Number.NEGATIVE_INFINITY;
2798
- const apply = (entry, index) => {
2799
- const event = entry.event;
2800
- if (completion) throw new SearchLedgerIntegrityError(`event ${event.eventId} appears after terminal event ${completion.eventId}`);
2801
- const occurredAt = Date.parse(event.occurredAt);
2802
- if (occurredAt < previousOccurredAt) throw new SearchLedgerIntegrityError(`event ${event.eventId} occurred before the preceding durable event`);
2803
- previousOccurredAt = occurredAt;
2804
- assertUnique(event.artifacts.map(artifactKey), "artifact receipt", event.eventId);
2805
- if (event.kind === "search-planned") {
2806
- if (index !== 0 || planEvent) throw new SearchLedgerIntegrityError("search plan must be the first and only plan event");
2807
- assertUnique(event.plan.candidateSlots.map((slot) => slot.slotId), "candidate slot", event.eventId);
2808
- assertUnique(event.plan.tasks.map((task) => task.taskId), "planned taskId", event.eventId);
2809
- assertUnique(event.plan.operations.map((operation) => operation.operationId), "planned operationId", event.eventId);
2810
- for (const slot of event.plan.candidateSlots) if (event.plan.operations.find((operation) => operation.operationId === slot.generationOperationId)?.kind !== "candidate-generation") throw new SearchLedgerIntegrityError(`candidate slot ${slot.slotId} references unplanned candidate-generation operation ${slot.generationOperationId}`);
2811
- planEvent = event;
2812
- return;
2813
- }
2814
- if (!planEvent) throw new SearchLedgerIntegrityError(`event ${event.eventId} appears before the required search plan`);
2815
- if (event.kind === "candidate-registered") {
2816
- if (candidates.has(event.candidateId)) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} was registered twice`);
2817
- const plannedSlot = planEvent.plan.candidateSlots.find((slot) => slot.slotId === event.slotId);
2818
- if (!plannedSlot) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} binds unknown slot ${event.slotId}`);
2819
- if (candidateBySlot.has(event.slotId)) throw new SearchLedgerIntegrityError(`candidate slot ${event.slotId} was bound twice`);
2820
- if (closedSlots.has(event.slotId)) throw new SearchLedgerIntegrityError(`candidate slot ${event.slotId} was already closed`);
2821
- if (event.generationOperationId !== plannedSlot.generationOperationId) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} generation operation ${event.generationOperationId} does not match slot ${event.slotId} plan ${plannedSlot.generationOperationId}`);
2822
- const generationOperation = operationsById.get(event.generationOperationId);
2823
- if (!generationOperation) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} precedes generation operation ${event.generationOperationId}`);
2824
- if (generationOperation.outcome.status === "failed") throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} cannot bind failed generation operation ${event.generationOperationId}`);
2825
- const previousCandidate = lineageNodes.get(event.lineage.lineageNodeId);
2826
- if (previousCandidate) throw new SearchLedgerIntegrityError(`lineage node ${event.lineage.lineageNodeId} is already bound to ${previousCandidate}`);
2827
- assertUnique(event.lineage.parentCandidateIds, "parentCandidateId", event.eventId);
2828
- const parents = event.lineage.parentCandidateIds.map((id) => {
2829
- const parent = candidates.get(id);
2830
- if (!parent) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} references unknown parent ${id}`);
2831
- return parent;
2832
- });
2833
- const expectedGeneration = parents.length === 0 ? 0 : Math.max(...parents.map((parent) => parent.registered.lineage.generation)) + 1;
2834
- if (event.lineage.generation !== expectedGeneration) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} generation ${event.lineage.generation} does not follow its parents (expected ${expectedGeneration})`);
2835
- assertUnique(event.surfaces.map((surface) => surface.surfaceId), "surfaceId", event.eventId);
2836
- candidates.set(event.candidateId, {
2837
- registered: event,
2838
- attempts: [],
2839
- decision: null
2840
- });
2841
- candidateBySlot.set(event.slotId, event.candidateId);
2842
- lineageNodes.set(event.lineage.lineageNodeId, event.candidateId);
2843
- candidateEvents.push(event);
2844
- return;
2845
- }
2846
- if (event.kind === "task-attempted") {
2847
- const candidate = candidates.get(event.candidateId);
2848
- if (!candidate) throw new SearchLedgerIntegrityError(`attempt ${event.eventId} references unknown candidate ${event.candidateId}`);
2849
- if (candidate.decision) throw new SearchLedgerIntegrityError(`attempt ${event.eventId} appears after candidate ${event.candidateId} was decided`);
2850
- const plannedTask = planEvent.plan.tasks.find((task) => task.taskId === event.task.taskId);
2851
- if (!plannedTask) throw new SearchLedgerIntegrityError(`attempt ${event.eventId} references unplanned task ${event.task.taskId}`);
2852
- if (canonicalString(plannedTask.source) !== canonicalString(event.task.source) || canonicalString(plannedTask.benchmark) !== canonicalString(event.identity.benchmark)) throw new SearchLedgerIntegrityError(`task ${event.task.taskId} does not match its planned source identity`);
2853
- if (event.attemptIndex >= plannedTask.maxAttempts) throw new SearchLedgerIntegrityError(`task ${event.task.taskId} attempt ${event.attemptIndex} exceeds planned maxAttempts ${plannedTask.maxAttempts}`);
2854
- if (runIds.has(event.runId)) throw new SearchLedgerIntegrityError(`runId ${event.runId} was recorded twice`);
2855
- runIds.add(event.runId);
2856
- const attemptKey = canonicalString([
2857
- event.candidateId,
2858
- event.task.taskId,
2859
- event.attemptIndex
2860
- ]);
2861
- if (attemptKeys.has(attemptKey)) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} task ${event.task.taskId} attempt ${event.attemptIndex} was recorded twice`);
2862
- const expectedAttemptIndex = candidate.attempts.filter((attempt) => attempt.task.taskId === event.task.taskId).length;
2863
- if (event.attemptIndex !== expectedAttemptIndex) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} task ${event.task.taskId} attempt index ${event.attemptIndex} is not contiguous (expected ${expectedAttemptIndex})`);
2864
- const previousAttempt = candidate.attempts.find((attempt) => attempt.task.taskId === event.task.taskId);
2865
- if (previousAttempt?.outcome.status !== void 0 && previousAttempt.outcome.status !== "errored") throw new SearchLedgerIntegrityError(`task ${event.task.taskId} was retried after a measured outcome`);
2866
- if (previousAttempt && canonicalString({
2867
- task: previousAttempt.task,
2868
- identity: previousAttempt.identity
2869
- }) !== canonicalString({
2870
- task: event.task,
2871
- identity: event.identity
2872
- })) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} task ${event.task.taskId} changed immutable execution identity between attempts`);
2873
- attemptKeys.add(attemptKey);
2874
- const declared = candidate.registered.surfaces.map((surface) => surface.surfaceId).sort();
2875
- const observed = event.surfaceEvidence.map((surface) => surface.surfaceId).sort();
2876
- assertUnique(observed, "surface evidence", event.eventId);
2877
- for (const evidence of event.surfaceEvidence) assertUnique(evidence.evidence.map(artifactKey), "surface evidence receipt", event.eventId);
2878
- if (canonicalString(declared) !== canonicalString(observed)) throw new SearchLedgerIntegrityError(`attempt ${event.eventId} surface evidence does not exactly cover candidate ${event.candidateId}`);
2879
- candidate.attempts.push(event);
2880
- attempts.push(event);
2881
- return;
2882
- }
2883
- if (event.kind === "search-operation-recorded") {
2884
- const plannedOperation = planEvent.plan.operations.find((operation) => operation.operationId === event.operationId);
2885
- if (!plannedOperation) throw new SearchLedgerIntegrityError(`operation ${event.operationId} was not declared in the search plan`);
2886
- if (plannedOperation.kind !== event.operationKind) throw new SearchLedgerIntegrityError(`operation ${event.operationId} kind ${event.operationKind} does not match planned ${plannedOperation.kind}`);
2887
- if (operationsById.has(event.operationId)) throw new SearchLedgerIntegrityError(`operation ${event.operationId} was recorded twice`);
2888
- operationsById.set(event.operationId, event);
2889
- operationEvents.push(event);
2890
- return;
2891
- }
2892
- if (event.kind === "candidate-slot-closed") {
2893
- const plannedSlot = planEvent.plan.candidateSlots.find((slot) => slot.slotId === event.slotId);
2894
- if (!plannedSlot) throw new SearchLedgerIntegrityError(`candidate slot closure ${event.eventId} references unknown slot ${event.slotId}`);
2895
- if (event.generationOperationId !== plannedSlot.generationOperationId) throw new SearchLedgerIntegrityError(`candidate slot closure ${event.eventId} generation operation ${event.generationOperationId} does not match slot ${event.slotId} plan ${plannedSlot.generationOperationId}`);
2896
- if (candidateBySlot.has(event.slotId)) throw new SearchLedgerIntegrityError(`candidate slot ${event.slotId} was already bound to a candidate`);
2897
- if (closedSlots.has(event.slotId)) throw new SearchLedgerIntegrityError(`candidate slot ${event.slotId} was closed twice`);
2898
- const operation = operationsById.get(event.generationOperationId);
2899
- if (!operation) throw new SearchLedgerIntegrityError(`candidate slot closure ${event.eventId} precedes operation ${event.generationOperationId}`);
2900
- if (operation.outcome.status === "completed") throw new SearchLedgerIntegrityError(`candidate slot ${event.slotId} cannot close from completed operation ${event.generationOperationId}`);
2901
- closedSlots.set(event.slotId, event);
2902
- closedSlotEvents.push(event);
2903
- return;
2904
- }
2905
- if (event.kind === "candidate-decided") {
2906
- const candidate = candidates.get(event.candidateId);
2907
- if (!candidate) throw new SearchLedgerIntegrityError(`decision ${event.eventId} references unknown candidate ${event.candidateId}`);
2908
- if (candidate.decision) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} was decided twice`);
2909
- if (event.decision.status === "selected") {
2910
- if (!candidate.attempts.some((attempt) => attempt.outcome.status !== "errored")) throw new SearchLedgerIntegrityError(`candidate ${event.candidateId} cannot be selected without a measured task outcome`);
2911
- if (decisions.some((decision) => decision.decision.status === "selected")) throw new SearchLedgerIntegrityError("more than one candidate was selected");
2912
- }
2913
- candidate.decision = event;
2914
- decisions.push(event);
2915
- return;
2916
- }
2917
- const missingCandidateSlots = planEvent.plan.candidateSlots.filter((slot) => !candidateBySlot.has(slot.slotId) && !closedSlots.has(slot.slotId)).map((slot) => slot.slotId);
2918
- if (missingCandidateSlots.length > 0) throw new SearchLedgerIntegrityError(`search completed with missing candidate slots: ${missingCandidateSlots.join(", ")}`);
2919
- const missingTaskOutcomes = plannedTaskOutcomeKeys(planEvent, candidates);
2920
- if (missingTaskOutcomes.length > 0) throw new SearchLedgerIntegrityError(`search completed with missing task outcomes: ${missingTaskOutcomes.join(", ")}`);
2921
- const missingOperations = planEvent.plan.operations.filter((operation) => !operationsById.has(operation.operationId)).map((operation) => operation.operationId);
2922
- if (missingOperations.length > 0) throw new SearchLedgerIntegrityError(`search completed with missing search operations: ${missingOperations.join(", ")}`);
2923
- for (const operation of planEvent.plan.operations) {
2924
- if (operation.kind !== "candidate-generation") continue;
2925
- const generationOutcome = operationsById.get(operation.operationId).outcome.status;
2926
- const slots = planEvent.plan.candidateSlots.filter((slot) => slot.generationOperationId === operation.operationId);
2927
- if (slots.length === 0) continue;
2928
- const registeredCount = slots.filter((slot) => candidateBySlot.has(slot.slotId)).length;
2929
- const closedCount = slots.filter((slot) => closedSlots.has(slot.slotId)).length;
2930
- if (generationOutcome === "completed" && closedCount > 0) throw new SearchLedgerIntegrityError(`completed generation operation ${operation.operationId} contains ${closedCount} closed slot(s)`);
2931
- if (generationOutcome === "failed" && registeredCount > 0) throw new SearchLedgerIntegrityError(`failed generation operation ${operation.operationId} contains ${registeredCount} registered candidate(s)`);
2932
- if (generationOutcome === "partial" && (registeredCount === 0 || closedCount === 0)) throw new SearchLedgerIntegrityError(`partial generation operation ${operation.operationId} must contain both a registered candidate and a closed slot`);
2933
- }
2934
- const pending = [...candidates.values()].filter((candidate) => candidate.decision === null);
2935
- if (pending.length > 0) throw new SearchLedgerIntegrityError(`search completed with ${pending.length} candidate decision(s) missing`);
2936
- const selected = decisions.filter((decision) => decision.decision.status === "selected");
2937
- if (event.result.status === "selected") {
2938
- if (selected.length !== 1 || selected[0].candidateId !== event.result.candidateId) throw new SearchLedgerIntegrityError(`search completion winner ${event.result.candidateId} does not match candidate decisions`);
2939
- } else if (selected.length !== 0) throw new SearchLedgerIntegrityError("all-rejected completion contains a selected candidate");
2940
- completion = event;
2941
- };
2942
- const finish = (entries) => {
2943
- const selectedDecisions = decisions.filter((decision) => decision.decision.status === "selected");
2944
- const rejectedDecisions = decisions.filter((decision) => decision.decision.status === "rejected");
2945
- const outcomeCounts = {
2946
- passed: 0,
2947
- failed: 0,
2948
- errored: 0
2949
- };
2950
- const operationOutcomeCounts = {
2951
- completed: 0,
2952
- partial: 0,
2953
- failed: 0
2954
- };
2955
- let inputTokens = 0;
2956
- let outputTokens = 0;
2957
- let cachedTokens = 0;
2958
- let costUsd = 0;
2959
- const unknownTokenEventIds = [];
2960
- const unknownCostEventIds = [];
2961
- for (const attempt of attempts) outcomeCounts[attempt.outcome.status] += 1;
2962
- for (const operation of operationEvents) operationOutcomeCounts[operation.outcome.status] += 1;
2963
- for (const costedEvent of [...attempts, ...operationEvents]) {
2964
- if (costedEvent.accounting.tokens.status === "known") {
2965
- inputTokens += costedEvent.accounting.tokens.inputTokens;
2966
- outputTokens += costedEvent.accounting.tokens.outputTokens;
2967
- cachedTokens += costedEvent.accounting.tokens.cachedTokens;
2968
- } else unknownTokenEventIds.push(costedEvent.eventId);
2969
- if (costedEvent.accounting.cost.status === "known") costUsd += costedEvent.accounting.cost.usd;
2970
- else {
2971
- costUsd += costedEvent.accounting.cost.knownLowerBoundUsd;
2972
- unknownCostEventIds.push(costedEvent.eventId);
2973
- }
2974
- }
2975
- const accounting = unknownTokenEventIds.length === 0 && unknownCostEventIds.length === 0 ? {
2976
- status: "known",
2977
- inputTokens,
2978
- outputTokens,
2979
- cachedTokens,
2980
- costUsd
2981
- } : {
2982
- status: "partial",
2983
- knownInputTokens: inputTokens,
2984
- knownOutputTokens: outputTokens,
2985
- knownCachedTokens: cachedTokens,
2986
- knownCostUsd: costUsd,
2987
- unknownTokenEventIds,
2988
- unknownCostEventIds
2989
- };
2990
- const selectedCandidateId = completion?.result.status === "selected" ? completion.result.candidateId : null;
2991
- const status = completion?.result.status === "selected" ? "selected" : completion?.result.status === "all-rejected" ? "all-rejected" : "in-progress";
2992
- const missingCandidateSlots = planEvent?.plan.candidateSlots.filter((slot) => !candidateBySlot.has(slot.slotId) && !closedSlots.has(slot.slotId)).map((slot) => slot.slotId) ?? [];
2993
- const missingTaskOutcomes = planEvent ? plannedTaskOutcomeKeys(planEvent, candidates) : [];
2994
- const missingOperations = planEvent?.plan.operations.filter((operation) => !operationsById.has(operation.operationId)).map((operation) => operation.operationId) ?? [];
2995
- return {
2996
- entries: [...entries],
2997
- plan: planEvent,
2998
- candidates: candidateEvents,
2999
- closedCandidateSlots: closedSlotEvents,
3000
- attempts,
3001
- operations: operationEvents,
3002
- decisions,
3003
- completion,
3004
- audit: {
3005
- campaignId,
3006
- eventCount: entries.length,
3007
- candidateCount: candidates.size,
3008
- closedCandidateSlotCount: closedSlots.size,
3009
- attemptCount: attempts.length,
3010
- operationCount: operationEvents.length,
3011
- outcomes: outcomeCounts,
3012
- operationOutcomes: operationOutcomeCounts,
3013
- decisions: {
3014
- selected: selectedDecisions.length,
3015
- rejected: rejectedDecisions.length,
3016
- pending: candidates.size - decisions.length
3017
- },
3018
- expected: {
3019
- candidateSlots: planEvent?.plan.candidateSlots.length ?? 0,
3020
- taskOutcomes: candidates.size * (planEvent?.plan.tasks.length ?? 0),
3021
- operations: planEvent?.plan.operations.length ?? 0,
3022
- missingCandidateSlots,
3023
- missingTaskOutcomes,
3024
- missingOperations
3025
- },
3026
- status,
3027
- selectedCandidateId,
3028
- accounting,
3029
- headHash: entries.at(-1)?.entryHash ?? null
3030
- }
3031
- };
3032
- };
3033
- return {
3034
- apply,
3035
- finish
3036
- };
3037
- }
3038
- function plannedTaskOutcomeKeys(planEvent, candidates) {
3039
- const missing = [];
3040
- const registeredCandidates = [...candidates.values()].sort((a, b) => compareStrings(a.registered.slotId, b.registered.slotId));
3041
- for (const candidate of registeredCandidates) {
3042
- const slotId = candidate.registered.slotId;
3043
- for (const task of planEvent.plan.tasks) if (!candidate.attempts.some((attempt) => attempt.task.taskId === task.taskId && attempt.outcome.status !== "errored")) missing.push(`${slotId}/${task.taskId}`);
3044
- }
3045
- return missing;
3046
- }
3047
- function normalizeEvent(event) {
3048
- const artifacts = sortArtifacts(event.artifacts);
3049
- if (event.kind === "search-planned") return {
3050
- ...event,
3051
- artifacts,
3052
- plan: {
3053
- candidateSlots: [...event.plan.candidateSlots].sort((a, b) => compareStrings(a.slotId, b.slotId)),
3054
- tasks: [...event.plan.tasks].sort((a, b) => compareStrings(a.taskId, b.taskId)),
3055
- operations: [...event.plan.operations].sort((a, b) => compareStrings(a.operationId, b.operationId))
3056
- }
3057
- };
3058
- if (event.kind === "candidate-registered") return {
3059
- ...event,
3060
- artifacts,
3061
- lineage: {
3062
- ...event.lineage,
3063
- parentCandidateIds: sortedStrings(event.lineage.parentCandidateIds)
3064
- },
3065
- surfaces: [...event.surfaces].map((surface) => ({
3066
- ...surface,
3067
- artifact: { ...surface.artifact }
3068
- })).sort((a, b) => compareStrings(a.surfaceId, b.surfaceId))
3069
- };
3070
- if (event.kind === "task-attempted") return {
3071
- ...event,
3072
- artifacts,
3073
- surfaceEvidence: [...event.surfaceEvidence].map((evidence) => ({
3074
- ...evidence,
3075
- evidence: sortArtifacts(evidence.evidence)
3076
- })).sort((a, b) => compareStrings(a.surfaceId, b.surfaceId))
3077
- };
3078
- return {
3079
- ...event,
3080
- artifacts
3081
- };
3082
- }
3083
- function sortArtifacts(artifacts) {
3084
- return [...artifacts].map((artifact) => ({ ...artifact })).sort((a, b) => compareStrings(artifactKey(a), artifactKey(b)));
3085
- }
3086
- function artifactKey(artifact) {
3087
- return canonicalString(artifact);
3088
- }
3089
- function compareStrings(a, b) {
3090
- return a < b ? -1 : a > b ? 1 : 0;
3091
- }
3092
- function sortedStrings(values) {
3093
- return [...values].sort();
3094
- }
3095
- function assertUnique(values, label, eventId) {
3096
- if (new Set(values).size !== values.length) throw new SearchLedgerIntegrityError(`event ${eventId} contains duplicate ${label} values`);
3097
- }
3098
- function formatZodError(error) {
3099
- return error.issues.map((issue) => `${issue.path.length > 0 ? issue.path.join(".") : "<root>"}: ${issue.message}`).join("; ");
3100
- }
3101
- //#endregion
3102
- //#region src/campaign/transient-failure.ts
3103
- const BASE_TRANSIENT = /\b50[234]\b|no stream output|produced no stream|admission timed out|admission_rejected|queue_timeout|fetch failed|ECONNRESET|This operation was aborted/i;
3104
- const TIMEOUT_PATTERN = /timeout after \d+ ?ms|cli-bridge timeout/i;
3105
- /**
3106
- * True when the error text describes an infrastructure hiccup that should be
3107
- * retried rather than scored. Empty/undefined input is not transient.
3108
- */
3109
- function isTransientTransportFailure(message, opts = {}) {
3110
- if (!message) return false;
3111
- if (BASE_TRANSIENT.test(message)) return true;
3112
- if ((opts.retryFullDurationTimeouts ?? false) && TIMEOUT_PATTERN.test(message)) return true;
3113
- for (const p of opts.extraPatterns ?? []) if (p.test(message)) return true;
3114
- return false;
3115
- }
3116
- //#endregion
3117
2399
  //#region src/campaign/upstream-evaluators.ts
3118
2400
  function phoenixEvaluatorJudge(evaluator, options) {
3119
2401
  if ((evaluator.optimizationDirection === "MINIMIZE" || evaluator.optimizationDirection === "NEUTRAL") && !options.toComposite) throw new TypeError(`phoenixEvaluatorJudge requires toComposite for a ${evaluator.optimizationDirection} evaluator`);
@@ -3765,6 +3047,6 @@ function resolveWorktreePath(surface, worktreeDir) {
3765
3047
  return verifyCodeSurface(surface, worktreeDir).path;
3766
3048
  }
3767
3049
  //#endregion
3768
- export { rolloutArgumentDiff as A, scoreboardSummary as C, FsLabeledScenarioStore as D, neutralizeText as E, planEvalFixtureRun as F, analyzeCrossSurfaceInteractions as I, buildTraceAnalystSurfaceDispatch as L, discoverEvalFixtures as M, loadEvalFixture as N, LabeledScenarioStoreError as O, loadEvalFixtureScenarios as P, traceAnalystQualityJudge as R, scoreUserStory as S, createOpenAiCompatibleExecutionOwner as T, runProfileMatrixSegment as _, autoevalsScorerJudge as a, makePlaybackDispatch as b, FileSearchLedger as c, validateSearchLedgerEvent as d, scoreDiscrimination as f, finalizeProfileMatrix as g, createProfileMatrixPlan as h, verifyCodeSurface as i, neutralizationGate as j, classifyUngroundedLiterals as k, SEARCH_LEDGER_SCHEMA as l, SegmentedProfileMatrixError as m, gitWorktreeAdapter as n, phoenixEvaluatorJudge as o, selectDiscriminative as p, resolveWorktreePath as r, isTransientTransportFailure as s, WorktreeAdapterError as t, openSearchLedger as u, ProfileMatrixError as v, userStoryScoreboard as w, renderScoreboardMarkdown as x, runProfileMatrix as y };
3050
+ export { analyzeCrossSurfaceInteractions as A, classifyUngroundedLiterals as C, loadEvalFixture as D, discoverEvalFixtures as E, traceAnalystQualityJudge as M, loadEvalFixtureScenarios as O, LabeledScenarioStoreError as S, neutralizationGate as T, scoreboardSummary as _, autoevalsScorerJudge as a, neutralizeText as b, selectDiscriminative as c, runProfileMatrixSegment as d, ProfileMatrixError as f, scoreUserStory as g, renderScoreboardMarkdown as h, verifyCodeSurface as i, buildTraceAnalystSurfaceDispatch as j, planEvalFixtureRun as k, createProfileMatrixPlan as l, makePlaybackDispatch as m, gitWorktreeAdapter as n, phoenixEvaluatorJudge as o, runProfileMatrix as p, resolveWorktreePath as r, scoreDiscrimination as s, WorktreeAdapterError as t, finalizeProfileMatrix as u, userStoryScoreboard as v, rolloutArgumentDiff as w, FsLabeledScenarioStore as x, crowdedFrontierParent as y };
3769
3051
 
3770
- //# sourceMappingURL=campaign-CN_7xJdV.js.map
3052
+ //# sourceMappingURL=campaign-BSmOwskD.js.map