@tangle-network/agent-eval 2.0.7 → 2.0.10

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 (314) hide show
  1. package/CHANGELOG.md +80 -16
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-CRdalpZv.d.ts → agent-profile-_JzxgLDM.d.ts} +11 -5
  4. package/dist/{agent-profile-CRdalpZv.d.ts.map → agent-profile-_JzxgLDM.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +14 -13
  6. package/dist/analyst/index.d.ts.map +1 -1
  7. package/dist/analyst/index.js +34 -13
  8. package/dist/analyst/index.js.map +1 -1
  9. package/dist/analyze-runs-Izz_ZeWg.d.ts +65 -0
  10. package/dist/analyze-runs-Izz_ZeWg.d.ts.map +1 -0
  11. package/dist/{analyze-runs-C_9cXPZn.js → analyze-runs-xhH2Qxoc.js} +6 -5
  12. package/dist/{analyze-runs-C_9cXPZn.js.map → analyze-runs-xhH2Qxoc.js.map} +1 -1
  13. package/dist/app-grade/index.d.ts +4 -4
  14. package/dist/app-grade/index.js +1 -1
  15. package/dist/{benchmark-command-DkBMUDwy.js → benchmark-command-CGQXNFj7.js} +12 -8
  16. package/dist/benchmark-command-CGQXNFj7.js.map +1 -0
  17. package/dist/benchmarks/index.d.ts +4 -4
  18. package/dist/benchmarks/index.js +4 -4
  19. package/dist/builder-eval/index.js +2 -2
  20. package/dist/calibration-CrORXMWx.d.ts +128 -0
  21. package/dist/calibration-CrORXMWx.d.ts.map +1 -0
  22. package/dist/{calibration-Cfoup0xz.js → calibration-Dz8mQb5P.js} +2 -2
  23. package/dist/{calibration-Cfoup0xz.js.map → calibration-Dz8mQb5P.js.map} +1 -1
  24. package/dist/campaign/index.d.ts +8 -8
  25. package/dist/campaign/index.js +13 -12
  26. package/dist/{campaign-DfSWSreo.js → campaign-eus7YRs2.js} +1590 -15
  27. package/dist/campaign-eus7YRs2.js.map +1 -0
  28. package/dist/{campaign-evidence-BojANgU7.d.ts → campaign-evidence-BOcX4w0r.d.ts} +5 -5
  29. package/dist/{campaign-evidence-BojANgU7.d.ts.map → campaign-evidence-BOcX4w0r.d.ts.map} +1 -1
  30. package/dist/{campaign-evidence-D_oBFfLc.js → campaign-evidence-KM5GTsHG.js} +5 -5
  31. package/dist/{campaign-evidence-D_oBFfLc.js.map → campaign-evidence-KM5GTsHG.js.map} +1 -1
  32. package/dist/{cluster-Bj90LK-1.d.ts → chat-client-BlTooBDA.d.ts} +9 -241
  33. package/dist/chat-client-BlTooBDA.d.ts.map +1 -0
  34. package/dist/{chat-client-CvyDOQBv.js → chat-client-Oyot5tyo.js} +2 -2
  35. package/dist/{chat-client-CvyDOQBv.js.map → chat-client-Oyot5tyo.js.map} +1 -1
  36. package/dist/{chat-json-call-DMrwmB-k.js → chat-json-call-DTmv2uNY.js} +2 -2
  37. package/dist/{chat-json-call-DMrwmB-k.js.map → chat-json-call-DTmv2uNY.js.map} +1 -1
  38. package/dist/cli.js +7 -7
  39. package/dist/cluster-BJ0nW3P7.d.ts +241 -0
  40. package/dist/cluster-BJ0nW3P7.d.ts.map +1 -0
  41. package/dist/{cluster-bootstrap-DPzVy3_K.js → cluster-bootstrap-CTC8Dd30.js} +3 -2
  42. package/dist/{cluster-bootstrap-DPzVy3_K.js.map → cluster-bootstrap-CTC8Dd30.js.map} +1 -1
  43. package/dist/{completion-verifier-DsotH2l3.js → completion-verifier-CCPG2Yc0.js} +3 -3
  44. package/dist/{completion-verifier-DsotH2l3.js.map → completion-verifier-CCPG2Yc0.js.map} +1 -1
  45. package/dist/{completion-verifier-Cy38EpGE.d.ts → completion-verifier-CQOC3_bm.d.ts} +2 -2
  46. package/dist/{completion-verifier-Cy38EpGE.d.ts.map → completion-verifier-CQOC3_bm.d.ts.map} +1 -1
  47. package/dist/contract/index.d.ts +14 -12
  48. package/dist/contract/index.js +14 -12
  49. package/dist/contract/index.js.map +1 -1
  50. package/dist/{decision-point-C46p-p9v.js → decision-point-CfqtnGop.js} +3 -3
  51. package/dist/{decision-point-C46p-p9v.js.map → decision-point-CfqtnGop.js.map} +1 -1
  52. package/dist/{default-registry-BWFPtmuI.js → default-registry-Rs5uzlfJ.js} +4 -4
  53. package/dist/{default-registry-BWFPtmuI.js.map → default-registry-Rs5uzlfJ.js.map} +1 -1
  54. package/dist/{default-registry-xoX0PMCb.d.ts → default-registry-X8McMoUV.d.ts} +6 -6
  55. package/dist/{default-registry-xoX0PMCb.d.ts.map → default-registry-X8McMoUV.d.ts.map} +1 -1
  56. package/dist/define-agent-eval-D8ntOXqV.js +96 -0
  57. package/dist/define-agent-eval-D8ntOXqV.js.map +1 -0
  58. package/dist/define-agent-eval-DH5-xi-F.d.ts +52 -0
  59. package/dist/define-agent-eval-DH5-xi-F.d.ts.map +1 -0
  60. package/dist/diagnosis/index.d.ts +3 -3
  61. package/dist/diagnosis/index.js +1 -1
  62. package/dist/{dspy-rlm-engine-r7YpKLhS.js → dspy-rlm-engine-ChE1PUM5.js} +3 -3
  63. package/dist/{dspy-rlm-engine-r7YpKLhS.js.map → dspy-rlm-engine-ChE1PUM5.js.map} +1 -1
  64. package/dist/{emitter-BjW3NnX-.js → emitter-xN9wGTVw.js} +9 -2
  65. package/dist/{emitter-BjW3NnX-.js.map → emitter-xN9wGTVw.js.map} +1 -1
  66. package/dist/{eval-campaign-Cyk-tkLh.js → eval-campaign-BciGnrGy.js} +3 -3
  67. package/dist/{eval-campaign-Cyk-tkLh.js.map → eval-campaign-BciGnrGy.js.map} +1 -1
  68. package/dist/{evaluation-X5E22NQK.d.ts → evaluation-CjZH6gW0.d.ts} +4 -4
  69. package/dist/{evaluation-X5E22NQK.d.ts.map → evaluation-CjZH6gW0.d.ts.map} +1 -1
  70. package/dist/evaluation.d.ts +1 -1
  71. package/dist/{exact-types-DjuabhUV.d.ts → exact-types-BIHqYBYf.d.ts} +2 -2
  72. package/dist/{exact-types-DjuabhUV.d.ts.map → exact-types-BIHqYBYf.d.ts.map} +1 -1
  73. package/dist/{execution-insight-CE20Bxq0.d.ts → execution-insight-YihQrSqd.d.ts} +2 -2
  74. package/dist/{execution-insight-CE20Bxq0.d.ts.map → execution-insight-YihQrSqd.d.ts.map} +1 -1
  75. package/dist/experiment/index.d.ts +5 -5
  76. package/dist/experiment/index.js +10 -184
  77. package/dist/experiment/index.js.map +1 -1
  78. package/dist/{external-optimizer-contracts-ZDBfbZ_s.js → external-optimizer-contracts-BFV8lnhl.js} +7 -2
  79. package/dist/{external-optimizer-contracts-ZDBfbZ_s.js.map → external-optimizer-contracts-BFV8lnhl.js.map} +1 -1
  80. package/dist/{external-optimizer-process-4QdcF7Kd.js → external-optimizer-process-B6emPodQ.js} +3 -3
  81. package/dist/{external-optimizer-process-4QdcF7Kd.js.map → external-optimizer-process-B6emPodQ.js.map} +1 -1
  82. package/dist/{external-optimizer-subprocess-BW0ZWUUr.js → external-optimizer-subprocess-_O06eDVA.js} +35 -376
  83. package/dist/external-optimizer-subprocess-_O06eDVA.js.map +1 -0
  84. package/dist/{feedback-trajectory-BMkJezPc.d.ts → feedback-trajectory-CoQPmSJV.d.ts} +3 -3
  85. package/dist/{feedback-trajectory-BMkJezPc.d.ts.map → feedback-trajectory-CoQPmSJV.d.ts.map} +1 -1
  86. package/dist/finding-scope-B_As3F_v.js +359 -0
  87. package/dist/finding-scope-B_As3F_v.js.map +1 -0
  88. package/dist/{findings-store-DV8WA5nD.js → findings-store-CvYUzQBR.js} +4 -4
  89. package/dist/{findings-store-DV8WA5nD.js.map → findings-store-CvYUzQBR.js.map} +1 -1
  90. package/dist/fuzz.js +1 -1
  91. package/dist/{index-C6TG1LwA.d.ts → index-BSb3fJyZ.d.ts} +318 -131
  92. package/dist/index-BSb3fJyZ.d.ts.map +1 -0
  93. package/dist/{index-CKjqN9_U.d.ts → index-Bk1XEkP7.d.ts} +99 -3
  94. package/dist/index-Bk1XEkP7.d.ts.map +1 -0
  95. package/dist/{index-DAFZRMlF.d.ts → index-BmWw8zN6.d.ts} +10 -8
  96. package/dist/index-BmWw8zN6.d.ts.map +1 -0
  97. package/dist/{index-DKpMyD_Z.d.ts → index-CCOaNmh2.d.ts} +7 -7
  98. package/dist/{index-DKpMyD_Z.d.ts.map → index-CCOaNmh2.d.ts.map} +1 -1
  99. package/dist/{index-xEM_SoCl.d.ts → index-ZffK_5sD.d.ts} +22 -20
  100. package/dist/index-ZffK_5sD.d.ts.map +1 -0
  101. package/dist/{index-BqAPIToS.d.ts → index-aRalB_Ma.d.ts} +3 -3
  102. package/dist/{index-BqAPIToS.d.ts.map → index-aRalB_Ma.d.ts.map} +1 -1
  103. package/dist/index.d.ts +33 -29
  104. package/dist/index.js +28 -25
  105. package/dist/index.js.map +1 -1
  106. package/dist/{analyze-runs-xjKBBqIB.d.ts → insight-report-DYofCMLx.d.ts} +4 -64
  107. package/dist/insight-report-DYofCMLx.d.ts.map +1 -0
  108. package/dist/{integrity-BF0tJK21.js → integrity-DacT3oJ1.js} +2 -2
  109. package/dist/{integrity-BF0tJK21.js.map → integrity-DacT3oJ1.js.map} +1 -1
  110. package/dist/{integrity-B9320cw1.d.ts → integrity-DotDLWtj.d.ts} +2 -2
  111. package/dist/{integrity-B9320cw1.d.ts.map → integrity-DotDLWtj.d.ts.map} +1 -1
  112. package/dist/{judge-gate-DqlzOBOm.js → judge-gate-CpD3wmcf.js} +3 -3
  113. package/dist/{judge-gate-DqlzOBOm.js.map → judge-gate-CpD3wmcf.js.map} +1 -1
  114. package/dist/{llm-client-Dw4x6EdE.js → llm-client-Dk8lBnMh.js} +15 -2
  115. package/dist/{llm-client-Dw4x6EdE.js.map → llm-client-Dk8lBnMh.js.map} +1 -1
  116. package/dist/llm-judge-DYmEdo3M.js +476 -0
  117. package/dist/llm-judge-DYmEdo3M.js.map +1 -0
  118. package/dist/{matrix-CqZSpwgN.d.ts → matrix-BDl7hoBr.d.ts} +6 -2
  119. package/dist/matrix-BDl7hoBr.d.ts.map +1 -0
  120. package/dist/measure-validity-plan-BReXzcVh.d.ts +201 -0
  121. package/dist/measure-validity-plan-BReXzcVh.d.ts.map +1 -0
  122. package/dist/measure-validity-plan-CJkBNzX_.js +154 -0
  123. package/dist/measure-validity-plan-CJkBNzX_.js.map +1 -0
  124. package/dist/meta-eval/index.d.ts +5 -3
  125. package/dist/meta-eval/index.js +808 -15
  126. package/dist/meta-eval/index.js.map +1 -1
  127. package/dist/multishot/golden/index.d.ts +1 -1
  128. package/dist/multishot/index.d.ts +497 -4
  129. package/dist/multishot/index.d.ts.map +1 -1
  130. package/dist/multishot/index.js +1000 -48
  131. package/dist/multishot/index.js.map +1 -1
  132. package/dist/node-transport-DJno8V46.js +62 -0
  133. package/dist/node-transport-DJno8V46.js.map +1 -0
  134. package/dist/openapi.json +1 -1
  135. package/dist/{llm-judge-DQJTQx01.js → optimization-method-4JlbMxd2.js} +38 -513
  136. package/dist/optimization-method-4JlbMxd2.js.map +1 -0
  137. package/dist/{outcome-observations-DL3CC8w1.js → outcome-observations-DEh8_V_P.js} +31 -6
  138. package/dist/outcome-observations-DEh8_V_P.js.map +1 -0
  139. package/dist/outcome-store-CHtuvstd.d.ts +56 -0
  140. package/dist/outcome-store-CHtuvstd.d.ts.map +1 -0
  141. package/dist/{paired-arms-DZhH3FGu.js → paired-arms-CJH5Q0wx.js} +3 -2
  142. package/dist/{paired-arms-DZhH3FGu.js.map → paired-arms-CJH5Q0wx.js.map} +1 -1
  143. package/dist/{paired-promotion-decision-Dn3-jaq4.js → paired-promotion-decision-BtfVwEAk.js} +3 -2
  144. package/dist/{paired-promotion-decision-Dn3-jaq4.js.map → paired-promotion-decision-BtfVwEAk.js.map} +1 -1
  145. package/dist/{paired-promotion-decision-ChHBuuHV.d.ts → paired-promotion-decision-DJlI4z_k.d.ts} +2 -2
  146. package/dist/{paired-promotion-decision-ChHBuuHV.d.ts.map → paired-promotion-decision-DJlI4z_k.d.ts.map} +1 -1
  147. package/dist/{paired-promotion-power-BlzXdgMD.js → paired-promotion-power-DG1avBKf.js} +3 -3
  148. package/dist/{paired-promotion-power-BlzXdgMD.js.map → paired-promotion-power-DG1avBKf.js.map} +1 -1
  149. package/dist/paired-tests-CXcD_B80.js +688 -0
  150. package/dist/paired-tests-CXcD_B80.js.map +1 -0
  151. package/dist/pareto-DIVE5D0T.js +81 -0
  152. package/dist/pareto-DIVE5D0T.js.map +1 -0
  153. package/dist/pipelines/index.d.ts +2 -1
  154. package/dist/pipelines/index.d.ts.map +1 -1
  155. package/dist/pipelines/index.js +1 -1
  156. package/dist/{sequential-BphITa5b.js → power-COie_o6E.js} +181 -4
  157. package/dist/power-COie_o6E.js.map +1 -0
  158. package/dist/{prime-protocol-Cv6_47rh.d.ts → prime-protocol-BRMk6dGI.d.ts} +2 -2
  159. package/dist/{prime-protocol-Cv6_47rh.d.ts.map → prime-protocol-BRMk6dGI.d.ts.map} +1 -1
  160. package/dist/{promotion-gate-CGkxh36r.d.ts → promotion-gate-B0VTBoXg.d.ts} +2 -2
  161. package/dist/{promotion-gate-CGkxh36r.d.ts.map → promotion-gate-B0VTBoXg.d.ts.map} +1 -1
  162. package/dist/{promotion-policy-CxDIh-9p.js → promotion-policy-BgI7PsQn.js} +4 -4
  163. package/dist/{promotion-policy-CxDIh-9p.js.map → promotion-policy-BgI7PsQn.js.map} +1 -1
  164. package/dist/{proposal-findings-DedMih-u.js → proposal-findings-CfRFCFXS.js} +2 -2
  165. package/dist/{proposal-findings-DedMih-u.js.map → proposal-findings-CfRFCFXS.js.map} +1 -1
  166. package/dist/{registry-CIjC6SdV.d.ts → registry-BeInzotS.d.ts} +4 -4
  167. package/dist/{registry-CIjC6SdV.d.ts.map → registry-BeInzotS.d.ts.map} +1 -1
  168. package/dist/{release-confidence-BLHOMK5Q.js → release-confidence-Cndq1hwi.js} +2 -2
  169. package/dist/{release-confidence-BLHOMK5Q.js.map → release-confidence-Cndq1hwi.js.map} +1 -1
  170. package/dist/reporting.d.ts +5 -5
  171. package/dist/reporting.js +6 -5
  172. package/dist/reporting.js.map +1 -1
  173. package/dist/{research-report-D6XIK0eK.d.ts → research-report-CL5_UqCX.d.ts} +2 -2
  174. package/dist/{research-report-D6XIK0eK.d.ts.map → research-report-CL5_UqCX.d.ts.map} +1 -1
  175. package/dist/{researcher---DhHG4J.d.ts → researcher-BOpZP_Ja.d.ts} +4 -4
  176. package/dist/{researcher---DhHG4J.d.ts.map → researcher-BOpZP_Ja.d.ts.map} +1 -1
  177. package/dist/{reward-hacking-DKAflk2c.js → reward-hacking-DMTm1OBd.js} +2 -2
  178. package/dist/{reward-hacking-DKAflk2c.js.map → reward-hacking-DMTm1OBd.js.map} +1 -1
  179. package/dist/rl.d.ts +9 -8
  180. package/dist/rl.d.ts.map +1 -1
  181. package/dist/rl.js +11 -10
  182. package/dist/rl.js.map +1 -1
  183. package/dist/rollout/index.d.ts +2 -2
  184. package/dist/rollout/index.js +1 -1
  185. package/dist/{rollout-B_lrpd9a.js → rollout--rSr43Pd.js} +2 -2
  186. package/dist/{rollout-B_lrpd9a.js.map → rollout--rSr43Pd.js.map} +1 -1
  187. package/dist/{rollout-nodes-Vas6OSxX.js → rollout-nodes-DFxKpIr2.js} +39 -10
  188. package/dist/rollout-nodes-DFxKpIr2.js.map +1 -0
  189. package/dist/{rubric-predictive-validity--6z0q8s6.js → rubric-predictive-validity-BXJ92Jp_.js} +3 -9
  190. package/dist/rubric-predictive-validity-BXJ92Jp_.js.map +1 -0
  191. package/dist/{rubric-predictive-validity-C9wc7f_D.d.ts → rubric-predictive-validity-DH94_0Q1.d.ts} +3 -56
  192. package/dist/rubric-predictive-validity-DH94_0Q1.d.ts.map +1 -0
  193. package/dist/{run-improvement-loop-BfwOUudy.d.ts → run-improvement-loop-BeHu5D9Z.d.ts} +396 -11
  194. package/dist/run-improvement-loop-BeHu5D9Z.d.ts.map +1 -0
  195. package/dist/{run-record-Bqg0NZ_e.js → run-record-CuO8ErrI.js} +3 -2
  196. package/dist/run-record-CuO8ErrI.js.map +1 -0
  197. package/dist/{runtime-rollouts-drQynu3t.js → runtime-rollouts-CE0MbQPq.js} +55 -8
  198. package/dist/runtime-rollouts-CE0MbQPq.js.map +1 -0
  199. package/dist/search/index.d.ts +2 -2
  200. package/dist/search/index.js +2 -2
  201. package/dist/{search-kernel-DJq9bUDU.d.ts → search-kernel-CJZ-ZSV1.d.ts} +3 -3
  202. package/dist/{search-kernel-DJq9bUDU.d.ts.map → search-kernel-CJZ-ZSV1.d.ts.map} +1 -1
  203. package/dist/{pareto-Bg75Gajo.js → search-kernel-mZc79S6N.js} +6 -88
  204. package/dist/search-kernel-mZc79S6N.js.map +1 -0
  205. package/dist/{search-summary-B1x1Vmzh.js → search-summary-CCgP2qXz.js} +4 -4
  206. package/dist/{search-summary-B1x1Vmzh.js.map → search-summary-CCgP2qXz.js.map} +1 -1
  207. package/dist/{define-agent-eval-Cjc0wWnO.d.ts → self-improve-B1fsNejr.d.ts} +8 -54
  208. package/dist/self-improve-B1fsNejr.d.ts.map +1 -0
  209. package/dist/{define-agent-eval-B6uE3gNu.js → self-improve-C_Bcdmv8.js} +9 -97
  210. package/dist/self-improve-C_Bcdmv8.js.map +1 -0
  211. package/dist/{sequential-BhbTSxpt.d.ts → sequential-CHplorpC.d.ts} +2 -2
  212. package/dist/{sequential-BhbTSxpt.d.ts.map → sequential-CHplorpC.d.ts.map} +1 -1
  213. package/dist/{sequential-ux_XrjBf.js → sequential-DR-pnYQ7.js} +3 -3
  214. package/dist/{sequential-ux_XrjBf.js.map → sequential-DR-pnYQ7.js.map} +1 -1
  215. package/dist/{server-1fzBCxMh.js → server-aZFmRucn.js} +3 -3
  216. package/dist/{server-1fzBCxMh.js.map → server-aZFmRucn.js.map} +1 -1
  217. package/dist/{skillopt-optimization-method-D_swD0Cy.js → skillopt-optimization-method-DHk1K757.js} +95 -40
  218. package/dist/skillopt-optimization-method-DHk1K757.js.map +1 -0
  219. package/dist/{statistical-heldout-CaS4T-43.js → statistical-heldout-CL_7mI5C.js} +3 -3
  220. package/dist/{statistical-heldout-CaS4T-43.js.map → statistical-heldout-CL_7mI5C.js.map} +1 -1
  221. package/dist/{statistics-DSidA5I2.js → statistics-AKnVFnK-.js} +233 -700
  222. package/dist/statistics-AKnVFnK-.js.map +1 -0
  223. package/dist/statistics.d.ts +3 -3
  224. package/dist/statistics.js +3 -2
  225. package/dist/{store-tool-spans-DniaFwjM.d.ts → store-tool-spans-M3WxeRrG.d.ts} +4 -4
  226. package/dist/{store-tool-spans-DniaFwjM.d.ts.map → store-tool-spans-M3WxeRrG.d.ts.map} +1 -1
  227. package/dist/{summary-report-CI4J6gxU.js → summary-report-DyBkOC6V.js} +15 -7
  228. package/dist/summary-report-DyBkOC6V.js.map +1 -0
  229. package/dist/summary-report-figures-CJHygLgw.d.ts.map +1 -1
  230. package/dist/supervisor-run/index.d.ts +12 -2
  231. package/dist/supervisor-run/index.d.ts.map +1 -1
  232. package/dist/supervisor-run/index.js +3 -3
  233. package/dist/{systemone-DzY-2Zri.d.ts → systemone-4PadCE4C.d.ts} +8 -7
  234. package/dist/systemone-4PadCE4C.d.ts.map +1 -0
  235. package/dist/{systemone-review-CXecR_m-.d.ts → systemone-review-DpAXWDkL.d.ts} +2 -2
  236. package/dist/{systemone-review-CXecR_m-.d.ts.map → systemone-review-DpAXWDkL.d.ts.map} +1 -1
  237. package/dist/systemone.d.ts +3 -3
  238. package/dist/systemone.js +1 -1
  239. package/dist/{tool-groups-DF6OqhoG.d.ts → tool-groups-SlnoQNyT.d.ts} +2 -2
  240. package/dist/tool-groups-SlnoQNyT.d.ts.map +1 -0
  241. package/dist/tool-waste-B01AMpID.d.ts +121 -0
  242. package/dist/tool-waste-B01AMpID.d.ts.map +1 -0
  243. package/dist/{tool-waste-u7JJ_BlE.js → tool-waste-BZnYSa6J.js} +3 -2
  244. package/dist/{tool-waste-u7JJ_BlE.js.map → tool-waste-BZnYSa6J.js.map} +1 -1
  245. package/dist/{trace-questions-DO8y3J-E.d.ts → trace-questions-ybyF0B6N.d.ts} +2 -2
  246. package/dist/{trace-questions-DO8y3J-E.d.ts.map → trace-questions-ybyF0B6N.d.ts.map} +1 -1
  247. package/dist/trace-repair/index.d.ts +1 -1
  248. package/dist/trace-repair/index.js +1 -1
  249. package/dist/traces.d.ts +4 -4
  250. package/dist/traces.js +1 -1
  251. package/dist/trajectory-B3o6Ald_.d.ts +100 -0
  252. package/dist/trajectory-B3o6Ald_.d.ts.map +1 -0
  253. package/dist/trajectory-replay/index.js +1 -1
  254. package/dist/{tree-DQMlcNFI.js → tree-CiIe-f3f.js} +6 -4
  255. package/dist/{tree-DQMlcNFI.js.map → tree-CiIe-f3f.js.map} +1 -1
  256. package/dist/{types-fuOwNq1C.d.ts → types-B1W3v8dT.d.ts} +3 -2
  257. package/dist/types-B1W3v8dT.d.ts.map +1 -0
  258. package/dist/{types-BMSDkS8l.d.ts → types-D5XtEH9Q.d.ts} +11 -4
  259. package/dist/{types-BMSDkS8l.d.ts.map → types-D5XtEH9Q.d.ts.map} +1 -1
  260. package/dist/types-DK4vNv5q.js.map +1 -1
  261. package/dist/{types-D_PfKC59.d.ts → types-an-CUndX.d.ts} +2 -2
  262. package/dist/{types-D_PfKC59.d.ts.map → types-an-CUndX.d.ts.map} +1 -1
  263. package/dist/{types-BLv2Ngla.d.ts → types-xVtEOBhO.d.ts} +31 -8
  264. package/dist/types-xVtEOBhO.d.ts.map +1 -0
  265. package/dist/wire/index.d.ts +2 -2
  266. package/dist/wire/index.js +1 -1
  267. package/dist/world/index.d.ts +529 -0
  268. package/dist/world/index.d.ts.map +1 -0
  269. package/dist/world/index.js +1356 -0
  270. package/dist/world/index.js.map +1 -0
  271. package/docs/campaign-proposers.md +7 -0
  272. package/docs/concepts.md +2 -0
  273. package/docs/design/statistics-decisions.md +48 -0
  274. package/docs/eval-surface-map.md +5 -2
  275. package/docs/feature-guide.md +3 -1
  276. package/docs/multi-turn-optimization.md +84 -0
  277. package/docs/outcome-validity.md +108 -0
  278. package/docs/public-api.md +89 -34
  279. package/docs/{multi-shot-optimization.md → trajectory-optimization.md} +1 -1
  280. package/docs/world.md +104 -0
  281. package/package.json +6 -1
  282. package/dist/analyze-runs-xjKBBqIB.d.ts.map +0 -1
  283. package/dist/benchmark-command-DkBMUDwy.js.map +0 -1
  284. package/dist/campaign-DfSWSreo.js.map +0 -1
  285. package/dist/cluster-Bj90LK-1.d.ts.map +0 -1
  286. package/dist/define-agent-eval-B6uE3gNu.js.map +0 -1
  287. package/dist/define-agent-eval-Cjc0wWnO.d.ts.map +0 -1
  288. package/dist/external-optimizer-subprocess-BW0ZWUUr.js.map +0 -1
  289. package/dist/index-C6TG1LwA.d.ts.map +0 -1
  290. package/dist/index-CKjqN9_U.d.ts.map +0 -1
  291. package/dist/index-DAFZRMlF.d.ts.map +0 -1
  292. package/dist/index-xEM_SoCl.d.ts.map +0 -1
  293. package/dist/interval-CWyxqDpE.d.ts +0 -43
  294. package/dist/interval-CWyxqDpE.d.ts.map +0 -1
  295. package/dist/llm-judge-DQJTQx01.js.map +0 -1
  296. package/dist/matrix-CqZSpwgN.d.ts.map +0 -1
  297. package/dist/outcome-observations-DL3CC8w1.js.map +0 -1
  298. package/dist/pareto-Bg75Gajo.js.map +0 -1
  299. package/dist/rollout-nodes-Vas6OSxX.js.map +0 -1
  300. package/dist/rubric-predictive-validity--6z0q8s6.js.map +0 -1
  301. package/dist/rubric-predictive-validity-C9wc7f_D.d.ts.map +0 -1
  302. package/dist/run-improvement-loop-BfwOUudy.d.ts.map +0 -1
  303. package/dist/run-record-Bqg0NZ_e.js.map +0 -1
  304. package/dist/runtime-rollouts-drQynu3t.js.map +0 -1
  305. package/dist/sequential-BphITa5b.js.map +0 -1
  306. package/dist/skillopt-optimization-method-D_swD0Cy.js.map +0 -1
  307. package/dist/statistics-DSidA5I2.js.map +0 -1
  308. package/dist/summary-report-CI4J6gxU.js.map +0 -1
  309. package/dist/systemone-DzY-2Zri.d.ts.map +0 -1
  310. package/dist/tool-groups-DF6OqhoG.d.ts.map +0 -1
  311. package/dist/tool-waste-CIhtU1ad.d.ts +0 -217
  312. package/dist/tool-waste-CIhtU1ad.d.ts.map +0 -1
  313. package/dist/types-BLv2Ngla.d.ts.map +0 -1
  314. package/dist/types-fuOwNq1C.d.ts.map +0 -1
@@ -0,0 +1,688 @@
1
+ import { s as ValidationError } from "./errors-DeEEV9Vx.js";
2
+ import { t as interpolatedQuantile } from "./quantile-CncXP-Ss.js";
3
+ 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
+ // src/statistics/internal.ts
106
+ /**
107
+ * Shared internals for the statistics modules. Nothing here is part of the
108
+ * public statistics surface — `./index` does not re-export this module.
109
+ */
110
+ /** Every rank test refuses non-finite input. Beyond the arithmetic being
111
+ * undefined, the tie-grouping scan compares values with `===`, and
112
+ * `NaN === NaN` is false, so a NaN would leave the group boundary unable to
113
+ * advance and spin the loop forever. */
114
+ function assertFiniteSample(fn, label, xs) {
115
+ 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]}`);
116
+ }
117
+ /**
118
+ * Two-sided exact p-value for b successes out of (b + c) Bernoulli(0.5) trials —
119
+ * the exact-binomial core of {@link mcnemar}. `min(1, 2·P(X ≤ min(b,c)))`. No
120
+ * discordant pairs ⇒ no evidence ⇒ p = 1. Summed in log space (lnGamma) so it
121
+ * stays exact at large discordant counts without overflow.
122
+ */
123
+ function binomialSignTwoSided(b, c) {
124
+ const nd = b + c;
125
+ if (nd === 0) return 1;
126
+ return Math.min(1, 2 * binomialHalfLowerTail(Math.min(b, c), nd));
127
+ }
128
+ /** P(X >= successes) for X ~ Binomial(n, 0.5). */
129
+ function binomialHalfUpperTail(successes, n) {
130
+ if (successes <= 0) return 1;
131
+ if (successes > n) return 0;
132
+ if (successes <= n / 2) return Math.max(0, 1 - binomialHalfLowerTail(successes - 1, n));
133
+ return binomialHalfLowerTail(n - successes, n);
134
+ }
135
+ /** P(X <= maxSuccesses) for X ~ Binomial(n, 0.5), accumulated in log space. */
136
+ function binomialHalfLowerTail(maxSuccesses, n) {
137
+ if (maxSuccesses < 0) return 0;
138
+ if (maxSuccesses >= n) return 1;
139
+ if (maxSuccesses === 0) return 2 ** -n;
140
+ const logHalfN = n * Math.log(.5);
141
+ let logTail = Number.NEGATIVE_INFINITY;
142
+ for (let i = 0; i <= maxSuccesses; i++) {
143
+ const logChoose = lnGamma(n + 1) - lnGamma(i + 1) - lnGamma(n - i + 1);
144
+ logTail = logAddExp(logTail, logChoose + logHalfN);
145
+ }
146
+ return Math.min(1, Math.exp(logTail));
147
+ }
148
+ function logAddExp(a, b) {
149
+ if (a === Number.NEGATIVE_INFINITY) return b;
150
+ if (b === Number.NEGATIVE_INFINITY) return a;
151
+ const max = Math.max(a, b);
152
+ return max + Math.log1p(Math.exp(Math.min(a, b) - max));
153
+ }
154
+ /** Standard-normal inverse CDF (Acklam approximation). */
155
+ function zQuantile(p) {
156
+ if (p <= 0 || p >= 1) {
157
+ if (p === 0) return -Infinity;
158
+ if (p === 1) return Infinity;
159
+ return NaN;
160
+ }
161
+ const a = [
162
+ -39.69683028665376,
163
+ 220.9460984245205,
164
+ -275.9285104469687,
165
+ 138.357751867269,
166
+ -30.66479806614716,
167
+ 2.506628277459239
168
+ ];
169
+ const b = [
170
+ -54.47609879822406,
171
+ 161.5858368580409,
172
+ -155.6989798598866,
173
+ 66.80131188771972,
174
+ -13.28068155288572
175
+ ];
176
+ const c = [
177
+ -.007784894002430293,
178
+ -.3223964580411365,
179
+ -2.400758277161838,
180
+ -2.549732539343734,
181
+ 4.374664141464968,
182
+ 2.938163982698783
183
+ ];
184
+ const d = [
185
+ .007784695709041462,
186
+ .3224671290700398,
187
+ 2.445134137142996,
188
+ 3.754408661907416
189
+ ];
190
+ const pLow = .02425;
191
+ const pHigh = .97575;
192
+ let q;
193
+ let r;
194
+ if (p < pLow) {
195
+ q = Math.sqrt(-2 * Math.log(p));
196
+ 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);
197
+ }
198
+ if (p <= pHigh) {
199
+ q = p - .5;
200
+ r = q * q;
201
+ 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);
202
+ }
203
+ q = Math.sqrt(-2 * Math.log(1 - p));
204
+ 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);
205
+ }
206
+ function medianInPlace(xs) {
207
+ if (xs.length === 0) return 0;
208
+ xs.sort((a, b) => a - b);
209
+ return interpolatedQuantile(xs, .5);
210
+ }
211
+ /**
212
+ * PRNG for every resampling path in this module.
213
+ *
214
+ * With no caller seed the seed is DERIVED FROM THE DATA rather than taken from
215
+ * `Math.random`, so re-running the same input reproduces the same interval —
216
+ * a gate verdict that cannot be re-derived is not evidence. Distinct data
217
+ * still gets a distinct stream. Same pattern as `promotion-gate.ts`.
218
+ */
219
+ function makeRng(seed, ...series) {
220
+ return mulberry32(seed ?? seedFromData(series));
221
+ }
222
+ /** FNV-1a over the IEEE-754 bytes of every observation. */
223
+ function seedFromData(series) {
224
+ const view = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
225
+ let hash = 2166136261;
226
+ for (const xs of series) {
227
+ for (const x of xs) {
228
+ view.setFloat64(0, x);
229
+ for (let byte = 0; byte < 8; byte++) hash = Math.imul(hash ^ view.getUint8(byte), 16777619);
230
+ }
231
+ hash = Math.imul(hash ^ 255, 16777619);
232
+ }
233
+ return hash | 0;
234
+ }
235
+ /** Order-independent seed for a symmetric two-sample statistic. */
236
+ function symmetricTwoSampleSeed(a, b) {
237
+ const sortedA = [...a].sort((left, right) => left - right);
238
+ const sortedB = [...b].sort((left, right) => left - right);
239
+ const forward = seedFromData([sortedA, sortedB]) >>> 0;
240
+ const reversed = seedFromData([sortedB, sortedA]) >>> 0;
241
+ return Math.min(forward, reversed);
242
+ }
243
+ // src/statistics/mean.ts
244
+ /** Arithmetic mean. An empty input has no mean and returns NaN. */
245
+ function mean(values) {
246
+ return values.reduce((sum, value) => sum + value, 0) / values.length;
247
+ }
248
+ /** Arithmetic mean, or null for an empty input. */
249
+ function meanOrNull(values) {
250
+ return values.length === 0 ? null : mean(values);
251
+ }
252
+ /** Arithmetic mean, or 0 for an empty input. */
253
+ function meanOrZero(values) {
254
+ return values.length === 0 ? 0 : mean(values);
255
+ }
256
+ // src/statistics/descriptive.ts
257
+ /**
258
+ * Descriptive statistics: means, bootstrap spread, correlation, and the
259
+ * weighted judge-dimension composite. Nothing here is a significance test.
260
+ */
261
+ /** Weighted mean — falls back to uniform weights when omitted */
262
+ function weightedMean(scores) {
263
+ if (scores.length === 0) return 0;
264
+ let totalWeight = 0;
265
+ let weightedSum = 0;
266
+ for (const { score, weight } of scores) {
267
+ const w = weight ?? 1;
268
+ weightedSum += score * w;
269
+ totalWeight += w;
270
+ }
271
+ return totalWeight > 0 ? weightedSum / totalWeight : 0;
272
+ }
273
+ /**
274
+ * Percentile bootstrap confidence interval on the mean of `scores`.
275
+ *
276
+ * Descriptive spread. It is not a significance test, and at small n its bounds
277
+ * are anti-conservative in the same way {@link pairedBootstrap}'s are — see
278
+ * {@link BOOTSTRAP_GATE_MIN_N}. With no `seed` the resampling is seeded from
279
+ * the scores themselves, so the interval is reproducible either way.
280
+ */
281
+ function confidenceInterval(scores, confidence = .95, opts = {}) {
282
+ if (scores.length === 0) return {
283
+ mean: 0,
284
+ lower: 0,
285
+ upper: 0
286
+ };
287
+ if (scores.length === 1) return {
288
+ mean: scores[0],
289
+ lower: scores[0],
290
+ upper: scores[0]
291
+ };
292
+ const n = scores.length;
293
+ const mean = scores.reduce((a, b) => a + b, 0) / n;
294
+ const B = opts.resamples ?? 1e3;
295
+ const rng = makeRng(opts.seed, scores);
296
+ const bootstrapMeans = [];
297
+ for (let i = 0; i < B; i++) {
298
+ let sum = 0;
299
+ for (let j = 0; j < n; j++) sum += scores[Math.floor(rng() * n)];
300
+ bootstrapMeans.push(sum / n);
301
+ }
302
+ bootstrapMeans.sort((a, b) => a - b);
303
+ const alpha = 1 - confidence;
304
+ const lowerIdx = Math.floor(alpha / 2 * B);
305
+ const upperIdx = Math.floor((1 - alpha / 2) * B) - 1;
306
+ return {
307
+ mean,
308
+ lower: bootstrapMeans[lowerIdx],
309
+ upper: bootstrapMeans[Math.min(upperIdx, B - 1)]
310
+ };
311
+ }
312
+ /**
313
+ * Two-sided Student-t critical value: the `t` with `P(|T| ≤ t) = confidence`
314
+ * for `df` degrees of freedom. Exact, from {@link studentTQuantile}, so any
315
+ * confidence in (0, 1) and fractional `df` are supported.
316
+ */
317
+ function studentTCritical(df, confidence = .95) {
318
+ if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`studentTCritical: confidence must be in (0, 1), got ${confidence}`);
319
+ if (!Number.isFinite(df) || df <= 0) throw new ValidationError(`studentTCritical: df must be positive and finite, got ${df}`);
320
+ return studentTQuantile(1 - (1 - confidence) / 2, df);
321
+ }
322
+ /**
323
+ * Student-t confidence interval on the mean of one sample:
324
+ * `mean ± t(df = n − 1) · s / √n`. Below two samples there is no spread to
325
+ * estimate, so the bounds are null rather than a zero-width interval that
326
+ * would read as certainty. Unlike {@link confidenceInterval} (a percentile
327
+ * bootstrap), the width keeps the small-n t penalty that z = 1.96 drops.
328
+ */
329
+ function meanConfidenceInterval(samples, confidence = .95) {
330
+ assertFiniteSample("meanConfidenceInterval", "samples", samples);
331
+ const n = samples.length;
332
+ if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`meanConfidenceInterval: confidence must be in (0, 1), got ${confidence}`);
333
+ if (n < 2) return {
334
+ n,
335
+ mean: n === 0 ? null : samples[0],
336
+ stdev: null,
337
+ low: null,
338
+ high: null,
339
+ criticalValue: null
340
+ };
341
+ const center = mean(samples);
342
+ const sumSquares = samples.reduce((sum, value) => sum + (value - center) ** 2, 0);
343
+ const stdev = Math.sqrt(sumSquares / (n - 1));
344
+ const criticalValue = studentTCritical(n - 1, confidence);
345
+ const halfWidth = criticalValue * stdev / Math.sqrt(n);
346
+ return {
347
+ n,
348
+ mean: center,
349
+ stdev,
350
+ low: center - halfWidth,
351
+ high: center + halfWidth,
352
+ criticalValue
353
+ };
354
+ }
355
+ /** Partial credit: returns 0-1 ratio of current toward target */
356
+ function partialCredit(current, target) {
357
+ if (target <= 0) return 1;
358
+ return Math.min(1, Math.max(0, current / target));
359
+ }
360
+ /**
361
+ * Fold a number series into its distribution summary. Quantiles use the
362
+ * nearest-rank definition — the `ceil(q·n)`-th order statistic — so every
363
+ * reported quantile is a value from the series. Returns `null` for an empty
364
+ * series: an empty series has no distribution, and a zero-filled summary
365
+ * would read as a measured all-zero series.
366
+ */
367
+ function summarizeNumberSeries(values, options) {
368
+ const criticalValue = options?.medianInterval?.criticalValue;
369
+ if (options) {
370
+ assertFiniteSample("summarizeNumberSeries", "values", values);
371
+ 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");
372
+ if (options.medianInterval && (criticalValue === void 0 || !Number.isFinite(criticalValue) || criticalValue < 0)) throw new ValidationError("summarizeNumberSeries: median criticalValue must be finite and nonnegative");
373
+ }
374
+ if (values.length === 0) return null;
375
+ const sorted = [...values].sort((a, b) => a - b);
376
+ const n = sorted.length;
377
+ const rank = (q) => sorted[Math.min(n - 1, Math.max(0, Math.ceil(q * n) - 1))];
378
+ const sum = sorted.reduce((a, b) => a + b, 0);
379
+ if (options && !Number.isFinite(sum)) throw new ValidationError("summarizeNumberSeries: sample sum exceeded finite range");
380
+ const spread = criticalValue === void 0 ? void 0 : criticalValue / 2 * Math.sqrt(n);
381
+ const lowRank = spread === void 0 ? 1 : Math.max(1, Math.floor(n / 2 - spread));
382
+ const highRank = spread === void 0 ? n : Math.min(n, Math.ceil(n / 2 + 1 + spread));
383
+ return {
384
+ n,
385
+ min: sorted[0],
386
+ p50: rank(.5),
387
+ p90: rank(.9),
388
+ max: sorted[sorted.length - 1],
389
+ sum,
390
+ ...options?.percentiles === void 0 ? {} : { percentiles: Object.fromEntries(options.percentiles.map((percentile) => [percentile, rank(percentile / 100)])) },
391
+ ...criticalValue === void 0 ? {} : { medianInterval: {
392
+ method: "normal-order-statistics",
393
+ criticalValue,
394
+ sampleSize: n,
395
+ lowRank,
396
+ highRank,
397
+ low: sorted[lowRank - 1],
398
+ high: sorted[highRank - 1]
399
+ } }
400
+ };
401
+ }
402
+ /**
403
+ * Average-rank-with-ties transform (1-indexed). Tied values receive the mean
404
+ * of the ranks they span, the standard correction for Spearman's ρ.
405
+ */
406
+ function ranks(xs) {
407
+ const indexed = xs.map((v, i) => ({
408
+ v,
409
+ i
410
+ })).sort((a, b) => a.v - b.v);
411
+ const r = new Array(xs.length);
412
+ let i = 0;
413
+ while (i < indexed.length) {
414
+ let j = i;
415
+ while (j + 1 < indexed.length && indexed[j + 1].v === indexed[i].v) j++;
416
+ const avg = (i + j) / 2 + 1;
417
+ for (let k = i; k <= j; k++) r[indexed[k].i] = avg;
418
+ i = j + 1;
419
+ }
420
+ return r;
421
+ }
422
+ /**
423
+ * Pearson product-moment correlation coefficient r ∈ [-1, 1] between two
424
+ * equal-length series. See the edge-case contract above: NaN for n < 2 or
425
+ * unequal lengths, 1 when both series are constant, 0 when exactly one is.
426
+ */
427
+ function pearsonR(a, b) {
428
+ if (a.length !== b.length || a.length < 2) return NaN;
429
+ const n = a.length;
430
+ const meanA = a.reduce((s, v) => s + v, 0) / n;
431
+ const meanB = b.reduce((s, v) => s + v, 0) / n;
432
+ let num = 0;
433
+ let varA = 0;
434
+ let varB = 0;
435
+ for (let i = 0; i < n; i++) {
436
+ const da = a[i] - meanA;
437
+ const db = b[i] - meanB;
438
+ num += da * db;
439
+ varA += da * da;
440
+ varB += db * db;
441
+ }
442
+ if (varA === 0 || varB === 0) return varA === 0 && varB === 0 ? 1 : 0;
443
+ return num / Math.sqrt(varA * varB);
444
+ }
445
+ /**
446
+ * Spearman's rank correlation ρ — Pearson over the average-rank-with-ties
447
+ * transform of each series. Same edge-case contract as {@link pearsonR}.
448
+ */
449
+ function spearmanR(a, b) {
450
+ if (a.length !== b.length || a.length < 2) return NaN;
451
+ return pearsonR(ranks(a), ranks(b));
452
+ }
453
+ /**
454
+ * Weighted composite over judge dimensions: `Σ(score_d · w_d) / Σ(w_d)` across
455
+ * the weighted dimensions. The canonical replacement for the per-consumer
456
+ * hand-rolled composite math (tax/legal/creative/gtm each ship a copy).
457
+ *
458
+ * Fail-loud: throws if a weighted dimension is missing from `dims`, if any
459
+ * weight is negative, or if the weights sum to 0 — none of which can produce
460
+ * a meaningful composite.
461
+ */
462
+ function weightedComposite(input) {
463
+ const entries = Object.entries(input.weights);
464
+ if (entries.length === 0) throw new Error("weightedComposite: `weights` is empty — nothing to combine");
465
+ let weightedSum = 0;
466
+ let weightTotal = 0;
467
+ for (const [dim, weight] of entries) {
468
+ if (weight < 0) throw new Error(`weightedComposite: weight for '${dim}' is negative (${weight})`);
469
+ if (!(dim in input.dims)) throw new Error(`weightedComposite: weighted dimension '${dim}' is absent from \`dims\` — refusing to renormalise onto a different denominator`);
470
+ weightedSum += input.dims[dim] * weight;
471
+ weightTotal += weight;
472
+ }
473
+ if (weightTotal === 0) throw new Error("weightedComposite: weights sum to 0 — composite is undefined");
474
+ const composite = weightedSum / weightTotal;
475
+ return input.threshold === void 0 ? { composite } : {
476
+ composite,
477
+ pass: composite >= input.threshold
478
+ };
479
+ }
480
+ // src/statistics/paired-tests.ts
481
+ /**
482
+ * Paired significance tests on continuous scores: the paired t-test, the
483
+ * promotion-gate paired bootstrap, the exact sign test, and the package-wide
484
+ * paired-delta decision statistic.
485
+ */
486
+ /**
487
+ * Paired t-test — before/after measurements on the SAME items.
488
+ * Pairing removes inter-item variance, giving tighter significance than
489
+ * an unpaired test when comparing prompt v1 vs prompt v2 on identical
490
+ * scenarios.
491
+ *
492
+ * Returns `t = p = null` where the statistic is undefined: fewer than two
493
+ * pairs, or a non-zero constant delta whose observed variance is zero. A
494
+ * constant shift carries no information about the variance it would have to
495
+ * be compared against, so the honest answer is "undefined", not `p = 0` —
496
+ * three observations cannot buy absolute certainty. This is the same contract
497
+ * {@link pairedCohensDz} states for the same condition. An all-zero delta is
498
+ * different: it is a measured null, and returns `t = 0, p = 1`.
499
+ */
500
+ function pairedTTest(before, after) {
501
+ if (before.length !== after.length) throw new ValidationError(`pairedTTest: unequal sample sizes (${before.length} vs ${after.length})`);
502
+ assertFiniteSample("pairedTTest", "before", before);
503
+ assertFiniteSample("pairedTTest", "after", after);
504
+ const n = before.length;
505
+ if (n < 2) return {
506
+ t: null,
507
+ df: 0,
508
+ p: null
509
+ };
510
+ const diffs = before.map((b, i) => after[i] - b);
511
+ const mean = diffs.reduce((a, b) => a + b, 0) / n;
512
+ const variance = diffs.reduce((acc, d) => acc + (d - mean) ** 2, 0) / (n - 1);
513
+ const se = Math.sqrt(variance / n);
514
+ if (se === 0) return mean === 0 ? {
515
+ t: 0,
516
+ df: n - 1,
517
+ p: 1
518
+ } : {
519
+ t: null,
520
+ df: n - 1,
521
+ p: null
522
+ };
523
+ const t = mean / se;
524
+ const df = n - 1;
525
+ return {
526
+ t,
527
+ df,
528
+ p: 2 * (1 - studentTCdf(Math.abs(t), df))
529
+ };
530
+ }
531
+ /**
532
+ * Pairs below which a percentile bootstrap interval is descriptive spread only.
533
+ *
534
+ * `P(low > 0)` under a true null, against a nominal 2.5 %, measured over 4000
535
+ * seeded trials: 13.53 % at n = 3, 3.52 % at n = 10, 3.10 % at n = 20 on the
536
+ * median; 13.85 %, 4.90 %, 3.80 % on the mean. This is intrinsic to resampling
537
+ * three points, not an implementation error — scipy's BCa gives 16.0 % on the
538
+ * same n = 3 data — so no change to the estimator moves it. Below this floor
539
+ * the decision belongs to the exact sign test or exact signed-rank test.
540
+ */
541
+ const BOOTSTRAP_GATE_MIN_N = 20;
542
+ /**
543
+ * Paired bootstrap on (after − before) deltas. Returns a CI on the chosen
544
+ * statistic (median by default); pairs are resampled with replacement. Throws
545
+ * on unequal sample sizes.
546
+ *
547
+ * `low > threshold` carries the stated confidence ONLY at `n ≥
548
+ * {@link BOOTSTRAP_GATE_MIN_N}`, which `gateEligible` reports. Below it the
549
+ * check fires under a true null several times more often than nominal, so the
550
+ * interval is descriptive spread and a promotion must not turn on it.
551
+ */
552
+ function pairedBootstrap(before, after, opts = {}) {
553
+ if (before.length !== after.length) throw new Error(`pairedBootstrap: unequal sample sizes (${before.length} vs ${after.length})`);
554
+ const confidence = opts.confidence ?? .95;
555
+ const resamples = opts.resamples ?? 2e3;
556
+ const statistic = opts.statistic ?? "median";
557
+ if (confidence <= 0 || confidence >= 1) throw new Error(`pairedBootstrap: confidence must be in (0,1), got ${confidence}`);
558
+ const n = before.length;
559
+ const deltas = before.map((b, i) => after[i] - b);
560
+ const gateEligible = n >= 20;
561
+ if (n === 0) return {
562
+ n: 0,
563
+ median: 0,
564
+ mean: 0,
565
+ low: 0,
566
+ high: 0,
567
+ confidence,
568
+ resamples,
569
+ gateEligible
570
+ };
571
+ if (n === 1) {
572
+ const d = deltas[0];
573
+ return {
574
+ n: 1,
575
+ median: d,
576
+ mean: d,
577
+ low: d,
578
+ high: d,
579
+ confidence,
580
+ resamples,
581
+ gateEligible
582
+ };
583
+ }
584
+ const rng = makeRng(opts.seed, deltas);
585
+ const samples = new Array(resamples);
586
+ for (let b = 0; b < resamples; b++) if (statistic === "mean") {
587
+ let sum = 0;
588
+ for (let k = 0; k < n; k++) sum += deltas[Math.floor(rng() * n)];
589
+ samples[b] = sum / n;
590
+ } else {
591
+ const acc = new Array(n);
592
+ for (let k = 0; k < n; k++) acc[k] = deltas[Math.floor(rng() * n)];
593
+ samples[b] = medianInPlace(acc);
594
+ }
595
+ samples.sort((a, b) => a - b);
596
+ const alpha = 1 - confidence;
597
+ const lowIdx = Math.floor(alpha / 2 * resamples);
598
+ const highIdx = Math.min(resamples - 1, Math.ceil((1 - alpha / 2) * resamples) - 1);
599
+ return {
600
+ n,
601
+ median: medianInPlace([...deltas]),
602
+ mean: deltas.reduce((s, x) => s + x, 0) / n,
603
+ low: samples[lowIdx],
604
+ high: samples[Math.max(highIdx, lowIdx)],
605
+ confidence,
606
+ resamples,
607
+ gateEligible
608
+ };
609
+ }
610
+ /**
611
+ * Exact one-sided sign test over paired differences.
612
+ *
613
+ * Pass `after[i] - before[i]` for each matched item. `alternative = 'greater'`
614
+ * tests whether positive signs are more likely than negative signs and returns
615
+ * `P(Binomial(nNonTies, 0.5) >= positive)`. `alternative = 'less'` treats
616
+ * negative signs as successes instead. With a continuous difference
617
+ * distribution this is the usual directional median test. Exact zero
618
+ * differences are ties and do not enter the binomial denominator. All-tie and
619
+ * empty inputs return p = 1. Every input difference must be finite, and the
620
+ * direction must be chosen explicitly so a caller cannot select it after
621
+ * seeing the signs.
622
+ */
623
+ function pairedSignTest(differences, alternative) {
624
+ if (alternative !== "greater" && alternative !== "less") throw new ValidationError(`pairedSignTest: alternative must be 'greater' or 'less', got ${alternative}`);
625
+ let positive = 0;
626
+ let negative = 0;
627
+ let ties = 0;
628
+ for (let i = 0; i < differences.length; i++) {
629
+ const difference = differences[i];
630
+ if (!Number.isFinite(difference)) throw new ValidationError(`pairedSignTest: difference at index ${i} must be finite, got ${difference}`);
631
+ if (difference > 0) positive++;
632
+ else if (difference < 0) negative++;
633
+ else ties++;
634
+ }
635
+ const nNonTies = positive + negative;
636
+ const successes = alternative === "greater" ? positive : negative;
637
+ return {
638
+ n: differences.length,
639
+ positive,
640
+ negative,
641
+ ties,
642
+ nNonTies,
643
+ alternative,
644
+ pValue: binomialHalfUpperTail(successes, nNonTies)
645
+ };
646
+ }
647
+ /** Fraction of paired observations whose delta is an exact tie (|after − before|
648
+ * < 1e-9). Throws on unequal sample sizes; 0 pairs ⇒ 0. */
649
+ function pairedDeltaTieFraction(before, after) {
650
+ if (before.length !== after.length) throw new Error(`pairedDeltaTieFraction: unequal sample sizes (${before.length} vs ${after.length})`);
651
+ const n = before.length;
652
+ if (n === 0) return 0;
653
+ let ties = 0;
654
+ for (let i = 0; i < n; i++) if (Math.abs(after[i] - before[i]) < 1e-9) ties++;
655
+ return ties / n;
656
+ }
657
+ /**
658
+ * The paired-delta statistic a DECISION is computed on, package-wide.
659
+ *
660
+ * The mean paired delta is the estimator that answers the question a promotion
661
+ * gate asks — "by how much did the candidate move the score" — in the caller's
662
+ * own units, and it equals the aggregate lift everyone quotes. The MEDIAN
663
+ * answers a different question and loses the answer to this one in every regime
664
+ * eval data actually lands in:
665
+ * - TWO-POINT (pass/fail) outcomes on any encoding: the delta vector lives in
666
+ * {−s, 0, +s} dominated by zeros, so the median and its whole bootstrap CI
667
+ * are pinned at exactly 0 however large the shift. (Decide these on
668
+ * {@link pairedRiskDifferenceExact} instead — same estimand, exact interval.)
669
+ * - TIE-DOMINATED outcomes: at half the pairs tied the sample median is 0 by
670
+ * construction, and `ci.low > threshold` then answers "no" forever at a
671
+ * non-negative threshold and "yes" forever at a negative one.
672
+ * - LOW-CARDINALITY outcomes, even well below half ties: judge dimensions on
673
+ * integer 0-100, and block scores like {⅔, 1} from averaging pass/fail
674
+ * leaves, put the median on a coarse lattice whose bootstrap percentiles
675
+ * land on atoms. Measured: 26 blocks of 3 pass/fail leaves carrying a real
676
+ * +12.8pp lift, only 23% of pairs tied, gives a median CI of [0, 0.333] —
677
+ * lower bound exactly 0, so a gate at threshold 0 refuses a real lift.
678
+ * That last case is why there is no tie-fraction threshold here: any cutoff on
679
+ * ties leaves the lattice case open on the other side of it.
680
+ *
681
+ * `heldoutSignificance` has defaulted to the mean since #316 for the same
682
+ * reason. The median remains available per call site for callers who
683
+ * specifically want outlier robustness and accept the blindness.
684
+ */
685
+ const DECISION_PAIRED_DELTA_STATISTIC = "mean";
686
+ export { regularizedIncompleteBeta as A, medianInPlace as C, studentTCdf as D, zQuantile as E, studentTQuantile as O, makeRng as S, symmetricTwoSampleSeed as T, mean as _, pairedSignTest as a, assertFiniteSample as b, meanConfidenceInterval as c, ranks as d, spearmanR as f, weightedMean as g, weightedComposite as h, pairedDeltaTieFraction as i, lnGamma as k, partialCredit as l, summarizeNumberSeries as m, DECISION_PAIRED_DELTA_STATISTIC as n, pairedTTest as o, studentTCritical as p, pairedBootstrap as r, confidenceInterval as s, BOOTSTRAP_GATE_MIN_N as t, pearsonR as u, meanOrNull as v, seedFromData as w, binomialSignTwoSided as x, meanOrZero as y };
687
+
688
+ //# sourceMappingURL=paired-tests-CXcD_B80.js.map