@tangle-network/agent-eval 2.0.9 → 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 (232) hide show
  1. package/CHANGELOG.md +64 -16
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-ORN4aArD.d.ts → agent-profile-_JzxgLDM.d.ts} +11 -5
  4. package/dist/{agent-profile-ORN4aArD.d.ts.map → agent-profile-_JzxgLDM.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +14 -14
  6. package/dist/analyst/index.js +31 -10
  7. package/dist/analyst/index.js.map +1 -1
  8. package/dist/{analyze-runs-DT693FJ7.d.ts → analyze-runs-Izz_ZeWg.d.ts} +2 -2
  9. package/dist/{analyze-runs-DT693FJ7.d.ts.map → analyze-runs-Izz_ZeWg.d.ts.map} +1 -1
  10. package/dist/{analyze-runs-CE_5VKh2.js → analyze-runs-xhH2Qxoc.js} +5 -5
  11. package/dist/{analyze-runs-CE_5VKh2.js.map → analyze-runs-xhH2Qxoc.js.map} +1 -1
  12. package/dist/app-grade/index.d.ts +4 -4
  13. package/dist/{benchmark-command-DLg8E4y8.js → benchmark-command-CGQXNFj7.js} +8 -7
  14. package/dist/benchmark-command-CGQXNFj7.js.map +1 -0
  15. package/dist/benchmarks/index.d.ts +4 -4
  16. package/dist/benchmarks/index.js +2 -2
  17. package/dist/campaign/index.d.ts +7 -7
  18. package/dist/campaign/index.js +11 -11
  19. package/dist/{campaign-C_S3MOYa.js → campaign-eus7YRs2.js} +13 -13
  20. package/dist/{campaign-C_S3MOYa.js.map → campaign-eus7YRs2.js.map} +1 -1
  21. package/dist/{campaign-evidence-CM4FBOkX.d.ts → campaign-evidence-BOcX4w0r.d.ts} +5 -5
  22. package/dist/{campaign-evidence-CM4FBOkX.d.ts.map → campaign-evidence-BOcX4w0r.d.ts.map} +1 -1
  23. package/dist/{campaign-evidence-BTfzZo1u.js → campaign-evidence-KM5GTsHG.js} +3 -3
  24. package/dist/{campaign-evidence-BTfzZo1u.js.map → campaign-evidence-KM5GTsHG.js.map} +1 -1
  25. package/dist/{chat-client-uQNXGuO4.d.ts → chat-client-BlTooBDA.d.ts} +7 -2
  26. package/dist/{chat-client-uQNXGuO4.d.ts.map → chat-client-BlTooBDA.d.ts.map} +1 -1
  27. package/dist/{chat-client-CvyDOQBv.js → chat-client-Oyot5tyo.js} +2 -2
  28. package/dist/{chat-client-CvyDOQBv.js.map → chat-client-Oyot5tyo.js.map} +1 -1
  29. package/dist/{chat-json-call-DMrwmB-k.js → chat-json-call-DTmv2uNY.js} +2 -2
  30. package/dist/{chat-json-call-DMrwmB-k.js.map → chat-json-call-DTmv2uNY.js.map} +1 -1
  31. package/dist/cli.js +7 -7
  32. package/dist/{cluster-C-K0N2br.d.ts → cluster-BJ0nW3P7.d.ts} +2 -2
  33. package/dist/{cluster-C-K0N2br.d.ts.map → cluster-BJ0nW3P7.d.ts.map} +1 -1
  34. package/dist/{cluster-bootstrap-DXbnIdm8.js → cluster-bootstrap-CTC8Dd30.js} +2 -2
  35. package/dist/{cluster-bootstrap-DXbnIdm8.js.map → cluster-bootstrap-CTC8Dd30.js.map} +1 -1
  36. package/dist/{completion-verifier-DsotH2l3.js → completion-verifier-CCPG2Yc0.js} +3 -3
  37. package/dist/{completion-verifier-DsotH2l3.js.map → completion-verifier-CCPG2Yc0.js.map} +1 -1
  38. package/dist/{completion-verifier-C7wipJOK.d.ts → completion-verifier-CQOC3_bm.d.ts} +2 -2
  39. package/dist/{completion-verifier-C7wipJOK.d.ts.map → completion-verifier-CQOC3_bm.d.ts.map} +1 -1
  40. package/dist/contract/index.d.ts +11 -11
  41. package/dist/contract/index.js +12 -12
  42. package/dist/{default-registry-kps1SOaD.js → default-registry-Rs5uzlfJ.js} +3 -3
  43. package/dist/{default-registry-kps1SOaD.js.map → default-registry-Rs5uzlfJ.js.map} +1 -1
  44. package/dist/{default-registry-Bskl2HzV.d.ts → default-registry-X8McMoUV.d.ts} +6 -6
  45. package/dist/{default-registry-Bskl2HzV.d.ts.map → default-registry-X8McMoUV.d.ts.map} +1 -1
  46. package/dist/{define-agent-eval-Dnh4jXLX.js → define-agent-eval-D8ntOXqV.js} +3 -3
  47. package/dist/{define-agent-eval-Dnh4jXLX.js.map → define-agent-eval-D8ntOXqV.js.map} +1 -1
  48. package/dist/{define-agent-eval-tu3anVlk.d.ts → define-agent-eval-DH5-xi-F.d.ts} +4 -4
  49. package/dist/{define-agent-eval-tu3anVlk.d.ts.map → define-agent-eval-DH5-xi-F.d.ts.map} +1 -1
  50. package/dist/diagnosis/index.d.ts +2 -2
  51. package/dist/diagnosis/index.js +1 -1
  52. package/dist/{dspy-rlm-engine-DQbPdT_o.js → dspy-rlm-engine-ChE1PUM5.js} +3 -3
  53. package/dist/{dspy-rlm-engine-DQbPdT_o.js.map → dspy-rlm-engine-ChE1PUM5.js.map} +1 -1
  54. package/dist/{eval-campaign-DswSn7Gm.js → eval-campaign-BciGnrGy.js} +2 -2
  55. package/dist/{eval-campaign-DswSn7Gm.js.map → eval-campaign-BciGnrGy.js.map} +1 -1
  56. package/dist/{evaluation-C4-tf3Z_.d.ts → evaluation-CjZH6gW0.d.ts} +4 -4
  57. package/dist/{evaluation-C4-tf3Z_.d.ts.map → evaluation-CjZH6gW0.d.ts.map} +1 -1
  58. package/dist/evaluation.d.ts +1 -1
  59. package/dist/{exact-types-CUsSMW3n.d.ts → exact-types-BIHqYBYf.d.ts} +2 -2
  60. package/dist/{exact-types-CUsSMW3n.d.ts.map → exact-types-BIHqYBYf.d.ts.map} +1 -1
  61. package/dist/experiment/index.d.ts +5 -5
  62. package/dist/experiment/index.js +8 -8
  63. package/dist/{external-optimizer-contracts-ZDBfbZ_s.js → external-optimizer-contracts-BFV8lnhl.js} +7 -2
  64. package/dist/{external-optimizer-contracts-ZDBfbZ_s.js.map → external-optimizer-contracts-BFV8lnhl.js.map} +1 -1
  65. package/dist/{external-optimizer-process-CVi1x2nb.js → external-optimizer-process-B6emPodQ.js} +3 -3
  66. package/dist/{external-optimizer-process-CVi1x2nb.js.map → external-optimizer-process-B6emPodQ.js.map} +1 -1
  67. package/dist/{external-optimizer-subprocess-mV-2swJI.js → external-optimizer-subprocess-_O06eDVA.js} +33 -20
  68. package/dist/external-optimizer-subprocess-_O06eDVA.js.map +1 -0
  69. package/dist/{feedback-trajectory-D7hgL6y5.d.ts → feedback-trajectory-CoQPmSJV.d.ts} +3 -3
  70. package/dist/{feedback-trajectory-D7hgL6y5.d.ts.map → feedback-trajectory-CoQPmSJV.d.ts.map} +1 -1
  71. package/dist/{findings-store-CZy5kUDo.js → findings-store-CvYUzQBR.js} +4 -4
  72. package/dist/{findings-store-CZy5kUDo.js.map → findings-store-CvYUzQBR.js.map} +1 -1
  73. package/dist/{index-Cav3abKy.d.ts → index-BSb3fJyZ.d.ts} +81 -19
  74. package/dist/{index-Cav3abKy.d.ts.map → index-BSb3fJyZ.d.ts.map} +1 -1
  75. package/dist/{index-CIqYaySd.d.ts → index-Bk1XEkP7.d.ts} +26 -16
  76. package/dist/index-Bk1XEkP7.d.ts.map +1 -0
  77. package/dist/{index-DmMHTDjT.d.ts → index-BmWw8zN6.d.ts} +9 -9
  78. package/dist/{index-DmMHTDjT.d.ts.map → index-BmWw8zN6.d.ts.map} +1 -1
  79. package/dist/{index--vDCtdaj.d.ts → index-CCOaNmh2.d.ts} +7 -7
  80. package/dist/{index--vDCtdaj.d.ts.map → index-CCOaNmh2.d.ts.map} +1 -1
  81. package/dist/{index-moZnazVj.d.ts → index-ZffK_5sD.d.ts} +21 -21
  82. package/dist/{index-moZnazVj.d.ts.map → index-ZffK_5sD.d.ts.map} +1 -1
  83. package/dist/{index-Er8TKQ3q.d.ts → index-aRalB_Ma.d.ts} +3 -3
  84. package/dist/{index-Er8TKQ3q.d.ts.map → index-aRalB_Ma.d.ts.map} +1 -1
  85. package/dist/index.d.ts +29 -29
  86. package/dist/index.js +23 -23
  87. package/dist/{integrity-BF0tJK21.js → integrity-DacT3oJ1.js} +2 -2
  88. package/dist/{integrity-BF0tJK21.js.map → integrity-DacT3oJ1.js.map} +1 -1
  89. package/dist/{integrity-BJGstiCh.d.ts → integrity-DotDLWtj.d.ts} +2 -2
  90. package/dist/{integrity-BJGstiCh.d.ts.map → integrity-DotDLWtj.d.ts.map} +1 -1
  91. package/dist/{judge-gate-DANg5FLq.js → judge-gate-CpD3wmcf.js} +2 -2
  92. package/dist/{judge-gate-DANg5FLq.js.map → judge-gate-CpD3wmcf.js.map} +1 -1
  93. package/dist/{llm-client-Dw4x6EdE.js → llm-client-Dk8lBnMh.js} +15 -2
  94. package/dist/{llm-client-Dw4x6EdE.js.map → llm-client-Dk8lBnMh.js.map} +1 -1
  95. package/dist/{llm-judge-DFoSy4Qn.js → llm-judge-DYmEdo3M.js} +3 -3
  96. package/dist/{llm-judge-DFoSy4Qn.js.map → llm-judge-DYmEdo3M.js.map} +1 -1
  97. package/dist/{matrix-OgdWQBQa.d.ts → matrix-BDl7hoBr.d.ts} +2 -2
  98. package/dist/{matrix-OgdWQBQa.d.ts.map → matrix-BDl7hoBr.d.ts.map} +1 -1
  99. package/dist/{measure-validity-plan-B1_qYlsk.d.ts → measure-validity-plan-BReXzcVh.d.ts} +62 -4
  100. package/dist/measure-validity-plan-BReXzcVh.d.ts.map +1 -0
  101. package/dist/{measure-validity-plan-t0YQRzJQ.js → measure-validity-plan-CJkBNzX_.js} +43 -6
  102. package/dist/measure-validity-plan-CJkBNzX_.js.map +1 -0
  103. package/dist/meta-eval/index.d.ts +2 -2
  104. package/dist/meta-eval/index.js +178 -35
  105. package/dist/meta-eval/index.js.map +1 -1
  106. package/dist/multishot/golden/index.d.ts +1 -1
  107. package/dist/multishot/index.d.ts +56 -17
  108. package/dist/multishot/index.d.ts.map +1 -1
  109. package/dist/multishot/index.js +93 -20
  110. package/dist/multishot/index.js.map +1 -1
  111. package/dist/node-transport-DJno8V46.js +62 -0
  112. package/dist/node-transport-DJno8V46.js.map +1 -0
  113. package/dist/openapi.json +1 -1
  114. package/dist/{optimization-method-D4CpYsVA.js → optimization-method-4JlbMxd2.js} +27 -38
  115. package/dist/optimization-method-4JlbMxd2.js.map +1 -0
  116. package/dist/{paired-arms-B6EXnI47.js → paired-arms-CJH5Q0wx.js} +2 -2
  117. package/dist/{paired-arms-B6EXnI47.js.map → paired-arms-CJH5Q0wx.js.map} +1 -1
  118. package/dist/{paired-promotion-decision-xYe881cD.js → paired-promotion-decision-BtfVwEAk.js} +2 -2
  119. package/dist/{paired-promotion-decision-xYe881cD.js.map → paired-promotion-decision-BtfVwEAk.js.map} +1 -1
  120. package/dist/{paired-promotion-decision-DuvRdnsW.d.ts → paired-promotion-decision-DJlI4z_k.d.ts} +2 -2
  121. package/dist/{paired-promotion-decision-DuvRdnsW.d.ts.map → paired-promotion-decision-DJlI4z_k.d.ts.map} +1 -1
  122. package/dist/{paired-promotion-power-DirShsIs.js → paired-promotion-power-DG1avBKf.js} +3 -3
  123. package/dist/{paired-promotion-power-DirShsIs.js.map → paired-promotion-power-DG1avBKf.js.map} +1 -1
  124. package/dist/pipelines/index.js +1 -1
  125. package/dist/{power-DTg6u30w.js → power-COie_o6E.js} +3 -3
  126. package/dist/{power-DTg6u30w.js.map → power-COie_o6E.js.map} +1 -1
  127. package/dist/{prime-protocol-Jm2pWh--.d.ts → prime-protocol-BRMk6dGI.d.ts} +2 -2
  128. package/dist/{prime-protocol-Jm2pWh--.d.ts.map → prime-protocol-BRMk6dGI.d.ts.map} +1 -1
  129. package/dist/{promotion-gate-BXgcORnM.d.ts → promotion-gate-B0VTBoXg.d.ts} +2 -2
  130. package/dist/{promotion-gate-BXgcORnM.d.ts.map → promotion-gate-B0VTBoXg.d.ts.map} +1 -1
  131. package/dist/{promotion-policy-Z5E-C32U.js → promotion-policy-BgI7PsQn.js} +3 -3
  132. package/dist/{promotion-policy-Z5E-C32U.js.map → promotion-policy-BgI7PsQn.js.map} +1 -1
  133. package/dist/{registry-DEZDECdr.d.ts → registry-BeInzotS.d.ts} +4 -4
  134. package/dist/{registry-DEZDECdr.d.ts.map → registry-BeInzotS.d.ts.map} +1 -1
  135. package/dist/reporting.d.ts +4 -4
  136. package/dist/reporting.js +3 -3
  137. package/dist/{research-report-CIgUe1lv.d.ts → research-report-CL5_UqCX.d.ts} +2 -2
  138. package/dist/{research-report-CIgUe1lv.d.ts.map → research-report-CL5_UqCX.d.ts.map} +1 -1
  139. package/dist/{researcher-CY_byuZl.d.ts → researcher-BOpZP_Ja.d.ts} +4 -4
  140. package/dist/{researcher-CY_byuZl.d.ts.map → researcher-BOpZP_Ja.d.ts.map} +1 -1
  141. package/dist/rl.d.ts +7 -7
  142. package/dist/rl.js +4 -4
  143. package/dist/rollout/index.d.ts +2 -2
  144. package/dist/rollout/index.js +1 -1
  145. package/dist/{rollout-B_lrpd9a.js → rollout--rSr43Pd.js} +2 -2
  146. package/dist/{rollout-B_lrpd9a.js.map → rollout--rSr43Pd.js.map} +1 -1
  147. package/dist/{rollout-nodes-Vas6OSxX.js → rollout-nodes-DFxKpIr2.js} +39 -10
  148. package/dist/rollout-nodes-DFxKpIr2.js.map +1 -0
  149. package/dist/{run-improvement-loop-BaPDVbW8.d.ts → run-improvement-loop-BeHu5D9Z.d.ts} +22 -10
  150. package/dist/run-improvement-loop-BeHu5D9Z.d.ts.map +1 -0
  151. package/dist/{runtime-rollouts-Vv-BAqmq.js → runtime-rollouts-CE0MbQPq.js} +54 -7
  152. package/dist/runtime-rollouts-CE0MbQPq.js.map +1 -0
  153. package/dist/search/index.d.ts +2 -2
  154. package/dist/search/index.js +2 -2
  155. package/dist/{search-kernel-BzTeb89p.d.ts → search-kernel-CJZ-ZSV1.d.ts} +3 -3
  156. package/dist/{search-kernel-BzTeb89p.d.ts.map → search-kernel-CJZ-ZSV1.d.ts.map} +1 -1
  157. package/dist/{search-kernel-DOPW08Hx.js → search-kernel-mZc79S6N.js} +4 -4
  158. package/dist/{search-kernel-DOPW08Hx.js.map → search-kernel-mZc79S6N.js.map} +1 -1
  159. package/dist/{search-summary-CYOHZAAy.js → search-summary-CCgP2qXz.js} +3 -3
  160. package/dist/{search-summary-CYOHZAAy.js.map → search-summary-CCgP2qXz.js.map} +1 -1
  161. package/dist/{self-improve-DY8ZY4lY.d.ts → self-improve-B1fsNejr.d.ts} +6 -6
  162. package/dist/{self-improve-DY8ZY4lY.d.ts.map → self-improve-B1fsNejr.d.ts.map} +1 -1
  163. package/dist/{self-improve-CIFqccHV.js → self-improve-C_Bcdmv8.js} +5 -4
  164. package/dist/{self-improve-CIFqccHV.js.map → self-improve-C_Bcdmv8.js.map} +1 -1
  165. package/dist/{sequential-B9iROM1S.d.ts → sequential-CHplorpC.d.ts} +2 -2
  166. package/dist/{sequential-B9iROM1S.d.ts.map → sequential-CHplorpC.d.ts.map} +1 -1
  167. package/dist/{sequential-tZjGysXY.js → sequential-DR-pnYQ7.js} +3 -3
  168. package/dist/{sequential-tZjGysXY.js.map → sequential-DR-pnYQ7.js.map} +1 -1
  169. package/dist/{server-1fzBCxMh.js → server-aZFmRucn.js} +3 -3
  170. package/dist/{server-1fzBCxMh.js.map → server-aZFmRucn.js.map} +1 -1
  171. package/dist/{skillopt-optimization-method-CbHBkopM.js → skillopt-optimization-method-DHk1K757.js} +93 -39
  172. package/dist/skillopt-optimization-method-DHk1K757.js.map +1 -0
  173. package/dist/{statistical-heldout-C7Jjo5nP.js → statistical-heldout-CL_7mI5C.js} +2 -2
  174. package/dist/{statistical-heldout-C7Jjo5nP.js.map → statistical-heldout-CL_7mI5C.js.map} +1 -1
  175. package/dist/{statistics-BPl13X3G.js → statistics-AKnVFnK-.js} +67 -42
  176. package/dist/statistics-AKnVFnK-.js.map +1 -0
  177. package/dist/statistics.d.ts +3 -3
  178. package/dist/statistics.js +1 -1
  179. package/dist/{store-tool-spans-Dq8r0PbJ.d.ts → store-tool-spans-M3WxeRrG.d.ts} +4 -4
  180. package/dist/{store-tool-spans-Dq8r0PbJ.d.ts.map → store-tool-spans-M3WxeRrG.d.ts.map} +1 -1
  181. package/dist/{summary-report-DzbnK81K.js → summary-report-DyBkOC6V.js} +3 -3
  182. package/dist/{summary-report-DzbnK81K.js.map → summary-report-DyBkOC6V.js.map} +1 -1
  183. package/dist/supervisor-run/index.d.ts +12 -2
  184. package/dist/supervisor-run/index.d.ts.map +1 -1
  185. package/dist/supervisor-run/index.js +3 -3
  186. package/dist/{systemone-BuSZTI88.d.ts → systemone-4PadCE4C.d.ts} +7 -7
  187. package/dist/{systemone-BuSZTI88.d.ts.map → systemone-4PadCE4C.d.ts.map} +1 -1
  188. package/dist/{systemone-review-mlfxWdLz.d.ts → systemone-review-DpAXWDkL.d.ts} +2 -2
  189. package/dist/{systemone-review-mlfxWdLz.d.ts.map → systemone-review-DpAXWDkL.d.ts.map} +1 -1
  190. package/dist/systemone.d.ts +3 -3
  191. package/dist/{tool-groups-PNDX8fd-.d.ts → tool-groups-SlnoQNyT.d.ts} +2 -2
  192. package/dist/tool-groups-SlnoQNyT.d.ts.map +1 -0
  193. package/dist/{tool-waste-783VCo1y.js → tool-waste-BZnYSa6J.js} +2 -2
  194. package/dist/{tool-waste-783VCo1y.js.map → tool-waste-BZnYSa6J.js.map} +1 -1
  195. package/dist/{trace-questions-DBtr4jWi.d.ts → trace-questions-ybyF0B6N.d.ts} +2 -2
  196. package/dist/{trace-questions-DBtr4jWi.d.ts.map → trace-questions-ybyF0B6N.d.ts.map} +1 -1
  197. package/dist/trace-repair/index.d.ts +1 -1
  198. package/dist/traces.d.ts +4 -4
  199. package/dist/{tree-CtlQQL1w.js → tree-CiIe-f3f.js} +4 -4
  200. package/dist/{tree-CtlQQL1w.js.map → tree-CiIe-f3f.js.map} +1 -1
  201. package/dist/{types-CKNAzCSA.d.ts → types-B1W3v8dT.d.ts} +3 -3
  202. package/dist/{types-CKNAzCSA.d.ts.map → types-B1W3v8dT.d.ts.map} +1 -1
  203. package/dist/{types-BO948H-U.d.ts → types-D5XtEH9Q.d.ts} +8 -4
  204. package/dist/{types-BO948H-U.d.ts.map → types-D5XtEH9Q.d.ts.map} +1 -1
  205. package/dist/{types-DbeIGi73.d.ts → types-an-CUndX.d.ts} +2 -2
  206. package/dist/{types-DbeIGi73.d.ts.map → types-an-CUndX.d.ts.map} +1 -1
  207. package/dist/{types-D-WF1KM3.d.ts → types-xVtEOBhO.d.ts} +31 -8
  208. package/dist/types-xVtEOBhO.d.ts.map +1 -0
  209. package/dist/wire/index.d.ts +4 -4
  210. package/dist/wire/index.js +1 -1
  211. package/dist/world/index.d.ts +1 -1
  212. package/docs/design/statistics-decisions.md +18 -1
  213. package/docs/eval-surface-map.md +1 -1
  214. package/docs/feature-guide.md +1 -1
  215. package/docs/multi-turn-optimization.md +6 -2
  216. package/docs/outcome-validity.md +51 -12
  217. package/docs/public-api.md +7 -7
  218. package/docs/{multi-shot-optimization.md → trajectory-optimization.md} +1 -1
  219. package/package.json +1 -1
  220. package/dist/benchmark-command-DLg8E4y8.js.map +0 -1
  221. package/dist/external-optimizer-subprocess-mV-2swJI.js.map +0 -1
  222. package/dist/index-CIqYaySd.d.ts.map +0 -1
  223. package/dist/measure-validity-plan-B1_qYlsk.d.ts.map +0 -1
  224. package/dist/measure-validity-plan-t0YQRzJQ.js.map +0 -1
  225. package/dist/optimization-method-D4CpYsVA.js.map +0 -1
  226. package/dist/rollout-nodes-Vas6OSxX.js.map +0 -1
  227. package/dist/run-improvement-loop-BaPDVbW8.d.ts.map +0 -1
  228. package/dist/runtime-rollouts-Vv-BAqmq.js.map +0 -1
  229. package/dist/skillopt-optimization-method-CbHBkopM.js.map +0 -1
  230. package/dist/statistics-BPl13X3G.js.map +0 -1
  231. package/dist/tool-groups-PNDX8fd-.d.ts.map +0 -1
  232. package/dist/types-D-WF1KM3.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"power-DTg6u30w.js","names":[],"sources":["../src/campaign/gates/sequential.ts","../src/experiment/power.ts"],"sourcesContent":["/**\n * Anytime-valid sequential promotion gate — an e-process (betting\n * test-martingale, see `eProcess` in `statistics.ts`) over paired\n * per-scenario deltas, so a campaign stops the MOMENT evidence decides\n * instead of burning a fixed-n budget. Decisions remain valid at any\n * data-dependent stopping time (Ville's inequality), which is exactly what\n * fixed-n machinery cannot offer: peeking at a bootstrap CI after every\n * observation and stopping on the first significant peek inflates type-I\n * error far beyond alpha.\n *\n * REPLACES, never layers on, a fixed-n gate. Running `heldoutSignificance`\n * or `paretoSignificanceGate` repeatedly on a growing sample and stopping\n * early is optional stopping no matter how it is dressed up; this gate is\n * the valid way to stop early. Use one or the other per evidence stream.\n *\n * Pre-registration binding: anytime validity holds only for the\n * PRE-REGISTERED statistic. When a `SignedManifest` is bound, the gate takes\n * alpha from `manifest.alpha`, the observation budget from\n * `manifest.preRegisteredN`, orients deltas by `manifest.direction`, and\n * shifts the null boundary by `manifest.minEffect` — re-deciding the same\n * stream under different parameters after seeing data would reopen optional\n * stopping under a fancier name. The manifest's content hash is verified at\n * construction with the canonical RFC 8785 digest used by signManifest.\n *\n * The supermartingale guarantee requires E[delta_t | past] ≤ the null\n * boundary under H0. Independent sampling with that mean bound suffices.\n * Exchangeability or shuffling alone does not: one fair sign repeated many\n * times is exchangeable and has marginal mean zero, but its conditional mean\n * becomes the revealed sign. A seeded shuffle cannot remove that dependence.\n * `decide(ctx)` pairs cells, then averages repetitions within each scenario\n * before testing. Pass independentUnitByScenarioId for scenarios sharing a\n * latent source or incident. Units must still satisfy the conditional-mean null.\n * Direct `observe()` callers own this sampling and aggregation contract.\n */\n\nimport { manifestContentDigest, type SignedManifest } from '../../pre-registration'\nimport { type EProcessState, eProcess, mulberry32 } from '../../statistics'\nimport type { Gate, GateContext, GateResult, GenerationRecord, Scenario } from '../types'\nimport { aggregatePairedHoldout, pairHoldout } from './statistical-heldout'\n\nexport type SequentialGateDecision = 'promote' | 'continue' | 'undecided-at-maxN'\n\nexport interface SequentialObservation {\n decision: SequentialGateDecision\n /** Current e-value (the betting wealth) against H0. */\n eValue: number\n /** Paired deltas consumed so far. */\n n: number\n /** Names the decision basis. For 'undecided-at-maxN' it states explicitly\n * that exhausting the budget is NOT evidence of no effect. */\n reason: string\n}\n\nexport interface SequentialPairedGateOptions {\n /** Type-I budget. With `preRegistration` bound this MUST match\n * `manifest.alpha` (conflict throws). Default 0.05. */\n alpha?: number\n /** Minimum independent paired units before a promote may fire. The stopping rule is\n * \"first n ≥ minN with e-value ≥ 1/alpha\" — still a valid stopping time.\n * Default 5. */\n minN?: number\n /** Pre-registered independent-unit budget (scenarios by default in decide()). Required unless `preRegistration`\n * supplies it via `preRegisteredN` (conflict throws). */\n maxN?: number\n /** Bet truncation forwarded to `eProcess`. Default 0.5. */\n maxBet?: number\n /** Bound on |delta| in the judge's native scale; deltas are mapped to\n * x = (d/scale + 1)/2 ∈ [0,1]. A delta outside ±scale throws (use\n * `detectScale` to pick 1 vs 100 BEFORE streaming). Default 1. */\n scale?: number\n /** Seed for reproducible ordering of scenario deltas in decide().\n * Shuffling does not establish the conditional-mean null. Default 1337. */\n shuffleSeed?: number\n /** Independent unit for every scenario passed to decide(). Full cell pairs\n * are averaged within each unit before testing. Defaults to scenario IDs.\n * The mapping is copied at construction. Direct observe() is unchanged. */\n independentUnitByScenarioId?: ReadonlyMap<string, string>\n /** Bind the pre-registered hypothesis. Verified (content hash) at\n * construction; alpha/maxN/direction/minEffect come FROM the manifest. */\n preRegistration?: SignedManifest\n /** Override the gate name in reports. */\n name?: string\n /** Continue the observe-stream from a `state()` snapshot taken before a\n * restart. The gate's parameters still resolve from this options object\n * (and the manifest); the snapshot must have been recorded under the same\n * alpha, maxBet, and null boundary, and its decision must be one this\n * configuration could have reached at its n, or construction throws.\n * `decide(ctx)` is unaffected — it always runs on a fresh stream. */\n resume?: SequentialStreamState\n}\n\n/** Snapshot of one observe-stream: the e-process state plus the gate's own\n * decision, which applies `minN` and `maxN` on top of the core latch. A\n * gate rebuilt with `resume` from this value continues exactly where the\n * snapshot was taken. */\nexport type SequentialStreamState = EProcessState & { decision: SequentialGateDecision }\n\nexport interface SequentialPairedGate<TArtifact = unknown, TScenario extends Scenario = Scenario>\n extends Gate<TArtifact, TScenario> {\n /** Streaming entry point: feed one paired independent-unit delta\n * (candidate − baseline, native scale). Aggregate correlated repetitions\n * before calling; the caller must justify E[delta_t | past] under H0.\n * Each gate instance carries ONE\n * observe-stream; `decide(ctx)` runs on its own fresh stream and never\n * consumes or advances this one. 'promote' is sticky; observing past the\n * pre-registered maxN throws (extending a finished stream after seeing\n * the result reopens optional stopping — start a NEW pre-registered\n * test). */\n observe(delta: number): SequentialObservation\n /** Read-only snapshot of the observe-stream. Pass it back as\n * `resume` to continue the stream after a restart. */\n state(): SequentialStreamState\n}\n\ninterface ResolvedConfig {\n alpha: number\n minN: number\n maxN: number\n maxBet: number\n scale: number\n shuffleSeed: number\n /** 'decrease' negates deltas so \"better\" is always positive. */\n direction: 'increase' | 'decrease'\n /** H0 boundary in x-space: 1/2 + minEffect/(2·scale). */\n nullMean: number\n minEffect: number\n}\n\n/** Sync twin of `verifyManifest`, so gate construction stays synchronous and\n * fails loud before any observation is consumed. The digest scheme belongs to\n * `pre-registration`; this gate only compares. */\nfunction verifyManifestSync(m: SignedManifest): boolean {\n return manifestContentDigest(m) === m.contentHash\n}\n\nfunction resolveConfig(opts: SequentialPairedGateOptions): ResolvedConfig {\n const m = opts.preRegistration\n let alpha: number\n let maxN: number\n let direction: 'increase' | 'decrease'\n let minEffect: number\n if (m) {\n if (!verifyManifestSync(m)) {\n throw new Error(\n `sequentialPairedGate: pre-registration manifest '${m.id}' content hash mismatch (tampered)`,\n )\n }\n if (opts.alpha !== undefined && opts.alpha !== m.alpha) {\n throw new Error(\n `sequentialPairedGate: alpha ${opts.alpha} conflicts with pre-registered alpha ${m.alpha} — ` +\n `the registered statistic is the only one anytime validity covers`,\n )\n }\n if (opts.maxN !== undefined && opts.maxN !== m.preRegisteredN) {\n throw new Error(\n `sequentialPairedGate: maxN ${opts.maxN} conflicts with pre-registered N ${m.preRegisteredN}`,\n )\n }\n alpha = m.alpha\n maxN = m.preRegisteredN\n direction = m.direction\n minEffect = m.minEffect\n } else {\n alpha = opts.alpha ?? 0.05\n if (opts.maxN === undefined) {\n throw new Error(\n 'sequentialPairedGate: maxN is required (or bind a preRegistration manifest whose ' +\n 'preRegisteredN is the budget) — an unbounded stream has no pre-registered budget',\n )\n }\n maxN = opts.maxN\n direction = 'increase'\n minEffect = 0\n }\n const scale = opts.scale ?? 1\n if (!Number.isFinite(scale) || scale <= 0) {\n throw new Error(`sequentialPairedGate: scale must be > 0, got ${scale}`)\n }\n if (!Number.isInteger(maxN) || maxN < 1) {\n throw new Error(`sequentialPairedGate: maxN must be a positive integer, got ${maxN}`)\n }\n const minN = opts.minN ?? 5\n if (!Number.isInteger(minN) || minN < 1 || minN > maxN) {\n throw new Error(\n `sequentialPairedGate: minN must be an integer in [1, maxN=${maxN}], got ${minN}`,\n )\n }\n if (!Number.isFinite(minEffect) || minEffect < 0 || minEffect >= scale) {\n throw new Error(\n `sequentialPairedGate: minEffect must be in [0, scale=${scale}), got ${minEffect}`,\n )\n }\n // H0: mean delta ≤ minEffect. In x = (d/scale + 1)/2 space that is\n // E[x] ≤ 1/2 + minEffect/(2·scale) — a shifted null boundary, NOT a clamp\n // of the observations (clamping is mean-distorting for skewed deltas).\n const nullMean = 0.5 + minEffect / (2 * scale)\n return {\n alpha,\n minN,\n maxN,\n maxBet: opts.maxBet ?? 0.5,\n scale,\n shuffleSeed: opts.shuffleSeed ?? 1337,\n direction,\n nullMean,\n minEffect,\n }\n}\n\ninterface SequentialStream {\n observe(delta: number): SequentialObservation\n state(): SequentialStreamState\n}\n\nconst SEQUENTIAL_DECISIONS: readonly SequentialGateDecision[] = [\n 'promote',\n 'continue',\n 'undecided-at-maxN',\n]\n\n/** Refuse a snapshot whose gate decision this configuration could not have\n * reached at the snapshot's n. The e-process parameters are checked by\n * `eProcess` itself; this covers the gate's own stopping rule. */\nfunction assertResumableStream(resume: SequentialStreamState, cfg: ResolvedConfig): void {\n const fail = (detail: string): never => {\n throw new Error(`sequentialPairedGate: cannot resume — ${detail}`)\n }\n if (!SEQUENTIAL_DECISIONS.includes(resume.decision)) {\n fail(`unknown decision '${String(resume.decision)}'`)\n }\n if (resume.n > cfg.maxN) {\n fail(`snapshot n=${resume.n} exceeds the pre-registered maxN=${cfg.maxN}`)\n }\n const threshold = 1 / cfg.alpha\n switch (resume.decision) {\n case 'promote':\n if (resume.n < cfg.minN) {\n fail(`decision 'promote' at n=${resume.n} is below minN=${cfg.minN}`)\n }\n break\n case 'undecided-at-maxN':\n if (resume.n !== cfg.maxN) {\n fail(`decision 'undecided-at-maxN' at n=${resume.n} does not match maxN=${cfg.maxN}`)\n }\n break\n case 'continue':\n if (resume.n >= cfg.maxN) {\n fail(`decision 'continue' at n=${resume.n} with maxN=${cfg.maxN}; the stream is finished`)\n }\n if (resume.n >= cfg.minN && resume.wealth >= threshold) {\n fail(\n `decision 'continue' at n=${resume.n} ≥ minN=${cfg.minN} with e-value ` +\n `${resume.wealth} ≥ 1/α=${threshold}; this stream would have promoted`,\n )\n }\n break\n }\n}\n\nfunction makeStream(cfg: ResolvedConfig, resume?: SequentialStreamState): SequentialStream {\n if (resume !== undefined) assertResumableStream(resume, cfg)\n const proc = eProcess({\n alpha: cfg.alpha,\n maxBet: cfg.maxBet,\n nullMean: cfg.nullMean,\n ...(resume === undefined ? {} : { resume }),\n })\n const threshold = 1 / cfg.alpha\n let terminal: SequentialGateDecision | undefined =\n resume === undefined || resume.decision === 'continue' ? undefined : resume.decision\n return {\n observe(delta: number): SequentialObservation {\n if (terminal === 'undecided-at-maxN') {\n throw new Error(\n `sequentialPairedGate: pre-registered maxN=${cfg.maxN} exhausted — extending the ` +\n 'stream after seeing the result reopens optional stopping; start a NEW ' +\n 'pre-registered test',\n )\n }\n if (!Number.isFinite(delta) || Math.abs(delta) > cfg.scale) {\n throw new Error(\n `sequentialPairedGate: delta ${delta} outside ±scale=${cfg.scale} — pass the judge's ` +\n `native scale explicitly (detectScale helps pick 1 vs 100)`,\n )\n }\n const d = cfg.direction === 'decrease' ? -delta : delta\n const step = proc.update((d / cfg.scale + 1) / 2)\n // Stopping rule: FIRST n ≥ minN with current wealth ≥ 1/alpha — a valid\n // stopping time (measurable w.r.t. the past), sticky once latched. The\n // core's own `decided` latch ignores minN, so the gate re-derives the\n // decision from current wealth here.\n if (terminal === undefined && step.n >= cfg.minN && step.wealth >= threshold) {\n terminal = 'promote'\n }\n if (terminal === 'promote') {\n return {\n decision: 'promote',\n eValue: step.wealth,\n n: step.n,\n reason:\n `e-value ${step.wealth.toFixed(2)} ≥ 1/α=${threshold.toFixed(2)} at n=${step.n} ` +\n `(minN=${cfg.minN}): the paired improvement exceeds ${cfg.minEffect} at anytime-valid ` +\n `level α=${cfg.alpha}`,\n }\n }\n if (step.n >= cfg.maxN) {\n terminal = 'undecided-at-maxN'\n return {\n decision: 'undecided-at-maxN',\n eValue: step.wealth,\n n: step.n,\n reason:\n `undecided at pre-registered maxN=${cfg.maxN} (e-value ${step.wealth.toFixed(2)} < ` +\n `1/α=${threshold.toFixed(2)}). This is NOT evidence of no effect — the effect may be ` +\n 'real but smaller than this budget can detect; re-register with a larger N to test that',\n }\n }\n return {\n decision: 'continue',\n eValue: step.wealth,\n n: step.n,\n reason: `e-value ${step.wealth.toFixed(2)} < 1/α=${threshold.toFixed(2)} at n=${step.n}/${cfg.maxN} — keep observing`,\n }\n },\n state() {\n return { ...proc.state(), decision: terminal ?? 'continue' }\n },\n }\n}\n\n/** Data-independent in-place Fisher–Yates with a seeded PRNG — the permutation\n * depends only on the seed, never the values, so bet predictability survives. */\nfunction seededShuffle<T>(items: T[], seed: number): T[] {\n const rng = mulberry32(seed)\n for (let i = items.length - 1; i > 0; i--) {\n const j = Math.floor(rng() * (i + 1))\n const tmp = items[i]!\n items[i] = items[j]!\n items[j] = tmp\n }\n return items\n}\n\n/**\n * Anytime-valid sequential paired gate. Conforms to the existing `Gate`\n * contract: decide(ctx) pairs candidate and baseline by full cellId, then\n * averages deltas within each configured unit (scenario by default). The\n * e-process consumes one observation per unit, with equal unit weights.\n * The streaming observe(delta) entry consumes caller-aggregated independent\n * units. Repetitions improve a unit's precision and do not increase n.\n *\n * Decision mapping onto the substrate's five-valued `GateDecision`:\n * - 'promote' → 'ship'\n * - 'continue' → 'need_more_work' (stream ended before maxN with\n * the e-value undecided — more independent units needed)\n * - 'undecided-at-maxN' → 'hold', with the reason stating it is NOT\n * evidence of no effect (never a silent default)\n */\nexport function sequentialPairedGate<TArtifact = unknown, TScenario extends Scenario = Scenario>(\n options: SequentialPairedGateOptions,\n): SequentialPairedGate<TArtifact, TScenario> {\n const cfg = resolveConfig(options)\n const name = options.name ?? 'sequentialPairedGate'\n const manifest = options.preRegistration\n const observeStream = makeStream(cfg, options.resume)\n const independentUnitByScenarioId =\n options.independentUnitByScenarioId === undefined\n ? undefined\n : new Map(options.independentUnitByScenarioId)\n\n return {\n name,\n observe(delta: number): SequentialObservation {\n return observeStream.observe(delta)\n },\n state() {\n return observeStream.state()\n },\n async decide(ctx: GateContext<TArtifact, TScenario>): Promise<GateResult> {\n if (!ctx.baselineJudgeScores) {\n throw new Error(\n `${name}: ctx.baselineJudgeScores is required — falling back to the candidate's own ` +\n 'scores would compare the candidate against itself (delta 0, silent no-op)',\n )\n }\n const scenarioIds = new Set(ctx.scenarios.map((s) => s.id))\n const unitMap = independentUnitByScenarioId ?? new Map([...scenarioIds].map((id) => [id, id]))\n for (const id of scenarioIds) {\n const unit = unitMap.get(id)\n if (typeof unit !== 'string' || unit.length === 0 || unit.trim() !== unit) {\n throw new Error(`${name}: missing independent unit for scenario '${id}'`)\n }\n }\n const paired = pairHoldout(\n ctx.judgeScores,\n ctx.baselineJudgeScores,\n scenarioIds,\n (s) => s.composite,\n )\n for (let i = 0; i < paired.cellIds.length; i++) {\n const delta = paired.after[i]! - paired.before[i]!\n if (Math.abs(delta) > cfg.scale) {\n throw new Error(\n `${name}: cell '${paired.cellIds[i]}' delta ${delta} outside ±scale=${cfg.scale}`,\n )\n }\n }\n const observations = aggregatePairedHoldout(paired, unitMap)\n const deltas = observations.after.map((after, i) => after - observations.before[i]!)\n seededShuffle(deltas, cfg.shuffleSeed)\n\n const stream = makeStream(cfg)\n let last: SequentialObservation | undefined\n for (const d of deltas) {\n last = stream.observe(d)\n if (last.decision !== 'continue') break\n }\n\n const detail = {\n ...stream.state(),\n minN: cfg.minN,\n maxN: cfg.maxN,\n scale: cfg.scale,\n shuffleSeed: cfg.shuffleSeed,\n direction: cfg.direction,\n minEffect: cfg.minEffect,\n pairedN: deltas.length,\n pairedCellN: paired.cellIds.length,\n observationUnit: independentUnitByScenarioId === undefined ? 'scenario' : 'registered',\n unitIds: observations.unitIds,\n ...(manifest ? { preRegisteredId: manifest.id, metric: manifest.metric } : {}),\n }\n const meanDelta =\n deltas.length === 0 ? undefined : deltas.reduce((s, d) => s + d, 0) / deltas.length\n\n if (last === undefined) {\n return {\n decision: 'need_more_work',\n reasons: [`${name}: no paired holdout observations — nothing to test`],\n contributingGates: [{ name, status: 'not_evaluated', detail }],\n }\n }\n const decision =\n last.decision === 'promote'\n ? 'ship'\n : last.decision === 'continue'\n ? 'need_more_work'\n : 'hold'\n return {\n decision,\n reasons: [`${name}: ${last.reason}`],\n contributingGates: [\n {\n name,\n status:\n decision === 'ship'\n ? 'pass'\n : decision === 'need_more_work'\n ? 'not_evaluated'\n : 'fail',\n detail,\n },\n ],\n delta: meanDelta,\n }\n },\n }\n}\n\nexport interface SequentialDecideOptions {\n /** Type-I budget for the early-stop evidence. Default 0.05. */\n alpha?: number\n /** Minimum paired deltas before a stop may fire. Default 5. */\n minN?: number\n /** Bet truncation forwarded to `eProcess`. Default 0.5. */\n maxBet?: number\n /** Bound on |per-scenario composite delta|. Default 1. */\n scale?: number\n}\n\nexport interface SequentialDecideFn {\n (args: { history: GenerationRecord[] }): { stop: boolean; reason?: string }\n /** Read-only snapshot of the accumulated e-process (observability + tests). */\n state(): EProcessState\n}\n\n/**\n * SurfaceProposer.decide adapter that stops exploration at an e-value threshold.\n * The selected candidate still requires an independent held-out decision.\n *\n * Stream: for each generation g ≥ 1, the per-scenario composite deltas of\n * generation g's top candidate vs the generation-0 top candidate (the\n * incumbent the loop set out to beat), paired by scenarioId. H0: no proposed\n * surface improves any scenario's expected composite over the incumbent —\n * under it every delta has conditional mean ≤ 0 and the e-process is valid.\n * Once wealth ≥ 1/alpha the loop stops and hands the winner to the promotion\n * gate (which re-scores on HELD-OUT data — this adapter only spends the\n * exploration budget, it never promotes).\n *\n * This is an exploration stopping heuristic. Selection of the best measured\n * candidate and reuse of measured incumbent scores generally violate the\n * conditional-mean null, even when the candidates have no true improvement.\n * More repetitions reduce noise but do not establish exact type-I control.\n * An UNDECIDED process never stops the loop — absence of a\n * crossing is NOT evidence of no effect, so the loop simply runs its normal\n * course. Calling the adapter repeatedly with a growing history consumes each\n * generation exactly once (re-feeding an already-seen record would double-count\n * evidence).\n */\nexport function sequentialDecide(options: SequentialDecideOptions = {}): SequentialDecideFn {\n const alpha = options.alpha ?? 0.05\n const minN = options.minN ?? 5\n const scale = options.scale ?? 1\n if (!Number.isFinite(scale) || scale <= 0) {\n throw new Error(`sequentialDecide: scale must be > 0, got ${scale}`)\n }\n const proc = eProcess({ alpha, maxBet: options.maxBet ?? 0.5, nullMean: 0.5 })\n const threshold = 1 / alpha\n let processedGenerations = 0\n let reference: Map<string, number> | undefined\n let stopped: { stop: true; reason: string } | undefined\n\n const topCandidate = (record: GenerationRecord) => {\n if (record.candidates.length === 0) {\n throw new Error(\n `sequentialDecide: generation ${record.generationIndex} has no candidates — ` +\n 'cannot extract a top candidate',\n )\n }\n return record.candidates.reduce((best, candidate) => {\n if (best.composite === null) return candidate\n if (candidate.composite === null) return best\n return candidate.composite > best.composite ? candidate : best\n })\n }\n\n const decide: SequentialDecideFn = ({ history }) => {\n if (stopped) return stopped\n if (history.length === 0) return { stop: false }\n if (reference === undefined) {\n reference = new Map(\n topCandidate(history[0]!).scenarios.map((s) => [s.scenarioId, s.composite]),\n )\n }\n // Consume only generations not yet seen; start at 1 — generation 0 IS the\n // reference and would contribute all-zero deltas (pure wealth dilution).\n for (let g = Math.max(1, processedGenerations); g < history.length; g++) {\n const top = topCandidate(history[g]!)\n const byScenario = new Map(top.scenarios.map((s) => [s.scenarioId, s.composite]))\n for (const [scenarioId, refComposite] of reference) {\n const candComposite = byScenario.get(scenarioId)\n if (candComposite === undefined) {\n throw new Error(\n `sequentialDecide: generation ${history[g]!.generationIndex} top candidate is missing ` +\n `scenario '${scenarioId}' — generations must score the same scenario set to pair`,\n )\n }\n const delta = candComposite - refComposite\n if (!Number.isFinite(delta) || Math.abs(delta) > scale) {\n throw new Error(\n `sequentialDecide: paired delta ${delta} outside ±scale=${scale} on scenario ` +\n `'${scenarioId}' — pass the composite scale explicitly`,\n )\n }\n const step = proc.update((delta / scale + 1) / 2)\n if (step.n >= minN && step.wealth >= threshold) {\n stopped = {\n stop: true,\n reason:\n `sequential e-process decided at generation ${history[g]!.generationIndex}: ` +\n `e-value ${step.wealth.toFixed(2)} ≥ 1/α=${threshold.toFixed(2)} after n=${step.n} ` +\n 'paired deltas vs the generation-0 incumbent; stop exploring and require ' +\n 'an independent held-out promotion decision',\n }\n processedGenerations = history.length\n return stopped\n }\n }\n }\n processedGenerations = history.length\n return { stop: false }\n }\n decide.state = () => proc.state()\n return decide\n}\n","/**\n * Design-time power for task-clustered paired designs, with a refusal verdict.\n *\n * The failure this prevents (measured): a pre-registered kill test fixed a\n * task-clustered bootstrap over 14 rows in 4 task clusters. Simulated at the\n * registered seed, the design's power topped out at 0.69 — at a per-row\n * effect of 1.0. \"Four clusters cannot certify any effect size, including\n * 1.0\" was learned by running the experiment; this module computes it before\n * a dollar is spent.\n *\n * Two floors, one simulation:\n * - Closed form, zero spend: with C independent clusters the exact\n * whole-cluster sign-flip test can never produce a two-sided p below\n * 2^(1-C). C=4 gives 0.125; C=3 gives 0.25 — both above a 0.05 alpha, so\n * those designs are refused at ANY effect size, before simulation.\n * - Seeded simulation: per-row paired contrasts drawn under a registered\n * effect model, a whole-cluster percentile bootstrap on each trial, power =\n * the fraction of trials whose interval excludes zero.\n *\n * The refusal is a verdict INSIDE the returned artifact (the powerPreflight\n * shape, made cluster-aware); `assertDesignAdequate` turns it into a throw for\n * callers that want configuration-time failure.\n */\n\nimport { ValidationError } from '../errors'\nimport { mulberry32 } from '../statistics'\n\n/** A design refused at configuration time, before any spend. */\nclass DesignRefusalError extends ValidationError {}\n\nexport interface ClusteredPowerOptions {\n /** Rows per independent cluster, e.g. [6, 3, 3, 2]. */\n clusterSizes: number[]\n /** P(win) − P(loss) in signal clusters; noisy clusters retain zero expected contrast. */\n effects: number[]\n /** Minimum worthwhile effect under the declared outcome model; must occur in effects. */\n minimumEffect: number\n /** Deterministic seed for outcome draws and bootstrap resampling. */\n seed: number\n /** Simulated experiments per effect. Default 2000. */\n trials?: number\n /** Whole-cluster bootstrap draws per trial. Default 4000. */\n resamples?: number\n /** Percentile interval level. Default 0.95. */\n confidence?: number\n /** Sign-flip alpha the closed-form floor is checked against. Default 0.05. */\n alpha?: number\n /** Power required at minimumEffect. Default 0.8. */\n targetPower?: number\n /** P(row favors treatment) under the zero-effect model. Must equal baseLossRate. Default 0.10. */\n baseWinRate?: number\n /** P(row favors control) under the zero-effect model. Must equal baseWinRate. Default 0.10. */\n baseLossRate?: number\n /**\n * Clusters whose rows carry outcome noise instead of signal: each row wins\n * with `flipRate` and loses with `flipRate`, independent of the effect.\n * Index into `clusterSizes`.\n */\n noisyClusters?: { index: number; flipRate: number }[]\n}\n\nexport interface ClusteredPowerPoint {\n effect: number\n power: number\n medianCiWidth: number\n}\n\nexport interface SignFlipFloor {\n /** Smallest achievable two-sided p: 2^(1-C) for C clusters. */\n twoSidedP: number\n /** Smallest achievable one-sided p: 2^-C. */\n oneSidedP: number\n alpha: number\n /** False when the cluster count can never certify at `alpha`, at any effect. */\n certifiableAtAlpha: boolean\n /** Smallest cluster count whose two-sided floor is at or under `alpha`. */\n minClustersForAlpha: number\n}\n\nexport interface ClusteredPowerRefusal {\n verdict: 'underpowered'\n reasons: string[]\n recommendation: string\n}\n\nexport interface ClusteredPowerResult {\n clusterCount: number\n totalRows: number\n trials: number\n resamples: number\n seed: number\n confidence: number\n targetPower: number\n minimumEffect: number\n powerAtMinimumEffect: number\n curve: ClusteredPowerPoint[]\n /** Maximum simulated power across the effect grid. */\n maxPower: number\n signFlipFloor: SignFlipFloor\n /** True when the sign-flip floor certifies and power at minimumEffect reaches target. */\n adequate: boolean\n /** Populated exactly when `adequate` is false. The refusal lives in the artifact. */\n refusal: ClusteredPowerRefusal | null\n}\n\n/**\n * Simulate the power of a whole-cluster percentile-bootstrap design and refuse\n * a structure that cannot reach target power at the declared minimum effect.\n */\nexport function clusteredPower(options: ClusteredPowerOptions): ClusteredPowerResult {\n const clusterSizes = options.clusterSizes\n if (clusterSizes.length === 0 || clusterSizes.some((n) => !Number.isInteger(n) || n <= 0)) {\n throw new ValidationError(\n `clusteredPower: clusterSizes must be positive integers, got [${clusterSizes.join(', ')}]`,\n )\n }\n if (options.effects.length === 0) {\n throw new ValidationError('clusteredPower: effects grid is empty')\n }\n if (\n options.effects.some((effect) => !Number.isFinite(effect) || effect < 0 || effect > 1) ||\n new Set(options.effects).size !== options.effects.length\n ) {\n throw new ValidationError('clusteredPower: effects must be unique finite values in [0,1]')\n }\n if (\n !Number.isFinite(options.minimumEffect) ||\n options.minimumEffect <= 0 ||\n options.minimumEffect > 1\n ) {\n throw new ValidationError('clusteredPower: minimumEffect must be in (0,1]')\n }\n if (!options.effects.includes(options.minimumEffect)) {\n throw new ValidationError(\n 'clusteredPower: effects must contain minimumEffect exactly; no interpolation is assumed',\n )\n }\n if (!Number.isInteger(options.seed)) {\n throw new ValidationError(`clusteredPower: seed must be an integer, got ${options.seed}`)\n }\n const trials = options.trials ?? 2000\n const resamples = options.resamples ?? 4000\n if (!Number.isInteger(trials) || trials <= 0 || !Number.isInteger(resamples) || resamples <= 0) {\n throw new ValidationError(\n `clusteredPower: trials and resamples must be positive integers, got ${trials}/${resamples}`,\n )\n }\n const confidence = options.confidence ?? 0.95\n if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) {\n throw new ValidationError(`clusteredPower: confidence must be in (0,1), got ${confidence}`)\n }\n const alpha = options.alpha ?? 0.05\n const targetPower = options.targetPower ?? 0.8\n if (!Number.isFinite(alpha) || alpha <= 0 || alpha >= 1) {\n throw new ValidationError('clusteredPower: alpha must be in (0,1)')\n }\n if (!Number.isFinite(targetPower) || targetPower <= 0 || targetPower > 1) {\n throw new ValidationError('clusteredPower: targetPower must be in (0,1]')\n }\n const baseWinRate = options.baseWinRate ?? 0.1\n const baseLossRate = options.baseLossRate ?? 0.1\n if (\n !Number.isFinite(baseWinRate) ||\n !Number.isFinite(baseLossRate) ||\n baseWinRate < 0 ||\n baseLossRate < 0 ||\n baseWinRate + baseLossRate > 1\n ) {\n throw new ValidationError(\n 'clusteredPower: base win/loss rates must be nonnegative and sum to at most 1',\n )\n }\n if (baseWinRate !== baseLossRate) {\n throw new ValidationError(\n 'clusteredPower: the zero-effect model requires equal baseWinRate and baseLossRate',\n )\n }\n const noisy = new Map<number, number>()\n for (const cluster of options.noisyClusters ?? []) {\n if (\n !Number.isInteger(cluster.index) ||\n cluster.index < 0 ||\n cluster.index >= clusterSizes.length\n ) {\n throw new ValidationError(\n `clusteredPower: noisy cluster index ${cluster.index} outside [0,${clusterSizes.length - 1}]`,\n )\n }\n if (\n noisy.has(cluster.index) ||\n !Number.isFinite(cluster.flipRate) ||\n cluster.flipRate < 0 ||\n cluster.flipRate > 1\n ) {\n throw new ValidationError(\n 'clusteredPower: noisy clusters need unique indices and flipRate in [0,1]',\n )\n }\n noisy.set(cluster.index, cluster.flipRate)\n }\n\n const clusterCount = clusterSizes.length\n const totalRows = clusterSizes.reduce((a, b) => a + b, 0)\n const signFlipFloor = computeSignFlipFloor(clusterCount, alpha)\n\n const curve: ClusteredPowerPoint[] = []\n for (const effect of options.effects) {\n curve.push(\n simulateEffect(effect, {\n clusterSizes,\n seed: options.seed,\n trials,\n resamples,\n confidence,\n baseWinRate,\n baseLossRate,\n noisy,\n }),\n )\n }\n const maxPower = Math.max(...curve.map((point) => point.power))\n const powerAtMinimumEffect = curve.find((point) => point.effect === options.minimumEffect)!.power\n\n const reasons: string[] = []\n if (!signFlipFloor.certifiableAtAlpha) {\n reasons.push(\n `${clusterCount} clusters cannot certify any effect size, including 1.0: the exact ` +\n `whole-cluster sign-flip test's smallest two-sided p is 2^(1-${clusterCount}) = ` +\n `${signFlipFloor.twoSidedP} > alpha ${alpha}; at least ` +\n `${signFlipFloor.minClustersForAlpha} clusters are needed`,\n )\n }\n if (powerAtMinimumEffect < targetPower) {\n reasons.push(\n `simulated power ${powerAtMinimumEffect.toFixed(3)} at minimum worthwhile effect ` +\n `${options.minimumEffect} is below target ${targetPower}; maximum grid power ` +\n `${maxPower.toFixed(3)} does not establish adequacy at that effect`,\n )\n }\n const adequate = reasons.length === 0\n return {\n clusterCount,\n totalRows,\n trials,\n resamples,\n seed: options.seed,\n confidence,\n targetPower,\n minimumEffect: options.minimumEffect,\n powerAtMinimumEffect,\n curve,\n maxPower,\n signFlipFloor,\n adequate,\n refusal: adequate\n ? null\n : {\n verdict: 'underpowered',\n reasons,\n recommendation:\n `Do not spend on this structure. Add independent clusters (>= ` +\n `${Math.max(signFlipFloor.minClustersForAlpha, clusterCount)}) or register a design ` +\n `whose simulated power reaches ${targetPower} at effect ${options.minimumEffect}, ` +\n `then re-run clusteredPower.`,\n },\n }\n}\n\n/** Throw the refusal for callers that want configuration-time failure. */\nexport function assertDesignAdequate(result: ClusteredPowerResult): void {\n if (result.refusal) {\n throw new DesignRefusalError(\n `design refused (underpowered): ${result.refusal.reasons.join('; ')}`,\n )\n }\n}\n\nfunction computeSignFlipFloor(clusterCount: number, alpha: number): SignFlipFloor {\n const twoSidedP = 2 ** (1 - clusterCount)\n const oneSidedP = 2 ** -clusterCount\n let minClusters = 1\n while (2 ** (1 - minClusters) > alpha) minClusters += 1\n return {\n twoSidedP,\n oneSidedP,\n alpha,\n certifiableAtAlpha: twoSidedP <= alpha,\n minClustersForAlpha: minClusters,\n }\n}\n\ninterface SimulationConfig {\n clusterSizes: number[]\n seed: number\n trials: number\n resamples: number\n confidence: number\n baseWinRate: number\n baseLossRate: number\n noisy: Map<number, number>\n}\n\n/**\n * One effect point. Loss probability is min(baseLoss, (1-effect)/2) and\n * win probability is loss probability plus effect. Their difference equals\n * effect, including near the probability boundary. Noisy clusters draw win\n * and loss independently at their\n * flip rate. Each trial computes a whole-cluster percentile bootstrap of the\n * pooled row mean; the trial counts toward power when the interval excludes\n * zero.\n */\nfunction simulateEffect(effect: number, config: SimulationConfig): ClusteredPowerPoint {\n const rng = mulberry32(mixSeed(config.seed, effect))\n const clusterCount = config.clusterSizes.length\n let excludes = 0\n const widths = new Array<number>(config.trials)\n const sums = new Array<number>(clusterCount)\n const means = new Array<number>(config.resamples)\n for (let trial = 0; trial < config.trials; trial++) {\n for (let cluster = 0; cluster < clusterCount; cluster++) {\n const size = config.clusterSizes[cluster]!\n const flipRate = config.noisy.get(cluster)\n let sum = 0\n for (let row = 0; row < size; row++) {\n if (flipRate !== undefined) {\n const win = rng() < flipRate ? 1 : 0\n const loss = rng() < flipRate ? 1 : 0\n sum += win - loss\n } else {\n const lossRate = Math.min(config.baseLossRate, (1 - effect) / 2)\n const winRate = lossRate + effect\n const u = rng()\n sum += u < winRate ? 1 : u < winRate + lossRate ? -1 : 0\n }\n }\n sums[cluster] = sum\n }\n for (let draw = 0; draw < config.resamples; draw++) {\n let pooledSum = 0\n let pooledRows = 0\n for (let pick = 0; pick < clusterCount; pick++) {\n const index = Math.floor(rng() * clusterCount)\n pooledSum += sums[index]!\n pooledRows += config.clusterSizes[index]!\n }\n means[draw] = pooledSum / pooledRows\n }\n means.sort((a, b) => a - b)\n const tail = 1 - config.confidence\n const lower = means[Math.floor((tail / 2) * config.resamples)]!\n const upper =\n means[\n Math.max(\n Math.floor((tail / 2) * config.resamples),\n Math.min(config.resamples - 1, Math.ceil((1 - tail / 2) * config.resamples) - 1),\n )\n ]!\n widths[trial] = upper - lower\n if (lower > 0 || upper < 0) excludes += 1\n }\n widths.sort((a, b) => a - b)\n return {\n effect,\n power: excludes / config.trials,\n medianCiWidth: widths[Math.floor(config.trials / 2)]!,\n }\n}\n\n/** Fold the effect into the seed so every grid point draws an independent stream. */\nfunction mixSeed(seed: number, effect: number): number {\n const scaled = Math.round(effect * 1_000_003)\n return ((seed ^ (scaled * 0x9e3779b9)) >>> 0) | 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIA,SAAS,mBAAmB,GAA4B;CACtD,OAAO,sBAAsB,CAAC,MAAM,EAAE;AACxC;AAEA,SAAS,cAAc,MAAmD;CACxE,MAAM,IAAI,KAAK;CACf,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,GAAG;EACL,IAAI,CAAC,mBAAmB,CAAC,GACvB,MAAM,IAAI,MACR,oDAAoD,EAAE,GAAG,mCAC3D;EAEF,IAAI,KAAK,UAAU,KAAA,KAAa,KAAK,UAAU,EAAE,OAC/C,MAAM,IAAI,MACR,+BAA+B,KAAK,MAAM,uCAAuC,EAAE,MAAM,oEAE3F;EAEF,IAAI,KAAK,SAAS,KAAA,KAAa,KAAK,SAAS,EAAE,gBAC7C,MAAM,IAAI,MACR,8BAA8B,KAAK,KAAK,mCAAmC,EAAE,gBAC/E;EAEF,QAAQ,EAAE;EACV,OAAO,EAAE;EACT,YAAY,EAAE;EACd,YAAY,EAAE;CAChB,OAAO;EACL,QAAQ,KAAK,SAAS;EACtB,IAAI,KAAK,SAAS,KAAA,GAChB,MAAM,IAAI,MACR,mKAEF;EAEF,OAAO,KAAK;EACZ,YAAY;EACZ,YAAY;CACd;CACA,MAAM,QAAQ,KAAK,SAAS;CAC5B,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,G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ACxB,IAAI,QAAQ,KAAK,QAAQ,GAAG,YAAY;CAC1C;CACA,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAC3B,OAAO;EACL;EACA,OAAO,WAAW,OAAO;EACzB,eAAe,OAAO,KAAK,MAAM,OAAO,SAAS,CAAC;CACpD;AACF;;AAGA,SAAS,QAAQ,MAAc,QAAwB;CAErD,QAAS,OADM,KAAK,MAAM,SAAS,OACb,IAAI,gBAAiB,IAAK;AAClD"}
1
+ {"version":3,"file":"power-COie_o6E.js","names":[],"sources":["../src/campaign/gates/sequential.ts","../src/experiment/power.ts"],"sourcesContent":["/**\n * Anytime-valid sequential promotion gate — an e-process (betting\n * test-martingale, see `eProcess` in `statistics.ts`) over paired\n * per-scenario deltas, so a campaign stops the MOMENT evidence decides\n * instead of burning a fixed-n budget. Decisions remain valid at any\n * data-dependent stopping time (Ville's inequality), which is exactly what\n * fixed-n machinery cannot offer: peeking at a bootstrap CI after every\n * observation and stopping on the first significant peek inflates type-I\n * error far beyond alpha.\n *\n * REPLACES, never layers on, a fixed-n gate. Running `heldoutSignificance`\n * or `paretoSignificanceGate` repeatedly on a growing sample and stopping\n * early is optional stopping no matter how it is dressed up; this gate is\n * the valid way to stop early. Use one or the other per evidence stream.\n *\n * Pre-registration binding: anytime validity holds only for the\n * PRE-REGISTERED statistic. When a `SignedManifest` is bound, the gate takes\n * alpha from `manifest.alpha`, the observation budget from\n * `manifest.preRegisteredN`, orients deltas by `manifest.direction`, and\n * shifts the null boundary by `manifest.minEffect` — re-deciding the same\n * stream under different parameters after seeing data would reopen optional\n * stopping under a fancier name. The manifest's content hash is verified at\n * construction with the canonical RFC 8785 digest used by signManifest.\n *\n * The supermartingale guarantee requires E[delta_t | past] ≤ the null\n * boundary under H0. Independent sampling with that mean bound suffices.\n * Exchangeability or shuffling alone does not: one fair sign repeated many\n * times is exchangeable and has marginal mean zero, but its conditional mean\n * becomes the revealed sign. A seeded shuffle cannot remove that dependence.\n * `decide(ctx)` pairs cells, then averages repetitions within each scenario\n * before testing. Pass independentUnitByScenarioId for scenarios sharing a\n * latent source or incident. Units must still satisfy the conditional-mean null.\n * Direct `observe()` callers own this sampling and aggregation contract.\n */\n\nimport { manifestContentDigest, type SignedManifest } from '../../pre-registration'\nimport { type EProcessState, eProcess, mulberry32 } from '../../statistics'\nimport type { Gate, GateContext, GateResult, GenerationRecord, Scenario } from '../types'\nimport { aggregatePairedHoldout, pairHoldout } from './statistical-heldout'\n\nexport type SequentialGateDecision = 'promote' | 'continue' | 'undecided-at-maxN'\n\nexport interface SequentialObservation {\n decision: SequentialGateDecision\n /** Current e-value (the betting wealth) against H0. */\n eValue: number\n /** Paired deltas consumed so far. */\n n: number\n /** Names the decision basis. For 'undecided-at-maxN' it states explicitly\n * that exhausting the budget is NOT evidence of no effect. */\n reason: string\n}\n\nexport interface SequentialPairedGateOptions {\n /** Type-I budget. With `preRegistration` bound this MUST match\n * `manifest.alpha` (conflict throws). Default 0.05. */\n alpha?: number\n /** Minimum independent paired units before a promote may fire. The stopping rule is\n * \"first n ≥ minN with e-value ≥ 1/alpha\" — still a valid stopping time.\n * Default 5. */\n minN?: number\n /** Pre-registered independent-unit budget (scenarios by default in decide()). Required unless `preRegistration`\n * supplies it via `preRegisteredN` (conflict throws). */\n maxN?: number\n /** Bet truncation forwarded to `eProcess`. Default 0.5. */\n maxBet?: number\n /** Bound on |delta| in the judge's native scale; deltas are mapped to\n * x = (d/scale + 1)/2 ∈ [0,1]. A delta outside ±scale throws (use\n * `detectScale` to pick 1 vs 100 BEFORE streaming). Default 1. */\n scale?: number\n /** Seed for reproducible ordering of scenario deltas in decide().\n * Shuffling does not establish the conditional-mean null. Default 1337. */\n shuffleSeed?: number\n /** Independent unit for every scenario passed to decide(). Full cell pairs\n * are averaged within each unit before testing. Defaults to scenario IDs.\n * The mapping is copied at construction. Direct observe() is unchanged. */\n independentUnitByScenarioId?: ReadonlyMap<string, string>\n /** Bind the pre-registered hypothesis. Verified (content hash) at\n * construction; alpha/maxN/direction/minEffect come FROM the manifest. */\n preRegistration?: SignedManifest\n /** Override the gate name in reports. */\n name?: string\n /** Continue the observe-stream from a `state()` snapshot taken before a\n * restart. The gate's parameters still resolve from this options object\n * (and the manifest); the snapshot must have been recorded under the same\n * alpha, maxBet, and null boundary, and its decision must be one this\n * configuration could have reached at its n, or construction throws.\n * `decide(ctx)` is unaffected — it always runs on a fresh stream. */\n resume?: SequentialStreamState\n}\n\n/** Snapshot of one observe-stream: the e-process state plus the gate's own\n * decision, which applies `minN` and `maxN` on top of the core latch. A\n * gate rebuilt with `resume` from this value continues exactly where the\n * snapshot was taken. */\nexport type SequentialStreamState = EProcessState & { decision: SequentialGateDecision }\n\nexport interface SequentialPairedGate<TArtifact = unknown, TScenario extends Scenario = Scenario>\n extends Gate<TArtifact, TScenario> {\n /** Streaming entry point: feed one paired independent-unit delta\n * (candidate − baseline, native scale). Aggregate correlated repetitions\n * before calling; the caller must justify E[delta_t | past] under H0.\n * Each gate instance carries ONE\n * observe-stream; `decide(ctx)` runs on its own fresh stream and never\n * consumes or advances this one. 'promote' is sticky; observing past the\n * pre-registered maxN throws (extending a finished stream after seeing\n * the result reopens optional stopping — start a NEW pre-registered\n * test). */\n observe(delta: number): SequentialObservation\n /** Read-only snapshot of the observe-stream. Pass it back as\n * `resume` to continue the stream after a restart. */\n state(): SequentialStreamState\n}\n\ninterface ResolvedConfig {\n alpha: number\n minN: number\n maxN: number\n maxBet: number\n scale: number\n shuffleSeed: number\n /** 'decrease' negates deltas so \"better\" is always positive. */\n direction: 'increase' | 'decrease'\n /** H0 boundary in x-space: 1/2 + minEffect/(2·scale). */\n nullMean: number\n minEffect: number\n}\n\n/** Sync twin of `verifyManifest`, so gate construction stays synchronous and\n * fails loud before any observation is consumed. The digest scheme belongs to\n * `pre-registration`; this gate only compares. */\nfunction verifyManifestSync(m: SignedManifest): boolean {\n return manifestContentDigest(m) === m.contentHash\n}\n\nfunction resolveConfig(opts: SequentialPairedGateOptions): ResolvedConfig {\n const m = opts.preRegistration\n let alpha: number\n let maxN: number\n let direction: 'increase' | 'decrease'\n let minEffect: number\n if (m) {\n if (!verifyManifestSync(m)) {\n throw new Error(\n `sequentialPairedGate: pre-registration manifest '${m.id}' content hash mismatch (tampered)`,\n )\n }\n if (opts.alpha !== undefined && opts.alpha !== m.alpha) {\n throw new Error(\n `sequentialPairedGate: alpha ${opts.alpha} conflicts with pre-registered alpha ${m.alpha} — ` +\n `the registered statistic is the only one anytime validity covers`,\n )\n }\n if (opts.maxN !== undefined && opts.maxN !== m.preRegisteredN) {\n throw new Error(\n `sequentialPairedGate: maxN ${opts.maxN} conflicts with pre-registered N ${m.preRegisteredN}`,\n )\n }\n alpha = m.alpha\n maxN = m.preRegisteredN\n direction = m.direction\n minEffect = m.minEffect\n } else {\n alpha = opts.alpha ?? 0.05\n if (opts.maxN === undefined) {\n throw new Error(\n 'sequentialPairedGate: maxN is required (or bind a preRegistration manifest whose ' +\n 'preRegisteredN is the budget) — an unbounded stream has no pre-registered budget',\n )\n }\n maxN = opts.maxN\n direction = 'increase'\n minEffect = 0\n }\n const scale = opts.scale ?? 1\n if (!Number.isFinite(scale) || scale <= 0) {\n throw new Error(`sequentialPairedGate: scale must be > 0, got ${scale}`)\n }\n if (!Number.isInteger(maxN) || maxN < 1) {\n throw new Error(`sequentialPairedGate: maxN must be a positive integer, got ${maxN}`)\n }\n const minN = opts.minN ?? 5\n if (!Number.isInteger(minN) || minN < 1 || minN > maxN) {\n throw new Error(\n `sequentialPairedGate: minN must be an integer in [1, maxN=${maxN}], got ${minN}`,\n )\n }\n if (!Number.isFinite(minEffect) || minEffect < 0 || minEffect >= scale) {\n throw new Error(\n `sequentialPairedGate: minEffect must be in [0, scale=${scale}), got ${minEffect}`,\n )\n }\n // H0: mean delta ≤ minEffect. In x = (d/scale + 1)/2 space that is\n // E[x] ≤ 1/2 + minEffect/(2·scale) — a shifted null boundary, NOT a clamp\n // of the observations (clamping is mean-distorting for skewed deltas).\n const nullMean = 0.5 + minEffect / (2 * scale)\n return {\n alpha,\n minN,\n maxN,\n maxBet: opts.maxBet ?? 0.5,\n scale,\n shuffleSeed: opts.shuffleSeed ?? 1337,\n direction,\n nullMean,\n minEffect,\n }\n}\n\ninterface SequentialStream {\n observe(delta: number): SequentialObservation\n state(): SequentialStreamState\n}\n\nconst SEQUENTIAL_DECISIONS: readonly SequentialGateDecision[] = [\n 'promote',\n 'continue',\n 'undecided-at-maxN',\n]\n\n/** Refuse a snapshot whose gate decision this configuration could not have\n * reached at the snapshot's n. The e-process parameters are checked by\n * `eProcess` itself; this covers the gate's own stopping rule. */\nfunction assertResumableStream(resume: SequentialStreamState, cfg: ResolvedConfig): void {\n const fail = (detail: string): never => {\n throw new Error(`sequentialPairedGate: cannot resume — ${detail}`)\n }\n if (!SEQUENTIAL_DECISIONS.includes(resume.decision)) {\n fail(`unknown decision '${String(resume.decision)}'`)\n }\n if (resume.n > cfg.maxN) {\n fail(`snapshot n=${resume.n} exceeds the pre-registered maxN=${cfg.maxN}`)\n }\n const threshold = 1 / cfg.alpha\n switch (resume.decision) {\n case 'promote':\n if (resume.n < cfg.minN) {\n fail(`decision 'promote' at n=${resume.n} is below minN=${cfg.minN}`)\n }\n break\n case 'undecided-at-maxN':\n if (resume.n !== cfg.maxN) {\n fail(`decision 'undecided-at-maxN' at n=${resume.n} does not match maxN=${cfg.maxN}`)\n }\n break\n case 'continue':\n if (resume.n >= cfg.maxN) {\n fail(`decision 'continue' at n=${resume.n} with maxN=${cfg.maxN}; the stream is finished`)\n }\n if (resume.n >= cfg.minN && resume.wealth >= threshold) {\n fail(\n `decision 'continue' at n=${resume.n} ≥ minN=${cfg.minN} with e-value ` +\n `${resume.wealth} ≥ 1/α=${threshold}; this stream would have promoted`,\n )\n }\n break\n }\n}\n\nfunction makeStream(cfg: ResolvedConfig, resume?: SequentialStreamState): SequentialStream {\n if (resume !== undefined) assertResumableStream(resume, cfg)\n const proc = eProcess({\n alpha: cfg.alpha,\n maxBet: cfg.maxBet,\n nullMean: cfg.nullMean,\n ...(resume === undefined ? {} : { resume }),\n })\n const threshold = 1 / cfg.alpha\n let terminal: SequentialGateDecision | undefined =\n resume === undefined || resume.decision === 'continue' ? undefined : resume.decision\n return {\n observe(delta: number): SequentialObservation {\n if (terminal === 'undecided-at-maxN') {\n throw new Error(\n `sequentialPairedGate: pre-registered maxN=${cfg.maxN} exhausted — extending the ` +\n 'stream after seeing the result reopens optional stopping; start a NEW ' +\n 'pre-registered test',\n )\n }\n if (!Number.isFinite(delta) || Math.abs(delta) > cfg.scale) {\n throw new Error(\n `sequentialPairedGate: delta ${delta} outside ±scale=${cfg.scale} — pass the judge's ` +\n `native scale explicitly (detectScale helps pick 1 vs 100)`,\n )\n }\n const d = cfg.direction === 'decrease' ? -delta : delta\n const step = proc.update((d / cfg.scale + 1) / 2)\n // Stopping rule: FIRST n ≥ minN with current wealth ≥ 1/alpha — a valid\n // stopping time (measurable w.r.t. the past), sticky once latched. The\n // core's own `decided` latch ignores minN, so the gate re-derives the\n // decision from current wealth here.\n if (terminal === undefined && step.n >= cfg.minN && step.wealth >= threshold) {\n terminal = 'promote'\n }\n if (terminal === 'promote') {\n return {\n decision: 'promote',\n eValue: step.wealth,\n n: step.n,\n reason:\n `e-value ${step.wealth.toFixed(2)} ≥ 1/α=${threshold.toFixed(2)} at n=${step.n} ` +\n `(minN=${cfg.minN}): the paired improvement exceeds ${cfg.minEffect} at anytime-valid ` +\n `level α=${cfg.alpha}`,\n }\n }\n if (step.n >= cfg.maxN) {\n terminal = 'undecided-at-maxN'\n return {\n decision: 'undecided-at-maxN',\n eValue: step.wealth,\n n: step.n,\n reason:\n `undecided at pre-registered maxN=${cfg.maxN} (e-value ${step.wealth.toFixed(2)} < ` +\n `1/α=${threshold.toFixed(2)}). This is NOT evidence of no effect — the effect may be ` +\n 'real but smaller than this budget can detect; re-register with a larger N to test that',\n }\n }\n return {\n decision: 'continue',\n eValue: step.wealth,\n n: step.n,\n reason: `e-value ${step.wealth.toFixed(2)} < 1/α=${threshold.toFixed(2)} at n=${step.n}/${cfg.maxN} — keep observing`,\n }\n },\n state() {\n return { ...proc.state(), decision: terminal ?? 'continue' }\n },\n }\n}\n\n/** Data-independent in-place Fisher–Yates with a seeded PRNG — the permutation\n * depends only on the seed, never the values, so bet predictability survives. */\nfunction seededShuffle<T>(items: T[], seed: number): T[] {\n const rng = mulberry32(seed)\n for (let i = items.length - 1; i > 0; i--) {\n const j = Math.floor(rng() * (i + 1))\n const tmp = items[i]!\n items[i] = items[j]!\n items[j] = tmp\n }\n return items\n}\n\n/**\n * Anytime-valid sequential paired gate. Conforms to the existing `Gate`\n * contract: decide(ctx) pairs candidate and baseline by full cellId, then\n * averages deltas within each configured unit (scenario by default). The\n * e-process consumes one observation per unit, with equal unit weights.\n * The streaming observe(delta) entry consumes caller-aggregated independent\n * units. Repetitions improve a unit's precision and do not increase n.\n *\n * Decision mapping onto the substrate's five-valued `GateDecision`:\n * - 'promote' → 'ship'\n * - 'continue' → 'need_more_work' (stream ended before maxN with\n * the e-value undecided — more independent units needed)\n * - 'undecided-at-maxN' → 'hold', with the reason stating it is NOT\n * evidence of no effect (never a silent default)\n */\nexport function sequentialPairedGate<TArtifact = unknown, TScenario extends Scenario = Scenario>(\n options: SequentialPairedGateOptions,\n): SequentialPairedGate<TArtifact, TScenario> {\n const cfg = resolveConfig(options)\n const name = options.name ?? 'sequentialPairedGate'\n const manifest = options.preRegistration\n const observeStream = makeStream(cfg, options.resume)\n const independentUnitByScenarioId =\n options.independentUnitByScenarioId === undefined\n ? undefined\n : new Map(options.independentUnitByScenarioId)\n\n return {\n name,\n observe(delta: number): SequentialObservation {\n return observeStream.observe(delta)\n },\n state() {\n return observeStream.state()\n },\n async decide(ctx: GateContext<TArtifact, TScenario>): Promise<GateResult> {\n if (!ctx.baselineJudgeScores) {\n throw new Error(\n `${name}: ctx.baselineJudgeScores is required — falling back to the candidate's own ` +\n 'scores would compare the candidate against itself (delta 0, silent no-op)',\n )\n }\n const scenarioIds = new Set(ctx.scenarios.map((s) => s.id))\n const unitMap = independentUnitByScenarioId ?? new Map([...scenarioIds].map((id) => [id, id]))\n for (const id of scenarioIds) {\n const unit = unitMap.get(id)\n if (typeof unit !== 'string' || unit.length === 0 || unit.trim() !== unit) {\n throw new Error(`${name}: missing independent unit for scenario '${id}'`)\n }\n }\n const paired = pairHoldout(\n ctx.judgeScores,\n ctx.baselineJudgeScores,\n scenarioIds,\n (s) => s.composite,\n )\n for (let i = 0; i < paired.cellIds.length; i++) {\n const delta = paired.after[i]! - paired.before[i]!\n if (Math.abs(delta) > cfg.scale) {\n throw new Error(\n `${name}: cell '${paired.cellIds[i]}' delta ${delta} outside ±scale=${cfg.scale}`,\n )\n }\n }\n const observations = aggregatePairedHoldout(paired, unitMap)\n const deltas = observations.after.map((after, i) => after - observations.before[i]!)\n seededShuffle(deltas, cfg.shuffleSeed)\n\n const stream = makeStream(cfg)\n let last: SequentialObservation | undefined\n for (const d of deltas) {\n last = stream.observe(d)\n if (last.decision !== 'continue') break\n }\n\n const detail = {\n ...stream.state(),\n minN: cfg.minN,\n maxN: cfg.maxN,\n scale: cfg.scale,\n shuffleSeed: cfg.shuffleSeed,\n direction: cfg.direction,\n minEffect: cfg.minEffect,\n pairedN: deltas.length,\n pairedCellN: paired.cellIds.length,\n observationUnit: independentUnitByScenarioId === undefined ? 'scenario' : 'registered',\n unitIds: observations.unitIds,\n ...(manifest ? { preRegisteredId: manifest.id, metric: manifest.metric } : {}),\n }\n const meanDelta =\n deltas.length === 0 ? undefined : deltas.reduce((s, d) => s + d, 0) / deltas.length\n\n if (last === undefined) {\n return {\n decision: 'need_more_work',\n reasons: [`${name}: no paired holdout observations — nothing to test`],\n contributingGates: [{ name, status: 'not_evaluated', detail }],\n }\n }\n const decision =\n last.decision === 'promote'\n ? 'ship'\n : last.decision === 'continue'\n ? 'need_more_work'\n : 'hold'\n return {\n decision,\n reasons: [`${name}: ${last.reason}`],\n contributingGates: [\n {\n name,\n status:\n decision === 'ship'\n ? 'pass'\n : decision === 'need_more_work'\n ? 'not_evaluated'\n : 'fail',\n detail,\n },\n ],\n delta: meanDelta,\n }\n },\n }\n}\n\nexport interface SequentialDecideOptions {\n /** Type-I budget for the early-stop evidence. Default 0.05. */\n alpha?: number\n /** Minimum paired deltas before a stop may fire. Default 5. */\n minN?: number\n /** Bet truncation forwarded to `eProcess`. Default 0.5. */\n maxBet?: number\n /** Bound on |per-scenario composite delta|. Default 1. */\n scale?: number\n}\n\nexport interface SequentialDecideFn {\n (args: { history: GenerationRecord[] }): { stop: boolean; reason?: string }\n /** Read-only snapshot of the accumulated e-process (observability + tests). */\n state(): EProcessState\n}\n\n/**\n * SurfaceProposer.decide adapter that stops exploration at an e-value threshold.\n * The selected candidate still requires an independent held-out decision.\n *\n * Stream: for each generation g ≥ 1, the per-scenario composite deltas of\n * generation g's top candidate vs the generation-0 top candidate (the\n * incumbent the loop set out to beat), paired by scenarioId. H0: no proposed\n * surface improves any scenario's expected composite over the incumbent —\n * under it every delta has conditional mean ≤ 0 and the e-process is valid.\n * Once wealth ≥ 1/alpha the loop stops and hands the winner to the promotion\n * gate (which re-scores on HELD-OUT data — this adapter only spends the\n * exploration budget, it never promotes).\n *\n * This is an exploration stopping heuristic. Selection of the best measured\n * candidate and reuse of measured incumbent scores generally violate the\n * conditional-mean null, even when the candidates have no true improvement.\n * More repetitions reduce noise but do not establish exact type-I control.\n * An UNDECIDED process never stops the loop — absence of a\n * crossing is NOT evidence of no effect, so the loop simply runs its normal\n * course. Calling the adapter repeatedly with a growing history consumes each\n * generation exactly once (re-feeding an already-seen record would double-count\n * evidence).\n */\nexport function sequentialDecide(options: SequentialDecideOptions = {}): SequentialDecideFn {\n const alpha = options.alpha ?? 0.05\n const minN = options.minN ?? 5\n const scale = options.scale ?? 1\n if (!Number.isFinite(scale) || scale <= 0) {\n throw new Error(`sequentialDecide: scale must be > 0, got ${scale}`)\n }\n const proc = eProcess({ alpha, maxBet: options.maxBet ?? 0.5, nullMean: 0.5 })\n const threshold = 1 / alpha\n let processedGenerations = 0\n let reference: Map<string, number> | undefined\n let stopped: { stop: true; reason: string } | undefined\n\n const topCandidate = (record: GenerationRecord) => {\n if (record.candidates.length === 0) {\n throw new Error(\n `sequentialDecide: generation ${record.generationIndex} has no candidates — ` +\n 'cannot extract a top candidate',\n )\n }\n return record.candidates.reduce((best, candidate) => {\n if (best.composite === null) return candidate\n if (candidate.composite === null) return best\n return candidate.composite > best.composite ? candidate : best\n })\n }\n\n const decide: SequentialDecideFn = ({ history }) => {\n if (stopped) return stopped\n if (history.length === 0) return { stop: false }\n if (reference === undefined) {\n reference = new Map(\n topCandidate(history[0]!).scenarios.map((s) => [s.scenarioId, s.composite]),\n )\n }\n // Consume only generations not yet seen; start at 1 — generation 0 IS the\n // reference and would contribute all-zero deltas (pure wealth dilution).\n for (let g = Math.max(1, processedGenerations); g < history.length; g++) {\n const top = topCandidate(history[g]!)\n const byScenario = new Map(top.scenarios.map((s) => [s.scenarioId, s.composite]))\n for (const [scenarioId, refComposite] of reference) {\n const candComposite = byScenario.get(scenarioId)\n if (candComposite === undefined) {\n throw new Error(\n `sequentialDecide: generation ${history[g]!.generationIndex} top candidate is missing ` +\n `scenario '${scenarioId}' — generations must score the same scenario set to pair`,\n )\n }\n const delta = candComposite - refComposite\n if (!Number.isFinite(delta) || Math.abs(delta) > scale) {\n throw new Error(\n `sequentialDecide: paired delta ${delta} outside ±scale=${scale} on scenario ` +\n `'${scenarioId}' — pass the composite scale explicitly`,\n )\n }\n const step = proc.update((delta / scale + 1) / 2)\n if (step.n >= minN && step.wealth >= threshold) {\n stopped = {\n stop: true,\n reason:\n `sequential e-process decided at generation ${history[g]!.generationIndex}: ` +\n `e-value ${step.wealth.toFixed(2)} ≥ 1/α=${threshold.toFixed(2)} after n=${step.n} ` +\n 'paired deltas vs the generation-0 incumbent; stop exploring and require ' +\n 'an independent held-out promotion decision',\n }\n processedGenerations = history.length\n return stopped\n }\n }\n }\n processedGenerations = history.length\n return { stop: false }\n }\n decide.state = () => proc.state()\n return decide\n}\n","/**\n * Design-time power for task-clustered paired designs, with a refusal verdict.\n *\n * The failure this prevents (measured): a pre-registered kill test fixed a\n * task-clustered bootstrap over 14 rows in 4 task clusters. Simulated at the\n * registered seed, the design's power topped out at 0.69 — at a per-row\n * effect of 1.0. \"Four clusters cannot certify any effect size, including\n * 1.0\" was learned by running the experiment; this module computes it before\n * a dollar is spent.\n *\n * Two floors, one simulation:\n * - Closed form, zero spend: with C independent clusters the exact\n * whole-cluster sign-flip test can never produce a two-sided p below\n * 2^(1-C). C=4 gives 0.125; C=3 gives 0.25 — both above a 0.05 alpha, so\n * those designs are refused at ANY effect size, before simulation.\n * - Seeded simulation: per-row paired contrasts drawn under a registered\n * effect model, a whole-cluster percentile bootstrap on each trial, power =\n * the fraction of trials whose interval excludes zero.\n *\n * The refusal is a verdict INSIDE the returned artifact (the powerPreflight\n * shape, made cluster-aware); `assertDesignAdequate` turns it into a throw for\n * callers that want configuration-time failure.\n */\n\nimport { ValidationError } from '../errors'\nimport { mulberry32 } from '../statistics'\n\n/** A design refused at configuration time, before any spend. */\nclass DesignRefusalError extends ValidationError {}\n\nexport interface ClusteredPowerOptions {\n /** Rows per independent cluster, e.g. [6, 3, 3, 2]. */\n clusterSizes: number[]\n /** P(win) − P(loss) in signal clusters; noisy clusters retain zero expected contrast. */\n effects: number[]\n /** Minimum worthwhile effect under the declared outcome model; must occur in effects. */\n minimumEffect: number\n /** Deterministic seed for outcome draws and bootstrap resampling. */\n seed: number\n /** Simulated experiments per effect. Default 2000. */\n trials?: number\n /** Whole-cluster bootstrap draws per trial. Default 4000. */\n resamples?: number\n /** Percentile interval level. Default 0.95. */\n confidence?: number\n /** Sign-flip alpha the closed-form floor is checked against. Default 0.05. */\n alpha?: number\n /** Power required at minimumEffect. Default 0.8. */\n targetPower?: number\n /** P(row favors treatment) under the zero-effect model. Must equal baseLossRate. Default 0.10. */\n baseWinRate?: number\n /** P(row favors control) under the zero-effect model. Must equal baseWinRate. Default 0.10. */\n baseLossRate?: number\n /**\n * Clusters whose rows carry outcome noise instead of signal: each row wins\n * with `flipRate` and loses with `flipRate`, independent of the effect.\n * Index into `clusterSizes`.\n */\n noisyClusters?: { index: number; flipRate: number }[]\n}\n\nexport interface ClusteredPowerPoint {\n effect: number\n power: number\n medianCiWidth: number\n}\n\nexport interface SignFlipFloor {\n /** Smallest achievable two-sided p: 2^(1-C) for C clusters. */\n twoSidedP: number\n /** Smallest achievable one-sided p: 2^-C. */\n oneSidedP: number\n alpha: number\n /** False when the cluster count can never certify at `alpha`, at any effect. */\n certifiableAtAlpha: boolean\n /** Smallest cluster count whose two-sided floor is at or under `alpha`. */\n minClustersForAlpha: number\n}\n\nexport interface ClusteredPowerRefusal {\n verdict: 'underpowered'\n reasons: string[]\n recommendation: string\n}\n\nexport interface ClusteredPowerResult {\n clusterCount: number\n totalRows: number\n trials: number\n resamples: number\n seed: number\n confidence: number\n targetPower: number\n minimumEffect: number\n powerAtMinimumEffect: number\n curve: ClusteredPowerPoint[]\n /** Maximum simulated power across the effect grid. */\n maxPower: number\n signFlipFloor: SignFlipFloor\n /** True when the sign-flip floor certifies and power at minimumEffect reaches target. */\n adequate: boolean\n /** Populated exactly when `adequate` is false. The refusal lives in the artifact. */\n refusal: ClusteredPowerRefusal | null\n}\n\n/**\n * Simulate the power of a whole-cluster percentile-bootstrap design and refuse\n * a structure that cannot reach target power at the declared minimum effect.\n */\nexport function clusteredPower(options: ClusteredPowerOptions): ClusteredPowerResult {\n const clusterSizes = options.clusterSizes\n if (clusterSizes.length === 0 || clusterSizes.some((n) => !Number.isInteger(n) || n <= 0)) {\n throw new ValidationError(\n `clusteredPower: clusterSizes must be positive integers, got [${clusterSizes.join(', ')}]`,\n )\n }\n if (options.effects.length === 0) {\n throw new ValidationError('clusteredPower: effects grid is empty')\n }\n if (\n options.effects.some((effect) => !Number.isFinite(effect) || effect < 0 || effect > 1) ||\n new Set(options.effects).size !== options.effects.length\n ) {\n throw new ValidationError('clusteredPower: effects must be unique finite values in [0,1]')\n }\n if (\n !Number.isFinite(options.minimumEffect) ||\n options.minimumEffect <= 0 ||\n options.minimumEffect > 1\n ) {\n throw new ValidationError('clusteredPower: minimumEffect must be in (0,1]')\n }\n if (!options.effects.includes(options.minimumEffect)) {\n throw new ValidationError(\n 'clusteredPower: effects must contain minimumEffect exactly; no interpolation is assumed',\n )\n }\n if (!Number.isInteger(options.seed)) {\n throw new ValidationError(`clusteredPower: seed must be an integer, got ${options.seed}`)\n }\n const trials = options.trials ?? 2000\n const resamples = options.resamples ?? 4000\n if (!Number.isInteger(trials) || trials <= 0 || !Number.isInteger(resamples) || resamples <= 0) {\n throw new ValidationError(\n `clusteredPower: trials and resamples must be positive integers, got ${trials}/${resamples}`,\n )\n }\n const confidence = options.confidence ?? 0.95\n if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) {\n throw new ValidationError(`clusteredPower: confidence must be in (0,1), got ${confidence}`)\n }\n const alpha = options.alpha ?? 0.05\n const targetPower = options.targetPower ?? 0.8\n if (!Number.isFinite(alpha) || alpha <= 0 || alpha >= 1) {\n throw new ValidationError('clusteredPower: alpha must be in (0,1)')\n }\n if (!Number.isFinite(targetPower) || targetPower <= 0 || targetPower > 1) {\n throw new ValidationError('clusteredPower: targetPower must be in (0,1]')\n }\n const baseWinRate = options.baseWinRate ?? 0.1\n const baseLossRate = options.baseLossRate ?? 0.1\n if (\n !Number.isFinite(baseWinRate) ||\n !Number.isFinite(baseLossRate) ||\n baseWinRate < 0 ||\n baseLossRate < 0 ||\n baseWinRate + baseLossRate > 1\n ) {\n throw new ValidationError(\n 'clusteredPower: base win/loss rates must be nonnegative and sum to at most 1',\n )\n }\n if (baseWinRate !== baseLossRate) {\n throw new ValidationError(\n 'clusteredPower: the zero-effect model requires equal baseWinRate and baseLossRate',\n )\n }\n const noisy = new Map<number, number>()\n for (const cluster of options.noisyClusters ?? []) {\n if (\n !Number.isInteger(cluster.index) ||\n cluster.index < 0 ||\n cluster.index >= clusterSizes.length\n ) {\n throw new ValidationError(\n `clusteredPower: noisy cluster index ${cluster.index} outside [0,${clusterSizes.length - 1}]`,\n )\n }\n if (\n noisy.has(cluster.index) ||\n !Number.isFinite(cluster.flipRate) ||\n cluster.flipRate < 0 ||\n cluster.flipRate > 1\n ) {\n throw new ValidationError(\n 'clusteredPower: noisy clusters need unique indices and flipRate in [0,1]',\n )\n }\n noisy.set(cluster.index, cluster.flipRate)\n }\n\n const clusterCount = clusterSizes.length\n const totalRows = clusterSizes.reduce((a, b) => a + b, 0)\n const signFlipFloor = computeSignFlipFloor(clusterCount, alpha)\n\n const curve: ClusteredPowerPoint[] = []\n for (const effect of options.effects) {\n curve.push(\n simulateEffect(effect, {\n clusterSizes,\n seed: options.seed,\n trials,\n resamples,\n confidence,\n baseWinRate,\n baseLossRate,\n noisy,\n }),\n )\n }\n const maxPower = Math.max(...curve.map((point) => point.power))\n const powerAtMinimumEffect = curve.find((point) => point.effect === options.minimumEffect)!.power\n\n const reasons: string[] = []\n if (!signFlipFloor.certifiableAtAlpha) {\n reasons.push(\n `${clusterCount} clusters cannot certify any effect size, including 1.0: the exact ` +\n `whole-cluster sign-flip test's smallest two-sided p is 2^(1-${clusterCount}) = ` +\n `${signFlipFloor.twoSidedP} > alpha ${alpha}; at least ` +\n `${signFlipFloor.minClustersForAlpha} clusters are needed`,\n )\n }\n if (powerAtMinimumEffect < targetPower) {\n reasons.push(\n `simulated power ${powerAtMinimumEffect.toFixed(3)} at minimum worthwhile effect ` +\n `${options.minimumEffect} is below target ${targetPower}; maximum grid power ` +\n `${maxPower.toFixed(3)} does not establish adequacy at that effect`,\n )\n }\n const adequate = reasons.length === 0\n return {\n clusterCount,\n totalRows,\n trials,\n resamples,\n seed: options.seed,\n confidence,\n targetPower,\n minimumEffect: options.minimumEffect,\n powerAtMinimumEffect,\n curve,\n maxPower,\n signFlipFloor,\n adequate,\n refusal: adequate\n ? null\n : {\n verdict: 'underpowered',\n reasons,\n recommendation:\n `Do not spend on this structure. Add independent clusters (>= ` +\n `${Math.max(signFlipFloor.minClustersForAlpha, clusterCount)}) or register a design ` +\n `whose simulated power reaches ${targetPower} at effect ${options.minimumEffect}, ` +\n `then re-run clusteredPower.`,\n },\n }\n}\n\n/** Throw the refusal for callers that want configuration-time failure. */\nexport function assertDesignAdequate(result: ClusteredPowerResult): void {\n if (result.refusal) {\n throw new DesignRefusalError(\n `design refused (underpowered): ${result.refusal.reasons.join('; ')}`,\n )\n }\n}\n\nfunction computeSignFlipFloor(clusterCount: number, alpha: number): SignFlipFloor {\n const twoSidedP = 2 ** (1 - clusterCount)\n const oneSidedP = 2 ** -clusterCount\n let minClusters = 1\n while (2 ** (1 - minClusters) > alpha) minClusters += 1\n return {\n twoSidedP,\n oneSidedP,\n alpha,\n certifiableAtAlpha: twoSidedP <= alpha,\n minClustersForAlpha: minClusters,\n }\n}\n\ninterface SimulationConfig {\n clusterSizes: number[]\n seed: number\n trials: number\n resamples: number\n confidence: number\n baseWinRate: number\n baseLossRate: number\n noisy: Map<number, number>\n}\n\n/**\n * One effect point. Loss probability is min(baseLoss, (1-effect)/2) and\n * win probability is loss probability plus effect. Their difference equals\n * effect, including near the probability boundary. Noisy clusters draw win\n * and loss independently at their\n * flip rate. Each trial computes a whole-cluster percentile bootstrap of the\n * pooled row mean; the trial counts toward power when the interval excludes\n * zero.\n */\nfunction simulateEffect(effect: number, config: SimulationConfig): ClusteredPowerPoint {\n const rng = mulberry32(mixSeed(config.seed, effect))\n const clusterCount = config.clusterSizes.length\n let excludes = 0\n const widths = new Array<number>(config.trials)\n const sums = new Array<number>(clusterCount)\n const means = new Array<number>(config.resamples)\n for (let trial = 0; trial < config.trials; trial++) {\n for (let cluster = 0; cluster < clusterCount; cluster++) {\n const size = config.clusterSizes[cluster]!\n const flipRate = config.noisy.get(cluster)\n let sum = 0\n for (let row = 0; row < size; row++) {\n if (flipRate !== undefined) {\n const win = rng() < flipRate ? 1 : 0\n const loss = rng() < flipRate ? 1 : 0\n sum += win - loss\n } else {\n const lossRate = Math.min(config.baseLossRate, (1 - effect) / 2)\n const winRate = lossRate + effect\n const u = rng()\n sum += u < winRate ? 1 : u < winRate + lossRate ? -1 : 0\n }\n }\n sums[cluster] = sum\n }\n for (let draw = 0; draw < config.resamples; draw++) {\n let pooledSum = 0\n let pooledRows = 0\n for (let pick = 0; pick < clusterCount; pick++) {\n const index = Math.floor(rng() * clusterCount)\n pooledSum += sums[index]!\n pooledRows += config.clusterSizes[index]!\n }\n means[draw] = pooledSum / pooledRows\n }\n means.sort((a, b) => a - b)\n const tail = 1 - config.confidence\n const lower = means[Math.floor((tail / 2) * config.resamples)]!\n const upper =\n means[\n Math.max(\n Math.floor((tail / 2) * config.resamples),\n Math.min(config.resamples - 1, Math.ceil((1 - tail / 2) * config.resamples) - 1),\n )\n ]!\n widths[trial] = upper - lower\n if (lower > 0 || upper < 0) excludes += 1\n }\n widths.sort((a, b) => a - b)\n return {\n effect,\n power: excludes / config.trials,\n medianCiWidth: widths[Math.floor(config.trials / 2)]!,\n }\n}\n\n/** Fold the effect into the seed so every grid point draws an independent stream. */\nfunction mixSeed(seed: number, effect: number): number {\n const scaled = Math.round(effect * 1_000_003)\n return ((seed ^ (scaled * 0x9e3779b9)) >>> 0) | 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIA,SAAS,mBAAmB,GAA4B;CACtD,OAAO,sBAAsB,CAAC,MAAM,EAAE;AACxC;AAEA,SAAS,cAAc,MAAmD;CACxE,MAAM,IAAI,KAAK;CACf,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,GAAG;EACL,IAAI,CAAC,mBAAmB,CAAC,GACvB,MAAM,IAAI,MACR,oDAAoD,EAAE,GAAG,mCAC3D;EAEF,IAAI,KAAK,UAAU,KAAA,KAAa,KAAK,UAAU,EAAE,OAC/C,MAAM,IAAI,MACR,+BAA+B,KAAK,MAAM,uCAAuC,EAA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MAAM,IAAI,IAAI,YAAY;IAC7C,aAAa,KAAK;IAClB,cAAc,OAAO,aAAa;GACpC;GACA,MAAM,QAAQ,YAAY;EAC5B;EACA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC;EAC1B,MAAM,OAAO,IAAI,OAAO;EACxB,MAAM,QAAQ,MAAM,KAAK,MAAO,OAAO,IAAK,OAAO,SAAS;EAC5D,MAAM,QACJ,MACE,KAAK,IACH,KAAK,MAAO,OAAO,IAAK,OAAO,SAAS,GACxC,KAAK,IAAI,OAAO,YAAY,GAAG,KAAK,MAAM,IAAI,OAAO,KAAK,OAAO,SAAS,IAAI,CAAC,CACjF;EAEJ,OAAO,SAAS,QAAQ;EACxB,IAAI,QAAQ,KAAK,QAAQ,GAAG,YAAY;CAC1C;CACA,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAC3B,OAAO;EACL;EACA,OAAO,WAAW,OAAO;EACzB,eAAe,OAAO,KAAK,MAAM,OAAO,SAAS,CAAC;CACpD;AACF;;AAGA,SAAS,QAAQ,MAAc,QAAwB;CAErD,QAAS,OADM,KAAK,MAAM,SAAS,OACb,IAAI,gBAAiB,IAAK;AAClD"}
@@ -1,5 +1,5 @@
1
1
  import { m as CustomTokenPricing } from "./cost-ledger-CSP-OfFe.js";
2
- import { p as AnalystUsageReceipt } from "./types-CKNAzCSA.js";
2
+ import { p as AnalystUsageReceipt } from "./types-B1W3v8dT.js";
3
3
  import { t as PrimeBridgeTransport } from "./prime-bridge-transport-Cfqir_Im.js";
4
4
  /**
5
5
  * The reply grammar an analyst arm holds a model to, independent of transport.
@@ -306,4 +306,4 @@ interface PrimeProtocolIdentity {
306
306
  */
307
307
  declare function primeProtocolSha256(identity: PrimeProtocolIdentity): string;
308
308
  export { runPrimeExchange as C, ReplyRowDecoded as D, ReplyEnvelope as E, ReplyRowRejection as O, projectPrimeTrajectory as S, ReplyContract as T, buildPrimePrompt as _, PrimeProjectionOutcome as a, normalizePrimeUsage as b, PrimeProtocolIdentity as c, PrimeRepairPromptSpec as d, PrimeRepairState as f, analystUsageReceiptFromPrimeUsage as g, PrimeTurnRecord as h, PrimeProjectionDelivery as i, PrimeRawUsage as l, PrimeRowDecoded as m, PrimeExchangeOutcome as n, PrimeProjectionSource as o, PrimeReplyContract as p, PrimeFailure as r, PrimePromptSpec as s, PrimeExchangeOptions as t, PrimeRejectedRow as u, buildPrimeRepairPrompt as v, DecodedReply as w, primeProtocolSha256 as x, mergePrimeRawUsage as y };
309
- //# sourceMappingURL=prime-protocol-Jm2pWh--.d.ts.map
309
+ //# sourceMappingURL=prime-protocol-BRMk6dGI.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prime-protocol-Jm2pWh--.d.ts","names":[],"sources":["../src/analyst/reply-contract.ts","../src/analyst/prime-protocol.ts"],"mappings":";;;;;;;;;;;;;KAaY,gBAAgB;EAAU;EAAU,KAAK;;EAAW;EAAW;;;UAG1D;EACf;;EAEA,QAAQ;;UAGO,cAAc;;EAE7B;;EAEA;;;;;EAKA;;;;;;EAMA,UAAU,cAAc,gBAAgB,gBAAgB;;;;;;EAMxD;;;;;;EAMA,eAAe,iBAAiB;;;;;;EAMhC;;;;;EAKA;;;UAIe;EACf;EACA;;UAGe,aAAa;EAC5B,MAAM;;EAEN,QAAQ;EACR,UAAU;;EAEV;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;KC3CU,gBAAgB,QAAQ,gBAAgB;KAExC,mBAAmB,QAAQ,cAAc;UAIpC;EACf;;EAEA;EACA;;EAEA;EACA;;EAEA;;iBAGc,iBAAiB,MAAM;UAatB;EACf;EACA;EACA;;;iBAIc,uBAAuB,MAAM;;;;;;UAoE5B;;;;;;EAMf;;EAEA;;EAEA;;;;;;;EAOA;;;iBAQc,oBAAoB,eAAe;;;;;;iBAgBnC,mBAAmB,GAAG,eAAe,GAAG,gBAAgB;;;;;;;;;;;;;iBA6BxD,kCACd,OAAO,eACP,SAAS,qBACR;;;;;;;;KAqCS;EAEN;EACA;;EAEA;EAAqB;EAAiB;EAAgB;;EACtD;EAAiB;EAAiB;;UAEvB;EACf;;EAEA;;;UAIe;EACf;EACA,OAAO;;EAEP;;UAGe;EACf;EACA;;KAGU,qBAAqB;EAE3B;;EAEA;EACA,MAAM;EACN,UAAU;;EAEV;;EAEA;EACA,OAAO;EACP,OAAO;EACP,QAAQ;EACR;;EAGA;EACA,SAAS;EACT,OAAO;EACP,OAAO;EACP,QAAQ;;EAER;;UAGW,qBAAqB;EACpC,UAAU,mBAAmB;EAC7B;EACA,WAAW;;EAEX;EACA;;EAEA;;EAEA;EACA,SAAS;;;;;;;iBAQW,iBAAiB,MACrC,SAAS,qBAAqB,QAC7B,QAAQ,qBAAqB;;;;;;UAyLf,sBAAsB;;EAErC,QAAQ,iBAAiB;;EAEzB,UAAU,iBAAiB;;EAE3B;;UAGe;EACf;EACA;EACA;;KAGU,uBAAuB;EAE7B;EACA,gBAAgB;EAChB;EACA,UAAU;;EAEV;EAAW;EAAgB;;;;;;;;;iBASX,uBAAuB,OAC3C,QAAQ,sBAAsB,QAC9B;EAAU;IACT,QAAQ,uBAAuB;UA8BjB;EACf;EACA;EACA;EACA;;EAEA,QAAQ,SAAS;;;;;;;;;;;;iBAaH,oBAAoB,UAAU"}
1
+ {"version":3,"file":"prime-protocol-BRMk6dGI.d.ts","names":[],"sources":["../src/analyst/reply-contract.ts","../src/analyst/prime-protocol.ts"],"mappings":";;;;;;;;;;;;;KAaY,gBAAgB;EAAU;EAAU,KAAK;;EAAW;EAAW;;;UAG1D;EACf;;EAEA,QAAQ;;UAGO,cAAc;;EAE7B;;EAEA;;;;;EAKA;;;;;;EAMA,UAAU,cAAc,gBAAgB,gBAAgB;;;;;;EAMxD;;;;;;EAMA,eAAe,iBAAiB;;;;;;EAMhC;;;;;EAKA;;;UAIe;EACf;EACA;;UAGe,aAAa;EAC5B,MAAM;;EAEN,QAAQ;EACR,UAAU;;EAEV;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;KC3CU,gB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} from "./run-record-kuOr3BCF.js";
3
3
  import { i as DatasetSplit, n as DatasetManifest, r as DatasetScenario } from "./dataset-DThC1S6G.js";
4
- import { d as HeldOutGateDecision } from "./research-report-CIgUe1lv.js";
4
+ import { d as HeldOutGateDecision } from "./research-report-CL5_UqCX.js";
5
5
  /** Severity of an actionable finding attached to a run/trace. */
6
6
  type AsiSeverity = 'info' | 'warning' | 'error' | 'critical';
7
7
  /** Actionable side-info — a diagnosed finding the loop can act on. */
@@ -227,4 +227,4 @@ declare function judgeReplayGate<TOutput>(args: JudgeReplayGateArgs<TOutput>): P
227
227
  candidateSamples: number;
228
228
  }>;
229
229
  export { evaluateReleaseConfidence as _, bootstrapCi as a, ReleaseConfidenceAxis as c, ReleaseConfidenceIssue as d, ReleaseConfidenceMetrics as f, ReleaseTraceEvidence as g, ReleaseConfidenceThresholds as h, Verdict as i, ReleaseConfidenceAxisName as l, ReleaseConfidenceStatus as m, BootstrapResult as n, judgeReplayGate as o, ReleaseConfidenceScorecard as p, JudgeReplayGateArgs as r, ActionableSideInfo as s, BootstrapOptions as t, ReleaseConfidenceInput as u };
230
- //# sourceMappingURL=promotion-gate-BXgcORnM.d.ts.map
230
+ //# sourceMappingURL=promotion-gate-B0VTBoXg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promotion-gate-BXgcORnM.d.ts","names":[],"sources":["../src/release-confidence.ts","../src/promotion-gate.ts"],"mappings":";;;;;KAuBK;;UAGY;;EAEf;;EAEA;EACA,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;EACA,WAAW;;KAGD;KACA;UAQK;EACf;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;;EAEA,eAAe;EACf,MAAM;EACN,WAAW;;UAGI;;EAEf;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA,UAAU;EACV,qBAAqB;EACrB,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;EACf,aAAa;;UAGE;EACf,MAAM;EACN,QAAQ;EACR;EACA;;UAGe;EACf,MAAM;EACN;EACA;EACA;;UAGe;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,OAAO;EACpB,cAAc;EACd,oBAAoB,QAAQ,OAAO;EACnC,0BAA0B;;;;;;;EAO1B;;UAGe;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA,MAAM;EACN,QAAQ;EACR,SAAS;EACT,SAAS;EACT,cAAc;EACd;;iBAkBc,0BACd,OAAO,yBACN;;;;;;;;;;;;;;;;;;;;;;;;;KC3JS;UAEK;EACf;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA,SAAS;;UAGM;;EAEf;;EAEA;;;;;;EAMA;;;EAGA;;;;;;;;;iBAUc,YACd,oBACA,qBACA,UAAS,mBACR;;;;;;;;;;;;;;;;UA0Gc,oBAAoB;EACnC,iBAAiB;EACjB,kBAAkB;;EAElB,QAAQ,QAAQ,YAAY;EAC5B;EACA;;EAEA;;EAEA;;;;;iBAMoB,gBAAgB,SACpC,MAAM,oBAAoB,WACzB,QAAQ;EAAoB;EAAyB"}
1
+ {"version":3,"file":"promotion-gate-B0VTBoXg.d.ts","names":[],"sources":["../src/release-confidence.ts","../src/promotion-gate.ts"],"mappings":";;;;;KAuBK;;UAGY;;EAEf;;EAEA;EACA,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;EACA,WAAW;;KAGD;KACA;UAQK;EACf;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;;EAEA,eAAe;EACf,MAAM;EACN,WAAW;;UAGI;;EAEf;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA,UAAU;EACV,qBAAqB;EACrB,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;EACf,aAAa;;UAGE;EACf,MAAM;EACN,QAAQ;EACR;EACA;;UAGe;EACf,MAAM;EACN;EACA;EACA;;UAGe;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,OAAO;EACpB,cAAc;EACd,oBAAoB,QAAQ,OAAO;EACnC,0BAA0B;;;;;;;EAO1B;;UAGe;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA,MAAM;EACN,QAAQ;EACR,SAAS;EACT,SAAS;EACT,cAAc;EACd;;iBAkBc,0BACd,OAAO,yBACN;;;;;;;;;;;;;;;;;;;;;;;;;KC3JS;UAEK;EACf;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA,SAAS;;UAGM;;EAEf;;EAEA;;;;;;EAMA;;;EAGA;;;;;;;;;iBAUc,YACd,oBACA,qBACA,UAAS,mBACR;;;;;;;;;;;;;;;;UA0Gc,oBAAoB;EACnC,iBAAiB;EACjB,kBAAkB;;EAElB,QAAQ,QAAQ,YAAY;EAC5B;EACA;;EAEA;;EAEA;;;;;iBAMoB,gBAAgB,SACpC,MAAM,oBAAoB,WACzB,QAAQ;EAAoB;EAAyB"}
@@ -1,6 +1,6 @@
1
1
  import { r as pairedBootstrap } from "./paired-tests-CXcD_B80.js";
2
- import { t as decidePairedPromotion } from "./paired-promotion-decision-xYe881cD.js";
3
- import { o as pairHoldout, r as detectScale } from "./statistical-heldout-C7Jjo5nP.js";
2
+ import { t as decidePairedPromotion } from "./paired-promotion-decision-BtfVwEAk.js";
3
+ import { o as pairHoldout, r as detectScale } from "./statistical-heldout-CL_7mI5C.js";
4
4
  // src/campaign/gates/promotion-policy.ts
5
5
  /**
6
6
  * Build paired evidence for each objective and apply a promotion policy.
@@ -170,4 +170,4 @@ function paretoSignificanceGate(options) {
170
170
  }
171
171
  export { paretoPolicy as n, paretoSignificanceGate as r, buildEvidenceVector as t };
172
172
 
173
- //# sourceMappingURL=promotion-policy-Z5E-C32U.js.map
173
+ //# sourceMappingURL=promotion-policy-BgI7PsQn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"promotion-policy-Z5E-C32U.js","names":[],"sources":["../src/campaign/gates/promotion-policy.ts"],"sourcesContent":["/**\n * Build paired evidence for each objective and apply a promotion policy.\n * The default policy requires at least one gain and every regression floor to\n * clear. A floor can fail because a larger loss remains plausible; that does\n * not demonstrate an observed regression. Missing evidence stays unresolved.\n * Confidence intervals apply to each axis, without a multiplicity adjustment.\n *\n * Cost and latency remain aggregate constraints because GateContext does not\n * supply paired observations for them. Compose a budget gate when needed.\n */\n\nimport {\n decidePairedPromotion,\n type PairedDecisionMethod,\n type PairedDecisionStatistic,\n type PairedMcNemarEvidence,\n} from '../../paired-promotion-decision'\nimport type { Direction } from '../../pareto'\nimport {\n DECISION_PAIRED_DELTA_STATISTIC,\n type PairedBootstrapResult,\n pairedBootstrap,\n} from '../../statistics'\nimport type { Gate, GateContext, GateDecision, GateResult, JudgeScore, Scenario } from '../types'\nimport { detectScale, pairHoldout } from './statistical-heldout'\n\n/** Where an objective's per-cell scalar comes from. `composite` reads the\n * judge's composite; `dimension` reads a named per-dimension score. */\nexport type ObjectiveSource = { kind: 'composite' } | { kind: 'dimension'; dimension: string }\n\nexport interface PromotionObjective {\n /** Stable label used in reports + `contributingGates`. */\n name: string\n source: ObjectiveSource\n /** 'maximize' (quality dims) or 'minimize' (error/risk/length dims). Orients\n * the paired delta so a positive bootstrap always means \"candidate better\". */\n direction: Direction\n /** Declared binary support {0, binaryScale}, including zero-only observations.\n * Must be finite and positive; paired cell scores must be 0 or this scale.\n * Uses the risk-difference mean and rejects the 'median' statistic. */\n binaryScale?: number\n /** The good-direction paired-delta CI lower bound must EXCEED this to count\n * as a significant gain on this axis. Interpreted in the judge's native\n * scale. Default 0 (⇒ \"confidently better\"). */\n gainThreshold?: number\n /** A floor breach (regression) is declared when the good-direction CI lower\n * bound is below −floorTolerance, or when the exact small-sample test proves\n * a drop past it. Defaults to 0.05 times the declared binary scale, or\n * auto-scales off observed magnitudes (0.05 on [0,1], 5 on 0-100). */\n floorTolerance?: number\n}\n\n/** Per-axis verdict from the shared paired decision rule.\n * 'regressed' includes uncertainty that prevents clearing the regression floor. */\nexport type AxisVerdict = 'improved' | 'regressed' | 'flat' | 'few_runs' | 'indeterminate'\n\nexport interface AxisEvidence {\n name: string\n source: ObjectiveSource\n direction: Direction\n /** Paired bootstrap on the GOOD-DIRECTION delta (oriented by `direction`):\n * a positive value means the candidate is better on this axis.\n *\n * DIAGNOSTIC on a pass/fail axis: there the verdict is decided on Tango's\n * score interval instead, because a percentile bootstrap over a three-atom\n * delta lattice is not a valid interval at the nonzero margin `floorTolerance`\n * and `gainThreshold` create. `ci` carries the interval that decided. */\n bootstrap: PairedBootstrapResult\n /** Which paired statistic `bootstrap.low`/`.high` bracket. `'mean'` unless the\n * caller asked for the median — on a pass/fail axis the median and its whole\n * CI are pinned at 0 by tie domination and can see neither a gain nor a\n * regression. `bootstrap.median` still carries the median point estimate. */\n bootstrapStatistic: 'median' | 'mean'\n /** The interval the axis verdict was actually decided on, good-direction and\n * in the axis's native units. */\n ci: { low: number; high: number }\n /** Which estimator produced `ci`. */\n decisionStatistic: PairedDecisionStatistic\n /** McNemar's exact evidence on a pass/fail axis; null otherwise. */\n mcnemar: PairedMcNemarEvidence | null\n /** `ci` has zero width or non-finite bounds. It cannot establish a gain or\n * clear a regression floor, regardless of the point estimate. */\n indeterminate: boolean\n /** Paired observations contributing to this axis. */\n n: number\n minimumRequired: number\n decisionMethod: PairedDecisionMethod\n gainThreshold: number\n floorTolerance: number\n verdict: AxisVerdict\n}\n\nexport interface EvidenceVector {\n /** One entry per objective — NOTHING averaged across axes. */\n axes: AxisEvidence[]\n /** Smallest paired n across axes that produced observations — the binding\n * evidence-sufficiency constraint. 0 when no axis produced observations. */\n minN: number\n /** Aggregate per-side cost from the gate context (a constraint input, not a\n * CI axis — see the module header). */\n cost: { candidate: number; baseline: number }\n}\n\n/** A promotion strategy: a pure function from the evidence vector to a verdict.\n * Many policies can run over the same `EvidenceVector` and disagree — that's\n * the point (competing strategies, shared evidence). */\nexport type PromotionPolicy = (ev: EvidenceVector) => GateResult\n\nexport interface BuildEvidenceVectorOptions {\n /** Minimum paired observations before an axis can claim significance; below\n * it the axis is `few_runs`. The exact small-sample test may require more\n * observations at the selected confidence. */\n minProductiveRuns?: number\n /** Confidence level for every axis bootstrap. Default 0.95. */\n confidence?: number\n /** Bootstrap resamples. Default 2000. */\n resamples?: number\n /** Fixed bootstrap seed for a deterministic, reproducible verdict. Default 1337. */\n seed?: number\n /** Paired statistic every axis CI is computed on. Default `'mean'` — see\n * {@link DECISION_PAIRED_DELTA_STATISTIC} for why the median is not. */\n statistic?: 'mean' | 'median'\n}\n\n/**\n * The Evidence Bus. For each objective, pair candidate vs baseline by full\n * cellId and bootstrap a CI on the good-direction paired delta. Reuses the\n * exact `pairHoldout` + `pairedBootstrap` machinery the held-out gate uses, so\n * a single source of truth governs pairing granularity + scale handling.\n */\nexport function buildEvidenceVector<TArtifact, TScenario extends Scenario>(\n ctx: GateContext<TArtifact, TScenario>,\n objectives: PromotionObjective[],\n opts: BuildEvidenceVectorOptions = {},\n): EvidenceVector {\n if (objectives.length === 0) {\n throw new Error('buildEvidenceVector: at least 1 objective required')\n }\n const confidence = opts.confidence ?? 0.95\n const resamples = opts.resamples ?? 2000\n const seed = opts.seed ?? 1337\n const baseline = ctx.baselineJudgeScores ?? ctx.judgeScores\n const scenarioIds = new Set(ctx.scenarios.map((s) => s.id))\n\n const axes: AxisEvidence[] = []\n for (const obj of objectives) {\n let select: (s: JudgeScore) => number | undefined\n if (obj.source.kind === 'composite') {\n select = (s) => s.composite\n } else {\n const dim = obj.source.dimension\n select = (s) => s.dimensions[dim]\n }\n const paired = pairHoldout(ctx.judgeScores, baseline, scenarioIds, select)\n // Orient to the good direction: maximize ⇒ bootstrap (candidate − baseline);\n // minimize ⇒ bootstrap (baseline − candidate) by swapping args, so a\n // positive bootstrap always reads as \"candidate better on this axis\".\n const before = obj.direction === 'maximize' ? paired.before : paired.after\n const after = obj.direction === 'maximize' ? paired.after : paired.before\n const n = paired.before.length\n const binaryScale = obj.binaryScale\n const floorTolerance =\n obj.floorTolerance ?? 0.05 * (binaryScale ?? detectScale([...paired.before, ...paired.after]))\n const gainThreshold = obj.gainThreshold ?? 0\n // Axes are decided on the MEAN paired delta — which for a pass/fail axis is\n // exactly the change in success rate. The median is structurally blind on\n // the shapes eval data lands in: with most pairs tied its bootstrap CI\n // collapses to [0,0] and the axis reads 'flat', hiding real gains AND real\n // regressions — pass/fail axes on ANY encoding ({0,1} and the 0-100 one\n // `detectScale` exists for), and low-cardinality axes even below half ties.\n // Orthogonal to `pairedDeltaTest`'s own small-sample switch: that picks the\n // TEST (bootstrap CI at n ≥ 20, exact sign test below), this picks the\n // ESTIMATOR the test is applied to. Both are needed — an exact sign test on\n // a tie-pinned median is still blind.\n const bootstrapStatistic = opts.statistic ?? DECISION_PAIRED_DELTA_STATISTIC\n // Both burdens of proof route through the ONE shared rule\n // (`decidePairedPromotion`), so a pass/fail axis is judged on Tango's score\n // interval — the only paired-binary construction valid at the nonzero\n // margins `gainThreshold` / `floorTolerance` create — and a zero-width\n // interval cannot buy a verdict in either direction.\n const improvement = decidePairedPromotion(before, after, {\n confidence,\n resamples,\n statistic: bootstrapStatistic,\n seed,\n threshold: gainThreshold,\n minPairs: opts.minProductiveRuns,\n binaryScale,\n })\n const regression = decidePairedPromotion(after, before, {\n confidence,\n resamples,\n statistic: bootstrapStatistic,\n seed,\n threshold: floorTolerance,\n minPairs: opts.minProductiveRuns,\n binaryScale,\n })\n const bootstrap =\n improvement.bootstrap ??\n pairedBootstrap(before, after, {\n confidence,\n resamples,\n statistic: bootstrapStatistic,\n seed,\n })\n // A floor breach fires on EITHER burden of proof, because they cover\n // different failures and the floor is the anti-Goodhart guard:\n // - `improvement.low < -floorTolerance` — the CREDIBLE WORST CASE exceeds\n // the tolerance. This is the contract `AxisEvidence.floorTolerance` and\n // `paretoPolicy`'s own reason string state, and it is the conservative\n // posture a safety axis needs: block unless the data can rule the\n // breach out, rather than waiting for the breach to be proven. Read off\n // the DECIDING interval, so a pass/fail axis is not screened by a\n // bootstrap that is pinned wherever ties dominate.\n // - `regression.promote` — a PROVEN drop past the tolerance. Adds the\n // small-sample path, where the decision is an exact sign test because\n // the bootstrap interval is descriptive only.\n // A tied binary axis still has uncertainty about unseen discordant pairs.\n // Its diagnostic bootstrap collapses to zero, so only the deciding score\n // interval can establish that a regression stays within the declared floor.\n const floorBreached = improvement.low < -floorTolerance || regression.promote\n // Floor check precedes the gain check: a credible regression must never be\n // masked as \"improved\". With the defaults (gainThreshold 0, positive floor)\n // the regions are disjoint and order is moot, but a consumer who sets a\n // negative gainThreshold (\"accept small dips\") could otherwise have a real\n // floor breach classified as a gain — anti-Goodhart wins the tie.\n const verdict: AxisVerdict = !improvement.sufficient\n ? 'few_runs'\n : improvement.indeterminate\n ? 'indeterminate'\n : floorBreached\n ? 'regressed'\n : improvement.promote\n ? 'improved'\n : 'flat'\n axes.push({\n name: obj.name,\n source: obj.source,\n direction: obj.direction,\n bootstrap,\n bootstrapStatistic,\n ci: { low: improvement.low, high: improvement.high },\n decisionStatistic: improvement.statistic,\n mcnemar: improvement.mcnemar,\n indeterminate: improvement.indeterminate,\n n,\n minimumRequired: improvement.minimumPairs,\n decisionMethod: improvement.method,\n gainThreshold,\n floorTolerance,\n verdict,\n })\n }\n const ns = axes.map((a) => a.n).filter((n) => n > 0)\n const minN = ns.length > 0 ? Math.min(...ns) : 0\n return { axes, minN, cost: { candidate: ctx.cost.candidate, baseline: ctx.cost.baseline } }\n}\n\n/**\n * Require a supported gain and every configured regression floor to clear.\n * A failed floor holds the candidate, including when uncertainty permits a loss.\n * Missing or indeterminate evidence requires more work; no gain holds release.\n */\nexport const paretoPolicy: PromotionPolicy = (ev) => {\n const contributingGates = ev.axes.map((ax) => ({\n name: `objective:${ax.name}`,\n status:\n ax.verdict === 'regressed'\n ? ('fail' as const)\n : ax.verdict === 'few_runs' || ax.verdict === 'indeterminate'\n ? ('not_evaluated' as const)\n : ('pass' as const),\n detail: {\n direction: ax.direction,\n source: ax.source,\n verdict: ax.verdict,\n n: ax.n,\n deltaMedian: ax.bootstrap.median,\n ciLow: ax.ci.low,\n ciHigh: ax.ci.high,\n decisionStatistic: ax.decisionStatistic,\n decisionMethod: ax.decisionMethod,\n mcnemar: ax.mcnemar,\n indeterminate: ax.indeterminate,\n bootstrapCiLow: ax.bootstrap.low,\n bootstrapCiHigh: ax.bootstrap.high,\n confidence: ax.bootstrap.confidence,\n gainThreshold: ax.gainThreshold,\n floorTolerance: ax.floorTolerance,\n },\n }))\n\n const regressed = ev.axes.filter((a) => a.verdict === 'regressed')\n const insufficient = ev.axes.filter(\n (a) => a.verdict === 'few_runs' || a.verdict === 'indeterminate',\n )\n const improved = ev.axes.filter((a) => a.verdict === 'improved')\n\n let decision: GateDecision\n const reasons: string[] = []\n if (regressed.length > 0) {\n // A gain on another axis cannot excuse an unresolved regression floor.\n decision = 'hold'\n for (const a of regressed) {\n reasons.push(\n `objective '${a.name}' did not clear its regression floor -${a.floorTolerance}: good-direction CI [${a.ci.low.toFixed(3)}, ${a.ci.high.toFixed(3)}] (n=${a.n})`,\n )\n }\n } else if (insufficient.length > 0) {\n // An unresolved axis cannot establish either a gain or a safe floor.\n decision = 'need_more_work'\n for (const a of insufficient) {\n reasons.push(\n a.verdict === 'few_runs'\n ? `objective '${a.name}' has only n=${a.n} paired runs — insufficient evidence to claim significance`\n : `objective '${a.name}' has an indeterminate deciding CI [${a.ci.low}, ${a.ci.high}] — insufficient evidence to clear its regression floor (n=${a.n})`,\n )\n }\n } else if (improved.length > 0) {\n decision = 'ship'\n reasons.push(\n `Supported objective gain: ${improved\n .map(\n (a) =>\n `'${a.name}' +${a.ci.low > 0 ? a.ci.low.toFixed(3) : a.bootstrap.mean.toFixed(3)} (CI.low ${a.ci.low.toFixed(3)})`,\n )\n .join(', ')}; every regression floor cleared`,\n )\n } else {\n // Every floor cleared, but no objective demonstrated a significant gain.\n decision = 'hold'\n reasons.push(\n 'no Pareto improvement: no objective shows a significant gain; every regression floor cleared',\n )\n }\n\n // `delta` surfaces the composite axis if present, else the first axis — a\n // single convenience scalar; the vector lives in `contributingGates`.\n const composite = ev.axes.find((a) => a.source.kind === 'composite') ?? ev.axes[0]\n return { decision, reasons, contributingGates, delta: composite?.bootstrap.median }\n}\n\nexport interface ParetoSignificanceGateOptions extends BuildEvidenceVectorOptions {\n /** The objective vector. Every axis is both a gain source and a safety floor. */\n objectives: PromotionObjective[]\n /** Strategy applied to the evidence vector. Default `paretoPolicy`. Override\n * to run a stricter/looser strategy over the SAME bus (competing policies). */\n policy?: PromotionPolicy\n /** Override the gate name in reports. */\n name?: string\n}\n\n/**\n * Wrap the bus + a policy as a `Gate`. Plugs into the existing\n * `runImprovementLoop({ gate })` slot and composes via `composeGate`; default\n * loop behavior is unchanged because consumers opt in by passing this gate.\n */\nexport function paretoSignificanceGate<TArtifact = unknown, TScenario extends Scenario = Scenario>(\n options: ParetoSignificanceGateOptions,\n): Gate<TArtifact, TScenario> {\n if (options.objectives.length === 0) {\n throw new Error('paretoSignificanceGate: at least 1 objective required')\n }\n const policy = options.policy ?? paretoPolicy\n return {\n name: options.name ?? 'paretoSignificanceGate',\n async decide(ctx: GateContext<TArtifact, TScenario>): Promise<GateResult> {\n const ev = buildEvidenceVector(ctx, options.objectives, options)\n return policy(ev)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkIA,SAAgB,oBACd,KACA,YACA,OAAmC,CAAC,GACpB;CAChB,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,MAAM,oDAAoD;CAEtE,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,WAAW,IAAI,uBAAuB,IAAI;CAChD,MAAM,cAAc,IAAI,IAA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sources":["../src/campaign/gates/promotion-policy.ts"],"sourcesContent":["/**\n * Build paired evidence for each objective and apply a promotion policy.\n * The default policy requires at least one gain and every regression floor to\n * clear. A floor can fail because a larger loss remains plausible; that does\n * not demonstrate an observed regression. Missing evidence stays unresolved.\n * Confidence intervals apply to each axis, without a multiplicity adjustment.\n *\n * Cost and latency remain aggregate constraints because GateContext does not\n * supply paired observations for them. Compose a budget gate when needed.\n */\n\nimport {\n decidePairedPromotion,\n type PairedDecisionMethod,\n type PairedDecisionStatistic,\n type PairedMcNemarEvidence,\n} from '../../paired-promotion-decision'\nimport type { Direction } from '../../pareto'\nimport {\n DECISION_PAIRED_DELTA_STATISTIC,\n type PairedBootstrapResult,\n pairedBootstrap,\n} from '../../statistics'\nimport type { Gate, GateContext, GateDecision, GateResult, JudgeScore, Scenario } from '../types'\nimport { detectScale, pairHoldout } from './statistical-heldout'\n\n/** Where an objective's per-cell scalar comes from. `composite` reads the\n * judge's composite; `dimension` reads a named per-dimension score. */\nexport type ObjectiveSource = { kind: 'composite' } | { kind: 'dimension'; dimension: string }\n\nexport interface PromotionObjective {\n /** Stable label used in reports + `contributingGates`. */\n name: string\n source: ObjectiveSource\n /** 'maximize' (quality dims) or 'minimize' (error/risk/length dims). Orients\n * the paired delta so a positive bootstrap always means \"candidate better\". */\n direction: Direction\n /** Declared binary support {0, binaryScale}, including zero-only observations.\n * Must be finite and positive; paired cell scores must be 0 or this scale.\n * Uses the risk-difference mean and rejects the 'median' statistic. */\n binaryScale?: number\n /** The good-direction paired-delta CI lower bound must EXCEED this to count\n * as a significant gain on this axis. Interpreted in the judge's native\n * scale. Default 0 (⇒ \"confidently better\"). */\n gainThreshold?: number\n /** A floor breach (regression) is declared when the good-direction CI lower\n * bound is below −floorTolerance, or when the exact small-sample test proves\n * a drop past it. Defaults to 0.05 times the declared binary scale, or\n * auto-scales off observed magnitudes (0.05 on [0,1], 5 on 0-100). */\n floorTolerance?: number\n}\n\n/** Per-axis verdict from the shared paired decision rule.\n * 'regressed' includes uncertainty that prevents clearing the regression floor. */\nexport type AxisVerdict = 'improved' | 'regressed' | 'flat' | 'few_runs' | 'indeterminate'\n\nexport interface AxisEvidence {\n name: string\n source: ObjectiveSource\n direction: Direction\n /** Paired bootstrap on the GOOD-DIRECTION delta (oriented by `direction`):\n * a positive value means the candidate is better on this axis.\n *\n * DIAGNOSTIC on a pass/fail axis: there the verdict is decided on Tango's\n * score interval instead, because a percentile bootstrap over a three-atom\n * delta lattice is not a valid interval at the nonzero margin `floorTolerance`\n * and `gainThreshold` create. `ci` carries the interval that decided. */\n bootstrap: PairedBootstrapResult\n /** Which paired statistic `bootstrap.low`/`.high` bracket. `'mean'` unless the\n * caller asked for the median — on a pass/fail axis the median and its whole\n * CI are pinned at 0 by tie domination and can see neither a gain nor a\n * regression. `bootstrap.median` still carries the median point estimate. */\n bootstrapStatistic: 'median' | 'mean'\n /** The interval the axis verdict was actually decided on, good-direction and\n * in the axis's native units. */\n ci: { low: number; high: number }\n /** Which estimator produced `ci`. */\n decisionStatistic: PairedDecisionStatistic\n /** McNemar's exact evidence on a pass/fail axis; null otherwise. */\n mcnemar: PairedMcNemarEvidence | null\n /** `ci` has zero width or non-finite bounds. It cannot establish a gain or\n * clear a regression floor, regardless of the point estimate. */\n indeterminate: boolean\n /** Paired observations contributing to this axis. */\n n: number\n minimumRequired: number\n decisionMethod: PairedDecisionMethod\n gainThreshold: number\n floorTolerance: number\n verdict: AxisVerdict\n}\n\nexport interface EvidenceVector {\n /** One entry per objective — NOTHING averaged across axes. */\n axes: AxisEvidence[]\n /** Smallest paired n across axes that produced observations — the binding\n * evidence-sufficiency constraint. 0 when no axis produced observations. */\n minN: number\n /** Aggregate per-side cost from the gate context (a constraint input, not a\n * CI axis — see the module header). */\n cost: { candidate: number; baseline: number }\n}\n\n/** A promotion strategy: a pure function from the evidence vector to a verdict.\n * Many policies can run over the same `EvidenceVector` and disagree — that's\n * the point (competing strategies, shared evidence). */\nexport type PromotionPolicy = (ev: EvidenceVector) => GateResult\n\nexport interface BuildEvidenceVectorOptions {\n /** Minimum paired observations before an axis can claim significance; below\n * it the axis is `few_runs`. The exact small-sample test may require more\n * observations at the selected confidence. */\n minProductiveRuns?: number\n /** Confidence level for every axis bootstrap. Default 0.95. */\n confidence?: number\n /** Bootstrap resamples. Default 2000. */\n resamples?: number\n /** Fixed bootstrap seed for a deterministic, reproducible verdict. Default 1337. */\n seed?: number\n /** Paired statistic every axis CI is computed on. Default `'mean'` — see\n * {@link DECISION_PAIRED_DELTA_STATISTIC} for why the median is not. */\n statistic?: 'mean' | 'median'\n}\n\n/**\n * The Evidence Bus. For each objective, pair candidate vs baseline by full\n * cellId and bootstrap a CI on the good-direction paired delta. Reuses the\n * exact `pairHoldout` + `pairedBootstrap` machinery the held-out gate uses, so\n * a single source of truth governs pairing granularity + scale handling.\n */\nexport function buildEvidenceVector<TArtifact, TScenario extends Scenario>(\n ctx: GateContext<TArtifact, TScenario>,\n objectives: PromotionObjective[],\n opts: BuildEvidenceVectorOptions = {},\n): EvidenceVector {\n if (objectives.length === 0) {\n throw new Error('buildEvidenceVector: at least 1 objective required')\n }\n const confidence = opts.confidence ?? 0.95\n const resamples = opts.resamples ?? 2000\n const seed = opts.seed ?? 1337\n const baseline = ctx.baselineJudgeScores ?? ctx.judgeScores\n const scenarioIds = new Set(ctx.scenarios.map((s) => s.id))\n\n const axes: AxisEvidence[] = []\n for (const obj of objectives) {\n let select: (s: JudgeScore) => number | undefined\n if (obj.source.kind === 'composite') {\n select = (s) => s.composite\n } else {\n const dim = obj.source.dimension\n select = (s) => s.dimensions[dim]\n }\n const paired = pairHoldout(ctx.judgeScores, baseline, scenarioIds, select)\n // Orient to the good direction: maximize ⇒ bootstrap (candidate − baseline);\n // minimize ⇒ bootstrap (baseline − candidate) by swapping args, so a\n // positive bootstrap always reads as \"candidate better on this axis\".\n const before = obj.direction === 'maximize' ? paired.before : paired.after\n const after = obj.direction === 'maximize' ? paired.after : paired.before\n const n = paired.before.length\n const binaryScale = obj.binaryScale\n const floorTolerance =\n obj.floorTolerance ?? 0.05 * (binaryScale ?? detectScale([...paired.before, ...paired.after]))\n const gainThreshold = obj.gainThreshold ?? 0\n // Axes are decided on the MEAN paired delta — which for a pass/fail axis is\n // exactly the change in success rate. The median is structurally blind on\n // the shapes eval data lands in: with most pairs tied its bootstrap CI\n // collapses to [0,0] and the axis reads 'flat', hiding real gains AND real\n // regressions — pass/fail axes on ANY encoding ({0,1} and the 0-100 one\n // `detectScale` exists for), and low-cardinality axes even below half ties.\n // Orthogonal to `pairedDeltaTest`'s own small-sample switch: that picks the\n // TEST (bootstrap CI at n ≥ 20, exact sign test below), this picks the\n // ESTIMATOR the test is applied to. Both are needed — an exact sign test on\n // a tie-pinned median is still blind.\n const bootstrapStatistic = opts.statistic ?? DECISION_PAIRED_DELTA_STATISTIC\n // Both burdens of proof route through the ONE shared rule\n // (`decidePairedPromotion`), so a pass/fail axis is judged on Tango's score\n // interval — the only paired-binary construction valid at the nonzero\n // margins `gainThreshold` / `floorTolerance` create — and a zero-width\n // interval cannot buy a verdict in either direction.\n const improvement = decidePairedPromotion(before, after, {\n confidence,\n resamples,\n statistic: bootstrapStatistic,\n seed,\n threshold: gainThreshold,\n minPairs: opts.minProductiveRuns,\n binaryScale,\n })\n const regression = decidePairedPromotion(after, before, {\n confidence,\n resamples,\n statistic: bootstrapStatistic,\n seed,\n threshold: floorTolerance,\n minPairs: opts.minProductiveRuns,\n binaryScale,\n })\n const bootstrap =\n improvement.bootstrap ??\n pairedBootstrap(before, after, {\n confidence,\n resamples,\n statistic: bootstrapStatistic,\n seed,\n })\n // A floor breach fires on EITHER burden of proof, because they cover\n // different failures and the floor is the anti-Goodhart guard:\n // - `improvement.low < -floorTolerance` — the CREDIBLE WORST CASE exceeds\n // the tolerance. This is the contract `AxisEvidence.floorTolerance` and\n // `paretoPolicy`'s own reason string state, and it is the conservative\n // posture a safety axis needs: block unless the data can rule the\n // breach out, rather than waiting for the breach to be proven. Read off\n // the DECIDING interval, so a pass/fail axis is not screened by a\n // bootstrap that is pinned wherever ties dominate.\n // - `regression.promote` — a PROVEN drop past the tolerance. Adds the\n // small-sample path, where the decision is an exact sign test because\n // the bootstrap interval is descriptive only.\n // A tied binary axis still has uncertainty about unseen discordant pairs.\n // Its diagnostic bootstrap collapses to zero, so only the deciding score\n // interval can establish that a regression stays within the declared floor.\n const floorBreached = improvement.low < -floorTolerance || regression.promote\n // Floor check precedes the gain check: a credible regression must never be\n // masked as \"improved\". With the defaults (gainThreshold 0, positive floor)\n // the regions are disjoint and order is moot, but a consumer who sets a\n // negative gainThreshold (\"accept small dips\") could otherwise have a real\n // floor breach classified as a gain — anti-Goodhart wins the tie.\n const verdict: AxisVerdict = !improvement.sufficient\n ? 'few_runs'\n : improvement.indeterminate\n ? 'indeterminate'\n : floorBreached\n ? 'regressed'\n : improvement.promote\n ? 'improved'\n : 'flat'\n axes.push({\n name: obj.name,\n source: obj.source,\n direction: obj.direction,\n bootstrap,\n bootstrapStatistic,\n ci: { low: improvement.low, high: improvement.high },\n decisionStatistic: improvement.statistic,\n mcnemar: improvement.mcnemar,\n indeterminate: improvement.indeterminate,\n n,\n minimumRequired: improvement.minimumPairs,\n decisionMethod: improvement.method,\n gainThreshold,\n floorTolerance,\n verdict,\n })\n }\n const ns = axes.map((a) => a.n).filter((n) => n > 0)\n const minN = ns.length > 0 ? Math.min(...ns) : 0\n return { axes, minN, cost: { candidate: ctx.cost.candidate, baseline: ctx.cost.baseline } }\n}\n\n/**\n * Require a supported gain and every configured regression floor to clear.\n * A failed floor holds the candidate, including when uncertainty permits a loss.\n * Missing or indeterminate evidence requires more work; no gain holds release.\n */\nexport const paretoPolicy: PromotionPolicy = (ev) => {\n const contributingGates = ev.axes.map((ax) => ({\n name: `objective:${ax.name}`,\n status:\n ax.verdict === 'regressed'\n ? ('fail' as const)\n : ax.verdict === 'few_runs' || ax.verdict === 'indeterminate'\n ? ('not_evaluated' as const)\n : ('pass' as const),\n detail: {\n direction: ax.direction,\n source: ax.source,\n verdict: ax.verdict,\n n: ax.n,\n deltaMedian: ax.bootstrap.median,\n ciLow: ax.ci.low,\n ciHigh: ax.ci.high,\n decisionStatistic: ax.decisionStatistic,\n decisionMethod: ax.decisionMethod,\n mcnemar: ax.mcnemar,\n indeterminate: ax.indeterminate,\n bootstrapCiLow: ax.bootstrap.low,\n bootstrapCiHigh: ax.bootstrap.high,\n confidence: ax.bootstrap.confidence,\n gainThreshold: ax.gainThreshold,\n floorTolerance: ax.floorTolerance,\n },\n }))\n\n const regressed = ev.axes.filter((a) => a.verdict === 'regressed')\n const insufficient = ev.axes.filter(\n (a) => a.verdict === 'few_runs' || a.verdict === 'indeterminate',\n )\n const improved = ev.axes.filter((a) => a.verdict === 'improved')\n\n let decision: GateDecision\n const reasons: string[] = []\n if (regressed.length > 0) {\n // A gain on another axis cannot excuse an unresolved regression floor.\n decision = 'hold'\n for (const a of regressed) {\n reasons.push(\n `objective '${a.name}' did not clear its regression floor -${a.floorTolerance}: good-direction CI [${a.ci.low.toFixed(3)}, ${a.ci.high.toFixed(3)}] (n=${a.n})`,\n )\n }\n } else if (insufficient.length > 0) {\n // An unresolved axis cannot establish either a gain or a safe floor.\n decision = 'need_more_work'\n for (const a of insufficient) {\n reasons.push(\n a.verdict === 'few_runs'\n ? `objective '${a.name}' has only n=${a.n} paired runs — insufficient evidence to claim significance`\n : `objective '${a.name}' has an indeterminate deciding CI [${a.ci.low}, ${a.ci.high}] — insufficient evidence to clear its regression floor (n=${a.n})`,\n )\n }\n } else if (improved.length > 0) {\n decision = 'ship'\n reasons.push(\n `Supported objective gain: ${improved\n .map(\n (a) =>\n `'${a.name}' +${a.ci.low > 0 ? a.ci.low.toFixed(3) : a.bootstrap.mean.toFixed(3)} (CI.low ${a.ci.low.toFixed(3)})`,\n )\n .join(', ')}; every regression floor cleared`,\n )\n } else {\n // Every floor cleared, but no objective demonstrated a significant gain.\n decision = 'hold'\n reasons.push(\n 'no Pareto improvement: no objective shows a significant gain; every regression floor cleared',\n )\n }\n\n // `delta` surfaces the composite axis if present, else the first axis — a\n // single convenience scalar; the vector lives in `contributingGates`.\n const composite = ev.axes.find((a) => a.source.kind === 'composite') ?? ev.axes[0]\n return { decision, reasons, contributingGates, delta: composite?.bootstrap.median }\n}\n\nexport interface ParetoSignificanceGateOptions extends BuildEvidenceVectorOptions {\n /** The objective vector. Every axis is both a gain source and a safety floor. */\n objectives: PromotionObjective[]\n /** Strategy applied to the evidence vector. Default `paretoPolicy`. Override\n * to run a stricter/looser strategy over the SAME bus (competing policies). */\n policy?: PromotionPolicy\n /** Override the gate name in reports. */\n name?: string\n}\n\n/**\n * Wrap the bus + a policy as a `Gate`. Plugs into the existing\n * `runImprovementLoop({ gate })` slot and composes via `composeGate`; default\n * loop behavior is unchanged because consumers opt in by passing this gate.\n */\nexport function paretoSignificanceGate<TArtifact = unknown, TScenario extends Scenario = Scenario>(\n options: ParetoSignificanceGateOptions,\n): Gate<TArtifact, TScenario> {\n if (options.objectives.length === 0) {\n throw new Error('paretoSignificanceGate: at least 1 objective required')\n }\n const policy = options.policy ?? paretoPolicy\n return {\n name: options.name ?? 'paretoSignificanceGate',\n async decide(ctx: GateContext<TArtifact, TScenario>): Promise<GateResult> {\n const ev = buildEvidenceVector(ctx, options.objectives, options)\n return policy(ev)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkIA,SAAgB,oBACd,KACA,YACA,OAAmC,CAAC,GACpB;CAChB,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,MAAM,oDAAoD;CAEtE,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,WAAW,IAAI,uBAAuB,IAAI;CAChD,MAAM,cAAc,IAAI,IAAI,IAAI,UAAU,KAAK,MAAM,EAAE,EAAE,CAAC;CAE1D,MAAM,OAAuB,CAAC;CAC9B,KAAK,MAAM,OAAO,YAAY;EAC5B,IAAI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AAC,EAAE,OAAO,EAAE,EAAE,EAC/J;CAEJ,OAAO,IAAI,aAAa,SAAS,GAAG;EAElC,WAAW;EACX,KAAK,MAAM,KAAK,cACd,QAAQ,KACN,EAAE,YAAY,aACV,cAAc,EAAE,KAAK,eAAe,EAAE,EAAE,8DACxC,cAAc,EAAE,KAAK,sCAAsC,EAAE,GAAG,IAAI,IAAI,EAAE,GAAG,KAAK,6DAA6D,EAAE,EAAE,EACzJ;CAEJ,OAAO,IAAI,SAAS,SAAS,GAAG;EAC9B,WAAW;EACX,QAAQ,KACN,6BAA6B,SAC1B,KACE,MACC,IAAI,EAAE,KAAK,KAAK,EAAE,GAAG,MAAM,IAAI,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,UAAU,KAAK,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,QAAQ,CAAC,EAAE,EACpH,CAAC,CACA,KAAK,IAAI,EAAE,iCAChB;CACF,OAAO;EAEL,WAAW;EACX,QAAQ,KACN,8FACF;CACF;CAIA,MAAM,YAAY,GAAG,KAAK,MAAM,MAAM,EAAE,OAAO,SAAS,WAAW,KAAK,GAAG,KAAK;CAChF,OAAO;EAAE;EAAU;EAAS;EAAmB,OAAO,WAAW,UAAU;CAAO;AACpF;;;;;;AAiBA,SAAgB,uBACd,SAC4B;CAC5B,IAAI,QAAQ,WAAW,WAAW,GAChC,MAAM,IAAI,MAAM,uDAAuD;CAEzE,MAAM,SAAS,QAAQ,UAAU;CACjC,OAAO;EACL,MAAM,QAAQ,QAAQ;EACtB,MAAM,OAAO,KAA6D;GACxE,MAAM,KAAK,oBAAoB,KAAK,QAAQ,YAAY,OAAO;GAC/D,OAAO,OAAO,EAAE;EAClB;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { o as CostLedgerHandle } from "./cost-ledger-CSP-OfFe.js";
2
- import { c as AnalystRunEvent, d as AnalystRunSummary, i as AnalystFinding, l as AnalystRunInputs, n as AnalystContext, t as Analyst, u as AnalystRunResult } from "./types-CKNAzCSA.js";
3
- import { n as ChatClient } from "./chat-client-uQNXGuO4.js";
4
- import { i as ExactAnalystRunEvent, o as ExactAnalystRunResult, u as ExactExecutionComponentIdentity } from "./exact-types-CUsSMW3n.js";
2
+ import { c as AnalystRunEvent, d as AnalystRunSummary, i as AnalystFinding, l as AnalystRunInputs, n as AnalystContext, t as Analyst, u as AnalystRunResult } from "./types-B1W3v8dT.js";
3
+ import { n as ChatClient } from "./chat-client-BlTooBDA.js";
4
+ import { i as ExactAnalystRunEvent, o as ExactAnalystRunResult, u as ExactExecutionComponentIdentity } from "./exact-types-BIHqYBYf.js";
5
5
  interface AnalystHooks {
6
6
  /** Legacy runs may mutate ctx; exact runs provide a frozen observational context. */
7
7
  onBeforeAnalyze?(args: {
@@ -165,4 +165,4 @@ declare class AnalystRegistry {
165
165
  runStream(runId: string, inputs: AnalystRunInputs, runOpts?: RegistryRunOpts): AsyncGenerator<AnalystRunEvent, void, void>;
166
166
  }
167
167
  export { BudgetPolicy as a, RegistryRunOpts as c, AnalystRegistryOptions as i, ExactAnalystRunExecutionError as n, ExactAnalystBudgetPolicy as o, AnalystHooks as r, ExactRegistryRunOpts as s, AnalystRegistry as t };
168
- //# sourceMappingURL=registry-DEZDECdr.d.ts.map
168
+ //# sourceMappingURL=registry-BeInzotS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-DEZDECdr.d.ts","names":[],"sources":["../src/analyst/registry-plan.ts","../src/analyst/registry-execution.ts","../src/analyst/registry.ts"],"mappings":";;;;UAiBiB;;EAEf,iBAAiB;IACf,SAAS;IACT,KAAK;IACL;aACS;;EAEX,gBAAgB;IACd,SAAS;IACT,SAAS;IACT,UAAU;IACV;aACS;;;;;;EAMX,SAAS;IACP,SAAS;IACT,OAAO;IACP;MACE,+BAA+B,QAAQ;;EAE3C,YAAY;IAAQ,QAAQ;aAA4B;;UAGzC;;EAEf;;EAEA,UAAU;;;;;;;EAOV,YAAY;IACV,SAAS;IACT;IACA;IACA;;;UAIa;;EAEf,OAAO;;EAEP,OAAO,aAAa,SAAS;;EAE7B,QAAQ;;EAER,gBAAgB;;EAEhB,gBAAgB;;EAEhB,eAAe;;UAGA;;EAEf;;EAEA;;EAEA,SAAS;;EAET;;EAEA,SAAS;;EAET,aAAa;;EAEb;;EAEA,OAAO;;;;;;;;;EASP,gBAAgB,cAAc,kBAAkB,eAAe,cAAc;;;;;;EAM7E;;;KAIU;WAEG;WACA;;WAGA;WACA;;WAEA,SAAS,SAAS;;;;;;;;;;UAWhB;WACN;WACA,QAAQ;WACR;WACA,QAAQ;WACR,YAAY;WACZ,oBAAoB;WACpB;WACA,MAAM,SAAS;WACf,eACL,cAAc,kBACd,SAAS,eAAe,cAAc;WAEjC;WACA;WACA;WACA;;;cChHE,sCAAsC;WACxC;WACA,QAAQ;EAEL,YAAA,iBAAiB,QAAQ,uBAAuB,UAAU;;cCN3D;mBACM;mBACA;EAEL,YAAA,UAAS;EAIrB,SAAS,SAAS;EAsBlB,QAAQ;IACN;IACA;IACA;IACA,MAAM;;EAUF,IACJ,eACA,QAAQ,kBACR,UAAS,kBACR,QAAQ;;EAUL,SACJ,eACA,QAAQ,kBACR,SAAS,uBACR,QAAQ;;EAQJ,eACL,eACA,QAAQ,kBACR,SAAS,uBACR,eAAe;;;;;;;;;;;;EAmBX,UACL,eACA,QAAQ,kBACR,UAAS,kBACR,eAAe"}
1
+ {"version":3,"file":"registry-BeInzotS.d.ts","names":[],"sources":["../src/analyst/registry-plan.ts","../src/analyst/registry-execution.ts","../src/analyst/registry.ts"],"mappings":";;;;UAiBiB;;EAEf,iBAAiB;IACf,SAAS;IACT,KAAK;IACL;aACS;;EAEX,gBAAgB;IACd,SAAS;IACT,SAAS;IACT,UAAU;IACV;aACS;;;;;;EAMX,SAAS;IACP,SAAS;IACT,OAAO;IACP;MACE,+BAA+B,QAAQ;;EAE3C,YAAY;IAAQ,QAAQ;aAA4B;;UAGzC;;EAEf;;EAEA,UAAU;;;;;;;EAOV,YAAY;IACV,SAAS;IACT;IACA;IACA;;;UAIa;;EAEf,OAAO;;EAEP,OAAO,aAAa,SAAS;;EAE7B,QAAQ;;EAER,gBAAgB;;EAEhB,gBAAgB;;EAEhB,eAAe;;UAGA;;EAEf;;EAEA;;EAEA,SAAS;;EAET;;EAEA,SAAS;;EAET,aAAa;;EAEb;;EAEA,OAAO;;;;;;;;;EASP,gBAAgB,cAAc,kBAAkB,eAAe,cAAc;;;;;;EAM7E;;;KAIU;WAEG;WACA;;WAGA;WACA;;WAEA,SAAS,SAAS;;;;;;;;;;UAWhB;WACN;WACA,QAAQ;WACR;WACA,QAAQ;WACR,YAAY;WACZ,oBAAoB;WACpB;WACA,MAAM,SAAS;WACf,eACL,cAAc,kBACd,SAAS,eAAe,cAAc;WAEjC;WACA;WACA;WACA;;;cChHE,sCAAsC;WACxC;WACA,QAAQ;EAEL,YAAA,iBAAiB,QAAQ,uBAAuB,UAAU;;cCN3D;mBACM;mBACA;EAEL,YAAA,UAAS;EAIrB,SAAS,SAAS;EAsBlB,QAAQ;IACN;IACA;IACA;IACA,MAAM;;EAUF,IACJ,eACA,QAAQ,kBACR,UAAS,kBACR,QAAQ;;EAUL,SACJ,eACA,QAAQ,kBACR,SAAS,uBACR,QAAQ;;EAQJ,eACL,eACA,QAAQ,kBACR,SAAS,uBACR,eAAe;;;;;;;;;;;;EAmBX,UACL,eACA,QAAQ,kBACR,UAAS,kBACR,eAAe"}
@@ -1,9 +1,9 @@
1
- import { A as pairedBootstrap, E as PairedBootstrapResult, T as PairedBootstrapOptions, Y as benjaminiHochberg, g as wilcoxonSignedRank } from "./index-CIqYaySd.js";
2
- import { a as ResearchReportOptions, i as ResearchReportMethodology, n as ResearchReportCandidate, o as ResearchReportRecommendation, r as ResearchReportDecision, s as researchReport, t as ResearchReport } from "./research-report-CIgUe1lv.js";
1
+ import { A as pairedBootstrap, E as PairedBootstrapResult, T as PairedBootstrapOptions, Y as benjaminiHochberg, g as wilcoxonSignedRank } from "./index-Bk1XEkP7.js";
2
+ import { a as ResearchReportOptions, i as ResearchReportMethodology, n as ResearchReportCandidate, o as ResearchReportRecommendation, r as ResearchReportDecision, s as researchReport, t as ResearchReport } from "./research-report-CL5_UqCX.js";
3
3
  import { a as ParetoPoint, c as SummaryTableRow, i as ParetoFigureSpec, l as gainHistogram, n as GainDistributionFigureSpec, o as SummaryTable, r as GainDistributionOptions, s as SummaryTableOptions, t as GainDistributionBin, u as summaryTable } from "./summary-report-figures-CJHygLgw.js";
4
4
  import { a as RubricPredictiveValidityReport, i as RubricPredictiveValidityInput, o as RubricRanking, r as RubricOutcomePair, s as rubricPredictiveValidity } from "./rubric-predictive-validity-DH94_0Q1.js";
5
- import { a as PairedEvalueStep, c as SequentialDecision, i as PairedEvalueSequence, l as evaluateInterimReleaseConfidence, n as InterimReleaseConfidenceInput, r as PairedEvalueOptions, t as InterimReleaseConfidence, u as pairedEvalueSequence } from "./sequential-B9iROM1S.js";
6
- import { _ as evaluateReleaseConfidence, a as bootstrapCi, c as ReleaseConfidenceAxis, d as ReleaseConfidenceIssue, f as ReleaseConfidenceMetrics, g as ReleaseTraceEvidence, h as ReleaseConfidenceThresholds, i as Verdict, l as ReleaseConfidenceAxisName, m as ReleaseConfidenceStatus, n as BootstrapResult, o as judgeReplayGate, p as ReleaseConfidenceScorecard, r as JudgeReplayGateArgs, t as BootstrapOptions, u as ReleaseConfidenceInput } from "./promotion-gate-BXgcORnM.js";
5
+ import { a as PairedEvalueStep, c as SequentialDecision, i as PairedEvalueSequence, l as evaluateInterimReleaseConfidence, n as InterimReleaseConfidenceInput, r as PairedEvalueOptions, t as InterimReleaseConfidence, u as pairedEvalueSequence } from "./sequential-CHplorpC.js";
6
+ import { _ as evaluateReleaseConfidence, a as bootstrapCi, c as ReleaseConfidenceAxis, d as ReleaseConfidenceIssue, f as ReleaseConfidenceMetrics, g as ReleaseTraceEvidence, h as ReleaseConfidenceThresholds, i as Verdict, l as ReleaseConfidenceAxisName, m as ReleaseConfidenceStatus, n as BootstrapResult, o as judgeReplayGate, p as ReleaseConfidenceScorecard, r as JudgeReplayGateArgs, t as BootstrapOptions, u as ReleaseConfidenceInput } from "./promotion-gate-B0VTBoXg.js";
7
7
  /**
8
8
  * Hard floor below which a paired comparison is treated as uninformative
9
9
  * regardless of `minPairs`. Mirrors the lower limit on Wilcoxon signed-rank
package/dist/reporting.js CHANGED
@@ -1,7 +1,7 @@
1
- import { a as RESEARCH_REPORT_HARD_PAIR_FLOOR, i as summaryTable, n as gainHistogram, t as researchReport } from "./summary-report-DzbnK81K.js";
1
+ import { a as RESEARCH_REPORT_HARD_PAIR_FLOOR, i as summaryTable, n as gainHistogram, t as researchReport } from "./summary-report-DyBkOC6V.js";
2
2
  import { r as pairedBootstrap } from "./paired-tests-CXcD_B80.js";
3
- import { a as wilcoxonSignedRank, b as benjaminiHochberg } from "./statistics-BPl13X3G.js";
4
- import { n as pairedEvalueSequence, t as evaluateInterimReleaseConfidence } from "./sequential-tZjGysXY.js";
3
+ import { a as wilcoxonSignedRank, b as benjaminiHochberg } from "./statistics-AKnVFnK-.js";
4
+ import { n as pairedEvalueSequence, t as evaluateInterimReleaseConfidence } from "./sequential-DR-pnYQ7.js";
5
5
  import { n as bootstrapCi, r as judgeReplayGate, t as evaluateReleaseConfidence } from "./release-confidence-Cndq1hwi.js";
6
6
  import { t as rubricPredictiveValidity } from "./rubric-predictive-validity-BXJ92Jp_.js";
7
7
  // src/reporting.ts
@@ -1,5 +1,5 @@
1
1
  import { a as RunRecord } from "./run-record-kuOr3BCF.js";
2
- import { r as PairedDecisionStatistic } from "./paired-promotion-decision-DuvRdnsW.js";
2
+ import { r as PairedDecisionStatistic } from "./paired-promotion-decision-DJlI4z_k.js";
3
3
  import { n as FailureClusterReport } from "./failure-cluster-OvKQ0BTq.js";
4
4
  import { a as ParetoPoint, i as ParetoFigureSpec, n as GainDistributionFigureSpec, o as SummaryTable } from "./summary-report-figures-CJHygLgw.js";
5
5
  type HeldOutGateRejectionCode = 'few_runs' | 'incomplete_coverage' | 'missing_split_scores' | 'missing_cost' | 'negative_delta' | 'indeterminate_delta' | 'overfit_gap' | 'cost_ceiling';
@@ -415,4 +415,4 @@ interface ResearchReport {
415
415
  */
416
416
  declare function researchReport(runs: RunRecord[], opts?: ResearchReportOptions): Promise<ResearchReport>;
417
417
  export { ResearchReportOptions as a, GateEvidence as c, HeldOutGateDecision as d, HeldOutGateRejectionCode as f, ResearchReportMethodology as i, HeldOutGate as l, ResearchReportCandidate as n, ResearchReportRecommendation as o, SplitCoverage as p, ResearchReportDecision as r, researchReport as s, ResearchReport as t, HeldOutGateConfig as u };
418
- //# sourceMappingURL=research-report-CIgUe1lv.d.ts.map
418
+ //# sourceMappingURL=research-report-CL5_UqCX.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"research-report-CIgUe1lv.d.ts","names":[],"sources":["../src/held-out-gate.ts","../src/research-report.ts"],"mappings":";;;;KAuIY;;;;;;;;UAiBK;;EAEf;;;EAGA;;;;EAIA;;EAEA;;EAEA;;;EAGA;;UAGe;;;;EAIf;;;;;EAKA;;;;;;;;;;;EAWA;;;;EAIA;;;EAGA;;EAEA;;EAEA;;;;EAIA;;;;;;;;;;;;;;;;;EAiBA;;;;;;;;;;;;;;EAcA;;;;KAKG,iBAAiB;UAEL;;EAEf;;EAEA;;EAEA;;;;;;;;EAQA,iBAAiB;;;;;EAKjB,gBAAgB;;;;;EAKhB;;;;;;;;;EASA,gBAAgB;;;EAGhB;;;EAGA;IAAY;IAAa;;;;EAGzB;;;;;;;EAOA;IAAW;IAAW;IAAW;IAAqB;;;;;;EAKtD;;;;;EAKA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;EAGA;;;;;;;EAOA;;UAGe;;EAEf;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA,eAAe;;;;;;;cAQJ;mBACM;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAEL,YAAA,QAAQ;;;;EAoCpB,SAAS,WAAW,aAAa,UAAU,cAAc;;;UAiCjD;;;;;;UAoEA;;;UAiCA;;;UAkEA;;;;;;;UAqDA;;KC5mBE;UAOK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;EASA;;;;;;;EAOA;IAAS;IAAa;;;;;;EAKtB;;;;;EAKA;;EAEA,gBAAgB,eAAe;;EAE/B,kBAAkB;;EAElB;;EAEA;;EAEA;;;;;;EAMA;;UAGe;EACf,UAAU;EACV;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAU;IAAa;;;;;;;EAMvB;EACA;;;;;;;EAOA;EACA;EACA,OAAO;EACP,UAAU;EACV;;UAGe;;;;;EAKf;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;EAMA;EACA;EACA;IAAQ;IAAa;;EACrB;EACA,gBAAgB;EAChB,YAAY;EACZ,SAAS;EACT;IACE,QAAQ;IACR,OAAO;;EAET,aAAa;EACb,kBAAkB;EAClB;EACA;;;;;;;;;;;;;;;;;;;;;iBAsBoB,eACpB,MAAM,aACN,OAAM,wBACL,QAAQ"}
1
+ {"version":3,"file":"research-report-CL5_UqCX.d.ts","names":[],"sources":["../src/held-out-gate.ts","../src/research-report.ts"],"mappings":";;;;KAuIY;;;;;;;;UAiBK;;EAEf;;;EAGA;;;;EAIA;;EAEA;;EAEA;;;EAGA;;UAGe;;;;EAIf;;;;;EAKA;;;;;;;;;;;EAWA;;;;EAIA;;;EAGA;;EAEA;;EAEA;;;;EAIA;;;;;;;;;;;;;;;;;EAiBA;;;;;;;;;;;;;;EAcA;;;;KAKG,iBAAiB;UAEL;;EAEf;;EAEA;;EAEA;;;;;;;;EAQA,iBAAiB;;;;;EAKjB,gBAAgB;;;;;EAKhB;;;;;;;;;EASA,gBAAgB;;;EAGhB;;;EAGA;IAAY;IAAa;;;;EAGzB;;;;;;;EAOA;IAAW;IAAW;IAAW;IAAqB;;;;;;EAKtD;;;;;EAKA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;EAGA;;;;;;;EAOA;;UAGe;;EAEf;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA,eAAe;;;;;;;cAQJ;mBACM;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAEL,YAAA,QAAQ;;;;EAoCpB,SAAS,WAAW,aAAa,UAAU,cAAc;;;UAiCjD;;;;;;UAoEA;;;UAiCA;;;UAkEA;;;;;;;UAqDA;;KC5mBE;UAOK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;EASA;;;;;;;EAOA;IAAS;IAAa;;;;;;EAKtB;;;;;EAKA;;EAEA,gBAAgB,eAAe;;EAE/B,kBAAkB;;EAElB;;EAEA;;EAEA;;;;;;EAMA;;UAGe;EACf,UAAU;EACV;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAU;IAAa;;;;;;;EAMvB;EACA;;;;;;;EAOA;EACA;EACA,OAAO;EACP,UAAU;EACV;;UAGe;;;;;EAKf;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;EAMA;EACA;EACA;IAAQ;IAAa;;EACrB;EACA,gBAAgB;EAChB,YAAY;EACZ,SAAS;EACT;IACE,QAAQ;IACR,OAAO;;EAET,aAAa;EACb,kBAAkB;EAClB;EACA;;;;;;;;;;;;;;;;;;;;;iBAsBoB,eACpB,MAAM,aACN,OAAM,wBACL,QAAQ"}
@@ -1,10 +1,10 @@
1
1
  import { n as AgentProfileCell, r as AgentProfileCellInput } from "./agent-profile-cell-BTsrta0H.js";
2
2
  import { a as RunRecord, c as RunSplitTag, d as RunTokenUsage, l as RunTaskFailure, n as RunCostProvenance, r as RunJudgeMetadata, t as JudgeScoresRecord } from "./run-record-kuOr3BCF.js";
3
- import { N as RawProviderSink, n as ChatClient } from "./chat-client-uQNXGuO4.js";
3
+ import { N as RawProviderSink, n as ChatClient } from "./chat-client-BlTooBDA.js";
4
4
  import { s as TraceStore } from "./store-CMs5wGXP.js";
5
5
  import { o as TraceEmitter, r as RunCompleteHook } from "./emitter-Cw8ijO3v.js";
6
- import { a as ResearchReportOptions, d as HeldOutGateDecision, t as ResearchReport } from "./research-report-CIgUe1lv.js";
7
- import { a as RunIntegrityReport, n as RunIntegrityExpectations } from "./integrity-BJGstiCh.js";
6
+ import { a as ResearchReportOptions, d as HeldOutGateDecision, t as ResearchReport } from "./research-report-CL5_UqCX.js";
7
+ import { a as RunIntegrityReport, n as RunIntegrityExpectations } from "./integrity-DotDLWtj.js";
8
8
  interface CampaignVariant<V> {
9
9
  id: string;
10
10
  payload: V;
@@ -286,4 +286,4 @@ interface Researcher {
286
286
  evaluateChange(plan: ExperimentPlan): Promise<ExperimentResult>;
287
287
  }
288
288
  export { SteeringChange as a, CampaignRunContext as c, CampaignVariant as d, EvalCampaignOptions as f, runEvalCampaign as h, Researcher as i, CampaignRunOutcome as l, FailedRun as m, ExperimentResult as n, CampaignFactoryParams as o, EvalCampaignResult as p, FailureMode as r, CampaignIntegrityPolicy as s, ExperimentPlan as t, CampaignScenario as u };
289
- //# sourceMappingURL=researcher-CY_byuZl.d.ts.map
289
+ //# sourceMappingURL=researcher-BOpZP_Ja.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"researcher-CY_byuZl.d.ts","names":[],"sources":["../src/eval-campaign.ts","../src/researcher.ts"],"mappings":";;;;;;;UAuEiB,gBAAgB;EAC/B;EACA,SAAS;;UAGM;EACf;;EAEA,OAAO;;UAGQ,mBAAmB;;EAElC;;EAEA;EACA,SAAS;EACT;EACA;EACA,cAAc;EACd;EACA,UAAU;;;;;;;EAOV,SAAS;EACT,OAAO;EACP,SAAS;;;;;EAKT,MAAM;;;UAIS;;;;;;EAMf,SAAS;EACT;;UAGQ;;EAER;;EAEA;;EAEA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gB,GACpC,MAAM,oBAAoB,KACzB,QAAQ;;UChUM;;;EAGf;;EAEA;EACA;;;IAGE;;IAEA;;;;UAKa;EACf;;;;EAIA;;;EAGA;;EAEA;;;UAIe;EACf;EACA;EACA,SAAS;;;EAGT;;EAEA;IAAU;IAAkB;;;;UAIb;EACf,MAAM;EACN,MAAM;EACN,cAAc;;;;;;;;;;;;;;;;;;;UAoBC;EACf,gBAAgB,MAAM,cAAc,QAAQ;EAC5C,cAAc,UAAU,gBAAgB,QAAQ;EAChD,YAAY,SAAS,kBAAkB,UAAU,iBAAiB,QAAQ;EAC1E,eAAe,MAAM,iBAAiB,QAAQ"}
package/dist/rl.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import { _ as Span } from "./schema-CkIvnmLU.js";
2
2
  import { a as RunRecord, c as RunSplitTag } from "./run-record-kuOr3BCF.js";
3
- import { E as PairedBootstrapResult } from "./index-CIqYaySd.js";
4
- import { Q as MintRolloutOptions, a as CampaignResult } from "./types-BO948H-U.js";
3
+ import { E as PairedBootstrapResult } from "./index-Bk1XEkP7.js";
4
+ import { Q as MintRolloutOptions, a as CampaignResult } from "./types-D5XtEH9Q.js";
5
5
  import { s as TraceStore } from "./store-CMs5wGXP.js";
6
6
  import { a as MintedRolloutLine, b as RolloutSplit, t as ChatMessage, w as ToolDef } from "./schema-BfSoJjD-.js";
7
- import { a as PairedPromotionDecision } from "./paired-promotion-decision-DuvRdnsW.js";
7
+ import { a as PairedPromotionDecision } from "./paired-promotion-decision-DJlI4z_k.js";
8
8
  import { a as detectRewardHacking, c as VerifiableRewardSource, i as RewardHackingSignal, l as extractVerifiableReward, n as RewardHackingFinding, o as VerifiableReward, r as RewardHackingReport, s as VerifiableRewardExtractionOptions, t as DetectRewardHackingInput, u as extractVerifiableRewardsFromRecords } from "./reward-hacking-4DsGTccp.js";
9
9
  import { i as InMemoryOutcomeStore, n as FileSystemOutcomeStore, o as OutcomeStore, r as FileSystemOutcomeStoreOptions, t as DeploymentOutcome } from "./outcome-store-CHtuvstd.js";
10
10
  import { a as RubricPredictiveValidityReport, t as OutcomeMetricSpec } from "./rubric-predictive-validity-DH94_0Q1.js";
11
- import { a as SystemOneReviewReport, t as PreparedSystemOneReview } from "./systemone-review-mlfxWdLz.js";
12
- import { n as TraceQuestionOutcome, r as TraceQuestionSpec } from "./trace-questions-DBtr4jWi.js";
13
- import { a as SteeringChange, f as EvalCampaignOptions, h as runEvalCampaign, i as Researcher, n as ExperimentResult, p as EvalCampaignResult, r as FailureMode, t as ExperimentPlan } from "./researcher-CY_byuZl.js";
11
+ import { a as SystemOneReviewReport, t as PreparedSystemOneReview } from "./systemone-review-DpAXWDkL.js";
12
+ import { n as TraceQuestionOutcome, r as TraceQuestionSpec } from "./trace-questions-ybyF0B6N.js";
13
+ import { a as SteeringChange, f as EvalCampaignOptions, h as runEvalCampaign, i as Researcher, n as ExperimentResult, p as EvalCampaignResult, r as FailureMode, t as ExperimentPlan } from "./researcher-BOpZP_Ja.js";
14
14
  import { n as TrainingExclusionReason, r as TrainingExportOptions } from "./training-admission-DGZCyntI.js";
15
- import { t as InterimReleaseConfidence } from "./sequential-B9iROM1S.js";
15
+ import { t as InterimReleaseConfidence } from "./sequential-CHplorpC.js";
16
16
  import { t as AdversarialMutation } from "./adversarial-DnQQFqTR.js";
17
17
  /**
18
18
  * Adaptive curriculum: active scenario selection by variance.
package/dist/rl.js CHANGED
@@ -2,16 +2,16 @@ import { s as ValidationError } from "./errors-DeEEV9Vx.js";
2
2
  import { a as hashCanonical, i as compareCodeUnits, n as LedgerCanonicalizationError, o as jsonDocument } from "./canonical-DKgL_Wby.js";
3
3
  import { s as runTaskScore } from "./run-record-CqUft6Yf.js";
4
4
  import { C as medianInPlace, r as pairedBootstrap } from "./paired-tests-CXcD_B80.js";
5
- import { a as wilcoxonSignedRank } from "./statistics-BPl13X3G.js";
6
- import { t as decidePairedPromotion } from "./paired-promotion-decision-xYe881cD.js";
5
+ import { a as wilcoxonSignedRank } from "./statistics-AKnVFnK-.js";
6
+ import { t as decidePairedPromotion } from "./paired-promotion-decision-BtfVwEAk.js";
7
7
  import { n as campaignCellToRunRecord } from "./run-record-CuO8ErrI.js";
8
8
  import { n as extractVerifiableReward, r as extractVerifiableRewardsFromRecords, t as detectRewardHacking } from "./reward-hacking-DMTm1OBd.js";
9
9
  import { n as runTaskId } from "./emitter-xN9wGTVw.js";
10
- import { t as runEvalCampaign } from "./eval-campaign-DswSn7Gm.js";
10
+ import { t as runEvalCampaign } from "./eval-campaign-BciGnrGy.js";
11
11
  import { s as assertRewardGate } from "./schema-Bh9CfSZT.js";
12
12
  import { a as toSftRows, s as trainingAdmission, t as isTrainingLineEligible } from "./exporters-CKFtnWmX.js";
13
13
  import { t as mintRolloutRows } from "./mint-B4n1pRRd.js";
14
- import { t as evaluateInterimReleaseConfidence } from "./sequential-tZjGysXY.js";
14
+ import { t as evaluateInterimReleaseConfidence } from "./sequential-DR-pnYQ7.js";
15
15
  import { c as validateOutcomeMetricSpecifications, t as assertUniqueObservationIds } from "./outcome-observations-DEh8_V_P.js";
16
16
  import { n as prepareSystemOneReview } from "./systemone-review-ir3Cbejl.js";
17
17
  import { t as rubricPredictiveValidity } from "./rubric-predictive-validity-BXJ92Jp_.js";