@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
package/dist/rl.js CHANGED
@@ -1,18 +1,19 @@
1
1
  import { s as ValidationError } from "./errors-DeEEV9Vx.js";
2
- import { a as hashCanonical, i as compareCodeUnits, o as jsonDocument } from "./canonical-BANK6NOj.js";
3
- import { s as runTaskScore } from "./run-record-Dx64nPcX.js";
4
- import { _t as medianInPlace, u as wilcoxonSignedRank, v as pairedBootstrap } from "./statistics-CHs0jlsY.js";
5
- import { t as decidePairedPromotion } from "./paired-promotion-decision-BoWHWL1i.js";
6
- import { n as campaignCellToRunRecord } from "./run-record-c860wUR8.js";
7
- import { n as extractVerifiableReward, r as extractVerifiableRewardsFromRecords, t as detectRewardHacking } from "./reward-hacking-DNiHskry.js";
8
- import { t as runEvalCampaign } from "./eval-campaign-CWWh-1p1.js";
9
- import { s as assertRewardGate } from "./schema-b18jtzZw.js";
10
- import { a as toSftRows, s as trainingAdmission, t as isTrainingLineEligible } from "./exporters-C9AwGDDK.js";
11
- import { t as mintRolloutRows } from "./mint-VN-qtJTc.js";
12
- import { t as evaluateInterimReleaseConfidence } from "./sequential-C6k0Wrb7.js";
13
- import { o as validateOutcomeMetricSpecifications, t as assertUniqueObservationIds } from "./outcome-observations-YFFmdGGW.js";
14
- import { n as prepareSystemOneReview } from "./systemone-review-CqNNZMiD.js";
15
- import { t as rubricPredictiveValidity } from "./rubric-predictive-validity-Cln7r56F.js";
2
+ import { a as hashCanonical, i as compareCodeUnits, n as LedgerCanonicalizationError, o as jsonDocument } from "./canonical-DKgL_Wby.js";
3
+ import { s as runTaskScore } from "./run-record-CqUft6Yf.js";
4
+ import { _t as medianInPlace, a as wilcoxonSignedRank, p as pairedBootstrap } from "./statistics-DSidA5I2.js";
5
+ import { t as decidePairedPromotion } from "./paired-promotion-decision-Dn3-jaq4.js";
6
+ import { n as campaignCellToRunRecord } from "./run-record-Bqg0NZ_e.js";
7
+ import { n as extractVerifiableReward, r as extractVerifiableRewardsFromRecords, t as detectRewardHacking } from "./reward-hacking-DKAflk2c.js";
8
+ import { n as defaultScenarioId } from "./emitter-BjW3NnX-.js";
9
+ import { t as runEvalCampaign } from "./eval-campaign-Cyk-tkLh.js";
10
+ import { s as assertRewardGate } from "./schema-Bh9CfSZT.js";
11
+ import { a as toSftRows, s as trainingAdmission, t as isTrainingLineEligible } from "./exporters-CKFtnWmX.js";
12
+ import { t as mintRolloutRows } from "./mint-B4n1pRRd.js";
13
+ import { t as evaluateInterimReleaseConfidence } from "./sequential-ux_XrjBf.js";
14
+ import { o as validateOutcomeMetricSpecifications, t as assertUniqueObservationIds } from "./outcome-observations-DL3CC8w1.js";
15
+ import { n as prepareSystemOneReview } from "./systemone-review-ir3Cbejl.js";
16
+ import { t as rubricPredictiveValidity } from "./rubric-predictive-validity--6z0q8s6.js";
16
17
  import { n as InMemoryOutcomeStore, t as FileSystemOutcomeStore } from "./outcome-store-TarrcfHG.js";
17
18
  import { createHash } from "node:crypto";
18
19
  import { existsSync, readFileSync } from "node:fs";
@@ -1330,12 +1331,21 @@ function toSftJsonl(rows) {
1330
1331
  * Convert PRM training triples to JSONL rows. Caller's `stepTextOf`
1331
1332
  * callback resolves span text from the consumer's trace store.
1332
1333
  *
1333
- * Every referenced run is checked against its minted line before any row is
1334
- * emitted, and the export FAILS LOUD on a trajectory that was never fully
1335
- * captured (see `assertPrmTrainableLine`). Triples whose chosen or rejected
1336
- * side is realness-gated are dropped instead: a capture defect is the caller's
1337
- * mint configuration and must be fixed, whereas a gamed run is exactly the
1338
- * condition the gate exists to filter.
1334
+ * A triple is two different actions taken in the same context, compared on
1335
+ * their mean rewards — the rule `prmTrainingPairs` enforces — and its
1336
+ * `contextDigest` names that context. A triple with no context digest, or that
1337
+ * does not name the runs behind its means, is refused before anything else,
1338
+ * because no row may be built from steps that are not known to share a context
1339
+ * or from a mean whose runs cannot be checked. The digest, the step counts and
1340
+ * the run ids behind each mean are carried on `meta`.
1341
+ *
1342
+ * Every referenced run — both representatives and every run behind either mean
1343
+ * — is checked against its minted line before any row is emitted, and the
1344
+ * export FAILS LOUD on a trajectory that was never fully captured (see
1345
+ * `assertPrmTrainableLine`). A triple any of whose runs is realness-gated is
1346
+ * dropped instead, so a gamed run cannot move a mean: a capture defect is the
1347
+ * caller's mint configuration and must be fixed, whereas a gamed run is exactly
1348
+ * the condition the gate exists to filter.
1339
1349
  *
1340
1350
  * `context` is REQUIRED. A two-argument call used to be accepted and produced
1341
1351
  * rows with no gate applied at all — a `PrmTrainingTriple` carries a bare
@@ -1346,6 +1356,10 @@ function toSftJsonl(rows) {
1346
1356
  * the exact step the gaming happened.
1347
1357
  */
1348
1358
  async function toPrmRows(triples, lookups, context) {
1359
+ for (const t of triples) {
1360
+ if (!t.contextDigest) throw new Error(`PRM export: triple ${t.chosenSpanId}/${t.rejectedSpanId} has no context digest; its steps are not known to share a context`);
1361
+ if (!Array.isArray(t.chosenRunIds) || !Array.isArray(t.rejectedRunIds)) throw new Error(`PRM export: triple ${t.chosenSpanId}/${t.rejectedSpanId} names no runs behind its mean rewards; their realness gates cannot be read`);
1362
+ }
1349
1363
  const admitted = admitPrmTriples(triples, context);
1350
1364
  const rows = [];
1351
1365
  for (const t of admitted) {
@@ -1365,9 +1379,14 @@ async function toPrmRows(triples, lookups, context) {
1365
1379
  rejectedReward: t.rejectedReward,
1366
1380
  marginScore: t.marginScore,
1367
1381
  meta: {
1382
+ contextDigest: t.contextDigest,
1368
1383
  prefixRunId: t.prefixRunId,
1369
1384
  rejectedRunId: t.rejectedRunId,
1370
- prefixStepIndex: t.prefixStepIndex
1385
+ prefixStepIndex: t.prefixStepIndex,
1386
+ chosenStepCount: t.chosenStepCount,
1387
+ rejectedStepCount: t.rejectedStepCount,
1388
+ chosenRunIds: t.chosenRunIds,
1389
+ rejectedRunIds: t.rejectedRunIds
1371
1390
  }
1372
1391
  });
1373
1392
  }
@@ -1401,7 +1420,12 @@ const PRM_CONTEXT_REQUIREMENT = {
1401
1420
  * `stepRewardsToJsonl`; only the trajectory-completeness rules are PRM's own.
1402
1421
  */
1403
1422
  function admitPrmTriples(triples, context) {
1404
- return admitUngatedByInvocation(triples, (t) => [t.prefixRunId, t.rejectedRunId], context, PRM_CONTEXT_REQUIREMENT, (line) => assertPrmTrainableLine(line, context.mintedWithMaxSteps));
1423
+ return admitUngatedByInvocation(triples, (t) => [.../* @__PURE__ */ new Set([
1424
+ t.prefixRunId,
1425
+ t.rejectedRunId,
1426
+ ...t.chosenRunIds,
1427
+ ...t.rejectedRunIds
1428
+ ])], context, PRM_CONTEXT_REQUIREMENT, (line) => assertPrmTrainableLine(line, context.mintedWithMaxSteps));
1405
1429
  }
1406
1430
  // src/rl/dataset.ts
1407
1431
  /**
@@ -2309,65 +2333,385 @@ function makePair(a, b, scenarioId, minMargin) {
2309
2333
  }
2310
2334
  // src/rl/process-reward.ts
2311
2335
  /**
2312
- * Build PRM training triples. The shape: pair runs that share an early
2313
- * prefix (same scenario, same first N steps) and diverge later — at the
2314
- * point of divergence, the high-reward run's next step is `chosen`, the
2315
- * low-reward run's next step is `rejected`. This is the canonical PRM
2316
- * training data shape from Lightman et al. and DeepSeek-R1 process
2317
- * supervision.
2318
- *
2319
- * Implementation note: we don't have a way to detect "same prefix" in
2320
- * the general agent setting (token-level prefixes require hashing model
2321
- * outputs). The current heuristic groups by `(scenarioId, prefixSpanName
2322
- * sequence)` — runs are paired when their first K span names match. For
2323
- * production use this should be replaced with a proper trajectory-prefix
2324
- * hash; the heuristic is good enough for early-stage scaffolding.
2336
+ * Process reward extraction — step-level credit assignment from trace spans.
2337
+ *
2338
+ * RL on long-horizon agents needs *step-level* rewards, not run-level
2339
+ * ones. The classic credit-assignment problem (Sutton & Barto) requires
2340
+ * knowing which sub-decisions in a trajectory contributed to the
2341
+ * outcome. Modern systems (DeepSeek-R1, OpenAI o-series, Lightman et al.
2342
+ * "Let's Verify Step by Step" 2023) train *process reward models* (PRMs)
2343
+ * that score every step, then do RL with the PRM as the reward signal.
2344
+ *
2345
+ * This module extracts `StepReward[]` from trace spans — one per
2346
+ * meaningful step — and ships:
2347
+ *
2348
+ * 1. `extractStepRewards(store, runId, opts)` — span → step-reward
2349
+ * conversion using configurable per-span scorers (LLM judge over the
2350
+ * span output, deterministic checkers, or a learned PRM). Each step
2351
+ * carries a digest of the context it acted in and of the action it took.
2352
+ * 2. `runwiseStepRewardSummary(stepRewards)` — aggregate the per-step
2353
+ * signal into a credit-assignment-aware run-level score.
2354
+ * 3. `prmTrainingPairs(stepRewardsByRun, options)` — produce the
2355
+ * `(prefix, chosen_step, rejected_step)` triples that PRM training
2356
+ * pipelines consume: two different actions taken in the same context,
2357
+ * compared on their mean reward across the runs that took them.
2358
+ *
2359
+ * What we ship: the *extraction* and *aggregation* infrastructure plus
2360
+ * the data shape PRM training expects. We do NOT ship the actual PRM
2361
+ * training (gradient descent over a transformer is out of scope for a
2362
+ * TS package). The interface is the contract; downstream consumers wire
2363
+ * their preferred trainer.
2364
+ *
2365
+ * A step's context is what had been recorded by the time it started: the
2366
+ * start of every earlier span and the end of every span that had already
2367
+ * ended. That is a timing boundary. It does not prove the policy read an
2368
+ * earlier span's output, only that the output existed before the step began.
2369
+ *
2370
+ * Caveat: a pair says that, from one recorded context, one action was
2371
+ * followed by a higher mean step reward than another. The reward is still the
2372
+ * scorer's; whether the action caused it needs counterfactual rollouts or a
2373
+ * learned dynamics model.
2325
2374
  */
2326
- function prmTrainingPairs(stepRewardsByRun, opts = {}) {
2327
- const minMargin = opts.minMargin ?? .2;
2328
- const minPrefix = opts.minPrefixLength ?? 1;
2329
- const runs = [...stepRewardsByRun.entries()].map(([runId, steps]) => ({
2330
- runId,
2331
- steps
2332
- }));
2333
- const triples = [];
2334
- for (let i = 0; i < runs.length; i++) for (let j = i + 1; j < runs.length; j++) {
2335
- const a = runs[i];
2336
- const b = runs[j];
2337
- const minLen = Math.min(a.steps.length, b.steps.length);
2338
- if (minLen < minPrefix + 1) continue;
2339
- let divergenceIdx = -1;
2340
- for (let k = 0; k < minLen; k++) {
2341
- const sa = a.steps[k];
2342
- const sb = b.steps[k];
2343
- const structuralDivergence = sa.kind !== sb.kind || sa.name !== sb.name;
2344
- const rewardGap = Math.abs(sa.reward - sb.reward);
2345
- if (structuralDivergence || rewardGap >= minMargin) {
2346
- divergenceIdx = k;
2375
+ /**
2376
+ * Score a recorded run's spans and attach to each step the digest of its
2377
+ * context and of its action.
2378
+ *
2379
+ * The context is built from a time-ordered chain of events: each span adds its
2380
+ * start content at `startedAt` and its end content (`END_FIELDS`) at
2381
+ * `endedAt`. A step's context digest is the chain just before its own start,
2382
+ * plus its own input. This is a timing boundary: it says what had been
2383
+ * recorded when the step began, not that the policy read it.
2384
+ */
2385
+ async function extractStepRewards(store, runId, opts) {
2386
+ const run = await store.getRun(runId);
2387
+ const ordered = [...await store.spans({ runId })].sort((a, b) => a.startedAt - b.startedAt);
2388
+ const positionOf = new Map(ordered.map((span, position) => [span.spanId, position]));
2389
+ const attributeKeys = opts.contextAttributes === void 0 ? void 0 : new Set(opts.contextAttributes);
2390
+ const task = run?.scenarioId && run.scenarioId !== defaultScenarioId(run) ? run.scenarioId : void 0;
2391
+ let chain = task === void 0 ? void 0 : digestOf({ scenarioId: task });
2392
+ const fold = (event, recorded) => {
2393
+ chain = chain === void 0 || !recorded ? void 0 : digestOf({
2394
+ prefix: chain,
2395
+ event
2396
+ });
2397
+ };
2398
+ let running = [];
2399
+ const out = [];
2400
+ for (const [position, span] of ordered.entries()) {
2401
+ const ended = running.filter((p) => endedBy(ordered[p], span.startedAt)).sort((a, b) => ordered[a].endedAt - ordered[b].endedAt || a - b);
2402
+ for (const p of ended) {
2403
+ const earlier = ordered[p];
2404
+ fold({
2405
+ end: p,
2406
+ content: endContent(earlier)
2407
+ }, endRecorded(earlier));
2408
+ }
2409
+ running = running.filter((p) => !ended.includes(p));
2410
+ const start = startContent(span, positionOf, attributeKeys);
2411
+ const input = span.kind === "llm" ? start.messages ?? UNRECORDED : void 0;
2412
+ const action = actionOf(span);
2413
+ const contextBefore = chain;
2414
+ fold({
2415
+ start: position,
2416
+ content: start
2417
+ }, input !== UNRECORDED && action !== UNRECORDED);
2418
+ running.push(position);
2419
+ if (opts.preFilter && !opts.preFilter(span)) continue;
2420
+ let scored = null;
2421
+ for (const s of opts.scorers) {
2422
+ if (!s.appliesTo.includes(span.kind)) continue;
2423
+ const r = await s.score(span);
2424
+ if (r) {
2425
+ scored = r;
2347
2426
  break;
2348
2427
  }
2349
2428
  }
2350
- if (divergenceIdx < 0) continue;
2351
- if (divergenceIdx < minPrefix) continue;
2352
- const aNext = a.steps[divergenceIdx];
2353
- const bNext = b.steps[divergenceIdx];
2354
- if (Math.abs(aNext.reward - bNext.reward) < minMargin) continue;
2355
- const chosen = aNext.reward > bNext.reward ? aNext : bNext;
2356
- const rejected = aNext.reward > bNext.reward ? bNext : aNext;
2357
- const chosenRun = aNext.reward > bNext.reward ? a.runId : b.runId;
2358
- const rejectedRun = aNext.reward > bNext.reward ? b.runId : a.runId;
2359
- triples.push({
2360
- prefixRunId: chosenRun,
2361
- prefixStepIndex: divergenceIdx - 1,
2362
- chosenSpanId: chosen.spanId,
2363
- chosenReward: chosen.reward,
2364
- rejectedSpanId: rejected.spanId,
2365
- rejectedReward: rejected.reward,
2366
- rejectedRunId: rejectedRun,
2367
- marginScore: chosen.reward - rejected.reward
2429
+ if (!scored) continue;
2430
+ const contextDigest = scored.contextDigest ?? (contextBefore === void 0 || input === UNRECORDED ? void 0 : digestOf({
2431
+ prefix: contextBefore,
2432
+ input
2433
+ }));
2434
+ const actionDigest = scored.actionDigest ?? (action === void 0 || action === UNRECORDED ? void 0 : digestOf({
2435
+ kind: span.kind,
2436
+ name: span.name,
2437
+ action
2438
+ }));
2439
+ out.push({
2440
+ spanId: span.spanId,
2441
+ runId,
2442
+ stepIndex: position,
2443
+ kind: span.kind,
2444
+ name: span.name,
2445
+ reward: scored.reward,
2446
+ determinism: scored.determinism,
2447
+ rationale: scored.rationale,
2448
+ weight: scored.weight,
2449
+ ...contextDigest === void 0 ? {} : { contextDigest },
2450
+ ...actionDigest === void 0 ? {} : { actionDigest }
2368
2451
  });
2369
2452
  }
2370
- return triples;
2453
+ return out;
2454
+ }
2455
+ /** A part the span's kind carries and the trace does not. */
2456
+ const UNRECORDED = Symbol("unrecorded");
2457
+ /**
2458
+ * Fields left out of a span's content: identifiers, timestamps, and token and
2459
+ * cost accounting differ between runs that saw and did the same thing, and the
2460
+ * model is the policy, not the context.
2461
+ */
2462
+ const NOT_CONTENT = /* @__PURE__ */ new Set([
2463
+ "spanId",
2464
+ "parentSpanId",
2465
+ "runId",
2466
+ "startedAt",
2467
+ "endedAt",
2468
+ "latencyMs",
2469
+ "wallMs",
2470
+ "model",
2471
+ "inputTokens",
2472
+ "outputTokens",
2473
+ "cachedTokens",
2474
+ "cacheWriteTokens",
2475
+ "reasoningTokens",
2476
+ "costUsd",
2477
+ "tokens"
2478
+ ]);
2479
+ /**
2480
+ * Fields that exist only once a span has ended, so they are observable only
2481
+ * after `endedAt`. Every other content field, including `attributes` and any
2482
+ * field the schema gains later, counts as known from `startedAt` — the strict
2483
+ * reading, since a field read too early can only make contexts differ.
2484
+ */
2485
+ const END_FIELDS = /* @__PURE__ */ new Set([
2486
+ "output",
2487
+ "finishReason",
2488
+ "result",
2489
+ "hits",
2490
+ "score",
2491
+ "rationale",
2492
+ "evidence",
2493
+ "exitCode",
2494
+ "testsTotal",
2495
+ "testsPassed",
2496
+ "stdoutHash",
2497
+ "stderrHash",
2498
+ "status",
2499
+ "error"
2500
+ ]);
2501
+ function contentOf(value, keep) {
2502
+ return Object.fromEntries(Object.entries(value).filter(([key]) => !NOT_CONTENT.has(key) && keep(key)));
2503
+ }
2504
+ /**
2505
+ * What a span carried when it started. An llm span's messages are missing when
2506
+ * none were captured; a judge's target is named by its position in the run, so
2507
+ * the same target reads the same in two runs.
2508
+ */
2509
+ function startContent(span, positionOf, attributeKeys) {
2510
+ const content = contentOf(span, (key) => !END_FIELDS.has(key));
2511
+ if (span.kind === "llm") content.messages = Array.isArray(span.messages) && span.messages.length > 0 ? span.messages.map((message) => contentOf(message, () => true)) : void 0;
2512
+ if (span.kind === "judge") content.targetSpanId = positionOf.get(span.targetSpanId) ?? span.targetSpanId;
2513
+ if (attributeKeys !== void 0 && span.attributes !== void 0) {
2514
+ const kept = Object.entries(span.attributes).filter(([key]) => attributeKeys.has(key));
2515
+ content.attributes = kept.length > 0 ? Object.fromEntries(kept) : void 0;
2516
+ }
2517
+ return content;
2518
+ }
2519
+ /** What a span carried once it ended. */
2520
+ function endContent(span) {
2521
+ return contentOf(span, (key) => END_FIELDS.has(key));
2522
+ }
2523
+ /** Whether the span had ended by `time`. A span that never ended never has. */
2524
+ function endedBy(span, time) {
2525
+ return span.endedAt !== void 0 && span.endedAt <= time;
2526
+ }
2527
+ /**
2528
+ * Whether an ended span recorded what it produced: an llm span its output or
2529
+ * error, a tool call its result or error, a retrieval its hits.
2530
+ */
2531
+ function endRecorded(span) {
2532
+ switch (span.kind) {
2533
+ case "llm": return typeof span.output === "string" || span.error !== void 0;
2534
+ case "tool": return span.result !== void 0 || span.error !== void 0;
2535
+ case "retrieval": return Array.isArray(span.hits) || span.error !== void 0;
2536
+ default: return true;
2537
+ }
2538
+ }
2539
+ /**
2540
+ * The decision a step made: an llm span's `output`, a tool call's name and
2541
+ * arguments, a retrieval's query. Judge, sandbox, agent and custom spans make
2542
+ * no policy decision — a judge grades, the harness runs the sandbox, a
2543
+ * container only groups — so they shape later contexts and are never paired.
2544
+ * A tool call's arguments and a retrieval's query are known at its start, so an
2545
+ * uncaptured one leaves the context unknown from that start on.
2546
+ */
2547
+ function actionOf(span) {
2548
+ switch (span.kind) {
2549
+ case "llm": return typeof span.output === "string" ? span.output : void 0;
2550
+ case "tool": return span.argsCaptured === false || span.args === void 0 ? UNRECORDED : {
2551
+ toolName: span.toolName,
2552
+ args: span.args
2553
+ };
2554
+ case "retrieval": return typeof span.query === "string" ? { query: span.query } : UNRECORDED;
2555
+ default: return;
2556
+ }
2557
+ }
2558
+ /**
2559
+ * The canonical digest of `value` in its JSON document form, where an
2560
+ * undefined field is absent. Content with no canonical form (NaN, a class
2561
+ * instance, a reference cycle) has no digest, the same as content that was
2562
+ * never recorded.
2563
+ */
2564
+ function digestOf(value) {
2565
+ try {
2566
+ return hashCanonical(jsonDocument(value));
2567
+ } catch (error) {
2568
+ if (error instanceof LedgerCanonicalizationError) return void 0;
2569
+ throw error;
2570
+ }
2571
+ }
2572
+ /** Summarize one run's step rewards, given in step order. */
2573
+ function runwiseStepRewardSummary(stepRewards) {
2574
+ if (stepRewards.length === 0) return {
2575
+ runId: "",
2576
+ totalSteps: 0,
2577
+ meanReward: 0,
2578
+ sumWeightedReward: 0,
2579
+ failureFraction: 0,
2580
+ worstStepDelta: 0,
2581
+ worstStepIndex: null
2582
+ };
2583
+ const runId = stepRewards[0].runId;
2584
+ let sumW = 0;
2585
+ let sumWR = 0;
2586
+ let failures = 0;
2587
+ let worstDelta = 0;
2588
+ let worstIdx = null;
2589
+ let prev = stepRewards[0].reward;
2590
+ for (let i = 0; i < stepRewards.length; i++) {
2591
+ const s = stepRewards[i];
2592
+ const w = s.weight ?? 1;
2593
+ sumW += w;
2594
+ sumWR += w * s.reward;
2595
+ if (s.reward < .5) failures++;
2596
+ if (i > 0) {
2597
+ const delta = s.reward - prev;
2598
+ if (delta < worstDelta) {
2599
+ worstDelta = delta;
2600
+ worstIdx = i;
2601
+ }
2602
+ prev = s.reward;
2603
+ } else prev = s.reward;
2604
+ }
2605
+ return {
2606
+ runId,
2607
+ totalSteps: stepRewards.length,
2608
+ meanReward: sumW === 0 ? 0 : sumWR / sumW,
2609
+ sumWeightedReward: sumWR,
2610
+ failureFraction: failures / stepRewards.length,
2611
+ worstStepDelta: worstDelta,
2612
+ worstStepIndex: worstIdx
2613
+ };
2614
+ }
2615
+ /**
2616
+ * Build PRM training triples — the `(prefix, chosen_step, rejected_step)`
2617
+ * shape of Lightman et al. and DeepSeek-R1 process supervision.
2618
+ *
2619
+ * Steps are grouped by `contextDigest` across all runs, and within a context by
2620
+ * `actionDigest`. Each action's reward is its mean over every step that took
2621
+ * it there, so the same action scored twice is one estimate, not two
2622
+ * preferences. Two actions in one context form one triple when:
2623
+ * - their mean rewards differ, by at least `minMargin` (default 0.2);
2624
+ * - two different runs can represent them.
2625
+ * The higher-mean action is `chosen`. Its representative is its step with the
2626
+ * lowest run id, then span id; the rejected representative is the other
2627
+ * action's first step, in the same order, from a different run. When the
2628
+ * chosen action's first step has no such partner, its next step is tried.
2629
+ * A step with no digest is counted in the result and never paired.
2630
+ */
2631
+ function prmTrainingPairs(stepRewardsByRun, opts = {}) {
2632
+ const minMargin = opts.minMargin ?? .2;
2633
+ if (!Number.isFinite(minMargin) || minMargin < 0) throw new RangeError(`prmTrainingPairs: minMargin must be a finite number >= 0, got ${minMargin}`);
2634
+ const result = {
2635
+ triples: [],
2636
+ stepsWithoutContextDigest: 0,
2637
+ stepsWithoutActionDigest: 0,
2638
+ singleRunContexts: 0,
2639
+ sameActionContexts: 0,
2640
+ actionPairsBelowMargin: 0,
2641
+ actionPairsInOneRun: 0
2642
+ };
2643
+ const byContext = /* @__PURE__ */ new Map();
2644
+ for (const steps of stepRewardsByRun.values()) for (const step of steps) if (!step.contextDigest) result.stepsWithoutContextDigest++;
2645
+ else if (!step.actionDigest) result.stepsWithoutActionDigest++;
2646
+ else byContext.set(step.contextDigest, [...byContext.get(step.contextDigest) ?? [], step]);
2647
+ for (const [contextDigest, group] of byContext) {
2648
+ if (new Set(group.map((s) => s.runId)).size < 2) {
2649
+ result.singleRunContexts++;
2650
+ continue;
2651
+ }
2652
+ const actions = actionsIn(group);
2653
+ if (actions.length < 2) {
2654
+ result.sameActionContexts++;
2655
+ continue;
2656
+ }
2657
+ for (let i = 0; i < actions.length; i++) for (let j = i + 1; j < actions.length; j++) {
2658
+ const a = actions[i];
2659
+ const b = actions[j];
2660
+ const [chosen, rejected] = a.mean >= b.mean ? [a, b] : [b, a];
2661
+ const margin = chosen.mean - rejected.mean;
2662
+ if (!(margin > 0 && margin >= minMargin)) {
2663
+ result.actionPairsBelowMargin++;
2664
+ continue;
2665
+ }
2666
+ const representatives = representativesOf(chosen.steps, rejected.steps);
2667
+ if (representatives === void 0) {
2668
+ result.actionPairsInOneRun++;
2669
+ continue;
2670
+ }
2671
+ const [chosenStep, rejectedStep] = representatives;
2672
+ result.triples.push({
2673
+ contextDigest,
2674
+ prefixRunId: chosenStep.runId,
2675
+ prefixStepIndex: chosenStep.stepIndex - 1,
2676
+ chosenSpanId: chosenStep.spanId,
2677
+ chosenReward: chosen.mean,
2678
+ chosenStepCount: chosen.steps.length,
2679
+ chosenRunIds: runIdsOf(chosen.steps),
2680
+ rejectedSpanId: rejectedStep.spanId,
2681
+ rejectedReward: rejected.mean,
2682
+ rejectedStepCount: rejected.steps.length,
2683
+ rejectedRunIds: runIdsOf(rejected.steps),
2684
+ rejectedRunId: rejectedStep.runId,
2685
+ marginScore: margin
2686
+ });
2687
+ }
2688
+ }
2689
+ return result;
2690
+ }
2691
+ /** A context's steps grouped by action, in first-seen order. */
2692
+ function actionsIn(group) {
2693
+ const byAction = /* @__PURE__ */ new Map();
2694
+ for (const step of group) {
2695
+ const digest = step.actionDigest;
2696
+ byAction.set(digest, [...byAction.get(digest) ?? [], step]);
2697
+ }
2698
+ return [...byAction.values()].map((steps) => ({
2699
+ steps: [...steps].sort(byRunThenSpan),
2700
+ mean: steps.reduce((sum, s) => sum + s.reward, 0) / steps.length
2701
+ }));
2702
+ }
2703
+ /** The first chosen step, in order, that a rejected step from another run can face. */
2704
+ function representativesOf(chosen, rejected) {
2705
+ for (const c of chosen) {
2706
+ const r = rejected.find((s) => s.runId !== c.runId);
2707
+ if (r !== void 0) return [c, r];
2708
+ }
2709
+ }
2710
+ function byRunThenSpan(a, b) {
2711
+ return compareCodeUnits(a.runId, b.runId) || compareCodeUnits(a.spanId, b.spanId);
2712
+ }
2713
+ function runIdsOf(steps) {
2714
+ return [...new Set(steps.map((s) => s.runId))].sort(compareCodeUnits);
2371
2715
  }
2372
2716
  // src/rl/rl-campaign.ts
2373
2717
  /**
@@ -3099,6 +3443,6 @@ function loadVerifiedFindingsDataset(source) {
3099
3443
  }
3100
3444
  };
3101
3445
  }
3102
- export { FileSystemOutcomeStore, GRADER_REFERENCE_PHRASES, InMemoryOutcomeStore, PredictiveValidityResearcher, bestOfN, bucketLabel, buildPairwiseFromCampaign, buildRlDataset, campaignToRunRecords, checkerReadSignal, claimIntegrityDigest, claimIntegritySystemOneReview, claimIntegrityTraceQuestions, claimIntegrityVerdict, compareAdaptationCurves, detectRewardHacking, doublyRobust, extractPreferences, extractVerifiableReward, extractVerifiableRewardsFromRecords, farmingSignal, firstPassK, fitBradleyTerry, graderReferenceSignal, inverseProbabilityWeighting, loadVerifiedFindingsDataset, monitorSignal, paretoCostScoreFrontier, parseSourceScopeReferee, prmTrainingPairs, readCorpus, refereeSignal, ruleHolds, runAdaptationCurve, runContaminationProbe, runEvalCampaign, runRLCampaign, scopeSignals, selfNormalizedImportanceWeighting, sourceScopeRefereeMessages, systemOneSignal, toAnthropicFormat, toDpoRows, toGrpoRows, toPrmRows, toSftJsonl, toSftRowsWithLookups, toTRLFormat, validateDatasetFormats };
3446
+ export { FileSystemOutcomeStore, GRADER_REFERENCE_PHRASES, InMemoryOutcomeStore, PredictiveValidityResearcher, bestOfN, bucketLabel, buildPairwiseFromCampaign, buildRlDataset, campaignToRunRecords, checkerReadSignal, claimIntegrityDigest, claimIntegritySystemOneReview, claimIntegrityTraceQuestions, claimIntegrityVerdict, compareAdaptationCurves, detectRewardHacking, doublyRobust, extractPreferences, extractStepRewards, extractVerifiableReward, extractVerifiableRewardsFromRecords, farmingSignal, firstPassK, fitBradleyTerry, graderReferenceSignal, inverseProbabilityWeighting, loadVerifiedFindingsDataset, monitorSignal, paretoCostScoreFrontier, parseSourceScopeReferee, prmTrainingPairs, readCorpus, refereeSignal, ruleHolds, runAdaptationCurve, runContaminationProbe, runEvalCampaign, runRLCampaign, runwiseStepRewardSummary, scopeSignals, selfNormalizedImportanceWeighting, sourceScopeRefereeMessages, systemOneSignal, toAnthropicFormat, toDpoRows, toGrpoRows, toPrmRows, toSftJsonl, toSftRowsWithLookups, toTRLFormat, validateDatasetFormats };
3103
3447
 
3104
3448
  //# sourceMappingURL=rl.js.map