@tangle-network/agent-eval 0.221.7 → 0.222.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (581) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/dist/adapters/http.d.ts +3 -5
  3. package/dist/adapters/http.d.ts.map +1 -1
  4. package/dist/adapters/http.js +1 -2
  5. package/dist/{adversarial-smnADNFS.d.ts → adversarial-DnQQFqTR.d.ts} +1 -3
  6. package/dist/adversarial-DnQQFqTR.d.ts.map +1 -0
  7. package/dist/{agent-profile-CNmwfaqq.d.ts → agent-profile-CoD1Dotf.d.ts} +4 -10
  8. package/dist/agent-profile-CoD1Dotf.d.ts.map +1 -0
  9. package/dist/agent-profile-Dngk3LZ0.js +153 -0
  10. package/dist/agent-profile-Dngk3LZ0.js.map +1 -0
  11. package/dist/{agent-profile-cell-BcpFbNd5.d.ts → agent-profile-cell-3kYxUsK2.d.ts} +3 -5
  12. package/dist/agent-profile-cell-3kYxUsK2.d.ts.map +1 -0
  13. package/dist/{agent-profile-cell-B1V1gUZs.js → agent-profile-cell-CT5JYueM.js} +5 -7
  14. package/dist/{agent-profile-cell-B1V1gUZs.js.map → agent-profile-cell-CT5JYueM.js.map} +1 -1
  15. package/dist/{agreement-irr-BhAqjluA.js → agreement-irr-BTjDN0i6.js} +4 -5
  16. package/dist/{agreement-irr-BhAqjluA.js.map → agreement-irr-BTjDN0i6.js.map} +1 -1
  17. package/dist/analyst/index.d.ts +95 -159
  18. package/dist/analyst/index.d.ts.map +1 -1
  19. package/dist/analyst/index.js +28 -39
  20. package/dist/analyst/index.js.map +1 -1
  21. package/dist/{analyze-runs-DfX6dHP0.d.ts → analyze-runs-C-pP1sK9.d.ts} +7 -13
  22. package/dist/analyze-runs-C-pP1sK9.d.ts.map +1 -0
  23. package/dist/{analyze-runs-CHmsykNJ.js → analyze-runs-CTheASYV.js} +23 -32
  24. package/dist/{analyze-runs-CHmsykNJ.js.map → analyze-runs-CTheASYV.js.map} +1 -1
  25. package/dist/{attribute-vocabulary-CcXqHODT.d.ts → attribute-vocabulary-5oo8ykIx.d.ts} +2 -4
  26. package/dist/attribute-vocabulary-5oo8ykIx.d.ts.map +1 -0
  27. package/dist/authenticity/index.d.ts +0 -2
  28. package/dist/authenticity/index.d.ts.map +1 -1
  29. package/dist/authenticity/index.js +1 -2
  30. package/dist/{benchmark-command-Cnjfo0Zh.js → benchmark-command-jYWR2gya.js} +61 -94
  31. package/dist/benchmark-command-jYWR2gya.js.map +1 -0
  32. package/dist/benchmarks/index.d.ts +5 -15
  33. package/dist/benchmarks/index.d.ts.map +1 -1
  34. package/dist/benchmarks/index.js +27 -38
  35. package/dist/benchmarks/index.js.map +1 -1
  36. package/dist/{bounded-process-Cj9YjXbE.js → bounded-process-BZrWXIKW.js} +2 -3
  37. package/dist/{bounded-process-Cj9YjXbE.js.map → bounded-process-BZrWXIKW.js.map} +1 -1
  38. package/dist/builder-eval/index.d.ts +5 -14
  39. package/dist/builder-eval/index.d.ts.map +1 -1
  40. package/dist/builder-eval/index.js +11 -17
  41. package/dist/builder-eval/index.js.map +1 -1
  42. package/dist/{calibration-CTwxpJ-t.js → calibration-6usfVYYo.js} +4 -5
  43. package/dist/{calibration-CTwxpJ-t.js.map → calibration-6usfVYYo.js.map} +1 -1
  44. package/dist/campaign/index.d.ts +9 -9
  45. package/dist/campaign/index.js +15 -14
  46. package/dist/{campaign-uddTlFg5.js → campaign-ddr1N3yD.js} +61 -58
  47. package/dist/campaign-ddr1N3yD.js.map +1 -0
  48. package/dist/{campaign-evidence-DunzcJGv.js → campaign-evidence-DN8rWuBj.js} +20 -322
  49. package/dist/campaign-evidence-DN8rWuBj.js.map +1 -0
  50. package/dist/{canonical-Dq2hOQ8L.js → canonical-CicJlINA.js} +3 -4
  51. package/dist/{canonical-Dq2hOQ8L.js.map → canonical-CicJlINA.js.map} +1 -1
  52. package/dist/{canonical-CFpojCN5.d.ts → canonical-gLeHiqzd.d.ts} +2 -4
  53. package/dist/canonical-gLeHiqzd.d.ts.map +1 -0
  54. package/dist/{cell-spend-DEWR3nj-.js → cell-spend-zxmzg4GH.js} +3 -4
  55. package/dist/{cell-spend-DEWR3nj-.js.map → cell-spend-zxmzg4GH.js.map} +1 -1
  56. package/dist/{chat-client-BNATB3rJ.js → chat-client-CO3uB33i.js} +3 -4
  57. package/dist/{chat-client-BNATB3rJ.js.map → chat-client-CO3uB33i.js.map} +1 -1
  58. package/dist/{chat-json-call-BzWYp18J.js → chat-json-call-8yUv4LFO.js} +4 -5
  59. package/dist/{chat-json-call-BzWYp18J.js.map → chat-json-call-8yUv4LFO.js.map} +1 -1
  60. package/dist/{claim-BPVuyHuy.js → claim-Dod_mjk3.js} +5 -6
  61. package/dist/{claim-BPVuyHuy.js.map → claim-Dod_mjk3.js.map} +1 -1
  62. package/dist/cli.js +179 -23
  63. package/dist/cli.js.map +1 -1
  64. package/dist/{client-hwo3cJjR.d.ts → client-BIFwUg7I.d.ts} +6 -12
  65. package/dist/client-BIFwUg7I.d.ts.map +1 -0
  66. package/dist/{cluster-bootstrap-DEwwhl0C.js → cluster-bootstrap-SbaeM44s.js} +4 -5
  67. package/dist/{cluster-bootstrap-DEwwhl0C.js.map → cluster-bootstrap-SbaeM44s.js.map} +1 -1
  68. package/dist/completion-verifier-7KEfroqx.d.ts +168 -0
  69. package/dist/completion-verifier-7KEfroqx.d.ts.map +1 -0
  70. package/dist/{completion-verifier-asaV1nSj.js → completion-verifier-rqbMh5-4.js} +9 -160
  71. package/dist/completion-verifier-rqbMh5-4.js.map +1 -0
  72. package/dist/contract/index.d.ts +13 -13
  73. package/dist/contract/index.js +41 -60
  74. package/dist/contract/index.js.map +1 -1
  75. package/dist/{cost-ledger-BGZB6yY2.js → cost-ledger-CS8R3IZj.js} +10 -17
  76. package/dist/{cost-ledger-BGZB6yY2.js.map → cost-ledger-CS8R3IZj.js.map} +1 -1
  77. package/dist/{cost-ledger-C1W3ICmP.d.ts → cost-ledger-Czro9wmo.d.ts} +1 -5
  78. package/dist/cost-ledger-Czro9wmo.d.ts.map +1 -0
  79. package/dist/{dataset-DQqhOCPt.d.ts → dataset-DThC1S6G.d.ts} +1 -3
  80. package/dist/dataset-DThC1S6G.d.ts.map +1 -0
  81. package/dist/{decision-point-0nJubuoM.js → decision-point-lhMgODOR.js} +14 -18
  82. package/dist/{decision-point-0nJubuoM.js.map → decision-point-lhMgODOR.js.map} +1 -1
  83. package/dist/{deep-freeze-CurcOQg3.js → deep-freeze-CK8-2W7p.js} +2 -3
  84. package/dist/{deep-freeze-CurcOQg3.js.map → deep-freeze-CK8-2W7p.js.map} +1 -1
  85. package/dist/{default-registry-CLG5YqGS.d.ts → default-registry-B1DstPYg.d.ts} +53 -61
  86. package/dist/default-registry-B1DstPYg.d.ts.map +1 -0
  87. package/dist/{default-registry-BBTDgkDM.js → default-registry-C1tPEjZ4.js} +29 -45
  88. package/dist/{default-registry-BBTDgkDM.js.map → default-registry-C1tPEjZ4.js.map} +1 -1
  89. package/dist/{define-agent-eval-CCbT7Kfr.js → define-agent-eval-BLoP4Lf9.js} +15 -18
  90. package/dist/{define-agent-eval-CCbT7Kfr.js.map → define-agent-eval-BLoP4Lf9.js.map} +1 -1
  91. package/dist/{define-agent-eval-JKt3gMQr.d.ts → define-agent-eval-CAffiFbN.d.ts} +19 -27
  92. package/dist/define-agent-eval-CAffiFbN.d.ts.map +1 -0
  93. package/dist/{descriptive-CVNy48rR.js → descriptive-cPwITVfy.js} +30 -8
  94. package/dist/descriptive-cPwITVfy.js.map +1 -0
  95. package/dist/diagnosis/index.d.ts +5 -15
  96. package/dist/diagnosis/index.d.ts.map +1 -1
  97. package/dist/diagnosis/index.js +13 -19
  98. package/dist/diagnosis/index.js.map +1 -1
  99. package/dist/{dspy-rlm-engine-DN1p_5jx.js → dspy-rlm-engine-jDiWkul6.js} +7 -10
  100. package/dist/{dspy-rlm-engine-DN1p_5jx.js.map → dspy-rlm-engine-jDiWkul6.js.map} +1 -1
  101. package/dist/{emitter-DbMXUIVP.js → emitter-DhQ65mza.js} +3 -4
  102. package/dist/{emitter-DbMXUIVP.js.map → emitter-DhQ65mza.js.map} +1 -1
  103. package/dist/{emitter-DABYYTcH.d.ts → emitter-mAXC5PSN.d.ts} +3 -5
  104. package/dist/emitter-mAXC5PSN.d.ts.map +1 -0
  105. package/dist/{engine-dtRVeuQs.d.ts → engine-CaHaCc3W.d.ts} +10 -18
  106. package/dist/engine-CaHaCc3W.d.ts.map +1 -0
  107. package/dist/{equal-terms-DbPGcVtI.js → equal-terms-K11VHmR3.js} +3 -4
  108. package/dist/{equal-terms-DbPGcVtI.js.map → equal-terms-K11VHmR3.js.map} +1 -1
  109. package/dist/{errors-BcOs5MKW.js → errors-DeEEV9Vx.js} +2 -3
  110. package/dist/{errors-BcOs5MKW.js.map → errors-DeEEV9Vx.js.map} +1 -1
  111. package/dist/{errors-DEE6u6ot.d.ts → errors-E9I2hldP.d.ts} +1 -3
  112. package/dist/errors-E9I2hldP.d.ts.map +1 -0
  113. package/dist/{eval-campaign-DoX5vz3E.js → eval-campaign-Cgixrvf7.js} +8 -9
  114. package/dist/{eval-campaign-DoX5vz3E.js.map → eval-campaign-Cgixrvf7.js.map} +1 -1
  115. package/dist/{evaluation-wdGyZ7jV.js → evaluation-B8H3GYej.js} +4 -6
  116. package/dist/{evaluation-wdGyZ7jV.js.map → evaluation-B8H3GYej.js.map} +1 -1
  117. package/dist/{evaluation-DblGquCB.d.ts → evaluation-BPqUvZ66.d.ts} +4 -6
  118. package/dist/evaluation-BPqUvZ66.d.ts.map +1 -0
  119. package/dist/evaluation.d.ts +1 -1
  120. package/dist/evaluation.js +1 -2
  121. package/dist/{exact-types-Do63KoKn.d.ts → exact-types-D98BKpxo.d.ts} +8 -10
  122. package/dist/exact-types-D98BKpxo.d.ts.map +1 -0
  123. package/dist/{exec-CpbtOXVt.js → exec-C0_AkLUv.js} +3 -5
  124. package/dist/{exec-CpbtOXVt.js.map → exec-C0_AkLUv.js.map} +1 -1
  125. package/dist/{execution-tracks-CpgFPpS5.js → execution-tracks-DaDXYwAq.js} +2 -3
  126. package/dist/{execution-tracks-CpgFPpS5.js.map → execution-tracks-DaDXYwAq.js.map} +1 -1
  127. package/dist/experiment/index.d.ts +9 -37
  128. package/dist/experiment/index.d.ts.map +1 -1
  129. package/dist/experiment/index.js +29 -40
  130. package/dist/experiment/index.js.map +1 -1
  131. package/dist/{exporters-Dk3oEbK_.d.ts → exporters-B5Ze_RKh.d.ts} +4 -4
  132. package/dist/exporters-B5Ze_RKh.d.ts.map +1 -0
  133. package/dist/{exporters-DWvM16LE.js → exporters-ByLcILYU.js} +23 -5
  134. package/dist/exporters-ByLcILYU.js.map +1 -0
  135. package/dist/{external-optimizer-process-DEzJ2CGX.js → external-optimizer-process-BRVmaDFe.js} +5 -6
  136. package/dist/{external-optimizer-process-DEzJ2CGX.js.map → external-optimizer-process-BRVmaDFe.js.map} +1 -1
  137. package/dist/{external-optimizer-subprocess-B_ukPtRD.js → external-optimizer-subprocess-U616hV_l.js} +24 -37
  138. package/dist/{external-optimizer-subprocess-B_ukPtRD.js.map → external-optimizer-subprocess-U616hV_l.js.map} +1 -1
  139. package/dist/{extract-usage-BZLU01kR.js → extract-usage-ISFqhfDz.js} +2 -3
  140. package/dist/{extract-usage-BZLU01kR.js.map → extract-usage-ISFqhfDz.js.map} +1 -1
  141. package/dist/{failure-cluster-DN0t63Z0.d.ts → failure-cluster-DOoa7CBg.d.ts} +3 -7
  142. package/dist/failure-cluster-DOoa7CBg.d.ts.map +1 -0
  143. package/dist/{failure-taxonomy-Bx5oWqaW.js → failure-taxonomy-9eQfXKoW.js} +2 -3
  144. package/dist/{failure-taxonomy-Bx5oWqaW.js.map → failure-taxonomy-9eQfXKoW.js.map} +1 -1
  145. package/dist/{feedback-trajectory-CYVJXolG.d.ts → feedback-trajectory-SBGncrCP.d.ts} +7 -13
  146. package/dist/feedback-trajectory-SBGncrCP.d.ts.map +1 -0
  147. package/dist/{finding-composition-8n0fFgVI.js → finding-composition-DlvE1Qul.js} +4 -6
  148. package/dist/{finding-composition-8n0fFgVI.js.map → finding-composition-DlvE1Qul.js.map} +1 -1
  149. package/dist/{findings-store-Bg4sdS-e.js → findings-store-B75Dspaq.js} +11 -14
  150. package/dist/{findings-store-Bg4sdS-e.js.map → findings-store-B75Dspaq.js.map} +1 -1
  151. package/dist/fuzz.d.ts +3 -17
  152. package/dist/fuzz.d.ts.map +1 -1
  153. package/dist/fuzz.js +30 -29
  154. package/dist/fuzz.js.map +1 -1
  155. package/dist/{hf-dataset-CKxIJQba.js → hf-dataset-DPVQXW5n.js} +362 -21
  156. package/dist/hf-dataset-DPVQXW5n.js.map +1 -0
  157. package/dist/hosted/index.d.ts +2 -6
  158. package/dist/hosted/index.d.ts.map +1 -1
  159. package/dist/hosted/index.js +1 -2
  160. package/dist/{index-CalAsXMR.d.ts → index-B1Bm9oJA.d.ts} +3 -15
  161. package/dist/index-B1Bm9oJA.d.ts.map +1 -0
  162. package/dist/{index-CdEVr8-O.d.ts → index-B7v2QHlD.d.ts} +24 -299
  163. package/dist/index-B7v2QHlD.d.ts.map +1 -0
  164. package/dist/{index-CTIRz-AB.d.ts → index-CUjeTDPv.d.ts} +14 -36
  165. package/dist/index-CUjeTDPv.d.ts.map +1 -0
  166. package/dist/{index-CfJULcW5.d.ts → index-DAk2quYu.d.ts} +18 -38
  167. package/dist/index-DAk2quYu.d.ts.map +1 -0
  168. package/dist/{index-D7fmC-1K.d.ts → index-DUn0GNiZ.d.ts} +183 -36
  169. package/dist/index-DUn0GNiZ.d.ts.map +1 -0
  170. package/dist/{index-CHxwfW5g.d.ts → index-DwUGehqX.d.ts} +3 -9
  171. package/dist/index-DwUGehqX.d.ts.map +1 -0
  172. package/dist/{index-jnuFLxOs.d.ts → index-aDPVYBIM.d.ts} +11 -39
  173. package/dist/index-aDPVYBIM.d.ts.map +1 -0
  174. package/dist/index.d.ts +55 -188
  175. package/dist/index.d.ts.map +1 -1
  176. package/dist/index.js +122 -195
  177. package/dist/index.js.map +1 -1
  178. package/dist/{integrity-D-s2iHiT.js → integrity-B1V6klyO.js} +12 -363
  179. package/dist/integrity-B1V6klyO.js.map +1 -0
  180. package/dist/{integrity-D9lBnv_K.d.ts → integrity-BAdVzT8u.d.ts} +4 -6
  181. package/dist/integrity-BAdVzT8u.d.ts.map +1 -0
  182. package/dist/{integrity-W4CADcFc.js → integrity-DOHt1mwU.js} +3 -4
  183. package/dist/{integrity-W4CADcFc.js.map → integrity-DOHt1mwU.js.map} +1 -1
  184. package/dist/{internal-BTK91Bqt.js → internal-v6XfOeJW.js} +6 -8
  185. package/dist/{internal-BTK91Bqt.js.map → internal-v6XfOeJW.js.map} +1 -1
  186. package/dist/{interval-Dq9gt7jx.js → interval-Bd2f4CRT.js} +6 -8
  187. package/dist/{interval-Dq9gt7jx.js.map → interval-Bd2f4CRT.js.map} +1 -1
  188. package/dist/{interval-ohuOJurX.d.ts → interval-CWyxqDpE.d.ts} +1 -5
  189. package/dist/interval-CWyxqDpE.d.ts.map +1 -0
  190. package/dist/{journal-C7om8Gum.js → journal-C1uLJi0w.js} +115 -121
  191. package/dist/{journal-C7om8Gum.js.map → journal-C1uLJi0w.js.map} +1 -1
  192. package/dist/{json-BhdsJaOQ.js → json-DtvZNAU9.js} +4 -6
  193. package/dist/{json-BhdsJaOQ.js.map → json-DtvZNAU9.js.map} +1 -1
  194. package/dist/json-recovery-DK4MDm5r.js +296 -0
  195. package/dist/json-recovery-DK4MDm5r.js.map +1 -0
  196. package/dist/{judge-calibration-BkXMIWA4.js → judge-calibration-DGqlfWW8.js} +5 -6
  197. package/dist/{judge-calibration-BkXMIWA4.js.map → judge-calibration-DGqlfWW8.js.map} +1 -1
  198. package/dist/{judge-calibration-DFtEMlde.d.ts → judge-calibration-DnrbQaXI.d.ts} +1 -3
  199. package/dist/judge-calibration-DnrbQaXI.d.ts.map +1 -0
  200. package/dist/{judge-gate-BVvmP00P.js → judge-gate-C2BCOt-M.js} +8 -12
  201. package/dist/{judge-gate-BVvmP00P.js.map → judge-gate-C2BCOt-M.js.map} +1 -1
  202. package/dist/judges-BLxg5p8E.js +20 -0
  203. package/dist/judges-BLxg5p8E.js.map +1 -0
  204. package/dist/{kind-factory-Dl0PmNQL.js → kind-factory-VKysp1ds.js} +23 -39
  205. package/dist/{kind-factory-Dl0PmNQL.js.map → kind-factory-VKysp1ds.js.map} +1 -1
  206. package/dist/ledger-core/index.d.ts +2 -2
  207. package/dist/ledger-core/index.js +3 -3
  208. package/dist/ledger-core/lock-holder.d.ts +1 -1
  209. package/dist/ledger-core/lock-holder.js +1 -2
  210. package/dist/{ledger-core-CAxUdDk0.js → ledger-core-CfT-FzPf.js} +5 -6
  211. package/dist/{ledger-core-CAxUdDk0.js.map → ledger-core-CfT-FzPf.js.map} +1 -1
  212. package/dist/{llm-client-b1ysZVIU.js → llm-client-kJ9EOqjt.js} +22 -30
  213. package/dist/{llm-client-b1ysZVIU.js.map → llm-client-kJ9EOqjt.js.map} +1 -1
  214. package/dist/{llm-judge-Cybq29bL.js → llm-judge-cgbhTKQp.js} +108 -164
  215. package/dist/llm-judge-cgbhTKQp.js.map +1 -0
  216. package/dist/{lock-holder-DaJbfpci.d.ts → lock-holder-DoxlZFkQ.d.ts} +1 -3
  217. package/dist/lock-holder-DoxlZFkQ.d.ts.map +1 -0
  218. package/dist/matrix/index.d.ts +3 -3
  219. package/dist/matrix/index.js +2 -2
  220. package/dist/{matrix-DtkZLD_3.d.ts → matrix-CBUzIZs4.d.ts} +4 -12
  221. package/dist/matrix-CBUzIZs4.d.ts.map +1 -0
  222. package/dist/{matrix-B8l-Nsxd.js → matrix-CgpX8wdm.js} +8 -13
  223. package/dist/matrix-CgpX8wdm.js.map +1 -0
  224. package/dist/{mean-BbA_JCzW.js → mean-CdDYG-us.js} +6 -9
  225. package/dist/{mean-BbA_JCzW.js.map → mean-CdDYG-us.js.map} +1 -1
  226. package/dist/meta-eval/index.d.ts +3 -3
  227. package/dist/meta-eval/index.js +17 -21
  228. package/dist/meta-eval/index.js.map +1 -1
  229. package/dist/{metrics-BKaPBtIG.js → metrics-DNCAUtuB.js} +2 -3
  230. package/dist/{metrics-BKaPBtIG.js.map → metrics-DNCAUtuB.js.map} +1 -1
  231. package/dist/{mint-CbdwjTPW.js → mint-D9ZysYtY.js} +7 -8
  232. package/dist/{mint-CbdwjTPW.js.map → mint-D9ZysYtY.js.map} +1 -1
  233. package/dist/{multi-layer-verifier-DEgMUk6v.d.ts → multi-layer-verifier-lM4aVN78.d.ts} +2 -4
  234. package/dist/multi-layer-verifier-lM4aVN78.d.ts.map +1 -0
  235. package/dist/{multiplicity-Sg0U7h8j.js → multiplicity-DAd4xaDC.js} +3 -4
  236. package/dist/{multiplicity-Sg0U7h8j.js.map → multiplicity-DAd4xaDC.js.map} +1 -1
  237. package/dist/{multiplicity-DIWHvysC.d.ts → multiplicity-D_SEsc5j.d.ts} +1 -3
  238. package/dist/multiplicity-D_SEsc5j.d.ts.map +1 -0
  239. package/dist/multishot/golden/index.d.ts +1 -17
  240. package/dist/multishot/golden/index.d.ts.map +1 -1
  241. package/dist/multishot/golden/index.js +10 -17
  242. package/dist/multishot/golden/index.js.map +1 -1
  243. package/dist/multishot/index.d.ts +2 -10
  244. package/dist/multishot/index.d.ts.map +1 -1
  245. package/dist/multishot/index.js +11 -18
  246. package/dist/multishot/index.js.map +1 -1
  247. package/dist/{nonnegative-number-DvdMxg_f.js → nonnegative-number-lEYbOsuh.js} +2 -3
  248. package/dist/{nonnegative-number-DvdMxg_f.js.map → nonnegative-number-lEYbOsuh.js.map} +1 -1
  249. package/dist/openapi.json +1 -1
  250. package/dist/{otel-spans-CdN909k1.js → otel-spans-BsGzTWIK.js} +5 -6
  251. package/dist/{otel-spans-CdN909k1.js.map → otel-spans-BsGzTWIK.js.map} +1 -1
  252. package/dist/{otlp-attributes-D9ptWaIJ.js → otlp-attributes-Boeb7gtH.js} +2 -3
  253. package/dist/{otlp-attributes-D9ptWaIJ.js.map → otlp-attributes-Boeb7gtH.js.map} +1 -1
  254. package/dist/{outcome-observations-FLmRpgYa.js → outcome-observations-D4snOtUb.js} +4 -5
  255. package/dist/{outcome-observations-FLmRpgYa.js.map → outcome-observations-D4snOtUb.js.map} +1 -1
  256. package/dist/{outcome-store-DUcMj-3D.js → outcome-store-TarrcfHG.js} +2 -3
  257. package/dist/{outcome-store-DUcMj-3D.js.map → outcome-store-TarrcfHG.js.map} +1 -1
  258. package/dist/{package-version-D7lQHt_-.js → package-version-CJl_pY9W.js} +2 -3
  259. package/dist/{package-version-D7lQHt_-.js.map → package-version-CJl_pY9W.js.map} +1 -1
  260. package/dist/{paired-arms-B2ttLc0_.js → paired-arms-D-54hO-k.js} +10 -14
  261. package/dist/{paired-arms-B2ttLc0_.js.map → paired-arms-D-54hO-k.js.map} +1 -1
  262. package/dist/{paired-binary-B_nejA44.js → paired-binary-BR0nwHOA.js} +3 -4
  263. package/dist/{paired-binary-B_nejA44.js.map → paired-binary-BR0nwHOA.js.map} +1 -1
  264. package/dist/{paired-promotion-decision-CQMJ5xGN.d.ts → paired-promotion-decision-BDnqepZ1.d.ts} +1 -5
  265. package/dist/paired-promotion-decision-BDnqepZ1.d.ts.map +1 -0
  266. package/dist/{paired-promotion-decision-D0SHb-ZL.js → paired-promotion-decision-FGvHA4p_.js} +5 -7
  267. package/dist/{paired-promotion-decision-D0SHb-ZL.js.map → paired-promotion-decision-FGvHA4p_.js.map} +1 -1
  268. package/dist/{pareto-BiBnQXAE.js → pareto-B9udAt2i.js} +28 -50
  269. package/dist/pareto-B9udAt2i.js.map +1 -0
  270. package/dist/pipelines/index.d.ts +5 -11
  271. package/dist/pipelines/index.d.ts.map +1 -1
  272. package/dist/pipelines/index.js +6 -8
  273. package/dist/pipelines/index.js.map +1 -1
  274. package/dist/{power-and-mde-CQX-0weG.js → power-and-mde-ClI6RWw4.js} +4 -5
  275. package/dist/{power-and-mde-CQX-0weG.js.map → power-and-mde-ClI6RWw4.js.map} +1 -1
  276. package/dist/{predicate-FdKmElA_.js → predicate-BYHA4MBn.js} +2 -3
  277. package/dist/{predicate-FdKmElA_.js.map → predicate-BYHA4MBn.js.map} +1 -1
  278. package/dist/{prime-bridge-transport-6feEglLf.d.ts → prime-bridge-transport-Cfqir_Im.d.ts} +1 -3
  279. package/dist/prime-bridge-transport-Cfqir_Im.d.ts.map +1 -0
  280. package/dist/{prime-bridge-transport-Z3cpKGoV.js → prime-bridge-transport-Csd5SQg7.js} +2 -3
  281. package/dist/{prime-bridge-transport-Z3cpKGoV.js.map → prime-bridge-transport-Csd5SQg7.js.map} +1 -1
  282. package/dist/{prime-protocol-BGxjfhM4.d.ts → prime-protocol-COFkxas6.d.ts} +4 -8
  283. package/dist/prime-protocol-COFkxas6.d.ts.map +1 -0
  284. package/dist/{prime-protocol-BFgGrEMP.js → prime-protocol-CrhpXRz9.js} +4 -6
  285. package/dist/{prime-protocol-BFgGrEMP.js.map → prime-protocol-CrhpXRz9.js.map} +1 -1
  286. package/dist/profile-cell.d.ts +1 -1
  287. package/dist/profile-cell.js +1 -2
  288. package/dist/{promotion-gate-CkVZHagC.d.ts → promotion-gate-CixshGI8.d.ts} +5 -11
  289. package/dist/promotion-gate-CixshGI8.d.ts.map +1 -0
  290. package/dist/{promotion-policy-6A8osGr_.js → promotion-policy-CBYeD4zi.js} +5 -6
  291. package/dist/{promotion-policy-6A8osGr_.js.map → promotion-policy-CBYeD4zi.js.map} +1 -1
  292. package/dist/{proposal-findings-DqLUWsAG.js → proposal-findings-WFQrxnfe.js} +3 -4
  293. package/dist/{proposal-findings-DqLUWsAG.js.map → proposal-findings-WFQrxnfe.js.map} +1 -1
  294. package/dist/{quantile--0yb07pD.js → quantile-CncXP-Ss.js} +2 -3
  295. package/dist/{quantile--0yb07pD.js.map → quantile-CncXP-Ss.js.map} +1 -1
  296. package/dist/{query-B_RZ36an.js → query-CGXzO9d4.js} +5 -6
  297. package/dist/{query-B_RZ36an.js.map → query-CGXzO9d4.js.map} +1 -1
  298. package/dist/{query-Cmv_U8vf.d.ts → query-UD0B08Sb.d.ts} +4 -6
  299. package/dist/query-UD0B08Sb.d.ts.map +1 -0
  300. package/dist/{random-DGEyr3zG.d.ts → random-BN150Q_X.d.ts} +1 -5
  301. package/dist/random-BN150Q_X.d.ts.map +1 -0
  302. package/dist/{random-DDDcC7YU.js → random-DrzcgC7F.js} +3 -4
  303. package/dist/{random-DDDcC7YU.js.map → random-DrzcgC7F.js.map} +1 -1
  304. package/dist/{raw-provider-sink-75w4FWBj.js → raw-provider-sink-DDLkP_eF.js} +3 -4
  305. package/dist/{raw-provider-sink-75w4FWBj.js.map → raw-provider-sink-DDLkP_eF.js.map} +1 -1
  306. package/dist/{record-id-DUgsK5qp.js → record-id-CWZXFh58.js} +2 -3
  307. package/dist/{record-id-DUgsK5qp.js.map → record-id-CWZXFh58.js.map} +1 -1
  308. package/dist/{redact-DXdlFb_U.d.ts → redact-C_wzC4c_.d.ts} +1 -3
  309. package/dist/redact-C_wzC4c_.d.ts.map +1 -0
  310. package/dist/{redact-mtkTiJVk.js → redact-D6APJS1d.js} +3 -5
  311. package/dist/{redact-mtkTiJVk.js.map → redact-D6APJS1d.js.map} +1 -1
  312. package/dist/{registry-BcdJmyoU.d.ts → registry-dhdDoAV8.d.ts} +5 -11
  313. package/dist/registry-dhdDoAV8.d.ts.map +1 -0
  314. package/dist/{release-confidence-CYIFH-fp.js → release-confidence-CTUJz5mM.js} +10 -16
  315. package/dist/release-confidence-CTUJz5mM.js.map +1 -0
  316. package/dist/{render-BhJqXoBH.js → render-pfAZ7IR4.js} +266 -33
  317. package/dist/render-pfAZ7IR4.js.map +1 -0
  318. package/dist/{reporting-html-Kvlc8oMt.js → reporting-html-DMXIjATy.js} +2 -3
  319. package/dist/{reporting-html-Kvlc8oMt.js.map → reporting-html-DMXIjATy.js.map} +1 -1
  320. package/dist/reporting.d.ts +6 -6
  321. package/dist/reporting.js +7 -7
  322. package/dist/{researcher-DKWtoMWk.d.ts → researcher-CLnNJ7Or.d.ts} +8 -12
  323. package/dist/researcher-CLnNJ7Or.d.ts.map +1 -0
  324. package/dist/{reward-nw2xZGZG.js → reward-P0VD_Aft.js} +2 -3
  325. package/dist/{reward-nw2xZGZG.js.map → reward-P0VD_Aft.js.map} +1 -1
  326. package/dist/{reward-BeUgVVC_.d.ts → reward-ST4PXNXF.d.ts} +2 -4
  327. package/dist/reward-ST4PXNXF.d.ts.map +1 -0
  328. package/dist/{reward-hacking-WTxUbtbb.d.ts → reward-hacking-C9hPVT0Q.d.ts} +4 -8
  329. package/dist/reward-hacking-C9hPVT0Q.d.ts.map +1 -0
  330. package/dist/{reward-hacking-ByuETaIb.js → reward-hacking-DZzHZlS1.js} +5 -7
  331. package/dist/{reward-hacking-ByuETaIb.js.map → reward-hacking-DZzHZlS1.js.map} +1 -1
  332. package/dist/rl.d.ts +26 -63
  333. package/dist/rl.d.ts.map +1 -1
  334. package/dist/rl.js +35 -52
  335. package/dist/rl.js.map +1 -1
  336. package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
  337. package/dist/rollout/index.d.ts +6 -6
  338. package/dist/rollout/index.js +7 -7
  339. package/dist/{rollout-Dd1ucT_M.js → rollout-BhkMpAJT.js} +279 -16
  340. package/dist/rollout-BhkMpAJT.js.map +1 -0
  341. package/dist/{terminal-record-CB9BFtjS.js → rollout-nodes-BHR9Q5jP.js} +351 -11
  342. package/dist/rollout-nodes-BHR9Q5jP.js.map +1 -0
  343. package/dist/{round-decimal-COrKglMh.js → round-decimal-ZmjAQPo1.js} +2 -3
  344. package/dist/{round-decimal-COrKglMh.js.map → round-decimal-ZmjAQPo1.js.map} +1 -1
  345. package/dist/{rubric-predictive-validity-Cd5SCtAf.d.ts → rubric-predictive-validity-B3RzbwOx.d.ts} +2 -8
  346. package/dist/rubric-predictive-validity-B3RzbwOx.d.ts.map +1 -0
  347. package/dist/{rubric-predictive-validity-CeKW2GQN.js → rubric-predictive-validity-CQp_M0vy.js} +3 -4
  348. package/dist/{rubric-predictive-validity-CeKW2GQN.js.map → rubric-predictive-validity-CQp_M0vy.js.map} +1 -1
  349. package/dist/{run-record-CysKLB93.js → run-record-CZy4-TnZ.js} +4 -5
  350. package/dist/{run-record-CysKLB93.js.map → run-record-CZy4-TnZ.js.map} +1 -1
  351. package/dist/{run-record-C3awiXPf.d.ts → run-record-D2BFMPGl.d.ts} +5 -7
  352. package/dist/run-record-D2BFMPGl.d.ts.map +1 -0
  353. package/dist/{run-record-DhEJgoPz.js → run-record-DEjx43cI.js} +6 -7
  354. package/dist/{run-record-DhEJgoPz.js.map → run-record-DEjx43cI.js.map} +1 -1
  355. package/dist/{sandbox-harness-BlSOu4LX.d.ts → sandbox-harness-B3Kx1fOA.d.ts} +1 -3
  356. package/dist/sandbox-harness-B3Kx1fOA.d.ts.map +1 -0
  357. package/dist/{schema-D6EVKzTB.d.ts → schema-CkIvnmLU.d.ts} +2 -43
  358. package/dist/schema-CkIvnmLU.d.ts.map +1 -0
  359. package/dist/{schema-Bt2vLFm3.js → schema-D-xu3MU_.js} +2 -3
  360. package/dist/{schema-Bt2vLFm3.js.map → schema-D-xu3MU_.js.map} +1 -1
  361. package/dist/{schema-C-ziyJD7.d.ts → schema-DkFJr3Y8.d.ts} +111 -48
  362. package/dist/schema-DkFJr3Y8.d.ts.map +1 -0
  363. package/dist/{schema-CvhfLjtZ.js → schema-YUIXT8iW.js} +37 -7
  364. package/dist/schema-YUIXT8iW.js.map +1 -0
  365. package/dist/search/index.d.ts +3 -35
  366. package/dist/search/index.d.ts.map +1 -1
  367. package/dist/search/index.js +4 -5
  368. package/dist/{search-kernel-CctpiDd2.d.ts → search-kernel-CBdwFZ05.d.ts} +10 -36
  369. package/dist/search-kernel-CBdwFZ05.d.ts.map +1 -0
  370. package/dist/{search-ledger-CZRqtFbW.js → search-ledger-BsVi-Ngv.js} +17 -26
  371. package/dist/{search-ledger-CZRqtFbW.js.map → search-ledger-BsVi-Ngv.js.map} +1 -1
  372. package/dist/{search-ledger-file-Bd5Tioq6.js → search-ledger-file-DTBD6X-y.js} +6 -8
  373. package/dist/{search-ledger-file-Bd5Tioq6.js.map → search-ledger-file-DTBD6X-y.js.map} +1 -1
  374. package/dist/{search-ledger-types-p2xKfiDJ.d.ts → search-ledger-types-qiYRUo_N.d.ts} +5 -9
  375. package/dist/search-ledger-types-qiYRUo_N.d.ts.map +1 -0
  376. package/dist/{search-shipper-Dn3NLsuH.js → search-shipper-pdg4viK7.js} +8 -13
  377. package/dist/{search-shipper-Dn3NLsuH.js.map → search-shipper-pdg4viK7.js.map} +1 -1
  378. package/dist/{search-summary-D4bwYnAE.js → search-summary-Ct7SrmVc.js} +6 -7
  379. package/dist/{search-summary-D4bwYnAE.js.map → search-summary-Ct7SrmVc.js.map} +1 -1
  380. package/dist/{sequential-CimQrbjv.js → sequential-B1I0tRfL.js} +6 -7
  381. package/dist/{sequential-CimQrbjv.js.map → sequential-B1I0tRfL.js.map} +1 -1
  382. package/dist/{sequential-KwGspfeR.d.ts → sequential-Bb_pdTqG.d.ts} +1 -3
  383. package/dist/sequential-Bb_pdTqG.d.ts.map +1 -0
  384. package/dist/{sequential-BVv1sjsw.js → sequential-Bjs5roiK.js} +2 -3
  385. package/dist/{sequential-BVv1sjsw.js.map → sequential-Bjs5roiK.js.map} +1 -1
  386. package/dist/{sequential-eprocess-DodI6RoF.js → sequential-eprocess-C1YLwFaz.js} +3 -4
  387. package/dist/{sequential-eprocess-DodI6RoF.js.map → sequential-eprocess-C1YLwFaz.js.map} +1 -1
  388. package/dist/{server-ChhXPCgX.js → server-DA6h3co5.js} +11 -17
  389. package/dist/{server-ChhXPCgX.js.map → server-DA6h3co5.js.map} +1 -1
  390. package/dist/{single-run-lock-Dekd8_Wv.js → single-run-lock-BGlW3OSk.js} +3 -4
  391. package/dist/{single-run-lock-Dekd8_Wv.js.map → single-run-lock-BGlW3OSk.js.map} +1 -1
  392. package/dist/{skillopt-optimization-method-sB_-yi1G.js → skillopt-optimization-method-qB1M554K.js} +38 -57
  393. package/dist/{skillopt-optimization-method-sB_-yi1G.js.map → skillopt-optimization-method-qB1M554K.js.map} +1 -1
  394. package/dist/{spans-CVngGij3.d.ts → spans-vZoW__3q.d.ts} +2 -4
  395. package/dist/spans-vZoW__3q.d.ts.map +1 -0
  396. package/dist/{statistical-heldout-BjzSOmLH.d.ts → statistical-heldout-Cei036nE.d.ts} +9 -37
  397. package/dist/statistical-heldout-Cei036nE.d.ts.map +1 -0
  398. package/dist/{statistical-heldout-Bksv92Th.js → statistical-heldout-TP6ndL0B.js} +4 -5
  399. package/dist/{statistical-heldout-Bksv92Th.js.map → statistical-heldout-TP6ndL0B.js.map} +1 -1
  400. package/dist/{steps-DlepJPwD.d.ts → steps-B8fYY_Vo.d.ts} +1 -3
  401. package/dist/steps-B8fYY_Vo.d.ts.map +1 -0
  402. package/dist/{store-B3nWRy3B.d.ts → store-CMs5wGXP.d.ts} +2 -4
  403. package/dist/store-CMs5wGXP.d.ts.map +1 -0
  404. package/dist/{store-BhNuLdJw.js → store-ZykIyQmy.js} +2 -3
  405. package/dist/{store-BhNuLdJw.js.map → store-ZykIyQmy.js.map} +1 -1
  406. package/dist/{store-otlp-CFf27E8_.js → store-otlp-DmLm65XW.js} +8 -13
  407. package/dist/{store-otlp-CFf27E8_.js.map → store-otlp-DmLm65XW.js.map} +1 -1
  408. package/dist/{store-tool-spans-DxsFwtdr.d.ts → store-tool-spans-B3i3fl0A.d.ts} +11 -29
  409. package/dist/store-tool-spans-B3i3fl0A.d.ts.map +1 -0
  410. package/dist/{store-tool-spans-BK_8FjGG.js → store-tool-spans-C2g8UYm-.js} +17 -41
  411. package/dist/{store-tool-spans-BK_8FjGG.js.map → store-tool-spans-C2g8UYm-.js.map} +1 -1
  412. package/dist/storyboard/index.d.ts +1 -5
  413. package/dist/storyboard/index.d.ts.map +1 -1
  414. package/dist/storyboard/index.js +3 -5
  415. package/dist/storyboard/index.js.map +1 -1
  416. package/dist/{summary-report-C8V49Jt3.d.ts → summary-report-0La5vejY.d.ts} +5 -13
  417. package/dist/summary-report-0La5vejY.d.ts.map +1 -0
  418. package/dist/{summary-report-DHDWxe6p.js → summary-report-CPfsrLac.js} +21 -30
  419. package/dist/summary-report-CPfsrLac.js.map +1 -0
  420. package/dist/supervisor-run/index.d.ts +30 -29
  421. package/dist/supervisor-run/index.d.ts.map +1 -1
  422. package/dist/supervisor-run/index.js +6 -7
  423. package/dist/{systemone-CHnqwmYg.d.ts → systemone-Cw2txK5m.d.ts} +12 -24
  424. package/dist/systemone-Cw2txK5m.d.ts.map +1 -0
  425. package/dist/{systemone-protocol-Bl2EI2KQ.d.ts → systemone-protocol-C4t7JH4Y.d.ts} +1 -3
  426. package/dist/systemone-protocol-C4t7JH4Y.d.ts.map +1 -0
  427. package/dist/systemone-protocol.d.ts +1 -1
  428. package/dist/systemone-protocol.js +2 -3
  429. package/dist/{systemone-review-cQ9acAsb.d.ts → systemone-review-BLgxt-4Q.d.ts} +8 -10
  430. package/dist/systemone-review-BLgxt-4Q.d.ts.map +1 -0
  431. package/dist/{systemone-review-DFGtIUcf.js → systemone-review-S49gsy_y.js} +5 -6
  432. package/dist/{systemone-review-DFGtIUcf.js.map → systemone-review-S49gsy_y.js.map} +1 -1
  433. package/dist/systemone.d.ts +4 -4
  434. package/dist/systemone.js +3 -3
  435. package/dist/{task-failure-attributes-BMsblaDh.js → task-failure-attributes-CC6VuIpk.js} +12 -11
  436. package/dist/task-failure-attributes-CC6VuIpk.js.map +1 -0
  437. package/dist/{tool-groups-b3oU_D88.d.ts → tool-groups-C3K-d3gd.d.ts} +3 -5
  438. package/dist/tool-groups-C3K-d3gd.d.ts.map +1 -0
  439. package/dist/{tool-waste-CkjzWmeY.d.ts → tool-waste-BFG1vwTV.d.ts} +4 -16
  440. package/dist/tool-waste-BFG1vwTV.d.ts.map +1 -0
  441. package/dist/{tool-waste-DLsjS_p-.js → tool-waste-CLJ46AbT.js} +10 -26
  442. package/dist/{tool-waste-DLsjS_p-.js.map → tool-waste-CLJ46AbT.js.map} +1 -1
  443. package/dist/trace-attributes.d.ts +1 -1
  444. package/dist/trace-attributes.js +1 -2
  445. package/dist/{trace-questions-BmT8M6UQ.d.ts → trace-questions-ej5AEJ5X.d.ts} +4 -6
  446. package/dist/trace-questions-ej5AEJ5X.d.ts.map +1 -0
  447. package/dist/trace-repair/index.d.ts +46 -92
  448. package/dist/trace-repair/index.d.ts.map +1 -1
  449. package/dist/trace-repair/index.js +32 -54
  450. package/dist/trace-repair/index.js.map +1 -1
  451. package/dist/traces.d.ts +13 -29
  452. package/dist/traces.d.ts.map +1 -1
  453. package/dist/traces.js +18 -22
  454. package/dist/traces.js.map +1 -1
  455. package/dist/{trajectory-D_7rLrvE.js → trajectory-O3GDHmev.js} +2 -3
  456. package/dist/{trajectory-D_7rLrvE.js.map → trajectory-O3GDHmev.js.map} +1 -1
  457. package/dist/trajectory-replay/index.d.ts +2 -22
  458. package/dist/trajectory-replay/index.d.ts.map +1 -1
  459. package/dist/trajectory-replay/index.js +19 -30
  460. package/dist/trajectory-replay/index.js.map +1 -1
  461. package/dist/{tree-DSqwJpL9.js → tree-DrIChF4a.js} +39 -68
  462. package/dist/{tree-DSqwJpL9.js.map → tree-DrIChF4a.js.map} +1 -1
  463. package/dist/{types-B_IFcKp5.d.ts → types-0KglnQ9o.d.ts} +3 -15
  464. package/dist/types-0KglnQ9o.d.ts.map +1 -0
  465. package/dist/{types-DZ0mYVw9.d.ts → types-0oMg7zee.d.ts} +3 -5
  466. package/dist/types-0oMg7zee.d.ts.map +1 -0
  467. package/dist/{types-CnWmj8NW.js → types-BK0blWhe.js} +3 -4
  468. package/dist/{types-CnWmj8NW.js.map → types-BK0blWhe.js.map} +1 -1
  469. package/dist/{types-CmXY0PQf.d.ts → types-C-aOqgt2.d.ts} +2 -5
  470. package/dist/types-C-aOqgt2.d.ts.map +1 -0
  471. package/dist/{types-M6eF9m-r.d.ts → types-C54Uk_a1.d.ts} +84 -24
  472. package/dist/types-C54Uk_a1.d.ts.map +1 -0
  473. package/dist/{types-BXgASBCL.js → types-DK4vNv5q.js} +2 -3
  474. package/dist/{types-BXgASBCL.js.map → types-DK4vNv5q.js.map} +1 -1
  475. package/dist/{types-6Lfdlshp.d.ts → types-DzCO-S1m.d.ts} +50 -62
  476. package/dist/types-DzCO-S1m.d.ts.map +1 -0
  477. package/dist/{verdict-BGQmxQ8A.js → verdict-C8TcdwfD.js} +3 -4
  478. package/dist/{verdict-BGQmxQ8A.js.map → verdict-C8TcdwfD.js.map} +1 -1
  479. package/dist/{verdict-C24NELtN.d.ts → verdict-D_qiBQ6_.d.ts} +1 -5
  480. package/dist/verdict-D_qiBQ6_.d.ts.map +1 -0
  481. package/dist/{verdict-cache-CL_7tePD.js → verdict-cache-BVH-fl18.js} +3 -4
  482. package/dist/{verdict-cache-CL_7tePD.js.map → verdict-cache-BVH-fl18.js.map} +1 -1
  483. package/dist/wire/index.d.ts +43 -51
  484. package/dist/wire/index.d.ts.map +1 -1
  485. package/dist/wire/index.js +1 -2
  486. package/docs/concepts.md +1 -0
  487. package/docs/eval-surface-map.md +15 -0
  488. package/docs/rollout.md +132 -6
  489. package/package.json +18 -18
  490. package/dist/adversarial-smnADNFS.d.ts.map +0 -1
  491. package/dist/agent-profile-CNmwfaqq.d.ts.map +0 -1
  492. package/dist/agent-profile-cell-BcpFbNd5.d.ts.map +0 -1
  493. package/dist/analyze-runs-DfX6dHP0.d.ts.map +0 -1
  494. package/dist/attribute-vocabulary-CcXqHODT.d.ts.map +0 -1
  495. package/dist/benchmark-command-Cnjfo0Zh.js.map +0 -1
  496. package/dist/campaign-evidence-DunzcJGv.js.map +0 -1
  497. package/dist/campaign-uddTlFg5.js.map +0 -1
  498. package/dist/canonical-CFpojCN5.d.ts.map +0 -1
  499. package/dist/client-hwo3cJjR.d.ts.map +0 -1
  500. package/dist/completion-verifier-asaV1nSj.js.map +0 -1
  501. package/dist/cost-ledger-C1W3ICmP.d.ts.map +0 -1
  502. package/dist/dataset-DQqhOCPt.d.ts.map +0 -1
  503. package/dist/default-registry-CLG5YqGS.d.ts.map +0 -1
  504. package/dist/define-agent-eval-JKt3gMQr.d.ts.map +0 -1
  505. package/dist/descriptive-B2iPaT9J.d.ts +0 -89
  506. package/dist/descriptive-B2iPaT9J.d.ts.map +0 -1
  507. package/dist/descriptive-CVNy48rR.js.map +0 -1
  508. package/dist/emitter-DABYYTcH.d.ts.map +0 -1
  509. package/dist/engine-dtRVeuQs.d.ts.map +0 -1
  510. package/dist/errors-DEE6u6ot.d.ts.map +0 -1
  511. package/dist/evaluation-DblGquCB.d.ts.map +0 -1
  512. package/dist/exact-types-Do63KoKn.d.ts.map +0 -1
  513. package/dist/exporters-DWvM16LE.js.map +0 -1
  514. package/dist/exporters-Dk3oEbK_.d.ts.map +0 -1
  515. package/dist/failure-cluster-DN0t63Z0.d.ts.map +0 -1
  516. package/dist/feedback-trajectory-CYVJXolG.d.ts.map +0 -1
  517. package/dist/hf-dataset-CKxIJQba.js.map +0 -1
  518. package/dist/index-CHxwfW5g.d.ts.map +0 -1
  519. package/dist/index-CTIRz-AB.d.ts.map +0 -1
  520. package/dist/index-CalAsXMR.d.ts.map +0 -1
  521. package/dist/index-CdEVr8-O.d.ts.map +0 -1
  522. package/dist/index-CfJULcW5.d.ts.map +0 -1
  523. package/dist/index-D7fmC-1K.d.ts.map +0 -1
  524. package/dist/index-jnuFLxOs.d.ts.map +0 -1
  525. package/dist/integrity-D-s2iHiT.js.map +0 -1
  526. package/dist/integrity-D9lBnv_K.d.ts.map +0 -1
  527. package/dist/interval-ohuOJurX.d.ts.map +0 -1
  528. package/dist/judge-calibration-DFtEMlde.d.ts.map +0 -1
  529. package/dist/llm-judge-Cybq29bL.js.map +0 -1
  530. package/dist/lock-holder-DaJbfpci.d.ts.map +0 -1
  531. package/dist/matrix-B8l-Nsxd.js.map +0 -1
  532. package/dist/matrix-DtkZLD_3.d.ts.map +0 -1
  533. package/dist/mint-CkzpVPdz.d.ts +0 -81
  534. package/dist/mint-CkzpVPdz.d.ts.map +0 -1
  535. package/dist/multi-layer-verifier-DEgMUk6v.d.ts.map +0 -1
  536. package/dist/multiplicity-DIWHvysC.d.ts.map +0 -1
  537. package/dist/paired-promotion-decision-CQMJ5xGN.d.ts.map +0 -1
  538. package/dist/pareto-BiBnQXAE.js.map +0 -1
  539. package/dist/prime-bridge-transport-6feEglLf.d.ts.map +0 -1
  540. package/dist/prime-protocol-BGxjfhM4.d.ts.map +0 -1
  541. package/dist/promotion-gate-CkVZHagC.d.ts.map +0 -1
  542. package/dist/query-Cmv_U8vf.d.ts.map +0 -1
  543. package/dist/random-DGEyr3zG.d.ts.map +0 -1
  544. package/dist/redact-DXdlFb_U.d.ts.map +0 -1
  545. package/dist/registry-BcdJmyoU.d.ts.map +0 -1
  546. package/dist/release-confidence-CYIFH-fp.js.map +0 -1
  547. package/dist/render-BhJqXoBH.js.map +0 -1
  548. package/dist/researcher-DKWtoMWk.d.ts.map +0 -1
  549. package/dist/reward-BeUgVVC_.d.ts.map +0 -1
  550. package/dist/reward-hacking-WTxUbtbb.d.ts.map +0 -1
  551. package/dist/rollout-Dd1ucT_M.js.map +0 -1
  552. package/dist/rubric-predictive-validity-Cd5SCtAf.d.ts.map +0 -1
  553. package/dist/run-record-C3awiXPf.d.ts.map +0 -1
  554. package/dist/sandbox-harness-BlSOu4LX.d.ts.map +0 -1
  555. package/dist/schema-C-ziyJD7.d.ts.map +0 -1
  556. package/dist/schema-CvhfLjtZ.js.map +0 -1
  557. package/dist/schema-D6EVKzTB.d.ts.map +0 -1
  558. package/dist/search-kernel-CctpiDd2.d.ts.map +0 -1
  559. package/dist/search-ledger-types-p2xKfiDJ.d.ts.map +0 -1
  560. package/dist/sequential-KwGspfeR.d.ts.map +0 -1
  561. package/dist/spans-CVngGij3.d.ts.map +0 -1
  562. package/dist/statistical-heldout-BjzSOmLH.d.ts.map +0 -1
  563. package/dist/steps-DlepJPwD.d.ts.map +0 -1
  564. package/dist/store-B3nWRy3B.d.ts.map +0 -1
  565. package/dist/store-tool-spans-DxsFwtdr.d.ts.map +0 -1
  566. package/dist/summary-report-C8V49Jt3.d.ts.map +0 -1
  567. package/dist/summary-report-DHDWxe6p.js.map +0 -1
  568. package/dist/systemone-CHnqwmYg.d.ts.map +0 -1
  569. package/dist/systemone-protocol-Bl2EI2KQ.d.ts.map +0 -1
  570. package/dist/systemone-review-cQ9acAsb.d.ts.map +0 -1
  571. package/dist/task-failure-attributes-BMsblaDh.js.map +0 -1
  572. package/dist/terminal-record-CB9BFtjS.js.map +0 -1
  573. package/dist/tool-groups-b3oU_D88.d.ts.map +0 -1
  574. package/dist/tool-waste-CkjzWmeY.d.ts.map +0 -1
  575. package/dist/trace-questions-BmT8M6UQ.d.ts.map +0 -1
  576. package/dist/types-6Lfdlshp.d.ts.map +0 -1
  577. package/dist/types-B_IFcKp5.d.ts.map +0 -1
  578. package/dist/types-CmXY0PQf.d.ts.map +0 -1
  579. package/dist/types-DZ0mYVw9.d.ts.map +0 -1
  580. package/dist/types-M6eF9m-r.d.ts.map +0 -1
  581. package/dist/verdict-C24NELtN.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/meta-eval/correlation-study.ts","../../src/meta-eval/evaluator-admission.ts","../../src/meta-eval/judge-panel-calibration.ts","../../src/meta-eval/plants.ts"],"sourcesContent":["/**\n * Correlation study — \"does our eval score predict real-world outcomes?\"\n *\n * Joins traces and outcomes by runId and reports descriptive correlations.\n * Independent runs are the bootstrap observation unit.\n * Association alone does not establish causation or held-out predictive performance.\n */\n\nimport { runMetricExtractor } from '../trace/query'\nimport type { Run } from '../trace/schema'\nimport type { TraceStore } from '../trace/store'\nimport {\n assertUniqueObservationIds,\n correlationSummary,\n hasVariation,\n reduceOutcomeMetric,\n validateObservationOptions,\n} from './outcome-observations'\nimport type { DeploymentOutcome, OutcomeFilter, OutcomeStore } from './outcome-store'\n\nexport interface EvalMetricSpec {\n id: string\n /** Extract a scalar from a run. Omit it and `id` must name one of\n * `RUN_METRICS`; any other `id` is refused. */\n extract?: (run: Run, store: TraceStore) => Promise<number | null>\n}\n\nexport interface OutcomePair {\n evalMetric: string\n outcomeMetric: string\n}\n\nexport interface CorrelationResult {\n evalMetric: string\n outcomeMetric: string\n n: number\n pearson: number\n spearman: number\n /** 95% bootstrap CI for Pearson. */\n pearsonCi95: { lower: number; upper: number } | null\n /** 95% bootstrap CI for Spearman; null when no resample is estimable. */\n spearmanCi95: { lower: number; upper: number } | null\n /** Rough verdict: 'strong' ≥ 0.7, 'moderate' ≥ 0.4, else 'weak'. */\n verdict: 'strong' | 'moderate' | 'weak'\n}\n\nexport interface CorrelationStudyResult {\n pairs: CorrelationResult[]\n /** Declared pairs without an estimable correlation, including their usable sample count. */\n excludedPairs: Array<\n OutcomePair & {\n n: number\n reason: 'insufficient_samples' | 'constant_eval_metric' | 'constant_outcome'\n }\n >\n joinedSamples: number\n skippedRuns: number\n}\n\nexport interface CorrelationStudyOptions {\n /** Only join outcomes captured within this window after run.startedAt. */\n maxCaptureLagMs?: number\n /** Restrict to a subset of outcomes (cohort, region, source). */\n outcomeFilter?: OutcomeFilter\n /** Which outcome per run to use when multiple exist. Default 'latest'. */\n reduction?: 'latest' | 'mean' | 'max'\n /** Bootstrap iterations for the CI. Default 500. */\n bootstrapIterations?: number\n /** Seed for the bootstrap resampler. Absent, the seed is derived from the\n * paired observations, so the same study reproduces the same interval. */\n seed?: number\n}\n\nexport async function correlationStudy(\n traceStore: TraceStore,\n outcomeStore: OutcomeStore,\n evalMetrics: EvalMetricSpec[],\n outcomeMetricNames: string[],\n options: CorrelationStudyOptions = {},\n): Promise<CorrelationStudyResult> {\n const reduction = options.reduction ?? 'latest'\n const iterations = options.bootstrapIterations ?? 500\n const seed = options.seed\n validateObservationOptions(reduction, iterations, seed)\n assertUniqueObservationIds(\n evalMetrics.map((metric) => metric.id),\n 'eval metric',\n )\n assertUniqueObservationIds(outcomeMetricNames, 'outcome metric')\n const maxLag = options.maxCaptureLagMs ?? Infinity\n if (maxLag < 0 || Number.isNaN(maxLag)) {\n throw new Error('maxCaptureLagMs must be nonnegative')\n }\n const extractors = evalMetrics.map((metric) => ({\n ...metric,\n extract: metric.extract ?? runMetricExtractor(metric.id),\n }))\n const metricNames = [...outcomeMetricNames]\n const runs = await traceStore.listRuns()\n assertUniqueObservationIds(\n runs.map((run) => run.runId),\n 'runId',\n )\n const outcomes = await outcomeStore.list(options.outcomeFilter)\n const outcomesByRun = new Map<string, DeploymentOutcome[]>()\n for (const o of outcomes) {\n const arr = outcomesByRun.get(o.runId) ?? []\n arr.push(o)\n outcomesByRun.set(o.runId, arr)\n }\n\n const pairs: Array<{ evalMetric: string; outcomeMetric: string; xs: number[]; ys: number[] }> = []\n for (const em of extractors) {\n for (const om of metricNames) {\n pairs.push({ evalMetric: em.id, outcomeMetric: om, xs: [], ys: [] })\n }\n }\n\n let joined = 0\n let skipped = 0\n for (const run of runs) {\n const os = outcomesByRun.get(run.runId)\n if (!os || os.length === 0) {\n skipped++\n continue\n }\n const eligible = os.filter((o) => {\n const lag = o.capturedAt - run.startedAt\n return lag >= 0 && lag <= maxLag\n })\n if (eligible.length === 0) {\n skipped++\n continue\n }\n\n let joinedThisRun = false\n for (const em of extractors) {\n const x = await em.extract(run, traceStore)\n if (x === null || !Number.isFinite(x)) continue\n\n for (const om of metricNames) {\n const y = reduceOutcomeMetric(eligible, om, reduction)\n if (y === null) continue\n const pair = pairs.find((p) => p.evalMetric === em.id && p.outcomeMetric === om)!\n pair.xs.push(x)\n pair.ys.push(y)\n joinedThisRun = true\n }\n }\n if (joinedThisRun) joined++\n else skipped++\n }\n\n const excludedPairs: CorrelationStudyResult['excludedPairs'] = []\n const results: CorrelationResult[] = []\n for (const p of pairs) {\n const reason =\n p.xs.length < 3\n ? 'insufficient_samples'\n : !hasVariation(p.xs)\n ? 'constant_eval_metric'\n : !hasVariation(p.ys)\n ? 'constant_outcome'\n : null\n if (reason !== null) {\n excludedPairs.push({\n evalMetric: p.evalMetric,\n outcomeMetric: p.outcomeMetric,\n n: p.xs.length,\n reason,\n })\n continue\n }\n const summary = correlationSummary(p.xs, p.ys, iterations, seed)\n const verdict: CorrelationResult['verdict'] =\n Math.abs(summary.pearson) >= 0.7\n ? 'strong'\n : Math.abs(summary.pearson) >= 0.4\n ? 'moderate'\n : 'weak'\n results.push({\n evalMetric: p.evalMetric,\n outcomeMetric: p.outcomeMetric,\n n: p.xs.length,\n ...summary,\n verdict,\n })\n }\n return { pairs: results, excludedPairs, joinedSamples: joined, skippedRuns: skipped }\n}\n","import { z } from 'zod'\nimport { ValidationError } from '../errors'\nimport { type ComputedInterval, computeInterval } from '../experiment/ast/interval'\nimport { compareCodeUnits, hashCanonical, type LedgerHash } from '../ledger-core/canonical'\n\nconst identity = z\n .string()\n .min(1)\n .refine((value) => value.trim() === value)\nexport const evaluatorAdmissionPolicySchema = z\n .object({\n confidence: z.number().finite().gt(0).lt(1),\n maxFalseAcceptanceRate: z.number().finite().min(0).lt(1),\n maxFalseRejectionRate: z.number().finite().min(0).lt(1),\n })\n .strict()\n\n/** Register both error limits before inspecting audit judgments. */\nexport type EvaluatorAdmissionPolicy = z.infer<typeof evaluatorAdmissionPolicySchema>\n\nexport const evaluatorAuditObservationSchema = z\n .object({\n id: identity,\n independentUnitId: identity,\n evidenceRef: identity,\n expected: z.enum(['accept', 'reject']),\n observed: z.enum(['accept', 'reject', 'unknown']),\n exposure: z.enum(['fresh', 'development']),\n })\n .strict()\n\n/** Actual control judgments. Variants from one source retain one independent identity. */\nexport type EvaluatorAuditObservation = z.infer<typeof evaluatorAuditObservationSchema>\n\nconst inputSchema = z\n .object({\n evaluatorDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/),\n population: identity,\n samplingFrame: identity,\n authority: z\n .object({\n evaluatorAuthorId: identity,\n auditorId: identity,\n independenceEvidenceRef: identity,\n })\n .strict(),\n policy: evaluatorAdmissionPolicySchema,\n observations: z.array(evaluatorAuditObservationSchema),\n })\n .strict()\n\nexport type EvaluatorAuditInput = z.infer<typeof inputSchema>\n\nexport interface EvaluatorErrorRate {\n /** Eligible control judgments in this class, including unknown judgments. */\n cases: number\n independentUnits: number\n /** Units with at least one observed mistake. */\n errorUnits: number\n /** Units with unknown judgments and no observed mistake yet. */\n unresolvedUnits: number\n unknownCases: number\n /** Missing judgments do not become measured zeros. */\n errorRate: number | null\n /** Exact bounds conservatively include every possible outcome of unknown judgments. */\n interval: ComputedInterval | null\n limit: number\n verdict: 'pass' | 'fail' | 'inconclusive'\n}\n\nexport interface EvaluatorAdmissionReport {\n evaluatorDigest: LedgerHash\n policyDigest: LedgerHash\n inputDigest: LedgerHash\n reportDigest: LedgerHash\n population: string\n samplingFrame: string\n authority: EvaluatorAuditInput['authority']\n policy: EvaluatorAdmissionPolicy\n /** Joint coverage for the two reported error-rate intervals. */\n confidence: number\n intervalConfidence: number\n verdict: 'admit' | 'reject' | 'inconclusive'\n reasons: string[]\n observations: EvaluatorAuditObservation[]\n coverage: {\n cases: number\n independentUnits: number\n eligibleCases: number\n eligibleIndependentUnits: number\n excludedCases: number\n unknownCases: number\n }\n exclusions: Array<{ id: string; independentUnitId: string; reason: 'development-exposure' }>\n falseAcceptance: EvaluatorErrorRate\n falseRejection: EvaluatorErrorRate\n}\n\nfunction errorRate(\n rows: readonly EvaluatorAuditObservation[],\n expected: 'accept' | 'reject',\n limit: number,\n level: number,\n): EvaluatorErrorRate {\n const cases = rows.filter((row) => row.expected === expected)\n const units = new Map<string, { error: boolean; unknown: boolean }>()\n for (const row of cases) {\n const unit = units.get(row.independentUnitId) ?? { error: false, unknown: false }\n unit.unknown ||= row.observed === 'unknown'\n unit.error ||= row.observed !== 'unknown' && row.observed !== expected\n units.set(row.independentUnitId, unit)\n }\n const n = units.size\n const errorUnits = [...units.values()].filter((unit) => unit.error).length\n const unresolvedUnits = [...units.values()].filter((unit) => unit.unknown && !unit.error).length\n const unknownCases = cases.filter((row) => row.observed === 'unknown').length\n // Unknown judgments contribute to n; their most favorable and adverse outcomes bound the rate.\n const interval =\n n === 0\n ? null\n : {\n lower: computeInterval(\n { kind: 'clopper-pearson', level },\n {\n kind: 'binomial',\n successes: errorUnits,\n trials: n,\n },\n ).lower,\n upper: computeInterval(\n { kind: 'clopper-pearson', level },\n {\n kind: 'binomial',\n successes: errorUnits + unresolvedUnits,\n trials: n,\n },\n ).upper,\n level,\n }\n const verdict =\n interval && interval.lower > limit\n ? 'fail'\n : interval && interval.upper <= limit\n ? 'pass'\n : 'inconclusive'\n return {\n cases: cases.length,\n independentUnits: n,\n errorUnits,\n unresolvedUnits,\n unknownCases,\n errorRate: n === 0 || unresolvedUnits > 0 ? null : errorUnits / n,\n interval,\n limit,\n verdict,\n }\n}\n\nfunction eligibleControls<\n T extends Pick<EvaluatorAuditObservation, 'id' | 'independentUnitId' | 'exposure'>,\n>(observations: T[]) {\n const ids = new Set<string>()\n for (const row of observations) {\n if (ids.has(row.id))\n throw new ValidationError(`duplicate evaluator audit observation '${row.id}'`)\n ids.add(row.id)\n }\n observations.sort((a, b) => compareCodeUnits(a.id, b.id))\n const developmentUnits = new Set(\n observations\n .filter((row) => row.exposure === 'development')\n .map((row) => row.independentUnitId),\n )\n const eligible = observations.filter((row) => !developmentUnits.has(row.independentUnitId))\n const exclusions = observations\n .filter((row) => developmentUnits.has(row.independentUnitId))\n .map((row) => ({\n id: row.id,\n independentUnitId: row.independentUnitId,\n reason: 'development-exposure' as const,\n }))\n return { eligible, exclusions }\n}\n\nfunction simultaneousIntervalConfidence(confidence: number): number {\n const level = 1 - (1 - confidence) / 2\n if (level >= 1)\n throw new ValidationError(\n 'evaluator audit confidence is too close to one for simultaneous intervals',\n )\n return level\n}\n\nconst capacitySchema = z\n .object({\n policy: evaluatorAdmissionPolicySchema,\n controls: z\n .array(evaluatorAuditObservationSchema.omit({ observed: true, evidenceRef: true }))\n .default([]),\n })\n .strict()\n\nexport type EvaluatorAuditPlanInput = z.input<typeof capacitySchema>\n\n/** The zero-error eligibility floor, not a statistical power calculation. */\nfunction zeroErrorUpperBound(trials: number, level: number): number {\n return -Math.expm1(Math.log((1 - level) / 2) / trials)\n}\n\nfunction minimumAuditUnits(limit: number, level: number): number | null {\n if (limit === 0) return null\n const estimate = Math.ceil(Math.log((1 - level) / 2) / Math.log1p(-limit))\n if (!Number.isFinite(estimate) || estimate > Number.MAX_SAFE_INTEGER) return null\n const clears = (trials: number) => zeroErrorUpperBound(trials, level) <= limit\n let minimum = Math.max(1, estimate)\n while (minimum > 1 && clears(minimum - 1)) minimum -= 1\n while (!clears(minimum)) {\n if (minimum === Number.MAX_SAFE_INTEGER) return null\n minimum += 1\n }\n return minimum\n}\n\n/**\n * Can the fixed control roster meet the policy even with zero errors?\n * Planning uses the admission rule's exact bounds and source-unit exclusions.\n * It accepts no judgments or authority and returns no admission report.\n */\nexport function planEvaluatorAudit(input: EvaluatorAuditPlanInput) {\n const parsed = capacitySchema.safeParse(input)\n if (!parsed.success)\n throw new ValidationError(`invalid evaluator audit plan: ${parsed.error.message}`)\n const { policy, controls } = parsed.data\n const { eligible } = eligibleControls(controls)\n const level = simultaneousIntervalConfidence(policy.confidence)\n const capacity = (expected: EvaluatorAuditObservation['expected'], limit: number) => {\n const independentUnits = new Set(\n eligible.filter((row) => row.expected === expected).map((row) => row.independentUnitId),\n ).size\n const bestPossibleUpperBound =\n independentUnits === 0 ? null : zeroErrorUpperBound(independentUnits, level)\n const minimumIndependentUnits = minimumAuditUnits(limit, level)\n return {\n independentUnits,\n bestPossibleUpperBound,\n limit,\n minimumIndependentUnits,\n additionalIndependentUnits:\n minimumIndependentUnits === null\n ? null\n : Math.max(0, minimumIndependentUnits - independentUnits),\n }\n }\n const falseAcceptance = capacity('reject', policy.maxFalseAcceptanceRate)\n const falseRejection = capacity('accept', policy.maxFalseRejectionRate)\n const sufficient = [falseAcceptance, falseRejection].every(\n (rate) => rate.bestPossibleUpperBound !== null && rate.bestPossibleUpperBound <= rate.limit,\n )\n return { sufficient, falseAcceptance, falseRejection }\n}\n\nexport type EvaluatorAuditPlan = ReturnType<typeof planEvaluatorAudit>\n\n/**\n * Audit frozen judgments using independent source units and exact binomial bounds.\n * A unit fails a class when any control in that class is misjudged.\n * The execution owner enforces auditor separation, fresh sampling, and evidence authenticity.\n */\nexport function auditEvaluator(input: EvaluatorAuditInput): EvaluatorAdmissionReport {\n const parsed = inputSchema.safeParse(input)\n if (!parsed.success) throw new ValidationError(`invalid evaluator audit: ${parsed.error.message}`)\n const audit = parsed.data\n if (audit.authority.evaluatorAuthorId === audit.authority.auditorId) {\n throw new ValidationError('evaluator admission requires a separate declared audit authority')\n }\n const { eligible, exclusions } = eligibleControls(audit.observations)\n const intervalConfidence = simultaneousIntervalConfidence(audit.policy.confidence)\n const falseAcceptance = errorRate(\n eligible,\n 'reject',\n audit.policy.maxFalseAcceptanceRate,\n intervalConfidence,\n )\n const falseRejection = errorRate(\n eligible,\n 'accept',\n audit.policy.maxFalseRejectionRate,\n intervalConfidence,\n )\n const rates = [falseAcceptance, falseRejection]\n const verdict = rates.some((rate) => rate.verdict === 'fail')\n ? 'reject'\n : rates.every((rate) => rate.verdict === 'pass')\n ? 'admit'\n : 'inconclusive'\n const reasons: string[] = []\n for (const [name, rate] of [\n ['false acceptance', falseAcceptance],\n ['false rejection', falseRejection],\n ] as const) {\n if (rate.independentUnits === 0) reasons.push(`${name}: no eligible independent units`)\n else if (rate.unknownCases > 0)\n reasons.push(`${name}: ${rate.unknownCases} judgments are unknown`)\n if (rate.verdict === 'fail') reasons.push(`${name}: lower error bound exceeds ${rate.limit}`)\n else if (rate.verdict === 'inconclusive' && rate.interval)\n reasons.push(`${name}: upper error bound does not establish the required limit`)\n }\n if (verdict === 'admit')\n reasons.push(\n 'both error bounds meet the registered limits, including the worst case for unknown judgments',\n )\n const body: Omit<EvaluatorAdmissionReport, 'reportDigest'> = {\n evaluatorDigest: audit.evaluatorDigest as LedgerHash,\n policyDigest: hashCanonical(audit.policy),\n inputDigest: hashCanonical(audit),\n population: audit.population,\n samplingFrame: audit.samplingFrame,\n authority: audit.authority,\n policy: audit.policy,\n confidence: audit.policy.confidence,\n intervalConfidence,\n verdict,\n reasons,\n observations: audit.observations,\n coverage: {\n cases: audit.observations.length,\n independentUnits: new Set(audit.observations.map((row) => row.independentUnitId)).size,\n eligibleCases: eligible.length,\n eligibleIndependentUnits: new Set(eligible.map((row) => row.independentUnitId)).size,\n excludedCases: exclusions.length,\n unknownCases: eligible.filter((row) => row.observed === 'unknown').length,\n },\n exclusions,\n falseAcceptance,\n falseRejection,\n }\n return { ...body, reportDigest: hashCanonical(body) }\n}\n\nconst probabilityThresholdsSchema = z\n .object({\n rejectAtOrBelow: z.number().finite().min(0).max(1),\n acceptAtOrAbove: z.number().finite().min(0).max(1),\n })\n .strict()\n .refine((value) => value.rejectAtOrBelow < value.acceptAtOrAbove, {\n message: 'rejection and acceptance thresholds must not overlap',\n })\nconst probabilityObservationSchema = evaluatorAuditObservationSchema\n .omit({ observed: true })\n .extend({ acceptProbability: z.number().finite().min(0).max(1).nullable() })\n .strict()\nconst probabilityAuditSchema = inputSchema.extend({\n thresholds: probabilityThresholdsSchema,\n observations: z.array(probabilityObservationSchema),\n})\n\n/** A frozen caller-owned rule over P(accept), not the provider's entropy/confidence statistic. */\nexport type ProbabilityPolicyAuditInput = z.infer<typeof probabilityAuditSchema>\n\nexport interface ProbabilityPolicyAuditReport extends EvaluatorAdmissionReport {\n probabilityPolicy: {\n sourceEvaluatorDigest: LedgerHash\n thresholds: ProbabilityPolicyAuditInput['thresholds']\n /** Retain probabilities by observation id so the reported mapping can be reproduced. */\n observations: Array<{ id: string; acceptProbability: number | null }>\n }\n}\n\n/**\n * Audit a fixed probability-to-decision rule with the existing independent-unit error bounds.\n * No threshold search, model calls, promotion, or assumption of calibrated probabilities.\n * Null scores and the open interval between thresholds remain unknown, never correct by default.\n */\nexport function auditProbabilityPolicy(\n input: ProbabilityPolicyAuditInput,\n): ProbabilityPolicyAuditReport {\n const parsed = probabilityAuditSchema.safeParse(input)\n if (!parsed.success) {\n throw new ValidationError(`invalid probability policy audit: ${parsed.error.message}`)\n }\n const { thresholds, observations, ...source } = parsed.data\n observations.sort((a, b) => compareCodeUnits(a.id, b.id))\n const probabilityPolicy = {\n sourceEvaluatorDigest: source.evaluatorDigest as LedgerHash,\n thresholds,\n observations: observations.map(({ id, acceptProbability }) => ({ id, acceptProbability })),\n }\n const audit = auditEvaluator({\n ...source,\n evaluatorDigest: hashCanonical({\n kind: 'probability-policy-v1',\n sourceEvaluatorDigest: source.evaluatorDigest,\n thresholds,\n }),\n observations: observations.map(({ acceptProbability, ...observation }) => ({\n ...observation,\n observed:\n acceptProbability === null\n ? 'unknown'\n : acceptProbability >= thresholds.acceptAtOrAbove\n ? 'accept'\n : acceptProbability <= thresholds.rejectAtOrBelow\n ? 'reject'\n : 'unknown',\n })),\n })\n const { reportDigest: _baseDigest, ...baseReport } = audit\n const body = {\n ...baseReport,\n // Bind the actual probabilities too, including changes that select the same action.\n inputDigest: hashCanonical(parsed.data),\n probabilityPolicy,\n }\n return { ...body, reportDigest: hashCanonical(body) }\n}\n","/**\n * Judge-panel calibration: score a hand-graded gold set with every judge model\n * on a panel, under one weighted rubric, and measure each (judge × dimension)\n * against the human grades with `calibrateJudge`.\n *\n * The caller owns the domain: the rubric text and weights, the system prompt,\n * the gold items and the judge list. This module owns the mechanics every\n * product repeats — the rubric prompt, the JSON call with retries, the\n * sequential (item × judge) sweep, null-grade handling, and the per-cell\n * calibration — plus `gateJudgeCalibration`, the pass/warn/fail rule over the\n * resulting cells.\n *\n * Calls run one at a time. Subscription bridges serialise per subprocess, and\n * concurrent requests from a full panel get killed under load.\n *\n * A gold cell with a null or missing human grade is still scored (the judge's\n * score lands in `rawScores`, useful for inter-judge agreement) but never\n * enters that dimension's calibration.\n */\n\nimport {\n type CalibrationResult,\n type CandidateScore,\n calibrateJudge,\n type GoldenItem,\n} from '../judge-calibration'\nimport { withJudgeRetry } from '../judge-retry'\nimport { callLlmJson, type LlmClientOptions } from '../llm-client'\n\n/** One rubric dimension: the guide the judge scores against and its weight in the composite. */\nexport interface RubricDimensionGuide {\n weight: number\n guide: string\n}\n\nexport interface JudgeCalibrationGoldItem<D extends string> {\n id: string\n /** Text after `Scenario:` in the judge prompt. Defaults to `id`. */\n scenarioLabel?: string\n /** The input the candidate answered. */\n scenario: string\n /** The output the judges score. */\n candidateOutput: string\n /** Human grade per dimension in [0,1]. `null` (whole item or one dimension)\n * means not graded: the item is still judged but excluded from calibration. */\n humanGrade: Partial<Record<D, number | null>> | null\n}\n\nexport interface JudgePanelPrompt {\n /** The judge's system prompt. */\n system: string\n /** Line above the rubric. Default: score each dimension in [0,1]. */\n rubricHeading?: string\n /** Line above the candidate output. Default `Candidate output to score:`. */\n candidateHeading?: string\n /** Candidate output is cut to this many characters. Default 12000. */\n maxCandidateChars?: number\n /** Lines after the JSON-shape instruction. */\n closingLines?: readonly string[]\n}\n\nexport interface CalibrateJudgePanelInput<D extends string> {\n rubric: Readonly<Record<D, RubricDimensionGuide>>\n /** Dimensions to score, in prompt order. Defaults to the rubric's keys. */\n dimensions?: readonly D[]\n items: readonly JudgeCalibrationGoldItem<D>[]\n judges: readonly string[]\n /** Endpoint and credential for every judge call. */\n llm: LlmClientOptions\n prompt: JudgePanelPrompt\n /** Default 1200. */\n maxTokens?: number\n /** Per-attempt timeout. Default 300000. */\n timeoutMs?: number\n /** Attempts per (item × judge); every error is retried. Default 3. */\n maxAttempts?: number\n /** Progress lines (one per item and judge, then the metrics table). */\n log?: (line: string) => void\n}\n\n/** A judge's calibration on one dimension. `golden` and `scores` hold the same\n * items: the human-graded ones this judge scored. */\nexport interface JudgeDimensionCalibration {\n calibration: CalibrationResult\n golden: GoldenItem[]\n scores: CandidateScore[]\n}\n\n/** What one judge returned for one item: a score per dimension and its rationale. */\nexport type JudgePanelOutput<D extends string> = Partial<Record<D, number>> & { rationale?: string }\n\nexport interface JudgePanelCalibration<D extends string> {\n judges: string[]\n dimensions: D[]\n perJudge: Record<string, Record<D, JudgeDimensionCalibration>>\n /** Every score each judge returned, graded items or not, clamped to [0,1]. */\n rawScores: Record<string, Record<D, CandidateScore[]>>\n /** Parsed judge output per item; `null` when every attempt failed. */\n outputs: Record<string, Record<string, JudgePanelOutput<D> | null>>\n /** Item ids with no human grade, per dimension. */\n ungradedItems: Record<D, string[]>\n /** (judge × item) cells where every attempt failed. */\n failures: Array<{ judge: string; itemId: string; errors: string[] }>\n elapsedMs: number\n}\n\nconst DEFAULT_RUBRIC_HEADING =\n 'Rubric (score each dimension in [0,1]; 1 = perfectly satisfies the guide, 0 = fails):'\n\nfunction clampUnit(n: number): number {\n if (!Number.isFinite(n)) return 0\n if (n < 0) return 0\n if (n > 1) return 1\n return n\n}\n\nfunction humanScore<D extends string>(item: JudgeCalibrationGoldItem<D>, d: D): number | null {\n const v = item.humanGrade?.[d]\n return typeof v === 'number' && Number.isFinite(v) ? v : null\n}\n\nfunction shortModel(model: string): string {\n return (model.split('/').pop() ?? model).padEnd(28)\n}\n\nfunction judgeUserPrompt<D extends string>(\n input: CalibrateJudgePanelInput<D>,\n dimensions: readonly D[],\n item: JudgeCalibrationGoldItem<D>,\n): string {\n const rubricLines = dimensions\n .map((d) => `- ${d} (weight ${input.rubric[d].weight}): ${input.rubric[d].guide}`)\n .join('\\n')\n const jsonShape = `{${dimensions.map((d) => `\"${d}\":number`).join(',')},\"rationale\":string}`\n return [\n `Scenario: ${item.scenarioLabel ?? item.id}`,\n `Input: ${item.scenario}`,\n '',\n input.prompt.rubricHeading ?? DEFAULT_RUBRIC_HEADING,\n rubricLines,\n '',\n input.prompt.candidateHeading ?? 'Candidate output to score:',\n '---',\n item.candidateOutput.slice(0, input.prompt.maxCandidateChars ?? 12_000),\n '---',\n '',\n `Respond ONLY with a JSON object exactly of shape: ${jsonShape}.`,\n ...(input.prompt.closingLines ?? []),\n ].join('\\n')\n}\n\n/** Run every judge on every gold item and calibrate each (judge × dimension). */\nexport async function calibrateJudgePanel<D extends string>(\n input: CalibrateJudgePanelInput<D>,\n): Promise<JudgePanelCalibration<D>> {\n const dimensions = [...(input.dimensions ?? (Object.keys(input.rubric) as D[]))]\n const judges = [...input.judges]\n const log = input.log ?? (() => {})\n const perDim = <T>(make: () => T) =>\n Object.fromEntries(dimensions.map((d) => [d, make()])) as Record<D, T>\n\n const rawScores: JudgePanelCalibration<D>['rawScores'] = {}\n const outputs: JudgePanelCalibration<D>['outputs'] = {}\n const goldenByJudge: Record<string, Record<D, GoldenItem[]>> = {}\n const scoresByJudge: Record<string, Record<D, CandidateScore[]>> = {}\n for (const judge of judges) {\n rawScores[judge] = perDim(() => [] as CandidateScore[])\n outputs[judge] = {}\n goldenByJudge[judge] = perDim(() => [] as GoldenItem[])\n scoresByJudge[judge] = perDim(() => [] as CandidateScore[])\n }\n const ungradedItems = perDim(() => [] as string[])\n for (const item of input.items) {\n for (const d of dimensions) if (humanScore(item, d) === null) ungradedItems[d].push(item.id)\n }\n const failures: JudgePanelCalibration<D>['failures'] = []\n\n const startedAt = Date.now()\n for (let i = 0; i < input.items.length; i++) {\n const item = input.items[i] as JudgeCalibrationGoldItem<D>\n log(` [${(i + 1).toString().padStart(2)}/${input.items.length}] ${item.id}`)\n const userPrompt = judgeUserPrompt(input, dimensions, item)\n for (const judge of judges) {\n const outcome = await withJudgeRetry(\n async (_model, signal) =>\n (\n await callLlmJson<JudgePanelOutput<D>>(\n {\n model: judge,\n messages: [\n { role: 'system', content: input.prompt.system },\n { role: 'user', content: userPrompt },\n ],\n jsonMode: true,\n temperature: 0,\n maxTokens: input.maxTokens ?? 1200,\n timeoutMs: input.timeoutMs ?? 300_000,\n },\n { ...input.llm, signal },\n )\n ).value,\n {\n maxAttempts: input.maxAttempts ?? 3,\n timeoutMs: input.timeoutMs ?? 300_000,\n isRetryable: () => true,\n backoffMs: (attempt) => 2_000 * (attempt + 1),\n },\n )\n const out = outcome.succeeded ? outcome.value : null\n outputs[judge]![item.id] = out\n if (!out) {\n const errors = outcome.attemptErrors.map((e) => e.error)\n failures.push({ judge, itemId: item.id, errors })\n log(` ${shortModel(judge)} - FAILED (${errors.at(-1) ?? 'no attempt'})`)\n continue\n }\n let judged = 0\n let expected = 0\n let covered = 0\n for (const d of dimensions) {\n const score = clampUnit(Number((out as Record<string, unknown>)[d]))\n rawScores[judge]![d].push({ itemId: item.id, score })\n const human = humanScore(item, d)\n if (human === null) continue\n goldenByJudge[judge]![d].push({ itemId: item.id, humanScore: human })\n scoresByJudge[judge]![d].push({ itemId: item.id, score })\n const weight = input.rubric[d].weight\n judged += score * weight\n expected += human * weight\n covered += weight\n }\n const pct = (n: number) => `${(n * 100).toFixed(0)}%`\n log(\n covered > 0\n ? ` ${shortModel(judge)} judged=${pct(judged / covered)} expected=${pct(expected / covered)} delta=${pct((judged - expected) / covered)} cover=${pct(covered)}`\n : ` ${shortModel(judge)} judged (ungraded item)`,\n )\n }\n }\n const elapsedMs = Date.now() - startedAt\n\n const perJudge: JudgePanelCalibration<D>['perJudge'] = {}\n for (const judge of judges) {\n log(` ${judge}`)\n perJudge[judge] = {} as Record<D, JudgeDimensionCalibration>\n for (const d of dimensions) {\n const golden = goldenByJudge[judge]![d]\n const scores = scoresByJudge[judge]![d]\n const calibration = calibrateJudge(golden, scores)\n perJudge[judge]![d] = { calibration, golden, scores }\n log(\n ` ${d.padEnd(34)} n=${calibration.n.toString().padStart(2)} kappa=${calibration.kappa.toFixed(2)} r=${calibration.pearson.toFixed(2)} MAE=${calibration.mae.toFixed(3)}`,\n )\n }\n }\n\n return { judges, dimensions, perJudge, rawScores, outputs, ungradedItems, failures, elapsedMs }\n}\n\n/** Thresholds for `gateJudgeCalibration`. */\nexport interface JudgeCalibrationGateConfig {\n /** Pearson below this (and at or above `pearsonWarn`) warns. */\n pearsonFloor: number\n /** Pearson below this fails. */\n pearsonWarn: number\n /** MAE above this fails. */\n maeCeiling: number\n /** Cells with fewer graded items are reported as insufficient and never fail. */\n minSamples: number\n}\n\nexport type JudgeCalibrationCellVerdict = 'pass' | 'warn' | 'fail' | 'insufficient'\n\nexport interface JudgeCalibrationGateCell {\n judge: string\n dim: string\n n: number\n pearson: number\n mae: number\n verdict: JudgeCalibrationCellVerdict\n reasons: string[]\n}\n\nexport interface JudgeCalibrationGate {\n pass: boolean\n config: JudgeCalibrationGateConfig\n failCount: number\n warnCount: number\n insufficientCount: number\n cells: JudgeCalibrationGateCell[]\n}\n\n/** Pass/warn/fail every (judge × dimension) cell; the gate passes with zero fail cells. */\nexport function gateJudgeCalibration(\n perJudge: Record<string, Record<string, { calibration: CalibrationResult }>>,\n config: JudgeCalibrationGateConfig,\n): JudgeCalibrationGate {\n const cells: JudgeCalibrationGateCell[] = []\n for (const [judge, dims] of Object.entries(perJudge)) {\n for (const [dim, { calibration: cal }] of Object.entries(dims)) {\n const reasons: string[] = []\n let verdict: JudgeCalibrationCellVerdict = 'pass'\n if (cal.n < config.minSamples) {\n verdict = 'insufficient'\n reasons.push(`n=${cal.n} < minSamples=${config.minSamples}`)\n } else {\n if (Number.isFinite(cal.pearson) && cal.pearson < config.pearsonFloor) {\n if (cal.pearson < config.pearsonWarn) {\n verdict = 'fail'\n reasons.push(\n `pearson=${cal.pearson.toFixed(2)} < floor=${config.pearsonFloor.toFixed(2)} (below warn=${config.pearsonWarn.toFixed(2)})`,\n )\n } else {\n verdict = 'warn'\n reasons.push(\n `pearson=${cal.pearson.toFixed(2)} in warn band [${config.pearsonWarn.toFixed(2)}, ${config.pearsonFloor.toFixed(2)})`,\n )\n }\n }\n if (Number.isFinite(cal.mae) && cal.mae > config.maeCeiling) {\n verdict = 'fail'\n reasons.push(`mae=${cal.mae.toFixed(3)} > ceiling=${config.maeCeiling.toFixed(3)}`)\n }\n }\n cells.push({ judge, dim, n: cal.n, pearson: cal.pearson, mae: cal.mae, verdict, reasons })\n }\n }\n const count = (v: JudgeCalibrationCellVerdict) => cells.filter((c) => c.verdict === v).length\n const failCount = count('fail')\n return {\n pass: failCount === 0,\n config,\n failCount,\n warnCount: count('warn'),\n insufficientCount: count('insufficient'),\n cells,\n }\n}\n","/**\n * Plants — seeded known-wrong items that measure the grader, not the work.\n *\n * A grading run reports how the work scored. It cannot report whether the\n * grader would have noticed a wrong answer, because every item it saw was\n * authored in good faith. A plant closes that hole: an item authored wrong by\n * construction is mixed into the live set, graded by the same path as\n * everything else, and the share of plants the grader refused is the catch\n * rate.\n *\n * Measured motive: a sibling lab ran a deliverable gate that accepted any\n * non-empty submission. It produced six false certifications in seventeen\n * deliveries, and no agent lied — the gate never asked a question the format\n * could fail. A catch rate is the number that would have shown it on day one.\n *\n * This module composes existing primitives rather than adding parallel ones:\n *\n * - A plant IS a {@link GoldenItem} from `../judge-calibration`. Its\n * `humanScore` is the grade a working grader owes the item, so the same\n * array feeds `calibrateJudge` unchanged.\n * - The grader's output is `CandidateScore[]`, the array `calibrateJudge` and\n * `snapshotFromSentinelSet` already consume.\n * - \"Caught\" is `snapshotFromSentinelSet`'s join with the labels inverted:\n * the grade lands on the side of `acceptThreshold` the seed demands.\n * - The manifest is sealed with `hashCanonical` from `../ledger-core/canonical`,\n * the digest the sealed-experiment path uses, so the answer key cannot be\n * revised once the results are in.\n *\n * Authoring the wrong item is the step before all of that, and it is where the\n * measurement silently breaks. {@link plantByPerturbation} takes a claim a\n * grader verified and alters exactly one load-bearing value in its evidence,\n * so the grader is asked a question it must fail. Hand-rolled perturbation\n * bumps a number that is part of an identity — `python3`, `file42.txt`, `1.5`,\n * `utf-8` — and the check stops EXECUTING; the plant then measures the\n * environment rather than the grader. {@link perturbEvidence} refuses those\n * digit runs by construction.\n *\n * Blindness has two halves, and this module owns one. It never puts a plant\n * flag on a graded item: `seedPlants` returns the mixed set and a manifest,\n * and only the manifest knows which ids are seeded. Keeping the manifest out\n * of the graded workspace and publishing its `seal` before grading is the\n * caller's half; {@link catchRate} refuses a manifest whose contents no longer\n * match its seal.\n *\n * Refusals, because a catch rate that cannot refuse is not a measurement:\n *\n * - a seeded id with no result makes the report `incomplete`, never a rate\n * over the results that did come back;\n * - zero seeded plants makes it `not_evaluated`, never 1.0;\n * - a result for an id the manifest never handed out is refused outright.\n */\n\nimport { CaptureIntegrityError, ValidationError } from '../errors'\nimport type { GoldenItem } from '../judge-calibration'\nimport { hashCanonical, type LedgerHash } from '../ledger-core/canonical'\nimport { mulberry32 } from '../statistics/random'\n\n/**\n * How a plant item was authored wrong. The class is reported separately in\n * {@link CatchRateReport.byKind} because a grader is routinely sharp on one\n * and blind to another.\n */\nexport type PlantKind =\n /** A load-bearing value is altered: a number off by one, a comparison flipped. */\n | 'wrong-value'\n /** The item carries its own check, and that check passes without testing the claim. */\n | 'self-certifying'\n /** The check names an input that does not exist, so it cannot run at all. */\n | 'unreachable-input'\n /** A copy of an item already in the set, which is owed a duplicate flag rather than a second grade. */\n | 'duplicate'\n\nconst PLANT_KINDS: readonly PlantKind[] = [\n 'wrong-value',\n 'self-certifying',\n 'unreachable-input',\n 'duplicate',\n]\n\n/** What a working grader owes a seeded item. */\nexport type PlantExpectation = 'reject' | 'accept'\n\nconst PLANT_EXPECTATIONS: readonly PlantExpectation[] = ['reject', 'accept']\n\n/** The label boundary a plant record is checked against at definition time. */\nconst RECORD_LABEL_BOUNDARY = 0.5\n\nexport interface Plant {\n /** Name of the plant record. Reported in `missedIds` and `missingIds`. */\n id: string\n kind: PlantKind\n /** The seeded item, indistinguishable from a real one once mixed. */\n item: GoldenItem\n /** The verdict a working grader owes this item. */\n expectedVerdict: PlantExpectation\n}\n\n/**\n * Build one plant record and refuse an incoherent one.\n *\n * The refusal that matters is the last: a record whose `expectedVerdict`\n * disagrees with `item.humanScore` inverts the measurement silently, because\n * the same item then reads as wrong here and as correct to every calibration\n * instrument that joins on the id.\n *\n * `item` is copied field by field so a later mutation of the caller's object\n * cannot change what the manifest sealed, and `group` is dropped when it is\n * absent so the record always has a canonical JSON form.\n */\nexport function definePlant(input: {\n id: string\n kind: PlantKind\n item: GoldenItem\n expectedVerdict: PlantExpectation\n}): Plant {\n const { id, kind, item, expectedVerdict } = input\n if (typeof id !== 'string' || id.trim() === '') {\n throw new ValidationError('definePlant: id must be a non-empty string')\n }\n if (!PLANT_KINDS.includes(kind)) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has kind ${JSON.stringify(kind)}; expected one of ${PLANT_KINDS.join(', ')}`,\n )\n }\n if (!PLANT_EXPECTATIONS.includes(expectedVerdict)) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has expectedVerdict ${JSON.stringify(expectedVerdict)}; expected one of ${PLANT_EXPECTATIONS.join(', ')}`,\n )\n }\n if (typeof item.itemId !== 'string' || item.itemId.trim() === '') {\n throw new ValidationError(`definePlant: plant \"${id}\" has an empty item.itemId`)\n }\n if (!Number.isFinite(item.humanScore) || item.humanScore < 0 || item.humanScore > 1) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has humanScore ${item.humanScore}; expected a finite number in [0, 1]`,\n )\n }\n if (item.group !== undefined && typeof item.group !== 'string') {\n throw new ValidationError(`definePlant: plant \"${id}\" has a non-string item.group`)\n }\n if (item.humanScore === RECORD_LABEL_BOUNDARY) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has humanScore ${RECORD_LABEL_BOUNDARY}, which states neither a rejection nor an acceptance`,\n )\n }\n const labelSays: PlantExpectation = item.humanScore < RECORD_LABEL_BOUNDARY ? 'reject' : 'accept'\n if (labelSays !== expectedVerdict) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" expects the grader to ${expectedVerdict} it, but humanScore ${item.humanScore} says ${labelSays}`,\n )\n }\n return {\n id,\n kind,\n item: {\n itemId: item.itemId,\n humanScore: item.humanScore,\n ...(item.group === undefined ? {} : { group: item.group }),\n },\n expectedVerdict,\n }\n}\n\n/**\n * A claim's executable evidence: the command a grader runs and the output it\n * must produce.\n */\nexport interface PlantEvidence {\n /** The command a grader runs to test the claim. */\n check?: string\n /** The output that command must produce for the claim to stand. */\n expect?: string\n}\n\n/** Which evidence field {@link perturbEvidence} altered. */\nexport type PerturbedField = 'check' | 'expect'\n\n/** How {@link perturbEvidence} altered it. */\nexport type PerturbationKind = 'number-off-by-one' | 'comparison-flipped'\n\nexport interface EvidencePerturbation {\n /** The evidence with exactly one value altered. */\n evidence: PlantEvidence\n /** Which field changed. */\n field: PerturbedField\n /** How it changed. */\n how: PerturbationKind\n /**\n * The exact substring that was replaced. A comparison token carries its\n * surrounding spaces, because the spaces are what make ` -ge ` a comparison\n * and not part of a word.\n */\n original: string\n /** What replaced it. */\n perturbed: string\n}\n\n/**\n * Characters that make a digit run part of something larger than a number.\n *\n * A run that touches one of these is an identity — `python3`, `file42.txt`,\n * `1.5`, `utf-8` — and bumping it renames a program, a file, a version, or an\n * encoding instead of falsifying the claim. The check then stops EXECUTING,\n * and a plant that cannot run measures the environment rather than the grader:\n * it reads as caught, for a reason that has nothing to do with the seeded\n * defect.\n */\nconst NUMBER_GLUE = /[A-Za-z0-9_./-]/\n\n/**\n * Comparison tokens that mean one thing only, each with its inversion.\n *\n * A bare `>` or `<` is absent on purpose: in a shell check it is a\n * redirection, so flipping it rewrites where output goes rather than what the\n * test asks, and the check stops testing the claim.\n */\nconst COMPARISON_FLIPS: readonly (readonly [string, string])[] = [\n [' -ge ', ' -lt '],\n [' -gt ', ' -le '],\n [' -le ', ' -gt '],\n [' -lt ', ' -ge '],\n [' -eq ', ' -ne '],\n [' -ne ', ' -eq '],\n ['>=', '<'],\n ['<=', '>'],\n ['==', '!='],\n ['!=', '=='],\n]\n\ninterface Span {\n start: number\n end: number\n}\n\n/**\n * The last digit run in `text` that is a number and nothing else, or null.\n *\n * The last is taken because a measured value trails its label — `count=42`,\n * `n>=5 OK cells=8` — and because the choice has to be deterministic: the same\n * claim must always yield the same plant, or two runs of the same authoring\n * step seed two different answer keys for one item.\n */\nfunction lastStandaloneNumber(text: string): Span | null {\n const digits = /\\d+/g\n let found: Span | null = null\n let match = digits.exec(text)\n while (match !== null) {\n const start = match.index\n const end = start + match[0].length\n // charAt returns '' outside the string, and NUMBER_GLUE never matches ''.\n if (!NUMBER_GLUE.test(text.charAt(start - 1)) && !NUMBER_GLUE.test(text.charAt(end))) {\n found = { start, end }\n }\n match = digits.exec(text)\n }\n return found\n}\n\n/**\n * The first flippable comparison in `text`, or null.\n *\n * Any single flip inverts the test wherever it sits, so unlike the number rule\n * there is no safety ordering among the matches. The first is taken so the\n * result is fixed by the head of the command and does not move when a later\n * comparison is added.\n */\nfunction firstComparison(text: string): { span: Span; flipped: string } | null {\n for (let index = 0; index < text.length; index += 1) {\n for (const [token, flipped] of COMPARISON_FLIPS) {\n if (text.startsWith(token, index)) {\n return { span: { start: index, end: index + token.length }, flipped }\n }\n }\n }\n return null\n}\n\nfunction replaceSpan(text: string, span: Span, value: string): string {\n return text.slice(0, span.start) + value + text.slice(span.end)\n}\n\n/**\n * Rebuild the evidence with one field replaced. An absent field is dropped\n * rather than set to undefined, so the record always has a canonical JSON form.\n */\nfunction withField(\n check: string | undefined,\n expect: string | undefined,\n field: PerturbedField,\n value: string,\n): PlantEvidence {\n const nextCheck = field === 'check' ? value : check\n const nextExpect = field === 'expect' ? value : expect\n return {\n ...(nextCheck === undefined ? {} : { check: nextCheck }),\n ...(nextExpect === undefined ? {} : { expect: nextExpect }),\n }\n}\n\nfunction offByOne(\n check: string | undefined,\n expect: string | undefined,\n field: PerturbedField,\n text: string,\n span: Span,\n): EvidencePerturbation {\n const original = text.slice(span.start, span.end)\n const perturbed = (BigInt(original) + 1n).toString()\n return {\n evidence: withField(check, expect, field, replaceSpan(text, span, perturbed)),\n field,\n how: 'number-off-by-one',\n original,\n perturbed,\n }\n}\n\n/**\n * Derive a known-wrong version of a claim's evidence by altering exactly one\n * value, or return null when no value can be altered safely.\n *\n * Exactly one value changes. A perturbation that moves two does not name the\n * defect it seeded, so a grader that catches it says nothing about which defect\n * the grader can see.\n *\n * The preference order IS the safety order:\n *\n * 1. the last standalone number in `expect` — it falsifies the claim while the\n * command still runs exactly as it did;\n * 2. a flipped comparison in `check` — it inverts a test that was passing;\n * 3. the last standalone number in `check` — last because a number in a command\n * can name an input (a port, a width, a version) rather than a threshold,\n * and renaming an input breaks execution, not the claim.\n *\n * \"Standalone\" excludes a digit run glued to a word, a dot, a slash, or a\n * hyphen: `python3`, `file42.txt`, `1.5`, `utf-8`. That exclusion is why this\n * helper exists. Hand-rolled perturbation bumps one of those, the check stops\n * executing, and the plant measures the environment instead of the grader.\n *\n * A number is bumped with BigInt, so a value wider than\n * `Number.MAX_SAFE_INTEGER` moves by exactly one. Bumped as a `number` it\n * rounds back to itself, and the plant is then a correct claim the grader is\n * right to verify.\n */\nexport function perturbEvidence(evidence: PlantEvidence): EvidencePerturbation | null {\n const check = typeof evidence.check === 'string' ? evidence.check : undefined\n const expect = typeof evidence.expect === 'string' ? evidence.expect : undefined\n\n if (expect !== undefined) {\n const span = lastStandaloneNumber(expect)\n if (span !== null) return offByOne(check, expect, 'expect', expect, span)\n }\n if (check !== undefined) {\n const comparison = firstComparison(check)\n if (comparison !== null) {\n return {\n evidence: withField(\n check,\n expect,\n 'check',\n replaceSpan(check, comparison.span, comparison.flipped),\n ),\n field: 'check',\n how: 'comparison-flipped',\n original: check.slice(comparison.span.start, comparison.span.end),\n perturbed: comparison.flipped,\n }\n }\n const span = lastStandaloneNumber(check)\n if (span !== null) return offByOne(check, expect, 'check', check, span)\n }\n return null\n}\n\nexport interface PerturbedPlant {\n plant: Plant\n /** The perturbed evidence to write into the item the grader is handed. */\n evidence: PlantEvidence\n field: PerturbedField\n how: PerturbationKind\n original: string\n perturbed: string\n}\n\n/**\n * Derive a reject-direction plant from a claim a grader verified, by perturbing\n * one value.\n *\n * {@link definePlant} takes a {@link GoldenItem} and never authors a wrong item\n * from a right one, so until now every caller hand-rolled the perturbation.\n * This is that step, done once and the same way every time: the claim's\n * evidence is altered by {@link perturbEvidence}, the result is a `wrong-value`\n * plant the grader owes a `reject`, and the record itself is built by\n * `definePlant` so every refusal there still applies — in particular the one\n * that catches an `expectedVerdict` its `humanScore` contradicts.\n *\n * Returns null when nothing in the evidence can be perturbed. That is not a\n * failure: a claim with no executable evidence cannot be made wrong in a way a\n * grader could execute, and seeding it would measure prose.\n *\n * Refuses an empty `id` or `itemId`. Both name the record — one in the manifest\n * and in `missedIds`, the other in the join with the results — and a miss\n * nobody can look up is not a measurement.\n */\nexport function plantByPerturbation(input: {\n id: string\n itemId: string\n evidence: PlantEvidence\n /** Score for the perturbed item. Must sit below the run's accept threshold. Default 0. */\n humanScore?: number\n group?: string\n}): PerturbedPlant | null {\n const { id, itemId, evidence, humanScore = 0, group } = input\n if (typeof id !== 'string' || id.trim() === '') {\n throw new ValidationError('plantByPerturbation: id must be a non-empty string')\n }\n if (typeof itemId !== 'string' || itemId.trim() === '') {\n throw new ValidationError(`plantByPerturbation: plant \"${id}\" has an empty itemId`)\n }\n const perturbation = perturbEvidence(evidence)\n if (perturbation === null) return null\n const plant = definePlant({\n id,\n kind: 'wrong-value',\n item: { itemId, humanScore, ...(group === undefined ? {} : { group }) },\n expectedVerdict: 'reject',\n })\n return {\n plant,\n evidence: perturbation.evidence,\n field: perturbation.field,\n how: perturbation.how,\n original: perturbation.original,\n perturbed: perturbation.perturbed,\n }\n}\n\nexport interface PlantManifest {\n /**\n * Digest over the seeded order, the plants, and the threshold. Publish it\n * before the grading run: a manifest edited afterwards to match the results\n * no longer matches its seal, and {@link catchRate} refuses it.\n */\n seal: LedgerHash\n /** The seed that fixed the mix order. */\n seed: number\n /** The grade at or above which the graded policy's own gate accepts an item. */\n acceptThreshold: number\n /** Every item id in the seeded set, in the order handed out. */\n itemIds: string[]\n /** The seeded plants. This is the answer key; keep it out of the graded workspace. */\n plants: Plant[]\n}\n\nexport interface SeededGradingSet {\n /**\n * The mixed set in seeded order. Operator-side: it still carries every\n * item's `humanScore`, so hand the graded policy the payload each `itemId`\n * names, never this array.\n */\n items: GoldenItem[]\n manifest: PlantManifest\n}\n\nexport interface SeedPlantsOptions {\n /**\n * Fixes the mix order. The same dataset, plants, threshold, and seed always\n * produce the same seeded order and the same seal.\n */\n seed?: number\n /**\n * The grade at or above which the graded policy's own gate accepts an item.\n * Supply the threshold your gate uses; the default suits a judge scoring in\n * [0, 1] with a pass at the midpoint.\n */\n acceptThreshold?: number\n}\n\n/**\n * Mix plants into a grading set and seal which items they are.\n *\n * Refusals: a duplicate id anywhere in the mixed set (the join is by id, so a\n * repeat makes one of the two unscoreable), a plant whose item id collides\n * with a dataset item (it would shadow real work and grade it as a plant), a\n * dataset item with no usable label, and a plant whose expectation the run's\n * `acceptThreshold` contradicts.\n */\nexport function seedPlants(\n dataset: readonly GoldenItem[],\n plants: readonly Plant[],\n options: SeedPlantsOptions = {},\n): SeededGradingSet {\n const seed = options.seed ?? 7\n const acceptThreshold = options.acceptThreshold ?? 0.5\n if (!Number.isFinite(seed)) {\n throw new ValidationError(`seedPlants: seed must be a finite number, got ${seed}`)\n }\n if (!Number.isFinite(acceptThreshold) || acceptThreshold <= 0 || acceptThreshold > 1) {\n throw new ValidationError(\n `seedPlants: acceptThreshold must be a finite number in (0, 1], got ${acceptThreshold}`,\n )\n }\n\n const datasetItems: GoldenItem[] = []\n const seen = new Set<string>()\n for (const item of dataset) {\n if (typeof item.itemId !== 'string' || item.itemId.trim() === '') {\n throw new ValidationError('seedPlants: a dataset item has an empty itemId')\n }\n if (!Number.isFinite(item.humanScore)) {\n throw new ValidationError(\n `seedPlants: dataset item \"${item.itemId}\" has a non-finite humanScore`,\n )\n }\n if (seen.has(item.itemId)) {\n throw new ValidationError(`seedPlants: duplicate dataset itemId \"${item.itemId}\"`)\n }\n seen.add(item.itemId)\n datasetItems.push({\n itemId: item.itemId,\n humanScore: item.humanScore,\n ...(item.group === undefined ? {} : { group: item.group }),\n })\n }\n\n const sealedPlants: Plant[] = []\n const plantIds = new Set<string>()\n for (const plant of plants) {\n const record = definePlant(plant)\n if (plantIds.has(record.id)) {\n throw new ValidationError(`seedPlants: duplicate plant id \"${record.id}\"`)\n }\n if (seen.has(record.item.itemId)) {\n throw new ValidationError(\n `seedPlants: plant \"${record.id}\" reuses itemId \"${record.item.itemId}\", which is already in the set`,\n )\n }\n const thresholdSays: PlantExpectation =\n record.item.humanScore >= acceptThreshold ? 'accept' : 'reject'\n if (thresholdSays !== record.expectedVerdict) {\n throw new ValidationError(\n `seedPlants: plant \"${record.id}\" expects the grader to ${record.expectedVerdict} it, but humanScore ${record.item.humanScore} is on the ${thresholdSays} side of acceptThreshold ${acceptThreshold}`,\n )\n }\n plantIds.add(record.id)\n seen.add(record.item.itemId)\n sealedPlants.push(record)\n }\n\n const items = shuffled(\n [...datasetItems, ...sealedPlants.map((plant) => plant.item)],\n mulberry32(seed),\n )\n const itemIds = items.map((item) => item.itemId)\n const manifest: PlantManifest = {\n seal: sealManifest({ seed, acceptThreshold, itemIds, plants: sealedPlants }),\n seed,\n acceptThreshold,\n itemIds,\n plants: sealedPlants,\n }\n return { items, manifest }\n}\n\n/**\n * Order by one independent uniform key per item, which is a uniform\n * permutation and a pure function of the seed. A comparator that returns a\n * fresh random sign instead is neither: it is not a consistent ordering, so\n * the permutation it produces is biased and depends on the sort algorithm.\n */\nfunction shuffled<T>(items: readonly T[], random: () => number): T[] {\n return items\n .map((item) => ({ item, key: random() }))\n .sort((left, right) => left.key - right.key)\n .map((entry) => entry.item)\n}\n\nfunction sealManifest(contents: Omit<PlantManifest, 'seal'>): LedgerHash {\n return hashCanonical({\n scheme: 'agent-eval.plant-manifest.v1',\n seed: contents.seed,\n acceptThreshold: contents.acceptThreshold,\n itemIds: contents.itemIds,\n plants: contents.plants,\n })\n}\n\n/**\n * One grader outcome for one item. `score: null` says the grader ran and\n * declined to decide — the check never tested the item's defect. Any\n * `CandidateScore` from a judge run is already a valid outcome.\n */\nexport interface PlantOutcome {\n itemId: string\n score: number | null\n}\n\n/**\n * `evaluated` — a rate stands. `incomplete` — a seeded id had no result.\n * `not_evaluated` — nothing was seeded, or nothing seeded was decided.\n */\nexport type CatchRateStatus = 'evaluated' | 'incomplete' | 'not_evaluated'\n\nexport interface PlantKindCounts {\n seeded: number\n caught: number\n missed: number\n indecisive: number\n /** caught / (caught + missed), or null when the report is not `evaluated`. */\n rate: number | null\n}\n\n/**\n * How the same grader treated the unseeded items of the same set. No labels\n * are needed to read it: a grader that refuses everything scores `rate` 1.0\n * on reject-plants, and a `rejectionRate` of 1.0 here is what separates that\n * reflex from discrimination.\n */\nexport interface UnseededRejection {\n n: number\n decided: number\n rejected: number\n /** rejected / decided, or null when nothing unseeded was decided. */\n rejectionRate: number | null\n}\n\nexport interface CatchRateReport {\n status: CatchRateStatus\n /** Why the status is not `evaluated`. Absent when it is. */\n reason?: string\n seeded: number\n caught: number\n missed: number\n /**\n * The grader returned a result and declined to decide. Counted apart: it\n * enters neither side of `rate`.\n */\n indecisive: number\n /** caught / (caught + missed), or null unless the status is `evaluated`. */\n rate: number | null\n /** One entry per kind actually seeded. A kind nobody seeded is absent, never zero. */\n byKind: Partial<Record<PlantKind, PlantKindCounts>>\n /** Plant ids the grader graded as the seed says it must not. */\n missedIds: string[]\n /** Plant ids with no result at all — the reason a status is `incomplete`. */\n missingIds: string[]\n unseeded: UnseededRejection\n}\n\n/**\n * Score a grading run against its sealed manifest.\n *\n * Refusals: a manifest whose contents no longer match its seal, a result for\n * an id the manifest never handed out, and a repeated result id. Each says\n * the results and the manifest describe different runs, and a rate computed\n * across two runs is a fabrication.\n */\nexport function catchRate(\n results: readonly PlantOutcome[],\n manifest: PlantManifest,\n): CatchRateReport {\n const expectedSeal = sealManifest({\n seed: manifest.seed,\n acceptThreshold: manifest.acceptThreshold,\n itemIds: manifest.itemIds,\n plants: manifest.plants,\n })\n if (expectedSeal !== manifest.seal) {\n throw new CaptureIntegrityError(\n `catchRate: manifest contents hash to ${expectedSeal} but the manifest carries seal ${manifest.seal} — the plant set changed after it was sealed`,\n )\n }\n\n const handedOut = new Set(manifest.itemIds)\n const scoreByItemId = new Map<string, number | null>()\n for (const result of results) {\n if (!handedOut.has(result.itemId)) {\n throw new ValidationError(\n `catchRate: result for \"${result.itemId}\", which this manifest never handed out`,\n )\n }\n if (scoreByItemId.has(result.itemId)) {\n throw new ValidationError(`catchRate: duplicate result for \"${result.itemId}\"`)\n }\n if (result.score !== null && !Number.isFinite(result.score)) {\n throw new ValidationError(\n `catchRate: result for \"${result.itemId}\" has score ${result.score}; expected a finite number or null`,\n )\n }\n scoreByItemId.set(result.itemId, result.score)\n }\n\n const byKind: Partial<Record<PlantKind, PlantKindCounts>> = {}\n const missedIds: string[] = []\n const missingIds: string[] = []\n let caught = 0\n let missed = 0\n let indecisive = 0\n\n for (const plant of manifest.plants) {\n let counts = byKind[plant.kind]\n if (counts === undefined) {\n counts = { seeded: 0, caught: 0, missed: 0, indecisive: 0, rate: null }\n byKind[plant.kind] = counts\n }\n counts.seeded += 1\n if (!scoreByItemId.has(plant.item.itemId)) {\n missingIds.push(plant.id)\n continue\n }\n const score = scoreByItemId.get(plant.item.itemId) ?? null\n if (score === null) {\n indecisive += 1\n counts.indecisive += 1\n continue\n }\n const graderSaid: PlantExpectation = score >= manifest.acceptThreshold ? 'accept' : 'reject'\n if (graderSaid === plant.expectedVerdict) {\n caught += 1\n counts.caught += 1\n } else {\n missed += 1\n counts.missed += 1\n missedIds.push(plant.id)\n }\n }\n\n const seeded = manifest.plants.length\n const decided = caught + missed\n const report: CatchRateReport = {\n status: 'evaluated',\n seeded,\n caught,\n missed,\n indecisive,\n rate: null,\n byKind,\n missedIds,\n missingIds,\n unseeded: unseededRejection(manifest, scoreByItemId),\n }\n\n if (seeded === 0) {\n return {\n ...report,\n status: 'not_evaluated',\n reason: 'no plant was seeded, so the grader was never asked a question it could fail',\n }\n }\n if (missingIds.length > 0) {\n return {\n ...report,\n status: 'incomplete',\n reason: `${missingIds.length} of ${seeded} seeded plants have no result: ${missingIds.join(', ')}`,\n }\n }\n if (decided === 0) {\n return {\n ...report,\n status: 'not_evaluated',\n reason: `all ${seeded} seeded plants are indecisive: no check tested the seeded defect`,\n }\n }\n\n for (const counts of Object.values(byKind)) {\n const kindDecided = counts.caught + counts.missed\n counts.rate = kindDecided === 0 ? null : counts.caught / kindDecided\n }\n report.rate = caught / decided\n return report\n}\n\nfunction unseededRejection(\n manifest: PlantManifest,\n scoreByItemId: ReadonlyMap<string, number | null>,\n): UnseededRejection {\n const plantItemIds = new Set(manifest.plants.map((plant) => plant.item.itemId))\n let n = 0\n let decided = 0\n let rejected = 0\n for (const itemId of manifest.itemIds) {\n if (plantItemIds.has(itemId)) continue\n n += 1\n const score = scoreByItemId.get(itemId)\n if (score === undefined || score === null) continue\n decided += 1\n if (score < manifest.acceptThreshold) rejected += 1\n }\n return { n, decided, rejected, rejectionRate: decided === 0 ? null : rejected / decided }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyEA,eAAsB,iBACpB,YACA,cACA,aACA,oBACA,UAAmC,CAAC,GACH;CACjC,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,aAAa,QAAQ,uBAAuB;CAClD,MAAM,OAAO,QAAQ;CACrB,2BAA2B,WAAW,YAAY,IAAI;CACtD,2BACE,YAAY,KAAK,WAAW,OAAO,EAAE,GACrC,aACF;CACA,2BAA2B,oBAAoB,gBAAgB;CAC/D,MAAM,SAAS,QAAQ,mBAAmB;CAC1C,IAAI,SAAS,KAAK,OAAO,MAAM,MAAM,GACnC,MAAM,IAAI,MAAM,qCAAqC;CAEvD,MAAM,aAAa,YAAY,KAAK,YAAY;EAC9C,GAAG;EACH,SAAS,OAAO,WAAW,mBAAmB,OAAO,EAAE;CACzD,EAAE;CACF,MAAM,cAAc,CAAC,GAAG,kBAAkB;CAC1C,MAAM,OAAO,MAAM,WAAW,SAAS;CACvC,2BACE,KAAK,KAAK,QAAQ,IAAI,KAAK,GAC3B,OACF;CACA,MAAM,WAAW,MAAM,aAAa,KAAK,QAAQ,aAAa;CAC9D,MAAM,gCAAgB,IAAI,IAAiC;CAC3D,KAAK,MAAM,KAAK,UAAU;EACxB,MAAM,MAAM,cAAc,IAAI,EAAE,KAAK,KAAK,CAAC;EAC3C,IAAI,KAAK,CAAC;EACV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I,OAAO,OAAO,SAAS;CAC3D;CACA,OAAO,OAAO,SAAS;CACvB,OAAO;AACT;AAEA,SAAS,kBACP,UACA,eACmB;CACnB,MAAM,eAAe,IAAI,IAAI,SAAS,OAAO,KAAK,UAAU,MAAM,KAAK,MAAM,CAAC;CAC9E,IAAI,IAAI;CACR,IAAI,UAAU;CACd,IAAI,WAAW;CACf,KAAK,MAAM,UAAU,SAAS,SAAS;EACrC,IAAI,aAAa,IAAI,MAAM,GAAG;EAC9B,KAAK;EACL,MAAM,QAAQ,cAAc,IAAI,MAAM;EACtC,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAC3C,WAAW;EACX,IAAI,QAAQ,SAAS,iBAAiB,YAAY;CACpD;CACA,OAAO;EAAE;EAAG;EAAS;EAAU,eAAe,YAAY,IAAI,OAAO,WAAW;CAAQ;AAC1F"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/meta-eval/correlation-study.ts","../../src/meta-eval/evaluator-admission.ts","../../src/meta-eval/judge-panel-calibration.ts","../../src/meta-eval/plants.ts"],"sourcesContent":["/**\n * Correlation study — \"does our eval score predict real-world outcomes?\"\n *\n * Joins traces and outcomes by runId and reports descriptive correlations.\n * Independent runs are the bootstrap observation unit.\n * Association alone does not establish causation or held-out predictive performance.\n */\n\nimport { runMetricExtractor } from '../trace/query'\nimport type { Run } from '../trace/schema'\nimport type { TraceStore } from '../trace/store'\nimport {\n assertUniqueObservationIds,\n correlationSummary,\n hasVariation,\n reduceOutcomeMetric,\n validateObservationOptions,\n} from './outcome-observations'\nimport type { DeploymentOutcome, OutcomeFilter, OutcomeStore } from './outcome-store'\n\nexport interface EvalMetricSpec {\n id: string\n /** Extract a scalar from a run. Omit it and `id` must name one of\n * `RUN_METRICS`; any other `id` is refused. */\n extract?: (run: Run, store: TraceStore) => Promise<number | null>\n}\n\nexport interface OutcomePair {\n evalMetric: string\n outcomeMetric: string\n}\n\nexport interface CorrelationResult {\n evalMetric: string\n outcomeMetric: string\n n: number\n pearson: number\n spearman: number\n /** 95% bootstrap CI for Pearson. */\n pearsonCi95: { lower: number; upper: number } | null\n /** 95% bootstrap CI for Spearman; null when no resample is estimable. */\n spearmanCi95: { lower: number; upper: number } | null\n /** Rough verdict: 'strong' ≥ 0.7, 'moderate' ≥ 0.4, else 'weak'. */\n verdict: 'strong' | 'moderate' | 'weak'\n}\n\nexport interface CorrelationStudyResult {\n pairs: CorrelationResult[]\n /** Declared pairs without an estimable correlation, including their usable sample count. */\n excludedPairs: Array<\n OutcomePair & {\n n: number\n reason: 'insufficient_samples' | 'constant_eval_metric' | 'constant_outcome'\n }\n >\n joinedSamples: number\n skippedRuns: number\n}\n\nexport interface CorrelationStudyOptions {\n /** Only join outcomes captured within this window after run.startedAt. */\n maxCaptureLagMs?: number\n /** Restrict to a subset of outcomes (cohort, region, source). */\n outcomeFilter?: OutcomeFilter\n /** Which outcome per run to use when multiple exist. Default 'latest'. */\n reduction?: 'latest' | 'mean' | 'max'\n /** Bootstrap iterations for the CI. Default 500. */\n bootstrapIterations?: number\n /** Seed for the bootstrap resampler. Absent, the seed is derived from the\n * paired observations, so the same study reproduces the same interval. */\n seed?: number\n}\n\nexport async function correlationStudy(\n traceStore: TraceStore,\n outcomeStore: OutcomeStore,\n evalMetrics: EvalMetricSpec[],\n outcomeMetricNames: string[],\n options: CorrelationStudyOptions = {},\n): Promise<CorrelationStudyResult> {\n const reduction = options.reduction ?? 'latest'\n const iterations = options.bootstrapIterations ?? 500\n const seed = options.seed\n validateObservationOptions(reduction, iterations, seed)\n assertUniqueObservationIds(\n evalMetrics.map((metric) => metric.id),\n 'eval metric',\n )\n assertUniqueObservationIds(outcomeMetricNames, 'outcome metric')\n const maxLag = options.maxCaptureLagMs ?? Infinity\n if (maxLag < 0 || Number.isNaN(maxLag)) {\n throw new Error('maxCaptureLagMs must be nonnegative')\n }\n const extractors = evalMetrics.map((metric) => ({\n ...metric,\n extract: metric.extract ?? runMetricExtractor(metric.id),\n }))\n const metricNames = [...outcomeMetricNames]\n const runs = await traceStore.listRuns()\n assertUniqueObservationIds(\n runs.map((run) => run.runId),\n 'runId',\n )\n const outcomes = await outcomeStore.list(options.outcomeFilter)\n const outcomesByRun = new Map<string, DeploymentOutcome[]>()\n for (const o of outcomes) {\n const arr = outcomesByRun.get(o.runId) ?? []\n arr.push(o)\n outcomesByRun.set(o.runId, arr)\n }\n\n const pairs: Array<{ evalMetric: string; outcomeMetric: string; xs: number[]; ys: number[] }> = []\n for (const em of extractors) {\n for (const om of metricNames) {\n pairs.push({ evalMetric: em.id, outcomeMetric: om, xs: [], ys: [] })\n }\n }\n\n let joined = 0\n let skipped = 0\n for (const run of runs) {\n const os = outcomesByRun.get(run.runId)\n if (!os || os.length === 0) {\n skipped++\n continue\n }\n const eligible = os.filter((o) => {\n const lag = o.capturedAt - run.startedAt\n return lag >= 0 && lag <= maxLag\n })\n if (eligible.length === 0) {\n skipped++\n continue\n }\n\n let joinedThisRun = false\n for (const em of extractors) {\n const x = await em.extract(run, traceStore)\n if (x === null || !Number.isFinite(x)) continue\n\n for (const om of metricNames) {\n const y = reduceOutcomeMetric(eligible, om, reduction)\n if (y === null) continue\n const pair = pairs.find((p) => p.evalMetric === em.id && p.outcomeMetric === om)!\n pair.xs.push(x)\n pair.ys.push(y)\n joinedThisRun = true\n }\n }\n if (joinedThisRun) joined++\n else skipped++\n }\n\n const excludedPairs: CorrelationStudyResult['excludedPairs'] = []\n const results: CorrelationResult[] = []\n for (const p of pairs) {\n const reason =\n p.xs.length < 3\n ? 'insufficient_samples'\n : !hasVariation(p.xs)\n ? 'constant_eval_metric'\n : !hasVariation(p.ys)\n ? 'constant_outcome'\n : null\n if (reason !== null) {\n excludedPairs.push({\n evalMetric: p.evalMetric,\n outcomeMetric: p.outcomeMetric,\n n: p.xs.length,\n reason,\n })\n continue\n }\n const summary = correlationSummary(p.xs, p.ys, iterations, seed)\n const verdict: CorrelationResult['verdict'] =\n Math.abs(summary.pearson) >= 0.7\n ? 'strong'\n : Math.abs(summary.pearson) >= 0.4\n ? 'moderate'\n : 'weak'\n results.push({\n evalMetric: p.evalMetric,\n outcomeMetric: p.outcomeMetric,\n n: p.xs.length,\n ...summary,\n verdict,\n })\n }\n return { pairs: results, excludedPairs, joinedSamples: joined, skippedRuns: skipped }\n}\n","import { z } from 'zod'\nimport { ValidationError } from '../errors'\nimport { type ComputedInterval, computeInterval } from '../experiment/ast/interval'\nimport { compareCodeUnits, hashCanonical, type LedgerHash } from '../ledger-core/canonical'\n\nconst identity = z\n .string()\n .min(1)\n .refine((value) => value.trim() === value)\nexport const evaluatorAdmissionPolicySchema = z\n .object({\n confidence: z.number().finite().gt(0).lt(1),\n maxFalseAcceptanceRate: z.number().finite().min(0).lt(1),\n maxFalseRejectionRate: z.number().finite().min(0).lt(1),\n })\n .strict()\n\n/** Register both error limits before inspecting audit judgments. */\nexport type EvaluatorAdmissionPolicy = z.infer<typeof evaluatorAdmissionPolicySchema>\n\nexport const evaluatorAuditObservationSchema = z\n .object({\n id: identity,\n independentUnitId: identity,\n evidenceRef: identity,\n expected: z.enum(['accept', 'reject']),\n observed: z.enum(['accept', 'reject', 'unknown']),\n exposure: z.enum(['fresh', 'development']),\n })\n .strict()\n\n/** Actual control judgments. Variants from one source retain one independent identity. */\nexport type EvaluatorAuditObservation = z.infer<typeof evaluatorAuditObservationSchema>\n\nconst inputSchema = z\n .object({\n evaluatorDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/),\n population: identity,\n samplingFrame: identity,\n authority: z\n .object({\n evaluatorAuthorId: identity,\n auditorId: identity,\n independenceEvidenceRef: identity,\n })\n .strict(),\n policy: evaluatorAdmissionPolicySchema,\n observations: z.array(evaluatorAuditObservationSchema),\n })\n .strict()\n\nexport type EvaluatorAuditInput = z.infer<typeof inputSchema>\n\nexport interface EvaluatorErrorRate {\n /** Eligible control judgments in this class, including unknown judgments. */\n cases: number\n independentUnits: number\n /** Units with at least one observed mistake. */\n errorUnits: number\n /** Units with unknown judgments and no observed mistake yet. */\n unresolvedUnits: number\n unknownCases: number\n /** Missing judgments do not become measured zeros. */\n errorRate: number | null\n /** Exact bounds conservatively include every possible outcome of unknown judgments. */\n interval: ComputedInterval | null\n limit: number\n verdict: 'pass' | 'fail' | 'inconclusive'\n}\n\nexport interface EvaluatorAdmissionReport {\n evaluatorDigest: LedgerHash\n policyDigest: LedgerHash\n inputDigest: LedgerHash\n reportDigest: LedgerHash\n population: string\n samplingFrame: string\n authority: EvaluatorAuditInput['authority']\n policy: EvaluatorAdmissionPolicy\n /** Joint coverage for the two reported error-rate intervals. */\n confidence: number\n intervalConfidence: number\n verdict: 'admit' | 'reject' | 'inconclusive'\n reasons: string[]\n observations: EvaluatorAuditObservation[]\n coverage: {\n cases: number\n independentUnits: number\n eligibleCases: number\n eligibleIndependentUnits: number\n excludedCases: number\n unknownCases: number\n }\n exclusions: Array<{ id: string; independentUnitId: string; reason: 'development-exposure' }>\n falseAcceptance: EvaluatorErrorRate\n falseRejection: EvaluatorErrorRate\n}\n\nfunction errorRate(\n rows: readonly EvaluatorAuditObservation[],\n expected: 'accept' | 'reject',\n limit: number,\n level: number,\n): EvaluatorErrorRate {\n const cases = rows.filter((row) => row.expected === expected)\n const units = new Map<string, { error: boolean; unknown: boolean }>()\n for (const row of cases) {\n const unit = units.get(row.independentUnitId) ?? { error: false, unknown: false }\n unit.unknown ||= row.observed === 'unknown'\n unit.error ||= row.observed !== 'unknown' && row.observed !== expected\n units.set(row.independentUnitId, unit)\n }\n const n = units.size\n const errorUnits = [...units.values()].filter((unit) => unit.error).length\n const unresolvedUnits = [...units.values()].filter((unit) => unit.unknown && !unit.error).length\n const unknownCases = cases.filter((row) => row.observed === 'unknown').length\n // Unknown judgments contribute to n; their most favorable and adverse outcomes bound the rate.\n const interval =\n n === 0\n ? null\n : {\n lower: computeInterval(\n { kind: 'clopper-pearson', level },\n {\n kind: 'binomial',\n successes: errorUnits,\n trials: n,\n },\n ).lower,\n upper: computeInterval(\n { kind: 'clopper-pearson', level },\n {\n kind: 'binomial',\n successes: errorUnits + unresolvedUnits,\n trials: n,\n },\n ).upper,\n level,\n }\n const verdict =\n interval && interval.lower > limit\n ? 'fail'\n : interval && interval.upper <= limit\n ? 'pass'\n : 'inconclusive'\n return {\n cases: cases.length,\n independentUnits: n,\n errorUnits,\n unresolvedUnits,\n unknownCases,\n errorRate: n === 0 || unresolvedUnits > 0 ? null : errorUnits / n,\n interval,\n limit,\n verdict,\n }\n}\n\nfunction eligibleControls<\n T extends Pick<EvaluatorAuditObservation, 'id' | 'independentUnitId' | 'exposure'>,\n>(observations: T[]) {\n const ids = new Set<string>()\n for (const row of observations) {\n if (ids.has(row.id))\n throw new ValidationError(`duplicate evaluator audit observation '${row.id}'`)\n ids.add(row.id)\n }\n observations.sort((a, b) => compareCodeUnits(a.id, b.id))\n const developmentUnits = new Set(\n observations\n .filter((row) => row.exposure === 'development')\n .map((row) => row.independentUnitId),\n )\n const eligible = observations.filter((row) => !developmentUnits.has(row.independentUnitId))\n const exclusions = observations\n .filter((row) => developmentUnits.has(row.independentUnitId))\n .map((row) => ({\n id: row.id,\n independentUnitId: row.independentUnitId,\n reason: 'development-exposure' as const,\n }))\n return { eligible, exclusions }\n}\n\nfunction simultaneousIntervalConfidence(confidence: number): number {\n const level = 1 - (1 - confidence) / 2\n if (level >= 1)\n throw new ValidationError(\n 'evaluator audit confidence is too close to one for simultaneous intervals',\n )\n return level\n}\n\nconst capacitySchema = z\n .object({\n policy: evaluatorAdmissionPolicySchema,\n controls: z\n .array(evaluatorAuditObservationSchema.omit({ observed: true, evidenceRef: true }))\n .default([]),\n })\n .strict()\n\nexport type EvaluatorAuditPlanInput = z.input<typeof capacitySchema>\n\n/** The zero-error eligibility floor, not a statistical power calculation. */\nfunction zeroErrorUpperBound(trials: number, level: number): number {\n return -Math.expm1(Math.log((1 - level) / 2) / trials)\n}\n\nfunction minimumAuditUnits(limit: number, level: number): number | null {\n if (limit === 0) return null\n const estimate = Math.ceil(Math.log((1 - level) / 2) / Math.log1p(-limit))\n if (!Number.isFinite(estimate) || estimate > Number.MAX_SAFE_INTEGER) return null\n const clears = (trials: number) => zeroErrorUpperBound(trials, level) <= limit\n let minimum = Math.max(1, estimate)\n while (minimum > 1 && clears(minimum - 1)) minimum -= 1\n while (!clears(minimum)) {\n if (minimum === Number.MAX_SAFE_INTEGER) return null\n minimum += 1\n }\n return minimum\n}\n\n/**\n * Can the fixed control roster meet the policy even with zero errors?\n * Planning uses the admission rule's exact bounds and source-unit exclusions.\n * It accepts no judgments or authority and returns no admission report.\n */\nexport function planEvaluatorAudit(input: EvaluatorAuditPlanInput) {\n const parsed = capacitySchema.safeParse(input)\n if (!parsed.success)\n throw new ValidationError(`invalid evaluator audit plan: ${parsed.error.message}`)\n const { policy, controls } = parsed.data\n const { eligible } = eligibleControls(controls)\n const level = simultaneousIntervalConfidence(policy.confidence)\n const capacity = (expected: EvaluatorAuditObservation['expected'], limit: number) => {\n const independentUnits = new Set(\n eligible.filter((row) => row.expected === expected).map((row) => row.independentUnitId),\n ).size\n const bestPossibleUpperBound =\n independentUnits === 0 ? null : zeroErrorUpperBound(independentUnits, level)\n const minimumIndependentUnits = minimumAuditUnits(limit, level)\n return {\n independentUnits,\n bestPossibleUpperBound,\n limit,\n minimumIndependentUnits,\n additionalIndependentUnits:\n minimumIndependentUnits === null\n ? null\n : Math.max(0, minimumIndependentUnits - independentUnits),\n }\n }\n const falseAcceptance = capacity('reject', policy.maxFalseAcceptanceRate)\n const falseRejection = capacity('accept', policy.maxFalseRejectionRate)\n const sufficient = [falseAcceptance, falseRejection].every(\n (rate) => rate.bestPossibleUpperBound !== null && rate.bestPossibleUpperBound <= rate.limit,\n )\n return { sufficient, falseAcceptance, falseRejection }\n}\n\nexport type EvaluatorAuditPlan = ReturnType<typeof planEvaluatorAudit>\n\n/**\n * Audit frozen judgments using independent source units and exact binomial bounds.\n * A unit fails a class when any control in that class is misjudged.\n * The execution owner enforces auditor separation, fresh sampling, and evidence authenticity.\n */\nexport function auditEvaluator(input: EvaluatorAuditInput): EvaluatorAdmissionReport {\n const parsed = inputSchema.safeParse(input)\n if (!parsed.success) throw new ValidationError(`invalid evaluator audit: ${parsed.error.message}`)\n const audit = parsed.data\n if (audit.authority.evaluatorAuthorId === audit.authority.auditorId) {\n throw new ValidationError('evaluator admission requires a separate declared audit authority')\n }\n const { eligible, exclusions } = eligibleControls(audit.observations)\n const intervalConfidence = simultaneousIntervalConfidence(audit.policy.confidence)\n const falseAcceptance = errorRate(\n eligible,\n 'reject',\n audit.policy.maxFalseAcceptanceRate,\n intervalConfidence,\n )\n const falseRejection = errorRate(\n eligible,\n 'accept',\n audit.policy.maxFalseRejectionRate,\n intervalConfidence,\n )\n const rates = [falseAcceptance, falseRejection]\n const verdict = rates.some((rate) => rate.verdict === 'fail')\n ? 'reject'\n : rates.every((rate) => rate.verdict === 'pass')\n ? 'admit'\n : 'inconclusive'\n const reasons: string[] = []\n for (const [name, rate] of [\n ['false acceptance', falseAcceptance],\n ['false rejection', falseRejection],\n ] as const) {\n if (rate.independentUnits === 0) reasons.push(`${name}: no eligible independent units`)\n else if (rate.unknownCases > 0)\n reasons.push(`${name}: ${rate.unknownCases} judgments are unknown`)\n if (rate.verdict === 'fail') reasons.push(`${name}: lower error bound exceeds ${rate.limit}`)\n else if (rate.verdict === 'inconclusive' && rate.interval)\n reasons.push(`${name}: upper error bound does not establish the required limit`)\n }\n if (verdict === 'admit')\n reasons.push(\n 'both error bounds meet the registered limits, including the worst case for unknown judgments',\n )\n const body: Omit<EvaluatorAdmissionReport, 'reportDigest'> = {\n evaluatorDigest: audit.evaluatorDigest as LedgerHash,\n policyDigest: hashCanonical(audit.policy),\n inputDigest: hashCanonical(audit),\n population: audit.population,\n samplingFrame: audit.samplingFrame,\n authority: audit.authority,\n policy: audit.policy,\n confidence: audit.policy.confidence,\n intervalConfidence,\n verdict,\n reasons,\n observations: audit.observations,\n coverage: {\n cases: audit.observations.length,\n independentUnits: new Set(audit.observations.map((row) => row.independentUnitId)).size,\n eligibleCases: eligible.length,\n eligibleIndependentUnits: new Set(eligible.map((row) => row.independentUnitId)).size,\n excludedCases: exclusions.length,\n unknownCases: eligible.filter((row) => row.observed === 'unknown').length,\n },\n exclusions,\n falseAcceptance,\n falseRejection,\n }\n return { ...body, reportDigest: hashCanonical(body) }\n}\n\nconst probabilityThresholdsSchema = z\n .object({\n rejectAtOrBelow: z.number().finite().min(0).max(1),\n acceptAtOrAbove: z.number().finite().min(0).max(1),\n })\n .strict()\n .refine((value) => value.rejectAtOrBelow < value.acceptAtOrAbove, {\n message: 'rejection and acceptance thresholds must not overlap',\n })\nconst probabilityObservationSchema = evaluatorAuditObservationSchema\n .omit({ observed: true })\n .extend({ acceptProbability: z.number().finite().min(0).max(1).nullable() })\n .strict()\nconst probabilityAuditSchema = inputSchema.extend({\n thresholds: probabilityThresholdsSchema,\n observations: z.array(probabilityObservationSchema),\n})\n\n/** A frozen caller-owned rule over P(accept), not the provider's entropy/confidence statistic. */\nexport type ProbabilityPolicyAuditInput = z.infer<typeof probabilityAuditSchema>\n\nexport interface ProbabilityPolicyAuditReport extends EvaluatorAdmissionReport {\n probabilityPolicy: {\n sourceEvaluatorDigest: LedgerHash\n thresholds: ProbabilityPolicyAuditInput['thresholds']\n /** Retain probabilities by observation id so the reported mapping can be reproduced. */\n observations: Array<{ id: string; acceptProbability: number | null }>\n }\n}\n\n/**\n * Audit a fixed probability-to-decision rule with the existing independent-unit error bounds.\n * No threshold search, model calls, promotion, or assumption of calibrated probabilities.\n * Null scores and the open interval between thresholds remain unknown, never correct by default.\n */\nexport function auditProbabilityPolicy(\n input: ProbabilityPolicyAuditInput,\n): ProbabilityPolicyAuditReport {\n const parsed = probabilityAuditSchema.safeParse(input)\n if (!parsed.success) {\n throw new ValidationError(`invalid probability policy audit: ${parsed.error.message}`)\n }\n const { thresholds, observations, ...source } = parsed.data\n observations.sort((a, b) => compareCodeUnits(a.id, b.id))\n const probabilityPolicy = {\n sourceEvaluatorDigest: source.evaluatorDigest as LedgerHash,\n thresholds,\n observations: observations.map(({ id, acceptProbability }) => ({ id, acceptProbability })),\n }\n const audit = auditEvaluator({\n ...source,\n evaluatorDigest: hashCanonical({\n kind: 'probability-policy-v1',\n sourceEvaluatorDigest: source.evaluatorDigest,\n thresholds,\n }),\n observations: observations.map(({ acceptProbability, ...observation }) => ({\n ...observation,\n observed:\n acceptProbability === null\n ? 'unknown'\n : acceptProbability >= thresholds.acceptAtOrAbove\n ? 'accept'\n : acceptProbability <= thresholds.rejectAtOrBelow\n ? 'reject'\n : 'unknown',\n })),\n })\n const { reportDigest: _baseDigest, ...baseReport } = audit\n const body = {\n ...baseReport,\n // Bind the actual probabilities too, including changes that select the same action.\n inputDigest: hashCanonical(parsed.data),\n probabilityPolicy,\n }\n return { ...body, reportDigest: hashCanonical(body) }\n}\n","/**\n * Judge-panel calibration: score a hand-graded gold set with every judge model\n * on a panel, under one weighted rubric, and measure each (judge × dimension)\n * against the human grades with `calibrateJudge`.\n *\n * The caller owns the domain: the rubric text and weights, the system prompt,\n * the gold items and the judge list. This module owns the mechanics every\n * product repeats — the rubric prompt, the JSON call with retries, the\n * sequential (item × judge) sweep, null-grade handling, and the per-cell\n * calibration — plus `gateJudgeCalibration`, the pass/warn/fail rule over the\n * resulting cells.\n *\n * Calls run one at a time. Subscription bridges serialise per subprocess, and\n * concurrent requests from a full panel get killed under load.\n *\n * A gold cell with a null or missing human grade is still scored (the judge's\n * score lands in `rawScores`, useful for inter-judge agreement) but never\n * enters that dimension's calibration.\n */\n\nimport {\n type CalibrationResult,\n type CandidateScore,\n calibrateJudge,\n type GoldenItem,\n} from '../judge-calibration'\nimport { withJudgeRetry } from '../judge-retry'\nimport { callLlmJson, type LlmClientOptions } from '../llm-client'\n\n/** One rubric dimension: the guide the judge scores against and its weight in the composite. */\nexport interface RubricDimensionGuide {\n weight: number\n guide: string\n}\n\nexport interface JudgeCalibrationGoldItem<D extends string> {\n id: string\n /** Text after `Scenario:` in the judge prompt. Defaults to `id`. */\n scenarioLabel?: string\n /** The input the candidate answered. */\n scenario: string\n /** The output the judges score. */\n candidateOutput: string\n /** Human grade per dimension in [0,1]. `null` (whole item or one dimension)\n * means not graded: the item is still judged but excluded from calibration. */\n humanGrade: Partial<Record<D, number | null>> | null\n}\n\nexport interface JudgePanelPrompt {\n /** The judge's system prompt. */\n system: string\n /** Line above the rubric. Default: score each dimension in [0,1]. */\n rubricHeading?: string\n /** Line above the candidate output. Default `Candidate output to score:`. */\n candidateHeading?: string\n /** Candidate output is cut to this many characters. Default 12000. */\n maxCandidateChars?: number\n /** Lines after the JSON-shape instruction. */\n closingLines?: readonly string[]\n}\n\nexport interface CalibrateJudgePanelInput<D extends string> {\n rubric: Readonly<Record<D, RubricDimensionGuide>>\n /** Dimensions to score, in prompt order. Defaults to the rubric's keys. */\n dimensions?: readonly D[]\n items: readonly JudgeCalibrationGoldItem<D>[]\n judges: readonly string[]\n /** Endpoint and credential for every judge call. */\n llm: LlmClientOptions\n prompt: JudgePanelPrompt\n /** Default 1200. */\n maxTokens?: number\n /** Per-attempt timeout. Default 300000. */\n timeoutMs?: number\n /** Attempts per (item × judge); every error is retried. Default 3. */\n maxAttempts?: number\n /** Progress lines (one per item and judge, then the metrics table). */\n log?: (line: string) => void\n}\n\n/** A judge's calibration on one dimension. `golden` and `scores` hold the same\n * items: the human-graded ones this judge scored. */\nexport interface JudgeDimensionCalibration {\n calibration: CalibrationResult\n golden: GoldenItem[]\n scores: CandidateScore[]\n}\n\n/** What one judge returned for one item: a score per dimension and its rationale. */\nexport type JudgePanelOutput<D extends string> = Partial<Record<D, number>> & { rationale?: string }\n\nexport interface JudgePanelCalibration<D extends string> {\n judges: string[]\n dimensions: D[]\n perJudge: Record<string, Record<D, JudgeDimensionCalibration>>\n /** Every score each judge returned, graded items or not, clamped to [0,1]. */\n rawScores: Record<string, Record<D, CandidateScore[]>>\n /** Parsed judge output per item; `null` when every attempt failed. */\n outputs: Record<string, Record<string, JudgePanelOutput<D> | null>>\n /** Item ids with no human grade, per dimension. */\n ungradedItems: Record<D, string[]>\n /** (judge × item) cells where every attempt failed. */\n failures: Array<{ judge: string; itemId: string; errors: string[] }>\n elapsedMs: number\n}\n\nconst DEFAULT_RUBRIC_HEADING =\n 'Rubric (score each dimension in [0,1]; 1 = perfectly satisfies the guide, 0 = fails):'\n\nfunction clampUnit(n: number): number {\n if (!Number.isFinite(n)) return 0\n if (n < 0) return 0\n if (n > 1) return 1\n return n\n}\n\nfunction humanScore<D extends string>(item: JudgeCalibrationGoldItem<D>, d: D): number | null {\n const v = item.humanGrade?.[d]\n return typeof v === 'number' && Number.isFinite(v) ? v : null\n}\n\nfunction shortModel(model: string): string {\n return (model.split('/').pop() ?? model).padEnd(28)\n}\n\nfunction judgeUserPrompt<D extends string>(\n input: CalibrateJudgePanelInput<D>,\n dimensions: readonly D[],\n item: JudgeCalibrationGoldItem<D>,\n): string {\n const rubricLines = dimensions\n .map((d) => `- ${d} (weight ${input.rubric[d].weight}): ${input.rubric[d].guide}`)\n .join('\\n')\n const jsonShape = `{${dimensions.map((d) => `\"${d}\":number`).join(',')},\"rationale\":string}`\n return [\n `Scenario: ${item.scenarioLabel ?? item.id}`,\n `Input: ${item.scenario}`,\n '',\n input.prompt.rubricHeading ?? DEFAULT_RUBRIC_HEADING,\n rubricLines,\n '',\n input.prompt.candidateHeading ?? 'Candidate output to score:',\n '---',\n item.candidateOutput.slice(0, input.prompt.maxCandidateChars ?? 12_000),\n '---',\n '',\n `Respond ONLY with a JSON object exactly of shape: ${jsonShape}.`,\n ...(input.prompt.closingLines ?? []),\n ].join('\\n')\n}\n\n/** Run every judge on every gold item and calibrate each (judge × dimension). */\nexport async function calibrateJudgePanel<D extends string>(\n input: CalibrateJudgePanelInput<D>,\n): Promise<JudgePanelCalibration<D>> {\n const dimensions = [...(input.dimensions ?? (Object.keys(input.rubric) as D[]))]\n const judges = [...input.judges]\n const log = input.log ?? (() => {})\n const perDim = <T>(make: () => T) =>\n Object.fromEntries(dimensions.map((d) => [d, make()])) as Record<D, T>\n\n const rawScores: JudgePanelCalibration<D>['rawScores'] = {}\n const outputs: JudgePanelCalibration<D>['outputs'] = {}\n const goldenByJudge: Record<string, Record<D, GoldenItem[]>> = {}\n const scoresByJudge: Record<string, Record<D, CandidateScore[]>> = {}\n for (const judge of judges) {\n rawScores[judge] = perDim(() => [] as CandidateScore[])\n outputs[judge] = {}\n goldenByJudge[judge] = perDim(() => [] as GoldenItem[])\n scoresByJudge[judge] = perDim(() => [] as CandidateScore[])\n }\n const ungradedItems = perDim(() => [] as string[])\n for (const item of input.items) {\n for (const d of dimensions) if (humanScore(item, d) === null) ungradedItems[d].push(item.id)\n }\n const failures: JudgePanelCalibration<D>['failures'] = []\n\n const startedAt = Date.now()\n for (let i = 0; i < input.items.length; i++) {\n const item = input.items[i] as JudgeCalibrationGoldItem<D>\n log(` [${(i + 1).toString().padStart(2)}/${input.items.length}] ${item.id}`)\n const userPrompt = judgeUserPrompt(input, dimensions, item)\n for (const judge of judges) {\n const outcome = await withJudgeRetry(\n async (_model, signal) =>\n (\n await callLlmJson<JudgePanelOutput<D>>(\n {\n model: judge,\n messages: [\n { role: 'system', content: input.prompt.system },\n { role: 'user', content: userPrompt },\n ],\n jsonMode: true,\n temperature: 0,\n maxTokens: input.maxTokens ?? 1200,\n timeoutMs: input.timeoutMs ?? 300_000,\n },\n { ...input.llm, signal },\n )\n ).value,\n {\n maxAttempts: input.maxAttempts ?? 3,\n timeoutMs: input.timeoutMs ?? 300_000,\n isRetryable: () => true,\n backoffMs: (attempt) => 2_000 * (attempt + 1),\n },\n )\n const out = outcome.succeeded ? outcome.value : null\n outputs[judge]![item.id] = out\n if (!out) {\n const errors = outcome.attemptErrors.map((e) => e.error)\n failures.push({ judge, itemId: item.id, errors })\n log(` ${shortModel(judge)} - FAILED (${errors.at(-1) ?? 'no attempt'})`)\n continue\n }\n let judged = 0\n let expected = 0\n let covered = 0\n for (const d of dimensions) {\n const score = clampUnit(Number((out as Record<string, unknown>)[d]))\n rawScores[judge]![d].push({ itemId: item.id, score })\n const human = humanScore(item, d)\n if (human === null) continue\n goldenByJudge[judge]![d].push({ itemId: item.id, humanScore: human })\n scoresByJudge[judge]![d].push({ itemId: item.id, score })\n const weight = input.rubric[d].weight\n judged += score * weight\n expected += human * weight\n covered += weight\n }\n const pct = (n: number) => `${(n * 100).toFixed(0)}%`\n log(\n covered > 0\n ? ` ${shortModel(judge)} judged=${pct(judged / covered)} expected=${pct(expected / covered)} delta=${pct((judged - expected) / covered)} cover=${pct(covered)}`\n : ` ${shortModel(judge)} judged (ungraded item)`,\n )\n }\n }\n const elapsedMs = Date.now() - startedAt\n\n const perJudge: JudgePanelCalibration<D>['perJudge'] = {}\n for (const judge of judges) {\n log(` ${judge}`)\n perJudge[judge] = {} as Record<D, JudgeDimensionCalibration>\n for (const d of dimensions) {\n const golden = goldenByJudge[judge]![d]\n const scores = scoresByJudge[judge]![d]\n const calibration = calibrateJudge(golden, scores)\n perJudge[judge]![d] = { calibration, golden, scores }\n log(\n ` ${d.padEnd(34)} n=${calibration.n.toString().padStart(2)} kappa=${calibration.kappa.toFixed(2)} r=${calibration.pearson.toFixed(2)} MAE=${calibration.mae.toFixed(3)}`,\n )\n }\n }\n\n return { judges, dimensions, perJudge, rawScores, outputs, ungradedItems, failures, elapsedMs }\n}\n\n/** Thresholds for `gateJudgeCalibration`. */\nexport interface JudgeCalibrationGateConfig {\n /** Pearson below this (and at or above `pearsonWarn`) warns. */\n pearsonFloor: number\n /** Pearson below this fails. */\n pearsonWarn: number\n /** MAE above this fails. */\n maeCeiling: number\n /** Cells with fewer graded items are reported as insufficient and never fail. */\n minSamples: number\n}\n\nexport type JudgeCalibrationCellVerdict = 'pass' | 'warn' | 'fail' | 'insufficient'\n\nexport interface JudgeCalibrationGateCell {\n judge: string\n dim: string\n n: number\n pearson: number\n mae: number\n verdict: JudgeCalibrationCellVerdict\n reasons: string[]\n}\n\nexport interface JudgeCalibrationGate {\n pass: boolean\n config: JudgeCalibrationGateConfig\n failCount: number\n warnCount: number\n insufficientCount: number\n cells: JudgeCalibrationGateCell[]\n}\n\n/** Pass/warn/fail every (judge × dimension) cell; the gate passes with zero fail cells. */\nexport function gateJudgeCalibration(\n perJudge: Record<string, Record<string, { calibration: CalibrationResult }>>,\n config: JudgeCalibrationGateConfig,\n): JudgeCalibrationGate {\n const cells: JudgeCalibrationGateCell[] = []\n for (const [judge, dims] of Object.entries(perJudge)) {\n for (const [dim, { calibration: cal }] of Object.entries(dims)) {\n const reasons: string[] = []\n let verdict: JudgeCalibrationCellVerdict = 'pass'\n if (cal.n < config.minSamples) {\n verdict = 'insufficient'\n reasons.push(`n=${cal.n} < minSamples=${config.minSamples}`)\n } else {\n if (Number.isFinite(cal.pearson) && cal.pearson < config.pearsonFloor) {\n if (cal.pearson < config.pearsonWarn) {\n verdict = 'fail'\n reasons.push(\n `pearson=${cal.pearson.toFixed(2)} < floor=${config.pearsonFloor.toFixed(2)} (below warn=${config.pearsonWarn.toFixed(2)})`,\n )\n } else {\n verdict = 'warn'\n reasons.push(\n `pearson=${cal.pearson.toFixed(2)} in warn band [${config.pearsonWarn.toFixed(2)}, ${config.pearsonFloor.toFixed(2)})`,\n )\n }\n }\n if (Number.isFinite(cal.mae) && cal.mae > config.maeCeiling) {\n verdict = 'fail'\n reasons.push(`mae=${cal.mae.toFixed(3)} > ceiling=${config.maeCeiling.toFixed(3)}`)\n }\n }\n cells.push({ judge, dim, n: cal.n, pearson: cal.pearson, mae: cal.mae, verdict, reasons })\n }\n }\n const count = (v: JudgeCalibrationCellVerdict) => cells.filter((c) => c.verdict === v).length\n const failCount = count('fail')\n return {\n pass: failCount === 0,\n config,\n failCount,\n warnCount: count('warn'),\n insufficientCount: count('insufficient'),\n cells,\n }\n}\n","/**\n * Plants — seeded known-wrong items that measure the grader, not the work.\n *\n * A grading run reports how the work scored. It cannot report whether the\n * grader would have noticed a wrong answer, because every item it saw was\n * authored in good faith. A plant closes that hole: an item authored wrong by\n * construction is mixed into the live set, graded by the same path as\n * everything else, and the share of plants the grader refused is the catch\n * rate.\n *\n * Measured motive: a sibling lab ran a deliverable gate that accepted any\n * non-empty submission. It produced six false certifications in seventeen\n * deliveries, and no agent lied — the gate never asked a question the format\n * could fail. A catch rate is the number that would have shown it on day one.\n *\n * This module composes existing primitives rather than adding parallel ones:\n *\n * - A plant IS a {@link GoldenItem} from `../judge-calibration`. Its\n * `humanScore` is the grade a working grader owes the item, so the same\n * array feeds `calibrateJudge` unchanged.\n * - The grader's output is `CandidateScore[]`, the array `calibrateJudge` and\n * `snapshotFromSentinelSet` already consume.\n * - \"Caught\" is `snapshotFromSentinelSet`'s join with the labels inverted:\n * the grade lands on the side of `acceptThreshold` the seed demands.\n * - The manifest is sealed with `hashCanonical` from `../ledger-core/canonical`,\n * the digest the sealed-experiment path uses, so the answer key cannot be\n * revised once the results are in.\n *\n * Authoring the wrong item is the step before all of that, and it is where the\n * measurement silently breaks. {@link plantByPerturbation} takes a claim a\n * grader verified and alters exactly one load-bearing value in its evidence,\n * so the grader is asked a question it must fail. Hand-rolled perturbation\n * bumps a number that is part of an identity — `python3`, `file42.txt`, `1.5`,\n * `utf-8` — and the check stops EXECUTING; the plant then measures the\n * environment rather than the grader. {@link perturbEvidence} refuses those\n * digit runs by construction.\n *\n * Blindness has two halves, and this module owns one. It never puts a plant\n * flag on a graded item: `seedPlants` returns the mixed set and a manifest,\n * and only the manifest knows which ids are seeded. Keeping the manifest out\n * of the graded workspace and publishing its `seal` before grading is the\n * caller's half; {@link catchRate} refuses a manifest whose contents no longer\n * match its seal.\n *\n * Refusals, because a catch rate that cannot refuse is not a measurement:\n *\n * - a seeded id with no result makes the report `incomplete`, never a rate\n * over the results that did come back;\n * - zero seeded plants makes it `not_evaluated`, never 1.0;\n * - a result for an id the manifest never handed out is refused outright.\n */\n\nimport { CaptureIntegrityError, ValidationError } from '../errors'\nimport type { GoldenItem } from '../judge-calibration'\nimport { hashCanonical, type LedgerHash } from '../ledger-core/canonical'\nimport { mulberry32 } from '../statistics/random'\n\n/**\n * How a plant item was authored wrong. The class is reported separately in\n * {@link CatchRateReport.byKind} because a grader is routinely sharp on one\n * and blind to another.\n */\nexport type PlantKind =\n /** A load-bearing value is altered: a number off by one, a comparison flipped. */\n | 'wrong-value'\n /** The item carries its own check, and that check passes without testing the claim. */\n | 'self-certifying'\n /** The check names an input that does not exist, so it cannot run at all. */\n | 'unreachable-input'\n /** A copy of an item already in the set, which is owed a duplicate flag rather than a second grade. */\n | 'duplicate'\n\nconst PLANT_KINDS: readonly PlantKind[] = [\n 'wrong-value',\n 'self-certifying',\n 'unreachable-input',\n 'duplicate',\n]\n\n/** What a working grader owes a seeded item. */\nexport type PlantExpectation = 'reject' | 'accept'\n\nconst PLANT_EXPECTATIONS: readonly PlantExpectation[] = ['reject', 'accept']\n\n/** The label boundary a plant record is checked against at definition time. */\nconst RECORD_LABEL_BOUNDARY = 0.5\n\nexport interface Plant {\n /** Name of the plant record. Reported in `missedIds` and `missingIds`. */\n id: string\n kind: PlantKind\n /** The seeded item, indistinguishable from a real one once mixed. */\n item: GoldenItem\n /** The verdict a working grader owes this item. */\n expectedVerdict: PlantExpectation\n}\n\n/**\n * Build one plant record and refuse an incoherent one.\n *\n * The refusal that matters is the last: a record whose `expectedVerdict`\n * disagrees with `item.humanScore` inverts the measurement silently, because\n * the same item then reads as wrong here and as correct to every calibration\n * instrument that joins on the id.\n *\n * `item` is copied field by field so a later mutation of the caller's object\n * cannot change what the manifest sealed, and `group` is dropped when it is\n * absent so the record always has a canonical JSON form.\n */\nexport function definePlant(input: {\n id: string\n kind: PlantKind\n item: GoldenItem\n expectedVerdict: PlantExpectation\n}): Plant {\n const { id, kind, item, expectedVerdict } = input\n if (typeof id !== 'string' || id.trim() === '') {\n throw new ValidationError('definePlant: id must be a non-empty string')\n }\n if (!PLANT_KINDS.includes(kind)) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has kind ${JSON.stringify(kind)}; expected one of ${PLANT_KINDS.join(', ')}`,\n )\n }\n if (!PLANT_EXPECTATIONS.includes(expectedVerdict)) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has expectedVerdict ${JSON.stringify(expectedVerdict)}; expected one of ${PLANT_EXPECTATIONS.join(', ')}`,\n )\n }\n if (typeof item.itemId !== 'string' || item.itemId.trim() === '') {\n throw new ValidationError(`definePlant: plant \"${id}\" has an empty item.itemId`)\n }\n if (!Number.isFinite(item.humanScore) || item.humanScore < 0 || item.humanScore > 1) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has humanScore ${item.humanScore}; expected a finite number in [0, 1]`,\n )\n }\n if (item.group !== undefined && typeof item.group !== 'string') {\n throw new ValidationError(`definePlant: plant \"${id}\" has a non-string item.group`)\n }\n if (item.humanScore === RECORD_LABEL_BOUNDARY) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" has humanScore ${RECORD_LABEL_BOUNDARY}, which states neither a rejection nor an acceptance`,\n )\n }\n const labelSays: PlantExpectation = item.humanScore < RECORD_LABEL_BOUNDARY ? 'reject' : 'accept'\n if (labelSays !== expectedVerdict) {\n throw new ValidationError(\n `definePlant: plant \"${id}\" expects the grader to ${expectedVerdict} it, but humanScore ${item.humanScore} says ${labelSays}`,\n )\n }\n return {\n id,\n kind,\n item: {\n itemId: item.itemId,\n humanScore: item.humanScore,\n ...(item.group === undefined ? {} : { group: item.group }),\n },\n expectedVerdict,\n }\n}\n\n/**\n * A claim's executable evidence: the command a grader runs and the output it\n * must produce.\n */\nexport interface PlantEvidence {\n /** The command a grader runs to test the claim. */\n check?: string\n /** The output that command must produce for the claim to stand. */\n expect?: string\n}\n\n/** Which evidence field {@link perturbEvidence} altered. */\nexport type PerturbedField = 'check' | 'expect'\n\n/** How {@link perturbEvidence} altered it. */\nexport type PerturbationKind = 'number-off-by-one' | 'comparison-flipped'\n\nexport interface EvidencePerturbation {\n /** The evidence with exactly one value altered. */\n evidence: PlantEvidence\n /** Which field changed. */\n field: PerturbedField\n /** How it changed. */\n how: PerturbationKind\n /**\n * The exact substring that was replaced. A comparison token carries its\n * surrounding spaces, because the spaces are what make ` -ge ` a comparison\n * and not part of a word.\n */\n original: string\n /** What replaced it. */\n perturbed: string\n}\n\n/**\n * Characters that make a digit run part of something larger than a number.\n *\n * A run that touches one of these is an identity — `python3`, `file42.txt`,\n * `1.5`, `utf-8` — and bumping it renames a program, a file, a version, or an\n * encoding instead of falsifying the claim. The check then stops EXECUTING,\n * and a plant that cannot run measures the environment rather than the grader:\n * it reads as caught, for a reason that has nothing to do with the seeded\n * defect.\n */\nconst NUMBER_GLUE = /[A-Za-z0-9_./-]/\n\n/**\n * Comparison tokens that mean one thing only, each with its inversion.\n *\n * A bare `>` or `<` is absent on purpose: in a shell check it is a\n * redirection, so flipping it rewrites where output goes rather than what the\n * test asks, and the check stops testing the claim.\n */\nconst COMPARISON_FLIPS: readonly (readonly [string, string])[] = [\n [' -ge ', ' -lt '],\n [' -gt ', ' -le '],\n [' -le ', ' -gt '],\n [' -lt ', ' -ge '],\n [' -eq ', ' -ne '],\n [' -ne ', ' -eq '],\n ['>=', '<'],\n ['<=', '>'],\n ['==', '!='],\n ['!=', '=='],\n]\n\ninterface Span {\n start: number\n end: number\n}\n\n/**\n * The last digit run in `text` that is a number and nothing else, or null.\n *\n * The last is taken because a measured value trails its label — `count=42`,\n * `n>=5 OK cells=8` — and because the choice has to be deterministic: the same\n * claim must always yield the same plant, or two runs of the same authoring\n * step seed two different answer keys for one item.\n */\nfunction lastStandaloneNumber(text: string): Span | null {\n const digits = /\\d+/g\n let found: Span | null = null\n let match = digits.exec(text)\n while (match !== null) {\n const start = match.index\n const end = start + match[0].length\n // charAt returns '' outside the string, and NUMBER_GLUE never matches ''.\n if (!NUMBER_GLUE.test(text.charAt(start - 1)) && !NUMBER_GLUE.test(text.charAt(end))) {\n found = { start, end }\n }\n match = digits.exec(text)\n }\n return found\n}\n\n/**\n * The first flippable comparison in `text`, or null.\n *\n * Any single flip inverts the test wherever it sits, so unlike the number rule\n * there is no safety ordering among the matches. The first is taken so the\n * result is fixed by the head of the command and does not move when a later\n * comparison is added.\n */\nfunction firstComparison(text: string): { span: Span; flipped: string } | null {\n for (let index = 0; index < text.length; index += 1) {\n for (const [token, flipped] of COMPARISON_FLIPS) {\n if (text.startsWith(token, index)) {\n return { span: { start: index, end: index + token.length }, flipped }\n }\n }\n }\n return null\n}\n\nfunction replaceSpan(text: string, span: Span, value: string): string {\n return text.slice(0, span.start) + value + text.slice(span.end)\n}\n\n/**\n * Rebuild the evidence with one field replaced. An absent field is dropped\n * rather than set to undefined, so the record always has a canonical JSON form.\n */\nfunction withField(\n check: string | undefined,\n expect: string | undefined,\n field: PerturbedField,\n value: string,\n): PlantEvidence {\n const nextCheck = field === 'check' ? value : check\n const nextExpect = field === 'expect' ? value : expect\n return {\n ...(nextCheck === undefined ? {} : { check: nextCheck }),\n ...(nextExpect === undefined ? {} : { expect: nextExpect }),\n }\n}\n\nfunction offByOne(\n check: string | undefined,\n expect: string | undefined,\n field: PerturbedField,\n text: string,\n span: Span,\n): EvidencePerturbation {\n const original = text.slice(span.start, span.end)\n const perturbed = (BigInt(original) + 1n).toString()\n return {\n evidence: withField(check, expect, field, replaceSpan(text, span, perturbed)),\n field,\n how: 'number-off-by-one',\n original,\n perturbed,\n }\n}\n\n/**\n * Derive a known-wrong version of a claim's evidence by altering exactly one\n * value, or return null when no value can be altered safely.\n *\n * Exactly one value changes. A perturbation that moves two does not name the\n * defect it seeded, so a grader that catches it says nothing about which defect\n * the grader can see.\n *\n * The preference order IS the safety order:\n *\n * 1. the last standalone number in `expect` — it falsifies the claim while the\n * command still runs exactly as it did;\n * 2. a flipped comparison in `check` — it inverts a test that was passing;\n * 3. the last standalone number in `check` — last because a number in a command\n * can name an input (a port, a width, a version) rather than a threshold,\n * and renaming an input breaks execution, not the claim.\n *\n * \"Standalone\" excludes a digit run glued to a word, a dot, a slash, or a\n * hyphen: `python3`, `file42.txt`, `1.5`, `utf-8`. That exclusion is why this\n * helper exists. Hand-rolled perturbation bumps one of those, the check stops\n * executing, and the plant measures the environment instead of the grader.\n *\n * A number is bumped with BigInt, so a value wider than\n * `Number.MAX_SAFE_INTEGER` moves by exactly one. Bumped as a `number` it\n * rounds back to itself, and the plant is then a correct claim the grader is\n * right to verify.\n */\nexport function perturbEvidence(evidence: PlantEvidence): EvidencePerturbation | null {\n const check = typeof evidence.check === 'string' ? evidence.check : undefined\n const expect = typeof evidence.expect === 'string' ? evidence.expect : undefined\n\n if (expect !== undefined) {\n const span = lastStandaloneNumber(expect)\n if (span !== null) return offByOne(check, expect, 'expect', expect, span)\n }\n if (check !== undefined) {\n const comparison = firstComparison(check)\n if (comparison !== null) {\n return {\n evidence: withField(\n check,\n expect,\n 'check',\n replaceSpan(check, comparison.span, comparison.flipped),\n ),\n field: 'check',\n how: 'comparison-flipped',\n original: check.slice(comparison.span.start, comparison.span.end),\n perturbed: comparison.flipped,\n }\n }\n const span = lastStandaloneNumber(check)\n if (span !== null) return offByOne(check, expect, 'check', check, span)\n }\n return null\n}\n\nexport interface PerturbedPlant {\n plant: Plant\n /** The perturbed evidence to write into the item the grader is handed. */\n evidence: PlantEvidence\n field: PerturbedField\n how: PerturbationKind\n original: string\n perturbed: string\n}\n\n/**\n * Derive a reject-direction plant from a claim a grader verified, by perturbing\n * one value.\n *\n * {@link definePlant} takes a {@link GoldenItem} and never authors a wrong item\n * from a right one, so until now every caller hand-rolled the perturbation.\n * This is that step, done once and the same way every time: the claim's\n * evidence is altered by {@link perturbEvidence}, the result is a `wrong-value`\n * plant the grader owes a `reject`, and the record itself is built by\n * `definePlant` so every refusal there still applies — in particular the one\n * that catches an `expectedVerdict` its `humanScore` contradicts.\n *\n * Returns null when nothing in the evidence can be perturbed. That is not a\n * failure: a claim with no executable evidence cannot be made wrong in a way a\n * grader could execute, and seeding it would measure prose.\n *\n * Refuses an empty `id` or `itemId`. Both name the record — one in the manifest\n * and in `missedIds`, the other in the join with the results — and a miss\n * nobody can look up is not a measurement.\n */\nexport function plantByPerturbation(input: {\n id: string\n itemId: string\n evidence: PlantEvidence\n /** Score for the perturbed item. Must sit below the run's accept threshold. Default 0. */\n humanScore?: number\n group?: string\n}): PerturbedPlant | null {\n const { id, itemId, evidence, humanScore = 0, group } = input\n if (typeof id !== 'string' || id.trim() === '') {\n throw new ValidationError('plantByPerturbation: id must be a non-empty string')\n }\n if (typeof itemId !== 'string' || itemId.trim() === '') {\n throw new ValidationError(`plantByPerturbation: plant \"${id}\" has an empty itemId`)\n }\n const perturbation = perturbEvidence(evidence)\n if (perturbation === null) return null\n const plant = definePlant({\n id,\n kind: 'wrong-value',\n item: { itemId, humanScore, ...(group === undefined ? {} : { group }) },\n expectedVerdict: 'reject',\n })\n return {\n plant,\n evidence: perturbation.evidence,\n field: perturbation.field,\n how: perturbation.how,\n original: perturbation.original,\n perturbed: perturbation.perturbed,\n }\n}\n\nexport interface PlantManifest {\n /**\n * Digest over the seeded order, the plants, and the threshold. Publish it\n * before the grading run: a manifest edited afterwards to match the results\n * no longer matches its seal, and {@link catchRate} refuses it.\n */\n seal: LedgerHash\n /** The seed that fixed the mix order. */\n seed: number\n /** The grade at or above which the graded policy's own gate accepts an item. */\n acceptThreshold: number\n /** Every item id in the seeded set, in the order handed out. */\n itemIds: string[]\n /** The seeded plants. This is the answer key; keep it out of the graded workspace. */\n plants: Plant[]\n}\n\nexport interface SeededGradingSet {\n /**\n * The mixed set in seeded order. Operator-side: it still carries every\n * item's `humanScore`, so hand the graded policy the payload each `itemId`\n * names, never this array.\n */\n items: GoldenItem[]\n manifest: PlantManifest\n}\n\nexport interface SeedPlantsOptions {\n /**\n * Fixes the mix order. The same dataset, plants, threshold, and seed always\n * produce the same seeded order and the same seal.\n */\n seed?: number\n /**\n * The grade at or above which the graded policy's own gate accepts an item.\n * Supply the threshold your gate uses; the default suits a judge scoring in\n * [0, 1] with a pass at the midpoint.\n */\n acceptThreshold?: number\n}\n\n/**\n * Mix plants into a grading set and seal which items they are.\n *\n * Refusals: a duplicate id anywhere in the mixed set (the join is by id, so a\n * repeat makes one of the two unscoreable), a plant whose item id collides\n * with a dataset item (it would shadow real work and grade it as a plant), a\n * dataset item with no usable label, and a plant whose expectation the run's\n * `acceptThreshold` contradicts.\n */\nexport function seedPlants(\n dataset: readonly GoldenItem[],\n plants: readonly Plant[],\n options: SeedPlantsOptions = {},\n): SeededGradingSet {\n const seed = options.seed ?? 7\n const acceptThreshold = options.acceptThreshold ?? 0.5\n if (!Number.isFinite(seed)) {\n throw new ValidationError(`seedPlants: seed must be a finite number, got ${seed}`)\n }\n if (!Number.isFinite(acceptThreshold) || acceptThreshold <= 0 || acceptThreshold > 1) {\n throw new ValidationError(\n `seedPlants: acceptThreshold must be a finite number in (0, 1], got ${acceptThreshold}`,\n )\n }\n\n const datasetItems: GoldenItem[] = []\n const seen = new Set<string>()\n for (const item of dataset) {\n if (typeof item.itemId !== 'string' || item.itemId.trim() === '') {\n throw new ValidationError('seedPlants: a dataset item has an empty itemId')\n }\n if (!Number.isFinite(item.humanScore)) {\n throw new ValidationError(\n `seedPlants: dataset item \"${item.itemId}\" has a non-finite humanScore`,\n )\n }\n if (seen.has(item.itemId)) {\n throw new ValidationError(`seedPlants: duplicate dataset itemId \"${item.itemId}\"`)\n }\n seen.add(item.itemId)\n datasetItems.push({\n itemId: item.itemId,\n humanScore: item.humanScore,\n ...(item.group === undefined ? {} : { group: item.group }),\n })\n }\n\n const sealedPlants: Plant[] = []\n const plantIds = new Set<string>()\n for (const plant of plants) {\n const record = definePlant(plant)\n if (plantIds.has(record.id)) {\n throw new ValidationError(`seedPlants: duplicate plant id \"${record.id}\"`)\n }\n if (seen.has(record.item.itemId)) {\n throw new ValidationError(\n `seedPlants: plant \"${record.id}\" reuses itemId \"${record.item.itemId}\", which is already in the set`,\n )\n }\n const thresholdSays: PlantExpectation =\n record.item.humanScore >= acceptThreshold ? 'accept' : 'reject'\n if (thresholdSays !== record.expectedVerdict) {\n throw new ValidationError(\n `seedPlants: plant \"${record.id}\" expects the grader to ${record.expectedVerdict} it, but humanScore ${record.item.humanScore} is on the ${thresholdSays} side of acceptThreshold ${acceptThreshold}`,\n )\n }\n plantIds.add(record.id)\n seen.add(record.item.itemId)\n sealedPlants.push(record)\n }\n\n const items = shuffled(\n [...datasetItems, ...sealedPlants.map((plant) => plant.item)],\n mulberry32(seed),\n )\n const itemIds = items.map((item) => item.itemId)\n const manifest: PlantManifest = {\n seal: sealManifest({ seed, acceptThreshold, itemIds, plants: sealedPlants }),\n seed,\n acceptThreshold,\n itemIds,\n plants: sealedPlants,\n }\n return { items, manifest }\n}\n\n/**\n * Order by one independent uniform key per item, which is a uniform\n * permutation and a pure function of the seed. A comparator that returns a\n * fresh random sign instead is neither: it is not a consistent ordering, so\n * the permutation it produces is biased and depends on the sort algorithm.\n */\nfunction shuffled<T>(items: readonly T[], random: () => number): T[] {\n return items\n .map((item) => ({ item, key: random() }))\n .sort((left, right) => left.key - right.key)\n .map((entry) => entry.item)\n}\n\nfunction sealManifest(contents: Omit<PlantManifest, 'seal'>): LedgerHash {\n return hashCanonical({\n scheme: 'agent-eval.plant-manifest.v1',\n seed: contents.seed,\n acceptThreshold: contents.acceptThreshold,\n itemIds: contents.itemIds,\n plants: contents.plants,\n })\n}\n\n/**\n * One grader outcome for one item. `score: null` says the grader ran and\n * declined to decide — the check never tested the item's defect. Any\n * `CandidateScore` from a judge run is already a valid outcome.\n */\nexport interface PlantOutcome {\n itemId: string\n score: number | null\n}\n\n/**\n * `evaluated` — a rate stands. `incomplete` — a seeded id had no result.\n * `not_evaluated` — nothing was seeded, or nothing seeded was decided.\n */\nexport type CatchRateStatus = 'evaluated' | 'incomplete' | 'not_evaluated'\n\nexport interface PlantKindCounts {\n seeded: number\n caught: number\n missed: number\n indecisive: number\n /** caught / (caught + missed), or null when the report is not `evaluated`. */\n rate: number | null\n}\n\n/**\n * How the same grader treated the unseeded items of the same set. No labels\n * are needed to read it: a grader that refuses everything scores `rate` 1.0\n * on reject-plants, and a `rejectionRate` of 1.0 here is what separates that\n * reflex from discrimination.\n */\nexport interface UnseededRejection {\n n: number\n decided: number\n rejected: number\n /** rejected / decided, or null when nothing unseeded was decided. */\n rejectionRate: number | null\n}\n\nexport interface CatchRateReport {\n status: CatchRateStatus\n /** Why the status is not `evaluated`. Absent when it is. */\n reason?: string\n seeded: number\n caught: number\n missed: number\n /**\n * The grader returned a result and declined to decide. Counted apart: it\n * enters neither side of `rate`.\n */\n indecisive: number\n /** caught / (caught + missed), or null unless the status is `evaluated`. */\n rate: number | null\n /** One entry per kind actually seeded. A kind nobody seeded is absent, never zero. */\n byKind: Partial<Record<PlantKind, PlantKindCounts>>\n /** Plant ids the grader graded as the seed says it must not. */\n missedIds: string[]\n /** Plant ids with no result at all — the reason a status is `incomplete`. */\n missingIds: string[]\n unseeded: UnseededRejection\n}\n\n/**\n * Score a grading run against its sealed manifest.\n *\n * Refusals: a manifest whose contents no longer match its seal, a result for\n * an id the manifest never handed out, and a repeated result id. Each says\n * the results and the manifest describe different runs, and a rate computed\n * across two runs is a fabrication.\n */\nexport function catchRate(\n results: readonly PlantOutcome[],\n manifest: PlantManifest,\n): CatchRateReport {\n const expectedSeal = sealManifest({\n seed: manifest.seed,\n acceptThreshold: manifest.acceptThreshold,\n itemIds: manifest.itemIds,\n plants: manifest.plants,\n })\n if (expectedSeal !== manifest.seal) {\n throw new CaptureIntegrityError(\n `catchRate: manifest contents hash to ${expectedSeal} but the manifest carries seal ${manifest.seal} — the plant set changed after it was sealed`,\n )\n }\n\n const handedOut = new Set(manifest.itemIds)\n const scoreByItemId = new Map<string, number | null>()\n for (const result of results) {\n if (!handedOut.has(result.itemId)) {\n throw new ValidationError(\n `catchRate: result for \"${result.itemId}\", which this manifest never handed out`,\n )\n }\n if (scoreByItemId.has(result.itemId)) {\n throw new ValidationError(`catchRate: duplicate result for \"${result.itemId}\"`)\n }\n if (result.score !== null && !Number.isFinite(result.score)) {\n throw new ValidationError(\n `catchRate: result for \"${result.itemId}\" has score ${result.score}; expected a finite number or null`,\n )\n }\n scoreByItemId.set(result.itemId, result.score)\n }\n\n const byKind: Partial<Record<PlantKind, PlantKindCounts>> = {}\n const missedIds: string[] = []\n const missingIds: string[] = []\n let caught = 0\n let missed = 0\n let indecisive = 0\n\n for (const plant of manifest.plants) {\n let counts = byKind[plant.kind]\n if (counts === undefined) {\n counts = { seeded: 0, caught: 0, missed: 0, indecisive: 0, rate: null }\n byKind[plant.kind] = counts\n }\n counts.seeded += 1\n if (!scoreByItemId.has(plant.item.itemId)) {\n missingIds.push(plant.id)\n continue\n }\n const score = scoreByItemId.get(plant.item.itemId) ?? null\n if (score === null) {\n indecisive += 1\n counts.indecisive += 1\n continue\n }\n const graderSaid: PlantExpectation = score >= manifest.acceptThreshold ? 'accept' : 'reject'\n if (graderSaid === plant.expectedVerdict) {\n caught += 1\n counts.caught += 1\n } else {\n missed += 1\n counts.missed += 1\n missedIds.push(plant.id)\n }\n }\n\n const seeded = manifest.plants.length\n const decided = caught + missed\n const report: CatchRateReport = {\n status: 'evaluated',\n seeded,\n caught,\n missed,\n indecisive,\n rate: null,\n byKind,\n missedIds,\n missingIds,\n unseeded: unseededRejection(manifest, scoreByItemId),\n }\n\n if (seeded === 0) {\n return {\n ...report,\n status: 'not_evaluated',\n reason: 'no plant was seeded, so the grader was never asked a question it could fail',\n }\n }\n if (missingIds.length > 0) {\n return {\n ...report,\n status: 'incomplete',\n reason: `${missingIds.length} of ${seeded} seeded plants have no result: ${missingIds.join(', ')}`,\n }\n }\n if (decided === 0) {\n return {\n ...report,\n status: 'not_evaluated',\n reason: `all ${seeded} seeded plants are indecisive: no check tested the seeded defect`,\n }\n }\n\n for (const counts of Object.values(byKind)) {\n const kindDecided = counts.caught + counts.missed\n counts.rate = kindDecided === 0 ? null : counts.caught / kindDecided\n }\n report.rate = caught / decided\n return report\n}\n\nfunction unseededRejection(\n manifest: PlantManifest,\n scoreByItemId: ReadonlyMap<string, number | null>,\n): UnseededRejection {\n const plantItemIds = new Set(manifest.plants.map((plant) => plant.item.itemId))\n let n = 0\n let decided = 0\n let rejected = 0\n for (const itemId of manifest.itemIds) {\n if (plantItemIds.has(itemId)) continue\n n += 1\n const score = scoreByItemId.get(itemId)\n if (score === undefined || score === null) continue\n decided += 1\n if (score < manifest.acceptThreshold) rejected += 1\n }\n return { n, decided, rejected, rejectionRate: decided === 0 ? null : rejected / decided }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyEA,eAAsB,iBACpB,YACA,cACA,aACA,oBACA,UAAmC,CAAC,GACH;CACjC,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,aAAa,QAAQ,uBAAuB;CAClD,MAAM,OAAO,QAAQ;CACrB,2BAA2B,WAAW,YAAY,IAAI;CACtD,2BACE,YAAY,KAAK,WAAW,OAAO,EAAE,GACrC,aACF;CACA,2BAA2B,oBAAoB,gBAAgB;CAC/D,MAAM,SAAS,QAAQ,mBAAmB;CAC1C,IAAI,SAAS,KAAK,OAAO,MAAM,MAAM,GACnC,MAAM,IAAI,MAAM,qCAAqC;CAEvD,MAAM,aAAa,YAAY,KAAK,YAAY;EAC9C,GAAG;EACH,SAAS,OAAO,WAAW,mBAAmB,OAAO,EAAE;CACzD,EAAE;CACF,MAAM,cAAc,CAAC,GAAG,kBAAkB;CAC1C,MAAM,OAAO,MAAM,WAAW,SAAS;CACvC,2BACE,KAAK,KAAK,QAAQ,IAAI,KAAK,GAC3B,OACF;CACA,MAAM,WAAW,MAAM,aAAa,KAAK,QAAQ,aAAa;CAC9D,MAAM,gCAAgB,IAAI,IAAiC;CAC3D,KAAK,MAAM,KAAK,UAAU;EACxB,MAAM,MAAM,cAAc,IAAI,EAAE,KAAK,KAAK,CAAC;EAC3C,IAAI,KAAK,CAAC;EACV,cAAc,IAAI,EAAE,OAAO,GAAG;CAChC;CAEA,MAAM,QAA0F,CAAC;CACjG,KAAK,MAAM,MAAM,YACf,KAAK,MAAM,MAAM,aACf,MAAM,KAAK;EAAE,YAAY,GAAG;EAAI,eAAe;EAAI,IAAI,C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;CAC9E,IAAI,IAAI;CACR,IAAI,UAAU;CACd,IAAI,WAAW;CACf,KAAK,MAAM,UAAU,SAAS,SAAS;EACrC,IAAI,aAAa,IAAI,MAAM,GAAG;EAC9B,KAAK;EACL,MAAM,QAAQ,cAAc,IAAI,MAAM;EACtC,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAC3C,WAAW;EACX,IAAI,QAAQ,SAAS,iBAAiB,YAAY;CACpD;CACA,OAAO;EAAE;EAAG;EAAS;EAAU,eAAe,YAAY,IAAI,OAAO,WAAW;CAAQ;AAC1F"}
@@ -1,4 +1,4 @@
1
- //#region src/metrics.ts
1
+ // src/metrics.ts
2
2
  /** Per-1K token pricing for exact model ids. */
3
3
  const MODEL_PRICING = {
4
4
  "gpt-4o": {
@@ -142,7 +142,6 @@ function estimateCost(inputTokens, outputTokens, model) {
142
142
  }
143
143
  return inputTokens / 1e3 * pricing.input + outputTokens / 1e3 * pricing.output;
144
144
  }
145
- //#endregion
146
145
  export { resolveModelPricing as a, isModelPriced as i, estimateCost as n, estimateTokens as r, MODEL_PRICING as t };
147
146
 
148
- //# sourceMappingURL=metrics-BKaPBtIG.js.map
147
+ //# sourceMappingURL=metrics-DNCAUtuB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metrics-BKaPBtIG.js","names":[],"sources":["../src/metrics.ts"],"sourcesContent":["interface TokenPrice {\n input: number\n output: number\n}\n\n/** Per-1K token pricing for exact model ids. */\nexport const MODEL_PRICING: Record<string, TokenPrice> = {\n 'gpt-4o': { input: 0.0025, output: 0.01 },\n 'gpt-4o-mini': { input: 0.00015, output: 0.0006 },\n 'gpt-4-turbo': { input: 0.01, output: 0.03 },\n 'claude-sonnet-4-20250514': { input: 0.003, output: 0.015 },\n 'claude-opus-4-20250514': { input: 0.015, output: 0.075 },\n 'claude-3-haiku-20240307': { input: 0.00025, output: 0.00125 },\n // Router response-header rates observed for the exact served model on\n // 2026-08-15. Keep this exact row ahead of the deliberately coarse family\n // fallback so glm-5.3 campaign costs are not understated by ~2.5x.\n 'glm-5.3': { input: 0.00168, output: 0.00528 },\n // Tangle Router's published rate (`GET /v1/models`) on 2026-10-09:\n // $0.10 / $0.50 per Mtok. Exact, because the coarse gpt-5 family row would\n // overstate it 12x on input and 20x on output.\n 'gpt-6-luna': { input: 0.0001, output: 0.0005 },\n}\n\n/** Family-level pricing fallbacks (per-1K), matched against a normalized id\n * after exact lookup misses. Ordered — first match wins. Covers the model\n * ids actually used through the Tangle router + cli-bridge harnesses\n * (`claude-code/sonnet`, `opencode/zai-coding-plan/glm-5.1`,\n * `kimi-code/kimi-k2.6`, `deepseek-v4-pro`, `anthropic/claude-sonnet-4-6`, …),\n * none of which appear in the exact table above — without this they priced\n * to a silent $0, blanking every cost/Pareto axis downstream. */\nconst FAMILY_PRICING: Array<[RegExp, TokenPrice]> = [\n // OpenRouter stealth previews (`stealth/union-alpha`, …) bill $0 during\n // their preview window. A real zero row lets the budget ledger admit them;\n // an unpriced id is refused before the first call.\n [/^stealth\\//, { input: 0, output: 0 }],\n [/claude.*opus/, { input: 0.015, output: 0.075 }],\n [/claude.*haiku/, { input: 0.0008, output: 0.004 }],\n [/claude.*sonnet|claude-code|claude-sonnet/, { input: 0.003, output: 0.015 }],\n [/gpt-4o-mini/, { input: 0.00015, output: 0.0006 }],\n [/gpt-5|gpt-4\\.1|o[134]\\b/, { input: 0.00125, output: 0.01 }],\n [/gpt-4o|gpt-4/, { input: 0.0025, output: 0.01 }],\n [/deepseek/, { input: 0.0003, output: 0.0011 }],\n [/glm|zhipu|zai/, { input: 0.0006, output: 0.0022 }],\n [/kimi|moonshot/, { input: 0.0006, output: 0.0025 }],\n [/qwen/, { input: 0.0004, output: 0.0012 }],\n [/gemini.*flash/, { input: 0.0001, output: 0.0004 }],\n [/gemini/, { input: 0.00125, output: 0.005 }],\n [/llama/, { input: 0.0002, output: 0.0006 }],\n]\n\n/** Normalize a model id for pricing: drop a `@snapshot` suffix, lowercase,\n * and return both the complete harness/provider-prefixed id and its final\n * served-model segment (`opencode/zai-coding-plan/glm-5.3` → full id plus\n * `glm-5.3`). Exact rows are checked against both before family fallback. */\nfunction normalizedModelIds(model: string): string[] {\n const id = (model.split('@')[0] ?? model).trim().toLowerCase()\n const finalSegment = id.slice(id.lastIndexOf('/') + 1)\n return finalSegment === id ? [id] : [id, finalSegment]\n}\n\n/** Resolve pricing for a model id: exact table, then family fallback.\n * Returns null when the id matches nothing (caller decides — never a\n * silent-zero masquerading as a real $0 cost). */\nexport function resolveModelPricing(model: string): TokenPrice | null {\n if (MODEL_PRICING[model]) return MODEL_PRICING[model]\n const ids = normalizedModelIds(model)\n for (const id of ids) {\n if (MODEL_PRICING[id]) return MODEL_PRICING[id]\n }\n for (const [pattern, price] of FAMILY_PRICING) {\n if (ids.some((id) => pattern.test(id))) return price\n }\n return null\n}\n\n/** True when `model` has known pricing (exact or family). Lets cost-aware\n * callers distinguish a real $0 from an unpriced model. */\nexport function isModelPriced(model: string): boolean {\n return resolveModelPricing(model) !== null\n}\n\nconst warnedUnpricedModels = new Set<string>()\n\n/** Estimate token count from string length (chars / 4 approximation) */\nexport function estimateTokens(text: string): number {\n return Math.ceil(text.length / 4)\n}\n\n/** Calculate cost in USD from token counts and model. Unknown models warn\n * once (not a silent zero) and return 0 so callers that ignore pricing keep\n * working; cost-sensitive callers should gate on {@link isModelPriced}. */\nexport function estimateCost(inputTokens: number, outputTokens: number, model: string): number {\n const pricing = resolveModelPricing(model)\n if (!pricing) {\n if (!warnedUnpricedModels.has(model)) {\n warnedUnpricedModels.add(model)\n console.warn(\n `estimateCost: no pricing for model \"${model}\" — returning 0; add it to ` +\n 'MODEL_PRICING/FAMILY_PRICING (cost/Pareto axes will be blank until then)',\n )\n }\n return 0\n }\n return (inputTokens / 1000) * pricing.input + (outputTokens / 1000) * pricing.output\n}\n"],"mappings":";;AAMA,MAAa,gBAA4C;CACvD,UAAU;EAAE,OAAO;EAAQ,QAAQ;CAAK;CACxC,eAAe;EAAE,OAAO;EA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MAAA,CAAO,KAAK,CAAC,CAAC,YAAY;CAC7D,MAAM,eAAe,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;CACrD,OAAO,iBAAiB,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,YAAY;AACvD;;;;AAKA,SAAgB,oBAAoB,OAAkC;CACpE,IAAI,cAAc,QAAQ,OAAO,cAAc;CAC/C,MAAM,MAAM,mBAAmB,KAAK;CACpC,KAAK,MAAM,MAAM,KACf,IAAI,cAAc,KAAK,OAAO,cAAc;CAE9C,KAAK,MAAM,CAAC,SAAS,UAAU,gBAC7B,IAAI,IAAI,MAAM,OAAO,QAAQ,KAAK,EAAE,CAAC,GAAG,OAAO;CAEjD,OAAO;AACT;;;AAIA,SAAgB,cAAc,OAAwB;CACpD,OAAO,oBAAoB,KAAK,MAAM;AACxC;AAEA,MAAM,uCAAuB,IAAI,IAAY;;AAG7C,SAAgB,eAAe,MAAsB;CACnD,OAAO,KAAK,KAAK,KAAK,SAAS,CAAC;AAClC;;;;AAKA,SAAgB,aAAa,aAAqB,cAAsB,OAAuB;CAC7F,MAAM,UAAU,oBAAoB,KAAK;CACzC,IAAI,CAAC,SAAS;EACZ,IAAI,CAAC,qBAAqB,IAAI,KAAK,GAAG;GACpC,qBAAqB,IAAI,KAAK;GAC9B,QAAQ,KACN,uCAAuC,MAAM,oGAE/C;EACF;EACA,OAAO;CACT;CACA,OAAQ,cAAc,MAAQ,QAAQ,QAAS,eAAe,MAAQ,QAAQ;AAChF"}
1
+ {"version":3,"file":"metrics-DNCAUtuB.js","names":[],"sources":["../src/metrics.ts"],"sourcesContent":["interface TokenPrice {\n input: number\n output: number\n}\n\n/** Per-1K token pricing for exact model ids. */\nexport const MODEL_PRICING: Record<string, TokenPrice> = {\n 'gpt-4o': { input: 0.0025, output: 0.01 },\n 'gpt-4o-mini': { input: 0.00015, output: 0.0006 },\n 'gpt-4-turbo': { input: 0.01, output: 0.03 },\n 'claude-sonnet-4-20250514': { input: 0.003, output: 0.015 },\n 'claude-opus-4-20250514': { input: 0.015, output: 0.075 },\n 'claude-3-haiku-20240307': { input: 0.00025, output: 0.00125 },\n // Router response-header rates observed for the exact served model on\n // 2026-08-15. Keep this exact row ahead of the deliberately coarse family\n // fallback so glm-5.3 campaign costs are not understated by ~2.5x.\n 'glm-5.3': { input: 0.00168, output: 0.00528 },\n // Tangle Router's published rate (`GET /v1/models`) on 2026-10-09:\n // $0.10 / $0.50 per Mtok. Exact, because the coarse gpt-5 family row would\n // overstate it 12x on input and 20x on output.\n 'gpt-6-luna': { input: 0.0001, output: 0.0005 },\n}\n\n/** Family-level pricing fallbacks (per-1K), matched against a normalized id\n * after exact lookup misses. Ordered — first match wins. Covers the model\n * ids actually used through the Tangle router + cli-bridge harnesses\n * (`claude-code/sonnet`, `opencode/zai-coding-plan/glm-5.1`,\n * `kimi-code/kimi-k2.6`, `deepseek-v4-pro`, `anthropic/claude-sonnet-4-6`, …),\n * none of which appear in the exact table above — without this they priced\n * to a silent $0, blanking every cost/Pareto axis downstream. */\nconst FAMILY_PRICING: Array<[RegExp, TokenPrice]> = [\n // OpenRouter stealth previews (`stealth/union-alpha`, …) bill $0 during\n // their preview window. A real zero row lets the budget ledger admit them;\n // an unpriced id is refused before the first call.\n [/^stealth\\//, { input: 0, output: 0 }],\n [/claude.*opus/, { input: 0.015, output: 0.075 }],\n [/claude.*haiku/, { input: 0.0008, output: 0.004 }],\n [/claude.*sonnet|claude-code|claude-sonnet/, { input: 0.003, output: 0.015 }],\n [/gpt-4o-mini/, { input: 0.00015, output: 0.0006 }],\n [/gpt-5|gpt-4\\.1|o[134]\\b/, { input: 0.00125, output: 0.01 }],\n [/gpt-4o|gpt-4/, { input: 0.0025, output: 0.01 }],\n [/deepseek/, { input: 0.0003, output: 0.0011 }],\n [/glm|zhipu|zai/, { input: 0.0006, output: 0.0022 }],\n [/kimi|moonshot/, { input: 0.0006, output: 0.0025 }],\n [/qwen/, { input: 0.0004, output: 0.0012 }],\n [/gemini.*flash/, { input: 0.0001, output: 0.0004 }],\n [/gemini/, { input: 0.00125, output: 0.005 }],\n [/llama/, { input: 0.0002, output: 0.0006 }],\n]\n\n/** Normalize a model id for pricing: drop a `@snapshot` suffix, lowercase,\n * and return both the complete harness/provider-prefixed id and its final\n * served-model segment (`opencode/zai-coding-plan/glm-5.3` → full id plus\n * `glm-5.3`). Exact rows are checked against both before family fallback. */\nfunction normalizedModelIds(model: string): string[] {\n const id = (model.split('@')[0] ?? model).trim().toLowerCase()\n const finalSegment = id.slice(id.lastIndexOf('/') + 1)\n return finalSegment === id ? [id] : [id, finalSegment]\n}\n\n/** Resolve pricing for a model id: exact table, then family fallback.\n * Returns null when the id matches nothing (caller decides — never a\n * silent-zero masquerading as a real $0 cost). */\nexport function resolveModelPricing(model: string): TokenPrice | null {\n if (MODEL_PRICING[model]) return MODEL_PRICING[model]\n const ids = normalizedModelIds(model)\n for (const id of ids) {\n if (MODEL_PRICING[id]) return MODEL_PRICING[id]\n }\n for (const [pattern, price] of FAMILY_PRICING) {\n if (ids.some((id) => pattern.test(id))) return price\n }\n return null\n}\n\n/** True when `model` has known pricing (exact or family). Lets cost-aware\n * callers distinguish a real $0 from an unpriced model. */\nexport function isModelPriced(model: string): boolean {\n return resolveModelPricing(model) !== null\n}\n\nconst warnedUnpricedModels = new Set<string>()\n\n/** Estimate token count from string length (chars / 4 approximation) */\nexport function estimateTokens(text: string): number {\n return Math.ceil(text.length / 4)\n}\n\n/** Calculate cost in USD from token counts and model. Unknown models warn\n * once (not a silent zero) and return 0 so callers that ignore pricing keep\n * working; cost-sensitive callers should gate on {@link isModelPriced}. */\nexport function estimateCost(inputTokens: number, outputTokens: number, model: string): number {\n const pricing = resolveModelPricing(model)\n if (!pricing) {\n if (!warnedUnpricedModels.has(model)) {\n warnedUnpricedModels.add(model)\n console.warn(\n `estimateCost: no pricing for model \"${model}\" — returning 0; add it to ` +\n 'MODEL_PRICING/FAMILY_PRICING (cost/Pareto axes will be blank until then)',\n )\n }\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AAM,CAAC;CAC5C,CAAC,SAAS;EAAE,OAAO;EAAQ,QAAQ;CAAO,CAAC;AAC7C;;;;;AAMA,SAAS,mBAAmB,OAAyB;CACnD,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,MAAA,CAAO,KAAK,CAAC,CAAC,YAAY;CAC7D,MAAM,eAAe,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;CACrD,OAAO,iBAAiB,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,YAAY;AACvD;;;;AAKA,SAAgB,oBAAoB,OAAkC;CACpE,IAAI,cAAc,QAAQ,OAAO,cAAc;CAC/C,MAAM,MAAM,mBAAmB,KAAK;CACpC,KAAK,MAAM,MAAM,KACf,IAAI,cAAc,KAAK,OAAO,cAAc;CAE9C,KAAK,MAAM,CAAC,SAAS,UAAU,gBAC7B,IAAI,IAAI,MAAM,OAAO,QAAQ,KAAK,EAAE,CAAC,GAAG,OAAO;CAEjD,OAAO;AACT;;;AAIA,SAAgB,cAAc,OAAwB;CACpD,OAAO,oBAAoB,KAAK,MAAM;AACxC;AAEA,MAAM,uCAAuB,IAAI,IAAY;;AAG7C,SAAgB,eAAe,MAAsB;CACnD,OAAO,KAAK,KAAK,KAAK,SAAS,CAAC;AAClC;;;;AAKA,SAAgB,aAAa,aAAqB,cAAsB,OAAuB;CAC7F,MAAM,UAAU,oBAAoB,KAAK;CACzC,IAAI,CAAC,SAAS;EACZ,IAAI,CAAC,qBAAqB,IAAI,KAAK,GAAG;GACpC,qBAAqB,IAAI,KAAK;GAC9B,QAAQ,KACN,uCAAuC,MAAM,oGAE/C;EACF;EACA,OAAO;CACT;CACA,OAAQ,cAAc,MAAQ,QAAQ,QAAS,eAAe,MAAQ,QAAQ;AAChF"}
@@ -1,9 +1,9 @@
1
- import { s as ValidationError } from "./errors-BcOs5MKW.js";
2
- import { a as scoreOrigin, i as rolloutRewardFields } from "./reward-nw2xZGZG.js";
3
- import { o as runTaskScore } from "./run-record-DhEJgoPz.js";
4
- import { t as buildTrajectory } from "./trajectory-D_7rLrvE.js";
5
- import { a as assertMinted, r as ROLLOUT_SCHEMA } from "./schema-CvhfLjtZ.js";
6
- //#region src/rollout/mint.ts
1
+ import { s as ValidationError } from "./errors-DeEEV9Vx.js";
2
+ import { a as scoreOrigin, i as rolloutRewardFields } from "./reward-P0VD_Aft.js";
3
+ import { o as runTaskScore } from "./run-record-DEjx43cI.js";
4
+ import { t as buildTrajectory } from "./trajectory-O3GDHmev.js";
5
+ import { a as assertMinted, r as ROLLOUT_SCHEMA } from "./schema-YUIXT8iW.js";
6
+ // src/rollout/mint.ts
7
7
  /**
8
8
  * Rollout minting — `tangle.rollout.v1` lines joined from the records the
9
9
  * substrate ALREADY keeps. There is no separate rollout store: a rollout
@@ -398,7 +398,6 @@ async function mintRolloutRows(records, store, options = {}) {
398
398
  missingTraces
399
399
  };
400
400
  }
401
- //#endregion
402
401
  export { unmintableReasons as n, mintRolloutRows as t };
403
402
 
404
- //# sourceMappingURL=mint-CbdwjTPW.js.map
403
+ //# sourceMappingURL=mint-D9ZysYtY.js.map