@tangle-network/agent-eval 1.0.18 → 1.0.20

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 (305) hide show
  1. package/CHANGELOG.md +20 -21
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-CPv4tENR.d.ts → agent-profile-BO8ruI6R.d.ts} +3 -3
  4. package/dist/{agent-profile-CPv4tENR.d.ts.map → agent-profile-BO8ruI6R.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +14 -14
  6. package/dist/analyst/index.js +13 -14
  7. package/dist/analyst/index.js.map +1 -1
  8. package/dist/{analyze-runs-pJ4fhnYg.d.ts → analyze-runs-DicleUI_.d.ts} +4 -4
  9. package/dist/{analyze-runs-pJ4fhnYg.d.ts.map → analyze-runs-DicleUI_.d.ts.map} +1 -1
  10. package/dist/{analyze-runs-C7vWBDhl.js → analyze-runs-e9vfXY--.js} +6 -110
  11. package/dist/analyze-runs-e9vfXY--.js.map +1 -0
  12. package/dist/app-grade/index.d.ts +12 -7
  13. package/dist/app-grade/index.d.ts.map +1 -1
  14. package/dist/app-grade/index.js +14 -10
  15. package/dist/app-grade/index.js.map +1 -1
  16. package/dist/{benchmark-command-Bqqvv9Tk.js → benchmark-command-BGZD77Un.js} +16 -17
  17. package/dist/benchmark-command-BGZD77Un.js.map +1 -0
  18. package/dist/benchmarks/index.d.ts +4 -4
  19. package/dist/benchmarks/index.js +4 -5
  20. package/dist/benchmarks/index.js.map +1 -1
  21. package/dist/builder-eval/index.js +1 -1
  22. package/dist/{calibration-CbZPApIO.js → calibration-Ze7SjhT9.js} +2 -2
  23. package/dist/{calibration-CbZPApIO.js.map → calibration-Ze7SjhT9.js.map} +1 -1
  24. package/dist/campaign/index.d.ts +7 -7
  25. package/dist/campaign/index.js +13 -13
  26. package/dist/{campaign-DzLlT0So.js → campaign-BfDMncQN.js} +16 -17
  27. package/dist/{campaign-DzLlT0So.js.map → campaign-BfDMncQN.js.map} +1 -1
  28. package/dist/{campaign-evidence-CcA7a67m.js → campaign-evidence-BuKlRzSA.js} +4 -4
  29. package/dist/{campaign-evidence-CcA7a67m.js.map → campaign-evidence-BuKlRzSA.js.map} +1 -1
  30. package/dist/{chat-client-D0me8iwq.js → chat-client-Zz97O3NB.js} +2 -2
  31. package/dist/{chat-client-D0me8iwq.js.map → chat-client-Zz97O3NB.js.map} +1 -1
  32. package/dist/{chat-json-call-C473CwTt.js → chat-json-call-Dgi7-RH-.js} +2 -2
  33. package/dist/{chat-json-call-C473CwTt.js.map → chat-json-call-Dgi7-RH-.js.map} +1 -1
  34. package/dist/cli.js +9 -9
  35. package/dist/{types-0KglnQ9o.d.ts → cluster-Cd0MRbr9.d.ts} +44 -2
  36. package/dist/cluster-Cd0MRbr9.d.ts.map +1 -0
  37. package/dist/cluster-bootstrap-BYIW7QJ4.js +24 -0
  38. package/dist/cluster-bootstrap-BYIW7QJ4.js.map +1 -0
  39. package/dist/{completion-verifier-7KEfroqx.d.ts → completion-verifier-BEpsr3N4.d.ts} +2 -2
  40. package/dist/{completion-verifier-7KEfroqx.d.ts.map → completion-verifier-BEpsr3N4.d.ts.map} +1 -1
  41. package/dist/{completion-verifier-ClmJV_Yc.js → completion-verifier-DFyYFezn.js} +3 -3
  42. package/dist/{completion-verifier-ClmJV_Yc.js.map → completion-verifier-DFyYFezn.js.map} +1 -1
  43. package/dist/contract/index.d.ts +10 -10
  44. package/dist/contract/index.js +15 -16
  45. package/dist/contract/index.js.map +1 -1
  46. package/dist/{cost-ledger-CS8R3IZj.js → cost-ledger-DfhStGcZ.js} +2 -2
  47. package/dist/{cost-ledger-CS8R3IZj.js.map → cost-ledger-DfhStGcZ.js.map} +1 -1
  48. package/dist/{decision-point-CNyoKOkz.js → decision-point-DJWievVw.js} +4 -4
  49. package/dist/{decision-point-CNyoKOkz.js.map → decision-point-DJWievVw.js.map} +1 -1
  50. package/dist/{default-registry-BNv7eB1C.d.ts → default-registry-BpGFsSpZ.d.ts} +7 -7
  51. package/dist/{default-registry-BNv7eB1C.d.ts.map → default-registry-BpGFsSpZ.d.ts.map} +1 -1
  52. package/dist/{default-registry-BB9_jzyH.js → default-registry-CdMtoY-s.js} +5 -5
  53. package/dist/{default-registry-BB9_jzyH.js.map → default-registry-CdMtoY-s.js.map} +1 -1
  54. package/dist/{define-agent-eval-DKVYlm-T.d.ts → define-agent-eval-DcK8mg63.d.ts} +7 -7
  55. package/dist/{define-agent-eval-DKVYlm-T.d.ts.map → define-agent-eval-DcK8mg63.d.ts.map} +1 -1
  56. package/dist/{define-agent-eval-CjF2nTA3.js → define-agent-eval-DuQNZajG.js} +7 -7
  57. package/dist/{define-agent-eval-CjF2nTA3.js.map → define-agent-eval-DuQNZajG.js.map} +1 -1
  58. package/dist/diagnosis/index.d.ts +2 -2
  59. package/dist/diagnosis/index.js +1 -1
  60. package/dist/{dspy-rlm-engine-_MEe2jIO.js → dspy-rlm-engine-cWyn8G1a.js} +4 -4
  61. package/dist/{dspy-rlm-engine-_MEe2jIO.js.map → dspy-rlm-engine-cWyn8G1a.js.map} +1 -1
  62. package/dist/{engine-rfV8Ff8V.d.ts → engine-BF8naBn7.d.ts} +2 -2
  63. package/dist/{engine-rfV8Ff8V.d.ts.map → engine-BF8naBn7.d.ts.map} +1 -1
  64. package/dist/{eval-campaign-CZSCjxVb.js → eval-campaign-LmpC_5fm.js} +2 -2
  65. package/dist/{eval-campaign-CZSCjxVb.js.map → eval-campaign-LmpC_5fm.js.map} +1 -1
  66. package/dist/{evaluation-DYAIkPQB.d.ts → evaluation-BCejQgkV.d.ts} +4 -4
  67. package/dist/{evaluation-DYAIkPQB.d.ts.map → evaluation-BCejQgkV.d.ts.map} +1 -1
  68. package/dist/{evaluation-BBI37mRe.js → evaluation-bU_bhlv-.js} +2 -2
  69. package/dist/{evaluation-BBI37mRe.js.map → evaluation-bU_bhlv-.js.map} +1 -1
  70. package/dist/evaluation.d.ts +1 -1
  71. package/dist/evaluation.js +1 -1
  72. package/dist/{exact-types-CaLLU1Pz.d.ts → exact-types-VAFjtOQN.d.ts} +2 -2
  73. package/dist/{exact-types-CaLLU1Pz.d.ts.map → exact-types-VAFjtOQN.d.ts.map} +1 -1
  74. package/dist/experiment/index.d.ts +3 -5
  75. package/dist/experiment/index.d.ts.map +1 -1
  76. package/dist/experiment/index.js +7 -12
  77. package/dist/experiment/index.js.map +1 -1
  78. package/dist/{exporters-BYBG9b1n.d.ts → exporters-dQKYD_Zo.d.ts} +2 -2
  79. package/dist/{exporters-BYBG9b1n.d.ts.map → exporters-dQKYD_Zo.d.ts.map} +1 -1
  80. package/dist/{external-optimizer-process-za-SsIap.js → external-optimizer-process-2ImGH_LR.js} +2 -2
  81. package/dist/{external-optimizer-process-za-SsIap.js.map → external-optimizer-process-2ImGH_LR.js.map} +1 -1
  82. package/dist/{external-optimizer-subprocess-B44kOfZb.js → external-optimizer-subprocess-_C_2yriN.js} +4 -4
  83. package/dist/{external-optimizer-subprocess-B44kOfZb.js.map → external-optimizer-subprocess-_C_2yriN.js.map} +1 -1
  84. package/dist/{feedback-trajectory-P37ju-gW.d.ts → feedback-trajectory-DTj8eVTR.d.ts} +3 -3
  85. package/dist/{feedback-trajectory-P37ju-gW.d.ts.map → feedback-trajectory-DTj8eVTR.d.ts.map} +1 -1
  86. package/dist/{findings-store-DWiBvJVM.js → findings-store-BSuaV3dN.js} +8 -25
  87. package/dist/findings-store-BSuaV3dN.js.map +1 -0
  88. package/dist/fuzz.js +2 -2
  89. package/dist/hosted/index.js +1 -1
  90. package/dist/{index-BJM4rwP2.d.ts → index-Bc8BZfzb.d.ts} +10 -9
  91. package/dist/index-Bc8BZfzb.d.ts.map +1 -0
  92. package/dist/index-BdLmBInV.d.ts +1099 -0
  93. package/dist/index-BdLmBInV.d.ts.map +1 -0
  94. package/dist/{index-BAPkHt5H.d.ts → index-CeYLLnfi.d.ts} +28 -128
  95. package/dist/index-CeYLLnfi.d.ts.map +1 -0
  96. package/dist/{index-C3t17kHu.d.ts → index-CzfdjM6o.d.ts} +7 -100
  97. package/dist/index-CzfdjM6o.d.ts.map +1 -0
  98. package/dist/{index-f09MX_H_.d.ts → index-DYNHOTTB.d.ts} +5 -5
  99. package/dist/{index-f09MX_H_.d.ts.map → index-DYNHOTTB.d.ts.map} +1 -1
  100. package/dist/{index-Dt6E4BHX.d.ts → index-D_eAFB3T.d.ts} +8 -8
  101. package/dist/{index-Dt6E4BHX.d.ts.map → index-D_eAFB3T.d.ts.map} +1 -1
  102. package/dist/{index-chNyKroE.d.ts → index-gSu9DUiw.d.ts} +8 -8
  103. package/dist/{index-chNyKroE.d.ts.map → index-gSu9DUiw.d.ts.map} +1 -1
  104. package/dist/{index-B1Bm9oJA.d.ts → index-lRKqfyg4.d.ts} +3 -7
  105. package/dist/index-lRKqfyg4.d.ts.map +1 -0
  106. package/dist/index.d.ts +29 -31
  107. package/dist/index.js +28 -164
  108. package/dist/index.js.map +1 -1
  109. package/dist/{integrity-BAdVzT8u.d.ts → integrity-CrmnGB2T.d.ts} +2 -2
  110. package/dist/{integrity-BAdVzT8u.d.ts.map → integrity-CrmnGB2T.d.ts.map} +1 -1
  111. package/dist/{journal-C1uLJi0w.js → journal-CTX5uK-n.js} +36 -26
  112. package/dist/journal-CTX5uK-n.js.map +1 -0
  113. package/dist/{judge-gate-CIlBrn6q.js → judge-gate-BliY81A0.js} +3 -3
  114. package/dist/{judge-gate-CIlBrn6q.js.map → judge-gate-BliY81A0.js.map} +1 -1
  115. package/dist/{kind-factory-Cfz8DUCc.js → kind-factory-CV0FNCMM.js} +2 -2
  116. package/dist/{kind-factory-Cfz8DUCc.js.map → kind-factory-CV0FNCMM.js.map} +1 -1
  117. package/dist/ledger-core/index.d.ts +1 -1
  118. package/dist/ledger-core/index.js +2 -2
  119. package/dist/{ledger-core-CfT-FzPf.js → ledger-core-24IxvmVY.js} +2 -2
  120. package/dist/{ledger-core-CfT-FzPf.js.map → ledger-core-24IxvmVY.js.map} +1 -1
  121. package/dist/{llm-client-BdSiZ4qz.js → llm-client-DMMSg-Ro.js} +2 -2
  122. package/dist/{llm-client-BdSiZ4qz.js.map → llm-client-DMMSg-Ro.js.map} +1 -1
  123. package/dist/{llm-judge-CHLvjbVR.js → llm-judge-Bnxuwjxl.js} +15 -16
  124. package/dist/{llm-judge-CHLvjbVR.js.map → llm-judge-Bnxuwjxl.js.map} +1 -1
  125. package/dist/{matrix-Cy3oy7Rq.d.ts → matrix-D6zEwLvE.d.ts} +2 -2
  126. package/dist/{matrix-Cy3oy7Rq.d.ts.map → matrix-D6zEwLvE.d.ts.map} +1 -1
  127. package/dist/meta-eval/index.d.ts +2 -2
  128. package/dist/meta-eval/index.js +7 -7
  129. package/dist/{metrics-DNCAUtuB.js → metrics-zALlR17s.js} +16 -17
  130. package/dist/metrics-zALlR17s.js.map +1 -0
  131. package/dist/multishot/golden/index.d.ts +1 -1
  132. package/dist/multishot/index.d.ts +2 -2
  133. package/dist/multishot/index.js +1 -1
  134. package/dist/openapi.json +1 -1
  135. package/dist/{outcome-observations-DZu5hLYF.js → outcome-observations-BpicIVQi.js} +2 -3
  136. package/dist/{outcome-observations-DZu5hLYF.js.map → outcome-observations-BpicIVQi.js.map} +1 -1
  137. package/dist/paired-arms-Dep5tbsw.js +338 -0
  138. package/dist/paired-arms-Dep5tbsw.js.map +1 -0
  139. package/dist/{paired-promotion-decision-BDnqepZ1.d.ts → paired-promotion-decision-BNzPfXDw.d.ts} +3 -113
  140. package/dist/paired-promotion-decision-BNzPfXDw.d.ts.map +1 -0
  141. package/dist/{paired-promotion-decision-CiueaTTj.js → paired-promotion-decision-Nt4CkkOT.js} +2 -3
  142. package/dist/{paired-promotion-decision-CiueaTTj.js.map → paired-promotion-decision-Nt4CkkOT.js.map} +1 -1
  143. package/dist/{pareto-B34N-vnn.js → pareto-C445lnEH.js} +6 -9
  144. package/dist/{pareto-B34N-vnn.js.map → pareto-C445lnEH.js.map} +1 -1
  145. package/dist/pipelines/index.js +1 -1
  146. package/dist/{prime-protocol-DKRk4l4U.d.ts → prime-protocol-D1NkJRuD.d.ts} +2 -2
  147. package/dist/{prime-protocol-DKRk4l4U.d.ts.map → prime-protocol-D1NkJRuD.d.ts.map} +1 -1
  148. package/dist/{promotion-gate-DOkgJcLW.d.ts → promotion-gate-DjAsmBSZ.d.ts} +3 -67
  149. package/dist/promotion-gate-DjAsmBSZ.d.ts.map +1 -0
  150. package/dist/{promotion-policy-DLPcEnCf.js → promotion-policy-CUWOv01m.js} +4 -4
  151. package/dist/{promotion-policy-DLPcEnCf.js.map → promotion-policy-CUWOv01m.js.map} +1 -1
  152. package/dist/{proposal-findings-CZJkS_GY.js → proposal-findings-DWs94yT8.js} +2 -2
  153. package/dist/{proposal-findings-CZJkS_GY.js.map → proposal-findings-DWs94yT8.js.map} +1 -1
  154. package/dist/{registry-Ck7w-rr5.d.ts → registry-BAcEbzKm.d.ts} +4 -4
  155. package/dist/{registry-Ck7w-rr5.d.ts.map → registry-BAcEbzKm.d.ts.map} +1 -1
  156. package/dist/{release-confidence-nfQNh3eb.js → release-confidence-DDrkmWxT.js} +2 -2
  157. package/dist/{release-confidence-nfQNh3eb.js.map → release-confidence-DDrkmWxT.js.map} +1 -1
  158. package/dist/reporting.d.ts +4 -5
  159. package/dist/reporting.d.ts.map +1 -1
  160. package/dist/reporting.js +5 -7
  161. package/dist/reporting.js.map +1 -1
  162. package/dist/{researcher-CLnNJ7Or.d.ts → researcher-D35yo0B8.d.ts} +4 -4
  163. package/dist/{researcher-CLnNJ7Or.d.ts.map → researcher-D35yo0B8.d.ts.map} +1 -1
  164. package/dist/{reward-hacking-B88f-Kh7.js → reward-hacking-DRb8K6N1.js} +2 -3
  165. package/dist/{reward-hacking-B88f-Kh7.js.map → reward-hacking-DRb8K6N1.js.map} +1 -1
  166. package/dist/rl.d.ts +9 -8
  167. package/dist/rl.d.ts.map +1 -1
  168. package/dist/rl.js +8 -10
  169. package/dist/rl.js.map +1 -1
  170. package/dist/rollout/index.d.ts +4 -4
  171. package/dist/rollout/index.js +1 -1
  172. package/dist/{rollout-Cu7kHGIe.js → rollout-DKa54qer.js} +2 -2
  173. package/dist/{rollout-Cu7kHGIe.js.map → rollout-DKa54qer.js.map} +1 -1
  174. package/dist/{rubric-predictive-validity-D_6ZPTNR.js → rubric-predictive-validity-BMS7SUyh.js} +2 -2
  175. package/dist/{rubric-predictive-validity-D_6ZPTNR.js.map → rubric-predictive-validity-BMS7SUyh.js.map} +1 -1
  176. package/dist/{run-record-CbUi2adH.js → run-record-CIflWk6i.js} +2 -2
  177. package/dist/{run-record-CbUi2adH.js.map → run-record-CIflWk6i.js.map} +1 -1
  178. package/dist/{runtime-rollouts-kGn1K5ut.js → runtime-rollouts-CfRyjk60.js} +2 -2
  179. package/dist/{runtime-rollouts-kGn1K5ut.js.map → runtime-rollouts-CfRyjk60.js.map} +1 -1
  180. package/dist/{schema-CfoA9U_U.d.ts → schema-PDKQ_iNE.d.ts} +2 -131
  181. package/dist/schema-PDKQ_iNE.d.ts.map +1 -0
  182. package/dist/search/index.d.ts +2 -2
  183. package/dist/search/index.js +2 -2
  184. package/dist/{search-kernel-kwO-sgCq.d.ts → search-kernel-Ds2zILpY.d.ts} +4 -4
  185. package/dist/{search-kernel-kwO-sgCq.d.ts.map → search-kernel-Ds2zILpY.d.ts.map} +1 -1
  186. package/dist/{search-ledger-CV_bQQed.js → search-ledger-Dk-yk5Li.js} +4 -4
  187. package/dist/{search-ledger-CV_bQQed.js.map → search-ledger-Dk-yk5Li.js.map} +1 -1
  188. package/dist/{search-ledger-file-DTBD6X-y.js → search-ledger-file-BhOdgYIt.js} +3 -3
  189. package/dist/{search-ledger-file-DTBD6X-y.js.map → search-ledger-file-BhOdgYIt.js.map} +1 -1
  190. package/dist/{search-shipper-CA3ooBbC.js → search-shipper-Dm-_Dtvy.js} +3 -3
  191. package/dist/{search-shipper-CA3ooBbC.js.map → search-shipper-Dm-_Dtvy.js.map} +1 -1
  192. package/dist/{search-summary-DBMjdecs.js → search-summary-BSftVrGY.js} +5 -5
  193. package/dist/{search-summary-DBMjdecs.js.map → search-summary-BSftVrGY.js.map} +1 -1
  194. package/dist/{sequential-Bb_pdTqG.d.ts → sequential-B9p6uoV8.d.ts} +9 -2
  195. package/dist/{sequential-Bb_pdTqG.d.ts.map → sequential-B9p6uoV8.d.ts.map} +1 -1
  196. package/dist/{sequential-Bjs5roiK.js → sequential-CAksw6EU.js} +32 -2
  197. package/dist/{sequential-Bjs5roiK.js.map → sequential-CAksw6EU.js.map} +1 -1
  198. package/dist/{sequential-BPbvgzfe.js → sequential-CqG6aLWS.js} +3 -3
  199. package/dist/{sequential-BPbvgzfe.js.map → sequential-CqG6aLWS.js.map} +1 -1
  200. package/dist/{server-CPKyf3bz.js → server-DFVwfoZq.js} +3 -3
  201. package/dist/{server-CPKyf3bz.js.map → server-DFVwfoZq.js.map} +1 -1
  202. package/dist/{single-run-lock-BGlW3OSk.js → single-run-lock-CUj2tjxT.js} +2 -2
  203. package/dist/{single-run-lock-BGlW3OSk.js.map → single-run-lock-CUj2tjxT.js.map} +1 -1
  204. package/dist/{skillopt-optimization-method-D72XZZfR.js → skillopt-optimization-method-DYwEndON.js} +12 -12
  205. package/dist/{skillopt-optimization-method-D72XZZfR.js.map → skillopt-optimization-method-DYwEndON.js.map} +1 -1
  206. package/dist/{statistical-heldout-_dXihc9T.d.ts → statistical-heldout--0b1lgx4.d.ts} +6 -282
  207. package/dist/statistical-heldout--0b1lgx4.d.ts.map +1 -0
  208. package/dist/{statistical-heldout-NBxC7jGo.js → statistical-heldout-D6i58CJ5.js} +3 -3
  209. package/dist/{statistical-heldout-NBxC7jGo.js.map → statistical-heldout-D6i58CJ5.js.map} +1 -1
  210. package/dist/statistics-DCZIC-qT.js +2627 -0
  211. package/dist/statistics-DCZIC-qT.js.map +1 -0
  212. package/dist/statistics.d.ts +3 -0
  213. package/dist/statistics.js +3 -0
  214. package/dist/{store-otlp-BfPRa2p8.js → store-otlp-C-jyj3WX.js} +2 -2
  215. package/dist/{store-otlp-BfPRa2p8.js.map → store-otlp-C-jyj3WX.js.map} +1 -1
  216. package/dist/{store-tool-spans-BgwVHXma.d.ts → store-tool-spans-B3z_Qb5u.d.ts} +5 -5
  217. package/dist/{store-tool-spans-BgwVHXma.d.ts.map → store-tool-spans-B3z_Qb5u.d.ts.map} +1 -1
  218. package/dist/{store-tool-spans-BrSWHB9O.js → store-tool-spans-DalWlKY8.js} +3 -3
  219. package/dist/{store-tool-spans-BrSWHB9O.js.map → store-tool-spans-DalWlKY8.js.map} +1 -1
  220. package/dist/{summary-report-0La5vejY.d.ts → summary-report-Cv1AC-iv.d.ts} +2 -2
  221. package/dist/{summary-report-0La5vejY.d.ts.map → summary-report-Cv1AC-iv.d.ts.map} +1 -1
  222. package/dist/{summary-report-C3IJvp0i.js → summary-report-D_uussI3.js} +4 -52
  223. package/dist/summary-report-D_uussI3.js.map +1 -0
  224. package/dist/supervisor-run/index.d.ts +2 -2
  225. package/dist/supervisor-run/index.js +1 -1
  226. package/dist/{systemone-CBvL1gx-.d.ts → systemone-C3xyEKvG.d.ts} +7 -7
  227. package/dist/{systemone-CBvL1gx-.d.ts.map → systemone-C3xyEKvG.d.ts.map} +1 -1
  228. package/dist/{systemone-review-nbuMxxmi.d.ts → systemone-review-CToBl1oa.d.ts} +2 -2
  229. package/dist/{systemone-review-nbuMxxmi.d.ts.map → systemone-review-CToBl1oa.d.ts.map} +1 -1
  230. package/dist/systemone.d.ts +3 -3
  231. package/dist/systemone.js +2 -2
  232. package/dist/{tool-groups-BQsjZD9F.d.ts → tool-groups-R5RO9OHn.d.ts} +3 -3
  233. package/dist/tool-groups-R5RO9OHn.d.ts.map +1 -0
  234. package/dist/{tool-waste-Czt3aWID.js → tool-waste-DEhKfiIE.js} +2 -3
  235. package/dist/{tool-waste-Czt3aWID.js.map → tool-waste-DEhKfiIE.js.map} +1 -1
  236. package/dist/{trace-questions-CpTrtEcm.d.ts → trace-questions-BY6taxnl.d.ts} +3 -3
  237. package/dist/{trace-questions-CpTrtEcm.d.ts.map → trace-questions-BY6taxnl.d.ts.map} +1 -1
  238. package/dist/trace-repair/index.d.ts +1 -1
  239. package/dist/trace-repair/index.js +1 -2
  240. package/dist/trace-repair/index.js.map +1 -1
  241. package/dist/traces.d.ts +5 -5
  242. package/dist/traces.js +3 -3
  243. package/dist/{tree-DPwgM2LX.js → tree-B2y1UR8o.js} +5 -7
  244. package/dist/{tree-DPwgM2LX.js.map → tree-B2y1UR8o.js.map} +1 -1
  245. package/dist/{types-DNB9hIXa.d.ts → types-BAJ2Hb-d.d.ts} +3 -2
  246. package/dist/types-BAJ2Hb-d.d.ts.map +1 -0
  247. package/dist/{types-D91tnhzf.d.ts → types-BwF--ZRz.d.ts} +2 -2
  248. package/dist/{types-D91tnhzf.d.ts.map → types-BwF--ZRz.d.ts.map} +1 -1
  249. package/dist/{types-CBkDo7ja.d.ts → types-CeMZYsNF.d.ts} +6 -5
  250. package/dist/types-CeMZYsNF.d.ts.map +1 -0
  251. package/dist/{types-B9s9Xo5_.d.ts → types-kBMNdo1X.d.ts} +3 -9
  252. package/dist/types-kBMNdo1X.d.ts.map +1 -0
  253. package/dist/wire/index.d.ts +4 -4
  254. package/dist/wire/index.js +1 -1
  255. package/docs/design/statistics-decisions.md +38 -364
  256. package/docs/design.md +1 -1
  257. package/docs/research-report-methodology.md +1 -1
  258. package/package.json +6 -1
  259. package/dist/agreement-irr-DXcXEt4I.js +0 -182
  260. package/dist/agreement-irr-DXcXEt4I.js.map +0 -1
  261. package/dist/analyze-runs-C7vWBDhl.js.map +0 -1
  262. package/dist/benchmark-command-Bqqvv9Tk.js.map +0 -1
  263. package/dist/cluster-bootstrap-BteuR1hg.js +0 -65
  264. package/dist/cluster-bootstrap-BteuR1hg.js.map +0 -1
  265. package/dist/descriptive-B3Eb7tX0.js +0 -229
  266. package/dist/descriptive-B3Eb7tX0.js.map +0 -1
  267. package/dist/findings-store-DWiBvJVM.js.map +0 -1
  268. package/dist/index-B1Bm9oJA.d.ts.map +0 -1
  269. package/dist/index-BAPkHt5H.d.ts.map +0 -1
  270. package/dist/index-BJM4rwP2.d.ts.map +0 -1
  271. package/dist/index-C3t17kHu.d.ts.map +0 -1
  272. package/dist/journal-C1uLJi0w.js.map +0 -1
  273. package/dist/judge-calibration-DKR6Xi-w.js +0 -319
  274. package/dist/judge-calibration-DKR6Xi-w.js.map +0 -1
  275. package/dist/judge-calibration-DnrbQaXI.d.ts +0 -144
  276. package/dist/judge-calibration-DnrbQaXI.d.ts.map +0 -1
  277. package/dist/mean-D1d6gedE.js +0 -284
  278. package/dist/mean-D1d6gedE.js.map +0 -1
  279. package/dist/metrics-DNCAUtuB.js.map +0 -1
  280. package/dist/multiplicity-DAd4xaDC.js +0 -100
  281. package/dist/multiplicity-DAd4xaDC.js.map +0 -1
  282. package/dist/multiplicity-D_SEsc5j.d.ts +0 -41
  283. package/dist/multiplicity-D_SEsc5j.d.ts.map +0 -1
  284. package/dist/paired-arms-3-tsXvvC.js +0 -740
  285. package/dist/paired-arms-3-tsXvvC.js.map +0 -1
  286. package/dist/paired-binary-CMzmSSd5.js +0 -372
  287. package/dist/paired-binary-CMzmSSd5.js.map +0 -1
  288. package/dist/paired-promotion-decision-BDnqepZ1.d.ts.map +0 -1
  289. package/dist/paired-tests-Buh6feJ4.js +0 -211
  290. package/dist/paired-tests-Buh6feJ4.js.map +0 -1
  291. package/dist/power-and-mde-g3vOn0XK.js +0 -99
  292. package/dist/power-and-mde-g3vOn0XK.js.map +0 -1
  293. package/dist/promotion-gate-DOkgJcLW.d.ts.map +0 -1
  294. package/dist/random-BN150Q_X.d.ts +0 -79
  295. package/dist/random-BN150Q_X.d.ts.map +0 -1
  296. package/dist/schema-CfoA9U_U.d.ts.map +0 -1
  297. package/dist/sequential-eprocess-C1YLwFaz.js +0 -129
  298. package/dist/sequential-eprocess-C1YLwFaz.js.map +0 -1
  299. package/dist/statistical-heldout-_dXihc9T.d.ts.map +0 -1
  300. package/dist/summary-report-C3IJvp0i.js.map +0 -1
  301. package/dist/tool-groups-BQsjZD9F.d.ts.map +0 -1
  302. package/dist/types-0KglnQ9o.d.ts.map +0 -1
  303. package/dist/types-B9s9Xo5_.d.ts.map +0 -1
  304. package/dist/types-CBkDo7ja.d.ts.map +0 -1
  305. package/dist/types-DNB9hIXa.d.ts.map +0 -1
@@ -1,740 +0,0 @@
1
- import { s as ValidationError } from "./errors-DeEEV9Vx.js";
2
- import { a as findingTreatmentSchema } from "./finding-composition-Belh_qU3.js";
3
- import { a as assertFiniteSample, d as symmetricTwoSampleSeed, h as lnGamma, l as makeRng, s as binomialSignTwoSided } from "./mean-D1d6gedE.js";
4
- import { r as pairedRiskDifference, t as mcnemar } from "./paired-binary-CMzmSSd5.js";
5
- import { r as pairedBootstrap } from "./paired-tests-Buh6feJ4.js";
6
- // src/arm-populations.ts
7
- const keyOf = (row) => JSON.stringify([
8
- row.arm,
9
- row.pairKey,
10
- row.repKey ?? null
11
- ]);
12
- function checkIdentity(row) {
13
- for (const value of [
14
- row.arm,
15
- row.pairKey,
16
- ...row.repKey === void 0 ? [] : [row.repKey]
17
- ]) if (typeof value !== "string" || !value.trim()) throw new TypeError("Arm assignments require nonempty identities");
18
- if (row.treatment !== void 0) {
19
- if (!Array.isArray(row.treatment)) throw new TypeError("Arm treatment must be an array");
20
- for (const value of row.treatment) findingTreatmentSchema.parse(value);
21
- if (new Set(row.treatment.map((t) => t.id)).size !== row.treatment.length) throw new TypeError("Duplicate arm treatment id");
22
- }
23
- }
24
- function checkObservation(row) {
25
- checkIdentity(row);
26
- if (row.pass != null && typeof row.pass !== "boolean") throw new TypeError("Invalid arm pass value");
27
- if (row.formation !== void 0) {
28
- if (row.formation === null || typeof row.formation !== "object") throw new TypeError("Invalid formation verdict");
29
- if (row.formation.formed !== null && typeof row.formation.formed !== "boolean") throw new TypeError("Invalid formation state");
30
- if (row.formation.reason !== void 0 && typeof row.formation.reason !== "string") throw new TypeError("Invalid formation reason");
31
- }
32
- for (const value of Object.values(row.metrics ?? {})) if (value !== null && !Number.isFinite(value)) throw new TypeError("Non-finite arm metric");
33
- }
34
- /** One roster join serves comparison and both denominators; no outcomes are inferred from formation. */
35
- function prepareArmPopulations(observations, assignments, options) {
36
- const arms = [options.baselineArm, options.treatmentArm];
37
- const roster = /* @__PURE__ */ new Map();
38
- for (const entry of assignments) {
39
- if (!arms.includes(entry.arm)) continue;
40
- checkIdentity(entry);
41
- const key = keyOf(entry);
42
- if (roster.has(key)) throw new TypeError("Duplicate arm assignment");
43
- roster.set(key, structuredClone(entry));
44
- }
45
- for (const arm of arms) if (![...roster.values()].some((r) => r.arm === arm)) throw new TypeError(`No assignment roster for arm '${arm}'`);
46
- const actual = /* @__PURE__ */ new Map();
47
- for (const row of observations) {
48
- if (!arms.includes(row.arm)) continue;
49
- checkObservation(row);
50
- const key = keyOf(row);
51
- if (!roster.has(key)) throw new TypeError("Observed seed is outside the assignment roster");
52
- if (actual.has(key)) throw new TypeError("Duplicate arm observation");
53
- actual.set(key, row);
54
- }
55
- const ordered = [...roster.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
56
- const rows = ordered.map(([key, entry]) => actual.get(key) ?? entry);
57
- const metricNames = options.metricNames ?? [...new Set([...actual.values()].flatMap((r) => Object.keys(r.metrics ?? {})))].sort();
58
- return {
59
- rows,
60
- readings: arms.map((arm) => {
61
- const declared = ordered.filter(([, r]) => r.arm === arm);
62
- const asAssigned = declared.map(([key]) => actual.get(key));
63
- const asFormed = asAssigned.filter((row) => row?.formation?.formed === true);
64
- return {
65
- arm,
66
- assignments: declared.map(([, r]) => r),
67
- missingObservations: asAssigned.filter((r) => r === void 0).length,
68
- formation: {
69
- formed: asFormed.length,
70
- notFormed: asAssigned.filter((r) => r?.formation?.formed === false).length,
71
- unknown: asAssigned.filter((r) => r?.formation?.formed == null).length
72
- },
73
- asAssigned: summarize(asAssigned, metricNames),
74
- asFormed: summarize(asFormed, metricNames)
75
- };
76
- })
77
- };
78
- }
79
- function summarize(rows, names) {
80
- const passed = rows.filter((r) => r?.pass === true).length;
81
- const failed = rows.filter((r) => r?.pass === false).length;
82
- const missingOutcomes = rows.length - passed - failed;
83
- const metrics = Object.fromEntries(names.map((name) => {
84
- const values = rows.map((r) => r?.metrics?.[name]).filter((x) => x != null);
85
- const sum = values.length ? values.reduce((s, v) => s + v, 0) : null;
86
- return [name, {
87
- n: values.length,
88
- missing: rows.length - values.length,
89
- sum,
90
- mean: sum === null ? null : sum / values.length
91
- }];
92
- }));
93
- return {
94
- n: rows.length,
95
- passed,
96
- failed,
97
- missingOutcomes,
98
- passRate: rows.length && !missingOutcomes ? passed / rows.length : null,
99
- metrics
100
- };
101
- }
102
- // src/math/normal.ts
103
- /**
104
- * Standard normal cumulative distribution using Abramowitz and Stegun 7.1.26.
105
- *
106
- * The approximation is evaluated as erf(x / sqrt(2)). Computing the negative
107
- * tail from the complementary term avoids cancellation when x is far below 0.
108
- * The maximum absolute CDF error is approximately 7.5e-8.
109
- */
110
- function normalCdf(x) {
111
- if (x === 0) return .5;
112
- const a1 = .254829592;
113
- const a2 = -.284496736;
114
- const a3 = 1.421413741;
115
- const a4 = -1.453152027;
116
- const a5 = 1.061405429;
117
- const p = .3275911;
118
- const scaled = Math.abs(x) / Math.SQRT2;
119
- const t = 1 / (1 + p * scaled);
120
- const complement = ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t * Math.exp(-scaled * scaled);
121
- return x < 0 ? complement / 2 : 1 - complement / 2;
122
- }
123
- // src/statistics/rank-tests.ts
124
- /** Maximum dynamic-programming cells used by an exact two-sample rank test. */
125
- const MANN_WHITNEY_EXACT_MAX_STATES = 8192;
126
- /** Maximum inner-loop transitions used by an exact two-sample rank test. */
127
- const MANN_WHITNEY_EXACT_MAX_WORK = 25e4;
128
- /** Non-zero differences up to which the signed-rank null is enumerated exactly. */
129
- const WILCOXON_EXACT_MAX_N = 20;
130
- /** Resamples used when a rank test falls back to Monte Carlo permutation. */
131
- const DEFAULT_PERMUTATIONS = 1e5;
132
- /**
133
- * Mann-Whitney U — two independent samples, no distributional assumption.
134
- *
135
- * Exact conditional (permutation) p by default when the dynamic program fits
136
- * {@link MANN_WHITNEY_EXACT_MAX_STATES} cells and
137
- * {@link MANN_WHITNEY_EXACT_MAX_WORK} transitions, seeded Monte Carlo
138
- * permutation above those limits. This keeps imbalanced designs such as 1+24
139
- * exact without admitting expensive balanced designs merely because they have
140
- * the same total size. Throws on non-finite input and on `method:
141
- * 'asymptotic'` where an exact answer is available. Empty input yields `p = 1,
142
- * pFloor = 1` — no design, no attainable evidence.
143
- */
144
- function mannWhitneyU(a, b, opts = {}) {
145
- assertFiniteSample("mannWhitneyU", "a", a);
146
- assertFiniteSample("mannWhitneyU", "b", b);
147
- const n1 = a.length;
148
- const n2 = b.length;
149
- if (n1 === 0 || n2 === 0) return {
150
- u: 0,
151
- uA: 0,
152
- p: 1,
153
- method: "exact",
154
- pFloor: 1
155
- };
156
- const total = n1 + n2;
157
- const combined = [...a.map((v) => ({
158
- v,
159
- fromA: true
160
- })), ...b.map((v) => ({
161
- v,
162
- fromA: false
163
- }))].sort((x, y) => x.v - y.v);
164
- const { midranks, tieTerm } = midranksWithTieTerm(combined.map((entry) => entry.v));
165
- let rankSumA = 0;
166
- for (let k = 0; k < total; k++) if (combined[k].fromA) rankSumA += midranks[k];
167
- const uA = rankSumA - n1 * (n1 + 1) / 2;
168
- const u = Math.min(uA, n1 * n2 - uA);
169
- const doubled = midranks.map((rank) => Math.round(rank * 2));
170
- const doubledDeviation = Math.abs(2 * uA - n1 * n2);
171
- const selectedN = Math.min(n1, n2);
172
- const otherN = total - selectedN;
173
- const exactCost = exactTwoSampleCost(doubled, selectedN);
174
- const designFloor = exactTwoSampleFloor(doubled, selectedN);
175
- const method = selectRankTestMethod("mannWhitneyU", opts.method ?? "auto", `n1=${n1}, n2=${n2}`, exactCost.states <= MANN_WHITNEY_EXACT_MAX_STATES && exactCost.work <= MANN_WHITNEY_EXACT_MAX_WORK, designFloor, `${MANN_WHITNEY_EXACT_MAX_STATES.toLocaleString("en-US")} states and ${MANN_WHITNEY_EXACT_MAX_WORK.toLocaleString("en-US")} transitions`);
176
- if (method === "exact") {
177
- const { p, pFloor } = exactTwoSampleP(doubled, selectedN, otherN, doubledDeviation);
178
- return {
179
- u,
180
- uA,
181
- p,
182
- method,
183
- pFloor
184
- };
185
- }
186
- if (method === "asymptotic") return {
187
- u,
188
- uA,
189
- p: asymptoticTwoSidedP(doubledDeviation / 2, twoSampleSigma(n1, n2, total, tieTerm)),
190
- method,
191
- pFloor: designFloor
192
- };
193
- const permutations = resolvePermutations("mannWhitneyU", opts.permutations);
194
- const rng = opts.seed === void 0 ? makeRng(symmetricTwoSampleSeed(a, b)) : makeRng(opts.seed);
195
- let atLeastAsExtreme = 0;
196
- const pool = [...doubled];
197
- for (let iteration = 0; iteration < permutations; iteration++) {
198
- let doubledRankSum = 0;
199
- for (let k = 0; k < selectedN; k++) {
200
- const pick = k + Math.floor(rng() * (total - k));
201
- const swapped = pool[pick];
202
- pool[pick] = pool[k];
203
- pool[k] = swapped;
204
- doubledRankSum += swapped;
205
- }
206
- if (Math.abs(doubledRankSum - selectedN * (selectedN + 1) - selectedN * otherN) >= doubledDeviation) atLeastAsExtreme++;
207
- }
208
- const pFloor = Math.max(1 / (permutations + 1), designFloor);
209
- return {
210
- u,
211
- uA,
212
- p: Math.max((1 + atLeastAsExtreme) / (permutations + 1), pFloor),
213
- method,
214
- pFloor
215
- };
216
- }
217
- /**
218
- * Wilcoxon signed-rank — paired, no distributional assumption on the deltas.
219
- *
220
- * Exact conditional (sign-flip) p by default at `n ≤
221
- * {@link WILCOXON_EXACT_MAX_N}` non-zero differences, seeded Monte Carlo
222
- * permutation above it. Throws on non-finite input and on `method:
223
- * 'asymptotic'` where an exact answer is available.
224
- *
225
- * `n` is the count of NON-ZERO differences: exact ties are dropped before
226
- * ranking, so a run of tied pairs shrinks the design and raises `pFloor`.
227
- * All-tied input yields `p = 1, pFloor = 1` — no attainable evidence, which
228
- * `pFloor` states rather than leaving `p = 1` to be read as a measured null.
229
- */
230
- function wilcoxonSignedRank(before, after, opts = {}) {
231
- if (before.length !== after.length) throw new ValidationError(`wilcoxonSignedRank: unequal sample sizes (${before.length} vs ${after.length})`);
232
- assertFiniteSample("wilcoxonSignedRank", "before", before);
233
- assertFiniteSample("wilcoxonSignedRank", "after", after);
234
- const diffs = before.map((b, i) => after[i] - b).filter((d) => d !== 0);
235
- const n = diffs.length;
236
- if (n === 0) return {
237
- w: 0,
238
- p: 1,
239
- method: "exact",
240
- pFloor: 1,
241
- nNonZero: 0
242
- };
243
- const abs = Math.abs(diffs[0]);
244
- const allEqualAbs = diffs.every((d) => Math.abs(d) === abs);
245
- if ((opts.method === void 0 || opts.method === "auto") && allEqualAbs) {
246
- const positive = diffs.filter((d) => d > 0).length;
247
- const negative = n - positive;
248
- return {
249
- w: positive * (n + 1) / 2,
250
- p: binomialSignTwoSided(positive, negative),
251
- method: "exact",
252
- pFloor: Math.min(1, 2 ** (1 - n)),
253
- nNonZero: n
254
- };
255
- }
256
- const order = diffs.map((d, i) => ({
257
- abs: Math.abs(d),
258
- i
259
- })).sort((x, y) => x.abs - y.abs);
260
- const { midranks, tieTerm } = midranksWithTieTerm(order.map((entry) => entry.abs));
261
- const ranks = new Array(n);
262
- for (let k = 0; k < n; k++) ranks[order[k].i] = midranks[k];
263
- let wPlus = 0;
264
- for (let k = 0; k < n; k++) if (diffs[k] > 0) wPlus += ranks[k];
265
- const doubled = midranks.map((rank) => Math.round(rank * 2));
266
- const doubledDeviation = Math.abs(2 * wPlus - n * (n + 1) / 2);
267
- const designFloor = Math.min(1, 2 ** (1 - n));
268
- const method = selectRankTestMethod("wilcoxonSignedRank", opts.method ?? "auto", `n=${n} non-zero differences`, n <= WILCOXON_EXACT_MAX_N, designFloor, `${WILCOXON_EXACT_MAX_N} non-zero differences`);
269
- if (method === "exact") {
270
- const { p, pFloor } = exactSignedRankP(doubled, doubledDeviation);
271
- return {
272
- w: wPlus,
273
- p,
274
- method,
275
- pFloor,
276
- nNonZero: n
277
- };
278
- }
279
- if (method === "asymptotic") {
280
- const variance = n * (n + 1) * (2 * n + 1) / 24 - tieTerm / 48;
281
- return {
282
- w: wPlus,
283
- p: asymptoticTwoSidedP(doubledDeviation / 2, Math.sqrt(variance)),
284
- method,
285
- pFloor: designFloor,
286
- nNonZero: n
287
- };
288
- }
289
- const permutations = resolvePermutations("wilcoxonSignedRank", opts.permutations);
290
- const rng = makeRng(opts.seed, before, after);
291
- const doubledCentre = n * (n + 1) / 2;
292
- let atLeastAsExtreme = 0;
293
- for (let iteration = 0; iteration < permutations; iteration++) {
294
- let doubledWPlus = 0;
295
- for (let k = 0; k < n; k++) if (rng() < .5) doubledWPlus += doubled[k];
296
- if (Math.abs(doubledWPlus - doubledCentre) >= doubledDeviation) atLeastAsExtreme++;
297
- }
298
- return {
299
- w: wPlus,
300
- p: (1 + atLeastAsExtreme) / (permutations + 1),
301
- method,
302
- pFloor: Math.max(1 / (permutations + 1), designFloor),
303
- nNonZero: n
304
- };
305
- }
306
- /**
307
- * Average ranks over an ASCENDING-sorted array, plus `Σ(t³ − t)` over tie
308
- * groups of size `t` — the correction term both asymptotic rank-test variances
309
- * need.
310
- */
311
- function midranksWithTieTerm(sorted) {
312
- const midranks = new Array(sorted.length);
313
- let tieTerm = 0;
314
- let i = 0;
315
- while (i < sorted.length) {
316
- let j = i;
317
- while (j < sorted.length && sorted[j] === sorted[i]) j++;
318
- const average = (i + 1 + j) / 2;
319
- for (let k = i; k < j; k++) midranks[k] = average;
320
- const groupSize = j - i;
321
- if (groupSize > 1) tieTerm += groupSize ** 3 - groupSize;
322
- i = j;
323
- }
324
- return {
325
- midranks,
326
- tieTerm
327
- };
328
- }
329
- function selectRankTestMethod(fn, request, design, exactFeasible, designFloor, threshold) {
330
- if (request === "auto") return exactFeasible ? "exact" : "permutation";
331
- if (request === "exact") {
332
- if (exactFeasible) return "exact";
333
- throw new ValidationError(`${fn}: method 'exact' is out of range at ${design} — enumeration is bounded by ${threshold}. Use 'auto' for the seeded Monte Carlo permutation, which converges to the same answer.`);
334
- }
335
- if (exactFeasible) throw new ValidationError(`${fn}: method 'asymptotic' is refused at ${design} — the exact p-grid at this design starts at ${formatProbability(designFloor)}, so an asymptotic p below it describes no attainable outcome. Use method 'exact' (the default) or add repetitions past ${threshold}.`);
336
- return "asymptotic";
337
- }
338
- function resolvePermutations(fn, permutations) {
339
- if (permutations === void 0) return DEFAULT_PERMUTATIONS;
340
- if (!Number.isInteger(permutations) || permutations < 1) throw new ValidationError(`${fn}: permutations must be a positive integer, got ${permutations}`);
341
- return permutations;
342
- }
343
- /** Two-sided normal-approximation tail with the continuity correction. */
344
- function asymptoticTwoSidedP(deviation, sigma) {
345
- if (!(sigma > 0)) return 1;
346
- return Math.min(1, 2 * (1 - normalCdf(Math.max(0, deviation - .5) / sigma)));
347
- }
348
- /** SD of U under the permutation null, corrected for the realised ties. The
349
- * tie term reduces (N+1) and reaches it exactly when every value is tied, so
350
- * the variance floors at 0 rather than going negative. */
351
- function twoSampleSigma(n1, n2, total, tieTerm) {
352
- if (total < 2) return 0;
353
- const variance = n1 * n2 / 12 * (total + 1 - tieTerm / (total * (total - 1)));
354
- return Math.sqrt(Math.max(0, variance));
355
- }
356
- function logChoose(n, k) {
357
- return lnGamma(n + 1) - lnGamma(k + 1) - lnGamma(n - k + 1);
358
- }
359
- function formatProbability(value) {
360
- return value >= 1e-4 || value === 0 ? value.toFixed(4) : value.toExponential(3);
361
- }
362
- /**
363
- * Exact DP allocation and loop count for this observed rank vector.
364
- *
365
- * The smaller arm is sufficient because selecting its complement produces the
366
- * same two-sided U deviation while using fewer rows in the state table.
367
- */
368
- function exactTwoSampleCost(doubledRanks, selectedN) {
369
- const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0);
370
- let work = 0;
371
- for (let placed = 0; placed < doubledRanks.length; placed++) work += Math.min(selectedN, placed + 1) * (maxSum - doubledRanks[placed] + 1);
372
- return {
373
- states: (selectedN + 1) * (maxSum + 1),
374
- work
375
- };
376
- }
377
- /**
378
- * Smallest attainable two-sided p under the observed ties.
379
- *
380
- * Only subsets with the minimum or maximum rank sum can attain the largest
381
- * deviation. Their multiplicity is the number of ways to choose within the
382
- * tie group at each boundary, so this calculation is exact without allocating
383
- * the full null distribution.
384
- */
385
- function exactTwoSampleFloor(doubledRanks, selectedN) {
386
- const total = doubledRanks.length;
387
- const otherN = total - selectedN;
388
- const minimumSum = doubledRanks.slice(0, selectedN).reduce((sum, rank) => sum + rank, 0);
389
- const maximumSum = doubledRanks.slice(total - selectedN).reduce((sum, rank) => sum + rank, 0);
390
- if (minimumSum === maximumSum) return 1;
391
- const centre = selectedN * (selectedN + 1) + selectedN * otherN;
392
- const minimumDeviation = Math.abs(minimumSum - centre);
393
- const maximumDeviation = Math.abs(maximumSum - centre);
394
- const totalLogWays = logChoose(total, selectedN);
395
- const minimumMass = Math.exp(logExtremeSubsetWays(doubledRanks, selectedN, "minimum") - totalLogWays);
396
- const maximumMass = Math.exp(logExtremeSubsetWays(doubledRanks, selectedN, "maximum") - totalLogWays);
397
- if (minimumDeviation > maximumDeviation) return minimumMass;
398
- if (maximumDeviation > minimumDeviation) return maximumMass;
399
- return Math.min(1, minimumMass + maximumMass);
400
- }
401
- function logExtremeSubsetWays(sortedRanks, selectedN, side) {
402
- const boundaryIndex = side === "minimum" ? selectedN - 1 : sortedRanks.length - selectedN;
403
- const boundary = sortedRanks[boundaryIndex];
404
- let first = boundaryIndex;
405
- let afterLast = boundaryIndex + 1;
406
- while (first > 0 && sortedRanks[first - 1] === boundary) first--;
407
- while (afterLast < sortedRanks.length && sortedRanks[afterLast] === boundary) afterLast++;
408
- return logChoose(afterLast - first, selectedN - (side === "minimum" ? first : sortedRanks.length - afterLast));
409
- }
410
- /**
411
- * Exact conditional two-sided p for the two-sample rank test.
412
- *
413
- * Convolves the observed doubled midranks into the null distribution of group
414
- * a's rank sum over every `C(n₁+n₂, n₁)` split — identical to enumerating the
415
- * splits, but `O(N·n₁·ΣR)` instead of `O(C(N,n₁)·n₁n₂)`. Conditioning on the
416
- * realised multiset makes the tie handling exact rather than a correction.
417
- *
418
- * The null is symmetric about `n₁n₂/2` (negating every value maps `U → n₁n₂ −
419
- * U` and permutes the split set onto itself), so the two-sided p is the mass
420
- * at least as far from the centre as the observation.
421
- */
422
- function exactTwoSampleP(doubledRanks, n1, n2, doubledDeviation) {
423
- const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0);
424
- const width = maxSum + 1;
425
- const ways = Array.from({ length: n1 + 1 }, () => new Float64Array(width));
426
- ways[0][0] = 1;
427
- let placed = 0;
428
- for (const rank of doubledRanks) {
429
- for (let k = Math.min(n1, placed + 1); k >= 1; k--) {
430
- const from = ways[k - 1];
431
- const into = ways[k];
432
- for (let sum = maxSum - rank; sum >= 0; sum--) {
433
- const count = from[sum];
434
- if (count !== 0) into[sum + rank] += count;
435
- }
436
- }
437
- placed++;
438
- }
439
- const shift = n1 * (n1 + 1) + n1 * n2;
440
- const chosen = ways[n1];
441
- let totalWays = 0;
442
- let extremeWays = 0;
443
- let tailWays = 0;
444
- let maxDeviation = -1;
445
- for (let sum = 0; sum < width; sum++) {
446
- const count = chosen[sum];
447
- if (count === 0) continue;
448
- totalWays += count;
449
- const deviation = Math.abs(sum - shift);
450
- if (deviation >= doubledDeviation) tailWays += count;
451
- if (deviation > maxDeviation) {
452
- maxDeviation = deviation;
453
- extremeWays = count;
454
- } else if (deviation === maxDeviation) extremeWays += count;
455
- }
456
- return {
457
- p: tailWays / totalWays,
458
- pFloor: extremeWays / totalWays
459
- };
460
- }
461
- /**
462
- * Exact conditional two-sided p for the paired signed-rank test.
463
- *
464
- * Convolves the observed doubled absolute midranks over all `2ⁿ` sign
465
- * assignments in `O(n·ΣR)`. Probabilities rather than counts keep `2ⁿ` off the
466
- * arithmetic. The null is symmetric about `n(n+1)/4`.
467
- */
468
- function exactSignedRankP(doubledRanks, doubledDeviation) {
469
- const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0);
470
- const width = maxSum + 1;
471
- let mass = new Float64Array(width);
472
- mass[0] = 1;
473
- for (const rank of doubledRanks) {
474
- const next = new Float64Array(width);
475
- for (let sum = 0; sum < width; sum++) {
476
- const probability = mass[sum];
477
- if (probability === 0) continue;
478
- next[sum] += probability * .5;
479
- next[sum + rank] += probability * .5;
480
- }
481
- mass = next;
482
- }
483
- const centre = maxSum / 2;
484
- let tail = 0;
485
- let extreme = 0;
486
- let maxDeviation = -1;
487
- for (let sum = 0; sum < width; sum++) {
488
- const probability = mass[sum];
489
- if (probability === 0) continue;
490
- const deviation = Math.abs(sum - centre);
491
- if (deviation >= doubledDeviation) tail += probability;
492
- if (deviation > maxDeviation) {
493
- maxDeviation = deviation;
494
- extreme = probability;
495
- } else if (deviation === maxDeviation) extreme += probability;
496
- }
497
- return {
498
- p: Math.min(1, tail),
499
- pFloor: Math.min(1, extreme)
500
- };
501
- }
502
- // src/paired-arms.ts
503
- /**
504
- * Match rows across two arms into (baseline, treatment) pairs by `pairKey`.
505
- *
506
- * A `pairKey` with at most one row per arm pairs directly, no `repKey`
507
- * needed. A `pairKey` with multiple reps in either arm requires `repKey` on
508
- * every one of its rows, and reps pair only on exact (`pairKey`, `repKey`)
509
- * match — pairing is keyed purely on row identity, never on outcome content
510
- * (outcome-keyed matching deflates discordant counts and biases McNemar), and
511
- * is therefore independent of input order. Reps whose `repKey` has no
512
- * counterpart in the other arm, and items present in only one arm, land in
513
- * the unpaired lists — reported, never truncated.
514
- *
515
- * Fail-loud: throws when either named arm has zero rows (an unknown arm
516
- * name would otherwise read as "everything unpaired"), when the two arm
517
- * names are equal, when a multi-rep `pairKey` has a row without `repKey`, or
518
- * when a (`pairKey`, arm) group repeats a `repKey` (the match would be
519
- * ambiguous).
520
- */
521
- function pairArms(rows, opts) {
522
- const { baselineArm, treatmentArm } = opts;
523
- if (baselineArm === treatmentArm) throw new ValidationError(`pairArms: baselineArm and treatmentArm are both '${baselineArm}' — an arm cannot be compared to itself`);
524
- const byArm = /* @__PURE__ */ new Map();
525
- const armsSeen = /* @__PURE__ */ new Set();
526
- for (const row of rows) {
527
- armsSeen.add(row.arm);
528
- if (row.arm !== baselineArm && row.arm !== treatmentArm) continue;
529
- const byKey = byArm.get(row.arm) ?? /* @__PURE__ */ new Map();
530
- const group = byKey.get(row.pairKey) ?? [];
531
- group.push(row);
532
- byKey.set(row.pairKey, group);
533
- byArm.set(row.arm, byKey);
534
- }
535
- for (const arm of [baselineArm, treatmentArm]) if (!byArm.has(arm)) {
536
- const seen = [...armsSeen].sort().join(", ") || "<none>";
537
- throw new ValidationError(`pairArms: no rows for arm '${arm}' (arms present: ${seen})`);
538
- }
539
- const baselineByKey = byArm.get(baselineArm);
540
- const treatmentByKey = byArm.get(treatmentArm);
541
- const allKeys = [.../* @__PURE__ */ new Set([...baselineByKey.keys(), ...treatmentByKey.keys()])].sort();
542
- const pairs = [];
543
- const unpairedBaseline = [];
544
- const unpairedTreatment = [];
545
- for (const pairKey of allKeys) {
546
- const b = baselineByKey.get(pairKey) ?? [];
547
- const t = treatmentByKey.get(pairKey) ?? [];
548
- if (b.length <= 1 && t.length <= 1) {
549
- if (b.length === 1 && t.length === 1) {
550
- const baseline = b[0];
551
- const treatment = t[0];
552
- if (baseline.repKey !== void 0 || treatment.repKey !== void 0) {
553
- if (baseline.repKey === void 0 || treatment.repKey === void 0 || baseline.repKey !== treatment.repKey) {
554
- unpairedBaseline.push(baseline);
555
- unpairedTreatment.push(treatment);
556
- continue;
557
- }
558
- }
559
- pairs.push({
560
- pairKey,
561
- repIndex: 0,
562
- baseline,
563
- treatment
564
- });
565
- } else {
566
- unpairedBaseline.push(...b);
567
- unpairedTreatment.push(...t);
568
- }
569
- continue;
570
- }
571
- const bByRep = indexByRepKey(b, pairKey, baselineArm);
572
- const tByRep = indexByRepKey(t, pairKey, treatmentArm);
573
- const repKeys = [.../* @__PURE__ */ new Set([...bByRep.keys(), ...tByRep.keys()])].sort();
574
- let repIndex = 0;
575
- for (const repKey of repKeys) {
576
- const baseline = bByRep.get(repKey);
577
- const treatment = tByRep.get(repKey);
578
- if (baseline !== void 0 && treatment !== void 0) pairs.push({
579
- pairKey,
580
- repIndex: repIndex++,
581
- baseline,
582
- treatment
583
- });
584
- else if (baseline !== void 0) unpairedBaseline.push(baseline);
585
- else if (treatment !== void 0) unpairedTreatment.push(treatment);
586
- }
587
- }
588
- return {
589
- pairs,
590
- unpairedBaseline,
591
- unpairedTreatment
592
- };
593
- }
594
- /** Index a multi-rep (pairKey, arm) group by `repKey`, enforcing that every
595
- * row carries one and that no repKey repeats within the group. */
596
- function indexByRepKey(group, pairKey, arm) {
597
- const byRep = /* @__PURE__ */ new Map();
598
- for (const row of group) {
599
- if (row.repKey === void 0) throw new ValidationError(`pairArms: pairKey '${pairKey}' has multiple reps in an arm, but a row in arm '${arm}' is missing repKey — multi-rep items require an explicit repKey on every row so reps pair by identity (pairing reps by outcome or by index would bias the paired statistics)`);
600
- if (byRep.has(row.repKey)) throw new ValidationError(`pairArms: duplicate repKey '${row.repKey}' for pairKey '${pairKey}' in arm '${arm}' — (pairKey, repKey) must uniquely identify a rep within an arm`);
601
- byRep.set(row.repKey, row);
602
- }
603
- return byRep;
604
- }
605
- /**
606
- * Full matched-pair arm comparison: pair via {@link pairArms}, then compose
607
- * the paired estimators from `statistics` over the matched pairs.
608
- *
609
- * Correctness uses only the pairs where both sides carry `pass` (`mcnemar.n`
610
- * is that subset's size); each metric uses only the pairs where both sides
611
- * carry a finite value for it, with the remainder counted in `nMissing`.
612
- * Deltas are treatment − baseline throughout. With an assignment roster, pairing
613
- * covers declared seed identities; missing observations remain identity-only rows
614
- * and never contribute fabricated outcomes or metrics. Per-arm summaries report
615
- * every assignment and the explicitly formed subset separately.
616
- *
617
- * Fail-loud: inherits {@link pairArms}'s unknown-arm throw, and throws on a
618
- * non-finite metric value — silently treating corrupt telemetry as "metric
619
- * absent" would misreport it as missing coverage.
620
- */
621
- function comparePairedArms(rows, opts) {
622
- const populations = opts.assignments === void 0 ? void 0 : prepareArmPopulations(rows, opts.assignments, opts);
623
- const { pairs, unpairedBaseline, unpairedTreatment } = pairArms(populations?.rows ?? rows, opts);
624
- let correctness = null;
625
- const baselinePass = [];
626
- const treatmentPass = [];
627
- for (const pair of pairs) {
628
- if (pair.baseline.pass == null || pair.treatment.pass == null) continue;
629
- baselinePass.push(pair.baseline.pass ? 1 : 0);
630
- treatmentPass.push(pair.treatment.pass ? 1 : 0);
631
- }
632
- if (baselinePass.length > 0) {
633
- const mc = mcnemar(baselinePass, treatmentPass);
634
- correctness = {
635
- b10: mc.b,
636
- b01: mc.c,
637
- mcnemar: mc,
638
- riskDifference: pairedRiskDifference(baselinePass, treatmentPass)
639
- };
640
- }
641
- const metricDeltas = (opts.metricNames ?? [...new Set(pairs.flatMap((p) => [...Object.keys(p.baseline.metrics ?? {}), ...Object.keys(p.treatment.metrics ?? {})]))].sort()).map((name) => {
642
- const before = [];
643
- const after = [];
644
- let nMissing = 0;
645
- for (const pair of pairs) {
646
- const b = metricValue(pair.baseline, name);
647
- const t = metricValue(pair.treatment, name);
648
- if (b === void 0 || t === void 0) {
649
- nMissing++;
650
- continue;
651
- }
652
- before.push(b);
653
- after.push(t);
654
- }
655
- const bootstrapCi = before.length === 0 ? null : pairedBootstrap(before, after, opts.bootstrap);
656
- return {
657
- name,
658
- n: before.length,
659
- nMissing,
660
- medianDelta: bootstrapCi?.median ?? null,
661
- meanDelta: bootstrapCi?.mean ?? null,
662
- bootstrapCi,
663
- wilcoxon: before.length === 0 ? null : wilcoxonSignedRank(before, after)
664
- };
665
- });
666
- return {
667
- ...populations ? { armPopulations: populations.readings } : {},
668
- nPairs: pairs.length,
669
- nUnpairedBaseline: unpairedBaseline.length,
670
- nUnpairedTreatment: unpairedTreatment.length,
671
- correctness,
672
- metricDeltas
673
- };
674
- }
675
- /**
676
- * Pair two RunRecord arms by the identity of the evaluated work:
677
- * `(experimentId, scenarioId, seed)`.
678
- *
679
- * Falling back to array order, candidate id, or experiment id can compare
680
- * different tasks and fabricate lift. Duplicate identities throw.
681
- */
682
- function pairRunRecords(baselineRuns, treatmentRuns) {
683
- const baselineRows = runRecordArmRows(baselineRuns, "baseline");
684
- const treatmentRows = runRecordArmRows(treatmentRuns, "treatment");
685
- validateRunRecordArmRows(baselineRows, "baseline");
686
- validateRunRecordArmRows(treatmentRows, "treatment");
687
- if (baselineRows.length === 0 || treatmentRows.length === 0) return {
688
- pairs: [],
689
- unpairedBaseline: baselineRows.map((row) => row.run),
690
- unpairedTreatment: treatmentRows.map((row) => row.run)
691
- };
692
- const result = pairArms([...baselineRows, ...treatmentRows], {
693
- baselineArm: "baseline",
694
- treatmentArm: "treatment"
695
- });
696
- return {
697
- pairs: result.pairs.map((pair) => {
698
- const baseline = pair.baseline;
699
- const treatment = pair.treatment;
700
- return {
701
- pairKey: pair.pairKey,
702
- repKey: baseline.repKey,
703
- baseline: baseline.run,
704
- treatment: treatment.run
705
- };
706
- }),
707
- unpairedBaseline: result.unpairedBaseline.map((row) => row.run),
708
- unpairedTreatment: result.unpairedTreatment.map((row) => row.run)
709
- };
710
- }
711
- function runRecordArmRows(runs, arm) {
712
- return runs.map((run) => {
713
- const scenarioId = run.scenarioId.trim();
714
- if (!scenarioId) throw new ValidationError(`pairRunRecords: run '${run.runId}' is missing scenarioId; paired comparisons require explicit scenario identity`);
715
- return {
716
- pairKey: JSON.stringify([run.experimentId, scenarioId]),
717
- repKey: String(run.seed),
718
- arm,
719
- run
720
- };
721
- });
722
- }
723
- function validateRunRecordArmRows(rows, arm) {
724
- const byPairKey = /* @__PURE__ */ new Map();
725
- for (const row of rows) {
726
- const group = byPairKey.get(row.pairKey) ?? [];
727
- group.push(row);
728
- byPairKey.set(row.pairKey, group);
729
- }
730
- for (const [pairKey, group] of byPairKey) if (group.length > 1) indexByRepKey(group, pairKey, arm);
731
- }
732
- function metricValue(row, name) {
733
- const v = row.metrics?.[name];
734
- if (v == null) return void 0;
735
- if (!Number.isFinite(v)) throw new ValidationError(`comparePairedArms: non-finite value for metric '${name}' on pairKey '${row.pairKey}' (arm '${row.arm}'): ${v}`);
736
- return v;
737
- }
738
- export { wilcoxonSignedRank as a, mannWhitneyU as i, pairArms as n, normalCdf as o, pairRunRecords as r, comparePairedArms as t };
739
-
740
- //# sourceMappingURL=paired-arms-3-tsXvvC.js.map