@tangle-network/agent-eval 2.0.5 → 2.0.9

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 (309) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-CcOq7bOO.d.ts → agent-profile-ORN4aArD.d.ts} +5 -5
  4. package/dist/{agent-profile-CcOq7bOO.d.ts.map → agent-profile-ORN4aArD.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +15 -15
  6. package/dist/analyst/index.js +18 -14
  7. package/dist/analyst/index.js.map +1 -1
  8. package/dist/{analyze-runs-C_9cXPZn.js → analyze-runs-CE_5VKh2.js} +6 -5
  9. package/dist/{analyze-runs-C_9cXPZn.js.map → analyze-runs-CE_5VKh2.js.map} +1 -1
  10. package/dist/analyze-runs-DT693FJ7.d.ts +65 -0
  11. package/dist/analyze-runs-DT693FJ7.d.ts.map +1 -0
  12. package/dist/app-grade/index.d.ts +4 -4
  13. package/dist/app-grade/index.js +1 -1
  14. package/dist/{benchmark-command-MfXRocwZ.js → benchmark-command-DLg8E4y8.js} +16 -9
  15. package/dist/benchmark-command-DLg8E4y8.js.map +1 -0
  16. package/dist/benchmarks/index.d.ts +4 -4
  17. package/dist/benchmarks/index.js +4 -4
  18. package/dist/builder-eval/index.js +2 -2
  19. package/dist/calibration-CrORXMWx.d.ts +128 -0
  20. package/dist/calibration-CrORXMWx.d.ts.map +1 -0
  21. package/dist/{calibration-Cfoup0xz.js → calibration-Dz8mQb5P.js} +2 -2
  22. package/dist/{calibration-Cfoup0xz.js.map → calibration-Dz8mQb5P.js.map} +1 -1
  23. package/dist/campaign/index.d.ts +8 -8
  24. package/dist/campaign/index.js +12 -11
  25. package/dist/{campaign-DfSWSreo.js → campaign-C_S3MOYa.js} +1589 -14
  26. package/dist/campaign-C_S3MOYa.js.map +1 -0
  27. package/dist/{campaign-evidence-D_oBFfLc.js → campaign-evidence-BTfzZo1u.js} +4 -4
  28. package/dist/{campaign-evidence-D_oBFfLc.js.map → campaign-evidence-BTfzZo1u.js.map} +1 -1
  29. package/dist/{campaign-evidence-BmMs8YJt.d.ts → campaign-evidence-CM4FBOkX.d.ts} +5 -5
  30. package/dist/{campaign-evidence-BmMs8YJt.d.ts.map → campaign-evidence-CM4FBOkX.d.ts.map} +1 -1
  31. package/dist/{cluster-Bj90LK-1.d.ts → chat-client-uQNXGuO4.d.ts} +3 -240
  32. package/dist/chat-client-uQNXGuO4.d.ts.map +1 -0
  33. package/dist/cli.js +6 -6
  34. package/dist/cluster-C-K0N2br.d.ts +241 -0
  35. package/dist/cluster-C-K0N2br.d.ts.map +1 -0
  36. package/dist/{cluster-bootstrap-DPzVy3_K.js → cluster-bootstrap-DXbnIdm8.js} +3 -2
  37. package/dist/{cluster-bootstrap-DPzVy3_K.js.map → cluster-bootstrap-DXbnIdm8.js.map} +1 -1
  38. package/dist/{completion-verifier-Cy38EpGE.d.ts → completion-verifier-C7wipJOK.d.ts} +2 -2
  39. package/dist/{completion-verifier-Cy38EpGE.d.ts.map → completion-verifier-C7wipJOK.d.ts.map} +1 -1
  40. package/dist/contract/index.d.ts +14 -12
  41. package/dist/contract/index.js +13 -11
  42. package/dist/contract/index.js.map +1 -1
  43. package/dist/{decision-point-C46p-p9v.js → decision-point-CfqtnGop.js} +3 -3
  44. package/dist/{decision-point-C46p-p9v.js.map → decision-point-CfqtnGop.js.map} +1 -1
  45. package/dist/{default-registry-CUuorCWZ.d.ts → default-registry-Bskl2HzV.d.ts} +6 -7
  46. package/dist/default-registry-Bskl2HzV.d.ts.map +1 -0
  47. package/dist/{default-registry-IkE3byrA.js → default-registry-kps1SOaD.js} +27 -15
  48. package/dist/default-registry-kps1SOaD.js.map +1 -0
  49. package/dist/define-agent-eval-Dnh4jXLX.js +96 -0
  50. package/dist/define-agent-eval-Dnh4jXLX.js.map +1 -0
  51. package/dist/define-agent-eval-tu3anVlk.d.ts +52 -0
  52. package/dist/define-agent-eval-tu3anVlk.d.ts.map +1 -0
  53. package/dist/diagnosis/index.d.ts +3 -3
  54. package/dist/diagnosis/index.js +1 -1
  55. package/dist/{dspy-rlm-engine-DE11iBcC.js → dspy-rlm-engine-DQbPdT_o.js} +8 -4
  56. package/dist/{dspy-rlm-engine-DE11iBcC.js.map → dspy-rlm-engine-DQbPdT_o.js.map} +1 -1
  57. package/dist/{emitter-BjW3NnX-.js → emitter-xN9wGTVw.js} +9 -2
  58. package/dist/{emitter-BjW3NnX-.js.map → emitter-xN9wGTVw.js.map} +1 -1
  59. package/dist/{eval-campaign-Cyk-tkLh.js → eval-campaign-DswSn7Gm.js} +3 -3
  60. package/dist/{eval-campaign-Cyk-tkLh.js.map → eval-campaign-DswSn7Gm.js.map} +1 -1
  61. package/dist/{evaluation-DfyLPVL1.d.ts → evaluation-C4-tf3Z_.d.ts} +4 -4
  62. package/dist/{evaluation-DfyLPVL1.d.ts.map → evaluation-C4-tf3Z_.d.ts.map} +1 -1
  63. package/dist/evaluation.d.ts +1 -1
  64. package/dist/{exact-types-CiCXYhNK.d.ts → exact-types-CUsSMW3n.d.ts} +2 -2
  65. package/dist/{exact-types-CiCXYhNK.d.ts.map → exact-types-CUsSMW3n.d.ts.map} +1 -1
  66. package/dist/{execution-insight-wUNXxo5Y.d.ts → execution-insight-YihQrSqd.d.ts} +2 -2
  67. package/dist/{execution-insight-wUNXxo5Y.d.ts.map → execution-insight-YihQrSqd.d.ts.map} +1 -1
  68. package/dist/experiment/index.d.ts +5 -5
  69. package/dist/experiment/index.js +10 -184
  70. package/dist/experiment/index.js.map +1 -1
  71. package/dist/{external-optimizer-process-4QdcF7Kd.js → external-optimizer-process-CVi1x2nb.js} +2 -2
  72. package/dist/{external-optimizer-process-4QdcF7Kd.js.map → external-optimizer-process-CVi1x2nb.js.map} +1 -1
  73. package/dist/{external-optimizer-subprocess-BW0ZWUUr.js → external-optimizer-subprocess-mV-2swJI.js} +3 -357
  74. package/dist/external-optimizer-subprocess-mV-2swJI.js.map +1 -0
  75. package/dist/{feedback-trajectory-HJticMDz.d.ts → feedback-trajectory-D7hgL6y5.d.ts} +3 -3
  76. package/dist/{feedback-trajectory-HJticMDz.d.ts.map → feedback-trajectory-D7hgL6y5.d.ts.map} +1 -1
  77. package/dist/finding-scope-B_As3F_v.js +359 -0
  78. package/dist/finding-scope-B_As3F_v.js.map +1 -0
  79. package/dist/{findings-store-BxpV-hfH.js → findings-store-CZy5kUDo.js} +26 -19
  80. package/dist/findings-store-CZy5kUDo.js.map +1 -0
  81. package/dist/fuzz.js +1 -1
  82. package/dist/{harness-session-lines-CSxKR6no.js → harness-session-lines-CTh1-uOb.js} +21 -19
  83. package/dist/harness-session-lines-CTh1-uOb.js.map +1 -0
  84. package/dist/{index-Ucp54Pcl.d.ts → index--vDCtdaj.d.ts} +7 -8
  85. package/dist/index--vDCtdaj.d.ts.map +1 -0
  86. package/dist/{index-CKjqN9_U.d.ts → index-CIqYaySd.d.ts} +89 -3
  87. package/dist/index-CIqYaySd.d.ts.map +1 -0
  88. package/dist/{index-C6TG1LwA.d.ts → index-Cav3abKy.d.ts} +256 -131
  89. package/dist/index-Cav3abKy.d.ts.map +1 -0
  90. package/dist/{index-CR-guIiZ.d.ts → index-DmMHTDjT.d.ts} +10 -8
  91. package/dist/index-DmMHTDjT.d.ts.map +1 -0
  92. package/dist/{index-oX0TuJFv.d.ts → index-Er8TKQ3q.d.ts} +4 -4
  93. package/dist/{index-oX0TuJFv.d.ts.map → index-Er8TKQ3q.d.ts.map} +1 -1
  94. package/dist/{index-B_k8aY9k.d.ts → index-moZnazVj.d.ts} +22 -21
  95. package/dist/index-moZnazVj.d.ts.map +1 -0
  96. package/dist/index.d.ts +33 -30
  97. package/dist/index.js +27 -24
  98. package/dist/index.js.map +1 -1
  99. package/dist/{analyze-runs-Ke0WbAf6.d.ts → insight-report-DYofCMLx.d.ts} +4 -64
  100. package/dist/insight-report-DYofCMLx.d.ts.map +1 -0
  101. package/dist/{integrity-B9320cw1.d.ts → integrity-BJGstiCh.d.ts} +2 -2
  102. package/dist/{integrity-B9320cw1.d.ts.map → integrity-BJGstiCh.d.ts.map} +1 -1
  103. package/dist/{judge-gate-DqlzOBOm.js → judge-gate-DANg5FLq.js} +2 -2
  104. package/dist/{judge-gate-DqlzOBOm.js.map → judge-gate-DANg5FLq.js.map} +1 -1
  105. package/dist/{kind-factory-BDd4rhML.js → kind-factory-B-xCxG7p.js} +33 -5
  106. package/dist/kind-factory-B-xCxG7p.js.map +1 -0
  107. package/dist/llm-judge-DFoSy4Qn.js +476 -0
  108. package/dist/llm-judge-DFoSy4Qn.js.map +1 -0
  109. package/dist/{matrix-DlSrRl_v.d.ts → matrix-OgdWQBQa.d.ts} +6 -2
  110. package/dist/matrix-OgdWQBQa.d.ts.map +1 -0
  111. package/dist/measure-validity-plan-B1_qYlsk.d.ts +143 -0
  112. package/dist/measure-validity-plan-B1_qYlsk.d.ts.map +1 -0
  113. package/dist/measure-validity-plan-t0YQRzJQ.js +117 -0
  114. package/dist/measure-validity-plan-t0YQRzJQ.js.map +1 -0
  115. package/dist/meta-eval/index.d.ts +5 -3
  116. package/dist/meta-eval/index.js +664 -14
  117. package/dist/meta-eval/index.js.map +1 -1
  118. package/dist/multishot/golden/index.d.ts +1 -1
  119. package/dist/multishot/index.d.ts +458 -4
  120. package/dist/multishot/index.d.ts.map +1 -1
  121. package/dist/multishot/index.js +926 -47
  122. package/dist/multishot/index.js.map +1 -1
  123. package/dist/openapi.json +1 -1
  124. package/dist/{llm-judge-DQJTQx01.js → optimization-method-D4CpYsVA.js} +18 -482
  125. package/dist/optimization-method-D4CpYsVA.js.map +1 -0
  126. package/dist/{outcome-observations-DL3CC8w1.js → outcome-observations-DEh8_V_P.js} +31 -6
  127. package/dist/outcome-observations-DEh8_V_P.js.map +1 -0
  128. package/dist/outcome-store-CHtuvstd.d.ts +56 -0
  129. package/dist/outcome-store-CHtuvstd.d.ts.map +1 -0
  130. package/dist/{paired-arms-DZhH3FGu.js → paired-arms-B6EXnI47.js} +3 -2
  131. package/dist/{paired-arms-DZhH3FGu.js.map → paired-arms-B6EXnI47.js.map} +1 -1
  132. package/dist/{paired-promotion-decision-ChHBuuHV.d.ts → paired-promotion-decision-DuvRdnsW.d.ts} +2 -2
  133. package/dist/{paired-promotion-decision-ChHBuuHV.d.ts.map → paired-promotion-decision-DuvRdnsW.d.ts.map} +1 -1
  134. package/dist/{paired-promotion-decision-Dn3-jaq4.js → paired-promotion-decision-xYe881cD.js} +3 -2
  135. package/dist/{paired-promotion-decision-Dn3-jaq4.js.map → paired-promotion-decision-xYe881cD.js.map} +1 -1
  136. package/dist/{paired-promotion-power-BlzXdgMD.js → paired-promotion-power-DirShsIs.js} +3 -3
  137. package/dist/{paired-promotion-power-BlzXdgMD.js.map → paired-promotion-power-DirShsIs.js.map} +1 -1
  138. package/dist/paired-tests-CXcD_B80.js +688 -0
  139. package/dist/paired-tests-CXcD_B80.js.map +1 -0
  140. package/dist/pareto-DIVE5D0T.js +81 -0
  141. package/dist/pareto-DIVE5D0T.js.map +1 -0
  142. package/dist/pipelines/index.d.ts +2 -1
  143. package/dist/pipelines/index.d.ts.map +1 -1
  144. package/dist/pipelines/index.js +1 -1
  145. package/dist/{sequential-BphITa5b.js → power-DTg6u30w.js} +181 -4
  146. package/dist/power-DTg6u30w.js.map +1 -0
  147. package/dist/{prime-protocol-iEaSEGZB.d.ts → prime-protocol-Jm2pWh--.d.ts} +2 -2
  148. package/dist/{prime-protocol-iEaSEGZB.d.ts.map → prime-protocol-Jm2pWh--.d.ts.map} +1 -1
  149. package/dist/{promotion-gate-CGkxh36r.d.ts → promotion-gate-BXgcORnM.d.ts} +2 -2
  150. package/dist/{promotion-gate-CGkxh36r.d.ts.map → promotion-gate-BXgcORnM.d.ts.map} +1 -1
  151. package/dist/{promotion-policy-CxDIh-9p.js → promotion-policy-Z5E-C32U.js} +4 -4
  152. package/dist/{promotion-policy-CxDIh-9p.js.map → promotion-policy-Z5E-C32U.js.map} +1 -1
  153. package/dist/{proposal-findings-DedMih-u.js → proposal-findings-CfRFCFXS.js} +2 -2
  154. package/dist/{proposal-findings-DedMih-u.js.map → proposal-findings-CfRFCFXS.js.map} +1 -1
  155. package/dist/{registry-V8o2kZtn.d.ts → registry-DEZDECdr.d.ts} +4 -4
  156. package/dist/{registry-V8o2kZtn.d.ts.map → registry-DEZDECdr.d.ts.map} +1 -1
  157. package/dist/{release-confidence-BLHOMK5Q.js → release-confidence-Cndq1hwi.js} +2 -2
  158. package/dist/{release-confidence-BLHOMK5Q.js.map → release-confidence-Cndq1hwi.js.map} +1 -1
  159. package/dist/reporting.d.ts +5 -5
  160. package/dist/reporting.js +6 -5
  161. package/dist/reporting.js.map +1 -1
  162. package/dist/{research-report-D6XIK0eK.d.ts → research-report-CIgUe1lv.d.ts} +2 -2
  163. package/dist/{research-report-D6XIK0eK.d.ts.map → research-report-CIgUe1lv.d.ts.map} +1 -1
  164. package/dist/{researcher---DhHG4J.d.ts → researcher-CY_byuZl.d.ts} +4 -4
  165. package/dist/{researcher---DhHG4J.d.ts.map → researcher-CY_byuZl.d.ts.map} +1 -1
  166. package/dist/{reward-hacking-DKAflk2c.js → reward-hacking-DMTm1OBd.js} +2 -2
  167. package/dist/{reward-hacking-DKAflk2c.js.map → reward-hacking-DMTm1OBd.js.map} +1 -1
  168. package/dist/rl.d.ts +9 -8
  169. package/dist/rl.d.ts.map +1 -1
  170. package/dist/rl.js +11 -10
  171. package/dist/rl.js.map +1 -1
  172. package/dist/rollout/index.d.ts +2 -2
  173. package/dist/rollout/index.js +2 -2
  174. package/dist/{rollout-DVwpCHBC.js → rollout-B_lrpd9a.js} +2 -2
  175. package/dist/{rollout-DVwpCHBC.js.map → rollout-B_lrpd9a.js.map} +1 -1
  176. package/dist/{rubric-predictive-validity--6z0q8s6.js → rubric-predictive-validity-BXJ92Jp_.js} +3 -9
  177. package/dist/rubric-predictive-validity-BXJ92Jp_.js.map +1 -0
  178. package/dist/{rubric-predictive-validity-C9wc7f_D.d.ts → rubric-predictive-validity-DH94_0Q1.d.ts} +3 -56
  179. package/dist/rubric-predictive-validity-DH94_0Q1.d.ts.map +1 -0
  180. package/dist/{run-improvement-loop-CtLyPb5-.d.ts → run-improvement-loop-BaPDVbW8.d.ts} +384 -11
  181. package/dist/run-improvement-loop-BaPDVbW8.d.ts.map +1 -0
  182. package/dist/{run-record-Bqg0NZ_e.js → run-record-CuO8ErrI.js} +3 -2
  183. package/dist/run-record-CuO8ErrI.js.map +1 -0
  184. package/dist/{runtime-rollouts-DdUijr_t.js → runtime-rollouts-Vv-BAqmq.js} +3 -3
  185. package/dist/{runtime-rollouts-DdUijr_t.js.map → runtime-rollouts-Vv-BAqmq.js.map} +1 -1
  186. package/dist/search/index.d.ts +2 -2
  187. package/dist/search/index.js +2 -2
  188. package/dist/{search-kernel-DXA1EhnN.d.ts → search-kernel-BzTeb89p.d.ts} +3 -3
  189. package/dist/{search-kernel-DXA1EhnN.d.ts.map → search-kernel-BzTeb89p.d.ts.map} +1 -1
  190. package/dist/{pareto-Bg75Gajo.js → search-kernel-DOPW08Hx.js} +6 -88
  191. package/dist/search-kernel-DOPW08Hx.js.map +1 -0
  192. package/dist/{search-summary-B1x1Vmzh.js → search-summary-CYOHZAAy.js} +4 -4
  193. package/dist/{search-summary-B1x1Vmzh.js.map → search-summary-CYOHZAAy.js.map} +1 -1
  194. package/dist/{define-agent-eval-B6uE3gNu.js → self-improve-CIFqccHV.js} +8 -97
  195. package/dist/self-improve-CIFqccHV.js.map +1 -0
  196. package/dist/{define-agent-eval-D17XsdAt.d.ts → self-improve-DY8ZY4lY.d.ts} +8 -54
  197. package/dist/self-improve-DY8ZY4lY.d.ts.map +1 -0
  198. package/dist/{sequential-BhbTSxpt.d.ts → sequential-B9iROM1S.d.ts} +2 -2
  199. package/dist/{sequential-BhbTSxpt.d.ts.map → sequential-B9iROM1S.d.ts.map} +1 -1
  200. package/dist/{sequential-ux_XrjBf.js → sequential-tZjGysXY.js} +3 -3
  201. package/dist/{sequential-ux_XrjBf.js.map → sequential-tZjGysXY.js.map} +1 -1
  202. package/dist/{skillopt-optimization-method-D_swD0Cy.js → skillopt-optimization-method-CbHBkopM.js} +9 -8
  203. package/dist/{skillopt-optimization-method-D_swD0Cy.js.map → skillopt-optimization-method-CbHBkopM.js.map} +1 -1
  204. package/dist/{statistical-heldout-CaS4T-43.js → statistical-heldout-C7Jjo5nP.js} +3 -3
  205. package/dist/{statistical-heldout-CaS4T-43.js.map → statistical-heldout-C7Jjo5nP.js.map} +1 -1
  206. package/dist/{statistics-DSidA5I2.js → statistics-BPl13X3G.js} +208 -700
  207. package/dist/statistics-BPl13X3G.js.map +1 -0
  208. package/dist/statistics.d.ts +3 -3
  209. package/dist/statistics.js +3 -2
  210. package/dist/{store-otlp-CR9fWum6.js → store-otlp-CdeW7NWq.js} +2 -2
  211. package/dist/{store-otlp-CR9fWum6.js.map → store-otlp-CdeW7NWq.js.map} +1 -1
  212. package/dist/{store-tool-spans-tkdUJWup.js → store-tool-spans-CVX-jfkk.js} +3 -3
  213. package/dist/{store-tool-spans-tkdUJWup.js.map → store-tool-spans-CVX-jfkk.js.map} +1 -1
  214. package/dist/{store-tool-spans-C47hUUVM.d.ts → store-tool-spans-Dq8r0PbJ.d.ts} +4 -5
  215. package/dist/store-tool-spans-Dq8r0PbJ.d.ts.map +1 -0
  216. package/dist/{summary-report-CI4J6gxU.js → summary-report-DzbnK81K.js} +15 -7
  217. package/dist/summary-report-DzbnK81K.js.map +1 -0
  218. package/dist/summary-report-figures-CJHygLgw.d.ts.map +1 -1
  219. package/dist/supervisor-run/index.d.ts +1 -1
  220. package/dist/supervisor-run/index.js +1 -1
  221. package/dist/{systemone-MXhFSYdy.d.ts → systemone-BuSZTI88.d.ts} +8 -7
  222. package/dist/systemone-BuSZTI88.d.ts.map +1 -0
  223. package/dist/{systemone-review-C9kbs3zD.d.ts → systemone-review-mlfxWdLz.d.ts} +2 -2
  224. package/dist/{systemone-review-C9kbs3zD.d.ts.map → systemone-review-mlfxWdLz.d.ts.map} +1 -1
  225. package/dist/systemone.d.ts +3 -3
  226. package/dist/systemone.js +1 -1
  227. package/dist/{tool-groups-BSd08M7B.d.ts → tool-groups-PNDX8fd-.d.ts} +2 -3
  228. package/dist/tool-groups-PNDX8fd-.d.ts.map +1 -0
  229. package/dist/{tool-waste-u7JJ_BlE.js → tool-waste-783VCo1y.js} +3 -2
  230. package/dist/{tool-waste-u7JJ_BlE.js.map → tool-waste-783VCo1y.js.map} +1 -1
  231. package/dist/tool-waste-B01AMpID.d.ts +121 -0
  232. package/dist/tool-waste-B01AMpID.d.ts.map +1 -0
  233. package/dist/{trace-questions-CJANeK9P.d.ts → trace-questions-DBtr4jWi.d.ts} +2 -3
  234. package/dist/trace-questions-DBtr4jWi.d.ts.map +1 -0
  235. package/dist/trace-repair/index.d.ts +1 -1
  236. package/dist/trace-repair/index.js +1 -1
  237. package/dist/traces.d.ts +4 -5
  238. package/dist/traces.d.ts.map +1 -1
  239. package/dist/traces.js +4 -4
  240. package/dist/trajectory-B3o6Ald_.d.ts +100 -0
  241. package/dist/trajectory-B3o6Ald_.d.ts.map +1 -0
  242. package/dist/trajectory-replay/index.js +1 -1
  243. package/dist/{tree-DQMlcNFI.js → tree-CtlQQL1w.js} +6 -4
  244. package/dist/{tree-DQMlcNFI.js.map → tree-CtlQQL1w.js.map} +1 -1
  245. package/dist/{types-DD1eUTLn.d.ts → types-BO948H-U.d.ts} +7 -4
  246. package/dist/{types-DD1eUTLn.d.ts.map → types-BO948H-U.d.ts.map} +1 -1
  247. package/dist/{types-AGUuvnae.d.ts → types-CKNAzCSA.d.ts} +158 -3
  248. package/dist/types-CKNAzCSA.d.ts.map +1 -0
  249. package/dist/{types-BLv2Ngla.d.ts → types-D-WF1KM3.d.ts} +2 -2
  250. package/dist/{types-BLv2Ngla.d.ts.map → types-D-WF1KM3.d.ts.map} +1 -1
  251. package/dist/types-DK4vNv5q.js.map +1 -1
  252. package/dist/{types-CE9JMZhk.d.ts → types-DbeIGi73.d.ts} +2 -2
  253. package/dist/{types-CE9JMZhk.d.ts.map → types-DbeIGi73.d.ts.map} +1 -1
  254. package/dist/types-_tlhWGUq.js.map +1 -1
  255. package/dist/wire/index.d.ts +4 -4
  256. package/dist/world/index.d.ts +529 -0
  257. package/dist/world/index.d.ts.map +1 -0
  258. package/dist/world/index.js +1356 -0
  259. package/dist/world/index.js.map +1 -0
  260. package/docs/campaign-proposers.md +7 -0
  261. package/docs/concepts.md +2 -0
  262. package/docs/design/statistics-decisions.md +31 -0
  263. package/docs/eval-surface-map.md +4 -1
  264. package/docs/feature-guide.md +2 -0
  265. package/docs/multi-turn-optimization.md +80 -0
  266. package/docs/outcome-validity.md +69 -0
  267. package/docs/public-api.md +86 -31
  268. package/docs/trace-analysis.md +1 -0
  269. package/docs/world.md +104 -0
  270. package/package.json +7 -2
  271. package/dist/analyze-runs-Ke0WbAf6.d.ts.map +0 -1
  272. package/dist/benchmark-command-MfXRocwZ.js.map +0 -1
  273. package/dist/campaign-DfSWSreo.js.map +0 -1
  274. package/dist/cluster-Bj90LK-1.d.ts.map +0 -1
  275. package/dist/default-registry-CUuorCWZ.d.ts.map +0 -1
  276. package/dist/default-registry-IkE3byrA.js.map +0 -1
  277. package/dist/define-agent-eval-B6uE3gNu.js.map +0 -1
  278. package/dist/define-agent-eval-D17XsdAt.d.ts.map +0 -1
  279. package/dist/engine-BZVXOc6n.d.ts +0 -152
  280. package/dist/engine-BZVXOc6n.d.ts.map +0 -1
  281. package/dist/external-optimizer-subprocess-BW0ZWUUr.js.map +0 -1
  282. package/dist/findings-store-BxpV-hfH.js.map +0 -1
  283. package/dist/harness-session-lines-CSxKR6no.js.map +0 -1
  284. package/dist/index-B_k8aY9k.d.ts.map +0 -1
  285. package/dist/index-C6TG1LwA.d.ts.map +0 -1
  286. package/dist/index-CKjqN9_U.d.ts.map +0 -1
  287. package/dist/index-CR-guIiZ.d.ts.map +0 -1
  288. package/dist/index-Ucp54Pcl.d.ts.map +0 -1
  289. package/dist/interval-CWyxqDpE.d.ts +0 -43
  290. package/dist/interval-CWyxqDpE.d.ts.map +0 -1
  291. package/dist/kind-factory-BDd4rhML.js.map +0 -1
  292. package/dist/llm-judge-DQJTQx01.js.map +0 -1
  293. package/dist/matrix-DlSrRl_v.d.ts.map +0 -1
  294. package/dist/outcome-observations-DL3CC8w1.js.map +0 -1
  295. package/dist/pareto-Bg75Gajo.js.map +0 -1
  296. package/dist/rubric-predictive-validity--6z0q8s6.js.map +0 -1
  297. package/dist/rubric-predictive-validity-C9wc7f_D.d.ts.map +0 -1
  298. package/dist/run-improvement-loop-CtLyPb5-.d.ts.map +0 -1
  299. package/dist/run-record-Bqg0NZ_e.js.map +0 -1
  300. package/dist/sequential-BphITa5b.js.map +0 -1
  301. package/dist/statistics-DSidA5I2.js.map +0 -1
  302. package/dist/store-tool-spans-C47hUUVM.d.ts.map +0 -1
  303. package/dist/summary-report-CI4J6gxU.js.map +0 -1
  304. package/dist/systemone-MXhFSYdy.d.ts.map +0 -1
  305. package/dist/tool-groups-BSd08M7B.d.ts.map +0 -1
  306. package/dist/tool-waste-CIhtU1ad.d.ts +0 -217
  307. package/dist/tool-waste-CIhtU1ad.d.ts.map +0 -1
  308. package/dist/trace-questions-CJANeK9P.d.ts.map +0 -1
  309. package/dist/types-AGUuvnae.d.ts.map +0 -1
@@ -1,107 +1,7 @@
1
1
  import { s as ValidationError } from "./errors-DeEEV9Vx.js";
2
2
  import { t as interpolatedQuantile } from "./quantile-CncXP-Ss.js";
3
+ import { A as regularizedIncompleteBeta, C as medianInPlace, D as studentTCdf, E as zQuantile, O as studentTQuantile, S as makeRng, T as symmetricTwoSampleSeed, b as assertFiniteSample, d as ranks, f as spearmanR, k as lnGamma, p as studentTCritical, u as pearsonR, w as seedFromData, x as binomialSignTwoSided } from "./paired-tests-CXcD_B80.js";
3
4
  import { t as mulberry32 } from "./random-DrzcgC7F.js";
4
- // src/math/special-functions.ts
5
- /** Lanczos approximation to ln Gamma(z). */
6
- function lnGamma(z) {
7
- const g = 7;
8
- const coefficients = [
9
- .9999999999998099,
10
- 676.5203681218851,
11
- -1259.1392167224028,
12
- 771.3234287776531,
13
- -176.6150291621406,
14
- 12.507343278686905,
15
- -.13857109526572012,
16
- 9984369578019572e-21,
17
- 1.5056327351493116e-7
18
- ];
19
- if (z < .5) return Math.log(Math.PI / Math.sin(Math.PI * z)) - lnGamma(1 - z);
20
- z -= 1;
21
- let x = coefficients[0];
22
- for (let i = 1; i < 9; i++) x += coefficients[i] / (z + i);
23
- const t = z + g + .5;
24
- return .5 * Math.log(2 * Math.PI) + (z + .5) * Math.log(t) - t + Math.log(x);
25
- }
26
- /**
27
- * Regularized incomplete beta function I_x(a, b).
28
- *
29
- * The Lentz continued fraction converges only for `x < (a+1)/(a+b+2)`; outside
30
- * that domain it must be reached through the symmetry `I_x(a,b) = 1 −
31
- * I_{1−x}(b,a)`. `studentTCdf` drives `x → 1` as `|t| → 0`, so the mirrored
32
- * branch is the one every near-null t-statistic takes.
33
- */
34
- function regularizedIncompleteBeta(x, a, b) {
35
- if (x <= 0) return 0;
36
- if (x >= 1) return 1;
37
- const logBeta = lnGamma(a) + lnGamma(b) - lnGamma(a + b);
38
- const front = Math.exp(Math.log(x) * a + Math.log(1 - x) * b - logBeta);
39
- if (x < (a + 1) / (a + b + 2)) return front * betaContinuedFraction(x, a, b) / a;
40
- return 1 - front * betaContinuedFraction(1 - x, b, a) / b;
41
- }
42
- /** Modified Lentz evaluation of the beta continued fraction at `x`. */
43
- function betaContinuedFraction(x, a, b) {
44
- const maxIterations = 300;
45
- const epsilon = 3e-15;
46
- let c = 1;
47
- let d = 1 - (a + b) * x / (a + 1);
48
- if (Math.abs(d) < 1e-30) d = 1e-30;
49
- d = 1 / d;
50
- let fraction = d;
51
- for (let m = 1; m <= maxIterations; m++) {
52
- const m2 = 2 * m;
53
- let numerator = m * (b - m) * x / ((a + m2 - 1) * (a + m2));
54
- d = 1 + numerator * d;
55
- if (Math.abs(d) < 1e-30) d = 1e-30;
56
- c = 1 + numerator / c;
57
- if (Math.abs(c) < 1e-30) c = 1e-30;
58
- d = 1 / d;
59
- fraction *= d * c;
60
- numerator = -((a + m) * (a + b + m) * x) / ((a + m2) * (a + m2 + 1));
61
- d = 1 + numerator * d;
62
- if (Math.abs(d) < 1e-30) d = 1e-30;
63
- c = 1 + numerator / c;
64
- if (Math.abs(c) < 1e-30) c = 1e-30;
65
- d = 1 / d;
66
- const delta = d * c;
67
- fraction *= delta;
68
- if (Math.abs(delta - 1) < epsilon) break;
69
- }
70
- return fraction;
71
- }
72
- // src/math/student-t.ts
73
- /**
74
- * Student-t CDF via the regularized incomplete beta function.
75
- */
76
- function studentTCdf(t, degreesOfFreedom) {
77
- if (degreesOfFreedom <= 0) return .5;
78
- const beta = regularizedIncompleteBeta(degreesOfFreedom / (degreesOfFreedom + t * t), degreesOfFreedom / 2, .5);
79
- return t >= 0 ? 1 - .5 * beta : .5 * beta;
80
- }
81
- /**
82
- * Inverse Student-t CDF, solved against {@link studentTCdf}.
83
- *
84
- * The CDF is monotone, so bracket expansion followed by bisection is stable
85
- * across fractional degrees of freedom and does not need a separate
86
- * approximation with a different error profile.
87
- */
88
- function studentTQuantile(probability, degreesOfFreedom) {
89
- if (!Number.isFinite(probability) || probability < 0 || probability > 1) throw new RangeError(`studentTQuantile: probability must be in [0,1], got ${probability}`);
90
- if (!Number.isFinite(degreesOfFreedom) || degreesOfFreedom <= 0) throw new RangeError(`studentTQuantile: degreesOfFreedom must be positive and finite, got ${degreesOfFreedom}`);
91
- if (probability === 0) return Number.NEGATIVE_INFINITY;
92
- if (probability === 1) return Number.POSITIVE_INFINITY;
93
- if (probability === .5) return 0;
94
- if (probability < .5) return -studentTQuantile(1 - probability, degreesOfFreedom);
95
- let low = 0;
96
- let high = 1;
97
- while (studentTCdf(high, degreesOfFreedom) < probability) high *= 2;
98
- for (let iteration = 0; iteration < 64; iteration++) {
99
- const middle = (low + high) / 2;
100
- if (studentTCdf(middle, degreesOfFreedom) < probability) low = middle;
101
- else high = middle;
102
- }
103
- return (low + high) / 2;
104
- }
105
5
  // src/statistics/cluster.ts
106
6
  const DEFAULT_BOOTSTRAP_SEED = 12648430;
107
7
  /** Percentile bootstrap; degenerate resamples are omitted, with NaN bounds if none remain. */
@@ -187,381 +87,6 @@ function placeboBand(history, options) {
187
87
  high: q025 === null ? null : delta - q025
188
88
  };
189
89
  }
190
- // src/statistics/internal.ts
191
- /**
192
- * Shared internals for the statistics modules. Nothing here is part of the
193
- * public statistics surface — `./index` does not re-export this module.
194
- */
195
- /** Every rank test refuses non-finite input. Beyond the arithmetic being
196
- * undefined, the tie-grouping scan compares values with `===`, and
197
- * `NaN === NaN` is false, so a NaN would leave the group boundary unable to
198
- * advance and spin the loop forever. */
199
- function assertFiniteSample(fn, label, xs) {
200
- for (let i = 0; i < xs.length; i++) if (!Number.isFinite(xs[i])) throw new ValidationError(`${fn}: ${label}[${i}] must be finite, got ${xs[i]}`);
201
- }
202
- /**
203
- * Two-sided exact p-value for b successes out of (b + c) Bernoulli(0.5) trials —
204
- * the exact-binomial core of {@link mcnemar}. `min(1, 2·P(X ≤ min(b,c)))`. No
205
- * discordant pairs ⇒ no evidence ⇒ p = 1. Summed in log space (lnGamma) so it
206
- * stays exact at large discordant counts without overflow.
207
- */
208
- function binomialSignTwoSided(b, c) {
209
- const nd = b + c;
210
- if (nd === 0) return 1;
211
- return Math.min(1, 2 * binomialHalfLowerTail(Math.min(b, c), nd));
212
- }
213
- /** P(X >= successes) for X ~ Binomial(n, 0.5). */
214
- function binomialHalfUpperTail(successes, n) {
215
- if (successes <= 0) return 1;
216
- if (successes > n) return 0;
217
- if (successes <= n / 2) return Math.max(0, 1 - binomialHalfLowerTail(successes - 1, n));
218
- return binomialHalfLowerTail(n - successes, n);
219
- }
220
- /** P(X <= maxSuccesses) for X ~ Binomial(n, 0.5), accumulated in log space. */
221
- function binomialHalfLowerTail(maxSuccesses, n) {
222
- if (maxSuccesses < 0) return 0;
223
- if (maxSuccesses >= n) return 1;
224
- if (maxSuccesses === 0) return 2 ** -n;
225
- const logHalfN = n * Math.log(.5);
226
- let logTail = Number.NEGATIVE_INFINITY;
227
- for (let i = 0; i <= maxSuccesses; i++) {
228
- const logChoose = lnGamma(n + 1) - lnGamma(i + 1) - lnGamma(n - i + 1);
229
- logTail = logAddExp(logTail, logChoose + logHalfN);
230
- }
231
- return Math.min(1, Math.exp(logTail));
232
- }
233
- function logAddExp(a, b) {
234
- if (a === Number.NEGATIVE_INFINITY) return b;
235
- if (b === Number.NEGATIVE_INFINITY) return a;
236
- const max = Math.max(a, b);
237
- return max + Math.log1p(Math.exp(Math.min(a, b) - max));
238
- }
239
- /** Standard-normal inverse CDF (Acklam approximation). */
240
- function zQuantile(p) {
241
- if (p <= 0 || p >= 1) {
242
- if (p === 0) return -Infinity;
243
- if (p === 1) return Infinity;
244
- return NaN;
245
- }
246
- const a = [
247
- -39.69683028665376,
248
- 220.9460984245205,
249
- -275.9285104469687,
250
- 138.357751867269,
251
- -30.66479806614716,
252
- 2.506628277459239
253
- ];
254
- const b = [
255
- -54.47609879822406,
256
- 161.5858368580409,
257
- -155.6989798598866,
258
- 66.80131188771972,
259
- -13.28068155288572
260
- ];
261
- const c = [
262
- -.007784894002430293,
263
- -.3223964580411365,
264
- -2.400758277161838,
265
- -2.549732539343734,
266
- 4.374664141464968,
267
- 2.938163982698783
268
- ];
269
- const d = [
270
- .007784695709041462,
271
- .3224671290700398,
272
- 2.445134137142996,
273
- 3.754408661907416
274
- ];
275
- const pLow = .02425;
276
- const pHigh = .97575;
277
- let q;
278
- let r;
279
- if (p < pLow) {
280
- q = Math.sqrt(-2 * Math.log(p));
281
- return (((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);
282
- }
283
- if (p <= pHigh) {
284
- q = p - .5;
285
- r = q * q;
286
- return (((((a[0] * r + a[1]) * r + a[2]) * r + a[3]) * r + a[4]) * r + a[5]) * q / (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r + b[4]) * r + 1);
287
- }
288
- q = Math.sqrt(-2 * Math.log(1 - p));
289
- return -(((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);
290
- }
291
- function medianInPlace(xs) {
292
- if (xs.length === 0) return 0;
293
- xs.sort((a, b) => a - b);
294
- return interpolatedQuantile(xs, .5);
295
- }
296
- /**
297
- * PRNG for every resampling path in this module.
298
- *
299
- * With no caller seed the seed is DERIVED FROM THE DATA rather than taken from
300
- * `Math.random`, so re-running the same input reproduces the same interval —
301
- * a gate verdict that cannot be re-derived is not evidence. Distinct data
302
- * still gets a distinct stream. Same pattern as `promotion-gate.ts`.
303
- */
304
- function makeRng(seed, ...series) {
305
- return mulberry32(seed ?? seedFromData(series));
306
- }
307
- /** FNV-1a over the IEEE-754 bytes of every observation. */
308
- function seedFromData(series) {
309
- const view = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
310
- let hash = 2166136261;
311
- for (const xs of series) {
312
- for (const x of xs) {
313
- view.setFloat64(0, x);
314
- for (let byte = 0; byte < 8; byte++) hash = Math.imul(hash ^ view.getUint8(byte), 16777619);
315
- }
316
- hash = Math.imul(hash ^ 255, 16777619);
317
- }
318
- return hash | 0;
319
- }
320
- /** Order-independent seed for a symmetric two-sample statistic. */
321
- function symmetricTwoSampleSeed(a, b) {
322
- const sortedA = [...a].sort((left, right) => left - right);
323
- const sortedB = [...b].sort((left, right) => left - right);
324
- const forward = seedFromData([sortedA, sortedB]) >>> 0;
325
- const reversed = seedFromData([sortedB, sortedA]) >>> 0;
326
- return Math.min(forward, reversed);
327
- }
328
- // src/statistics/mean.ts
329
- /** Arithmetic mean. An empty input has no mean and returns NaN. */
330
- function mean(values) {
331
- return values.reduce((sum, value) => sum + value, 0) / values.length;
332
- }
333
- /** Arithmetic mean, or null for an empty input. */
334
- function meanOrNull(values) {
335
- return values.length === 0 ? null : mean(values);
336
- }
337
- /** Arithmetic mean, or 0 for an empty input. */
338
- function meanOrZero(values) {
339
- return values.length === 0 ? 0 : mean(values);
340
- }
341
- // src/statistics/descriptive.ts
342
- /**
343
- * Descriptive statistics: means, bootstrap spread, correlation, and the
344
- * weighted judge-dimension composite. Nothing here is a significance test.
345
- */
346
- /** Weighted mean — falls back to uniform weights when omitted */
347
- function weightedMean(scores) {
348
- if (scores.length === 0) return 0;
349
- let totalWeight = 0;
350
- let weightedSum = 0;
351
- for (const { score, weight } of scores) {
352
- const w = weight ?? 1;
353
- weightedSum += score * w;
354
- totalWeight += w;
355
- }
356
- return totalWeight > 0 ? weightedSum / totalWeight : 0;
357
- }
358
- /**
359
- * Percentile bootstrap confidence interval on the mean of `scores`.
360
- *
361
- * Descriptive spread. It is not a significance test, and at small n its bounds
362
- * are anti-conservative in the same way {@link pairedBootstrap}'s are — see
363
- * {@link BOOTSTRAP_GATE_MIN_N}. With no `seed` the resampling is seeded from
364
- * the scores themselves, so the interval is reproducible either way.
365
- */
366
- function confidenceInterval(scores, confidence = .95, opts = {}) {
367
- if (scores.length === 0) return {
368
- mean: 0,
369
- lower: 0,
370
- upper: 0
371
- };
372
- if (scores.length === 1) return {
373
- mean: scores[0],
374
- lower: scores[0],
375
- upper: scores[0]
376
- };
377
- const n = scores.length;
378
- const mean = scores.reduce((a, b) => a + b, 0) / n;
379
- const B = opts.resamples ?? 1e3;
380
- const rng = makeRng(opts.seed, scores);
381
- const bootstrapMeans = [];
382
- for (let i = 0; i < B; i++) {
383
- let sum = 0;
384
- for (let j = 0; j < n; j++) sum += scores[Math.floor(rng() * n)];
385
- bootstrapMeans.push(sum / n);
386
- }
387
- bootstrapMeans.sort((a, b) => a - b);
388
- const alpha = 1 - confidence;
389
- const lowerIdx = Math.floor(alpha / 2 * B);
390
- const upperIdx = Math.floor((1 - alpha / 2) * B) - 1;
391
- return {
392
- mean,
393
- lower: bootstrapMeans[lowerIdx],
394
- upper: bootstrapMeans[Math.min(upperIdx, B - 1)]
395
- };
396
- }
397
- /**
398
- * Two-sided Student-t critical value: the `t` with `P(|T| ≤ t) = confidence`
399
- * for `df` degrees of freedom. Exact, from {@link studentTQuantile}, so any
400
- * confidence in (0, 1) and fractional `df` are supported.
401
- */
402
- function studentTCritical(df, confidence = .95) {
403
- if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`studentTCritical: confidence must be in (0, 1), got ${confidence}`);
404
- if (!Number.isFinite(df) || df <= 0) throw new ValidationError(`studentTCritical: df must be positive and finite, got ${df}`);
405
- return studentTQuantile(1 - (1 - confidence) / 2, df);
406
- }
407
- /**
408
- * Student-t confidence interval on the mean of one sample:
409
- * `mean ± t(df = n − 1) · s / √n`. Below two samples there is no spread to
410
- * estimate, so the bounds are null rather than a zero-width interval that
411
- * would read as certainty. Unlike {@link confidenceInterval} (a percentile
412
- * bootstrap), the width keeps the small-n t penalty that z = 1.96 drops.
413
- */
414
- function meanConfidenceInterval(samples, confidence = .95) {
415
- assertFiniteSample("meanConfidenceInterval", "samples", samples);
416
- const n = samples.length;
417
- if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`meanConfidenceInterval: confidence must be in (0, 1), got ${confidence}`);
418
- if (n < 2) return {
419
- n,
420
- mean: n === 0 ? null : samples[0],
421
- stdev: null,
422
- low: null,
423
- high: null,
424
- criticalValue: null
425
- };
426
- const center = mean(samples);
427
- const sumSquares = samples.reduce((sum, value) => sum + (value - center) ** 2, 0);
428
- const stdev = Math.sqrt(sumSquares / (n - 1));
429
- const criticalValue = studentTCritical(n - 1, confidence);
430
- const halfWidth = criticalValue * stdev / Math.sqrt(n);
431
- return {
432
- n,
433
- mean: center,
434
- stdev,
435
- low: center - halfWidth,
436
- high: center + halfWidth,
437
- criticalValue
438
- };
439
- }
440
- /** Partial credit: returns 0-1 ratio of current toward target */
441
- function partialCredit(current, target) {
442
- if (target <= 0) return 1;
443
- return Math.min(1, Math.max(0, current / target));
444
- }
445
- /**
446
- * Fold a number series into its distribution summary. Quantiles use the
447
- * nearest-rank definition — the `ceil(q·n)`-th order statistic — so every
448
- * reported quantile is a value from the series. Returns `null` for an empty
449
- * series: an empty series has no distribution, and a zero-filled summary
450
- * would read as a measured all-zero series.
451
- */
452
- function summarizeNumberSeries(values, options) {
453
- const criticalValue = options?.medianInterval?.criticalValue;
454
- if (options) {
455
- assertFiniteSample("summarizeNumberSeries", "values", values);
456
- for (const percentile of options.percentiles ?? []) if (!Number.isFinite(percentile) || percentile < 0 || percentile > 100) throw new ValidationError("summarizeNumberSeries: percentiles must be finite and between 0 and 100");
457
- if (options.medianInterval && (criticalValue === void 0 || !Number.isFinite(criticalValue) || criticalValue < 0)) throw new ValidationError("summarizeNumberSeries: median criticalValue must be finite and nonnegative");
458
- }
459
- if (values.length === 0) return null;
460
- const sorted = [...values].sort((a, b) => a - b);
461
- const n = sorted.length;
462
- const rank = (q) => sorted[Math.min(n - 1, Math.max(0, Math.ceil(q * n) - 1))];
463
- const sum = sorted.reduce((a, b) => a + b, 0);
464
- if (options && !Number.isFinite(sum)) throw new ValidationError("summarizeNumberSeries: sample sum exceeded finite range");
465
- const spread = criticalValue === void 0 ? void 0 : criticalValue / 2 * Math.sqrt(n);
466
- const lowRank = spread === void 0 ? 1 : Math.max(1, Math.floor(n / 2 - spread));
467
- const highRank = spread === void 0 ? n : Math.min(n, Math.ceil(n / 2 + 1 + spread));
468
- return {
469
- n,
470
- min: sorted[0],
471
- p50: rank(.5),
472
- p90: rank(.9),
473
- max: sorted[sorted.length - 1],
474
- sum,
475
- ...options?.percentiles === void 0 ? {} : { percentiles: Object.fromEntries(options.percentiles.map((percentile) => [percentile, rank(percentile / 100)])) },
476
- ...criticalValue === void 0 ? {} : { medianInterval: {
477
- method: "normal-order-statistics",
478
- criticalValue,
479
- sampleSize: n,
480
- lowRank,
481
- highRank,
482
- low: sorted[lowRank - 1],
483
- high: sorted[highRank - 1]
484
- } }
485
- };
486
- }
487
- /**
488
- * Average-rank-with-ties transform (1-indexed). Tied values receive the mean
489
- * of the ranks they span, the standard correction for Spearman's ρ.
490
- */
491
- function ranks(xs) {
492
- const indexed = xs.map((v, i) => ({
493
- v,
494
- i
495
- })).sort((a, b) => a.v - b.v);
496
- const r = new Array(xs.length);
497
- let i = 0;
498
- while (i < indexed.length) {
499
- let j = i;
500
- while (j + 1 < indexed.length && indexed[j + 1].v === indexed[i].v) j++;
501
- const avg = (i + j) / 2 + 1;
502
- for (let k = i; k <= j; k++) r[indexed[k].i] = avg;
503
- i = j + 1;
504
- }
505
- return r;
506
- }
507
- /**
508
- * Pearson product-moment correlation coefficient r ∈ [-1, 1] between two
509
- * equal-length series. See the edge-case contract above: NaN for n < 2 or
510
- * unequal lengths, 1 when both series are constant, 0 when exactly one is.
511
- */
512
- function pearsonR(a, b) {
513
- if (a.length !== b.length || a.length < 2) return NaN;
514
- const n = a.length;
515
- const meanA = a.reduce((s, v) => s + v, 0) / n;
516
- const meanB = b.reduce((s, v) => s + v, 0) / n;
517
- let num = 0;
518
- let varA = 0;
519
- let varB = 0;
520
- for (let i = 0; i < n; i++) {
521
- const da = a[i] - meanA;
522
- const db = b[i] - meanB;
523
- num += da * db;
524
- varA += da * da;
525
- varB += db * db;
526
- }
527
- if (varA === 0 || varB === 0) return varA === 0 && varB === 0 ? 1 : 0;
528
- return num / Math.sqrt(varA * varB);
529
- }
530
- /**
531
- * Spearman's rank correlation ρ — Pearson over the average-rank-with-ties
532
- * transform of each series. Same edge-case contract as {@link pearsonR}.
533
- */
534
- function spearmanR(a, b) {
535
- if (a.length !== b.length || a.length < 2) return NaN;
536
- return pearsonR(ranks(a), ranks(b));
537
- }
538
- /**
539
- * Weighted composite over judge dimensions: `Σ(score_d · w_d) / Σ(w_d)` across
540
- * the weighted dimensions. The canonical replacement for the per-consumer
541
- * hand-rolled composite math (tax/legal/creative/gtm each ship a copy).
542
- *
543
- * Fail-loud: throws if a weighted dimension is missing from `dims`, if any
544
- * weight is negative, or if the weights sum to 0 — none of which can produce
545
- * a meaningful composite.
546
- */
547
- function weightedComposite(input) {
548
- const entries = Object.entries(input.weights);
549
- if (entries.length === 0) throw new Error("weightedComposite: `weights` is empty — nothing to combine");
550
- let weightedSum = 0;
551
- let weightTotal = 0;
552
- for (const [dim, weight] of entries) {
553
- if (weight < 0) throw new Error(`weightedComposite: weight for '${dim}' is negative (${weight})`);
554
- if (!(dim in input.dims)) throw new Error(`weightedComposite: weighted dimension '${dim}' is absent from \`dims\` — refusing to renormalise onto a different denominator`);
555
- weightedSum += input.dims[dim] * weight;
556
- weightTotal += weight;
557
- }
558
- if (weightTotal === 0) throw new Error("weightedComposite: weights sum to 0 — composite is undefined");
559
- const composite = weightedSum / weightTotal;
560
- return input.threshold === void 0 ? { composite } : {
561
- composite,
562
- pass: composite >= input.threshold
563
- };
564
- }
565
90
  // src/judge-calibration.ts
566
91
  /**
567
92
  * Judge calibration — measure judge quality against human gold + bias.
@@ -1051,6 +576,187 @@ function cohenKappa(pairs) {
1051
576
  kappa: expected === 1 ? NaN : (observed - expected) / (1 - expected)
1052
577
  };
1053
578
  }
579
+ // src/statistics/comparison-effects.ts
580
+ function binary(values, name) {
581
+ if (values.some((value) => value !== 0 && value !== 1)) throw new ValidationError(`${name}: expected binary 0/1 values`);
582
+ }
583
+ /** Mann–Whitney ROC area: ties count half; no observed member of either class means unknown. */
584
+ function rocAuc(scores, labels) {
585
+ assertFiniteSample("rocAuc", "scores", scores);
586
+ binary(labels, "rocAuc.labels");
587
+ if (scores.length !== labels.length) throw new ValidationError("rocAuc: scores and labels must have equal lengths");
588
+ const ranked = ranks(scores);
589
+ const positive = labels.reduce((sum, label) => sum + label, 0);
590
+ const sum = labels.reduce((total, label, index) => total + label * ranked[index], 0);
591
+ const negative = labels.length - positive;
592
+ return positive && negative ? (sum - positive * (positive + 1) / 2) / (positive * negative) : null;
593
+ }
594
+ // src/statistics/normalize-signed-zero.ts
595
+ /** Normalize IEEE negative zero before numerical evidence reaches canonical JSON. */
596
+ function normalizeSignedZero(value) {
597
+ return value === 0 ? 0 : value;
598
+ }
599
+ // src/statistics/clustered-association.ts
600
+ /**
601
+ * Association between a score and an outcome when rows share independent units.
602
+ *
603
+ * The interval and the standard error come from resampling whole units, never
604
+ * rows: rows of one unit share whatever makes that unit differ, and a row
605
+ * resample counts them as independent evidence. The p-value is a Wald test on
606
+ * that standard error with `units - 1` degrees of freedom, so it stays
607
+ * continuous for a false-discovery correction across many measures instead of
608
+ * stopping at the bootstrap's `1 / resamples` floor. When every defined
609
+ * resample gives the same value the standard error is zero and the p-value
610
+ * falls back to `1 / (definedResamples + 1)` for an estimate on the tested
611
+ * side of the null, and 1 otherwise.
612
+ *
613
+ * The within-unit scope answers whether the score separates rows of the same
614
+ * unit: AUC inside each unit weighted by its positive-negative pairs, or
615
+ * Spearman inside each unit weighted by its row pairs, where a score constant
616
+ * inside a unit counts as no association there.
617
+ */
618
+ function clusteredAssociation(rows, options) {
619
+ const { statistic } = options;
620
+ const scope = options.scope ?? "pooled";
621
+ const alternative = options.alternative ?? "two-sided";
622
+ const resamples = options.resamples ?? 1e3;
623
+ const confidence = options.confidence ?? .95;
624
+ if (statistic !== "auc" && statistic !== "spearman") throw new ValidationError("clusteredAssociation: statistic must be auc or spearman");
625
+ if (scope !== "pooled" && scope !== "within-unit") throw new ValidationError("clusteredAssociation: scope must be pooled or within-unit");
626
+ if (alternative !== "two-sided" && alternative !== "greater") throw new ValidationError("clusteredAssociation: alternative must be two-sided or greater");
627
+ if (!Number.isSafeInteger(resamples) || resamples < 1) throw new ValidationError("clusteredAssociation: resamples must be a positive safe integer");
628
+ for (const [index, row] of rows.entries()) {
629
+ if (!Number.isFinite(row.x) || !Number.isFinite(row.y)) throw new ValidationError(`clusteredAssociation: rows[${index}] must have finite x and y`);
630
+ if (statistic === "auc" && row.y !== 0 && row.y !== 1) throw new ValidationError(`clusteredAssociation: rows[${index}].y must be 0 or 1 for auc`);
631
+ if (typeof row.unit !== "string" || row.unit.length === 0) throw new ValidationError(`clusteredAssociation: rows[${index}].unit must be nonempty`);
632
+ }
633
+ const seed = options.seed ?? seedFromData([rows.map((row) => row.x), rows.map((row) => row.y)]);
634
+ const draws = [];
635
+ const record = (value) => {
636
+ if (Number.isFinite(value)) draws.push(value);
637
+ return value;
638
+ };
639
+ let estimate;
640
+ let n;
641
+ let units;
642
+ let interval;
643
+ if (scope === "pooled") {
644
+ estimate = associationEstimate(statistic, rows);
645
+ n = rows.length;
646
+ units = new Set(rows.map((row) => row.unit)).size;
647
+ if (Number.isFinite(estimate) && units >= 2) interval = clusterBootstrap(rows, (row) => row.unit, (sample) => record(associationEstimate(statistic, sample)), {
648
+ resamples,
649
+ level: confidence,
650
+ seed
651
+ });
652
+ else interval = {
653
+ low: NaN,
654
+ high: NaN
655
+ };
656
+ } else {
657
+ const summaries = unitSummaries(statistic, rows);
658
+ estimate = weightedMean(summaries);
659
+ n = summaries.reduce((sum, unit) => sum + unit.rows, 0);
660
+ units = summaries.length;
661
+ if (Number.isFinite(estimate) && units >= 2) interval = clusterBootstrap(summaries, (unit) => unit.unit, (sample) => record(weightedMean(sample)), {
662
+ resamples,
663
+ level: confidence,
664
+ seed
665
+ });
666
+ else interval = {
667
+ low: NaN,
668
+ high: NaN
669
+ };
670
+ }
671
+ if (!Number.isFinite(estimate) || units < 2) throw new ValidationError(`clusteredAssociation: the ${scope} ${statistic} needs two units with both outcome classes for auc, or variation on both sides`);
672
+ const nullValue = statistic === "auc" ? .5 : 0;
673
+ const standardError = sampleStandardDeviation(draws);
674
+ const distance = estimate - nullValue;
675
+ let pValue;
676
+ if (!(standardError > 0)) pValue = (alternative === "greater" ? distance > 0 : distance !== 0) ? 1 / (draws.length + 1) : 1;
677
+ else if (alternative === "greater") pValue = 1 - studentTCdf(distance / standardError, units - 1);
678
+ else pValue = Math.min(1, 2 * (1 - studentTCdf(Math.abs(distance) / standardError, units - 1)));
679
+ return {
680
+ statistic,
681
+ scope,
682
+ alternative,
683
+ n,
684
+ units,
685
+ estimate: normalizeSignedZero(estimate),
686
+ null: nullValue,
687
+ standardError,
688
+ low: interval.low,
689
+ high: interval.high,
690
+ confidence,
691
+ pValue,
692
+ resamples,
693
+ definedResamples: draws.length
694
+ };
695
+ }
696
+ /**
697
+ * The point statistic alone, pooled across units or within them; NaN when it
698
+ * is undefined on these rows. Within units it needs `unit` on every row.
699
+ */
700
+ function associationEstimate(statistic, rows, scope = "pooled") {
701
+ if (scope === "within-unit") return weightedMean(unitSummaries(statistic, rows));
702
+ const xs = rows.map((row) => row.x);
703
+ const ys = rows.map((row) => row.y);
704
+ if (statistic === "auc") return rocAuc(xs, ys) ?? NaN;
705
+ if (!varies(xs) || !varies(ys)) return NaN;
706
+ return spearmanR(xs, ys);
707
+ }
708
+ function unitSummaries(statistic, rows) {
709
+ const byUnit = /* @__PURE__ */ new Map();
710
+ for (const row of rows) {
711
+ const unit = byUnit.get(row.unit) ?? {
712
+ xs: [],
713
+ ys: []
714
+ };
715
+ unit.xs.push(row.x);
716
+ unit.ys.push(row.y);
717
+ byUnit.set(row.unit, unit);
718
+ }
719
+ const summaries = [];
720
+ for (const [unit, { xs, ys }] of byUnit) if (statistic === "auc") {
721
+ const positive = ys.reduce((sum, y) => sum + y, 0);
722
+ const negative = ys.length - positive;
723
+ const value = rocAuc(xs, ys);
724
+ if (value === null) continue;
725
+ summaries.push({
726
+ unit,
727
+ rows: ys.length,
728
+ value,
729
+ weight: positive * negative
730
+ });
731
+ } else {
732
+ if (ys.length < 2 || !varies(ys)) continue;
733
+ summaries.push({
734
+ unit,
735
+ rows: ys.length,
736
+ value: varies(xs) ? spearmanR(xs, ys) : 0,
737
+ weight: ys.length * (ys.length - 1) / 2
738
+ });
739
+ }
740
+ return summaries;
741
+ }
742
+ function weightedMean(summaries) {
743
+ let total = 0;
744
+ let weight = 0;
745
+ for (const summary of summaries) {
746
+ total += summary.value * summary.weight;
747
+ weight += summary.weight;
748
+ }
749
+ return weight > 0 ? total / weight : NaN;
750
+ }
751
+ function varies(values) {
752
+ return values.some((value) => value !== values[0]);
753
+ }
754
+ function sampleStandardDeviation(values) {
755
+ if (values.length < 2) return 0;
756
+ const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
757
+ const squares = values.reduce((sum, value) => sum + (value - mean) ** 2, 0);
758
+ return Math.sqrt(squares / (values.length - 1));
759
+ }
1054
760
  // src/statistics/clustered-paired.ts
1055
761
  const groupsOf = (items, cluster) => {
1056
762
  const groups = /* @__PURE__ */ new Map();
@@ -1233,21 +939,6 @@ function simulateClusteredBinaryContrast(design) {
1233
939
  simulatedPowerSe: detected.se
1234
940
  };
1235
941
  }
1236
- // src/statistics/comparison-effects.ts
1237
- function binary(values, name) {
1238
- if (values.some((value) => value !== 0 && value !== 1)) throw new ValidationError(`${name}: expected binary 0/1 values`);
1239
- }
1240
- /** Mann–Whitney ROC area: ties count half; no observed member of either class means unknown. */
1241
- function rocAuc(scores, labels) {
1242
- assertFiniteSample("rocAuc", "scores", scores);
1243
- binary(labels, "rocAuc.labels");
1244
- if (scores.length !== labels.length) throw new ValidationError("rocAuc: scores and labels must have equal lengths");
1245
- const ranked = ranks(scores);
1246
- const positive = labels.reduce((sum, label) => sum + label, 0);
1247
- const sum = labels.reduce((total, label, index) => total + label * ranked[index], 0);
1248
- const negative = labels.length - positive;
1249
- return positive && negative ? (sum - positive * (positive + 1) / 2) / (positive * negative) : null;
1250
- }
1251
942
  // src/statistics/distribution-summary.ts
1252
943
  /** Nearest-rank percentile on a sorted, non-empty sample (0-100 scale). */
1253
944
  function nearestRank(sorted, percentile) {
@@ -1929,219 +1620,33 @@ function pairedBinaryScale(before, after) {
1929
1620
  * form. Requires 1 ≤ k ≤ n and 0 ≤ c ≤ n.
1930
1621
  */
1931
1622
  function passAtK(n, c, k) {
1932
- if (!Number.isInteger(n) || !Number.isInteger(c) || !Number.isInteger(k)) throw new Error(`passAtK: n, c, k must be integers (got n=${n}, c=${c}, k=${k})`);
1933
- if (k < 1 || k > n || c < 0 || c > n) throw new Error(`passAtK: require 1 ≤ k ≤ n and 0 ≤ c ≤ n (got n=${n}, c=${c}, k=${k})`);
1623
+ assertPassKArguments("passAtK", n, c, k);
1934
1624
  if (n - c < k) return 1;
1935
1625
  let prob = 1;
1936
1626
  for (let i = n - c + 1; i <= n; i++) prob *= 1 - k / i;
1937
1627
  return 1 - prob;
1938
1628
  }
1939
- // src/statistics/paired-tests.ts
1940
- /**
1941
- * Paired significance tests on continuous scores: the paired t-test, the
1942
- * promotion-gate paired bootstrap, the exact sign test, and the package-wide
1943
- * paired-delta decision statistic.
1944
- */
1945
- /**
1946
- * Paired t-test — before/after measurements on the SAME items.
1947
- * Pairing removes inter-item variance, giving tighter significance than
1948
- * an unpaired test when comparing prompt v1 vs prompt v2 on identical
1949
- * scenarios.
1950
- *
1951
- * Returns `t = p = null` where the statistic is undefined: fewer than two
1952
- * pairs, or a non-zero constant delta whose observed variance is zero. A
1953
- * constant shift carries no information about the variance it would have to
1954
- * be compared against, so the honest answer is "undefined", not `p = 0` —
1955
- * three observations cannot buy absolute certainty. This is the same contract
1956
- * {@link pairedCohensDz} states for the same condition. An all-zero delta is
1957
- * different: it is a measured null, and returns `t = 0, p = 1`.
1958
- */
1959
- function pairedTTest(before, after) {
1960
- if (before.length !== after.length) throw new ValidationError(`pairedTTest: unequal sample sizes (${before.length} vs ${after.length})`);
1961
- assertFiniteSample("pairedTTest", "before", before);
1962
- assertFiniteSample("pairedTTest", "after", after);
1963
- const n = before.length;
1964
- if (n < 2) return {
1965
- t: null,
1966
- df: 0,
1967
- p: null
1968
- };
1969
- const diffs = before.map((b, i) => after[i] - b);
1970
- const mean = diffs.reduce((a, b) => a + b, 0) / n;
1971
- const variance = diffs.reduce((acc, d) => acc + (d - mean) ** 2, 0) / (n - 1);
1972
- const se = Math.sqrt(variance / n);
1973
- if (se === 0) return mean === 0 ? {
1974
- t: 0,
1975
- df: n - 1,
1976
- p: 1
1977
- } : {
1978
- t: null,
1979
- df: n - 1,
1980
- p: null
1981
- };
1982
- const t = mean / se;
1983
- const df = n - 1;
1984
- return {
1985
- t,
1986
- df,
1987
- p: 2 * (1 - studentTCdf(Math.abs(t), df))
1988
- };
1989
- }
1990
1629
  /**
1991
- * Pairs below which a percentile bootstrap interval is descriptive spread only.
1992
- *
1993
- * `P(low > 0)` under a true null, against a nominal 2.5 %, measured over 4000
1994
- * seeded trials: 13.53 % at n = 3, 3.52 % at n = 10, 3.10 % at n = 20 on the
1995
- * median; 13.85 %, 4.90 %, 3.80 % on the mean. This is intrinsic to resampling
1996
- * three points, not an implementation error — scipy's BCa gives 16.0 % on the
1997
- * same n = 3 data — so no change to the estimator moves it. Below this floor
1998
- * the decision belongs to the exact sign test or exact signed-rank test.
1630
+ * Unbiased pass^k (Yao et al. 2024, τ-bench): the probability that every one
1631
+ * of a random k of the `n` independent attempts at one task passes, given `c`
1632
+ * of them passed — C(c, k) / C(n, k). With n = k it is 1 when all k passed and
1633
+ * 0 otherwise: success in all k of k repeats. pass@k rewards one lucky attempt;
1634
+ * pass^k charges every unreliable one, so the two diverge exactly on tasks that
1635
+ * pass in some repeats only. Average the per-task values across the suite.
1636
+ * Shares `passAtK`'s argument rules; computed in product form, so no factorial
1637
+ * overflows.
1999
1638
  */
2000
- const BOOTSTRAP_GATE_MIN_N = 20;
2001
- /**
2002
- * Paired bootstrap on (after − before) deltas. Returns a CI on the chosen
2003
- * statistic (median by default); pairs are resampled with replacement. Throws
2004
- * on unequal sample sizes.
2005
- *
2006
- * `low > threshold` carries the stated confidence ONLY at `n ≥
2007
- * {@link BOOTSTRAP_GATE_MIN_N}`, which `gateEligible` reports. Below it the
2008
- * check fires under a true null several times more often than nominal, so the
2009
- * interval is descriptive spread and a promotion must not turn on it.
2010
- */
2011
- function pairedBootstrap(before, after, opts = {}) {
2012
- if (before.length !== after.length) throw new Error(`pairedBootstrap: unequal sample sizes (${before.length} vs ${after.length})`);
2013
- const confidence = opts.confidence ?? .95;
2014
- const resamples = opts.resamples ?? 2e3;
2015
- const statistic = opts.statistic ?? "median";
2016
- if (confidence <= 0 || confidence >= 1) throw new Error(`pairedBootstrap: confidence must be in (0,1), got ${confidence}`);
2017
- const n = before.length;
2018
- const deltas = before.map((b, i) => after[i] - b);
2019
- const gateEligible = n >= 20;
2020
- if (n === 0) return {
2021
- n: 0,
2022
- median: 0,
2023
- mean: 0,
2024
- low: 0,
2025
- high: 0,
2026
- confidence,
2027
- resamples,
2028
- gateEligible
2029
- };
2030
- if (n === 1) {
2031
- const d = deltas[0];
2032
- return {
2033
- n: 1,
2034
- median: d,
2035
- mean: d,
2036
- low: d,
2037
- high: d,
2038
- confidence,
2039
- resamples,
2040
- gateEligible
2041
- };
2042
- }
2043
- const rng = makeRng(opts.seed, deltas);
2044
- const samples = new Array(resamples);
2045
- for (let b = 0; b < resamples; b++) if (statistic === "mean") {
2046
- let sum = 0;
2047
- for (let k = 0; k < n; k++) sum += deltas[Math.floor(rng() * n)];
2048
- samples[b] = sum / n;
2049
- } else {
2050
- const acc = new Array(n);
2051
- for (let k = 0; k < n; k++) acc[k] = deltas[Math.floor(rng() * n)];
2052
- samples[b] = medianInPlace(acc);
2053
- }
2054
- samples.sort((a, b) => a - b);
2055
- const alpha = 1 - confidence;
2056
- const lowIdx = Math.floor(alpha / 2 * resamples);
2057
- const highIdx = Math.min(resamples - 1, Math.ceil((1 - alpha / 2) * resamples) - 1);
2058
- return {
2059
- n,
2060
- median: medianInPlace([...deltas]),
2061
- mean: deltas.reduce((s, x) => s + x, 0) / n,
2062
- low: samples[lowIdx],
2063
- high: samples[Math.max(highIdx, lowIdx)],
2064
- confidence,
2065
- resamples,
2066
- gateEligible
2067
- };
2068
- }
2069
- /**
2070
- * Exact one-sided sign test over paired differences.
2071
- *
2072
- * Pass `after[i] - before[i]` for each matched item. `alternative = 'greater'`
2073
- * tests whether positive signs are more likely than negative signs and returns
2074
- * `P(Binomial(nNonTies, 0.5) >= positive)`. `alternative = 'less'` treats
2075
- * negative signs as successes instead. With a continuous difference
2076
- * distribution this is the usual directional median test. Exact zero
2077
- * differences are ties and do not enter the binomial denominator. All-tie and
2078
- * empty inputs return p = 1. Every input difference must be finite, and the
2079
- * direction must be chosen explicitly so a caller cannot select it after
2080
- * seeing the signs.
2081
- */
2082
- function pairedSignTest(differences, alternative) {
2083
- if (alternative !== "greater" && alternative !== "less") throw new ValidationError(`pairedSignTest: alternative must be 'greater' or 'less', got ${alternative}`);
2084
- let positive = 0;
2085
- let negative = 0;
2086
- let ties = 0;
2087
- for (let i = 0; i < differences.length; i++) {
2088
- const difference = differences[i];
2089
- if (!Number.isFinite(difference)) throw new ValidationError(`pairedSignTest: difference at index ${i} must be finite, got ${difference}`);
2090
- if (difference > 0) positive++;
2091
- else if (difference < 0) negative++;
2092
- else ties++;
2093
- }
2094
- const nNonTies = positive + negative;
2095
- const successes = alternative === "greater" ? positive : negative;
2096
- return {
2097
- n: differences.length,
2098
- positive,
2099
- negative,
2100
- ties,
2101
- nNonTies,
2102
- alternative,
2103
- pValue: binomialHalfUpperTail(successes, nNonTies)
2104
- };
1639
+ function passHatK(n, c, k) {
1640
+ assertPassKArguments("passHatK", n, c, k);
1641
+ if (c < k) return 0;
1642
+ let prob = 1;
1643
+ for (let i = 0; i < k; i++) prob *= (c - i) / (n - i);
1644
+ return prob;
2105
1645
  }
2106
- /** Fraction of paired observations whose delta is an exact tie (|after − before|
2107
- * < 1e-9). Throws on unequal sample sizes; 0 pairs ⇒ 0. */
2108
- function pairedDeltaTieFraction(before, after) {
2109
- if (before.length !== after.length) throw new Error(`pairedDeltaTieFraction: unequal sample sizes (${before.length} vs ${after.length})`);
2110
- const n = before.length;
2111
- if (n === 0) return 0;
2112
- let ties = 0;
2113
- for (let i = 0; i < n; i++) if (Math.abs(after[i] - before[i]) < 1e-9) ties++;
2114
- return ties / n;
1646
+ function assertPassKArguments(name, n, c, k) {
1647
+ if (!Number.isInteger(n) || !Number.isInteger(c) || !Number.isInteger(k)) throw new Error(`${name}: n, c, k must be integers (got n=${n}, c=${c}, k=${k})`);
1648
+ if (k < 1 || k > n || c < 0 || c > n) throw new Error(`${name}: require 1 ≤ k ≤ n and 0 ≤ c ≤ n (got n=${n}, c=${c}, k=${k})`);
2115
1649
  }
2116
- /**
2117
- * The paired-delta statistic a DECISION is computed on, package-wide.
2118
- *
2119
- * The mean paired delta is the estimator that answers the question a promotion
2120
- * gate asks — "by how much did the candidate move the score" — in the caller's
2121
- * own units, and it equals the aggregate lift everyone quotes. The MEDIAN
2122
- * answers a different question and loses the answer to this one in every regime
2123
- * eval data actually lands in:
2124
- * - TWO-POINT (pass/fail) outcomes on any encoding: the delta vector lives in
2125
- * {−s, 0, +s} dominated by zeros, so the median and its whole bootstrap CI
2126
- * are pinned at exactly 0 however large the shift. (Decide these on
2127
- * {@link pairedRiskDifferenceExact} instead — same estimand, exact interval.)
2128
- * - TIE-DOMINATED outcomes: at half the pairs tied the sample median is 0 by
2129
- * construction, and `ci.low > threshold` then answers "no" forever at a
2130
- * non-negative threshold and "yes" forever at a negative one.
2131
- * - LOW-CARDINALITY outcomes, even well below half ties: judge dimensions on
2132
- * integer 0-100, and block scores like {⅔, 1} from averaging pass/fail
2133
- * leaves, put the median on a coarse lattice whose bootstrap percentiles
2134
- * land on atoms. Measured: 26 blocks of 3 pass/fail leaves carrying a real
2135
- * +12.8pp lift, only 23% of pairs tied, gives a median CI of [0, 0.333] —
2136
- * lower bound exactly 0, so a gate at threshold 0 refuses a real lift.
2137
- * That last case is why there is no tie-fraction threshold here: any cutoff on
2138
- * ties leaves the lattice case open on the other side of it.
2139
- *
2140
- * `heldoutSignificance` has defaulted to the mean since #316 for the same
2141
- * reason. The median remains available per call site for callers who
2142
- * specifically want outlier robustness and accept the blindness.
2143
- */
2144
- const DECISION_PAIRED_DELTA_STATISTIC = "mean";
2145
1650
  // src/statistics/power-and-mde.ts
2146
1651
  /**
2147
1652
  * Required N per arm for a two-sample comparison at target effect size,
@@ -2154,7 +1659,8 @@ function requiredSampleSize(opts) {
2154
1659
  if (!Number.isFinite(effect) || effect <= 0) return Infinity;
2155
1660
  const alpha = opts.alpha ?? .05;
2156
1661
  const power = opts.power ?? .8;
2157
- const n = 2 * ((zQuantile(opts.twoSided ?? true ? 1 - alpha / 2 : 1 - alpha) + zQuantile(power)) / effect) ** 2;
1662
+ const twoSided = opts.twoSided ?? true;
1663
+ const n = 2 * ((zQuantile(twoSided ? 1 - alpha / 2 : 1 - alpha) + zQuantile(power)) / effect) ** 2;
2158
1664
  return Math.ceil(n);
2159
1665
  }
2160
1666
  /**
@@ -2171,7 +1677,8 @@ function requiredPairedSampleSize(opts) {
2171
1677
  if (!Number.isFinite(effect) || effect <= 0) return Infinity;
2172
1678
  const alpha = opts.alpha ?? .05;
2173
1679
  const power = opts.power ?? .8;
2174
- const zAlpha = zQuantile(opts.twoSided ?? true ? 1 - alpha / 2 : 1 - alpha);
1680
+ const twoSided = opts.twoSided ?? true;
1681
+ const zAlpha = zQuantile(twoSided ? 1 - alpha / 2 : 1 - alpha);
2175
1682
  const zBeta = zQuantile(power);
2176
1683
  return Math.ceil(((zAlpha + zBeta) / effect) ** 2);
2177
1684
  }
@@ -2185,7 +1692,8 @@ function pairedMde(opts) {
2185
1692
  if (!Number.isFinite(opts.nPaired) || opts.nPaired <= 0) return Infinity;
2186
1693
  const alpha = opts.alpha ?? .05;
2187
1694
  const power = opts.power ?? .8;
2188
- return (zQuantile(opts.twoSided ?? true ? 1 - alpha / 2 : 1 - alpha) + zQuantile(power)) / Math.sqrt(opts.nPaired);
1695
+ const twoSided = opts.twoSided ?? true;
1696
+ return (zQuantile(twoSided ? 1 - alpha / 2 : 1 - alpha) + zQuantile(power)) / Math.sqrt(opts.nPaired);
2189
1697
  }
2190
1698
  /**
2191
1699
  * Number of paired observations needed for a McNemar test to reach a target
@@ -2811,6 +2319,6 @@ function assertResumable(resume, params) {
2811
2319
  }
2812
2320
  return resume;
2813
2321
  }
2814
- export { continuousAgreement as $, fisherExactTwoSided as A, summarizeDistribution as B, passAtK as C, studentTCdf as Ct, holm as D, bonferroni as E, cliffsDelta as F, clusteredPairedContrast as G, clusterJackknife as H, cohensD as I, corpusInterRaterAgreementFromJudgeScores as J, simulateClusteredBinaryContrast as K, interpretCliffs as L, normalTwoSidedPValue as M, studentTTwoSidedPValue as N, chiSquared as O, twoByTwoPValue as P, calibrateJudgeContinuous as Q, pairedCohensDz as R, pairedRiskDifferenceScore as S, placeboBand as St, benjaminiHochberg as T, clusterSignFlipTest as U, rocAuc as V, clusteredBinaryMde as W, nominalAgreement as X, interRaterReliability as Y, calibrateJudge as Z, independentRiskDifference as _, medianInPlace as _t, wilcoxonSignedRank as a, partialCredit as at, pairedRiskDifference as b, DEFAULT_BOOTSTRAP_SEED as bt, pairedMde as c, spearmanR as ct, BOOTSTRAP_GATE_MIN_N as d, weightedComposite as dt, positionalBias as et, DECISION_PAIRED_DELTA_STATISTIC as f, weightedMean as ft, pairedTTest as g, makeRng as gt, pairedSignTest as h, meanOrZero as ht, mannWhitneyU as i, meanConfidenceInterval as it, linearRegressionSlope as j, chiSquaredPValue as k, requiredPairedSampleSize as l, studentTCritical as lt, pairedDeltaTieFraction as m, meanOrNull as mt, sampleMedian as n, verbosityBias as nt, mcnemarPower as o, pearsonR as ot, pairedBootstrap as p, mean as pt, corpusInterRaterAgreement as q, summarizeSample as r, confidenceInterval as rt, mcnemarRequiredN as s, ranks as st, eProcess as t, selfPreference as tt, requiredSampleSize as u, summarizeNumberSeries as ut, mcnemar as v, seedFromData as vt, wilson as w, studentTQuantile as wt, pairedRiskDifferenceExact as x, clusterBootstrap as xt, pairedBinaryScale as y, zQuantile as yt, percentileNearestRank as z };
2322
+ export { selfPreference as $, cliffsDelta as A, simulateClusteredBinaryContrast as B, chiSquared as C, normalTwoSidedPValue as D, linearRegressionSlope as E, summarizeDistribution as F, corpusInterRaterAgreement as G, clusteredAssociation as H, clusterJackknife as I, nominalAgreement as J, corpusInterRaterAgreementFromJudgeScores as K, clusterSignFlipTest as L, interpretCliffs as M, pairedCohensDz as N, studentTTwoSidedPValue as O, percentileNearestRank as P, positionalBias as Q, clusteredBinaryMde as R, holm as S, fisherExactTwoSided as T, normalizeSignedZero as U, associationEstimate as V, rocAuc as W, calibrateJudgeContinuous as X, calibrateJudge as Y, continuousAgreement as Z, passAtK as _, wilcoxonSignedRank as a, benjaminiHochberg as b, pairedMde as c, independentRiskDifference as d, verbosityBias as et, mcnemar as f, pairedRiskDifferenceScore as g, pairedRiskDifferenceExact as h, mannWhitneyU as i, cohensD as j, twoByTwoPValue as k, requiredPairedSampleSize as l, pairedRiskDifference as m, sampleMedian as n, clusterBootstrap as nt, mcnemarPower as o, pairedBinaryScale as p, interRaterReliability as q, summarizeSample as r, placeboBand as rt, mcnemarRequiredN as s, eProcess as t, DEFAULT_BOOTSTRAP_SEED as tt, requiredSampleSize as u, passHatK as v, chiSquaredPValue as w, bonferroni as x, wilson as y, clusteredPairedContrast as z };
2815
2323
 
2816
- //# sourceMappingURL=statistics-DSidA5I2.js.map
2324
+ //# sourceMappingURL=statistics-BPl13X3G.js.map