@tangle-network/agent-eval 0.216.1 → 0.217.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/CHANGELOG.md +102 -57
  2. package/README.md +2 -2
  3. package/dist/adapters/http.d.ts +2 -2
  4. package/dist/{agent-profile-VFcQncbW.d.ts → agent-profile-DTt8uGP9.d.ts} +4 -17
  5. package/dist/agent-profile-DTt8uGP9.d.ts.map +1 -0
  6. package/dist/{agent-profile-cell-BK8mlqlq.js → agent-profile-cell-B1V1gUZs.js} +4 -53
  7. package/dist/agent-profile-cell-B1V1gUZs.js.map +1 -0
  8. package/dist/{agent-profile-cell-BNp-Js9F.d.ts → agent-profile-cell-BcpFbNd5.d.ts} +2 -22
  9. package/dist/agent-profile-cell-BcpFbNd5.d.ts.map +1 -0
  10. package/dist/{agreement-irr-BEWLIF3_.js → agreement-irr-BhAqjluA.js} +5 -5
  11. package/dist/agreement-irr-BhAqjluA.js.map +1 -0
  12. package/dist/analyst/index.d.ts +36 -169
  13. package/dist/analyst/index.d.ts.map +1 -1
  14. package/dist/analyst/index.js +17 -192
  15. package/dist/analyst/index.js.map +1 -1
  16. package/dist/{analyze-runs-C84irm4i.js → analyze-runs-DqPJaJ4X.js} +225 -21
  17. package/dist/analyze-runs-DqPJaJ4X.js.map +1 -0
  18. package/dist/{analyze-runs-D68fd-su.d.ts → analyze-runs-DyeNcenW.d.ts} +5 -5
  19. package/dist/{analyze-runs-D68fd-su.d.ts.map → analyze-runs-DyeNcenW.d.ts.map} +1 -1
  20. package/dist/authenticity/index.d.ts +0 -23
  21. package/dist/authenticity/index.d.ts.map +1 -1
  22. package/dist/authenticity/index.js +1 -34
  23. package/dist/authenticity/index.js.map +1 -1
  24. package/dist/{benchmark-command-By0vh8q7.js → benchmark-command-xQK8nOI6.js} +554 -89
  25. package/dist/benchmark-command-xQK8nOI6.js.map +1 -0
  26. package/dist/benchmarks/index.d.ts +5 -6
  27. package/dist/benchmarks/index.d.ts.map +1 -1
  28. package/dist/benchmarks/index.js +4 -4
  29. package/dist/benchmarks/index.js.map +1 -1
  30. package/dist/builder-eval/index.d.ts +3 -3
  31. package/dist/builder-eval/index.js +2 -2
  32. package/dist/builder-eval/index.js.map +1 -1
  33. package/dist/campaign/index.d.ts +7 -7
  34. package/dist/campaign/index.js +15 -15
  35. package/dist/{campaign-BudZ70zo.js → campaign-CJGkxAQ6.js} +23 -530
  36. package/dist/campaign-CJGkxAQ6.js.map +1 -0
  37. package/dist/{campaign-evidence-Clrn4hBV.js → campaign-evidence-CQYw8_0H.js} +10 -18
  38. package/dist/{campaign-evidence-Clrn4hBV.js.map → campaign-evidence-CQYw8_0H.js.map} +1 -1
  39. package/dist/{canonical-B2RqLofv.js → canonical-Dq2hOQ8L.js} +2 -2
  40. package/dist/{canonical-B2RqLofv.js.map → canonical-Dq2hOQ8L.js.map} +1 -1
  41. package/dist/cell-spend-DEWR3nj-.js +90 -0
  42. package/dist/cell-spend-DEWR3nj-.js.map +1 -0
  43. package/dist/{chat-client-l-MVDlDk.js → chat-client-ldqxYYTN.js} +2 -2
  44. package/dist/{chat-client-l-MVDlDk.js.map → chat-client-ldqxYYTN.js.map} +1 -1
  45. package/dist/{chat-json-call-puMArmtW.js → chat-json-call-DavzexSp.js} +3 -2
  46. package/dist/chat-json-call-DavzexSp.js.map +1 -0
  47. package/dist/{claim-q4HQhK1G.js → claim-BPVuyHuy.js} +3 -3
  48. package/dist/{claim-q4HQhK1G.js.map → claim-BPVuyHuy.js.map} +1 -1
  49. package/dist/cli.js +113 -12
  50. package/dist/cli.js.map +1 -1
  51. package/dist/{client-BzL9niqi.d.ts → client-hwo3cJjR.d.ts} +3 -16
  52. package/dist/client-hwo3cJjR.d.ts.map +1 -0
  53. package/dist/{cluster-bootstrap-qcUWYFl-.js → cluster-bootstrap-DEwwhl0C.js} +3 -3
  54. package/dist/{cluster-bootstrap-qcUWYFl-.js.map → cluster-bootstrap-DEwwhl0C.js.map} +1 -1
  55. package/dist/{produced-state-BsDmnwxc.js → completion-verifier-B_jw6C9p.js} +9 -64
  56. package/dist/completion-verifier-B_jw6C9p.js.map +1 -0
  57. package/dist/contract/index.d.ts +12 -12
  58. package/dist/contract/index.js +25 -401
  59. package/dist/contract/index.js.map +1 -1
  60. package/dist/{cost-ledger-BP8V4kUQ.js → cost-ledger-D0352Z4d.js} +4 -8
  61. package/dist/cost-ledger-D0352Z4d.js.map +1 -0
  62. package/dist/dataset-DQqhOCPt.d.ts.map +1 -1
  63. package/dist/{default-registry-COhk9g36.js → default-registry-ClYjq3QE.js} +8 -11
  64. package/dist/default-registry-ClYjq3QE.js.map +1 -0
  65. package/dist/{default-registry-DzHiGruW.d.ts → default-registry-DXgLmoDI.d.ts} +7 -50
  66. package/dist/default-registry-DXgLmoDI.d.ts.map +1 -0
  67. package/dist/{define-agent-eval-CNTPzIkp.js → define-agent-eval-BDxNlP3D.js} +10 -10
  68. package/dist/{define-agent-eval-CNTPzIkp.js.map → define-agent-eval-BDxNlP3D.js.map} +1 -1
  69. package/dist/{define-agent-eval-WSck0CZJ.d.ts → define-agent-eval-BIkH_gAR.d.ts} +8 -8
  70. package/dist/define-agent-eval-BIkH_gAR.d.ts.map +1 -0
  71. package/dist/{descriptive-DboxPZrG.js → descriptive-CVNy48rR.js} +2 -2
  72. package/dist/{descriptive-DboxPZrG.js.map → descriptive-CVNy48rR.js.map} +1 -1
  73. package/dist/diagnosis/index.d.ts +4 -14
  74. package/dist/diagnosis/index.d.ts.map +1 -1
  75. package/dist/diagnosis/index.js +67 -28
  76. package/dist/diagnosis/index.js.map +1 -1
  77. package/dist/{dspy-rlm-engine-LRCu61m5.js → dspy-rlm-engine-DhdCr1Dc.js} +5 -10
  78. package/dist/dspy-rlm-engine-DhdCr1Dc.js.map +1 -0
  79. package/dist/{emitter-HcCmFQl_.d.ts → emitter-DABYYTcH.d.ts} +5 -5
  80. package/dist/emitter-DABYYTcH.d.ts.map +1 -0
  81. package/dist/emitter-DbMXUIVP.js.map +1 -1
  82. package/dist/{engine-3A_4jOlI.d.ts → engine-BvZ0R-36.d.ts} +17 -21
  83. package/dist/engine-BvZ0R-36.d.ts.map +1 -0
  84. package/dist/{equal-terms-BtdXayCJ.js → equal-terms-DbPGcVtI.js} +2 -2
  85. package/dist/equal-terms-DbPGcVtI.js.map +1 -0
  86. package/dist/{errors-DVZiqS7K.js → errors-BcOs5MKW.js} +2 -8
  87. package/dist/{errors-DVZiqS7K.js.map → errors-BcOs5MKW.js.map} +1 -1
  88. package/dist/{eval-campaign-90jeaCAI.js → eval-campaign-BLEfBGbA.js} +6 -6
  89. package/dist/{eval-campaign-90jeaCAI.js.map → eval-campaign-BLEfBGbA.js.map} +1 -1
  90. package/dist/{evaluation-6Yoi74gM.d.ts → evaluation-jTjC_QQD.d.ts} +7 -7
  91. package/dist/evaluation-jTjC_QQD.d.ts.map +1 -0
  92. package/dist/evaluation.d.ts +2 -2
  93. package/dist/evaluation.js +1 -1
  94. package/dist/evaluation.js.map +1 -1
  95. package/dist/{exact-types-ClugMJfI.d.ts → exact-types-CflbJ9f3.d.ts} +2 -2
  96. package/dist/{exact-types-ClugMJfI.d.ts.map → exact-types-CflbJ9f3.d.ts.map} +1 -1
  97. package/dist/{exec-ChJ6d5if.js → exec-CpbtOXVt.js} +2 -24
  98. package/dist/{exec-ChJ6d5if.js.map → exec-CpbtOXVt.js.map} +1 -1
  99. package/dist/execution-tracks-CpgFPpS5.js.map +1 -1
  100. package/dist/experiment/index.d.ts +9 -112
  101. package/dist/experiment/index.d.ts.map +1 -1
  102. package/dist/experiment/index.js +149 -241
  103. package/dist/experiment/index.js.map +1 -1
  104. package/dist/{exporters-X4xwla8A.js → exporters-Cl6IeNAu.js} +3 -3
  105. package/dist/exporters-Cl6IeNAu.js.map +1 -0
  106. package/dist/{exporters-ChTnR90l.d.ts → exporters-Dk3oEbK_.d.ts} +2 -4
  107. package/dist/{exporters-ChTnR90l.d.ts.map → exporters-Dk3oEbK_.d.ts.map} +1 -1
  108. package/dist/{external-optimizer-process-BjMGUuds.js → external-optimizer-process-KVFGvYX1.js} +4 -3
  109. package/dist/external-optimizer-process-KVFGvYX1.js.map +1 -0
  110. package/dist/{external-optimizer-subprocess-BqW0hHcI.js → external-optimizer-subprocess-XIHBOSKt.js} +9 -11
  111. package/dist/external-optimizer-subprocess-XIHBOSKt.js.map +1 -0
  112. package/dist/{extract-usage-BrnzRJ6H.js → extract-usage-BZLU01kR.js} +2 -23
  113. package/dist/{extract-usage-BrnzRJ6H.js.map → extract-usage-BZLU01kR.js.map} +1 -1
  114. package/dist/{failure-cluster-CbgEDcFJ.d.ts → failure-cluster-DN0t63Z0.d.ts} +4 -43
  115. package/dist/failure-cluster-DN0t63Z0.d.ts.map +1 -0
  116. package/dist/{failure-taxonomy-CjabTATj.js → failure-taxonomy-Bx5oWqaW.js} +2 -19
  117. package/dist/{failure-taxonomy-CjabTATj.js.map → failure-taxonomy-Bx5oWqaW.js.map} +1 -1
  118. package/dist/{feedback-trajectory-C4EG0nNH.d.ts → feedback-trajectory-BWmhRBGu.d.ts} +7 -9
  119. package/dist/feedback-trajectory-BWmhRBGu.d.ts.map +1 -0
  120. package/dist/{semantic-concept-judge-BQF8te0T.js → findings-store-BMVQtEsm.js} +9 -249
  121. package/dist/findings-store-BMVQtEsm.js.map +1 -0
  122. package/dist/fuzz.d.ts +19 -62
  123. package/dist/fuzz.d.ts.map +1 -1
  124. package/dist/fuzz.js +62 -108
  125. package/dist/fuzz.js.map +1 -1
  126. package/dist/{hf-dataset-BR2yhuNn.js → hf-dataset-D9f7-oX7.js} +4 -24
  127. package/dist/hf-dataset-D9f7-oX7.js.map +1 -0
  128. package/dist/hosted/index.d.ts +2 -2
  129. package/dist/hosted/index.js +2 -2
  130. package/dist/{index-DHKEAv3s.d.ts → index-9jJ2fKSX.d.ts} +2 -64
  131. package/dist/index-9jJ2fKSX.d.ts.map +1 -0
  132. package/dist/{index-DV-jSzxF.d.ts → index-BLGqZ81N.d.ts} +10 -15
  133. package/dist/{index-DV-jSzxF.d.ts.map → index-BLGqZ81N.d.ts.map} +1 -1
  134. package/dist/{index-DPcngtwt.d.ts → index-BiT6RtNH.d.ts} +11 -36
  135. package/dist/index-BiT6RtNH.d.ts.map +1 -0
  136. package/dist/{index-BO41eGj5.d.ts → index-CX-GAUpw.d.ts} +3 -7
  137. package/dist/index-CX-GAUpw.d.ts.map +1 -0
  138. package/dist/{index-BFRO6chs.d.ts → index-CiRwLv2R.d.ts} +5 -69
  139. package/dist/index-CiRwLv2R.d.ts.map +1 -0
  140. package/dist/{index-CyszSg4O.d.ts → index-ZuWx52WG.d.ts} +115 -347
  141. package/dist/index-ZuWx52WG.d.ts.map +1 -0
  142. package/dist/index.d.ts +211 -218
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +402 -1040
  145. package/dist/index.js.map +1 -1
  146. package/dist/{integrity-dLiDe2kD.js → integrity-DOd9Q86O.js} +7 -9
  147. package/dist/integrity-DOd9Q86O.js.map +1 -0
  148. package/dist/{integrity-BXOsAb3i.js → integrity-W4CADcFc.js} +3 -7
  149. package/dist/{integrity-BXOsAb3i.js.map → integrity-W4CADcFc.js.map} +1 -1
  150. package/dist/{integrity-DAMEDFaC.d.ts → integrity-_qgZLA5p.d.ts} +4 -6
  151. package/dist/{integrity-DAMEDFaC.d.ts.map → integrity-_qgZLA5p.d.ts.map} +1 -1
  152. package/dist/{internal-Epl-YBZW.js → internal-BTK91Bqt.js} +3 -3
  153. package/dist/{internal-Epl-YBZW.js.map → internal-BTK91Bqt.js.map} +1 -1
  154. package/dist/{interval-CELpye1n.js → interval-Dq9gt7jx.js} +3 -3
  155. package/dist/{interval-CELpye1n.js.map → interval-Dq9gt7jx.js.map} +1 -1
  156. package/dist/{journal-DfRz9kps.js → journal-CR4QikYp.js} +110 -110
  157. package/dist/journal-CR4QikYp.js.map +1 -0
  158. package/dist/json-BhdsJaOQ.js +111 -0
  159. package/dist/json-BhdsJaOQ.js.map +1 -0
  160. package/dist/{judge-calibration-BpCy5XQl.js → judge-calibration-BkXMIWA4.js} +3 -3
  161. package/dist/{judge-calibration-BpCy5XQl.js.map → judge-calibration-BkXMIWA4.js.map} +1 -1
  162. package/dist/{judge-gate-iY9s4L44.js → judge-gate-Co5tuh57.js} +4 -27
  163. package/dist/{judge-gate-iY9s4L44.js.map → judge-gate-Co5tuh57.js.map} +1 -1
  164. package/dist/{judge-gate-CE7CQAgt.d.ts → judge-gate-DsL0yFcb.d.ts} +8 -9
  165. package/dist/judge-gate-DsL0yFcb.d.ts.map +1 -0
  166. package/dist/{kind-factory-BobI5Jy3.js → kind-factory-Gy4fXixd.js} +88 -17
  167. package/dist/kind-factory-Gy4fXixd.js.map +1 -0
  168. package/dist/ledger-core/index.d.ts +2 -2
  169. package/dist/ledger-core/index.js +4 -4
  170. package/dist/{ledger-core-Gq7yp8lP.js → ledger-core-DrJhbms9.js} +5 -84
  171. package/dist/ledger-core-DrJhbms9.js.map +1 -0
  172. package/dist/{llm-client-CyBAoYiX.js → llm-client-BshCREn6.js} +6 -108
  173. package/dist/llm-client-BshCREn6.js.map +1 -0
  174. package/dist/{llm-judge-CG12SQJq.js → llm-judge-C8jMTNNG.js} +24 -32
  175. package/dist/llm-judge-C8jMTNNG.js.map +1 -0
  176. package/dist/matrix/index.d.ts +3 -3
  177. package/dist/matrix/index.js +3 -2
  178. package/dist/{matrix-Dm0BQW7U.js → matrix-B8l-Nsxd.js} +3 -88
  179. package/dist/matrix-B8l-Nsxd.js.map +1 -0
  180. package/dist/{matrix-DSrSxjjy.d.ts → matrix-DHe-dwVJ.d.ts} +9 -18
  181. package/dist/matrix-DHe-dwVJ.d.ts.map +1 -0
  182. package/dist/{mean-DHoMiudD.js → mean-BbA_JCzW.js} +39 -5
  183. package/dist/mean-BbA_JCzW.js.map +1 -0
  184. package/dist/meta-eval/index.d.ts +5 -5
  185. package/dist/meta-eval/index.js +10 -10
  186. package/dist/metrics-BKaPBtIG.js.map +1 -1
  187. package/dist/{mint-DNU8QPG4.d.ts → mint-BRZXuwRi.d.ts} +4 -4
  188. package/dist/{mint-DNU8QPG4.d.ts.map → mint-BRZXuwRi.d.ts.map} +1 -1
  189. package/dist/{mint-QaD5cA0u.js → mint-zszyYlpA.js} +4 -4
  190. package/dist/{mint-QaD5cA0u.js.map → mint-zszyYlpA.js.map} +1 -1
  191. package/dist/{multi-layer-verifier-BUaQ4C17.d.ts → multi-layer-verifier-DEgMUk6v.d.ts} +2 -2
  192. package/dist/{multi-layer-verifier-BUaQ4C17.d.ts.map → multi-layer-verifier-DEgMUk6v.d.ts.map} +1 -1
  193. package/dist/{multiplicity-DQUFcbW4.js → multiplicity-Sg0U7h8j.js} +2 -2
  194. package/dist/{multiplicity-DQUFcbW4.js.map → multiplicity-Sg0U7h8j.js.map} +1 -1
  195. package/dist/multishot/golden/index.d.ts +1 -23
  196. package/dist/multishot/golden/index.d.ts.map +1 -1
  197. package/dist/multishot/golden/index.js +3 -3
  198. package/dist/multishot/golden/index.js.map +1 -1
  199. package/dist/multishot/index.d.ts +3 -12
  200. package/dist/multishot/index.d.ts.map +1 -1
  201. package/dist/multishot/index.js +4 -3
  202. package/dist/multishot/index.js.map +1 -1
  203. package/dist/openapi.json +114 -10
  204. package/dist/{otel-spans-B9tUXRHF.js → otel-spans-CdN909k1.js} +3 -3
  205. package/dist/{otel-spans-B9tUXRHF.js.map → otel-spans-CdN909k1.js.map} +1 -1
  206. package/dist/{paired-arms-CwMGJsrS.js → paired-arms-Ct4LTKc1.js} +32 -9
  207. package/dist/paired-arms-Ct4LTKc1.js.map +1 -0
  208. package/dist/{paired-binary-CvpFHfKZ.js → paired-binary-B_nejA44.js} +3 -36
  209. package/dist/paired-binary-B_nejA44.js.map +1 -0
  210. package/dist/{paired-promotion-decision-DPKz8ZnF.d.ts → paired-promotion-decision-CQMJ5xGN.d.ts} +2 -34
  211. package/dist/paired-promotion-decision-CQMJ5xGN.d.ts.map +1 -0
  212. package/dist/{paired-promotion-decision-DsAPYGCm.js → paired-promotion-decision-D0SHb-ZL.js} +3 -3
  213. package/dist/{paired-promotion-decision-DsAPYGCm.js.map → paired-promotion-decision-D0SHb-ZL.js.map} +1 -1
  214. package/dist/{pareto-Cm6ndrWN.js → pareto-BzsxidFD.js} +11 -11
  215. package/dist/pareto-BzsxidFD.js.map +1 -0
  216. package/dist/pipelines/index.d.ts +16 -19
  217. package/dist/pipelines/index.d.ts.map +1 -1
  218. package/dist/pipelines/index.js +4 -68
  219. package/dist/pipelines/index.js.map +1 -1
  220. package/dist/{power-and-mde-Hj2ubb4B.js → power-and-mde-N5nU4_Ly.js} +3 -3
  221. package/dist/{power-and-mde-Hj2ubb4B.js.map → power-and-mde-N5nU4_Ly.js.map} +1 -1
  222. package/dist/{prime-protocol-CHKgA3a6.js → prime-protocol-BFgGrEMP.js} +3 -3
  223. package/dist/prime-protocol-BFgGrEMP.js.map +1 -0
  224. package/dist/{prime-protocol-HiB9HX7E.d.ts → prime-protocol-BWG2DQIk.d.ts} +3 -21
  225. package/dist/prime-protocol-BWG2DQIk.d.ts.map +1 -0
  226. package/dist/profile-cell.d.ts +2 -2
  227. package/dist/profile-cell.js +2 -2
  228. package/dist/{promotion-gate-BawrdPYr.d.ts → promotion-gate-DaY95yU6.d.ts} +7 -8
  229. package/dist/{promotion-gate-BawrdPYr.d.ts.map → promotion-gate-DaY95yU6.d.ts.map} +1 -1
  230. package/dist/{promotion-policy-KO57gbyV.js → promotion-policy-6A8osGr_.js} +4 -4
  231. package/dist/{promotion-policy-KO57gbyV.js.map → promotion-policy-6A8osGr_.js.map} +1 -1
  232. package/dist/{proposal-findings-CY1xKn_a.js → proposal-findings-BbWidvUk.js} +3 -3
  233. package/dist/proposal-findings-BbWidvUk.js.map +1 -0
  234. package/dist/{query-BUCZCK7F.js → query-B_RZ36an.js} +5 -5
  235. package/dist/query-B_RZ36an.js.map +1 -0
  236. package/dist/{query-DK1nWcmp.d.ts → query-Cmv_U8vf.d.ts} +4 -24
  237. package/dist/{query-DK1nWcmp.d.ts.map → query-Cmv_U8vf.d.ts.map} +1 -1
  238. package/dist/{random-ByUSnV9w.js → random-DDDcC7YU.js} +2 -2
  239. package/dist/{random-ByUSnV9w.js.map → random-DDDcC7YU.js.map} +1 -1
  240. package/dist/{raw-provider-sink-DoHz4JNG.js → raw-provider-sink-75w4FWBj.js} +2 -2
  241. package/dist/{raw-provider-sink-DoHz4JNG.js.map → raw-provider-sink-75w4FWBj.js.map} +1 -1
  242. package/dist/{redact-mtCCcT8z.d.ts → redact-DXdlFb_U.d.ts} +2 -3
  243. package/dist/redact-DXdlFb_U.d.ts.map +1 -0
  244. package/dist/{redact-B5xXKqQ3.js → redact-mtkTiJVk.js} +2 -7
  245. package/dist/{redact-B5xXKqQ3.js.map → redact-mtkTiJVk.js.map} +1 -1
  246. package/dist/{registry-D7_hm2fK.d.ts → registry-ssNoHzwD.d.ts} +4 -4
  247. package/dist/{registry-D7_hm2fK.d.ts.map → registry-ssNoHzwD.d.ts.map} +1 -1
  248. package/dist/{release-confidence-CpuP65S5.js → release-confidence-CYIFH-fp.js} +6 -11
  249. package/dist/release-confidence-CYIFH-fp.js.map +1 -0
  250. package/dist/{report-command-SC9nqb4M.js → render-C-w2EZ6p.js} +205 -363
  251. package/dist/render-C-w2EZ6p.js.map +1 -0
  252. package/dist/reporting.d.ts +6 -6
  253. package/dist/reporting.js +8 -8
  254. package/dist/{researcher-CEcfku-T.d.ts → researcher-0ABVIdGa.d.ts} +9 -9
  255. package/dist/{researcher-CEcfku-T.d.ts.map → researcher-0ABVIdGa.d.ts.map} +1 -1
  256. package/dist/{reward-CpCmAM8L.d.ts → reward-DrZ71vnf.d.ts} +3 -26
  257. package/dist/reward-DrZ71vnf.d.ts.map +1 -0
  258. package/dist/{reward-hacking-E0d-WVcP.js → reward-hacking-ByuETaIb.js} +3 -3
  259. package/dist/{reward-hacking-E0d-WVcP.js.map → reward-hacking-ByuETaIb.js.map} +1 -1
  260. package/dist/{reward-hacking-RVdZ6Kkt.d.ts → reward-hacking-E52wq86n.d.ts} +5 -18
  261. package/dist/reward-hacking-E52wq86n.d.ts.map +1 -0
  262. package/dist/reward-nw2xZGZG.js.map +1 -1
  263. package/dist/rl.d.ts +117 -295
  264. package/dist/rl.d.ts.map +1 -1
  265. package/dist/rl.js +27 -747
  266. package/dist/rl.js.map +1 -1
  267. package/dist/rollout/index.d.ts +5 -5
  268. package/dist/rollout/index.js +7 -8
  269. package/dist/{rollout-DZV1t2Wg.js → rollout-D6C50mfA.js} +88 -13
  270. package/dist/rollout-D6C50mfA.js.map +1 -0
  271. package/dist/{rubric-predictive-validity-DaFW70y9.js → rubric-predictive-validity-D3_oI72N.js} +3 -3
  272. package/dist/{rubric-predictive-validity-DaFW70y9.js.map → rubric-predictive-validity-D3_oI72N.js.map} +1 -1
  273. package/dist/{rubric-predictive-validity-C03EC7ZE.d.ts → rubric-predictive-validity-DiwT8PbL.d.ts} +2 -2
  274. package/dist/{rubric-predictive-validity-C03EC7ZE.d.ts.map → rubric-predictive-validity-DiwT8PbL.d.ts.map} +1 -1
  275. package/dist/{run-record-C1E24G2A.d.ts → run-record-CaxbLq6Y.d.ts} +4 -10
  276. package/dist/run-record-CaxbLq6Y.d.ts.map +1 -0
  277. package/dist/{run-record-C5e7FjhJ.js → run-record-CysKLB93.js} +3 -3
  278. package/dist/run-record-CysKLB93.js.map +1 -0
  279. package/dist/{run-record-Boc5IUTp.js → run-record-DhEJgoPz.js} +4 -4
  280. package/dist/{run-record-Boc5IUTp.js.map → run-record-DhEJgoPz.js.map} +1 -1
  281. package/dist/sandbox-harness-BlSOu4LX.d.ts.map +1 -1
  282. package/dist/{schema-CSf6qWgZ.js → schema-Bt2vLFm3.js} +2 -14
  283. package/dist/schema-Bt2vLFm3.js.map +1 -0
  284. package/dist/schema-C-ziyJD7.d.ts.map +1 -1
  285. package/dist/{schema-2g7trUwH.d.ts → schema-D6EVKzTB.d.ts} +4 -5
  286. package/dist/schema-D6EVKzTB.d.ts.map +1 -0
  287. package/dist/{schema-BuiujZ-g.js → schema-DxcKTzbi.js} +2 -2
  288. package/dist/schema-DxcKTzbi.js.map +1 -0
  289. package/dist/search/index.d.ts +3 -31
  290. package/dist/search/index.d.ts.map +1 -1
  291. package/dist/search/index.js +4 -4
  292. package/dist/{search-kernel-DyNEa6IU.d.ts → search-kernel-DxqjBxA-.d.ts} +10 -27
  293. package/dist/search-kernel-DxqjBxA-.d.ts.map +1 -0
  294. package/dist/{search-ledger-CVUGLDZp.js → search-ledger-TUvB5gWH.js} +7 -7
  295. package/dist/{search-ledger-CVUGLDZp.js.map → search-ledger-TUvB5gWH.js.map} +1 -1
  296. package/dist/{search-ledger-file-DDQUgvCg.js → search-ledger-file-UKCO2r8a.js} +4 -4
  297. package/dist/search-ledger-file-UKCO2r8a.js.map +1 -0
  298. package/dist/{search-shipper-BOSD46qv.js → search-shipper-Cw2z3-td.js} +4 -4
  299. package/dist/search-shipper-Cw2z3-td.js.map +1 -0
  300. package/dist/{search-summary-BQCSWf1g.js → search-summary-DQIvJsSB.js} +5 -5
  301. package/dist/{search-summary-BQCSWf1g.js.map → search-summary-DQIvJsSB.js.map} +1 -1
  302. package/dist/{sequential-CzK5DarL.js → sequential-BVv1sjsw.js} +2 -32
  303. package/dist/{sequential-CzK5DarL.js.map → sequential-BVv1sjsw.js.map} +1 -1
  304. package/dist/{sequential-Bf_pbE50.js → sequential-CimQrbjv.js} +5 -5
  305. package/dist/sequential-CimQrbjv.js.map +1 -0
  306. package/dist/{sequential-BhsrMupG.d.ts → sequential-KwGspfeR.d.ts} +2 -9
  307. package/dist/{sequential-BhsrMupG.d.ts.map → sequential-KwGspfeR.d.ts.map} +1 -1
  308. package/dist/{sequential-eprocess-DM_qENCl.js → sequential-eprocess-DodI6RoF.js} +2 -2
  309. package/dist/{sequential-eprocess-DM_qENCl.js.map → sequential-eprocess-DodI6RoF.js.map} +1 -1
  310. package/dist/{server-e9oWO_bN.js → server-DoVbqqtJ.js} +101 -101
  311. package/dist/server-DoVbqqtJ.js.map +1 -0
  312. package/dist/{single-run-lock-CV9Eyd_q.js → single-run-lock-U58yf8N6.js} +2 -2
  313. package/dist/{single-run-lock-CV9Eyd_q.js.map → single-run-lock-U58yf8N6.js.map} +1 -1
  314. package/dist/{skillopt-optimization-method-BiwA8nfX.js → skillopt-optimization-method-kyL94-ri.js} +17 -95
  315. package/dist/skillopt-optimization-method-kyL94-ri.js.map +1 -0
  316. package/dist/{spans-BHAUXMGN.d.ts → spans-CVngGij3.d.ts} +2 -2
  317. package/dist/{spans-BHAUXMGN.d.ts.map → spans-CVngGij3.d.ts.map} +1 -1
  318. package/dist/{statistical-heldout-42NlCNDe.js → statistical-heldout-Bksv92Th.js} +3 -3
  319. package/dist/statistical-heldout-Bksv92Th.js.map +1 -0
  320. package/dist/{statistical-heldout-CYpGaoDH.d.ts → statistical-heldout-C9AbgREN.d.ts} +8 -67
  321. package/dist/statistical-heldout-C9AbgREN.d.ts.map +1 -0
  322. package/dist/{steps-Bg5-KVx1.d.ts → steps-DlepJPwD.d.ts} +2 -56
  323. package/dist/steps-DlepJPwD.d.ts.map +1 -0
  324. package/dist/{store-C4avFjIi.d.ts → store-B3nWRy3B.d.ts} +2 -2
  325. package/dist/{store-C4avFjIi.d.ts.map → store-B3nWRy3B.d.ts.map} +1 -1
  326. package/dist/{store-otlp-DJ9dtA5x.js → store-otlp-BteDAbHK.js} +3 -3
  327. package/dist/{store-otlp-DJ9dtA5x.js.map → store-otlp-BteDAbHK.js.map} +1 -1
  328. package/dist/{store-tool-spans-CIX5arAG.js → store-tool-spans-D5l_OfTJ.js} +8 -8
  329. package/dist/store-tool-spans-D5l_OfTJ.js.map +1 -0
  330. package/dist/{store-tool-spans-DdCSPa7C.d.ts → store-tool-spans-DZS0HWVf.d.ts} +9 -18
  331. package/dist/store-tool-spans-DZS0HWVf.d.ts.map +1 -0
  332. package/dist/storyboard/index.d.ts +4 -11
  333. package/dist/storyboard/index.d.ts.map +1 -1
  334. package/dist/storyboard/index.js +1 -16
  335. package/dist/storyboard/index.js.map +1 -1
  336. package/dist/{summary-report-V_JACR4Y.js → summary-report-BsXJoYX5.js} +88 -10
  337. package/dist/summary-report-BsXJoYX5.js.map +1 -0
  338. package/dist/{summary-report-bdFDXq0b.d.ts → summary-report-DM7tlml1.d.ts} +10 -19
  339. package/dist/summary-report-DM7tlml1.d.ts.map +1 -0
  340. package/dist/supervisor-run/index.d.ts +60 -28
  341. package/dist/supervisor-run/index.d.ts.map +1 -1
  342. package/dist/supervisor-run/index.js +4 -458
  343. package/dist/supervisor-run/index.js.map +1 -1
  344. package/dist/{systemone-BomhHr2c.d.ts → systemone-Bp_Ac0p1.d.ts} +5 -5
  345. package/dist/{systemone-BomhHr2c.d.ts.map → systemone-Bp_Ac0p1.d.ts.map} +1 -1
  346. package/dist/systemone-protocol.js +1 -1
  347. package/dist/{systemone-review-CUVcQJu6.d.ts → systemone-review-CwE6JGIp.d.ts} +2 -2
  348. package/dist/{systemone-review-CUVcQJu6.d.ts.map → systemone-review-CwE6JGIp.d.ts.map} +1 -1
  349. package/dist/{systemone-review-D7sXwsqq.js → systemone-review-DzdOJ8I6.js} +3 -3
  350. package/dist/{systemone-review-D7sXwsqq.js.map → systemone-review-DzdOJ8I6.js.map} +1 -1
  351. package/dist/systemone.d.ts +5 -5
  352. package/dist/systemone.js +5 -5
  353. package/dist/systemone.js.map +1 -1
  354. package/dist/{task-failure-attributes-hEmASjix.js → task-failure-attributes-BMsblaDh.js} +3 -3
  355. package/dist/task-failure-attributes-BMsblaDh.js.map +1 -0
  356. package/dist/{terminal-record-DZyQZ3pz.js → terminal-record-78g6E4vh.js} +5 -5
  357. package/dist/terminal-record-78g6E4vh.js.map +1 -0
  358. package/dist/{tool-groups-C3NEcdCM.d.ts → tool-groups-DyNz2JZ_.d.ts} +3 -3
  359. package/dist/tool-groups-DyNz2JZ_.d.ts.map +1 -0
  360. package/dist/{tool-waste-BKgvd-TP.d.ts → tool-waste-CkjzWmeY.d.ts} +25 -28
  361. package/dist/tool-waste-CkjzWmeY.d.ts.map +1 -0
  362. package/dist/{tool-waste-BlesqTqW.js → tool-waste-DLsjS_p-.js} +5 -5
  363. package/dist/{tool-waste-BlesqTqW.js.map → tool-waste-DLsjS_p-.js.map} +1 -1
  364. package/dist/{trace-questions-CM2CAocU.d.ts → trace-questions-xxwgsuMi.d.ts} +4 -9
  365. package/dist/{trace-questions-CM2CAocU.d.ts.map → trace-questions-xxwgsuMi.d.ts.map} +1 -1
  366. package/dist/trace-repair/index.d.ts +14 -211
  367. package/dist/trace-repair/index.d.ts.map +1 -1
  368. package/dist/trace-repair/index.js +865 -981
  369. package/dist/trace-repair/index.js.map +1 -1
  370. package/dist/traces.d.ts +18 -46
  371. package/dist/traces.d.ts.map +1 -1
  372. package/dist/traces.js +13 -13
  373. package/dist/traces.js.map +1 -1
  374. package/dist/trajectory-replay/index.d.ts +3 -117
  375. package/dist/trajectory-replay/index.d.ts.map +1 -1
  376. package/dist/trajectory-replay/index.js +98 -56
  377. package/dist/trajectory-replay/index.js.map +1 -1
  378. package/dist/{tree-C1XYeXvy.js → tree-BGRglkKd.js} +13 -10
  379. package/dist/tree-BGRglkKd.js.map +1 -0
  380. package/dist/{types-B3jzCp0p.js → types-BXgASBCL.js} +2 -2
  381. package/dist/{types-B3jzCp0p.js.map → types-BXgASBCL.js.map} +1 -1
  382. package/dist/{types-C1tnkEgM.d.ts → types-CW8ewATZ.d.ts} +4 -113
  383. package/dist/types-CW8ewATZ.d.ts.map +1 -0
  384. package/dist/{types-BqkVmHfv.d.ts → types-CmXY0PQf.d.ts} +2 -4
  385. package/dist/types-CmXY0PQf.d.ts.map +1 -0
  386. package/dist/{types-C02qtnG8.d.ts → types-D-mgRzlh.d.ts} +7 -28
  387. package/dist/types-D-mgRzlh.d.ts.map +1 -0
  388. package/dist/{types-Cq8mSbq8.d.ts → types-D8GhJoHk.d.ts} +7 -9
  389. package/dist/{types-Cq8mSbq8.d.ts.map → types-D8GhJoHk.d.ts.map} +1 -1
  390. package/dist/{types-IXD2HJzu.js → types-DqFMNTgK.js} +2 -4
  391. package/dist/types-DqFMNTgK.js.map +1 -0
  392. package/dist/{types-Cbe2fWBa.d.ts → types-DtMbFw6U.d.ts} +3 -3
  393. package/dist/{types-Cbe2fWBa.d.ts.map → types-DtMbFw6U.d.ts.map} +1 -1
  394. package/dist/{verdict-Dl0tiT1X.js → verdict-BGQmxQ8A.js} +3 -3
  395. package/dist/verdict-BGQmxQ8A.js.map +1 -0
  396. package/dist/{verdict-E4eRNf7-.d.ts → verdict-C24NELtN.d.ts} +2 -15
  397. package/dist/{verdict-E4eRNf7-.d.ts.map → verdict-C24NELtN.d.ts.map} +1 -1
  398. package/dist/{verdict-cache-Bm8EKL2s.js → verdict-cache-CL_7tePD.js} +2 -2
  399. package/dist/verdict-cache-CL_7tePD.js.map +1 -0
  400. package/dist/wire/index.d.ts +31 -410
  401. package/dist/wire/index.d.ts.map +1 -1
  402. package/dist/wire/index.js +2 -2
  403. package/docs/changes/jev-evidence-review.md +1 -1
  404. package/docs/changes/jev-product-adoption.md +1 -1
  405. package/docs/changes/jev-recorded-evidence.md +1 -1
  406. package/docs/design/statistics-decisions.md +17 -17
  407. package/docs/design.md +1 -1
  408. package/docs/evaluation-integrity.md +1 -1
  409. package/docs/proofs/campaign-attempt-retention-20261001/README.md +2 -2
  410. package/docs/public-api.md +138 -529
  411. package/docs/rollout.md +1 -1
  412. package/docs/trace-repair-admission.md +1 -1
  413. package/docs/wire-protocol.md +1 -1
  414. package/package.json +1 -1
  415. package/dist/active-curriculum-B_Lc9kfO.js +0 -61
  416. package/dist/active-curriculum-B_Lc9kfO.js.map +0 -1
  417. package/dist/agent-profile-VFcQncbW.d.ts.map +0 -1
  418. package/dist/agent-profile-cell-BK8mlqlq.js.map +0 -1
  419. package/dist/agent-profile-cell-BNp-Js9F.d.ts.map +0 -1
  420. package/dist/agreement-irr-BEWLIF3_.js.map +0 -1
  421. package/dist/analyze-runs-C84irm4i.js.map +0 -1
  422. package/dist/baseline-Udi_PLuT.js +0 -259
  423. package/dist/baseline-Udi_PLuT.js.map +0 -1
  424. package/dist/benchmark-CXmVVHH2.js +0 -562
  425. package/dist/benchmark-CXmVVHH2.js.map +0 -1
  426. package/dist/benchmark-command-By0vh8q7.js.map +0 -1
  427. package/dist/campaign-BudZ70zo.js.map +0 -1
  428. package/dist/chat-json-call-puMArmtW.js.map +0 -1
  429. package/dist/claude-jsonl-dZir12m6.js +0 -86
  430. package/dist/claude-jsonl-dZir12m6.js.map +0 -1
  431. package/dist/client-BzL9niqi.d.ts.map +0 -1
  432. package/dist/cost-ledger-BP8V4kUQ.js.map +0 -1
  433. package/dist/counterfactual-CPaWN99-.d.ts +0 -60
  434. package/dist/counterfactual-CPaWN99-.d.ts.map +0 -1
  435. package/dist/counterfactual-Dn3veueY.js +0 -98
  436. package/dist/counterfactual-Dn3veueY.js.map +0 -1
  437. package/dist/default-registry-COhk9g36.js.map +0 -1
  438. package/dist/default-registry-DzHiGruW.d.ts.map +0 -1
  439. package/dist/define-agent-eval-WSck0CZJ.d.ts.map +0 -1
  440. package/dist/dspy-rlm-engine-LRCu61m5.js.map +0 -1
  441. package/dist/effect-sizes-BhzEpXMc.js +0 -82
  442. package/dist/effect-sizes-BhzEpXMc.js.map +0 -1
  443. package/dist/emitter-HcCmFQl_.d.ts.map +0 -1
  444. package/dist/engine-3A_4jOlI.d.ts.map +0 -1
  445. package/dist/equal-terms-BtdXayCJ.js.map +0 -1
  446. package/dist/evaluation-6Yoi74gM.d.ts.map +0 -1
  447. package/dist/exporters-X4xwla8A.js.map +0 -1
  448. package/dist/external-optimizer-process-BjMGUuds.js.map +0 -1
  449. package/dist/external-optimizer-subprocess-BqW0hHcI.js.map +0 -1
  450. package/dist/failure-cluster-CbgEDcFJ.d.ts.map +0 -1
  451. package/dist/feedback-trajectory-C4EG0nNH.d.ts.map +0 -1
  452. package/dist/hf-dataset-BR2yhuNn.js.map +0 -1
  453. package/dist/index-BFRO6chs.d.ts.map +0 -1
  454. package/dist/index-BO41eGj5.d.ts.map +0 -1
  455. package/dist/index-CyszSg4O.d.ts.map +0 -1
  456. package/dist/index-DHKEAv3s.d.ts.map +0 -1
  457. package/dist/index-DPcngtwt.d.ts.map +0 -1
  458. package/dist/integrity-dLiDe2kD.js.map +0 -1
  459. package/dist/journal-DfRz9kps.js.map +0 -1
  460. package/dist/judge-gate-CE7CQAgt.d.ts.map +0 -1
  461. package/dist/kind-factory-BobI5Jy3.js.map +0 -1
  462. package/dist/ledger-core-Gq7yp8lP.js.map +0 -1
  463. package/dist/llm-client-CyBAoYiX.js.map +0 -1
  464. package/dist/llm-judge-CG12SQJq.js.map +0 -1
  465. package/dist/matrix-DSrSxjjy.d.ts.map +0 -1
  466. package/dist/matrix-Dm0BQW7U.js.map +0 -1
  467. package/dist/mean-DHoMiudD.js.map +0 -1
  468. package/dist/normal-DsJZtrJc.js +0 -25
  469. package/dist/normal-DsJZtrJc.js.map +0 -1
  470. package/dist/paired-arms-CwMGJsrS.js.map +0 -1
  471. package/dist/paired-binary-CvpFHfKZ.js.map +0 -1
  472. package/dist/paired-promotion-decision-DPKz8ZnF.d.ts.map +0 -1
  473. package/dist/pareto-Cm6ndrWN.js.map +0 -1
  474. package/dist/prime-protocol-CHKgA3a6.js.map +0 -1
  475. package/dist/prime-protocol-HiB9HX7E.d.ts.map +0 -1
  476. package/dist/produced-state-BsDmnwxc.js.map +0 -1
  477. package/dist/proposal-findings-CY1xKn_a.js.map +0 -1
  478. package/dist/query-BUCZCK7F.js.map +0 -1
  479. package/dist/redact-mtCCcT8z.d.ts.map +0 -1
  480. package/dist/release-confidence-CpuP65S5.js.map +0 -1
  481. package/dist/report-command-SC9nqb4M.js.map +0 -1
  482. package/dist/reward-CpCmAM8L.d.ts.map +0 -1
  483. package/dist/reward-hacking-RVdZ6Kkt.d.ts.map +0 -1
  484. package/dist/rollout-DZV1t2Wg.js.map +0 -1
  485. package/dist/run-record-C1E24G2A.d.ts.map +0 -1
  486. package/dist/run-record-C5e7FjhJ.js.map +0 -1
  487. package/dist/schema-2g7trUwH.d.ts.map +0 -1
  488. package/dist/schema-BuiujZ-g.js.map +0 -1
  489. package/dist/schema-CSf6qWgZ.js.map +0 -1
  490. package/dist/search-kernel-DyNEa6IU.d.ts.map +0 -1
  491. package/dist/search-ledger-file-DDQUgvCg.js.map +0 -1
  492. package/dist/search-shipper-BOSD46qv.js.map +0 -1
  493. package/dist/semantic-concept-judge-BQF8te0T.js.map +0 -1
  494. package/dist/sequential-Bf_pbE50.js.map +0 -1
  495. package/dist/server-e9oWO_bN.js.map +0 -1
  496. package/dist/skillopt-optimization-method-BiwA8nfX.js.map +0 -1
  497. package/dist/statistical-heldout-42NlCNDe.js.map +0 -1
  498. package/dist/statistical-heldout-CYpGaoDH.d.ts.map +0 -1
  499. package/dist/steps-Bg5-KVx1.d.ts.map +0 -1
  500. package/dist/store-tool-spans-CIX5arAG.js.map +0 -1
  501. package/dist/store-tool-spans-DdCSPa7C.d.ts.map +0 -1
  502. package/dist/student-t-DVPW7CdL.js +0 -39
  503. package/dist/student-t-DVPW7CdL.js.map +0 -1
  504. package/dist/summary-report-V_JACR4Y.js.map +0 -1
  505. package/dist/summary-report-bdFDXq0b.d.ts.map +0 -1
  506. package/dist/task-failure-attributes-hEmASjix.js.map +0 -1
  507. package/dist/terminal-record-DZyQZ3pz.js.map +0 -1
  508. package/dist/tool-groups-C3NEcdCM.d.ts.map +0 -1
  509. package/dist/tool-waste-BKgvd-TP.d.ts.map +0 -1
  510. package/dist/trajectory-Y1fmdlw7.d.ts +0 -24
  511. package/dist/trajectory-Y1fmdlw7.d.ts.map +0 -1
  512. package/dist/tree-C1XYeXvy.js.map +0 -1
  513. package/dist/types-BqkVmHfv.d.ts.map +0 -1
  514. package/dist/types-C02qtnG8.d.ts.map +0 -1
  515. package/dist/types-C1tnkEgM.d.ts.map +0 -1
  516. package/dist/types-IXD2HJzu.js.map +0 -1
  517. package/dist/usage-receipt-Cx3xNeyB.js +0 -76
  518. package/dist/usage-receipt-Cx3xNeyB.js.map +0 -1
  519. package/dist/verdict-Dl0tiT1X.js.map +0 -1
  520. package/dist/verdict-cache-Bm8EKL2s.js.map +0 -1
  521. package/docs/design/self-improvement-evidence-audit.md +0 -263
@@ -1,6 +1,6 @@
1
1
  import { A as isTrainableSplit, C as RolloutWorkspaceCapture, D as assertRolloutLine, E as assertMintedLines, O as gateGamedOutcome, S as RolloutTask, T as assertMinted, _ as RolloutPolicy, a as MintedRolloutLine, b as RolloutSplit, c as ROLLOUT_ROLES, d as RolloutArtifacts, f as RolloutCapture, g as RolloutOutcome, h as RolloutLine, i as GatedEvidence, j as validateRolloutLine, k as isRolloutLine, l as ROLLOUT_SCHEMA, m as RolloutEvidenceAttempt, n as ChatRole, o as MintedRolloutOutcome, p as RolloutCostBlock, r as ChatToolCall, s as ROLLOUT_CAPTURES, t as ChatMessage, u as ROLLOUT_SPLITS, v as RolloutProvenance, w as ToolDef, x as RolloutStep, y as RolloutRole } from "../schema-C-ziyJD7.js";
2
- import { a as observedSplitScore, c as trainingScore, i as observedScore, n as ScorePreference, o as scoreOrigin, r as isRealnessGated, s as trainingReward, t as ScoreOrigin } from "../reward-CpCmAM8L.js";
3
- import { a as mintRolloutRows, i as RolloutSearchLineage, n as MintRolloutResult, o as unmintableReasons, r as RolloutScrubber, t as MintRolloutOptions } from "../mint-DNU8QPG4.js";
4
- import { a as SftRow, c as VerifiersTokenUsage, d as toRftItem, f as toRftItems, h as toVerifiersRolloutOutputs, i as SftExportOptions, l as toJsonl, m as toVerifiersRolloutOutput, n as RewardRow, p as toSftRows, r as RftItem, s as VerifiersRolloutOutput, t as RealnessLabels, u as toRewardRows } from "../exporters-ChTnR90l.js";
5
- import { $ as HarborAgent, A as measureFormatGate, B as ReadClaudeTranscriptOptions, C as FORMAT_GATE_DISPOSITION, Ct as GatePolicy, D as ReleaseRowRef, E as GateReport, F as readOpencodeSessionMessages, G as transcriptFromSession, H as findClaudeTranscripts, I as ClaudeTranscript, J as readRolloutLedger, K as appendRolloutLines, L as ClaudeTranscriptRef, M as DEFAULT_OPENCODE_DB, N as findOpencodeSessionsByDirectory, O as assertGateReport, P as readOpencodeSession, Q as HARBOR_IMPORT_GAP, R as ClaudeUsageTotals, S as EmittedEvidence, St as GateEntryPoint, T as GateDisposition, Tt as gatedEvidenceOf, U as parseClaudeTranscript, V as claudeProjectSlug, W as readClaudeTranscript, X as ATIF_SCHEMA_VERSION, Y as writeRolloutLedger, Z as FromHarborOptions, _ as defaultRolloutScrubber, _t as GATE_POLICIES, a as buildHfDataset, at as HarborObservationResult, b as scrubRolloutLine, bt as GateCheckId, c as runRolloutReleaseCli, ct as HarborSubagentTrajectoryRef, d as RELEASE_FORMATS, dt as fromHarborTrajectory, et as HarborContentPart, f as ReleaseFormat, ft as relabelImportedSplit, g as addScrubCounts, gt as GATE_CHECK_IDS, h as ScrubRule, ht as GATE_CHECKS, i as ScrubReport, it as HarborObservation, j as releaseRowRefs, k as gatedRolloutIds, l as DatasetCardInputs, lt as HarborToolCall, m as ScrubCounts, mt as toHarborTrajectory, n as BuildSummary, nt as HarborImageSource, o as parseRolloutReleaseArgs, ot as HarborStep, p as buildDatasetCard, pt as toHarborTrajectories, q as readRolloutJournal, r as RolloutReleaseCliArgs, rt as HarborMetrics, s as planPushCommand, st as HarborStepSource, t as BuildOptions, tt as HarborFinalMetrics, u as FORMAT_FILES, ut as HarborTrajectory, v as emptyScrubCounts, vt as GateCheck, w as FormatGateCounts, wt as gateErrors, x as scrubText, xt as GateCheckedOutcome, y as scrubLines, yt as GateCheckDisposition, z as DEFAULT_CLAUDE_PROJECTS_DIR } from "../index-BFRO6chs.js";
6
- export { ATIF_SCHEMA_VERSION, type BuildOptions, type BuildSummary, type ChatMessage, type ChatRole, type ChatToolCall, type ClaudeTranscript, type ClaudeTranscriptRef, type ClaudeUsageTotals, DEFAULT_CLAUDE_PROJECTS_DIR, DEFAULT_OPENCODE_DB, type DatasetCardInputs, type EmittedEvidence, FORMAT_FILES, FORMAT_GATE_DISPOSITION, type FormatGateCounts, type FromHarborOptions, GATE_CHECKS, GATE_CHECK_IDS, GATE_POLICIES, type GateCheck, type GateCheckDisposition, type GateCheckId, type GateCheckedOutcome, type GateDisposition, type GateEntryPoint, type GatePolicy, type GateReport, type GatedEvidence, HARBOR_IMPORT_GAP, type HarborAgent, type HarborContentPart, type HarborFinalMetrics, type HarborImageSource, type HarborMetrics, type HarborObservation, type HarborObservationResult, type HarborStep, type HarborStepSource, type HarborSubagentTrajectoryRef, type HarborToolCall, type HarborTrajectory, type MintRolloutOptions, type MintRolloutResult, type MintedRolloutLine, type MintedRolloutOutcome, RELEASE_FORMATS, ROLLOUT_CAPTURES, ROLLOUT_ROLES, ROLLOUT_SCHEMA, ROLLOUT_SPLITS, type ReadClaudeTranscriptOptions, type RealnessLabels, type ReleaseFormat, type ReleaseRowRef, type RewardRow, type RftItem, type RolloutArtifacts, type RolloutCapture, type RolloutCostBlock, type RolloutEvidenceAttempt, type RolloutLine, type RolloutOutcome, type RolloutPolicy, type RolloutProvenance, type RolloutReleaseCliArgs, type RolloutRole, type RolloutScrubber, type RolloutSearchLineage, type RolloutSplit, type RolloutStep, type RolloutTask, type RolloutWorkspaceCapture, type ScoreOrigin, type ScorePreference, type ScrubCounts, type ScrubReport, type ScrubRule, type SftExportOptions, type SftRow, type ToolDef, type VerifiersRolloutOutput, type VerifiersTokenUsage, addScrubCounts, appendRolloutLines, assertGateReport, assertMinted, assertMintedLines, assertRolloutLine, buildDatasetCard, buildHfDataset, claudeProjectSlug, defaultRolloutScrubber, emptyScrubCounts, findClaudeTranscripts, findOpencodeSessionsByDirectory, fromHarborTrajectory, gateErrors, gateGamedOutcome, gatedEvidenceOf, gatedRolloutIds, isRealnessGated, isRolloutLine, isTrainableSplit, measureFormatGate, mintRolloutRows, observedScore, observedSplitScore, parseClaudeTranscript, parseRolloutReleaseArgs, planPushCommand, readClaudeTranscript, readOpencodeSession, readOpencodeSessionMessages, readRolloutJournal, readRolloutLedger, relabelImportedSplit, releaseRowRefs, runRolloutReleaseCli, scoreOrigin, scrubLines, scrubRolloutLine, scrubText, toHarborTrajectories, toHarborTrajectory, toJsonl, toRewardRows, toRftItem, toRftItems, toSftRows, toVerifiersRolloutOutput, toVerifiersRolloutOutputs, trainingReward, trainingScore, transcriptFromSession, unmintableReasons, validateRolloutLine, writeRolloutLedger };
2
+ import { a as trainingReward, i as observedSplitScore, n as ScorePreference, o as trainingScore, r as isRealnessGated, t as ScoreOrigin } from "../reward-DrZ71vnf.js";
3
+ import { a as mintRolloutRows, i as RolloutSearchLineage, n as MintRolloutResult, o as unmintableReasons, r as RolloutScrubber, t as MintRolloutOptions } from "../mint-BRZXuwRi.js";
4
+ import { a as SftRow, c as VerifiersTokenUsage, d as toRftItems, f as toSftRows, i as SftExportOptions, l as toJsonl, n as RewardRow, p as toVerifiersRolloutOutputs, r as RftItem, s as VerifiersRolloutOutput, t as RealnessLabels, u as toRewardRows } from "../exporters-Dk3oEbK_.js";
5
+ import { $ as GateCheck, A as appendRolloutLines, B as HarborObservationResult, C as ClaudeTranscriptRef, D as findClaudeTranscripts, E as ReadClaudeTranscriptOptions, F as HarborContentPart, G as HarborTrajectory, H as HarborStepSource, I as HarborFinalMetrics, J as toHarborTrajectories, K as fromHarborTrajectory, L as HarborImageSource, M as writeRolloutLedger, N as FromHarborOptions, O as parseClaudeTranscript, P as HarborAgent, Q as GATE_POLICIES, R as HarborMetrics, S as ClaudeTranscript, T as DEFAULT_CLAUDE_PROJECTS_DIR, U as HarborSubagentTrajectoryRef, V as HarborStep, W as HarborToolCall, X as GATE_CHECKS, Y as toHarborTrajectory, Z as GATE_CHECK_IDS, _ as GateReport, a as buildHfDataset, at as gateErrors, b as DEFAULT_OPENCODE_DB, c as buildDatasetCard, d as defaultRolloutScrubber, et as GateCheckDisposition, f as scrubLines, g as GateDisposition, h as FormatGateCounts, i as ScrubReport, it as GatePolicy, j as readRolloutLedger, k as readClaudeTranscript, l as ScrubCounts, m as EmittedEvidence, n as BuildSummary, nt as GateCheckedOutcome, o as DatasetCardInputs, ot as gatedEvidenceOf, p as scrubText, q as relabelImportedSplit, r as RolloutReleaseCliArgs, rt as GateEntryPoint, s as ReleaseFormat, t as BuildOptions, tt as GateCheckId, u as ScrubRule, v as ReleaseRowRef, w as ClaudeUsageTotals, x as readOpencodeSessionMessages, y as assertGateReport, z as HarborObservation } from "../index-CiRwLv2R.js";
6
+ export { type BuildOptions, type BuildSummary, type ChatMessage, type ChatRole, type ChatToolCall, type ClaudeTranscript, type ClaudeTranscriptRef, type ClaudeUsageTotals, DEFAULT_CLAUDE_PROJECTS_DIR, DEFAULT_OPENCODE_DB, type DatasetCardInputs, type EmittedEvidence, type FormatGateCounts, type FromHarborOptions, GATE_CHECKS, GATE_CHECK_IDS, GATE_POLICIES, type GateCheck, type GateCheckDisposition, type GateCheckId, type GateCheckedOutcome, type GateDisposition, type GateEntryPoint, type GatePolicy, type GateReport, type GatedEvidence, type HarborAgent, type HarborContentPart, type HarborFinalMetrics, type HarborImageSource, type HarborMetrics, type HarborObservation, type HarborObservationResult, type HarborStep, type HarborStepSource, type HarborSubagentTrajectoryRef, type HarborToolCall, type HarborTrajectory, type MintRolloutOptions, type MintRolloutResult, type MintedRolloutLine, type MintedRolloutOutcome, ROLLOUT_CAPTURES, ROLLOUT_ROLES, ROLLOUT_SCHEMA, ROLLOUT_SPLITS, type ReadClaudeTranscriptOptions, type RealnessLabels, type ReleaseFormat, type ReleaseRowRef, type RewardRow, type RftItem, type RolloutArtifacts, type RolloutCapture, type RolloutCostBlock, type RolloutEvidenceAttempt, type RolloutLine, type RolloutOutcome, type RolloutPolicy, type RolloutProvenance, type RolloutReleaseCliArgs, type RolloutRole, type RolloutScrubber, type RolloutSearchLineage, type RolloutSplit, type RolloutStep, type RolloutTask, type RolloutWorkspaceCapture, type ScoreOrigin, type ScorePreference, type ScrubCounts, type ScrubReport, type ScrubRule, type SftExportOptions, type SftRow, type ToolDef, type VerifiersRolloutOutput, type VerifiersTokenUsage, appendRolloutLines, assertGateReport, assertMinted, assertMintedLines, assertRolloutLine, buildDatasetCard, buildHfDataset, defaultRolloutScrubber, findClaudeTranscripts, fromHarborTrajectory, gateErrors, gateGamedOutcome, gatedEvidenceOf, isRealnessGated, isRolloutLine, isTrainableSplit, mintRolloutRows, observedSplitScore, parseClaudeTranscript, readClaudeTranscript, readOpencodeSessionMessages, readRolloutLedger, relabelImportedSplit, scrubLines, scrubText, toHarborTrajectories, toHarborTrajectory, toJsonl, toRewardRows, toRftItems, toSftRows, toVerifiersRolloutOutputs, trainingReward, trainingScore, unmintableReasons, validateRolloutLine, writeRolloutLedger };
@@ -1,8 +1,7 @@
1
- import { a as scoreOrigin, n as observedScore, o as trainingReward, r as observedSplitScore, s as trainingScore, t as isRealnessGated } from "../reward-nw2xZGZG.js";
2
- import { _ as gatedEvidenceOf, a as assertMinted, c as assertRolloutLine, d as isTrainableSplit, f as validateRolloutLine, g as gateErrors, h as GATE_POLICIES, i as ROLLOUT_SPLITS, l as gateGamedOutcome, m as GATE_CHECK_IDS, n as ROLLOUT_ROLES, o as assertMintedLines, p as GATE_CHECKS, r as ROLLOUT_SCHEMA, t as ROLLOUT_CAPTURES, u as isRolloutLine } from "../schema-BuiujZ-g.js";
3
- import { a as toRftItem, c as toVerifiersRolloutOutput, i as toRewardRows, l as toVerifiersRolloutOutputs, o as toRftItems, r as toJsonl, s as toSftRows } from "../exporters-X4xwla8A.js";
4
- import { a as ATIF_SCHEMA_VERSION, c as relabelImportedSplit, i as readOpencodeSessionMessages, l as toHarborTrajectories, n as findOpencodeSessionsByDirectory, o as HARBOR_IMPORT_GAP, r as readOpencodeSession, s as fromHarborTrajectory, t as DEFAULT_OPENCODE_DB, u as toHarborTrajectory } from "../rollout-DZV1t2Wg.js";
5
- import { S as writeRolloutLedger, _ as measureFormatGate, a as addScrubCounts, b as readRolloutJournal, c as scrubLines, d as FORMAT_FILES, f as RELEASE_FORMATS, g as gatedRolloutIds, h as assertGateReport, i as runRolloutReleaseCli, l as scrubRolloutLine, m as FORMAT_GATE_DISPOSITION, n as parseRolloutReleaseArgs, o as defaultRolloutScrubber, p as buildDatasetCard, r as planPushCommand, s as emptyScrubCounts, t as buildHfDataset, u as scrubText, v as releaseRowRefs, x as readRolloutLedger, y as appendRolloutLines } from "../hf-dataset-BR2yhuNn.js";
6
- import { n as unmintableReasons, t as mintRolloutRows } from "../mint-QaD5cA0u.js";
7
- import { a as readClaudeTranscript, i as parseClaudeTranscript, n as claudeProjectSlug, o as transcriptFromSession, r as findClaudeTranscripts, t as DEFAULT_CLAUDE_PROJECTS_DIR } from "../claude-jsonl-dZir12m6.js";
8
- export { ATIF_SCHEMA_VERSION, DEFAULT_CLAUDE_PROJECTS_DIR, DEFAULT_OPENCODE_DB, FORMAT_FILES, FORMAT_GATE_DISPOSITION, GATE_CHECKS, GATE_CHECK_IDS, GATE_POLICIES, HARBOR_IMPORT_GAP, RELEASE_FORMATS, ROLLOUT_CAPTURES, ROLLOUT_ROLES, ROLLOUT_SCHEMA, ROLLOUT_SPLITS, addScrubCounts, appendRolloutLines, assertGateReport, assertMinted, assertMintedLines, assertRolloutLine, buildDatasetCard, buildHfDataset, claudeProjectSlug, defaultRolloutScrubber, emptyScrubCounts, findClaudeTranscripts, findOpencodeSessionsByDirectory, fromHarborTrajectory, gateErrors, gateGamedOutcome, gatedEvidenceOf, gatedRolloutIds, isRealnessGated, isRolloutLine, isTrainableSplit, measureFormatGate, mintRolloutRows, observedScore, observedSplitScore, parseClaudeTranscript, parseRolloutReleaseArgs, planPushCommand, readClaudeTranscript, readOpencodeSession, readOpencodeSessionMessages, readRolloutJournal, readRolloutLedger, relabelImportedSplit, releaseRowRefs, runRolloutReleaseCli, scoreOrigin, scrubLines, scrubRolloutLine, scrubText, toHarborTrajectories, toHarborTrajectory, toJsonl, toRewardRows, toRftItem, toRftItems, toSftRows, toVerifiersRolloutOutput, toVerifiersRolloutOutputs, trainingReward, trainingScore, transcriptFromSession, unmintableReasons, validateRolloutLine, writeRolloutLedger };
1
+ import { o as trainingReward, r as observedSplitScore, s as trainingScore, t as isRealnessGated } from "../reward-nw2xZGZG.js";
2
+ import { _ as gatedEvidenceOf, a as assertMinted, c as assertRolloutLine, d as isTrainableSplit, f as validateRolloutLine, g as gateErrors, h as GATE_POLICIES, i as ROLLOUT_SPLITS, l as gateGamedOutcome, m as GATE_CHECK_IDS, n as ROLLOUT_ROLES, o as assertMintedLines, p as GATE_CHECKS, r as ROLLOUT_SCHEMA, t as ROLLOUT_CAPTURES, u as isRolloutLine } from "../schema-DxcKTzbi.js";
3
+ import { a as toRftItems, i as toRewardRows, o as toSftRows, r as toJsonl, s as toVerifiersRolloutOutputs } from "../exporters-Cl6IeNAu.js";
4
+ import { a as parseClaudeTranscript, c as relabelImportedSplit, i as findClaudeTranscripts, l as toHarborTrajectories, n as readOpencodeSessionMessages, o as readClaudeTranscript, r as DEFAULT_CLAUDE_PROJECTS_DIR, s as fromHarborTrajectory, t as DEFAULT_OPENCODE_DB, u as toHarborTrajectory } from "../rollout-D6C50mfA.js";
5
+ import { a as scrubText, c as appendRolloutLines, i as scrubLines, l as readRolloutLedger, o as buildDatasetCard, r as defaultRolloutScrubber, s as assertGateReport, t as buildHfDataset, u as writeRolloutLedger } from "../hf-dataset-D9f7-oX7.js";
6
+ import { n as unmintableReasons, t as mintRolloutRows } from "../mint-zszyYlpA.js";
7
+ export { DEFAULT_CLAUDE_PROJECTS_DIR, DEFAULT_OPENCODE_DB, GATE_CHECKS, GATE_CHECK_IDS, GATE_POLICIES, ROLLOUT_CAPTURES, ROLLOUT_ROLES, ROLLOUT_SCHEMA, ROLLOUT_SPLITS, appendRolloutLines, assertGateReport, assertMinted, assertMintedLines, assertRolloutLine, buildDatasetCard, buildHfDataset, defaultRolloutScrubber, findClaudeTranscripts, fromHarborTrajectory, gateErrors, gateGamedOutcome, gatedEvidenceOf, isRealnessGated, isRolloutLine, isTrainableSplit, mintRolloutRows, observedSplitScore, parseClaudeTranscript, readClaudeTranscript, readOpencodeSessionMessages, readRolloutLedger, relabelImportedSplit, scrubLines, scrubText, toHarborTrajectories, toHarborTrajectory, toJsonl, toRewardRows, toRftItems, toSftRows, toVerifiersRolloutOutputs, trainingReward, trainingScore, unmintableReasons, validateRolloutLine, writeRolloutLedger };
@@ -1,11 +1,12 @@
1
- import { c as assertRolloutLine, i as ROLLOUT_SPLITS, n as ROLLOUT_ROLES, r as ROLLOUT_SCHEMA, t as ROLLOUT_CAPTURES } from "./schema-BuiujZ-g.js";
2
- import "./exporters-X4xwla8A.js";
3
- import "./hf-dataset-BR2yhuNn.js";
4
- import "./mint-QaD5cA0u.js";
5
- import "./claude-jsonl-dZir12m6.js";
1
+ import { n as isRecord } from "./json-BhdsJaOQ.js";
2
+ import { c as assertRolloutLine, i as ROLLOUT_SPLITS, n as ROLLOUT_ROLES, r as ROLLOUT_SCHEMA, t as ROLLOUT_CAPTURES } from "./schema-DxcKTzbi.js";
3
+ import "./exporters-Cl6IeNAu.js";
4
+ import "./hf-dataset-D9f7-oX7.js";
5
+ import "./mint-zszyYlpA.js";
6
6
  import { join } from "node:path";
7
7
  import { homedir } from "node:os";
8
- import { opencodeReader, opencodeSessionsInStore, toChatMessages } from "@tangle-network/harness-sessions";
8
+ import { readdir } from "node:fs/promises";
9
+ import { claudeCodeReader, claudeCodeRefForFile, opencodeReader, opencodeSessionsInStore, readSessionInput, toChatMessages } from "@tangle-network/harness-sessions";
9
10
  //#region src/rollout/interchange/harbor.ts
10
11
  /**
11
12
  * Harbor ATIF-v1.7 interchange — `tangle.rollout.v1` ⇄ Agent Trajectory
@@ -84,7 +85,6 @@ const ESCROW = "tangle";
84
85
  * document lying about who made the call.
85
86
  */
86
87
  const TOOL_RESULTS_ONLY = "tool-results-only";
87
- const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
88
88
  const asString = (v) => typeof v === "string" ? v : void 0;
89
89
  const asNumberOrNull = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
90
90
  const asIntegerOrUndefined = (v) => Number.isInteger(v) ? v : void 0;
@@ -622,6 +622,85 @@ function relabelImportedSplit(lines, split) {
622
622
  }));
623
623
  }
624
624
  //#endregion
625
+ //#region src/rollout/readers/claude-jsonl.ts
626
+ /**
627
+ * Claude Code project transcripts (~/.claude/projects/<cwd-slug>/<sessionId>.jsonl) as canonical
628
+ * chat-with-tools messages plus per-session token usage.
629
+ *
630
+ * The transcript is read by @tangle-network/harness-sessions, the one reader of harness sessions
631
+ * shared with Discovery, agent-record, traces and the blog: one model call per API response
632
+ * (`message.id`, its usage counted once), the served model from the response, tool calls with
633
+ * their results. This module only projects that session. Sidechain lines (subagent threads in the
634
+ * main file) are separate invocations and are excluded unless `includeSidechain` asks for a
635
+ * subagent's own transcript.
636
+ */
637
+ const DEFAULT_CLAUDE_PROJECTS_DIR = join(homedir(), ".claude", "projects");
638
+ /** Claude Code's project-directory slug for a working directory. */
639
+ function claudeProjectSlug(cwd) {
640
+ return cwd.replace(/[^a-zA-Z0-9-]/g, "-");
641
+ }
642
+ /** Transcript files recorded for sessions launched from `cwd`. */
643
+ async function findClaudeTranscripts(cwd, projectsDir = DEFAULT_CLAUDE_PROJECTS_DIR) {
644
+ const dir = join(projectsDir, claudeProjectSlug(cwd));
645
+ return (await readdir(dir).catch(() => [])).filter((n) => n.endsWith(".jsonl")).sort().map((n) => ({
646
+ sessionId: n.replace(/\.jsonl$/, ""),
647
+ path: join(dir, n)
648
+ }));
649
+ }
650
+ const USAGE_FIELDS = [
651
+ ["tokensIn", "input"],
652
+ ["tokensOut", "output"],
653
+ ["cacheRead", "cacheRead"],
654
+ ["cacheWrite", "cacheWrite"]
655
+ ];
656
+ /**
657
+ * The messages+usage projection of a normalized session. A usage field is null when any answered
658
+ * model call did not report it, so a partial sum is never mistaken for the session's usage.
659
+ */
660
+ function transcriptFromSession(session) {
661
+ const gaps = session.integrity.gaps.filter((gap) => /is not a JSON record|still being written/u.test(gap));
662
+ const answered = session.modelCalls.filter((call) => call.error === null);
663
+ const usage = {
664
+ tokensIn: null,
665
+ tokensOut: null,
666
+ cacheRead: null,
667
+ cacheWrite: null
668
+ };
669
+ if (answered.length > 0) for (const [target, field] of USAGE_FIELDS) {
670
+ let total = 0;
671
+ for (const call of answered) {
672
+ const value = call.usage?.[field] ?? null;
673
+ if (value === null) {
674
+ total = null;
675
+ gaps.push(`model call ${call.id}: ${field} usage unavailable`);
676
+ break;
677
+ }
678
+ total += value;
679
+ }
680
+ usage[target] = total;
681
+ }
682
+ const model = [...answered].reverse().find((call) => call.servedModel !== null)?.servedModel ?? null;
683
+ return {
684
+ messages: toChatMessages(session),
685
+ usage,
686
+ startedAt: session.startedAt,
687
+ endedAt: session.endedAt,
688
+ model,
689
+ gaps
690
+ };
691
+ }
692
+ /** Read one transcript file. */
693
+ async function readClaudeTranscript(path, options = {}) {
694
+ return transcriptFromSession(await claudeCodeReader.read(claudeCodeRefForFile(path, options.includeSidechain === true ? "parent" : null)));
695
+ }
696
+ /** Parse retained JSONL text without another file or store; source gaps remain explicit. */
697
+ function parseClaudeTranscript(raw, options = {}) {
698
+ return transcriptFromSession(readSessionInput("claude-code", { text: raw }, {
699
+ parentNativeSessionId: options.includeSidechain === true ? "parent" : null,
700
+ label: "retained transcript"
701
+ }));
702
+ }
703
+ //#endregion
625
704
  //#region src/rollout/readers/opencode-sqlite.ts
626
705
  /**
627
706
  * OpenCode's SQLite store (~/.local/share/opencode/opencode.db) as canonical chat-with-tools
@@ -631,10 +710,6 @@ function relabelImportedSplit(lines, split) {
631
710
  * refused.
632
711
  */
633
712
  const DEFAULT_OPENCODE_DB = join(homedir(), ".local", "share", "opencode", "opencode.db");
634
- /** Sessions whose cwd is `directory` (the worker-clone join key), oldest first. */
635
- async function findOpencodeSessionsByDirectory(directory, db = DEFAULT_OPENCODE_DB) {
636
- return (await opencodeSessionsInStore(db, null, { cwd: directory })).filter((ref) => ref.cwd === directory).reverse();
637
- }
638
713
  /** One session, normalized. */
639
714
  async function readOpencodeSession(sessionId, db = DEFAULT_OPENCODE_DB) {
640
715
  const [ref] = await opencodeSessionsInStore(db, null, { nativeSessionId: sessionId });
@@ -646,6 +721,6 @@ async function readOpencodeSessionMessages(sessionId, db = DEFAULT_OPENCODE_DB)
646
721
  return toChatMessages(await readOpencodeSession(sessionId, db));
647
722
  }
648
723
  //#endregion
649
- export { ATIF_SCHEMA_VERSION as a, relabelImportedSplit as c, readOpencodeSessionMessages as i, toHarborTrajectories as l, findOpencodeSessionsByDirectory as n, HARBOR_IMPORT_GAP as o, readOpencodeSession as r, fromHarborTrajectory as s, DEFAULT_OPENCODE_DB as t, toHarborTrajectory as u };
724
+ export { parseClaudeTranscript as a, relabelImportedSplit as c, findClaudeTranscripts as i, toHarborTrajectories as l, readOpencodeSessionMessages as n, readClaudeTranscript as o, DEFAULT_CLAUDE_PROJECTS_DIR as r, fromHarborTrajectory as s, DEFAULT_OPENCODE_DB as t, toHarborTrajectory as u };
650
725
 
651
- //# sourceMappingURL=rollout-DZV1t2Wg.js.map
726
+ //# sourceMappingURL=rollout-D6C50mfA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollout-D6C50mfA.js","names":[],"sources":["../src/rollout/interchange/harbor.ts","../src/rollout/readers/claude-jsonl.ts","../src/rollout/readers/opencode-sqlite.ts"],"sourcesContent":["/**\n * Harbor ATIF-v1.7 interchange — `tangle.rollout.v1` ⇄ Agent Trajectory\n * Interchange Format.\n *\n * ATIF is the portability format (spec:\n * https://www.harborframework.com/docs/agents/trajectory-format, normative\n * RFC: harbor-framework/harbor `rfcs/0001-trajectory-format.md`). It sits\n * BELOW the waist of the rollout hourglass in both directions — export reads\n * `RolloutLine[]`, import writes `RolloutLine[]` — and it is never a source\n * of training labels:\n *\n * ATIF models NO reward, NO judge verdict, NO task/split coordinates.\n *\n * Consequences, both deliberate:\n * - EXPORT drops `outcome.reward`, `outcome.reward_source` and\n * `outcome.verdict` entirely. They are not smuggled into `extra`: a\n * third-party reading our ATIF file must not be able to mistake an\n * agent-eval judge score for something ATIF sanctioned.\n * - IMPORT therefore mints UNLABELED lines: `reward: null` (the existing\n * \"null reward is a labeled gap, never 0\" semantics), `verdict: null`,\n * and a `provenance.gap` naming the missing label. An imported\n * trajectory is not a training example until a judge scores it.\n *\n * Everything else we own that ATIF has no field for travels in a namespaced\n * escrow at `extra.tangle.*`, so our own round-trip is exact while a foreign\n * reader can ignore it. Fields that neither ATIF nor the escrow can carry\n * come back explicitly null / fail-closed, never invented.\n *\n * THE ESCROW IS NAMESPACED, NOT AUTHENTICATED. Anyone can write\n * `extra.tangle.*` into a file. So the escrow may restore what a value IS, but\n * never what a line is ALLOWED to do: `task.split` is forced to `holdout` on\n * every import regardless of what the document claims, and promoting an\n * imported trajectory to a trainable split is an explicit, greppable act\n * (`relabelImportedSplit`) rather than a property of the file. The document\n * keeps its claim — the claim just is not authority.\n *\n * Multi-agent shape differs on purpose. ATIF EMBEDS children in\n * `subagent_trajectories`; we keep a flat ledger with a normalized\n * `parent_rollout_id` edge. Export assembles the tree, import flattens it.\n * `session_id` is RUN-scoped in ATIF, so it carries `run_id` — the coordinate\n * that is shared by every invocation of one run — not `rollout_id`, which\n * identifies a single invocation and would split one run across session ids.\n *\n * ROUND-TRIPPING IS IDEMPOTENT: `import(export(import(export(x))))` is\n * byte-identical to `import(export(x))`. Import composes `provenance.gap` as a\n * de-duplicated ordered set rather than appending, and it emits every\n * `ChatMessage` with keys in the canonical schema order (role, content,\n * reasoning_content, tool_calls, tool_call_id, name, is_copied_context), so a\n * ledger hashed on serialized bytes sees no diff across further passes. The\n * FIRST import may re-order a producer's keys — that is the canonicalization.\n *\n * NOT building a Letta converter. Letta's trajectory-v1 is a strict subset of\n * what we need from ATIF here — no per-step or aggregate cost, no\n * multi-agent/subagent structure, no token-id or logprob channel — so a Letta\n * sink would carry less than this one and add a second format to keep\n * correct. Decision recorded in docs/rollout.md; do not re-litigate without a\n * concrete consumer that reads Letta and cannot read ATIF.\n */\n\nimport {\n assertRolloutLine,\n type ChatMessage,\n type ChatRole,\n type ChatToolCall,\n type GatedEvidence,\n ROLLOUT_CAPTURES,\n ROLLOUT_ROLES,\n ROLLOUT_SCHEMA,\n ROLLOUT_SPLITS,\n type RolloutArtifacts,\n type RolloutCapture,\n type RolloutCostBlock,\n type RolloutLine,\n type RolloutPolicy,\n type RolloutRole,\n type RolloutSplit,\n type RolloutStep,\n type RolloutTask,\n type ToolDef,\n} from '../schema'\n\nimport { isRecord } from '../../llm-client/json'\nconst ATIF_SCHEMA_VERSION = 'ATIF-v1.7'\n\n/** Gap note on every imported line — ATIF carries no verdict, so nothing is scored. */\nconst HARBOR_IMPORT_GAP = 'imported from Harbor ATIF; no verdict'\n\n/** Namespaced escrow key for everything ATIF does not model but we must not lose. */\nconst ESCROW = 'tangle'\n\n/**\n * Marks a step we synthesized purely to hold tool results that answered no\n * assistant turn IN THIS DOCUMENT. ATIF has no `tool` source, so such results\n * need a carrier step; the marker lets import drop the carrier instead of\n * inventing a turn.\n *\n * A carrier's results carry NO `source_call_id`. RFC 0001 rule 2 requires every\n * `source_call_id` to match a `tool_call_id` in the same step's `tool_calls`,\n * and a carrier declares no calls (a `system` step cannot legally make one), so\n * emitting the id there would produce an invalid document. The id is escrowed\n * instead and restored verbatim on import — the link survives without the\n * document lying about who made the call.\n */\nconst TOOL_RESULTS_ONLY = 'tool-results-only'\n\n// ---------------------------------------------------------------------------\n// ATIF-v1.7 wire types (RFC 0001). Optional fields are optional here too.\n// ---------------------------------------------------------------------------\n\nexport type HarborStepSource = 'system' | 'user' | 'agent'\n\nexport interface HarborImageSource {\n media_type: string\n path: string\n}\n\nexport interface HarborContentPart {\n type: 'text' | 'image'\n text?: string\n source?: HarborImageSource\n}\n\nexport interface HarborToolCall {\n tool_call_id: string\n function_name: string\n /** ATIF requires a decoded JSON object here, unlike our raw argument string. */\n arguments: Record<string, unknown>\n extra?: Record<string, unknown>\n}\n\nexport interface HarborSubagentTrajectoryRef {\n trajectory_id?: string\n trajectory_path?: string\n /** Informational only since v1.7 — never a resolution key. */\n session_id?: string\n extra?: Record<string, unknown>\n}\n\nexport interface HarborObservationResult {\n source_call_id?: string\n content?: string | HarborContentPart[]\n subagent_trajectory_ref?: HarborSubagentTrajectoryRef[]\n extra?: Record<string, unknown>\n}\n\nexport interface HarborObservation {\n results: HarborObservationResult[]\n}\n\nexport interface HarborMetrics {\n prompt_tokens?: number\n completion_tokens?: number\n cached_tokens?: number\n cost_usd?: number\n prompt_token_ids?: number[]\n completion_token_ids?: number[]\n logprobs?: number[]\n extra?: Record<string, unknown>\n}\n\nexport interface HarborStep {\n /** Ordinal, sequential from 1. */\n step_id: number\n timestamp?: string\n source: HarborStepSource\n model_name?: string\n reasoning_effort?: string | number\n message: string | HarborContentPart[]\n reasoning_content?: string\n tool_calls?: HarborToolCall[]\n observation?: HarborObservation\n metrics?: HarborMetrics\n llm_call_count?: number\n is_copied_context?: boolean\n extra?: Record<string, unknown>\n}\n\nexport interface HarborAgent {\n name: string\n version: string\n model_name?: string\n /** OpenAI function-calling schema — byte-identical to our `ToolDef`. */\n tool_definitions?: ToolDef[]\n extra?: Record<string, unknown>\n}\n\nexport interface HarborFinalMetrics {\n total_prompt_tokens?: number\n total_completion_tokens?: number\n total_cached_tokens?: number\n total_cost_usd?: number\n total_steps?: number\n extra?: Record<string, unknown>\n}\n\nexport interface HarborTrajectory {\n schema_version: string\n session_id?: string\n /** Required on embedded subagents; we always set it so lines stay joinable. */\n trajectory_id?: string\n agent: HarborAgent\n steps: HarborStep[]\n notes?: string\n final_metrics?: HarborFinalMetrics\n continued_trajectory_ref?: string\n subagent_trajectories?: HarborTrajectory[]\n extra?: Record<string, unknown>\n}\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\nconst asString = (v: unknown): string | undefined => (typeof v === 'string' ? v : undefined)\n\nconst asNumberOrNull = (v: unknown): number | null =>\n typeof v === 'number' && Number.isFinite(v) ? v : null\n\nconst asIntegerOrUndefined = (v: unknown): number | undefined =>\n Number.isInteger(v) ? (v as number) : undefined\n\nconst asNumberArray = (v: unknown): number[] | undefined =>\n Array.isArray(v) && v.every((n) => typeof n === 'number' && Number.isFinite(n))\n ? (v as number[])\n : undefined\n\nconst asIntegerArray = (v: unknown): number[] | undefined =>\n Array.isArray(v) && v.every((n) => Number.isInteger(n)) ? (v as number[]) : undefined\n\n/**\n * Builds a `ChatMessage` with keys in the schema's declaration order.\n *\n * Object key order is insertion order in JS, so a message assembled\n * conditionally field-by-field serializes differently depending on which\n * optional fields were present — which makes a byte-hashed ledger see a diff\n * across an import that changed nothing. One builder, one order, stable bytes.\n */\nfunction canonicalChatMessage(parts: {\n role: ChatRole\n content: string | null\n reasoning_content?: string\n tool_calls?: ChatToolCall[]\n tool_call_id?: string\n name?: string\n is_copied_context?: boolean\n}): ChatMessage {\n const message: ChatMessage = { role: parts.role, content: parts.content }\n if (parts.reasoning_content !== undefined) message.reasoning_content = parts.reasoning_content\n if (parts.tool_calls !== undefined) message.tool_calls = parts.tool_calls\n if (parts.tool_call_id !== undefined) message.tool_call_id = parts.tool_call_id\n if (parts.name !== undefined) message.name = parts.name\n if (parts.is_copied_context === true) message.is_copied_context = true\n return message\n}\n\n/** Reads the `extra.tangle` escrow, tolerating a foreign file that has none. */\nfunction escrowOf(extra: Record<string, unknown> | undefined): Record<string, unknown> | undefined {\n if (!isRecord(extra)) return undefined\n const value = extra[ESCROW]\n return isRecord(value) ? value : undefined\n}\n\nfunction escrowSection(\n escrow: Record<string, unknown> | undefined,\n key: string,\n): Record<string, unknown> | undefined {\n if (escrow === undefined) return undefined\n const value = escrow[key]\n return isRecord(value) ? value : undefined\n}\n\n// ---------------------------------------------------------------------------\n// Export: RolloutLine[] → ATIF trajectory tree\n// ---------------------------------------------------------------------------\n\nfunction toHarborToolCall(call: ChatToolCall): HarborToolCall {\n // ATIF requires `arguments` to be a JSON object; ours is the raw\n // JSON-encoded string the model emitted, and models really do emit\n // malformed ones. Keep the exact bytes in `extra` so import restores the\n // string verbatim instead of re-serializing a normalized parse.\n let parsed: Record<string, unknown> | undefined\n try {\n const decoded: unknown = JSON.parse(call.function.arguments)\n if (isRecord(decoded)) parsed = decoded\n } catch {\n parsed = undefined\n }\n return {\n tool_call_id: call.id,\n function_name: call.function.name,\n arguments: parsed ?? {},\n extra: { [ESCROW]: { arguments_raw: call.function.arguments } },\n }\n}\n\n/**\n * `linked` = this result is attached to the step that actually declared the\n * call, so `source_call_id` is legal (RFC 0001 rule 2). When it is not, the id\n * goes to escrow instead of onto the wire.\n */\nfunction toObservationResult(message: ChatMessage, linked: boolean): HarborObservationResult {\n const result: HarborObservationResult = {}\n if (linked && message.tool_call_id !== undefined) result.source_call_id = message.tool_call_id\n if (message.content !== null) result.content = message.content\n const escrow: Record<string, unknown> = {}\n if (!linked && message.tool_call_id !== undefined) escrow.source_call_id = message.tool_call_id\n if (message.name !== undefined) escrow.name = message.name\n // `content: null` on a tool turn is meaningful (a tool that returned\n // nothing) and is not the same as the empty string ATIF would round-trip it to.\n if (message.content === null) escrow.content_null = true\n if (message.reasoning_content !== undefined) escrow.reasoning_content = message.reasoning_content\n if (message.is_copied_context === true) escrow.is_copied_context = true\n if (Object.keys(escrow).length > 0) result.extra = { [ESCROW]: escrow }\n return result\n}\n\n/** True when `step` is the agent turn that declared `callId` — the rule-2 test. */\nfunction declaresCall(step: HarborStep, callId: string | undefined): boolean {\n if (callId === undefined) return false\n return step.tool_calls?.some((call) => call.tool_call_id === callId) === true\n}\n\n/**\n * Attaches the four RL fields lifted from ATIF onto the agent step the span\n * describes. They are ALSO escrowed with the whole span under `extra.tangle`,\n * on purpose: the escrow is how our own round-trip stays exact, and these\n * native fields are how a foreign consumer — which never reads our escrow —\n * gets the logprobs and token ids at all. A field carried only in the escrow is\n * not an interchange field.\n */\nfunction applySpanMetrics(step: HarborStep, span: RolloutStep | undefined): void {\n if (span === undefined) return\n if (span.llm_call_count !== undefined) step.llm_call_count = span.llm_call_count\n const metrics: HarborMetrics = {}\n if (span.prompt_token_ids !== undefined) metrics.prompt_token_ids = span.prompt_token_ids\n if (span.completion_token_ids !== undefined) {\n metrics.completion_token_ids = span.completion_token_ids\n }\n if (span.logprobs !== undefined) metrics.logprobs = span.logprobs\n if (Object.keys(metrics).length > 0) step.metrics = metrics\n}\n\n/**\n * Coalescing fold, not a 1:1 map: ATIF has no `tool` source, so a tool result\n * becomes an `observation.results[]` entry on the agent step THAT DECLARED ITS\n * `tool_call_id`.\n *\n * Linking by id, not by adjacency. Adjacency emitted invalid documents in three\n * shapes the RFC forbids — an assistant turn with no `tool_calls` swallowing the\n * results that followed it, a result whose id matched none of the preceding\n * step's calls, and an unanswered result riding a `system` step that carried a\n * `source_call_id` it could never declare. Attaching only to the step that owns\n * the id also preserves message order exactly: a result either joins the step\n * immediately before it or becomes its own carrier at its own position.\n *\n * `line.steps` span projections are matched to agent steps in order (k-th llm\n * span → k-th agent step) purely to fill ATIF's native per-step `metrics`;\n * extra spans on either side are simply not matched, never invented.\n */\nfunction messagesToSteps(line: RolloutLine): HarborStep[] {\n const steps: HarborStep[] = []\n const llmSpans = (line.steps ?? []).filter((span) => span.kind === 'llm')\n let nextSpan = 0\n for (const message of line.messages) {\n if (message.role === 'tool') {\n const previous = steps[steps.length - 1]\n if (previous !== undefined && declaresCall(previous, message.tool_call_id)) {\n if (previous.observation === undefined) previous.observation = { results: [] }\n previous.observation.results.push(toObservationResult(message, true))\n continue\n }\n // A tool result answering no assistant turn in this document (truncated or\n // reconstructed transcript). It still has to survive, so it rides a marked\n // carrier step whose observation states no call id.\n const carrier: HarborStep = {\n step_id: steps.length + 1,\n source: 'system',\n message: '',\n observation: { results: [toObservationResult(message, false)] },\n extra: { [ESCROW]: { synthetic: TOOL_RESULTS_ONLY } },\n }\n if (message.is_copied_context === true) carrier.is_copied_context = true\n steps.push(carrier)\n continue\n }\n const step: HarborStep = {\n step_id: steps.length + 1,\n source: message.role === 'assistant' ? 'agent' : message.role,\n message: message.content ?? '',\n }\n const escrow: Record<string, unknown> = {}\n if (message.content === null) escrow.content_null = true\n if (message.name !== undefined) escrow.name = message.name\n if (message.role === 'assistant') {\n if (line.policy.model !== null) step.model_name = line.policy.model\n if (message.reasoning_content !== undefined) {\n step.reasoning_content = message.reasoning_content\n }\n if (message.tool_calls !== undefined && message.tool_calls.length > 0) {\n step.tool_calls = message.tool_calls.map(toHarborToolCall)\n }\n applySpanMetrics(step, llmSpans[nextSpan])\n nextSpan += 1\n } else if (message.reasoning_content !== undefined) {\n // ATIF confines `reasoning_content` to agent steps; ours is not confined.\n escrow.reasoning_content = message.reasoning_content\n }\n // RFC 0001 rule 7: a copied-context turn was not authored by this agent, and\n // an SFT pipeline MUST exclude it. Native ATIF field, both directions.\n if (message.is_copied_context === true) step.is_copied_context = true\n if (Object.keys(escrow).length > 0) step.extra = { [ESCROW]: escrow }\n steps.push(step)\n }\n return steps\n}\n\nfunction finalMetricsOf(line: RolloutLine, stepCount: number): HarborFinalMetrics {\n const metrics: HarborFinalMetrics = {}\n if (line.cost.tokens_in !== null) metrics.total_prompt_tokens = line.cost.tokens_in\n if (line.cost.tokens_out !== null) metrics.total_completion_tokens = line.cost.tokens_out\n if (line.cost.cache_read !== null) metrics.total_cached_tokens = line.cost.cache_read\n // Omitted, never 0, when cost was not captured — a fake 0 is a lie about spend.\n if (line.cost.usd !== null) metrics.total_cost_usd = line.cost.usd\n metrics.total_steps = stepCount\n // ATIF has no aggregate field for these three; `reasoning_tokens` under\n // `extra` is the key the RFC's own worked example uses.\n const extra: Record<string, unknown> = {}\n if (line.cost.tokens_reasoning !== null) extra.reasoning_tokens = line.cost.tokens_reasoning\n if (line.cost.cache_write !== null) extra.cache_write_tokens = line.cost.cache_write\n if (line.cost.wall_s !== null) extra.wall_s = line.cost.wall_s\n if (line.cost.llm_call_count !== undefined && line.cost.llm_call_count !== null) {\n extra.llm_call_count = line.cost.llm_call_count\n }\n if (Object.keys(extra).length > 0) metrics.extra = extra\n return metrics\n}\n\nfunction notesOf(line: RolloutLine): string | undefined {\n const parts: string[] = []\n if (line.provenance.gap !== undefined) parts.push(line.provenance.gap)\n if (line.outcome.realness_gated === true) {\n // ATIF has no gate field. A third-party consumer that ignores `extra`\n // would otherwise see a gamed trajectory with nothing marking it, so the\n // flag is stated in prose as well. This export carries no reward at all,\n // so it is not a training-data door — but it is an audit record.\n parts.push('realness-gated: this run faked its success signal (anti-Goodhart gate fired)')\n }\n return parts.length > 0 ? parts.join(' | ') : undefined\n}\n\nfunction toTrajectoryNode(line: RolloutLine): HarborTrajectory {\n const steps = messagesToSteps(line)\n const trajectory: HarborTrajectory = {\n schema_version: ATIF_SCHEMA_VERSION,\n // RUN-scoped, per the spec — so it is `run_id`, the coordinate every\n // invocation of one run shares. `rollout_id` identifies a single\n // invocation: using it gave two roots of the same run different session\n // ids, and foreign tooling that groups by session_id would split the run.\n session_id: line.run_id,\n trajectory_id: line.rollout_id,\n agent: {\n // ATIF requires both; ours are nullable, so a null is substituted here\n // and restored on import from the escrowed policy — never guessed back.\n name: line.policy.harness ?? 'unknown',\n version: line.policy.harness_version ?? '0.0.0',\n ...(line.policy.model !== null ? { model_name: line.policy.model } : {}),\n ...(line.tool_defs.length > 0 ? { tool_definitions: line.tool_defs } : {}),\n },\n steps,\n final_metrics: finalMetricsOf(line, steps.length),\n extra: {\n [ESCROW]: {\n schema: line.schema,\n rollout_id: line.rollout_id,\n parent_rollout_id: line.parent_rollout_id,\n run_id: line.run_id,\n ...(line.experiment_id !== undefined ? { experiment_id: line.experiment_id } : {}),\n ...(line.candidate_id !== undefined ? { candidate_id: line.candidate_id } : {}),\n generation: line.generation,\n candidate_index: line.candidate_index,\n role: line.role,\n task: line.task,\n policy: line.policy,\n // Span projections overlap the same turns as `steps[]`; folding them\n // into ATIF steps would double-count the run, so they stay escrowed.\n ...(line.steps !== undefined ? { spans: line.steps } : {}),\n outcome: {\n // reward / reward_source / verdict are deliberately absent — see the\n // module header. Only the non-scalar outcome fields travel.\n metrics: line.outcome.metrics,\n is_completed: line.outcome.is_completed,\n is_truncated: line.outcome.is_truncated,\n error: line.outcome.error,\n ...(line.outcome.realness_gated !== undefined\n ? { realness_gated: line.outcome.realness_gated }\n : {}),\n },\n artifacts: line.artifacts,\n provenance: line.provenance,\n },\n },\n }\n const notes = notesOf(line)\n if (notes !== undefined) trajectory.notes = notes\n return trajectory\n}\n\ninterface Forest {\n roots: RolloutLine[]\n childrenOf: Map<string, RolloutLine[]>\n}\n\nfunction buildForest(lines: RolloutLine[]): Forest {\n const byId = new Map<string, RolloutLine>()\n for (const line of lines) {\n if (byId.has(line.rollout_id)) {\n throw new Error(`duplicate rollout_id in input: ${line.rollout_id}`)\n }\n byId.set(line.rollout_id, line)\n }\n const roots: RolloutLine[] = []\n const childrenOf = new Map<string, RolloutLine[]>()\n for (const line of lines) {\n const parent = line.parent_rollout_id\n // A parent outside this set is a root OF WHAT WE HAVE: the edge is kept in\n // escrow so a later import restores the dangling pointer instead of nulling it.\n if (parent === null || !byId.has(parent)) {\n roots.push(line)\n continue\n }\n const siblings = childrenOf.get(parent)\n if (siblings === undefined) childrenOf.set(parent, [line])\n else siblings.push(line)\n }\n // Every line has a parent inside the set: the edges form a cycle with no\n // root. Returning zero documents would drop the whole episode silently.\n if (lines.length > 0 && roots.length === 0) {\n throw new Error(\n `parent_rollout_id cycle: no root among ${lines.length} lines (${lines.map((l) => l.rollout_id).join(', ')})`,\n )\n }\n return { roots, childrenOf }\n}\n\nfunction assemble(line: RolloutLine, forest: Forest, onPath: Set<string>): HarborTrajectory {\n if (onPath.has(line.rollout_id)) {\n throw new Error(`parent_rollout_id cycle through rollout_id ${line.rollout_id}`)\n }\n onPath.add(line.rollout_id)\n const node = toTrajectoryNode(line)\n const children = forest.childrenOf.get(line.rollout_id)\n if (children !== undefined && children.length > 0) {\n node.subagent_trajectories = children.map((child) => assemble(child, forest, onPath))\n }\n onPath.delete(line.rollout_id)\n return node\n}\n\n/**\n * Assemble one episode's flat lines into a single ATIF trajectory tree,\n * linked by `parent_rollout_id`.\n *\n * Reward, verdict and split are NOT emitted (ATIF models none of them); the\n * split and the rest of the task coordinates survive only in `extra.tangle`.\n *\n * We deliberately do NOT synthesize an `observation.subagent_trajectory_ref`\n * pointing at each child: our ledger records WHICH invocation spawned a\n * worker, not which STEP did, and attaching the ref to a guessed step would\n * fabricate a causal claim. Children are embedded in `subagent_trajectories`\n * (each with the `trajectory_id` the spec requires) and the edge is stated in\n * the child's escrowed `parent_rollout_id`.\n *\n * Throws when the lines are not one tree — use `toHarborTrajectories` for a forest.\n */\nexport function toHarborTrajectory(lines: RolloutLine[]): HarborTrajectory {\n const trees = toHarborTrajectories(lines)\n if (trees.length === 0) throw new Error('toHarborTrajectory: no lines')\n if (trees.length > 1) {\n const ids = trees.map((t) => t.trajectory_id ?? '?').join(', ')\n throw new Error(\n `toHarborTrajectory: ${trees.length} roots (${ids}) — ATIF is one tree per document; use toHarborTrajectories`,\n )\n }\n return trees[0]!\n}\n\n/** Every independent tree in the input, one ATIF document each. */\nexport function toHarborTrajectories(lines: RolloutLine[]): HarborTrajectory[] {\n const forest = buildForest(lines)\n return forest.roots.map((root) => assemble(root, forest, new Set()))\n}\n\n// ---------------------------------------------------------------------------\n// Import: ATIF trajectory tree → RolloutLine[]\n// ---------------------------------------------------------------------------\n\nfunction contentToString(message: string | HarborContentPart[]): string {\n if (typeof message === 'string') return message\n return message\n .map((part) =>\n part.type === 'image'\n ? // Our chat content is text-only. Describing the image is honest about\n // what the source held; dropping it silently would not be.\n `[image ${part.source?.media_type ?? 'unknown'} ${part.source?.path ?? ''}]`.trim()\n : (part.text ?? ''),\n )\n .join('\\n')\n}\n\nfunction fromHarborToolCall(call: HarborToolCall): ChatToolCall {\n const raw = asString(escrowOf(call.extra)?.arguments_raw)\n return {\n id: call.tool_call_id,\n type: 'function',\n function: { name: call.function_name, arguments: raw ?? JSON.stringify(call.arguments ?? {}) },\n }\n}\n\nfunction fromObservationResult(\n result: HarborObservationResult,\n callId: string | undefined,\n): ChatMessage {\n const escrow = escrowOf(result.extra)\n return canonicalChatMessage({\n role: 'tool',\n content:\n escrow?.content_null === true\n ? null\n : result.content === undefined\n ? ''\n : contentToString(result.content),\n reasoning_content: asString(escrow?.reasoning_content),\n tool_call_id: callId,\n name: asString(escrow?.name),\n is_copied_context: escrow?.is_copied_context === true,\n })\n}\n\nfunction stepsToMessages(steps: HarborStep[]): ChatMessage[] {\n const messages: ChatMessage[] = []\n for (const step of steps) {\n const escrow = escrowOf(step.extra)\n const carrierOnly = escrow?.synthetic === TOOL_RESULTS_ONLY\n if (!carrierOnly) {\n messages.push(\n canonicalChatMessage({\n role: step.source === 'agent' ? 'assistant' : step.source,\n content: escrow?.content_null === true ? null : contentToString(step.message),\n reasoning_content: step.reasoning_content ?? asString(escrow?.reasoning_content),\n tool_calls:\n step.tool_calls !== undefined && step.tool_calls.length > 0\n ? step.tool_calls.map(fromHarborToolCall)\n : undefined,\n name: asString(escrow?.name),\n is_copied_context: step.is_copied_context === true,\n }),\n )\n }\n for (const result of step.observation?.results ?? []) {\n const resultEscrow = escrowOf(result.extra)\n const callId = result.source_call_id ?? asString(resultEscrow?.source_call_id)\n if (carrierOnly) {\n // Our own carrier: every result on it was a tool turn, and its call id\n // (if the transcript had one) is in escrow, not on the wire.\n messages.push(fromObservationResult(result, callId))\n continue\n }\n if (typeof callId === 'string') {\n messages.push(fromObservationResult(result, callId))\n continue\n }\n // ATIF allows a result from a non-tool-calling action. Our chat schema\n // requires `tool_call_id` on a tool turn, so inventing one would forge a\n // link; the text is preserved as a system observation instead.\n if (result.content !== undefined) {\n messages.push(\n canonicalChatMessage({ role: 'system', content: contentToString(result.content) }),\n )\n }\n }\n }\n return messages\n}\n\nfunction taskFrom(escrow: Record<string, unknown> | undefined, fallbackId: string): RolloutTask {\n const task = escrowSection(escrow, 'task')\n return {\n suite: asString(task?.suite) ?? 'harbor-atif-import',\n instance_id: asString(task?.instance_id) ?? fallbackId,\n // ALWAYS holdout — the escrowed claim is read for nothing here.\n //\n // `extra.tangle.task.split` is a namespaced key, not an authenticated one:\n // a hand-written or third-party document can set `split: 'search'` as\n // easily as our own exporter can, and honouring it made \"this file says so\"\n // sufficient to walk into a training export. Trainability is a decision\n // about a file, so it is made by an operator through\n // `relabelImportedSplit`, never by the file about itself. The claim is not\n // destroyed — it stays readable in the source document.\n split: 'holdout',\n seed: asNumberOrNull(task?.seed),\n rep: asIntegerOrUndefined(task?.rep) ?? 0,\n }\n}\n\nfunction policyFrom(\n escrow: Record<string, unknown> | undefined,\n agent: HarborAgent,\n): RolloutPolicy {\n const escrowed = escrowSection(escrow, 'policy')\n if (escrowed !== undefined) {\n // Our own export: restore verbatim, including the nulls ATIF forced us to\n // substitute placeholders for in `agent.name` / `agent.version`.\n return {\n harness: asString(escrowed.harness) ?? null,\n harness_version: asString(escrowed.harness_version) ?? null,\n model: asString(escrowed.model) ?? null,\n provider: asString(escrowed.provider) ?? null,\n profile_commit: asString(escrowed.profile_commit) ?? null,\n ...(escrowed.prompt_hash !== undefined\n ? { prompt_hash: asString(escrowed.prompt_hash) ?? null }\n : {}),\n ...(escrowed.config_hash !== undefined\n ? { config_hash: asString(escrowed.config_hash) ?? null }\n : {}),\n ...(escrowed.agent_profile_cell_id !== undefined\n ? { agent_profile_cell_id: asString(escrowed.agent_profile_cell_id) ?? null }\n : {}),\n sampling: isRecord(escrowed.sampling) ? escrowed.sampling : null,\n }\n }\n return {\n harness: agent.name,\n harness_version: agent.version,\n model: agent.model_name ?? null,\n provider: null,\n profile_commit: null,\n sampling: null,\n }\n}\n\nfunction artifactsFrom(escrow: Record<string, unknown> | undefined): RolloutArtifacts {\n const artifacts = escrowSection(escrow, 'artifacts')\n return {\n patch_path: asString(artifacts?.patch_path) ?? null,\n run_dir: asString(artifacts?.run_dir) ?? null,\n transcript_ref: asString(artifacts?.transcript_ref) ?? null,\n }\n}\n\nfunction costFrom(final: HarborFinalMetrics | undefined): RolloutCostBlock {\n const rawExtra = final?.extra\n const extra = isRecord(rawExtra) ? rawExtra : undefined\n const calls = asIntegerOrUndefined(extra?.llm_call_count)\n return {\n usd: asNumberOrNull(final?.total_cost_usd),\n tokens_in: asNumberOrNull(final?.total_prompt_tokens),\n tokens_out: asNumberOrNull(final?.total_completion_tokens),\n tokens_reasoning: asNumberOrNull(extra?.reasoning_tokens),\n cache_read: asNumberOrNull(final?.total_cached_tokens),\n cache_write: asNumberOrNull(extra?.cache_write_tokens),\n wall_s: asNumberOrNull(extra?.wall_s),\n ...(calls !== undefined ? { llm_call_count: calls } : {}),\n }\n}\n\n/**\n * Recovers span projections from ATIF's NATIVE per-step channel, for documents\n * with no `extra.tangle.spans` escrow — i.e. everything a foreign producer\n * writes. Without this the logprobs and token ids a Harbor-native trainer\n * records would be read, validated, and then dropped on the floor.\n *\n * Only steps that actually carry one of the four fields produce a span: an\n * agent step with no metrics means \"not captured\", and inventing an empty span\n * for it would claim the run had a shape we did not observe.\n */\nfunction spansFromSteps(steps: HarborStep[]): RolloutStep[] {\n const spans: RolloutStep[] = []\n for (const step of steps) {\n if (step.source !== 'agent') continue\n const calls = asIntegerOrUndefined(step.llm_call_count)\n const promptIds = asIntegerArray(step.metrics?.prompt_token_ids)\n const completionIds = asIntegerArray(step.metrics?.completion_token_ids)\n const logprobs = asNumberArray(step.metrics?.logprobs)\n if (\n calls === undefined &&\n promptIds === undefined &&\n completionIds === undefined &&\n logprobs === undefined\n ) {\n continue\n }\n spans.push({\n kind: 'llm',\n name: step.model_name ?? 'chat',\n ...(calls !== undefined ? { llm_call_count: calls } : {}),\n ...(promptIds !== undefined ? { prompt_token_ids: promptIds } : {}),\n ...(completionIds !== undefined ? { completion_token_ids: completionIds } : {}),\n ...(logprobs !== undefined ? { logprobs } : {}),\n })\n }\n return spans\n}\n\n/**\n * Composes `provenance.gap` as an ordered SET of reasons.\n *\n * Appending made the note accrete on every pass (\"…no verdict | …no verdict\"),\n * which both grows without bound and breaks byte-level idempotency for a ledger\n * hashed on its serialized lines.\n */\nfunction composeGap(escrowedGap: string | undefined, added: readonly string[]): string {\n const parts: string[] = []\n const seen = new Set<string>()\n for (const raw of [...(escrowedGap?.split(' | ') ?? []), ...added]) {\n const reason = raw.trim()\n if (reason.length === 0 || seen.has(reason)) continue\n seen.add(reason)\n parts.push(reason)\n }\n return parts.join(' | ')\n}\n\nexport interface FromHarborOptions {\n /** Injected clock for deterministic output when the source carries no capture time. */\n now?: () => Date\n}\n\nfunction nodeToLine(\n trajectory: HarborTrajectory,\n parentId: string | null,\n capturedAt: string,\n): RolloutLine {\n const escrow = escrowOf(trajectory.extra)\n const rolloutId =\n asString(escrow?.rollout_id) ?? trajectory.trajectory_id ?? trajectory.session_id\n if (rolloutId === undefined || rolloutId.length === 0) {\n throw new Error(\n 'fromHarborTrajectory: trajectory has no trajectory_id or session_id — cannot mint a joinable rollout_id without inventing one',\n )\n }\n const outcome = escrowSection(escrow, 'outcome')\n const provenance = escrowSection(escrow, 'provenance')\n const capture = provenance?.capture\n const escrowedGap = asString(provenance?.gap)\n const role = escrow?.role\n const escrowedSpans = escrow?.spans\n // The escrow wins when it exists (our own export: exact, including an empty\n // array, which claims \"captured, none\" rather than \"not captured\"), and the\n // native per-step channel is the fallback (a foreign export: still signal).\n const nativeSpans = spansFromSteps(trajectory.steps)\n const spans: RolloutStep[] | undefined = Array.isArray(escrowedSpans)\n ? (escrowedSpans as RolloutStep[])\n : nativeSpans.length > 0\n ? nativeSpans\n : undefined\n const messages = stepsToMessages(trajectory.steps)\n const line: RolloutLine = {\n schema: ROLLOUT_SCHEMA,\n rollout_id: rolloutId,\n // The tree edge wins for embedded children; for a root, the escrowed\n // pointer may reference a line outside this document and is preserved.\n parent_rollout_id: parentId ?? asString(escrow?.parent_rollout_id) ?? null,\n run_id: asString(escrow?.run_id) ?? trajectory.session_id ?? rolloutId,\n // Required keys on the wire (0.127.0): a foreign document that never\n // stated them imports as explicit `null`, not as an absent field.\n experiment_id: asString(escrow?.experiment_id) ?? null,\n candidate_id: asString(escrow?.candidate_id) ?? null,\n generation: asIntegerOrUndefined(escrow?.generation) ?? null,\n candidate_index: asIntegerOrUndefined(escrow?.candidate_index) ?? null,\n role: ROLLOUT_ROLES.includes(role as RolloutRole) ? (role as RolloutRole) : 'agent',\n task: taskFrom(escrow, rolloutId),\n policy: policyFrom(escrow, trajectory.agent),\n messages,\n tool_defs: trajectory.agent.tool_definitions ?? [],\n ...(spans !== undefined ? { steps: spans } : {}),\n outcome: {\n // ATIF carries no label. Null is the labeled gap; a 0 here would be a\n // fabricated failure and a 1 a fabricated success.\n reward: null,\n reward_source: null,\n verdict: null,\n metrics: isRecord(outcome?.metrics) ? outcome.metrics : {},\n is_completed: typeof outcome?.is_completed === 'boolean' ? outcome.is_completed : true,\n is_truncated:\n typeof outcome?.is_truncated === 'boolean'\n ? outcome.is_truncated\n : trajectory.continued_trajectory_ref !== undefined,\n error: asString(outcome?.error) ?? null,\n // The anti-Goodhart flag is restored when the source document stated\n // it; the wire schema requires the field, so a document that never did\n // imports as `false`. That is safe here because the reward is already\n // forced to `null` (not trainable) and `realness_screened` stays\n // absent = unknown rather than claiming a screen ran.\n realness_gated: outcome?.realness_gated === true,\n },\n cost: costFrom(trajectory.final_metrics),\n artifacts: artifactsFrom(escrow),\n provenance: {\n captured_at: asString(provenance?.captured_at) ?? capturedAt,\n capture: ROLLOUT_CAPTURES.includes(capture as RolloutCapture)\n ? (capture as RolloutCapture)\n : 'backfill',\n gap: composeGap(escrowedGap, [HARBOR_IMPORT_GAP]),\n // Restored for the same reason `realness_gated` is, and with the opposite\n // risk profile from the reward: this is the gated run's own measurement\n // bag, moved off `outcome` by `gateGamedOutcome` so no exporter reads it\n // as training input. Dropping it here would silently destroy the audit\n // trail that says WHY the run was flagged and what it claimed, on the one\n // population an auditor most wants to inspect. It cannot be fail-open —\n // nothing projects `provenance` into a training row.\n ...(isRecord(provenance?.gated_evidence)\n ? { gated_evidence: provenance.gated_evidence as GatedEvidence }\n : {}),\n },\n }\n assertRolloutLine(line, `rollout line imported from ATIF trajectory ${rolloutId}`)\n return line\n}\n\n/**\n * Flatten an ATIF trajectory tree back into `tangle.rollout.v1` lines, parent\n * first, each child carrying `parent_rollout_id`.\n *\n * Every line comes back UNLABELED: `reward`, `reward_source` and `verdict` are\n * null and `provenance.gap` says why. ATIF models no verdict, so scoring an\n * imported trajectory is a judge's job, not this function's. Every line lands\n * on `holdout` whatever the document claims — see `relabelImportedSplit`.\n */\nexport function fromHarborTrajectory(\n trajectory: HarborTrajectory,\n options: FromHarborOptions = {},\n): RolloutLine[] {\n const capturedAt = (options.now?.() ?? new Date()).toISOString()\n const lines: RolloutLine[] = []\n const walk = (node: HarborTrajectory, parentId: string | null, onPath: Set<string>): void => {\n const line = nodeToLine(node, parentId, capturedAt)\n if (onPath.has(line.rollout_id)) {\n throw new Error(`subagent_trajectories cycle through trajectory_id ${line.rollout_id}`)\n }\n onPath.add(line.rollout_id)\n lines.push(line)\n for (const child of node.subagent_trajectories ?? []) {\n walk(child, line.rollout_id, onPath)\n }\n onPath.delete(line.rollout_id)\n }\n walk(trajectory, null, new Set())\n return lines\n}\n\n/**\n * THE explicit door out of `holdout` for imported lines.\n *\n * Import forces `holdout` because a document's own claim about its split is not\n * evidence — anyone can write `extra.tangle.task.split`. Promoting a file to a\n * trainable split is an operator's decision about provenance they verified, so\n * it is a separate, greppable call: `grep relabelImportedSplit` enumerates\n * every place foreign data was declared trainable, which is exactly the audit\n * the trusted-escrow version made impossible.\n *\n * Returns plain `RolloutLine`s. They still have to pass `assertMinted` (and its\n * anti-Goodhart check) to reach an exporter — re-labeling a split is not\n * minting a reward.\n */\nexport function relabelImportedSplit(\n lines: readonly RolloutLine[],\n split: RolloutSplit,\n): RolloutLine[] {\n if (!ROLLOUT_SPLITS.includes(split)) {\n throw new Error(`relabelImportedSplit: unknown split ${String(split)}`)\n }\n return lines.map((line) => ({ ...line, task: { ...line.task, split } }))\n}\n","/**\n * Claude Code project transcripts (~/.claude/projects/<cwd-slug>/<sessionId>.jsonl) as canonical\n * chat-with-tools messages plus per-session token usage.\n *\n * The transcript is read by @tangle-network/harness-sessions, the one reader of harness sessions\n * shared with Discovery, agent-record, traces and the blog: one model call per API response\n * (`message.id`, its usage counted once), the served model from the response, tool calls with\n * their results. This module only projects that session. Sidechain lines (subagent threads in the\n * main file) are separate invocations and are excluded unless `includeSidechain` asks for a\n * subagent's own transcript.\n */\n\nimport { readdir } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport {\n claudeCodeReader,\n claudeCodeRefForFile,\n type HarnessSession,\n readSessionInput,\n toChatMessages,\n} from '@tangle-network/harness-sessions'\nimport type { ChatMessage } from '../schema'\n\nexport const DEFAULT_CLAUDE_PROJECTS_DIR = join(homedir(), '.claude', 'projects')\n\n/** Claude Code's project-directory slug for a working directory. */\nfunction claudeProjectSlug(cwd: string): string {\n return cwd.replace(/[^a-zA-Z0-9-]/g, '-')\n}\n\nexport interface ClaudeTranscriptRef {\n sessionId: string\n path: string\n}\n\n/** Transcript files recorded for sessions launched from `cwd`. */\nexport async function findClaudeTranscripts(\n cwd: string,\n projectsDir: string = DEFAULT_CLAUDE_PROJECTS_DIR,\n): Promise<ClaudeTranscriptRef[]> {\n const dir = join(projectsDir, claudeProjectSlug(cwd))\n const names = await readdir(dir).catch(() => [])\n return names\n .filter((n) => n.endsWith('.jsonl'))\n .sort()\n .map((n) => ({ sessionId: n.replace(/\\.jsonl$/, ''), path: join(dir, n) }))\n}\n\nexport interface ClaudeUsageTotals {\n tokensIn: number | null\n tokensOut: number | null\n cacheRead: number | null\n cacheWrite: number | null\n}\n\nexport interface ClaudeTranscript {\n messages: ChatMessage[]\n usage: ClaudeUsageTotals\n /** Timestamp of the first conversation record; null = empty transcript. */\n startedAt: string | null\n endedAt: string | null\n /** The model that answered the last response (never Claude Code's `<synthetic>` error turn). */\n model: string | null\n /** Every parse or usage gap retained beside this semantic projection. */\n gaps: string[]\n}\n\nexport interface ReadClaudeTranscriptOptions {\n /**\n * Read a subagent's own transcript (`<session>/subagents/agent-<id>.jsonl`), whose records are\n * sidechain end to end, instead of skipping sidechain records.\n */\n readonly includeSidechain?: boolean\n}\n\nconst USAGE_FIELDS = [\n ['tokensIn', 'input'],\n ['tokensOut', 'output'],\n ['cacheRead', 'cacheRead'],\n ['cacheWrite', 'cacheWrite'],\n] as const\n\n/**\n * The messages+usage projection of a normalized session. A usage field is null when any answered\n * model call did not report it, so a partial sum is never mistaken for the session's usage.\n */\nexport function transcriptFromSession(session: HarnessSession): ClaudeTranscript {\n const gaps = session.integrity.gaps.filter((gap) =>\n /is not a JSON record|still being written/u.test(gap),\n )\n const answered = session.modelCalls.filter((call) => call.error === null)\n const usage: ClaudeUsageTotals = {\n tokensIn: null,\n tokensOut: null,\n cacheRead: null,\n cacheWrite: null,\n }\n if (answered.length > 0) {\n for (const [target, field] of USAGE_FIELDS) {\n let total: number | null = 0\n for (const call of answered) {\n const value = call.usage?.[field] ?? null\n if (value === null) {\n total = null\n gaps.push(`model call ${call.id}: ${field} usage unavailable`)\n break\n }\n total += value\n }\n usage[target] = total\n }\n }\n const model =\n [...answered].reverse().find((call) => call.servedModel !== null)?.servedModel ?? null\n return {\n messages: toChatMessages(session),\n usage,\n startedAt: session.startedAt,\n endedAt: session.endedAt,\n model,\n gaps,\n }\n}\n\n/** Read one transcript file. */\nexport async function readClaudeTranscript(\n path: string,\n options: ReadClaudeTranscriptOptions = {},\n): Promise<ClaudeTranscript> {\n const session = await claudeCodeReader.read(\n claudeCodeRefForFile(path, options.includeSidechain === true ? 'parent' : null),\n )\n return transcriptFromSession(session)\n}\n\n/** Parse retained JSONL text without another file or store; source gaps remain explicit. */\nexport function parseClaudeTranscript(\n raw: string,\n options: ReadClaudeTranscriptOptions = {},\n): ClaudeTranscript {\n const session = readSessionInput(\n 'claude-code',\n { text: raw },\n {\n parentNativeSessionId: options.includeSidechain === true ? 'parent' : null,\n label: 'retained transcript',\n },\n )\n return transcriptFromSession(session)\n}\n","/**\n * OpenCode's SQLite store (~/.local/share/opencode/opencode.db) as canonical chat-with-tools\n * messages, through @tangle-network/harness-sessions: the one reader of harness sessions shared\n * with Discovery, agent-record, traces and the blog. The store is read from a private copy, never\n * in place, and a tool part that errored or never finished is read as what it is rather than\n * refused.\n */\n\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport {\n type HarnessSession,\n opencodeReader,\n opencodeSessionsInStore,\n toChatMessages,\n} from '@tangle-network/harness-sessions'\nimport type { ChatMessage } from '../schema'\n\nexport const DEFAULT_OPENCODE_DB = join(homedir(), '.local', 'share', 'opencode', 'opencode.db')\n\n\n\n/** One session, normalized. */\nasync function readOpencodeSession(\n sessionId: string,\n db: string = DEFAULT_OPENCODE_DB,\n): Promise<HarnessSession> {\n const [ref] = await opencodeSessionsInStore(db, null, { nativeSessionId: sessionId })\n if (ref === undefined) throw new Error(`OpenCode session ${sessionId} is not in ${db}`)\n return opencodeReader.read(ref)\n}\n\n/** One session's canonical messages: each model step, then the results of its tool calls. */\nexport async function readOpencodeSessionMessages(\n sessionId: string,\n db: string = DEFAULT_OPENCODE_DB,\n): Promise<ChatMessage[]> {\n return toChatMessages(await readOpencodeSession(sessionId, db))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,MAAM,sBAAsB;;AAG5B,MAAM,oBAAoB;;AAG1B,MAAM,SAAS;;;;;;;;;;;;;;AAef,MAAM,oBAAoB;AA8G1B,MAAM,YAAY,MAAoC,OAAO,MAAM,WAAW,IAAI,KAAA;AAElF,MAAM,kBAAkB,MACtB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,IAAI;AAEpD,MAAM,wBAAwB,MAC5B,OAAO,UAAU,CAAC,IAAK,IAAe,KAAA;AAExC,MAAM,iBAAiB,MACrB,MAAM,QAAQ,CAAC,KAAK,EAAE,OAAO,MAAM,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,CAAC,IACzE,IACD,KAAA;AAEN,M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rC,qBAAqB,MAAM,QAAQ,qBAAqB,OAAO,WAAW,IAAI,CAChF,CACoC;AACtC;;AAGA,SAAgB,sBACd,KACA,UAAuC,CAAC,GACtB;CASlB,OAAO,sBARS,iBACd,eACA,EAAE,MAAM,IAAI,GACZ;EACE,uBAAuB,QAAQ,qBAAqB,OAAO,WAAW;EACtE,OAAO;CACT,CAEiC,CAAC;AACtC;;;;;;;;;;ACpIA,MAAa,sBAAsB,KAAK,QAAQ,GAAG,UAAU,SAAS,YAAY,aAAa;;AAK/F,eAAe,oBACb,WACA,KAAa,qBACY;CACzB,MAAM,CAAC,OAAO,MAAM,wBAAwB,IAAI,MAAM,EAAE,iBAAiB,UAAU,CAAC;CACpF,IAAI,QAAQ,KAAA,GAAW,MAAM,IAAI,MAAM,oBAAoB,UAAU,aAAa,IAAI;CACtF,OAAO,eAAe,KAAK,GAAG;AAChC;;AAGA,eAAsB,4BACpB,WACA,KAAa,qBACW;CACxB,OAAO,eAAe,MAAM,oBAAoB,WAAW,EAAE,CAAC;AAChE"}
@@ -1,5 +1,5 @@
1
- import { i as makeRng } from "./internal-Epl-YBZW.js";
2
- import { a as spearmanR, r as pearsonR } from "./descriptive-DboxPZrG.js";
1
+ import { i as makeRng } from "./internal-BTK91Bqt.js";
2
+ import { a as spearmanR, r as pearsonR } from "./descriptive-CVNy48rR.js";
3
3
  //#region src/meta-eval/outcome-observations.ts
4
4
  /** Reduce observations of one named metric; unrelated keys cannot supply a value. */
5
5
  function reduceOutcomeMetric(outcomes, metric, reduction) {
@@ -175,4 +175,4 @@ async function rubricPredictiveValidity(input) {
175
175
  //#endregion
176
176
  export { reduceOutcomeMetric as a, hasVariation as i, assertUniqueObservationIds as n, validateObservationOptions as o, correlationSummary as r, validateOutcomeMetricSpecifications as s, rubricPredictiveValidity as t };
177
177
 
178
- //# sourceMappingURL=rubric-predictive-validity-DaFW70y9.js.map
178
+ //# sourceMappingURL=rubric-predictive-validity-D3_oI72N.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rubric-predictive-validity-DaFW70y9.js","names":[],"sources":["../src/meta-eval/outcome-observations.ts","../src/meta-eval/rubric-predictive-validity.ts"],"sourcesContent":["import { pearsonR, spearmanR } from '../statistics'\nimport { makeRng } from '../statistics/internal'\nimport type { DeploymentOutcome } from './outcome-store'\n\nexport type OutcomeReduction = 'latest' | 'mean' | 'max'\n\nexport interface CorrelationInterval {\n lower: number\n upper: number\n}\n\n/** Reduce observations of one named metric; unrelated keys cannot supply a value. */\nexport function reduceOutcomeMetric(\n outcomes: readonly DeploymentOutcome[],\n metric: string,\n reduction: OutcomeReduction,\n): number | null {\n const observations = outcomes.flatMap((outcome) => {\n const value = outcome.metrics[metric]\n return Number.isFinite(outcome.capturedAt) &&\n typeof value === 'number' &&\n Number.isFinite(value)\n ? [{ capturedAt: outcome.capturedAt, value }]\n : []\n })\n if (observations.length === 0) return null\n if (reduction === 'mean') {\n return observations.reduce(\n (sum, observation) => sum + observation.value / observations.length,\n 0,\n )\n }\n if (reduction === 'max') return Math.max(...observations.map((observation) => observation.value))\n return observations.reduce((a, b) => (b.capturedAt > a.capturedAt ? b : a)).value\n}\n\nexport function hasVariation(values: readonly number[]): boolean {\n return values.some((value) => value !== values[0])\n}\n\nexport function correlationSummary(\n xs: number[],\n ys: number[],\n iterations: number,\n seed: number | undefined,\n): {\n pearson: number\n spearman: number\n pearsonCi95: CorrelationInterval | null\n spearmanCi95: CorrelationInterval | null\n} {\n const rng = makeRng(seed, xs, ys)\n const pearsons: number[] = []\n const spearmans: number[] = []\n for (let b = 0; b < iterations; b++) {\n const rx: number[] = []\n const ry: number[] = []\n for (let i = 0; i < xs.length; i++) {\n const index = Math.floor(rng() * xs.length)\n rx.push(xs[index]!)\n ry.push(ys[index]!)\n }\n // A constant resample has no estimable correlation, even when both sides agree.\n if (!hasVariation(rx) || !hasVariation(ry)) continue\n const pearson = pearsonR(rx, ry)\n const spearman = spearmanR(rx, ry)\n if (Number.isFinite(pearson)) pearsons.push(pearson)\n if (Number.isFinite(spearman)) spearmans.push(spearman)\n }\n return {\n pearson: pearsonR(xs, ys),\n spearman: spearmanR(xs, ys),\n pearsonCi95: interval(pearsons),\n spearmanCi95: interval(spearmans),\n }\n}\n\nexport function validateObservationOptions(\n reduction: OutcomeReduction,\n iterations: number,\n seed: number | undefined,\n): void {\n if (!['latest', 'mean', 'max'].includes(reduction)) {\n throw new Error('outcome reduction must be latest, mean, or max')\n }\n if (!Number.isSafeInteger(iterations) || iterations < 1) {\n throw new Error('bootstrap iterations must be a positive safe integer')\n }\n if (seed !== undefined && !Number.isFinite(seed)) {\n throw new Error('bootstrap seed must be finite')\n }\n}\n\nexport function assertUniqueObservationIds(ids: readonly string[], name: string): void {\n if (ids.some((id) => typeof id !== 'string' || id.trim().length === 0)) {\n throw new Error(`${name} must be a nonempty string`)\n }\n if (new Set(ids).size !== ids.length) throw new Error(`duplicate ${name} in outcome study`)\n}\n\nexport function validateOutcomeMetricSpecifications(\n metrics: readonly { id: string; direction: string }[],\n): void {\n if (!Array.isArray(metrics) || metrics.length === 0) {\n throw new Error('outcomeMetrics must declare at least one outcome metric and direction')\n }\n for (const metric of metrics) {\n if (!metric || typeof metric.id !== 'string' || metric.id.trim().length === 0) {\n throw new Error('each outcome metric must have a nonempty id and explicit direction')\n }\n if (metric.direction !== 'higher-is-better' && metric.direction !== 'lower-is-better') {\n throw new Error(\n `outcome metric ${metric.id} must declare higher-is-better or lower-is-better`,\n )\n }\n }\n assertUniqueObservationIds(\n metrics.map((metric) => metric.id),\n 'outcome metric',\n )\n}\n\nfunction interval(values: number[]): CorrelationInterval | null {\n if (values.length === 0) return null\n values.sort((a, b) => a - b)\n return {\n lower: Math.max(-1, values[Math.floor(0.025 * values.length)]!),\n upper: Math.min(1, values[Math.min(values.length - 1, Math.floor(0.975 * values.length))]!),\n }\n}\n","/**\n * Join rubric scores to deployment outcomes and measure their association.\n * Higher rubric scores always mean better evaluated behavior.\n * Outcome directions are explicit because success rate and failure rate have opposite meanings.\n * These descriptive associations neither establish causation nor validate a change to rubric weights.\n */\n\nimport type { RunRecord } from '../run-record'\nimport {\n assertUniqueObservationIds,\n type CorrelationInterval,\n correlationSummary,\n hasVariation,\n reduceOutcomeMetric,\n validateObservationOptions,\n validateOutcomeMetricSpecifications,\n} from './outcome-observations'\nimport type { DeploymentOutcome, OutcomeStore } from './outcome-store'\n\nexport interface OutcomeMetricSpec {\n /** Exact key in DeploymentOutcome.metrics. */\n id: string\n direction: 'higher-is-better' | 'lower-is-better'\n}\n\nexport interface RubricPredictiveValidityInput {\n /** One record per independent run; rubric scores come from outcome.raw. */\n runs: RunRecord[]\n outcomes: OutcomeStore\n /** Declare desired directions before inspecting associations. */\n outcomeMetrics: readonly OutcomeMetricSpec[]\n /** Higher is better for each rubric. Omit to discover finite numeric outcome.raw keys. */\n rubrics?: readonly string[]\n /** Minimum joined runs for an estimate; an integer at least 3. Default 8. */\n minSamples?: number\n /** Bootstrap resamples for both correlation intervals. Default 500. */\n bootstrapResamples?: number\n /** Omit to derive a reproducible seed from the paired observations. */\n seed?: number\n /** Reduce finite observations of each named outcome within a run. Default latest. */\n reduction?: 'latest' | 'mean' | 'max'\n}\n\nexport interface RubricOutcomePair {\n rubric: string\n outcome: string\n outcomeDirection: OutcomeMetricSpec['direction']\n n: number\n /** Raw association with the recorded outcome, before direction alignment. */\n pearson: number\n spearman: number\n pearsonCi95: CorrelationInterval | null\n spearmanCi95: CorrelationInterval | null\n /** Positive values associate higher rubric scores with better outcomes. */\n alignedPearson: number\n alignedSpearman: number\n alignedSpearmanCi95: CorrelationInterval | null\n /** Descriptive buckets at aligned Spearman +/-0.4; no causal or release authority. */\n verdict: 'aligned' | 'inverse' | 'weak'\n}\n\nexport interface RubricRanking extends Omit<RubricOutcomePair, 'outcome'> {\n /** Outcome with the greatest direction-aligned Spearman for this rubric. */\n bestOutcome: string\n}\n\nexport interface RubricOutcomeExclusion {\n rubric: string\n outcome: string\n outcomeDirection: OutcomeMetricSpec['direction']\n /** Finite joined observations, including measured zeros. */\n n: number\n reason: 'insufficient_samples' | 'constant_rubric' | 'constant_outcome'\n}\n\nexport interface RubricPredictiveValidityReport {\n outcomeMetrics: OutcomeMetricSpec[]\n pairs: RubricOutcomePair[]\n /** All declared pairs lacking an estimate, with their usable observation count. */\n excludedPairs: RubricOutcomeExclusion[]\n /** Exploratory ordering by aligned Spearman; never use outcome selection as confirmatory evidence. */\n ranked: RubricRanking[]\n /** Runs contributing at least one finite pair, including pairs below minSamples. */\n joinedSamples: number\n /** Runs contributing no finite pair; joinedSamples + skippedRuns equals the input run count. */\n skippedRuns: number\n /** Declared rubrics with no finite score, distinct from too few outcomes or constant observations. */\n rubricsWithoutData: string[]\n}\n\nexport async function rubricPredictiveValidity(\n input: RubricPredictiveValidityInput,\n): Promise<RubricPredictiveValidityReport> {\n const minSamples = input.minSamples ?? 8\n const reduction = input.reduction ?? 'latest'\n const resamples = input.bootstrapResamples ?? 500\n const seed = input.seed\n if (!Number.isSafeInteger(minSamples) || minSamples < 3) {\n throw new Error('minSamples must be a safe integer at least 3')\n }\n validateObservationOptions(reduction, resamples, seed)\n validateOutcomeMetricSpecifications(input.outcomeMetrics)\n assertUniqueObservationIds(\n input.runs.map((run) => run.runId),\n 'runId',\n )\n\n const outcomeMetrics = input.outcomeMetrics.map((metric) => ({ ...metric }))\n const runs = input.runs.map((run) => ({ runId: run.runId, scores: { ...run.outcome.raw } }))\n const declaredRubrics = input.rubrics === undefined ? undefined : [...input.rubrics]\n if (declaredRubrics !== undefined) assertUniqueObservationIds(declaredRubrics, 'rubric')\n\n const outcomes = await input.outcomes.list()\n const outcomesByRun = new Map<string, DeploymentOutcome[]>()\n for (const outcome of outcomes) {\n const rows = outcomesByRun.get(outcome.runId) ?? []\n rows.push(outcome)\n outcomesByRun.set(outcome.runId, rows)\n }\n\n const observedRubrics = new Set<string>()\n for (const run of runs) {\n for (const [rubric, value] of Object.entries(run.scores)) {\n if (typeof value === 'number' && Number.isFinite(value)) observedRubrics.add(rubric)\n }\n }\n const rubrics = declaredRubrics ?? [...observedRubrics]\n const buckets = rubrics.flatMap((rubric) =>\n outcomeMetrics.map((outcome) => ({\n rubric,\n outcome,\n xs: [] as number[],\n ys: [] as number[],\n })),\n )\n\n let joined = 0\n for (const run of runs) {\n const rows = outcomesByRun.get(run.runId) ?? []\n let joinedThisRun = false\n for (const bucket of buckets) {\n const x = run.scores[bucket.rubric]\n if (typeof x !== 'number' || !Number.isFinite(x)) continue\n const y = reduceOutcomeMetric(rows, bucket.outcome.id, reduction)\n if (y === null) continue\n bucket.xs.push(x)\n bucket.ys.push(y)\n joinedThisRun = true\n }\n if (joinedThisRun) joined++\n }\n\n const pairs: RubricOutcomePair[] = []\n const excludedPairs: RubricOutcomeExclusion[] = []\n for (const bucket of buckets) {\n const identity = {\n rubric: bucket.rubric,\n outcome: bucket.outcome.id,\n outcomeDirection: bucket.outcome.direction,\n n: bucket.xs.length,\n }\n const reason =\n bucket.xs.length < minSamples\n ? 'insufficient_samples'\n : !hasVariation(bucket.xs)\n ? 'constant_rubric'\n : !hasVariation(bucket.ys)\n ? 'constant_outcome'\n : null\n if (reason !== null) {\n excludedPairs.push({ ...identity, reason })\n continue\n }\n const summary = correlationSummary(bucket.xs, bucket.ys, resamples, seed)\n const sign = bucket.outcome.direction === 'higher-is-better' ? 1 : -1\n const alignedSpearman = summary.spearman * sign\n const alignedSpearmanCi95 =\n summary.spearmanCi95 === null\n ? null\n : sign === 1\n ? summary.spearmanCi95\n : { lower: -summary.spearmanCi95.upper, upper: -summary.spearmanCi95.lower }\n pairs.push({\n ...identity,\n ...summary,\n alignedPearson: summary.pearson * sign,\n alignedSpearman,\n alignedSpearmanCi95,\n verdict: alignedSpearman >= 0.4 ? 'aligned' : alignedSpearman <= -0.4 ? 'inverse' : 'weak',\n })\n }\n\n const bestByRubric = new Map<string, RubricOutcomePair>()\n for (const pair of pairs) {\n const best = bestByRubric.get(pair.rubric)\n if (!best || pair.alignedSpearman > best.alignedSpearman) bestByRubric.set(pair.rubric, pair)\n }\n const ranked = [...bestByRubric.values()]\n .map(({ outcome, ...pair }) => ({ ...pair, bestOutcome: outcome }))\n .sort((a, b) => b.alignedSpearman - a.alignedSpearman)\n\n return {\n outcomeMetrics,\n pairs,\n excludedPairs,\n ranked,\n joinedSamples: joined,\n skippedRuns: runs.length - joined,\n rubricsWithoutData: rubrics.filter((rubric) => !observedRubrics.has(rubric)),\n }\n}\n"],"mappings":";;;;AAYA,SAAgB,oBACd,UACA,QACA,WACe;CACf,MAAM,eAAe,SAAS,SAAS,YAAY;EACjD,MAAM,QAAQ,QAAQ,QAAQ;EAC9B,OAAO,OAAO,SAAS,QAAQ,UAAU,KACvC,OAAO,UAAU,YACjB,OAAO,SAAS,KAAK,IACnB,CAAC;GAAE,YAAY,QAAQ;GAAY;EAAM,CAAC,IAC1C,CAAC;CACP,CAAC;CACD,IAAI,aAAa,WAAW,GAAG,OAAO;CACtC,IAAI,cAAc,QAChB,OAAO,aAAa,QACjB,KAAK,gBAAgB,MAAM,YAAY,QAAQ,aAAa,QAC7D,CACF;CAEF,IAAI,cAAc,OAAO,OAAO,KAAK,IAAI,GAAG,aAAa,KAAK,gBAAgB,YAAY,KAAK,CAAC;CAChG,OAAO,aAAa,QAAQ,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,IAAI,CAAE,CAAC,CAAC;AAC9E;AAEA,SAAgB,aAAa,QAAoC;CAC/D,OAAO,OAAO,MAAM,UAAU,UAAU,OAAO,EAAE;AACnD;AAEA,SAAgB,mBACd,IACA,IACA,YACA,MAMA;CACA,MAAM,MAAM,QAAQ,MAAM,IAAI,EAAE;CAChC,MAAM,WAAqB,CAAC;CAC5B,MAAM,YAAsB,CAAC;CAC7B,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAAK;EACnC,MAAM,KAAe,CAAC;EACtB,MAAM,KAAe,CAAC;EACtB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,QAAQ,KAAK;GAClC,MAAM,QAAQ,KAAK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ts","../src/meta-eval/rubric-predictive-validity.ts"],"sourcesContent":["import { pearsonR, spearmanR } from '../statistics'\nimport { makeRng } from '../statistics/internal'\nimport type { DeploymentOutcome } from './outcome-store'\n\nexport type OutcomeReduction = 'latest' | 'mean' | 'max'\n\nexport interface CorrelationInterval {\n lower: number\n upper: number\n}\n\n/** Reduce observations of one named metric; unrelated keys cannot supply a value. */\nexport function reduceOutcomeMetric(\n outcomes: readonly DeploymentOutcome[],\n metric: string,\n reduction: OutcomeReduction,\n): number | null {\n const observations = outcomes.flatMap((outcome) => {\n const value = outcome.metrics[metric]\n return Number.isFinite(outcome.capturedAt) &&\n typeof value === 'number' &&\n Number.isFinite(value)\n ? [{ capturedAt: outcome.capturedAt, value }]\n : []\n })\n if (observations.length === 0) return null\n if (reduction === 'mean') {\n return observations.reduce(\n (sum, observation) => sum + observation.value / observations.length,\n 0,\n )\n }\n if (reduction === 'max') return Math.max(...observations.map((observation) => observation.value))\n return observations.reduce((a, b) => (b.capturedAt > a.capturedAt ? b : a)).value\n}\n\nexport function hasVariation(values: readonly number[]): boolean {\n return values.some((value) => value !== values[0])\n}\n\nexport function correlationSummary(\n xs: number[],\n ys: number[],\n iterations: number,\n seed: number | undefined,\n): {\n pearson: number\n spearman: number\n pearsonCi95: CorrelationInterval | null\n spearmanCi95: CorrelationInterval | null\n} {\n const rng = makeRng(seed, xs, ys)\n const pearsons: number[] = []\n const spearmans: number[] = []\n for (let b = 0; b < iterations; b++) {\n const rx: number[] = []\n const ry: number[] = []\n for (let i = 0; i < xs.length; i++) {\n const index = Math.floor(rng() * xs.length)\n rx.push(xs[index]!)\n ry.push(ys[index]!)\n }\n // A constant resample has no estimable correlation, even when both sides agree.\n if (!hasVariation(rx) || !hasVariation(ry)) continue\n const pearson = pearsonR(rx, ry)\n const spearman = spearmanR(rx, ry)\n if (Number.isFinite(pearson)) pearsons.push(pearson)\n if (Number.isFinite(spearman)) spearmans.push(spearman)\n }\n return {\n pearson: pearsonR(xs, ys),\n spearman: spearmanR(xs, ys),\n pearsonCi95: interval(pearsons),\n spearmanCi95: interval(spearmans),\n }\n}\n\nexport function validateObservationOptions(\n reduction: OutcomeReduction,\n iterations: number,\n seed: number | undefined,\n): void {\n if (!['latest', 'mean', 'max'].includes(reduction)) {\n throw new Error('outcome reduction must be latest, mean, or max')\n }\n if (!Number.isSafeInteger(iterations) || iterations < 1) {\n throw new Error('bootstrap iterations must be a positive safe integer')\n }\n if (seed !== undefined && !Number.isFinite(seed)) {\n throw new Error('bootstrap seed must be finite')\n }\n}\n\nexport function assertUniqueObservationIds(ids: readonly string[], name: string): void {\n if (ids.some((id) => typeof id !== 'string' || id.trim().length === 0)) {\n throw new Error(`${name} must be a nonempty string`)\n }\n if (new Set(ids).size !== ids.length) throw new Error(`duplicate ${name} in outcome study`)\n}\n\nexport function validateOutcomeMetricSpecifications(\n metrics: readonly { id: string; direction: string }[],\n): void {\n if (!Array.isArray(metrics) || metrics.length === 0) {\n throw new Error('outcomeMetrics must declare at least one outcome metric and direction')\n }\n for (const metric of metrics) {\n if (!metric || typeof metric.id !== 'string' || metric.id.trim().length === 0) {\n throw new Error('each outcome metric must have a nonempty id and explicit direction')\n }\n if (metric.direction !== 'higher-is-better' && metric.direction !== 'lower-is-better') {\n throw new Error(\n `outcome metric ${metric.id} must declare higher-is-better or lower-is-better`,\n )\n }\n }\n assertUniqueObservationIds(\n metrics.map((metric) => metric.id),\n 'outcome metric',\n )\n}\n\nfunction interval(values: number[]): CorrelationInterval | null {\n if (values.length === 0) return null\n values.sort((a, b) => a - b)\n return {\n lower: Math.max(-1, values[Math.floor(0.025 * values.length)]!),\n upper: Math.min(1, values[Math.min(values.length - 1, Math.floor(0.975 * values.length))]!),\n }\n}\n","/**\n * Join rubric scores to deployment outcomes and measure their association.\n * Higher rubric scores always mean better evaluated behavior.\n * Outcome directions are explicit because success rate and failure rate have opposite meanings.\n * These descriptive associations neither establish causation nor validate a change to rubric weights.\n */\n\nimport type { RunRecord } from '../run-record'\nimport {\n assertUniqueObservationIds,\n type CorrelationInterval,\n correlationSummary,\n hasVariation,\n reduceOutcomeMetric,\n validateObservationOptions,\n validateOutcomeMetricSpecifications,\n} from './outcome-observations'\nimport type { DeploymentOutcome, OutcomeStore } from './outcome-store'\n\nexport interface OutcomeMetricSpec {\n /** Exact key in DeploymentOutcome.metrics. */\n id: string\n direction: 'higher-is-better' | 'lower-is-better'\n}\n\nexport interface RubricPredictiveValidityInput {\n /** One record per independent run; rubric scores come from outcome.raw. */\n runs: RunRecord[]\n outcomes: OutcomeStore\n /** Declare desired directions before inspecting associations. */\n outcomeMetrics: readonly OutcomeMetricSpec[]\n /** Higher is better for each rubric. Omit to discover finite numeric outcome.raw keys. */\n rubrics?: readonly string[]\n /** Minimum joined runs for an estimate; an integer at least 3. Default 8. */\n minSamples?: number\n /** Bootstrap resamples for both correlation intervals. Default 500. */\n bootstrapResamples?: number\n /** Omit to derive a reproducible seed from the paired observations. */\n seed?: number\n /** Reduce finite observations of each named outcome within a run. Default latest. */\n reduction?: 'latest' | 'mean' | 'max'\n}\n\nexport interface RubricOutcomePair {\n rubric: string\n outcome: string\n outcomeDirection: OutcomeMetricSpec['direction']\n n: number\n /** Raw association with the recorded outcome, before direction alignment. */\n pearson: number\n spearman: number\n pearsonCi95: CorrelationInterval | null\n spearmanCi95: CorrelationInterval | null\n /** Positive values associate higher rubric scores with better outcomes. */\n alignedPearson: number\n alignedSpearman: number\n alignedSpearmanCi95: CorrelationInterval | null\n /** Descriptive buckets at aligned Spearman +/-0.4; no causal or release authority. */\n verdict: 'aligned' | 'inverse' | 'weak'\n}\n\nexport interface RubricRanking extends Omit<RubricOutcomePair, 'outcome'> {\n /** Outcome with the greatest direction-aligned Spearman for this rubric. */\n bestOutcome: string\n}\n\nexport interface RubricOutcomeExclusion {\n rubric: string\n outcome: string\n outcomeDirection: OutcomeMetricSpec['direction']\n /** Finite joined observations, including measured zeros. */\n n: number\n reason: 'insufficient_samples' | 'constant_rubric' | 'constant_outcome'\n}\n\nexport interface RubricPredictiveValidityReport {\n outcomeMetrics: OutcomeMetricSpec[]\n pairs: RubricOutcomePair[]\n /** All declared pairs lacking an estimate, with their usable observation count. */\n excludedPairs: RubricOutcomeExclusion[]\n /** Exploratory ordering by aligned Spearman; never use outcome selection as confirmatory evidence. */\n ranked: RubricRanking[]\n /** Runs contributing at least one finite pair, including pairs below minSamples. */\n joinedSamples: number\n /** Runs contributing no finite pair; joinedSamples + skippedRuns equals the input run count. */\n skippedRuns: number\n /** Declared rubrics with no finite score, distinct from too few outcomes or constant observations. */\n rubricsWithoutData: string[]\n}\n\nexport async function rubricPredictiveValidity(\n input: RubricPredictiveValidityInput,\n): Promise<RubricPredictiveValidityReport> {\n const minSamples = input.minSamples ?? 8\n const reduction = input.reduction ?? 'latest'\n const resamples = input.bootstrapResamples ?? 500\n const seed = input.seed\n if (!Number.isSafeInteger(minSamples) || minSamples < 3) {\n throw new Error('minSamples must be a safe integer at least 3')\n }\n validateObservationOptions(reduction, resamples, seed)\n validateOutcomeMetricSpecifications(input.outcomeMetrics)\n assertUniqueObservationIds(\n input.runs.map((run) => run.runId),\n 'runId',\n )\n\n const outcomeMetrics = input.outcomeMetrics.map((metric) => ({ ...metric }))\n const runs = input.runs.map((run) => ({ runId: run.runId, scores: { ...run.outcome.raw } }))\n const declaredRubrics = input.rubrics === undefined ? undefined : [...input.rubrics]\n if (declaredRubrics !== undefined) assertUniqueObservationIds(declaredRubrics, 'rubric')\n\n const outcomes = await input.outcomes.list()\n const outcomesByRun = new Map<string, DeploymentOutcome[]>()\n for (const outcome of outcomes) {\n const rows = outcomesByRun.get(outcome.runId) ?? []\n rows.push(outcome)\n outcomesByRun.set(outcome.runId, rows)\n }\n\n const observedRubrics = new Set<string>()\n for (const run of runs) {\n for (const [rubric, value] of Object.entries(run.scores)) {\n if (typeof value === 'number' && Number.isFinite(value)) observedRubrics.add(rubric)\n }\n }\n const rubrics = declaredRubrics ?? [...observedRubrics]\n const buckets = rubrics.flatMap((rubric) =>\n outcomeMetrics.map((outcome) => ({\n rubric,\n outcome,\n xs: [] as number[],\n ys: [] as number[],\n })),\n )\n\n let joined = 0\n for (const run of runs) {\n const rows = outcomesByRun.get(run.runId) ?? []\n let joinedThisRun = false\n for (const bucket of buckets) {\n const x = run.scores[bucket.rubric]\n if (typeof x !== 'number' || !Number.isFinite(x)) continue\n const y = reduceOutcomeMetric(rows, bucket.outcome.id, reduction)\n if (y === null) continue\n bucket.xs.push(x)\n bucket.ys.push(y)\n joinedThisRun = true\n }\n if (joinedThisRun) joined++\n }\n\n const pairs: RubricOutcomePair[] = []\n const excludedPairs: RubricOutcomeExclusion[] = []\n for (const bucket of buckets) {\n const identity = {\n rubric: bucket.rubric,\n outcome: bucket.outcome.id,\n outcomeDirection: bucket.outcome.direction,\n n: bucket.xs.length,\n }\n const reason =\n bucket.xs.length < minSamples\n ? 'insufficient_samples'\n : !hasVariation(bucket.xs)\n ? 'constant_rubric'\n : !hasVariation(bucket.ys)\n ? 'constant_outcome'\n : null\n if (reason !== null) {\n excludedPairs.push({ ...identity, reason })\n continue\n }\n const summary = correlationSummary(bucket.xs, bucket.ys, resamples, seed)\n const sign = bucket.outcome.direction === 'higher-is-better' ? 1 : -1\n const alignedSpearman = summary.spearman * sign\n const alignedSpearmanCi95 =\n summary.spearmanCi95 === null\n ? null\n : sign === 1\n ? summary.spearmanCi95\n : { lower: -summary.spearmanCi95.upper, upper: -summary.spearmanCi95.lower }\n pairs.push({\n ...identity,\n ...summary,\n alignedPearson: summary.pearson * sign,\n alignedSpearman,\n alignedSpearmanCi95,\n verdict: alignedSpearman >= 0.4 ? 'aligned' : alignedSpearman <= -0.4 ? 'inverse' : 'weak',\n })\n }\n\n const bestByRubric = new Map<string, RubricOutcomePair>()\n for (const pair of pairs) {\n const best = bestByRubric.get(pair.rubric)\n if (!best || pair.alignedSpearman > best.alignedSpearman) bestByRubric.set(pair.rubric, pair)\n }\n const ranked = [...bestByRubric.values()]\n .map(({ outcome, ...pair }) => ({ ...pair, bestOutcome: outcome }))\n .sort((a, b) => b.alignedSpearman - a.alignedSpearman)\n\n return {\n outcomeMetrics,\n pairs,\n excludedPairs,\n ranked,\n joinedSamples: joined,\n skippedRuns: runs.length - joined,\n rubricsWithoutData: rubrics.filter((rubric) => !observedRubrics.has(rubric)),\n }\n}\n"],"mappings":";;;;AAYA,SAAgB,oBACd,UACA,QACA,WACe;CACf,MAAM,eAAe,SAAS,SAAS,YAAY;EACjD,MAAM,QAAQ,QAAQ,QAAQ;EAC9B,OAAO,OAAO,SAAS,QAAQ,UAAU,KACvC,OAAO,UAAU,YACjB,OAAO,SAAS,KAAK,IACnB,CAAC;GAAE,YAAY,QAAQ;GAAY;EAAM,CAAC,IAC1C,CAAC;CACP,CAAC;CACD,IAAI,aAAa,WAAW,GAAG,OAAO;CACtC,IAAI,cAAc,QAChB,OAAO,aAAa,QACjB,KAAK,gBAAgB,MAAM,YAAY,QAAQ,aAAa,QAC7D,CACF;CAEF,IAAI,cAAc,OAAO,OAAO,KAAK,IAAI,GAAG,aAAa,KAAK,gBAAgB,YAAY,KAAK,CAAC;CAChG,OAAO,aAAa,QAAQ,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,IAAI,CAAE,CAAC,CAAC;AAC9E;AAEA,SAAgB,aAAa,QAAoC;CAC/D,OAAO,OAAO,MAAM,UAAU,UAAU,OAAO,EAAE;AACnD;AAEA,SAAgB,mBACd,IACA,IACA,YACA,MAMA;CACA,MAAM,MAAM,QAAQ,MAAM,IAAI,EAAE;CAChC,MAAM,WAAqB,CAAC;CAC5B,MAAM,YAAsB,CAAC;CAC7B,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAAK;EACnC,MAAM,KAAe,CAAC;EACtB,MAAM,KAAe,CAAC;EACtB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,QAAQ,KAAK;GAClC,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI,GAAG,MAAM;GAC1C,GAAG,KAAK,GAAG,MAAO;GACl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,OAAO,EAAE,IACrB,oBACA,CAAC,aAAa,OAAO,EAAE,IACrB,qBACA;EACV,IAAI,WAAW,MAAM;GACnB,cAAc,KAAK;IAAE,GAAG;IAAU;GAAO,CAAC;GAC1C;EACF;EACA,MAAM,UAAU,mBAAmB,OAAO,IAAI,OAAO,IAAI,WAAW,IAAI;EACxE,MAAM,OAAO,OAAO,QAAQ,cAAc,qBAAqB,IAAI;EACnE,MAAM,kBAAkB,QAAQ,WAAW;EAC3C,MAAM,sBACJ,QAAQ,iBAAiB,OACrB,OACA,SAAS,IACP,QAAQ,eACR;GAAE,OAAO,CAAC,QAAQ,aAAa;GAAO,OAAO,CAAC,QAAQ,aAAa;EAAM;EACjF,MAAM,KAAK;GACT,GAAG;GACH,GAAG;GACH,gBAAgB,QAAQ,UAAU;GAClC;GACA;GACA,SAAS,mBAAmB,KAAM,YAAY,mBAAmB,MAAO,YAAY;EACtF,CAAC;CACH;CAEA,MAAM,+BAAe,IAAI,IAA+B;CACxD,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,aAAa,IAAI,KAAK,MAAM;EACzC,IAAI,CAAC,QAAQ,KAAK,kBAAkB,KAAK,iBAAiB,aAAa,IAAI,KAAK,QAAQ,IAAI;CAC9F;CAKA,OAAO;EACL;EACA;EACA;EACA,QARa,CAAC,GAAG,aAAa,OAAO,CAAC,CAAC,CACtC,KAAK,EAAE,SAAS,GAAG,YAAY;GAAE,GAAG;GAAM,aAAa;EAAQ,EAAE,CAAC,CAClE,MAAM,GAAG,MAAM,EAAE,kBAAkB,EAAE,eAMjC;EACL,eAAe;EACf,aAAa,KAAK,SAAS;EAC3B,oBAAoB,QAAQ,QAAQ,WAAW,CAAC,gBAAgB,IAAI,MAAM,CAAC;CAC7E;AACF"}
@@ -1,4 +1,4 @@
1
- import { a as RunRecord } from "./run-record-C1E24G2A.js";
1
+ import { a as RunRecord } from "./run-record-CaxbLq6Y.js";
2
2
  import { o as OutcomeStore } from "./outcome-store-CNt4iZ67.js";
3
3
  //#region src/meta-eval/outcome-observations.d.ts
4
4
  type OutcomeReduction = 'latest' | 'mean' | 'max';
@@ -76,4 +76,4 @@ interface RubricPredictiveValidityReport {
76
76
  declare function rubricPredictiveValidity(input: RubricPredictiveValidityInput): Promise<RubricPredictiveValidityReport>;
77
77
  //#endregion
78
78
  export { RubricPredictiveValidityReport as a, CorrelationInterval as c, RubricPredictiveValidityInput as i, OutcomeReduction as l, RubricOutcomeExclusion as n, RubricRanking as o, RubricOutcomePair as r, rubricPredictiveValidity as s, OutcomeMetricSpec as t };
79
- //# sourceMappingURL=rubric-predictive-validity-C03EC7ZE.d.ts.map
79
+ //# sourceMappingURL=rubric-predictive-validity-DiwT8PbL.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rubric-predictive-validity-C03EC7ZE.d.ts","names":[],"sources":["../src/meta-eval/outcome-observations.ts","../src/meta-eval/rubric-predictive-validity.ts"],"mappings":";;;KAIY;UAEK;EACf;EACA;;;;UCWe;;EAEf;EACA;;UAGe;;EAEf,MAAM;EACN,UAAU;;EAEV,yBAAyB;;EAEzB;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA,kBAAkB;EAClB;;EAEA;EACA;EACA,aAAa;EACb,cAAc;;EAEd;EACA;EACA,qBAAqB;;EAErB;;UAGe,sBAAsB,KAAK;;EAE1C;;UAGe;EACf;EACA;EACA,kBAAkB;;EAElB;EACA;;UAGe;EACf,gBAAgB;EAChB,OAAO;;EAEP,eAAe;;EAEf,QAAQ;;EAER;;EAEA;;EAEA;;iBAGoB,yBACpB,OAAO,gCACN,QAAQ"}
1
+ {"version":3,"file":"rubric-predictive-validity-DiwT8PbL.d.ts","names":[],"sources":["../src/meta-eval/outcome-observations.ts","../src/meta-eval/rubric-predictive-validity.ts"],"mappings":";;;KAIY;UAEK;EACf;EACA;;;;UCWe;;EAEf;EACA;;UAGe;;EAEf,MAAM;EACN,UAAU;;EAEV,yBAAyB;;EAEzB;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA,kBAAkB;EAClB;;EAEA;EACA;EACA,aAAa;EACb,cAAc;;EAEd;EACA;EACA,qBAAqB;;EAErB;;UAGe,sBAAsB,KAAK;;EAE1C;;UAGe;EACf;EACA;EACA,kBAAkB;;EAElB;EACA;;UAGe;EACf,gBAAgB;EAChB,OAAO;;EAEP,eAAe;;EAEf,QAAQ;;EAER;;EAEA;;EAEA;;iBAGoB,yBACpB,OAAO,gCACN,QAAQ"}
@@ -1,7 +1,7 @@
1
1
  import { l as CostProvenance } from "./cost-ledger-Jk62OBfF.js";
2
2
  import { c as ValidationError } from "./errors-DEE6u6ot.js";
3
- import { r as AgentProfileCell } from "./agent-profile-cell-BNp-Js9F.js";
4
- import { o as FailureClass } from "./schema-2g7trUwH.js";
3
+ import { r as AgentProfileCell } from "./agent-profile-cell-BcpFbNd5.js";
4
+ import { o as FailureClass } from "./schema-D6EVKzTB.js";
5
5
  //#region src/run-record.d.ts
6
6
  /** Search/dev/holdout split tag. 'search' is the paper-grade alias for the
7
7
  * combined train+test pool that the optimizer is allowed to read. */
@@ -68,12 +68,6 @@ interface RunTraceRef {
68
68
  /** Root run of the execution tree the run spawned, when one exists. */
69
69
  execRunId?: string;
70
70
  }
71
- /**
72
- * The run id of one attempt at a search cell. It is unique across candidates
73
- * and attempts, unlike a `${scenario}:${rep}` id, which every candidate that
74
- * ran the same scenario shares.
75
- */
76
- declare function searchCellRunId(search: Pick<RunSearchCoordinates, 'cellId' | 'attempt'>): string;
77
71
  interface RunJudgeMetadata {
78
72
  model: string;
79
73
  promptVersion: string;
@@ -291,5 +285,5 @@ declare function parseRunRecordSafe(input: unknown): {
291
285
  */
292
286
  declare function modelHasSnapshot(model: string): boolean;
293
287
  //#endregion
294
- export { runTaskScore as _, RunRecord as a, RunSplitTag as c, RunTokenUsage as d, RunTraceRef as f, parseRunRecordSafe as g, modelHasSnapshot as h, RunOutcome as i, RunTaskFailure as l, isRunRecord as m, RunCostProvenance as n, RunRecordValidationError as o, UNKNOWN_MODEL as p, RunJudgeMetadata as r, RunSearchCoordinates as s, JudgeScoresRecord as t, RunTerminalOutcome as u, searchCellRunId as v, validateRunRecord as y };
295
- //# sourceMappingURL=run-record-C1E24G2A.d.ts.map
288
+ export { runTaskScore as _, RunRecord as a, RunSplitTag as c, RunTokenUsage as d, RunTraceRef as f, parseRunRecordSafe as g, modelHasSnapshot as h, RunOutcome as i, RunTaskFailure as l, isRunRecord as m, RunCostProvenance as n, RunRecordValidationError as o, UNKNOWN_MODEL as p, RunJudgeMetadata as r, RunSearchCoordinates as s, JudgeScoresRecord as t, RunTerminalOutcome as u, validateRunRecord as v };
289
+ //# sourceMappingURL=run-record-CaxbLq6Y.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-record-CaxbLq6Y.d.ts","names":[],"sources":["../src/run-record.ts"],"mappings":";;;;;;;KAsCY;;;;;;;KAQA;;cAGC;UAEI;EACf;;EAEA;;;EAGA;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;;KAgBU,oBACR;EACE;EAAqB;EAAW;;;;;;;UAOrB;EACf;EACA;;;EAGA;;EAEA;;;UAIe;;EAEf;;EAEA;;UAYe;EACf;EACA;;;EAGA;;;EAGA;;;;;;;;;;;;;;;;;;;;;UAsBe;;EAEf,UAAU,eAAe;;EAEzB,YAAY;;;EAGZ;;;;EAIA;;;EAGA;;UAGe;;;EAGf;;;EAGA;;;;EAIA,KAAK;;;;;;EAML,cAAc;;;;;;;EAOd;IAAa;IAAe;IAAgB;;;;;;;;;;;;;;;;;;;;;;UAsB7B;;EAEf;;;EAGA;;;EAGA;;;EAGA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;EAGA,gBAAgB;;EAEhB,YAAY;;EAEZ,iBAAiB;;;EAGjB;;EAEA,gBAAgB;;EAEhB,SAAS;;;;;EAKT,eAAe;;;EAGf;;EAEA,UAAU;;;;;EAKV;;;;;;;;EAQA,eAAe;;;EAGf,SAAS;;;EAGT,WAAW;;;;;;;;;KAUD;EACN;EAA0B;;EAC1B;EAAyB;;EAEzB,cAAc,QAAQ;EACtB;;;;;;;;;;iBAWU,aAAa,QAAQ;cAmCxB,iCAAiC;WACnC;EACT,YAAY,iBAAiB;;;;;;;iBAWf,kBAAkB,iBAAiB;;iBA2SnC,YAAY,iBAAiB,SAAS;;iBAUtC,mBACd;EACG;EAAU,OAAO;;EAAgB;EAAW,OAAO;;;;;;;;iBA2FxC,iBAAiB"}
@@ -1,5 +1,5 @@
1
- import { c as validateRunRecord } from "./run-record-Boc5IUTp.js";
2
- import { t as mean } from "./mean-DHoMiudD.js";
1
+ import { c as validateRunRecord } from "./run-record-DhEJgoPz.js";
2
+ import { t as mean } from "./mean-BbA_JCzW.js";
3
3
  //#region src/campaign/run-record.ts
4
4
  /**
5
5
  * A campaign cell carried a judge score without a `dimensions` record.
@@ -218,4 +218,4 @@ function finiteMetrics(metrics) {
218
218
  //#endregion
219
219
  export { campaignCellToRunRecord as n, projectCampaignCellQuality as r, campaignCellCostProvenance as t };
220
220
 
221
- //# sourceMappingURL=run-record-C5e7FjhJ.js.map
221
+ //# sourceMappingURL=run-record-CysKLB93.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-record-CysKLB93.js","names":[],"sources":["../src/campaign/run-record.ts"],"sourcesContent":["import type { AgentProfileCell } from '../agent-profile-cell'\nimport type { CostProvenance } from '../cost-ledger'\nimport type {\n JudgeScoresRecord,\n RunCostProvenance,\n RunOutcome,\n RunRecord,\n RunSearchCoordinates,\n RunSplitTag,\n RunTerminalOutcome,\n RunTraceRef,\n} from '../run-record'\nimport { validateRunRecord } from '../run-record'\nimport { mean } from '../statistics/mean'\nimport type { CampaignCellResult, JudgeScore } from './types'\n\ninterface CampaignCellRunRecordOptions {\n /** With `search`, this must be `searchCellRunId(search)`. */\n runId: string\n experimentId: string\n candidateId: string\n model: string\n promptHash: string\n configHash: string\n commitSha: string\n splitTag: RunSplitTag\n seed?: number\n scenarioId?: string\n /** Estimated total for a cell that proved no spend at all. A cell that\n * proved part of its spend keeps that floor instead. */\n defaultCostUsd?: number\n agentProfile?: AgentProfileCell\n raw?: Record<string, number>\n search?: RunSearchCoordinates\n traceRef?: RunTraceRef\n}\n\ninterface CampaignCellQualityProjection {\n score?: number\n judgeScores?: JudgeScoresRecord\n successfulJudgeScores: Record<string, JudgeScore>\n failedJudges: string[]\n raw: Record<string, number>\n}\n\n/**\n * A campaign cell carried a judge score without a `dimensions` record.\n *\n * Two exported types share the name `JudgeScore`: the campaign verdict\n * (`{ dimensions, composite, notes }` from `@tangle-network/agent-eval/campaign`)\n * and the root export's flat per-dimension row (`{ judgeName, dimension, score }`\n * from `@tangle-network/agent-eval`). Campaign aggregation accepts only the\n * campaign shape; the flat shape previously crashed here with an opaque\n * TypeError deep inside aggregation.\n */\nexport class CampaignJudgeScoreShapeError extends TypeError {\n constructor(judgeName: string) {\n super(\n `campaign cell judge '${judgeName}' carries a score without a 'dimensions' record. ` +\n `Use the campaign JudgeScore ({ dimensions, composite, notes }) from ` +\n `'@tangle-network/agent-eval/campaign'; the root export's JudgeScore ` +\n `({ judgeName, dimension, score }) is a different type with the same name.`,\n )\n this.name = 'CampaignJudgeScoreShapeError'\n }\n}\n\ninterface CampaignCellExecutionEvidence {\n terminalOutcome: RunTerminalOutcome\n executionErrorCount?: number\n judgeErrorCount?: number\n unclassifiedErrorCount?: number\n terminalFailureReason?: string\n}\n\n/**\n * Project one campaign cell into the canonical run format.\n *\n * A dispatch error establishes terminal execution failure. A judge error only\n * establishes that quality measurement failed after dispatch completed.\n * Failures without a stage remain unknown. No failure becomes a zero-quality\n * label.\n */\nexport function campaignCellToRunRecord<TArtifact>(\n cell: CampaignCellResult<TArtifact>,\n options: CampaignCellRunRecordOptions,\n): RunRecord {\n const quality = projectCampaignCellQuality(cell)\n const execution = campaignCellExecutionEvidence(cell)\n const judgeErrorCount = Math.max(\n quality.raw.judge_error_count ?? 0,\n execution.judgeErrorCount ?? 0,\n )\n const costProvenance = campaignCellRunCostProvenance(cell, options.defaultCostUsd)\n const costUsd = costProvenance.usd\n const raw: Record<string, number> = {\n ...finiteMetrics(options.raw),\n ...quality.raw,\n rep: cell.rep,\n duration_ms: cell.durationMs,\n ...(costUsd === null ? {} : { cost_usd: costUsd }),\n tokens_input: cell.tokenUsage.input,\n tokens_output: cell.tokenUsage.output,\n tokens_known: cell.tokenUsage.tokensKnown === false ? 0 : 1,\n latency_ms: cell.durationMs,\n ...(execution.executionErrorCount === undefined\n ? {}\n : { execution_error_count: execution.executionErrorCount }),\n ...(judgeErrorCount > 0 ? { judge_error_count: judgeErrorCount } : {}),\n ...(execution.unclassifiedErrorCount === undefined\n ? {}\n : { unclassified_error_count: execution.unclassifiedErrorCount }),\n }\n if (typeof cell.generation === 'number') raw.generation = cell.generation\n if (cell.tokenUsage.reasoning !== undefined) {\n raw.tokens_reasoning = cell.tokenUsage.reasoning\n }\n if (cell.tokenUsage.cached !== undefined) raw.tokens_cached = cell.tokenUsage.cached\n if (cell.tokenUsage.cacheWrite !== undefined) {\n raw.tokens_cache_write = cell.tokenUsage.cacheWrite\n }\n if (cell.tokenUsage.tokensKnown !== false && costUsd !== null && costUsd > 0) {\n raw.tokens_per_dollar = (cell.tokenUsage.input + cell.tokenUsage.output) / costUsd\n }\n if (costUsd !== null && quality.score !== undefined && quality.score > 0.01) {\n raw.cost_per_quality = costUsd / quality.score\n }\n\n const outcome: RunOutcome = {\n raw,\n ...(quality.judgeScores ? { judgeScores: quality.judgeScores } : {}),\n }\n if (quality.score !== undefined) {\n if (options.splitTag === 'holdout') outcome.holdoutScore = quality.score\n else outcome.searchScore = quality.score\n }\n\n return validateRunRecord({\n runId: options.runId,\n experimentId: options.experimentId,\n candidateId: options.candidateId,\n seed: options.seed ?? cell.seed,\n model: options.model,\n promptHash: options.promptHash,\n configHash: options.configHash,\n commitSha: options.commitSha,\n wallMs: cell.durationMs,\n costUsd,\n costProvenance,\n tokenUsage: { ...cell.tokenUsage },\n terminalOutcome: execution.terminalOutcome,\n ...(execution.terminalFailureReason\n ? { terminalFailureReason: execution.terminalFailureReason }\n : {}),\n outcome,\n splitTag: options.splitTag,\n scenarioId: options.scenarioId ?? cell.scenarioId,\n ...(options.agentProfile ? { agentProfile: options.agentProfile } : {}),\n ...(options.search ? { search: options.search } : {}),\n ...(options.traceRef ? { traceRef: options.traceRef } : {}),\n })\n}\n\n/**\n * A cell's cost as a RunRecord states it. An uncaptured cell's `costUsd` is\n * the spend its receipts proved, so a positive one is the run's floor. The\n * caller's `defaultCostUsd` stands in only when nothing was proved: a proven\n * floor is never replaced by a guess.\n */\nfunction campaignCellRunCostProvenance<TArtifact>(\n cell: CampaignCellResult<TArtifact>,\n defaultCostUsd: number | undefined,\n): RunCostProvenance {\n const provenance = campaignCellCostProvenance(cell)\n if (provenance.kind !== 'uncaptured') return provenance\n if (cell.costUsd > 0) return { kind: 'lower-bound', usd: null, knownLowerBoundUsd: cell.costUsd }\n return defaultCostUsd === undefined ? provenance : { kind: 'estimated', usd: defaultCostUsd }\n}\n\n/**\n * Validate the cost fields that cross campaign cache and RunRecord boundaries.\n * `costUsd` is a known subtotal for uncaptured cells, but it must equal the\n * authoritative total whenever that total is observed or estimated.\n */\nexport function campaignCellCostProvenance<TArtifact>(\n cell: Pick<CampaignCellResult<TArtifact>, 'cellId' | 'costUsd' | 'costProvenance'>,\n): CostProvenance {\n if (!Number.isFinite(cell.costUsd) || cell.costUsd < 0) {\n throw new Error(`campaign cell '${cell.cellId}' has invalid costUsd`)\n }\n const provenance = cell.costProvenance\n if (!provenance || typeof provenance !== 'object') {\n throw new Error(`campaign cell '${cell.cellId}' has no costProvenance`)\n }\n if (provenance.kind === 'uncaptured') {\n if (provenance.usd !== null) {\n throw new Error(`campaign cell '${cell.cellId}' has invalid uncaptured costProvenance`)\n }\n return { kind: 'uncaptured', usd: null }\n }\n if (\n (provenance.kind !== 'observed' && provenance.kind !== 'estimated') ||\n !Number.isFinite(provenance.usd) ||\n provenance.usd < 0\n ) {\n throw new Error(`campaign cell '${cell.cellId}' has invalid costProvenance`)\n }\n if (provenance.usd !== cell.costUsd) {\n throw new Error(`campaign cell '${cell.cellId}' has costUsd inconsistent with costProvenance`)\n }\n return { kind: provenance.kind, usd: provenance.usd }\n}\n\nfunction campaignCellExecutionEvidence<TArtifact>(\n cell: CampaignCellResult<TArtifact>,\n): CampaignCellExecutionEvidence {\n if (cell.errorStage === 'dispatch') {\n return {\n terminalOutcome: 'failed',\n executionErrorCount: 1,\n ...(cell.error ? { terminalFailureReason: cell.error } : {}),\n }\n }\n if (cell.errorStage === 'judge') {\n return {\n terminalOutcome: 'succeeded',\n executionErrorCount: 0,\n judgeErrorCount: 1,\n }\n }\n if (!cell.error) {\n return { terminalOutcome: 'succeeded', executionErrorCount: 0 }\n }\n return {\n terminalOutcome: 'unknown',\n unclassifiedErrorCount: 1,\n }\n}\n\n/**\n * Produce the only task-quality view used by campaign aggregates and exports.\n *\n * Successful judge results remain available for diagnosis after another judge\n * fails, but a task score exists only for an error-free cell whose reported\n * judge values are all finite.\n */\nexport function projectCampaignCellQuality<TArtifact>(\n cell: CampaignCellResult<TArtifact>,\n): CampaignCellQualityProjection {\n if (cell.errorStage === 'dispatch') {\n return { successfulJudgeScores: {}, failedJudges: [], raw: {} }\n }\n\n const perJudge: Record<string, Record<string, number>> = {}\n const successfulJudgeScores: Record<string, JudgeScore> = {}\n const dimensionValues = new Map<string, number[]>()\n const composites: number[] = []\n const notes: string[] = []\n const failedJudges = new Set<string>(\n cell.errorStage === 'judge' ? [cell.errorJudge ?? 'unknown-judge'] : [],\n )\n const raw: Record<string, number> = {}\n\n for (const [judgeName, score] of Object.entries(cell.judgeScores)) {\n const dimensionsShape = (score as { dimensions?: unknown }).dimensions\n if (\n typeof dimensionsShape !== 'object' ||\n dimensionsShape === null ||\n Array.isArray(dimensionsShape)\n ) {\n throw new CampaignJudgeScoreShapeError(judgeName)\n }\n const finiteDimensions = Object.values(score.dimensions).every(Number.isFinite)\n if (score.failed || !Number.isFinite(score.composite) || !finiteDimensions) {\n failedJudges.add(judgeName)\n continue\n }\n\n composites.push(score.composite)\n successfulJudgeScores[judgeName] = score\n const dimensions = { ...score.dimensions }\n perJudge[judgeName] = dimensions\n for (const [dimension, value] of Object.entries(dimensions)) {\n raw[`${judgeName}.${dimension}`] = value\n const values = dimensionValues.get(dimension) ?? []\n values.push(value)\n dimensionValues.set(dimension, values)\n }\n if (score.notes) notes.push(`${judgeName}: ${score.notes}`)\n for (const failedJudge of score.failedJudges ?? []) {\n failedJudges.add(`${judgeName}/${failedJudge}`)\n }\n }\n\n if (failedJudges.size > 0) raw.judge_error_count = failedJudges.size\n const sortedFailedJudges = [...failedJudges].sort()\n if (composites.length === 0) {\n return {\n successfulJudgeScores,\n failedJudges: sortedFailedJudges,\n raw,\n }\n }\n\n const composite = mean(composites)\n const perDimMean = Object.fromEntries(\n [...dimensionValues.entries()].map(([dimension, values]) => [dimension, mean(values)]),\n )\n const complete =\n cell.error === undefined && cell.errorStage === undefined && failedJudges.size === 0\n if (complete) raw.composite = composite\n\n return {\n ...(complete ? { score: composite } : {}),\n raw,\n successfulJudgeScores,\n failedJudges: sortedFailedJudges,\n judgeScores: {\n perJudge,\n perDimMean,\n composite,\n ...(sortedFailedJudges.length > 0 ? { failedJudges: sortedFailedJudges } : {}),\n ...(notes.length > 0 ? { notes: notes.join(' | ') } : {}),\n },\n }\n}\n\nfunction finiteMetrics(metrics: Record<string, number> | undefined): Record<string, number> {\n const finite: Record<string, number> = {}\n for (const [key, value] of Object.entries(metrics ?? {})) {\n if (Number.isFinite(value)) finite[key] = value\n }\n return finite\n}\n"],"mappings":";;;;;;;;;;;;;AAuDA,IAAa,+BAAb,cAAkD,UAAU;CAC1D,YAAY,WAAmB;EAC7B,MACE,wBAAwB,UAAU,mQAIpC;EACA,KAAK,OAAO;CACd;AACF;;;;;;;;;AAkBA,SAAgB,wBACd,MACA,SACW;CACX,MAAM,UAAU,2BAA2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,CAAC,CACvF;CACA,MAAM,WACJ,KAAK,UAAU,KAAA,KAAa,KAAK,eAAe,KAAA,KAAa,aAAa,SAAS;CACrF,IAAI,UAAU,IAAI,YAAY;CAE9B,OAAO;EACL,GAAI,WAAW,EAAE,OAAO,UAAU,IAAI,CAAC;EACvC;EACA;EACA,cAAc;EACd,aAAa;GACX;GACA;GACA;GACA,GAAI,mBAAmB,SAAS,IAAI,EAAE,cAAc,mBAAmB,IAAI,CAAC;GAC5E,GAAI,MAAM,SAAS,IAAI,EAAE,OAAO,MAAM,KAAK,KAAK,EAAE,IAAI,CAAC;EACzD;CACF;AACF;AAEA,SAAS,cAAc,SAAqE;CAC1F,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,WAAW,CAAC,CAAC,GACrD,IAAI,OAAO,SAAS,KAAK,GAAG,OAAO,OAAO;CAE5C,OAAO;AACT"}
@@ -1,7 +1,7 @@
1
- import { s as ValidationError } from "./errors-DVZiqS7K.js";
2
- import { u as validateAgentProfileCell } from "./agent-profile-cell-BK8mlqlq.js";
1
+ import { s as ValidationError } from "./errors-BcOs5MKW.js";
2
+ import { s as validateAgentProfileCell } from "./agent-profile-cell-B1V1gUZs.js";
3
3
  import { n as observedScore } from "./reward-nw2xZGZG.js";
4
- import { t as FAILURE_CLASSES } from "./schema-CSf6qWgZ.js";
4
+ import { t as FAILURE_CLASSES } from "./schema-Bt2vLFm3.js";
5
5
  //#region src/run-record.ts
6
6
  /** Explicit model value for a row that never produced a served model snapshot. */
7
7
  const UNKNOWN_MODEL = "unknown";
@@ -283,4 +283,4 @@ function validSnapshotDate(year, month, day) {
283
283
  //#endregion
284
284
  export { parseRunRecordSafe as a, validateRunRecord as c, modelHasSnapshot as i, UNKNOWN_MODEL as n, runTaskScore as o, isRunRecord as r, searchCellRunId as s, RunRecordValidationError as t };
285
285
 
286
- //# sourceMappingURL=run-record-Boc5IUTp.js.map
286
+ //# sourceMappingURL=run-record-DhEJgoPz.js.map