@tangle-network/agent-eval 1.0.40 → 2.0.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 (398) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/dist/adapters/http.d.ts +3 -3
  3. package/dist/{agent-profile-DgbRJpSi.js → agent-profile-CCw6EXWW.js} +2 -2
  4. package/dist/{agent-profile-DgbRJpSi.js.map → agent-profile-CCw6EXWW.js.map} +1 -1
  5. package/dist/{agent-profile-hytrwAnN.d.ts → agent-profile-CcOq7bOO.d.ts} +84 -5
  6. package/dist/agent-profile-CcOq7bOO.d.ts.map +1 -0
  7. package/dist/{agent-profile-cell-7Mt0wBkl.js → agent-profile-cell-CUthydZB.js} +2 -2
  8. package/dist/{agent-profile-cell-7Mt0wBkl.js.map → agent-profile-cell-CUthydZB.js.map} +1 -1
  9. package/dist/analyst/index.d.ts +15 -15
  10. package/dist/analyst/index.d.ts.map +1 -1
  11. package/dist/analyst/index.js +15 -15
  12. package/dist/analyst/index.js.map +1 -1
  13. package/dist/{analyze-runs-DqHx3Q_g.js → analyze-runs-C_9cXPZn.js} +9 -9
  14. package/dist/{analyze-runs-DqHx3Q_g.js.map → analyze-runs-C_9cXPZn.js.map} +1 -1
  15. package/dist/{analyze-runs-Ctuz-dd3.d.ts → analyze-runs-Ke0WbAf6.d.ts} +4 -4
  16. package/dist/{analyze-runs-Ctuz-dd3.d.ts.map → analyze-runs-Ke0WbAf6.d.ts.map} +1 -1
  17. package/dist/app-grade/index.d.ts +5 -5
  18. package/dist/app-grade/index.js +5 -5
  19. package/dist/authenticity/index.d.ts.map +1 -1
  20. package/dist/authenticity/index.js.map +1 -1
  21. package/dist/{benchmark-command-CJw3ijDV.js → benchmark-command-BIMwcK97.js} +15 -14
  22. package/dist/benchmark-command-BIMwcK97.js.map +1 -0
  23. package/dist/benchmarks/index.d.ts +9 -5
  24. package/dist/benchmarks/index.d.ts.map +1 -1
  25. package/dist/benchmarks/index.js +11 -6
  26. package/dist/benchmarks/index.js.map +1 -1
  27. package/dist/builder-eval/index.d.ts +1 -1
  28. package/dist/builder-eval/index.js +3 -3
  29. package/dist/{calibration-BBhY1QM6.js → calibration-Cfoup0xz.js} +3 -3
  30. package/dist/{calibration-BBhY1QM6.js.map → calibration-Cfoup0xz.js.map} +1 -1
  31. package/dist/campaign/index.d.ts +10 -10
  32. package/dist/campaign/index.js +16 -15
  33. package/dist/{campaign-DawSkDag.js → campaign-C4rXvh2q.js} +33 -25
  34. package/dist/campaign-C4rXvh2q.js.map +1 -0
  35. package/dist/{campaign-evidence-C1c6uihA.d.ts → campaign-evidence-BmMs8YJt.d.ts} +7 -7
  36. package/dist/{campaign-evidence-C1c6uihA.d.ts.map → campaign-evidence-BmMs8YJt.d.ts.map} +1 -1
  37. package/dist/{campaign-evidence-BX8OveG5.js → campaign-evidence-D_oBFfLc.js} +92 -32
  38. package/dist/campaign-evidence-D_oBFfLc.js.map +1 -0
  39. package/dist/{canonical-gLeHiqzd.d.ts → canonical-CGXS21f_.d.ts} +8 -5
  40. package/dist/{canonical-gLeHiqzd.d.ts.map → canonical-CGXS21f_.d.ts.map} +1 -1
  41. package/dist/{canonical-BANK6NOj.js → canonical-DKgL_Wby.js} +30 -8
  42. package/dist/canonical-DKgL_Wby.js.map +1 -0
  43. package/dist/{chat-client-DmPB31_2.js → chat-client-CvyDOQBv.js} +2 -2
  44. package/dist/{chat-client-DmPB31_2.js.map → chat-client-CvyDOQBv.js.map} +1 -1
  45. package/dist/{chat-json-call-Rfhu7JbJ.js → chat-json-call-DMrwmB-k.js} +2 -2
  46. package/dist/{chat-json-call-Rfhu7JbJ.js.map → chat-json-call-DMrwmB-k.js.map} +1 -1
  47. package/dist/{claim-C6LRiwz1.js → claim-BWEXwwBk.js} +2 -2
  48. package/dist/{claim-C6LRiwz1.js.map → claim-BWEXwwBk.js.map} +1 -1
  49. package/dist/cli.js +11 -11
  50. package/dist/{client-BIFwUg7I.d.ts → client-DUMIaMob.d.ts} +2 -2
  51. package/dist/{client-BIFwUg7I.d.ts.map → client-DUMIaMob.d.ts.map} +1 -1
  52. package/dist/{cluster-CSd0LE_M.d.ts → cluster-Bj90LK-1.d.ts} +2 -2
  53. package/dist/{cluster-CSd0LE_M.d.ts.map → cluster-Bj90LK-1.d.ts.map} +1 -1
  54. package/dist/{cluster-bootstrap-ClPYIWoX.js → cluster-bootstrap-DPzVy3_K.js} +2 -2
  55. package/dist/{cluster-bootstrap-ClPYIWoX.js.map → cluster-bootstrap-DPzVy3_K.js.map} +1 -1
  56. package/dist/{completion-verifier-oAgSwdFe.d.ts → completion-verifier-Cy38EpGE.d.ts} +3 -3
  57. package/dist/{completion-verifier-oAgSwdFe.d.ts.map → completion-verifier-Cy38EpGE.d.ts.map} +1 -1
  58. package/dist/{completion-verifier-C3q1T96h.js → completion-verifier-DsotH2l3.js} +7 -7
  59. package/dist/{completion-verifier-C3q1T96h.js.map → completion-verifier-DsotH2l3.js.map} +1 -1
  60. package/dist/containment-order-GCJ-y_FV.js +56 -0
  61. package/dist/containment-order-GCJ-y_FV.js.map +1 -0
  62. package/dist/contract/index.d.ts +14 -14
  63. package/dist/contract/index.js +17 -17
  64. package/dist/contract/index.js.map +1 -1
  65. package/dist/{cost-ledger-1CwUnVOd.js → cost-ledger-C5CCidPm.js} +9 -2
  66. package/dist/cost-ledger-C5CCidPm.js.map +1 -0
  67. package/dist/{cost-ledger-Czro9wmo.d.ts → cost-ledger-CSP-OfFe.d.ts} +7 -1
  68. package/dist/cost-ledger-CSP-OfFe.d.ts.map +1 -0
  69. package/dist/{decision-point-BN1YQNqk.js → decision-point-C46p-p9v.js} +9 -9
  70. package/dist/{decision-point-BN1YQNqk.js.map → decision-point-C46p-p9v.js.map} +1 -1
  71. package/dist/{default-registry-C5x2jyD6.d.ts → default-registry-CUuorCWZ.d.ts} +7 -7
  72. package/dist/{default-registry-C5x2jyD6.d.ts.map → default-registry-CUuorCWZ.d.ts.map} +1 -1
  73. package/dist/{default-registry-BE5Rj9ba.js → default-registry-D6WZm_vR.js} +9 -9
  74. package/dist/default-registry-D6WZm_vR.js.map +1 -0
  75. package/dist/{define-agent-eval-CyU7eAzj.js → define-agent-eval-CNvv_D6O.js} +20 -12
  76. package/dist/define-agent-eval-CNvv_D6O.js.map +1 -0
  77. package/dist/{define-agent-eval-C4yoCqkc.d.ts → define-agent-eval-D17XsdAt.d.ts} +22 -13
  78. package/dist/define-agent-eval-D17XsdAt.d.ts.map +1 -0
  79. package/dist/diagnosis/index.d.ts +3 -3
  80. package/dist/diagnosis/index.d.ts.map +1 -1
  81. package/dist/diagnosis/index.js +1 -1
  82. package/dist/diagnosis/index.js.map +1 -1
  83. package/dist/{dspy-rlm-engine-aM1RWOUT.js → dspy-rlm-engine-s6iexObG.js} +5 -4
  84. package/dist/dspy-rlm-engine-s6iexObG.js.map +1 -0
  85. package/dist/{emitter-DhQ65mza.js → emitter-BjW3NnX-.js} +15 -6
  86. package/dist/emitter-BjW3NnX-.js.map +1 -0
  87. package/dist/{emitter-mAXC5PSN.d.ts → emitter-Cw8ijO3v.d.ts} +4 -4
  88. package/dist/{emitter-mAXC5PSN.d.ts.map → emitter-Cw8ijO3v.d.ts.map} +1 -1
  89. package/dist/{engine-B2w3ARpj.d.ts → engine-BZVXOc6n.d.ts} +3 -3
  90. package/dist/{engine-B2w3ARpj.d.ts.map → engine-BZVXOc6n.d.ts.map} +1 -1
  91. package/dist/errors-DeEEV9Vx.js.map +1 -1
  92. package/dist/{eval-campaign-CWWh-1p1.js → eval-campaign-Cyk-tkLh.js} +5 -5
  93. package/dist/{eval-campaign-CWWh-1p1.js.map → eval-campaign-Cyk-tkLh.js.map} +1 -1
  94. package/dist/{evaluation-C_GJvEEG.js → evaluation-BAisv8ZR.js} +2 -2
  95. package/dist/{evaluation-C_GJvEEG.js.map → evaluation-BAisv8ZR.js.map} +1 -1
  96. package/dist/{evaluation-CQ-uAbqF.d.ts → evaluation-DfyLPVL1.d.ts} +5 -5
  97. package/dist/{evaluation-CQ-uAbqF.d.ts.map → evaluation-DfyLPVL1.d.ts.map} +1 -1
  98. package/dist/evaluation.d.ts +1 -1
  99. package/dist/evaluation.js +1 -1
  100. package/dist/{exact-types-B0_jA3V7.d.ts → exact-types-CiCXYhNK.d.ts} +2 -2
  101. package/dist/{exact-types-B0_jA3V7.d.ts.map → exact-types-CiCXYhNK.d.ts.map} +1 -1
  102. package/dist/{execution-insight-9No6Si55.d.ts → execution-insight-wUNXxo5Y.d.ts} +3 -3
  103. package/dist/{execution-insight-9No6Si55.d.ts.map → execution-insight-wUNXxo5Y.d.ts.map} +1 -1
  104. package/dist/experiment/index.d.ts +4 -4
  105. package/dist/experiment/index.d.ts.map +1 -1
  106. package/dist/experiment/index.js +10 -10
  107. package/dist/experiment/index.js.map +1 -1
  108. package/dist/{exporters-C9AwGDDK.js → exporters-CKFtnWmX.js} +2 -2
  109. package/dist/{exporters-C9AwGDDK.js.map → exporters-CKFtnWmX.js.map} +1 -1
  110. package/dist/external-optimizer-contracts-ZDBfbZ_s.js +123 -0
  111. package/dist/external-optimizer-contracts-ZDBfbZ_s.js.map +1 -0
  112. package/dist/{external-optimizer-process-DFEPdWJY.js → external-optimizer-process-wxSzICQX.js} +22 -26
  113. package/dist/external-optimizer-process-wxSzICQX.js.map +1 -0
  114. package/dist/{external-optimizer-subprocess-BspZ0bZb.js → external-optimizer-subprocess-DeMYwEd5.js} +11 -125
  115. package/dist/external-optimizer-subprocess-DeMYwEd5.js.map +1 -0
  116. package/dist/extract-usage-ISFqhfDz.js.map +1 -1
  117. package/dist/{feedback-trajectory-CCWiFzeE.d.ts → feedback-trajectory-HJticMDz.d.ts} +4 -4
  118. package/dist/{feedback-trajectory-CCWiFzeE.d.ts.map → feedback-trajectory-HJticMDz.d.ts.map} +1 -1
  119. package/dist/{finding-composition-BMgspnVI.js → finding-composition-CyWSTcAY.js} +2 -2
  120. package/dist/{finding-composition-BMgspnVI.js.map → finding-composition-CyWSTcAY.js.map} +1 -1
  121. package/dist/{findings-store-B8pq8Rhr.js → findings-store-D09YcDnR.js} +6 -6
  122. package/dist/{findings-store-B8pq8Rhr.js.map → findings-store-D09YcDnR.js.map} +1 -1
  123. package/dist/fuzz.d.ts +1 -1
  124. package/dist/fuzz.d.ts.map +1 -1
  125. package/dist/fuzz.js +2 -2
  126. package/dist/fuzz.js.map +1 -1
  127. package/dist/{harness-session-lines-Fd5aeSDV.js → harness-session-lines-CSxKR6no.js} +3 -3
  128. package/dist/{harness-session-lines-Fd5aeSDV.js.map → harness-session-lines-CSxKR6no.js.map} +1 -1
  129. package/dist/{hf-dataset-kthWy7xl.js → hf-dataset-B0s2ZAhQ.js} +4 -4
  130. package/dist/{hf-dataset-kthWy7xl.js.map → hf-dataset-B0s2ZAhQ.js.map} +1 -1
  131. package/dist/hosted/index.d.ts +2 -2
  132. package/dist/hosted/index.js +1 -1
  133. package/dist/{index-BuuUhU_V.d.ts → index-B_k8aY9k.d.ts} +44 -32
  134. package/dist/index-B_k8aY9k.d.ts.map +1 -0
  135. package/dist/{index-DtW7KhyE.d.ts → index-C6TG1LwA.d.ts} +5 -5
  136. package/dist/{index-DtW7KhyE.d.ts.map → index-C6TG1LwA.d.ts.map} +1 -1
  137. package/dist/{index-Bcy00QoN.d.ts → index-CKjqN9_U.d.ts} +87 -87
  138. package/dist/index-CKjqN9_U.d.ts.map +1 -0
  139. package/dist/{index-CXoFLNKI.d.ts → index-CR-guIiZ.d.ts} +11 -11
  140. package/dist/index-CR-guIiZ.d.ts.map +1 -0
  141. package/dist/{index-DwUGehqX.d.ts → index-DsgqP-Hg.d.ts} +2 -2
  142. package/dist/{index-DwUGehqX.d.ts.map → index-DsgqP-Hg.d.ts.map} +1 -1
  143. package/dist/{index-HdlzN11G.d.ts → index-Ucp54Pcl.d.ts} +9 -9
  144. package/dist/{index-HdlzN11G.d.ts.map → index-Ucp54Pcl.d.ts.map} +1 -1
  145. package/dist/{index-Bhc7H9e0.d.ts → index-oX0TuJFv.d.ts} +7 -7
  146. package/dist/{index-Bhc7H9e0.d.ts.map → index-oX0TuJFv.d.ts.map} +1 -1
  147. package/dist/{index-lRKqfyg4.d.ts → index-qy6buL6y.d.ts} +2 -2
  148. package/dist/{index-lRKqfyg4.d.ts.map → index-qy6buL6y.d.ts.map} +1 -1
  149. package/dist/index.d.ts +35 -35
  150. package/dist/index.js +42 -42
  151. package/dist/index.js.map +1 -1
  152. package/dist/{integrity-BMyCpnZ8.d.ts → integrity-B9320cw1.d.ts} +2 -2
  153. package/dist/{integrity-BMyCpnZ8.d.ts.map → integrity-B9320cw1.d.ts.map} +1 -1
  154. package/dist/{integrity-BSs9dgKW.js → integrity-BF0tJK21.js} +3 -3
  155. package/dist/{integrity-BSs9dgKW.js.map → integrity-BF0tJK21.js.map} +1 -1
  156. package/dist/{journal-DQsbHGjX.js → journal-3y-btqaP.js} +2 -2
  157. package/dist/{journal-DQsbHGjX.js.map → journal-3y-btqaP.js.map} +1 -1
  158. package/dist/journal-file-AekB57Er.js.map +1 -1
  159. package/dist/{json-recovery-b7O9WVTF.js → json-recovery-BRUCeQxo.js} +2 -2
  160. package/dist/{json-recovery-b7O9WVTF.js.map → json-recovery-BRUCeQxo.js.map} +1 -1
  161. package/dist/{judge-gate-LbmZU-pA.js → judge-gate-DqlzOBOm.js} +3 -3
  162. package/dist/{judge-gate-LbmZU-pA.js.map → judge-gate-DqlzOBOm.js.map} +1 -1
  163. package/dist/{kind-factory-B5FfFE5G.js → kind-factory-Bs-oaT61.js} +4 -4
  164. package/dist/kind-factory-Bs-oaT61.js.map +1 -0
  165. package/dist/ledger-core/index.d.ts +2 -2
  166. package/dist/ledger-core/index.js +3 -3
  167. package/dist/{ledger-core-7e6sXmhV.js → ledger-core-auznoaD7.js} +3 -3
  168. package/dist/ledger-core-auznoaD7.js.map +1 -0
  169. package/dist/{llm-client-CdHo3SH0.js → llm-client-Dw4x6EdE.js} +3 -3
  170. package/dist/{llm-client-CdHo3SH0.js.map → llm-client-Dw4x6EdE.js.map} +1 -1
  171. package/dist/{llm-judge-DHgx29ro.js → llm-judge-OZtO1yNS.js} +183 -78
  172. package/dist/llm-judge-OZtO1yNS.js.map +1 -0
  173. package/dist/matrix/index.d.ts +2 -2
  174. package/dist/{matrix-BKzNwIWb.d.ts → matrix-DlSrRl_v.d.ts} +4 -4
  175. package/dist/{matrix-BKzNwIWb.d.ts.map → matrix-DlSrRl_v.d.ts.map} +1 -1
  176. package/dist/meta-eval/index.d.ts +2 -2
  177. package/dist/meta-eval/index.js +9 -9
  178. package/dist/{mint-VN-qtJTc.js → mint-B4n1pRRd.js} +12 -6
  179. package/dist/mint-B4n1pRRd.js.map +1 -0
  180. package/dist/{model-comparison-BZr_Hu00.js → model-comparison-CgnVh4Ph.js} +3 -3
  181. package/dist/{model-comparison-BZr_Hu00.js.map → model-comparison-CgnVh4Ph.js.map} +1 -1
  182. package/dist/multishot/golden/index.d.ts +1 -1
  183. package/dist/multishot/index.d.ts +3 -3
  184. package/dist/multishot/index.js +2 -2
  185. package/dist/multishot/index.js.map +1 -1
  186. package/dist/openapi.json +1 -1
  187. package/dist/{outcome-observations-YFFmdGGW.js → outcome-observations-DL3CC8w1.js} +2 -2
  188. package/dist/{outcome-observations-YFFmdGGW.js.map → outcome-observations-DL3CC8w1.js.map} +1 -1
  189. package/dist/{paired-arms-DH376s4-.js → paired-arms-DZhH3FGu.js} +3 -3
  190. package/dist/{paired-arms-DH376s4-.js.map → paired-arms-DZhH3FGu.js.map} +1 -1
  191. package/dist/{paired-promotion-decision-BBSxTo-h.d.ts → paired-promotion-decision-ChHBuuHV.d.ts} +2 -2
  192. package/dist/{paired-promotion-decision-BBSxTo-h.d.ts.map → paired-promotion-decision-ChHBuuHV.d.ts.map} +1 -1
  193. package/dist/{paired-promotion-decision-BoWHWL1i.js → paired-promotion-decision-Dn3-jaq4.js} +2 -2
  194. package/dist/{paired-promotion-decision-BoWHWL1i.js.map → paired-promotion-decision-Dn3-jaq4.js.map} +1 -1
  195. package/dist/{paired-promotion-power-BXH3gzvs.js → paired-promotion-power-BlzXdgMD.js} +3 -3
  196. package/dist/{paired-promotion-power-BXH3gzvs.js.map → paired-promotion-power-BlzXdgMD.js.map} +1 -1
  197. package/dist/{pareto-BNWWbLNl.js → pareto-Bg75Gajo.js} +7 -7
  198. package/dist/{pareto-BNWWbLNl.js.map → pareto-Bg75Gajo.js.map} +1 -1
  199. package/dist/pipelines/index.d.ts +3 -3
  200. package/dist/pipelines/index.d.ts.map +1 -1
  201. package/dist/pipelines/index.js +19 -33
  202. package/dist/pipelines/index.js.map +1 -1
  203. package/dist/{prime-protocol-BR0xy0cF.d.ts → prime-protocol-iEaSEGZB.d.ts} +3 -3
  204. package/dist/{prime-protocol-BR0xy0cF.d.ts.map → prime-protocol-iEaSEGZB.d.ts.map} +1 -1
  205. package/dist/profile-cell.js +1 -1
  206. package/dist/{promotion-gate-XiTqW22r.d.ts → promotion-gate-CGkxh36r.d.ts} +3 -3
  207. package/dist/{promotion-gate-XiTqW22r.d.ts.map → promotion-gate-CGkxh36r.d.ts.map} +1 -1
  208. package/dist/{promotion-policy-CfgRPGx0.js → promotion-policy-CxDIh-9p.js} +4 -4
  209. package/dist/{promotion-policy-CfgRPGx0.js.map → promotion-policy-CxDIh-9p.js.map} +1 -1
  210. package/dist/{proposal-findings-DFQvA-k5.js → proposal-findings-Bi4ouHdc.js} +2 -2
  211. package/dist/{proposal-findings-DFQvA-k5.js.map → proposal-findings-Bi4ouHdc.js.map} +1 -1
  212. package/dist/{query-Ck6KhcDo.js → query-Dhjkwqyx.js} +2 -2
  213. package/dist/{query-Ck6KhcDo.js.map → query-Dhjkwqyx.js.map} +1 -1
  214. package/dist/{registry-D23oO0_f.d.ts → registry-V8o2kZtn.d.ts} +5 -5
  215. package/dist/{registry-D23oO0_f.d.ts.map → registry-V8o2kZtn.d.ts.map} +1 -1
  216. package/dist/{release-confidence-BdidB0mG.js → release-confidence-BLHOMK5Q.js} +3 -3
  217. package/dist/{release-confidence-BdidB0mG.js.map → release-confidence-BLHOMK5Q.js.map} +1 -1
  218. package/dist/reporting.d.ts +6 -6
  219. package/dist/reporting.js +5 -5
  220. package/dist/{research-report-BGKsOqkF.d.ts → research-report-D6XIK0eK.d.ts} +4 -4
  221. package/dist/{research-report-BGKsOqkF.d.ts.map → research-report-D6XIK0eK.d.ts.map} +1 -1
  222. package/dist/{researcher-DvFDa1o1.d.ts → researcher---DhHG4J.d.ts} +6 -6
  223. package/dist/{researcher-DvFDa1o1.d.ts.map → researcher---DhHG4J.d.ts.map} +1 -1
  224. package/dist/{reward-hacking-CLMvxEY_.d.ts → reward-hacking-4DsGTccp.d.ts} +2 -2
  225. package/dist/{reward-hacking-CLMvxEY_.d.ts.map → reward-hacking-4DsGTccp.d.ts.map} +1 -1
  226. package/dist/{reward-hacking-DNiHskry.js → reward-hacking-DKAflk2c.js} +2 -2
  227. package/dist/{reward-hacking-DNiHskry.js.map → reward-hacking-DKAflk2c.js.map} +1 -1
  228. package/dist/rl.d.ts +158 -42
  229. package/dist/rl.d.ts.map +1 -1
  230. package/dist/rl.js +420 -76
  231. package/dist/rl.js.map +1 -1
  232. package/dist/rollout/index.d.ts +4 -4
  233. package/dist/rollout/index.js +6 -6
  234. package/dist/{rollout-DDMkK_Lw.js → rollout-DVwpCHBC.js} +9 -9
  235. package/dist/rollout-DVwpCHBC.js.map +1 -0
  236. package/dist/{rollout-nodes-DzmHlPAC.js → rollout-nodes-Vas6OSxX.js} +2 -2
  237. package/dist/{rollout-nodes-DzmHlPAC.js.map → rollout-nodes-Vas6OSxX.js.map} +1 -1
  238. package/dist/{rubric-predictive-validity-Cln7r56F.js → rubric-predictive-validity--6z0q8s6.js} +2 -2
  239. package/dist/{rubric-predictive-validity-Cln7r56F.js.map → rubric-predictive-validity--6z0q8s6.js.map} +1 -1
  240. package/dist/{rubric-predictive-validity-B7rsN074.d.ts → rubric-predictive-validity-C9wc7f_D.d.ts} +2 -2
  241. package/dist/{rubric-predictive-validity-B7rsN074.d.ts.map → rubric-predictive-validity-C9wc7f_D.d.ts.map} +1 -1
  242. package/dist/{run-improvement-loop-BAxDnaPI.d.ts → run-improvement-loop-CtLyPb5-.d.ts} +140 -81
  243. package/dist/run-improvement-loop-CtLyPb5-.d.ts.map +1 -0
  244. package/dist/{run-record-c860wUR8.js → run-record-Bqg0NZ_e.js} +19 -4
  245. package/dist/run-record-Bqg0NZ_e.js.map +1 -0
  246. package/dist/{run-record-Dx64nPcX.js → run-record-CqUft6Yf.js} +2 -2
  247. package/dist/{run-record-Dx64nPcX.js.map → run-record-CqUft6Yf.js.map} +1 -1
  248. package/dist/{run-record-CCJR7q_j.d.ts → run-record-kuOr3BCF.d.ts} +2 -2
  249. package/dist/{run-record-CCJR7q_j.d.ts.map → run-record-kuOr3BCF.d.ts.map} +1 -1
  250. package/dist/{runtime-rollouts-CALol_Y4.js → runtime-rollouts-DdUijr_t.js} +7 -7
  251. package/dist/runtime-rollouts-DdUijr_t.js.map +1 -0
  252. package/dist/{schema-BTTzvMnn.d.ts → schema-BfSoJjD-.d.ts} +5 -1
  253. package/dist/schema-BfSoJjD-.d.ts.map +1 -0
  254. package/dist/{schema-b18jtzZw.js → schema-Bh9CfSZT.js} +3 -1
  255. package/dist/schema-Bh9CfSZT.js.map +1 -0
  256. package/dist/schema-CkIvnmLU.d.ts.map +1 -1
  257. package/dist/schema-D-xu3MU_.js.map +1 -1
  258. package/dist/search/index.d.ts +3 -3
  259. package/dist/search/index.d.ts.map +1 -1
  260. package/dist/search/index.js +3 -3
  261. package/dist/{search-kernel-DRHWY35J.d.ts → search-kernel-DXA1EhnN.d.ts} +7 -7
  262. package/dist/{search-kernel-DRHWY35J.d.ts.map → search-kernel-DXA1EhnN.d.ts.map} +1 -1
  263. package/dist/{search-ledger-oyqxZhry.js → search-ledger-C7t68cmy.js} +7 -7
  264. package/dist/{search-ledger-oyqxZhry.js.map → search-ledger-C7t68cmy.js.map} +1 -1
  265. package/dist/{search-ledger-file-DoHCYYLt.js → search-ledger-file-QuIbgz6b.js} +2 -2
  266. package/dist/search-ledger-file-QuIbgz6b.js.map +1 -0
  267. package/dist/{search-ledger-types-qiYRUo_N.d.ts → search-ledger-types-BhZE848w.d.ts} +2 -2
  268. package/dist/{search-ledger-types-qiYRUo_N.d.ts.map → search-ledger-types-BhZE848w.d.ts.map} +1 -1
  269. package/dist/{search-shipper-BwqeQ61l.js → search-shipper-CmDW9dU6.js} +3 -3
  270. package/dist/{search-shipper-BwqeQ61l.js.map → search-shipper-CmDW9dU6.js.map} +1 -1
  271. package/dist/{search-summary-CNHpHFfw.js → search-summary-B1x1Vmzh.js} +5 -5
  272. package/dist/{search-summary-CNHpHFfw.js.map → search-summary-B1x1Vmzh.js.map} +1 -1
  273. package/dist/{sequential-B-zx24n_.d.ts → sequential-BhbTSxpt.d.ts} +2 -2
  274. package/dist/{sequential-B-zx24n_.d.ts.map → sequential-BhbTSxpt.d.ts.map} +1 -1
  275. package/dist/{sequential-93xxuiiG.js → sequential-BphITa5b.js} +4 -4
  276. package/dist/{sequential-93xxuiiG.js.map → sequential-BphITa5b.js.map} +1 -1
  277. package/dist/{sequential-C6k0Wrb7.js → sequential-ux_XrjBf.js} +3 -3
  278. package/dist/{sequential-C6k0Wrb7.js.map → sequential-ux_XrjBf.js.map} +1 -1
  279. package/dist/{served-model-qhLmbutL.js → served-model-BXmeKm7D.js} +2 -2
  280. package/dist/{served-model-qhLmbutL.js.map → served-model-BXmeKm7D.js.map} +1 -1
  281. package/dist/{server-DnoEi4Sb.js → server-1fzBCxMh.js} +5 -5
  282. package/dist/{server-DnoEi4Sb.js.map → server-1fzBCxMh.js.map} +1 -1
  283. package/dist/{skillopt-optimization-method-Du3GbReg.js → skillopt-optimization-method-DTwL-L6q.js} +390 -68
  284. package/dist/skillopt-optimization-method-DTwL-L6q.js.map +1 -0
  285. package/dist/{statistical-heldout-BvcAVtof.js → statistical-heldout-CaS4T-43.js} +3 -3
  286. package/dist/{statistical-heldout-BvcAVtof.js.map → statistical-heldout-CaS4T-43.js.map} +1 -1
  287. package/dist/{statistics-CHs0jlsY.js → statistics-DSidA5I2.js} +184 -184
  288. package/dist/statistics-DSidA5I2.js.map +1 -0
  289. package/dist/statistics.d.ts +2 -2
  290. package/dist/statistics.js +1 -1
  291. package/dist/{store-otlp-DHc_E78m.js → store-otlp-Re9Gwt2B.js} +2 -2
  292. package/dist/{store-otlp-DHc_E78m.js.map → store-otlp-Re9Gwt2B.js.map} +1 -1
  293. package/dist/{store-tool-spans-C1lZKvvl.d.ts → store-tool-spans-C47hUUVM.d.ts} +8 -8
  294. package/dist/{store-tool-spans-C1lZKvvl.d.ts.map → store-tool-spans-C47hUUVM.d.ts.map} +1 -1
  295. package/dist/{store-tool-spans-BR4IhZYZ.js → store-tool-spans-MpjSz292.js} +4 -4
  296. package/dist/{store-tool-spans-BR4IhZYZ.js.map → store-tool-spans-MpjSz292.js.map} +1 -1
  297. package/dist/storyboard/index.d.ts.map +1 -1
  298. package/dist/storyboard/index.js.map +1 -1
  299. package/dist/{summary-report-CXiE1UrA.js → summary-report-CI4J6gxU.js} +4 -4
  300. package/dist/{summary-report-CXiE1UrA.js.map → summary-report-CI4J6gxU.js.map} +1 -1
  301. package/dist/{summary-report-figures-C4JW8fdy.d.ts → summary-report-figures-CJHygLgw.d.ts} +2 -2
  302. package/dist/{summary-report-figures-C4JW8fdy.d.ts.map → summary-report-figures-CJHygLgw.d.ts.map} +1 -1
  303. package/dist/supervisor-run/index.d.ts +2 -2
  304. package/dist/supervisor-run/index.d.ts.map +1 -1
  305. package/dist/supervisor-run/index.js +3 -3
  306. package/dist/{systemone-B_3Vd395.d.ts → systemone-MXhFSYdy.d.ts} +9 -9
  307. package/dist/{systemone-B_3Vd395.d.ts.map → systemone-MXhFSYdy.d.ts.map} +1 -1
  308. package/dist/systemone-protocol.js +1 -1
  309. package/dist/{systemone-review-ZAN-5m_2.d.ts → systemone-review-C9kbs3zD.d.ts} +2 -2
  310. package/dist/{systemone-review-ZAN-5m_2.d.ts.map → systemone-review-C9kbs3zD.d.ts.map} +1 -1
  311. package/dist/{systemone-review-CqNNZMiD.js → systemone-review-ir3Cbejl.js} +3 -3
  312. package/dist/{systemone-review-CqNNZMiD.js.map → systemone-review-ir3Cbejl.js.map} +1 -1
  313. package/dist/systemone.d.ts +3 -3
  314. package/dist/systemone.js +3 -3
  315. package/dist/{tool-groups-BOH1E-E4.d.ts → tool-groups-BSd08M7B.d.ts} +3 -3
  316. package/dist/tool-groups-BSd08M7B.d.ts.map +1 -0
  317. package/dist/tool-waste-CIhtU1ad.d.ts +217 -0
  318. package/dist/tool-waste-CIhtU1ad.d.ts.map +1 -0
  319. package/dist/{tool-waste-DzLI-JJg.js → tool-waste-u7JJ_BlE.js} +3 -3
  320. package/dist/{tool-waste-DzLI-JJg.js.map → tool-waste-u7JJ_BlE.js.map} +1 -1
  321. package/dist/{trace-questions-DBsrgY_H.d.ts → trace-questions-CJANeK9P.d.ts} +4 -4
  322. package/dist/{trace-questions-DBsrgY_H.d.ts.map → trace-questions-CJANeK9P.d.ts.map} +1 -1
  323. package/dist/trace-repair/index.d.ts +3 -3
  324. package/dist/trace-repair/index.d.ts.map +1 -1
  325. package/dist/trace-repair/index.js +4 -4
  326. package/dist/trace-repair/index.js.map +1 -1
  327. package/dist/traces.d.ts +7 -7
  328. package/dist/traces.js +6 -6
  329. package/dist/{training-admission-xaDOlQ_U.d.ts → training-admission-DGZCyntI.d.ts} +2 -2
  330. package/dist/{training-admission-xaDOlQ_U.d.ts.map → training-admission-DGZCyntI.d.ts.map} +1 -1
  331. package/dist/trajectory-CKVZaQoQ.js +144 -0
  332. package/dist/trajectory-CKVZaQoQ.js.map +1 -0
  333. package/dist/trajectory-replay/index.d.ts.map +1 -1
  334. package/dist/trajectory-replay/index.js +24 -11
  335. package/dist/trajectory-replay/index.js.map +1 -1
  336. package/dist/{tree-0r6gPODs.js → tree-DQMlcNFI.js} +18 -6
  337. package/dist/tree-DQMlcNFI.js.map +1 -0
  338. package/dist/{types-DmYd2Igl.d.ts → types-AGUuvnae.d.ts} +4 -4
  339. package/dist/{types-DmYd2Igl.d.ts.map → types-AGUuvnae.d.ts.map} +1 -1
  340. package/dist/{types-_dfu6Ox2.d.ts → types-BLv2Ngla.d.ts} +3 -3
  341. package/dist/{types-_dfu6Ox2.d.ts.map → types-BLv2Ngla.d.ts.map} +1 -1
  342. package/dist/{types-ClDpBoLt.d.ts → types-CE9JMZhk.d.ts} +3 -3
  343. package/dist/{types-ClDpBoLt.d.ts.map → types-CE9JMZhk.d.ts.map} +1 -1
  344. package/dist/{types-DGqGbNY4.d.ts → types-DD1eUTLn.d.ts} +23 -9
  345. package/dist/{types-DGqGbNY4.d.ts.map → types-DD1eUTLn.d.ts.map} +1 -1
  346. package/dist/{types-C8AyaiFi.js → types-_tlhWGUq.js} +2 -2
  347. package/dist/{types-C8AyaiFi.js.map → types-_tlhWGUq.js.map} +1 -1
  348. package/dist/{verdict-CKo1iZkI.js → verdict-5PVtsWT_.js} +2 -2
  349. package/dist/{verdict-CKo1iZkI.js.map → verdict-5PVtsWT_.js.map} +1 -1
  350. package/dist/{verdict-cache-DfzlHLdf.js → verdict-cache-BPaYxfG8.js} +2 -2
  351. package/dist/verdict-cache-BPaYxfG8.js.map +1 -0
  352. package/dist/wire/index.d.ts +5 -5
  353. package/dist/wire/index.js +1 -1
  354. package/docs/campaign-proposers.md +15 -2
  355. package/docs/concepts.md +4 -0
  356. package/docs/public-api.md +325 -87
  357. package/docs/rollout.md +2 -2
  358. package/docs/search-ledger.md +14 -2
  359. package/docs/statistical-evidence.md +9 -3
  360. package/docs/trajectory-replay.md +4 -0
  361. package/package.json +1 -1
  362. package/dist/agent-profile-hytrwAnN.d.ts.map +0 -1
  363. package/dist/benchmark-command-CJw3ijDV.js.map +0 -1
  364. package/dist/campaign-DawSkDag.js.map +0 -1
  365. package/dist/campaign-evidence-BX8OveG5.js.map +0 -1
  366. package/dist/canonical-BANK6NOj.js.map +0 -1
  367. package/dist/cost-ledger-1CwUnVOd.js.map +0 -1
  368. package/dist/cost-ledger-Czro9wmo.d.ts.map +0 -1
  369. package/dist/default-registry-BE5Rj9ba.js.map +0 -1
  370. package/dist/define-agent-eval-C4yoCqkc.d.ts.map +0 -1
  371. package/dist/define-agent-eval-CyU7eAzj.js.map +0 -1
  372. package/dist/dspy-rlm-engine-aM1RWOUT.js.map +0 -1
  373. package/dist/emitter-DhQ65mza.js.map +0 -1
  374. package/dist/external-optimizer-process-DFEPdWJY.js.map +0 -1
  375. package/dist/external-optimizer-subprocess-BspZ0bZb.js.map +0 -1
  376. package/dist/index-Bcy00QoN.d.ts.map +0 -1
  377. package/dist/index-BuuUhU_V.d.ts.map +0 -1
  378. package/dist/index-CXoFLNKI.d.ts.map +0 -1
  379. package/dist/kind-factory-B5FfFE5G.js.map +0 -1
  380. package/dist/ledger-core-7e6sXmhV.js.map +0 -1
  381. package/dist/llm-judge-DHgx29ro.js.map +0 -1
  382. package/dist/mint-VN-qtJTc.js.map +0 -1
  383. package/dist/rollout-DDMkK_Lw.js.map +0 -1
  384. package/dist/run-improvement-loop-BAxDnaPI.d.ts.map +0 -1
  385. package/dist/run-record-c860wUR8.js.map +0 -1
  386. package/dist/runtime-rollouts-CALol_Y4.js.map +0 -1
  387. package/dist/schema-BTTzvMnn.d.ts.map +0 -1
  388. package/dist/schema-b18jtzZw.js.map +0 -1
  389. package/dist/search-ledger-file-DoHCYYLt.js.map +0 -1
  390. package/dist/skillopt-optimization-method-Du3GbReg.js.map +0 -1
  391. package/dist/statistics-CHs0jlsY.js.map +0 -1
  392. package/dist/tool-groups-BOH1E-E4.d.ts.map +0 -1
  393. package/dist/tool-waste-CUASoTtk.d.ts +0 -139
  394. package/dist/tool-waste-CUASoTtk.d.ts.map +0 -1
  395. package/dist/trajectory-O3GDHmev.js +0 -55
  396. package/dist/trajectory-O3GDHmev.js.map +0 -1
  397. package/dist/tree-0r6gPODs.js.map +0 -1
  398. package/dist/verdict-cache-DfzlHLdf.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"mint-VN-qtJTc.js","names":[],"sources":["../src/rollout/mint.ts"],"sourcesContent":["/**\n * Rollout minting — `tangle.rollout.v1` lines joined from the records the\n * substrate ALREADY keeps. There is no separate rollout store: a rollout\n * is the JOIN of a RunRecord (identity, provenance, cost, outcome) with\n * its trace (spans share `runId`), projected into the canonical line.\n *\n * Composition, not duplication:\n * - identity/provenance → `RunRecord` (candidateId, splitTag, agentProfile, hashes)\n * - step structure → `buildTrajectory` over the shared TraceStore\n * - preference-pair export → `feedbackTrajectoryToOptimizerRow` (feedback-trajectory.ts)\n * - PRM / reward-model → `reward-model-export.ts`\n * - search lineage → `searchLineage`, read from the run's search ledger\n *\n * Anti-Goodhart invariant: a run whose `outcome.realness.gated` is true is\n * never exported with a positive reward OR with any of the numbers that reward\n * was computed from. The gate travels into the training data (`reward` forced\n * to 0, `realness_gated: true`) and the whole outcome is transformed by\n * `gateGamedOutcome` inside `assertMinted` below, which relocates `metrics` and\n * `verdict` to `provenance.gated_evidence`. Mint returns\n * `MintedRolloutLine[]`: the brand the training exporters require, which only\n * this function, `readRolloutLedger`, and an explicit `assertMinted` can mint.\n *\n * A record carrying NEITHER split score is REJECTED (`ValidationError`), never\n * minted at 0 — \"nobody graded this\" is not the same claim as \"graded a total\n * failure\", and a trainer reading 0 learns the second. Lines that already\n * carry `reward: null` (interchange imports, existing ledgers) remain valid on\n * the wire; only the RunRecord→line door refuses.\n *\n * Records without spans or an explicit full capture become labeled GAP LINES (messages: [],\n * provenance.gap) — present in the output AND surfaced in\n * `missingTraces`; a capture gap is a finding, never a silent omission.\n */\n\nimport { ValidationError } from '../errors'\nimport { canonicalString, jsonDocument } from '../ledger-core/canonical'\nimport { type RunRecord, type RunSearchCoordinates, runTaskScore } from '../run-record'\nimport type { LlmSpan, Span, ToolSpan } from '../trace/schema'\nimport type { TraceStore } from '../trace/store'\nimport { buildTrajectory } from '../trajectory'\nimport { rolloutRewardFields, scoreOrigin } from './reward'\nimport {\n assertMinted,\n type ChatMessage,\n type MintedRolloutLine,\n ROLLOUT_SCHEMA,\n type RolloutEvidenceAttempt,\n type RolloutRole,\n type RolloutSplit,\n type RolloutStep,\n type ToolDef,\n} from './schema'\nimport { requireToolLinkage } from './transcript'\n\n/** Redactor for transcript/step payload text (secrets, PII), not opaque identity. */\nexport type RolloutScrubber = (text: string) => string\n\n/** A search cell's place in its search tree, read from the search ledger. */\nexport interface RolloutSearchLineage {\n /** Edges between the cell's node and the search root; the root is 0. */\n depth: number\n /** Order in which the node registered in its search; the root is 0. */\n ordinal: number\n /** Repeat index of the cell on its task, from 0. */\n rep: number\n /** Run id of the cell whose execution contains this search; null for a\n * top-level search. */\n containingRunId: string | null\n}\n\nexport interface MintRolloutOptions {\n scrub?: RolloutScrubber\n /**\n * Full canonical capture, including turns no longer in the model's context.\n * When supplied, missing/empty capture is refused, never replaced with a\n * span summary. Use the execution owner's capture or the existing harness\n * readers; reviewer traces and compacted histories are not full capture.\n */\n messagesOf?: (\n runId: string,\n ) => readonly ChatMessage[] | undefined | Promise<readonly ChatMessage[] | undefined>\n /** Tool schemas captured at the same invocation; never reconstructed from tool calls. */\n toolDefsOf?: (\n runId: string,\n ) => readonly ToolDef[] | undefined | Promise<readonly ToolDef[] | undefined>\n /** Provider attempts from a retained receipt bound to the exact run. */\n evidenceOf?: (\n runId: string,\n ) =>\n | { runId: string; attempts: readonly RolloutEvidenceAttempt[] }\n | undefined\n | Promise<{ runId: string; attempts: readonly RolloutEvidenceAttempt[] } | undefined>\n /** Cap steps per line (longest runs first drop middle steps). Default: no cap. */\n maxSteps?: number\n /** Role recorded on every minted line. Default 'agent' (a solo eval run). */\n role?: RolloutRole\n /** Task suite label. Default: the record's `experimentId`. */\n suite?: string\n /** Injected clock for deterministic output. */\n now?: () => Date\n /**\n * Lineage of a search run, read from its search ledger. It fills the line's\n * `generation` (node depth), `candidate_index` (node order), `task.rep` and\n * `parent_rollout_id` (the containing cell's run). Mint refuses a record\n * that carries `search` when this is absent, because a null `generation`\n * states that the run is not part of a search.\n */\n searchLineage?: (\n search: RunSearchCoordinates,\n ) => RolloutSearchLineage | Promise<RolloutSearchLineage>\n}\n\nexport interface MintRolloutResult {\n rows: MintedRolloutLine[]\n /** runIds that had a RunRecord but no spans — emitted as gap lines AND listed here. */\n missingTraces: string[]\n}\n\nconst asText = (v: unknown, scrub: RolloutScrubber): string => {\n const s = typeof v === 'string' ? v : JSON.stringify(v)\n return scrub(s ?? '')\n}\n\nfunction projectStep(span: Span, scrub: RolloutScrubber): RolloutStep {\n const base: RolloutStep = {\n kind: span.kind,\n name: scrub(span.name),\n status: span.status,\n durationMs: span.endedAt !== undefined ? span.endedAt - span.startedAt : undefined,\n }\n if (span.kind === 'llm') {\n const llm = span as LlmSpan\n const last = llm.messages[llm.messages.length - 1]\n if (last && last.content !== null) base.input = scrub(last.content)\n if (llm.output !== undefined) base.output = scrub(llm.output)\n } else if (span.kind === 'tool') {\n const tool = span as ToolSpan\n base.input = asText(tool.args, scrub)\n if (tool.result !== undefined) base.output = asText(tool.result, scrub)\n }\n return base\n}\n\n/** Preserve captured fields; invocation ids are opaque linkage, not generated text. */\nfunction projectMessage(message: ChatMessage, scrub: RolloutScrubber): ChatMessage {\n return {\n role: message.role,\n content: message.content === null ? null : scrub(message.content),\n ...(message.reasoning_content !== undefined\n ? { reasoning_content: scrub(message.reasoning_content) }\n : {}),\n ...(message.tool_calls !== undefined\n ? {\n tool_calls: message.tool_calls.map((call) => ({\n id: call.id,\n type: call.type,\n function: {\n name: call.function.name,\n arguments: scrub(call.function.arguments),\n },\n })),\n }\n : {}),\n ...(message.tool_call_id !== undefined ? { tool_call_id: message.tool_call_id } : {}),\n ...(message.name !== undefined ? { name: message.name } : {}),\n ...(message.is_copied_context !== undefined\n ? { is_copied_context: message.is_copied_context }\n : {}),\n }\n}\n\n/** Legacy span history; callers with compacted contexts supply messagesOf instead. */\nfunction finalConversation(spans: Span[]): ChatMessage[] {\n const llms = spans.filter((s): s is LlmSpan => s.kind === 'llm')\n const last = llms[llms.length - 1]\n if (!last) return []\n const messages: ChatMessage[] = [...last.messages]\n if (last.output !== undefined && last.output !== '') {\n messages.push({ role: 'assistant', content: last.output })\n }\n return messages\n}\n\n// The reward derivations live in the leaf module `./reward` so gate and\n// reporting code can import them without dragging in the trace store; they are\n// re-exported here because the derivations shipped from this path.\nexport {\n isRealnessGated,\n observedScore,\n observedSplitScore,\n type ScoreOrigin,\n type ScorePreference,\n scoreOrigin,\n trainingReward,\n trainingScore,\n} from './reward'\n\nconst REWARD_SOURCE: Record<ReturnType<typeof scoreOrigin>, string> = {\n holdout: 'run-record/holdout-score',\n search: 'run-record/search-score',\n unscored: 'run-record/unscored',\n}\n\n/**\n * The mint door refuses an execution-only record: a missing training label is\n * not a zero reward, and not a mintable line either. Lines that already carry\n * `reward: null` — interchange imports, existing ledgers — stay valid on the\n * wire and keep their labeled gap; this guard is only about the\n * RunRecord→line door, where the producer can still be told to go score the\n * run instead of shipping an unlabeled row.\n */\nfunction requireTaskScore(record: RunRecord): void {\n if (runTaskScore(record) === undefined) {\n throw new ValidationError(`Cannot mint rollout for run ${record.runId}: task score is missing`)\n }\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null\n\ninterface MintFieldCheck {\n /** The RunRecord path, spelled the way the caller has to fix it. */\n readonly field: string\n /** True when the record carries something the line can honestly be built from. */\n readonly present: (bag: Record<string, unknown>) => boolean\n /** What the caller writes onto the record, and why that value and not another. */\n readonly remedy: string\n}\n\n/**\n * The RunRecord fields mint reads that a record can be missing even though the\n * TYPE says it cannot. There are exactly two ways that happens:\n *\n * 1. The field was OPTIONAL when the record was serialized. `costProvenance`,\n * `terminalOutcome` and `scenarioId` were optional through agent-eval\n * 0.125 and became required in 0.126, with no on-disk migration — so every\n * ledger written before 0.126 is full of records the type calls complete.\n * 2. Mint reads a level DEEPER than the record's own type is checked at:\n * `outcome.raw`, `tokenUsage.input`, `tokenUsage.output`.\n *\n * Nothing else needs a check here. Every other field mint copies is a top-level\n * scalar landing in a typed slot on the line, where an absent value arrives as\n * `undefined` and `assertMinted` refuses it by name. These are the ones where an\n * absent value instead kills the join with `TypeError: Cannot read properties of\n * undefined`, or — worse — mints a line that reads as measured.\n *\n * This is deliberately NOT `validateRunRecord`. That validator answers \"is this\n * a valid RunRecord\", which is a wider question than \"can a rollout line be\n * built from this one\": it also enforces model-snapshot discipline, the\n * `terminalFailureReason` coupling, and the `costUsd === costProvenance.usd`\n * agreement. Routing the mint door through it would refuse records mint can\n * mint honestly today (a model alias with no snapshot date, for one), which is\n * a policy change with its own blast radius and not this bug. The door asks the\n * narrower question and answers it precisely.\n */\nconst MINT_FIELD_CHECKS: readonly MintFieldCheck[] = [\n {\n field: 'costProvenance',\n present: (bag) => isObject(bag.costProvenance) && typeof bag.costProvenance.kind === 'string',\n remedy:\n \"Records written before agent-eval 0.126 predate this field and carry `costUsd: 0` as the documented uncaptured sentinel, which is NOT an observed zero. Backfill it as costProvenance: { kind: 'uncaptured', usd: null } WITH costUsd: null — an uncaptured cost whose costUsd is non-null is rejected by validateRunRecord, so provenance alone leaves the record invalid.\",\n },\n {\n field: 'tokenUsage',\n present: (bag) => isObject(bag.tokenUsage),\n remedy:\n \"The line's cost.tokens_in and cost.tokens_out are read from it. Backfill it from the provider's usage report; mint will not write 0 for tokens nobody counted.\",\n },\n {\n field: 'tokenUsage.input',\n present: (bag) => !isObject(bag.tokenUsage) || typeof bag.tokenUsage.input === 'number',\n remedy: \"The line's cost.tokens_in is read from it, and a missing count is not a zero count.\",\n },\n {\n field: 'tokenUsage.output',\n present: (bag) => !isObject(bag.tokenUsage) || typeof bag.tokenUsage.output === 'number',\n remedy: \"The line's cost.tokens_out is read from it, and a missing count is not a zero count.\",\n },\n {\n field: 'outcome',\n present: (bag) => isObject(bag.outcome),\n remedy:\n \"The line's reward, reward_source and metrics are all read from it. A record with no outcome carries no training label at all, and mint refuses an unlabeled row.\",\n },\n {\n field: 'outcome.raw',\n // Reported only when `outcome` itself is present: one absent field should\n // produce one reason per CAUSE, not one per path that dereferences it.\n present: (bag) => !isObject(bag.outcome) || isObject(bag.outcome.raw),\n remedy:\n 'It is the metric bag copied verbatim into the line\\'s outcome.metrics. `{ ...undefined }` spreads to `{}` without complaint, so an absent bag would mint as \"this run reported no metrics\" — a different claim from \"this record predates the field\". Backfill it as {} only when that is what you mean.',\n },\n {\n field: 'terminalOutcome',\n present: (bag) => typeof bag.terminalOutcome === 'string',\n remedy:\n \"It became required in agent-eval 0.126. Backfill it from root-run or process evidence, or as 'unknown' when the producer has none — mint will not decide the line's is_completed and is_truncated for you.\",\n },\n {\n field: 'scenarioId',\n present: (bag) => typeof bag.scenarioId === 'string' && bag.scenarioId.length > 0,\n remedy:\n \"It became required in agent-eval 0.126 and becomes the line's task.instance_id, which must be a non-empty string. Backfill it from the scenario the run was dealt (pre-0.126 producers often left it in outcome.raw.scenario_id).\",\n },\n]\n\n/**\n * Why a record cannot be minted, one entry per missing field, empty when it can.\n *\n * Exported so a caller can partition a whole ledger — \"which of my 2742 records\n * predate 0.126\" — without catching an exception per record, and without\n * re-deriving the field list on their side. A re-derived list is a list that\n * drifts from the door it is supposed to predict.\n *\n * Takes a `RunRecord` because that is what the caller holds and what the\n * compiler agrees they hold. The type is precisely the thing that is wrong, so\n * the checks read the record as the untyped bag it actually is on disk.\n */\nexport function unmintableReasons(record: RunRecord): string[] {\n const bag = record as unknown as Record<string, unknown>\n return MINT_FIELD_CHECKS.filter((check) => !check.present(bag)).map(\n (check) => `${check.field} is missing. ${check.remedy}`,\n )\n}\n\n/**\n * The mint door THROWS on a record it cannot build a line from. It does NOT\n * normalise an absent `costProvenance` to `{kind:'uncaptured', usd:null}`, and\n * the choice is not stylistic:\n *\n * - Normalising cannot cover the record, only part of it. `terminalOutcome`\n * feeds `is_completed` and `is_truncated`, which the rollout schema requires\n * to be BOOLEAN — there is no null to fall back to, so every possible\n * default is a claim about how the run ended. A door that quietly fixes the\n * cost and invents the ending is a door no caller can predict.\n * - Normalising the cost requires knowing what `costUsd: 0` meant, and mint\n * cannot know. A genuinely free run and an uncaptured one are the same bytes\n * in a pre-0.126 record; only the producer can tell them apart. Guessing is\n * exactly the failure this guard exists to stop — the 0.125 optional chain\n * `record.costProvenance?.kind === 'uncaptured'` already made that guess,\n * silently, and every record it touched minted `cost.usd: 0`: an unmeasured\n * cost published as a measured zero, into a training dataset.\n * - `requireTaskScore`, directly above, already refuses an unlabeled record\n * for the same reason: \"nobody graded this\" is not \"graded zero\". \"Nobody\n * billed this\" is not \"billed zero\".\n *\n * The caller who wants historical records minted backfills them at their store,\n * in one pass, where `costUsd` can be corrected alongside `costProvenance` —\n * which is the only place that decision can be made correctly. The refusal names\n * the run, names every missing field, and spells the value to write.\n */\nfunction requireMintableRecord(record: RunRecord): void {\n const reasons = unmintableReasons(record)\n if (reasons.length === 0) return\n throw new ValidationError(`Cannot mint rollout for run ${record.runId}: ${reasons.join('\\n ')}`)\n}\n\n/** The search lineage a record's line is built from; undefined for a record outside a search. */\nasync function resolveSearchLineage(\n record: RunRecord,\n options: MintRolloutOptions,\n): Promise<RolloutSearchLineage | undefined> {\n if (record.search === undefined) return undefined\n const refuse: (detail: string) => never = (detail) => {\n throw new ValidationError(`Cannot mint rollout for search run ${record.runId}: ${detail}`)\n }\n if (!options.searchLineage) {\n refuse('pass searchLineage so generation, candidate_index, rep and parent come from its ledger')\n }\n const lineage = await options.searchLineage(record.search)\n const isCount = (value: unknown): boolean => Number.isSafeInteger(value) && (value as number) >= 0\n if (!isCount(lineage.depth)) refuse('lineage depth must be a non-negative integer')\n if (!isCount(lineage.ordinal)) refuse('lineage ordinal must be a non-negative integer')\n if (!isCount(lineage.rep)) refuse('lineage rep must be a non-negative integer')\n if (\n lineage.containingRunId !== null &&\n (typeof lineage.containingRunId !== 'string' || lineage.containingRunId.length === 0)\n ) {\n refuse('lineage containingRunId must be null or a non-empty run id')\n }\n if (lineage.containingRunId === record.runId) refuse('a run cannot contain itself')\n return lineage\n}\n\nconst SPLIT_FROM_TAG: Record<RunRecord['splitTag'], RolloutSplit> = {\n search: 'search',\n dev: 'dev',\n holdout: 'holdout',\n}\n\nfunction mintLine(\n record: RunRecord,\n lineage: RolloutSearchLineage | undefined,\n steps: RolloutStep[],\n messages: ChatMessage[],\n options: MintRolloutOptions,\n capturedAt: string,\n gap?: string,\n attempts?: readonly RolloutEvidenceAttempt[],\n lossyProjection = false,\n toolDefs: ToolDef[] = [],\n): MintedRolloutLine {\n // Field presence first, and BEFORE `requireTaskScore`: that guard reads\n // `record.outcome.searchScore` on its way to the answer, so an absent\n // `outcome` would throw a bare TypeError from inside the guard whose whole\n // job is to produce a clean refusal.\n //\n // Both branches of `mintRolloutRows` — the traced line and the gap line —\n // land here, which is the point: `mintLine` is the only constructor of a\n // `MintedRolloutLine` from a RunRecord, so there is no path into the waist\n // that skips the check and no way to get this wrong from the outside.\n requireMintableRecord(record)\n // A missing task score is refused before anything is built: an\n // execution-only record has no training label, and a missing label is\n // neither a zero reward nor a mintable row.\n requireTaskScore(record)\n // `reward` and `realness_gated` come out of one call, so neither door into\n // the waist can write one and forget the other.\n const rewardFields = rolloutRewardFields(record)\n // Only an observed or estimated amount is a total; a lower bound is not.\n const knownTotal =\n record.costProvenance.kind === 'observed' || record.costProvenance.kind === 'estimated'\n const terminalOutcome = record.terminalOutcome\n const isCompleted = terminalOutcome === 'succeeded' || terminalOutcome === 'failed'\n const isTruncated = terminalOutcome === 'cancelled' || terminalOutcome === 'incomplete'\n const terminalError =\n terminalOutcome === 'failed' ||\n terminalOutcome === 'cancelled' ||\n terminalOutcome === 'incomplete'\n ? (record.terminalFailureReason ?? `run ended ${terminalOutcome}`)\n : null\n // `assertMinted` rather than a cast: mint is the producer the whole gate\n // rests on, so it proves the line it just built is valid instead of asserting\n // it by fiat. The brand is unforgeable precisely because nobody casts to it.\n return assertMinted(\n {\n schema: ROLLOUT_SCHEMA,\n rollout_id: record.runId,\n parent_rollout_id: lineage?.containingRunId ?? null,\n run_id: record.runId,\n experiment_id: record.experimentId,\n candidate_id: record.candidateId,\n generation: lineage?.depth ?? null,\n candidate_index: lineage?.ordinal ?? null,\n role: options.role ?? 'agent',\n task: {\n suite: options.suite ?? record.experimentId,\n instance_id: record.scenarioId,\n split: SPLIT_FROM_TAG[record.splitTag],\n seed: record.seed,\n rep: lineage?.rep ?? 0,\n },\n policy: {\n harness: null,\n harness_version: null,\n model: record.model,\n provider: null,\n profile_commit: record.commitSha,\n prompt_hash: record.promptHash,\n config_hash: record.configHash,\n agent_profile_cell_id: record.agentProfile?.cellId ?? null,\n sampling: null,\n },\n messages,\n tool_defs: toolDefs,\n ...(steps.length > 0 ? { steps } : {}),\n outcome: {\n ...rewardFields,\n reward_source: REWARD_SOURCE[scoreOrigin(record)],\n verdict: null,\n // A verbatim bulk copy, deliberately UNFILTERED here. `outcome.raw`\n // holds the per-layer verifier scores (`layer.*`) that the reward was\n // derived from, so on a gated run this dict is the reward signal in\n // component form — but filtering it at this call site is the pattern\n // that has now leaked twice, because the next producer to write a\n // reward-bearing field forgets. The gate is applied to the whole\n // outcome once, in `assertMinted` below (`gateGamedOutcome`), which\n // moves the block to `provenance.gated_evidence` when the run is gated\n // and leaves it here untouched when it is not.\n metrics: { ...record.outcome.raw },\n is_completed: isCompleted,\n is_truncated: isTruncated,\n error: terminalError,\n },\n cost: {\n usd: knownTotal ? record.costUsd : null,\n tokens_in: record.tokenUsage.input,\n tokens_out: record.tokenUsage.output,\n tokens_reasoning: record.tokenUsage.reasoning ?? null,\n cache_read: record.tokenUsage.cached ?? null,\n cache_write: record.tokenUsage.cacheWrite ?? null,\n wall_s: Math.round(record.wallMs / 1000),\n },\n artifacts: {\n patch_path: null,\n run_dir: null,\n transcript_ref: record.traceRef ? `trace:${record.traceRef.traceId}` : null,\n },\n provenance: {\n captured_at: capturedAt,\n capture: 'mint',\n ...(record.search !== undefined ? { search: { ...record.search } } : {}),\n ...(attempts !== undefined ? { attempts: [...attempts] } : {}),\n ...(lossyProjection ? { lossy_projection: true } : {}),\n ...(gap !== undefined ? { gap } : {}),\n },\n },\n `minted rollout line for run ${record.runId}`,\n )\n}\n\n/**\n * Join RunRecords with their traces into canonical rollout lines. Records\n * without spans or an explicit capture are emitted as labeled gap lines and reported in\n * `missingTraces`. Execution-only records without a task score are rejected\n * because a missing training label is not a zero reward.\n */\nexport async function mintRolloutRows(\n records: RunRecord[],\n store: TraceStore,\n options: MintRolloutOptions = {},\n): Promise<MintRolloutResult> {\n const scrub = options.scrub ?? ((t) => t)\n const capturedAt = (options.now?.() ?? new Date()).toISOString()\n if (\n options.maxSteps !== undefined &&\n (!Number.isSafeInteger(options.maxSteps) || options.maxSteps < 1)\n ) {\n throw new ValidationError('maxSteps must be a positive integer')\n }\n const rows: MintedRolloutLine[] = []\n const missingTraces: string[] = []\n for (const record of records) {\n const trajectory = await buildTrajectory(store, record.runId)\n const captured = options.messagesOf ? await options.messagesOf(record.runId) : undefined\n const tools = options.toolDefsOf ? await options.toolDefsOf(record.runId) : []\n if (!Array.isArray(tools))\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: declared tool definitions are missing`,\n )\n const toolDefs: ToolDef[] = JSON.parse(canonicalString(jsonDocument(tools)))\n const evidence = options.evidenceOf ? await options.evidenceOf(record.runId) : undefined\n if (evidence !== undefined && evidence?.runId !== record.runId) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: capture evidence belongs to another run`,\n )\n }\n if (\n options.evidenceOf &&\n (!evidence || !Array.isArray(evidence.attempts) || evidence.attempts.length === 0)\n ) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: provider attempt evidence is missing`,\n )\n }\n if (\n evidence?.attempts.some(\n (attempt) =>\n !attempt ||\n !Array.isArray(attempt.nativeSessionIds) ||\n !Array.isArray(attempt.processIds) ||\n !Array.isArray(attempt.missingReasons),\n )\n ) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: malformed provider attempt evidence`,\n )\n }\n const attempts = evidence?.attempts.map((attempt) => ({\n ...attempt,\n nativeSessionIds: [...attempt.nativeSessionIds],\n processIds: [...attempt.processIds],\n missingReasons: attempt.missingReasons.map(scrub),\n }))\n if (options.messagesOf && (!Array.isArray(captured) || captured.length === 0)) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: full capture is missing`,\n )\n }\n const lineage = await resolveSearchLineage(record, options)\n if (trajectory.steps.length === 0 && !options.messagesOf) {\n missingTraces.push(record.runId)\n rows.push(\n mintLine(\n record,\n lineage,\n [],\n [],\n options,\n capturedAt,\n 'no trace spans recorded for this runId',\n attempts,\n false,\n toolDefs,\n ),\n )\n continue\n }\n let steps = trajectory.steps.map((s) => projectStep(s.span, scrub))\n const omittedSteps =\n options.maxSteps !== undefined && steps.length > options.maxSteps\n ? steps.length - options.maxSteps\n : 0\n if (options.maxSteps !== undefined && omittedSteps > 0) {\n // Keep the head and tail — the middle of a long run is the least\n // informative for outcome attribution.\n const head = Math.ceil(options.maxSteps / 2)\n const tail = options.maxSteps - head\n steps = [...steps.slice(0, head), ...steps.slice(steps.length - tail)]\n }\n const spans = trajectory.steps.map((s) => s.span)\n const messages = captured ?? finalConversation(spans)\n requireToolLinkage(messages, `Cannot mint rollout for run ${record.runId}`)\n const conversation = messages.map((message) => projectMessage(message, scrub))\n const gaps: string[] = []\n if (conversation.length === 0) gaps.push('trace has no llm spans; no conversation to inline')\n else if (!options.messagesOf) {\n gaps.push('messages project only the last LLM context; full transcript was not captured')\n }\n if (omittedSteps > 0) gaps.push(`${omittedSteps} middle trace steps omitted by maxSteps`)\n for (const attempt of attempts ?? []) {\n if (attempt.missingReasons.length > 0) {\n gaps.push(`provider attempt ${attempt.ordinal}: ${attempt.missingReasons.join(', ')}`)\n }\n }\n rows.push(\n mintLine(\n record,\n lineage,\n steps,\n conversation,\n options,\n capturedAt,\n gaps.length > 0 ? gaps.join('; ') : undefined,\n attempts,\n (conversation.length > 0 && !options.messagesOf) ||\n omittedSteps > 0 ||\n (attempts?.some((attempt) => attemp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ACA,SACA,YACA,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAA,GACpC,UACC,aAAa,SAAS,KAAK,CAAC,QAAQ,cACnC,eAAe,MACd,UAAU,MAAM,YAAY,QAAQ,eAAe,SAAS,CAAC,KAAK,QACrE,QACF,CACF;CACF;CACA,OAAO;EAAE;EAAM;CAAc;AAC/B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rollout-DDMkK_Lw.js","names":[],"sources":["../src/rollout/harbor-task.ts","../src/rollout/interchange/harbor.ts","../src/rollout/readers/claude-jsonl.ts","../src/rollout/readers/codex-rollout.ts","../src/rollout/readers/opencode-sqlite.ts","../src/rollout/tinker.ts"],"sourcesContent":["import { createHash } from 'node:crypto'\nimport {\n link,\n lstat,\n mkdir,\n readdir,\n readFile,\n realpath,\n unlink,\n writeFile,\n} from 'node:fs/promises'\nimport { dirname, join, resolve } from 'node:path'\n\nimport { assertCodeSurfaceIdentity } from '../campaign/surface-identity'\nimport type { CodeSurface } from '../campaign/types'\nimport { type CompletionVerdict, completionVerdict } from '../completion-verifier'\nimport { canonicalString } from '../ledger-core/canonical'\nimport { deepFreezeCanonicalJson } from '../ledger-core/deep-freeze'\nimport { assertMinted, type MintedRolloutLine } from './schema'\n\n/** Existing completion checks required to admit a verified episode as a runnable task. */\nexport const HARBOR_TASK_CHECKS = [\n 'base-bundle',\n 'acceptance',\n 'production-delta',\n 'dangling-references',\n 'merge-followup',\n] as const\n\nexport interface HarborTaskFile {\n /** Relative path in the published task. */\n readonly path: string\n /** Actual staged path; task.toml is not published until verification succeeds. */\n readonly stagedPath: string\n readonly sha256: string\n readonly byteLength: number\n}\n\nexport interface HarborTaskVerification {\n /** Digest binding this episode, immutable source identity, merge and every task file. */\n readonly taskId: string\n readonly rolloutId: string\n readonly episodeSha256: string\n readonly task: MintedRolloutLine['task']\n readonly source: Omit<CodeSurface, 'worktreeRef' | 'summary' | 'baseRef'>\n readonly mergeCommit: string\n readonly files: readonly HarborTaskFile[]\n}\n\nexport interface WriteHarborTaskOptions {\n /** Fresh task directory, normally <dataset>/tasks/<task>. Existing paths are refused. */\n readonly directory: string\n readonly episode: MintedRolloutLine\n readonly surface: CodeSurface\n readonly mergeCommit: string\n /** Harbor's org/name task name. */\n readonly name: string\n readonly instruction: string\n /** Caller image with Git/dependencies and a configured user able to clone into /workspace. */\n readonly image: string\n /** Git bundle containing the base and its ancestors only, never the answer/head/merge. */\n readonly baseBundle: Uint8Array\n readonly commands: {\n readonly acceptance: string\n readonly productionDelta: string\n readonly danglingReferences: string\n }\n readonly agentTimeoutSec: number\n readonly verifierTimeoutSec: number\n /**\n * Trusted caller execution boundary. Inspect the actual staged bundle and file hashes.\n * base-bundle proves exact base/tree, base-only closure and no answer material; the\n * three verifier checks prove the supplied commands actually passed on this candidate\n * (strict production-line decrease, zero dangling refs); merge-followup proves this\n * candidate merged with base=merge^1 and a closed, explicitly checked no-fix-forward\n * followup window. Every check must cite receipts bound to taskId, not a title/keyword.\n * Unknown, absent, open followup and provider eligibility are not affirmative evidence.\n */\n readonly verify: (\n request: HarborTaskVerification,\n signal?: AbortSignal,\n ) => Promise<CompletionVerdict>\n readonly signal?: AbortSignal\n}\n\nconst digest = (bytes: Uint8Array | string): string =>\n `sha256:${createHash('sha256').update(bytes).digest('hex')}`\n\nfunction admitted(verdict: CompletionVerdict, taskId: string): void {\n if (verdict.taskId !== taskId) throw new Error('Harbor task verification identity mismatch')\n if (!Array.isArray(verdict.requirements))\n throw new Error('Harbor task requires completion checks')\n for (const row of verdict.requirements) {\n if (\n !row ||\n typeof row.reqId !== 'string' ||\n !row.reqId.trim() ||\n row.correct !== true ||\n row.structurallyPresent !== true ||\n row.satisfied !== true ||\n row.unmeasured !== undefined ||\n !Array.isArray(row.evidence) ||\n !row.evidence.some((value) => typeof value === 'string' && value.trim().length > 0)\n ) {\n throw new Error(`Harbor task requires measured passing ${row?.reqId ?? 'invalid'} evidence`)\n }\n }\n for (const id of HARBOR_TASK_CHECKS) {\n if (verdict.requirements.filter((row) => row.reqId === id).length !== 1) {\n throw new Error(`Harbor task requires exactly one ${id} check`)\n }\n }\n const derived = completionVerdict({ taskId, requirements: verdict.requirements })\n if (\n derived.fullyComplete !== true ||\n verdict.fullyComplete !== true ||\n verdict.valid !== true ||\n verdict.score !== 1 ||\n verdict.completionRate !== 1 ||\n verdict.unmeasuredCount !== 0\n ) {\n throw new Error('Harbor task verification is incomplete')\n }\n}\n\n/**\n * Write a Harbor directory from an admitted canonical episode, without executing it.\n * Failed admission leaves diagnostic files but no task.toml, so the directory is not\n * loadable as a task. The caller owns execution, receipt truth and artifact retention.\n */\nexport async function writeHarborTask(options: WriteHarborTaskOptions): Promise<string> {\n // Capture inputs before the first await; the callback cannot retarget caller-owned data.\n const episode = assertMinted(JSON.parse(canonicalString(options.episode)), 'Harbor task episode')\n const surface = JSON.parse(canonicalString(options.surface)) as CodeSurface\n assertCodeSurfaceIdentity(surface)\n const { kind, baseCommit, baseTree, candidateCommit, candidateTree, patch } = surface\n const source = { kind, baseCommit, baseTree, candidateCommit, candidateTree, patch }\n const {\n directory: inputDirectory,\n name,\n instruction,\n image,\n mergeCommit,\n agentTimeoutSec,\n verifierTimeoutSec,\n verify,\n signal,\n } = options\n const commands = { ...options.commands }\n const bundle = Uint8Array.from(options.baseBundle)\n if (\n episode.outcome.reward !== 1 ||\n !episode.outcome.is_completed ||\n episode.outcome.is_truncated ||\n episode.outcome.error !== null ||\n episode.outcome.realness_screened !== true ||\n episode.outcome.realness_gated === true\n ) {\n throw new Error('Harbor task requires a completed, screened, passing episode')\n }\n if (!/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(mergeCommit)) {\n throw new Error('Harbor task requires a full merge commit identity')\n }\n if (\n !/^[a-zA-Z0-9][a-zA-Z0-9._-]*\\/[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(name) ||\n !instruction.trim() ||\n !bundle.length\n )\n throw new Error('Invalid Harbor task input')\n if (!/^[a-zA-Z0-9][a-zA-Z0-9./:_-]*@sha256:[a-f0-9]{64}$/.test(image)) {\n throw new Error('Harbor task image must be pinned by sha256 digest')\n }\n for (const timeout of [agentTimeoutSec, verifierTimeoutSec]) {\n if (!Number.isSafeInteger(timeout) || timeout <= 0) throw new Error('Invalid Harbor timeout')\n }\n if (Object.values(commands).some((command) => typeof command !== 'string' || !command.trim())) {\n throw new Error('All three Harbor verifier commands are required')\n }\n const config =\n `schema_version = \"1.3\"\\n[task]\\nname = \"${name}\"\\n` +\n `[agent]\\ntimeout_sec = ${agentTimeoutSec}\\n[verifier]\\ntimeout_sec = ${verifierTimeoutSec}\\n`\n const files: Record<string, string | Uint8Array> = {\n 'task.toml': config,\n 'instruction.md': instruction,\n 'environment/base.bundle': bundle,\n 'environment/Dockerfile':\n `FROM ${image}\\nCOPY --chmod=0444 base.bundle /tmp/base.bundle\\n` +\n `RUN git clone --no-checkout /tmp/base.bundle /workspace/repo \\\\\\n && git -C /workspace/repo checkout --detach ${baseCommit} \\\\\\n && test \"$(git -C /workspace/repo rev-parse HEAD)\" = \"${baseCommit}\"\\nWORKDIR /workspace/repo\\n`,\n 'tests/acceptance.sh': commands.acceptance,\n 'tests/production-delta.sh': commands.productionDelta,\n 'tests/dangling-references.sh': commands.danglingReferences,\n 'tests/test.sh':\n '#!/bin/sh\\nset -eu\\nproject=${1:-/workspace/repo}\\n' +\n 'tests=${2:-/tests}\\nrewards=${3:-/logs/verifier}\\nmkdir -p \"$rewards\"\\n' +\n 'printf \"0\\\\n\" > \"$rewards/reward.txt\"\\ncd \"$project\"\\n' +\n `git cat-file -e ${baseCommit}^{commit}\\ngit merge-base --is-ancestor ${baseCommit} HEAD\\n` +\n 'sh \"$tests/acceptance.sh\"\\nsh \"$tests/production-delta.sh\"\\nsh \"$tests/dangling-references.sh\"\\n' +\n 'printf \"1\\\\n\" > \"$rewards/reward.txt\"\\n',\n }\n const directory = resolve(inputDirectory)\n signal?.throwIfAborted()\n if ((await realpath(dirname(directory))) !== dirname(directory)) {\n throw new Error('Harbor task parent must not traverse symlinks')\n }\n await mkdir(directory, { mode: 0o700 })\n await mkdir(join(directory, 'environment'))\n await mkdir(join(directory, 'tests'))\n const staged: HarborTaskFile[] = []\n for (const [path, bytes] of Object.entries(files)) {\n const stagedPath = join(directory, path === 'task.toml' ? '.task.toml.pending' : path)\n await writeFile(stagedPath, bytes, { flag: 'wx', mode: path.endsWith('.sh') ? 0o700 : 0o600 })\n staged.push(\n Object.freeze({\n path,\n stagedPath,\n sha256: digest(bytes),\n byteLength: typeof bytes === 'string' ? Buffer.byteLength(bytes) : bytes.byteLength,\n }),\n )\n }\n const identity = {\n rolloutId: episode.rollout_id,\n episodeSha256: digest(canonicalString(episode)),\n task: episode.task,\n source,\n mergeCommit,\n files: staged.map(({ path, sha256, byteLength }) => ({ path, sha256, byteLength })),\n }\n const taskId = digest(canonicalString(identity))\n const request = deepFreezeCanonicalJson({ ...identity, taskId, files: staged })\n signal?.throwIfAborted()\n const verdict = JSON.parse(canonicalString(await verify(request, signal))) as CompletionVerdict\n signal?.throwIfAborted()\n admitted(verdict, taskId)\n // No callback may add answer material to the build context or redirect a parent directory.\n for (const folder of ['', 'environment', 'tests']) {\n const path = join(directory, folder)\n if (!(await lstat(path)).isDirectory() || (await realpath(path)) !== path) {\n throw new Error('Harbor task directory changed during verification')\n }\n const expected =\n folder === ''\n ? ['.task.toml.pending', 'environment', 'instruction.md', 'tests']\n : Object.keys(files)\n .filter((file) => file.startsWith(`${folder}/`))\n .map((file) => file.slice(folder.length + 1))\n if (canonicalString((await readdir(path)).sort()) !== canonicalString(expected.sort())) {\n throw new Error('Harbor task contains unexpected files')\n }\n }\n for (const file of staged) {\n const info = await lstat(file.stagedPath)\n if (\n !info.isFile() ||\n info.isSymbolicLink() ||\n digest(await readFile(file.stagedPath)) !== file.sha256\n ) {\n throw new Error(`Harbor task file changed during verification: ${file.path}`)\n }\n }\n await writeFile(\n join(directory, 'tests/verification.json'),\n canonicalString({ identity, taskId, verdict }),\n { flag: 'wx', mode: 0o600 },\n )\n signal?.throwIfAborted()\n await link(join(directory, '.task.toml.pending'), join(directory, 'task.toml'))\n await unlink(join(directory, '.task.toml.pending'))\n return directory\n}\n","/**\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 */\nfunction 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 * Codex rollout JSONL through the shared native-session reader. This module\n * projects its result onto rollout messages; it never parses native records,\n * discovers stores, judges an outcome, or makes an imported capture trainable.\n */\nimport {\n codexReader,\n codexRefForFile,\n type HarnessSession,\n type ReadOptions,\n readSessionInput,\n type SessionInputInit,\n toChatMessages,\n} from '@tangle-network/harness-sessions'\nimport type { ChatMessage } from '../schema'\n\n/** Normalized source evidence, with the existing canonical message projection. */\nexport type CodexRollout = Pick<\n HarnessSession,\n | 'nativeSessionId'\n | 'parentNativeSessionId'\n | 'startedAt'\n | 'endedAt'\n | 'usage'\n | 'ending'\n | 'integrity'\n | 'modelSource'\n> & {\n messages: ChatMessage[]\n /** Null when only turn_context names a model; that is configuration, not a response. */\n model: string | null\n requestedModel: string | null\n}\n\nfunction rolloutFromSession(session: HarnessSession): CodexRollout {\n const answered = session.modelCalls.filter((call) => call.error === null)\n const trustedModel =\n session.modelSource === 'provider-response' || session.modelSource === 'session-record'\n return {\n nativeSessionId: session.nativeSessionId,\n parentNativeSessionId: session.parentNativeSessionId,\n messages: toChatMessages(session),\n usage: session.usage,\n startedAt: session.startedAt,\n endedAt: session.endedAt,\n model: trustedModel\n ? ([...answered].reverse().find((call) => call.servedModel !== null)?.servedModel ?? null)\n : null,\n requestedModel:\n [...session.modelCalls].reverse().find((call) => call.requestedModel !== null)\n ?.requestedModel ?? null,\n modelSource: session.modelSource,\n ending: session.ending,\n integrity: session.integrity,\n }\n}\n\n/** Read one already-resolved native file; strict/recover behavior belongs to the SDK. */\nexport async function readCodexRollout(\n path: string,\n options: ReadOptions = {},\n): Promise<CodexRollout> {\n return rolloutFromSession(await codexReader.read(codexRefForFile(path), options))\n}\n\n/** Parse retained text through the same SDK fold, retaining source hashes and gaps. */\nexport function parseCodexRollout(\n raw: string,\n source: SessionInputInit = {},\n options: Pick<ReadOptions, 'corruption'> = {},\n): CodexRollout {\n return rolloutFromSession(readSessionInput('codex', { text: raw }, source, options))\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","/** Tinker RL Datum projection of the canonical rollout waist; no client or training loop. */\nimport { assessShareSafety, shareAllowed } from '../trace/redact'\nimport { defaultRolloutScrubber } from './release/scrub'\nimport { assertMinted, assertRewardGate, type MintedRolloutLine, type RolloutStep } from './schema'\nimport { type TrainingExportOptions, trainingAdmission } from './training-admission'\n\n/** JSON wire projection of Tinker's text-only Datum; the consumer constructs SDK objects. */\nexport interface TinkerDatum {\n model_input: { chunks: Array<{ type: 'encoded_text'; tokens: number[] }> }\n loss_fn_inputs: {\n target_tokens: { data: number[]; dtype: 'int64'; shape: [number] }\n logprobs: { data: number[]; dtype: 'float32'; shape: [number] }\n advantages: { data: number[]; dtype: 'float32'; shape: [number] }\n }\n}\n\nexport interface TinkerDatumRow {\n /** Only this object goes to the Tinker SDK. Attribution stays with the caller. */\n datum: TinkerDatum\n rollout_id: string\n run_id: string\n instance_id: string\n step_index: number\n reward: number\n realness_gated: false\n realness_screened: boolean | null\n}\n\nexport interface TinkerExportOptions\n extends Pick<\n TrainingExportOptions,\n 'allowHeldOutTrainingData' | 'allowLicenseClasses' | 'onAdmission'\n > {\n /** Exact model identity of the captured tokenizer/sampling policy. */\n model: string\n /** Offline decoder for that model. Never re-tokenize or fabricate missing sampling data. */\n decodeTokens: (tokens: readonly number[]) => string\n /** Caller owns group baselines; a reward is not silently treated as an advantage. */\n advantageOf: (line: MintedRolloutLine, stepIndex: number) => number\n}\n\nfunction safeText(text: string, context: string): void {\n // Scrubbing text while retaining its original token ids would transmit the very bytes removed.\n if (\n defaultRolloutScrubber(text) !== text ||\n !shareAllowed(assessShareSafety(text, { profile: 'share' }))\n ) {\n throw new Error(`Tinker export: ${context} needs scrubbing; recapture approved token data`)\n }\n}\n\nfunction tokenIds(tokens: number[] | undefined, context: string): number[] {\n if (!tokens?.length || tokens.some((id) => !Number.isSafeInteger(id) || id < 0)) {\n throw new Error(`Tinker export: ${context} requires captured nonempty token ids`)\n }\n return [...tokens]\n}\n\nfunction projectStep(\n step: RolloutStep,\n line: MintedRolloutLine,\n stepIndex: number,\n options: TinkerExportOptions,\n): TinkerDatumRow {\n if (step.llm_call_count !== 1) {\n throw new Error(\n `Tinker export: ${line.rollout_id} step ${stepIndex} must name one captured model call`,\n )\n }\n const prompt = tokenIds(step.prompt_token_ids, 'prompt')\n const completion = tokenIds(step.completion_token_ids, 'completion')\n const logprobs = step.logprobs === undefined ? undefined : [...step.logprobs]\n if (\n !logprobs ||\n logprobs.length !== completion.length ||\n logprobs.some((p) => !Number.isFinite(Math.fround(p)) || p > 0)\n ) {\n throw new Error(\n `Tinker export: ${line.rollout_id} step ${stepIndex} needs aligned sampling logprobs`,\n )\n }\n safeText(options.decodeTokens(prompt), 'decoded prompt')\n safeText(options.decodeTokens(completion), 'decoded completion')\n const advantage = options.advantageOf(line, stepIndex)\n if (\n typeof advantage !== 'number' ||\n !Number.isFinite(advantage) ||\n !Number.isFinite(Math.fround(advantage))\n ) {\n throw new Error('Tinker export: advantage must be a finite number that fits float32')\n }\n const full = [...prompt, ...completion]\n safeText(options.decodeTokens(full), 'decoded sequence')\n const prefix = Array<number>(prompt.length - 1).fill(0)\n const length = full.length - 1\n return {\n datum: {\n model_input: { chunks: [{ type: 'encoded_text', tokens: full.slice(0, -1) }] },\n loss_fn_inputs: {\n target_tokens: { data: full.slice(1), dtype: 'int64', shape: [length] },\n logprobs: { data: [...prefix, ...logprobs], dtype: 'float32', shape: [length] },\n advantages: {\n data: [...prefix, ...completion.map(() => advantage)],\n dtype: 'float32',\n shape: [length],\n },\n },\n },\n rollout_id: line.rollout_id,\n run_id: line.run_id,\n instance_id: line.task.instance_id,\n step_index: stepIndex,\n reward: line.outcome.reward!,\n realness_gated: false,\n realness_screened: line.outcome.realness_screened ?? null,\n }\n}\n\n/**\n * Project known-reward completed search rollouts, including honest zero/negative rewards.\n * Unknown rewards, gated/lossy/incomplete runs and ineligible splits do not become training data.\n * Missing capture on an otherwise eligible model call refuses the batch, never invents tokens.\n * The caller retains the canonical ledger and owns Tinker sampling/forward_backward/optim_step.\n */\nexport function toTinkerDatumRows(\n lines: readonly MintedRolloutLine[],\n options: TinkerExportOptions,\n): TinkerDatumRow[] {\n if (!options.model) throw new Error('Tinker export: captured model identity is required')\n const rows: TinkerDatumRow[] = []\n const identities = new Set<string>()\n for (const supplied of lines) {\n const line = assertMinted(supplied, 'Tinker rollout')\n assertRewardGate(line, 'Tinker export')\n if (identities.has(line.rollout_id))\n throw new Error(`Tinker export: duplicate rollout ${line.rollout_id}`)\n identities.add(line.rollout_id)\n const admission = trainingAdmission(line, 'preference', { ...options, onAdmission: undefined })\n // Token-level policy gradients require a finished, error-free sampled action sequence.\n if (admission.reason === null && line.outcome.error !== null)\n admission.reason = 'execution-error'\n options.onAdmission?.(admission)\n if (admission.reason !== null) continue\n if (line.policy.model !== options.model)\n throw new Error('Tinker export: captured model identity differs')\n if (line.messages.some((message) => message.is_copied_context)) {\n throw new Error('Tinker export: copied context has no captured token mask')\n }\n const steps = line.steps\n if (!steps?.some((step) => step.kind === 'llm'))\n throw new Error('Tinker export: no captured model steps')\n safeText(\n JSON.stringify({ messages: line.messages, steps, tool_defs: line.tool_defs }),\n 'rollout content',\n )\n for (const [index, step] of steps.entries()) {\n if (step.kind === 'llm') rows.push(projectStep(step, line, index, options))\n }\n }\n return rows\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;AACF;AA0DA,MAAM,UAAU,UACd,UAAU,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;AAE3D,SAAS,SAAS,SAA4B,QAAsB;CAClE,IAAI,QAAQ,WAAW,QAAQ,MAAM,IAAI,MAAM,4CAA4C;CAC3F,IAAI,CAAC,MAAM,QAAQ,QAAQ,YAAY,GACrC,MAAM,IAAI,MAAM,wCAAwC;CAC1D,KAAK,MAAM,OAAO,QAAQ,cACxB,IACE,CAAC,OACD,OAAO,IAAI,UAAU,YACrB,CAAC,IAAI,MAAM,KAAK,KAChB,IAA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Y,kBAAkB,MAAM,cAAc;GAAE,GAAG;GAAS,aAAa,KAAA;EAAU,CAAC;EAE9F,IAAI,UAAU,WAAW,QAAQ,KAAK,QAAQ,UAAU,MACtD,UAAU,SAAS;EACrB,QAAQ,cAAc,SAAS;EAC/B,IAAI,UAAU,WAAW,MAAM;EAC/B,IAAI,KAAK,OAAO,UAAU,QAAQ,OAChC,MAAM,IAAI,MAAM,gDAAgD;EAClE,IAAI,KAAK,SAAS,MAAM,YAAY,QAAQ,iBAAiB,GAC3D,MAAM,IAAI,MAAM,0DAA0D;EAE5E,MAAM,QAAQ,KAAK;EACnB,IAAI,CAAC,OAAO,MAAM,SAAS,KAAK,SAAS,KAAK,GAC5C,MAAM,IAAI,MAAM,wCAAwC;EAC1D,SACE,KAAK,UAAU;GAAE,UAAU,KAAK;GAAU;GAAO,WAAW,KAAK;EAAU,CAAC,GAC5E,iBACF;EACA,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GACxC,IAAI,KAAK,SAAS,OAAO,KAAK,KAAK,YAAY,MAAM,MAAM,OAAO,OAAO,CAAC;CAE9E;CACA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-improvement-loop-BAxDnaPI.d.ts","names":["_$__external_optimizer_process0.ExternalTextEvaluationRequest","AgentProfile","AgentProfile"],"sources":["../src/campaign/search-ledger-errors.ts","../src/campaign/coverage.ts","../src/campaign/final-evidence.ts","../src/campaign/cell-schedule.ts","../src/campaign/cell-cache.ts","../src/campaign/plan-campaign-run.ts","../src/campaign/run-campaign.ts","../src/campaign/presets/run-eval.ts","../src/campaign/auto-pr.ts","../src/llm-judge.ts","../src/reference-equivalence-judge.ts","../src/campaign/analyst-surface.ts","../src/campaign/cost-breakdown.ts","../src/campaign/cross-surface-types.ts","../src/campaign/cross-surface-interaction.ts","../src/campaign/external-optimizer-observations.ts","../src/campaign/gepa-candidate-population.ts","../src/campaign/optimization-cost.ts","../src/campaign/optimization-method.ts","../src/campaign/external-text-evaluation.ts","../src/campaign/external-text-optimization-contract.ts","../src/campaign/external-text-optimization.ts","../src/campaign/fixtures.ts","../src/campaign/gates/compose.ts","../src/canary.ts","../src/red-team.ts","../src/campaign/gates/default-production-gate.ts","../src/campaign/gates/heldout-gate.ts","../src/campaign/gates/neutralization-gate.ts","../src/campaign/optimizer-model.ts","../src/campaign/gepa-optimization-method.ts","../src/campaign/gepa-search-import.ts","../src/campaign/grounded-reflection.ts","../src/campaign/labeled-store/fs-adapter.ts","../src/campaign/neutralize.ts","../src/campaign/optimization-method-composition.ts","../src/campaign/presets/compare-optimization-methods.ts","../src/produced-state.ts","../src/campaign/presets/playback.ts","../src/integrity/backend-integrity.ts","../src/campaign/presets/run-profile-matrix.ts","../src/campaign/presets/segmented-profile-matrix.ts","../src/campaign/score-utils.ts","../src/campaign/provenance.ts","../src/campaign/retained-dispatch.ts","../src/campaign/run-dir.ts","../src/campaign/scenario-selection.ts","../src/campaign/search-campaign-cell.ts","../src/campaign/single-run-lock.ts","../src/campaign/skillopt-optimization-method.ts","../src/campaign/surface-identity.ts","../src/campaign/transient-failure.ts","../src/campaign/upstream-evaluators.ts","../src/campaign/worktree/index.ts","../src/campaign/presets/run-optimization.ts","../src/campaign/presets/run-improvement-loop.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;cAGa,0BAA0B;;cAG1B,mCAAmC;UCE/B;EACf;EACA;EACA;EACA,iBAAiB;IAAQ;IAAgB;;;;iBAI3B,qBAAqB,kBAAkB,UACrD,oBAAoB,aACpB;;iBA2Bc,yBAAyB,kBAAkB,UACzD,UAAU,YACT,2BAA2B,KAAK;;iBAUnB,kCACd,oBAAoB,4BACpB;;iBAgBc,oBAAoB,kBAAkB,UACpD,oBAAoB,aACpB;;iBAkBc,iBAAiB,WAAW,kBAAkB,UAC5D,gBAAgB,mBAAmB,cACnC,oBAAoB,aACpB,cACA,6BACC;;UCzEc;EACf,QAAQ;EACR;EACA,iBAAiB;;;EAGjB,2BAA2B,oBAAoB;;UA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;;EAEf,gBAAgB;;KCjnBN,0BACV,kBAAkB,UAClB,aACE,uBAAuB,WAAW;;;EAGpC,kBAAkB;EAClB,QAAQ;EACR,gBAAgB;;EAEhB;;EAEA,iBAAiB;;;EAGjB;;;;;;;;;EASA;;;;EAIA,MAAM,KAAK,WAAW;;;;;EAKtB;;EAEA;EACA;;;;;;;;EAQA,cAAc,eAAe,gBAAgB,iBAAiB,mBAAmB;;UAGlE,yBAAyB,WAAW,kBAAkB,kBAC7D,sBAAsB,WAAW;EACzC,mBAAmB,eAAe,WAAW;EAC7C,iBAAiB,eAAe,WAAW;EAC3C,uBAAuB,eAAe,WAAW;EACjD,qBAAqB;EACrB,YAAY,QAAQ,WAAW,KAAK,WAAW;EAC/C,QAAQ;EACR,gBAAgB;EAChB,iBAAiB;;;;EAIjB;;;;;EAKA;EACA,WAAW,kBAAkB;;;;;iBAMT,mBAAmB,kBAAkB,UAAU,WACnE,MAAM,0BAA0B,WAAW,aAC1C,QAAQ,yBAAyB,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-record-c860wUR8.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,2BAA2B,IAAI;CAC/C,MAAM,YAAY,8BAA8B,IAAI;CACpD,MAAM,kBAAkB,KAAK,IAC3B,QAAQ,IAAI,qBAAqB,GACjC,UAAU,mBAAmB,CAC/B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