@tangle-network/agent-eval 0.216.0 → 0.216.1

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 (384) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/adapters/http.d.ts +3 -3
  3. package/dist/{agent-profile-CIA2Atnt.d.ts → agent-profile-VFcQncbW.d.ts} +5 -5
  4. package/dist/{agent-profile-CIA2Atnt.d.ts.map → agent-profile-VFcQncbW.d.ts.map} +1 -1
  5. package/dist/{agent-profile-cell-BYc0bxsL.js → agent-profile-cell-BK8mlqlq.js} +3 -3
  6. package/dist/{agent-profile-cell-BYc0bxsL.js.map → agent-profile-cell-BK8mlqlq.js.map} +1 -1
  7. package/dist/{agreement-irr-DsTURxdr.js → agreement-irr-BEWLIF3_.js} +3 -3
  8. package/dist/{agreement-irr-DsTURxdr.js.map → agreement-irr-BEWLIF3_.js.map} +1 -1
  9. package/dist/analyst/index.d.ts +14 -14
  10. package/dist/analyst/index.d.ts.map +1 -1
  11. package/dist/analyst/index.js +15 -15
  12. package/dist/{analyze-runs-3xpby3p2.js → analyze-runs-C84irm4i.js} +608 -604
  13. package/dist/analyze-runs-C84irm4i.js.map +1 -0
  14. package/dist/{analyze-runs-CSDAh8A7.d.ts → analyze-runs-D68fd-su.d.ts} +17 -15
  15. package/dist/analyze-runs-D68fd-su.d.ts.map +1 -0
  16. package/dist/{baseline-Dm8966du.js → baseline-Udi_PLuT.js} +5 -5
  17. package/dist/{baseline-Dm8966du.js.map → baseline-Udi_PLuT.js.map} +1 -1
  18. package/dist/{benchmark-BywPeAUo.js → benchmark-CXmVVHH2.js} +2 -2
  19. package/dist/{benchmark-BywPeAUo.js.map → benchmark-CXmVVHH2.js.map} +1 -1
  20. package/dist/{benchmark-command-CByl9dxG.js → benchmark-command-By0vh8q7.js} +62 -45
  21. package/dist/benchmark-command-By0vh8q7.js.map +1 -0
  22. package/dist/benchmarks/index.d.ts +5 -5
  23. package/dist/benchmarks/index.js +3 -3
  24. package/dist/builder-eval/index.js +2 -2
  25. package/dist/campaign/index.d.ts +7 -7
  26. package/dist/campaign/index.js +13 -13
  27. package/dist/{campaign-BQ-Jujuj.js → campaign-BudZ70zo.js} +245 -247
  28. package/dist/campaign-BudZ70zo.js.map +1 -0
  29. package/dist/{campaign-evidence-OcUciD-N.js → campaign-evidence-Clrn4hBV.js} +8 -8
  30. package/dist/campaign-evidence-Clrn4hBV.js.map +1 -0
  31. package/dist/{canonical-BsZVgBhW.js → canonical-B2RqLofv.js} +2 -2
  32. package/dist/{canonical-BsZVgBhW.js.map → canonical-B2RqLofv.js.map} +1 -1
  33. package/dist/{chat-client-DthPOYGd.js → chat-client-l-MVDlDk.js} +2 -2
  34. package/dist/{chat-client-DthPOYGd.js.map → chat-client-l-MVDlDk.js.map} +1 -1
  35. package/dist/{chat-json-call-BrKsyspg.js → chat-json-call-puMArmtW.js} +2 -2
  36. package/dist/{chat-json-call-BrKsyspg.js.map → chat-json-call-puMArmtW.js.map} +1 -1
  37. package/dist/{claim-BXcZw-jo.js → claim-q4HQhK1G.js} +4 -4
  38. package/dist/claim-q4HQhK1G.js.map +1 -0
  39. package/dist/cli.js +9 -9
  40. package/dist/cli.js.map +1 -1
  41. package/dist/{cluster-bootstrap-B3JywQQn.js → cluster-bootstrap-qcUWYFl-.js} +3 -3
  42. package/dist/{cluster-bootstrap-B3JywQQn.js.map → cluster-bootstrap-qcUWYFl-.js.map} +1 -1
  43. package/dist/contract/index.d.ts +11 -11
  44. package/dist/contract/index.js +1022 -1078
  45. package/dist/contract/index.js.map +1 -1
  46. package/dist/{cost-ledger-D2FnJPBF.js → cost-ledger-BP8V4kUQ.js} +835 -816
  47. package/dist/cost-ledger-BP8V4kUQ.js.map +1 -0
  48. package/dist/{cost-ledger-CO7UyEcQ.d.ts → cost-ledger-Jk62OBfF.d.ts} +12 -47
  49. package/dist/cost-ledger-Jk62OBfF.d.ts.map +1 -0
  50. package/dist/{counterfactual-DtMWvn7D.js → counterfactual-Dn3veueY.js} +2 -2
  51. package/dist/{counterfactual-DtMWvn7D.js.map → counterfactual-Dn3veueY.js.map} +1 -1
  52. package/dist/{default-registry-Cn1LQ2Ve.js → default-registry-COhk9g36.js} +5 -5
  53. package/dist/{default-registry-Cn1LQ2Ve.js.map → default-registry-COhk9g36.js.map} +1 -1
  54. package/dist/{default-registry-BrWh62zf.d.ts → default-registry-DzHiGruW.d.ts} +6 -6
  55. package/dist/{default-registry-BrWh62zf.d.ts.map → default-registry-DzHiGruW.d.ts.map} +1 -1
  56. package/dist/{define-agent-eval-Ch3MWX6k.js → define-agent-eval-CNTPzIkp.js} +10 -10
  57. package/dist/define-agent-eval-CNTPzIkp.js.map +1 -0
  58. package/dist/{define-agent-eval-CEWkX5wZ.d.ts → define-agent-eval-WSck0CZJ.d.ts} +8 -8
  59. package/dist/{define-agent-eval-CEWkX5wZ.d.ts.map → define-agent-eval-WSck0CZJ.d.ts.map} +1 -1
  60. package/dist/{descriptive-CnU8Yq29.js → descriptive-DboxPZrG.js} +2 -2
  61. package/dist/{descriptive-CnU8Yq29.js.map → descriptive-DboxPZrG.js.map} +1 -1
  62. package/dist/diagnosis/index.d.ts +3 -3
  63. package/dist/diagnosis/index.js +4 -4
  64. package/dist/{dspy-rlm-engine-D-KX_e64.js → dspy-rlm-engine-LRCu61m5.js} +3 -3
  65. package/dist/{dspy-rlm-engine-D-KX_e64.js.map → dspy-rlm-engine-LRCu61m5.js.map} +1 -1
  66. package/dist/{effect-sizes-DiH8MGOH.js → effect-sizes-BhzEpXMc.js} +2 -2
  67. package/dist/{effect-sizes-DiH8MGOH.js.map → effect-sizes-BhzEpXMc.js.map} +1 -1
  68. package/dist/{engine-C_zNWfM8.d.ts → engine-3A_4jOlI.d.ts} +5 -5
  69. package/dist/{engine-C_zNWfM8.d.ts.map → engine-3A_4jOlI.d.ts.map} +1 -1
  70. package/dist/{equal-terms-Blx9Zk5I.js → equal-terms-BtdXayCJ.js} +2 -2
  71. package/dist/{equal-terms-Blx9Zk5I.js.map → equal-terms-BtdXayCJ.js.map} +1 -1
  72. package/dist/{errors-Dngq5h35.js → errors-DVZiqS7K.js} +6 -2
  73. package/dist/{errors-Dngq5h35.js.map → errors-DVZiqS7K.js.map} +1 -1
  74. package/dist/{eval-campaign-4byTtqrf.js → eval-campaign-90jeaCAI.js} +6 -6
  75. package/dist/{eval-campaign-4byTtqrf.js.map → eval-campaign-90jeaCAI.js.map} +1 -1
  76. package/dist/{evaluation-Cn2dRZIz.d.ts → evaluation-6Yoi74gM.d.ts} +4 -4
  77. package/dist/{evaluation-Cn2dRZIz.d.ts.map → evaluation-6Yoi74gM.d.ts.map} +1 -1
  78. package/dist/evaluation.d.ts +1 -1
  79. package/dist/evaluation.js +1 -1
  80. package/dist/{exact-types-CD0lf5Qd.d.ts → exact-types-ClugMJfI.d.ts} +2 -2
  81. package/dist/{exact-types-CD0lf5Qd.d.ts.map → exact-types-ClugMJfI.d.ts.map} +1 -1
  82. package/dist/experiment/index.d.ts +404 -3
  83. package/dist/experiment/index.d.ts.map +1 -1
  84. package/dist/experiment/index.js +313 -19
  85. package/dist/experiment/index.js.map +1 -1
  86. package/dist/{external-optimizer-process-nnsY5D_4.js → external-optimizer-process-BjMGUuds.js} +3 -3
  87. package/dist/{external-optimizer-process-nnsY5D_4.js.map → external-optimizer-process-BjMGUuds.js.map} +1 -1
  88. package/dist/{external-optimizer-subprocess-DcerlZSG.js → external-optimizer-subprocess-BqW0hHcI.js} +548 -548
  89. package/dist/external-optimizer-subprocess-BqW0hHcI.js.map +1 -0
  90. package/dist/{feedback-trajectory-DkaDj0dj.d.ts → feedback-trajectory-C4EG0nNH.d.ts} +5 -8
  91. package/dist/feedback-trajectory-C4EG0nNH.d.ts.map +1 -0
  92. package/dist/fuzz.d.ts +1 -1
  93. package/dist/fuzz.js +3 -3
  94. package/dist/hosted/index.js +1 -1
  95. package/dist/{index-CPJJr98o.d.ts → index-BFRO6chs.d.ts} +3 -2
  96. package/dist/index-BFRO6chs.d.ts.map +1 -0
  97. package/dist/{index-Ch9VxCpK.d.ts → index-BO41eGj5.d.ts} +2 -2
  98. package/dist/{index-Ch9VxCpK.d.ts.map → index-BO41eGj5.d.ts.map} +1 -1
  99. package/dist/{index-NvGBiO8H.d.ts → index-CyszSg4O.d.ts} +165 -162
  100. package/dist/index-CyszSg4O.d.ts.map +1 -0
  101. package/dist/{index-DlH0Y9gI.d.ts → index-DPcngtwt.d.ts} +30 -17
  102. package/dist/index-DPcngtwt.d.ts.map +1 -0
  103. package/dist/{index-oQ4aHziK.d.ts → index-DV-jSzxF.d.ts} +8 -8
  104. package/dist/{index-oQ4aHziK.d.ts.map → index-DV-jSzxF.d.ts.map} +1 -1
  105. package/dist/index.d.ts +1969 -1871
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +161 -201
  108. package/dist/index.js.map +1 -1
  109. package/dist/{integrity-BvnVARVl.js → integrity-BXOsAb3i.js} +2 -2
  110. package/dist/{integrity-BvnVARVl.js.map → integrity-BXOsAb3i.js.map} +1 -1
  111. package/dist/{integrity-CCAxGVK6.d.ts → integrity-DAMEDFaC.d.ts} +2 -2
  112. package/dist/{integrity-CCAxGVK6.d.ts.map → integrity-DAMEDFaC.d.ts.map} +1 -1
  113. package/dist/{integrity-BV1ZDf42.js → integrity-dLiDe2kD.js} +2 -5
  114. package/dist/integrity-dLiDe2kD.js.map +1 -0
  115. package/dist/{internal-CRHwS9iz.js → internal-Epl-YBZW.js} +3 -3
  116. package/dist/{internal-CRHwS9iz.js.map → internal-Epl-YBZW.js.map} +1 -1
  117. package/dist/interval-CELpye1n.js +219 -0
  118. package/dist/interval-CELpye1n.js.map +1 -0
  119. package/dist/interval-ohuOJurX.d.ts +47 -0
  120. package/dist/interval-ohuOJurX.d.ts.map +1 -0
  121. package/dist/{journal-DvKCvjty.js → journal-DfRz9kps.js} +2 -2
  122. package/dist/{journal-DvKCvjty.js.map → journal-DfRz9kps.js.map} +1 -1
  123. package/dist/{judge-calibration-N44V04Se.js → judge-calibration-BpCy5XQl.js} +3 -3
  124. package/dist/{judge-calibration-N44V04Se.js.map → judge-calibration-BpCy5XQl.js.map} +1 -1
  125. package/dist/{judge-gate-DNcUrRFA.d.ts → judge-gate-CE7CQAgt.d.ts} +3 -3
  126. package/dist/{judge-gate-DNcUrRFA.d.ts.map → judge-gate-CE7CQAgt.d.ts.map} +1 -1
  127. package/dist/{judge-gate-B1qYnkpi.js → judge-gate-iY9s4L44.js} +3 -3
  128. package/dist/judge-gate-iY9s4L44.js.map +1 -0
  129. package/dist/{kind-factory-CbZ-6tvu.js → kind-factory-BobI5Jy3.js} +4 -4
  130. package/dist/{kind-factory-CbZ-6tvu.js.map → kind-factory-BobI5Jy3.js.map} +1 -1
  131. package/dist/ledger-core/index.js +3 -3
  132. package/dist/{ledger-core-B2hahzrt.js → ledger-core-Gq7yp8lP.js} +4 -4
  133. package/dist/{ledger-core-B2hahzrt.js.map → ledger-core-Gq7yp8lP.js.map} +1 -1
  134. package/dist/{llm-client-DQveoxSM.js → llm-client-CyBAoYiX.js} +192 -219
  135. package/dist/llm-client-CyBAoYiX.js.map +1 -0
  136. package/dist/{llm-judge-PXV7Xljl.js → llm-judge-CG12SQJq.js} +499 -921
  137. package/dist/llm-judge-CG12SQJq.js.map +1 -0
  138. package/dist/matrix/index.d.ts +2 -2
  139. package/dist/matrix/index.js +1 -1
  140. package/dist/{matrix-CHMiebFx.d.ts → matrix-DSrSxjjy.d.ts} +4 -4
  141. package/dist/{matrix-CHMiebFx.d.ts.map → matrix-DSrSxjjy.d.ts.map} +1 -1
  142. package/dist/{matrix-_BV9-Lk5.js → matrix-Dm0BQW7U.js} +7 -11
  143. package/dist/matrix-Dm0BQW7U.js.map +1 -0
  144. package/dist/{paired-tests-jbwPdSz5.js → mean-DHoMiudD.js} +11 -5
  145. package/dist/mean-DHoMiudD.js.map +1 -0
  146. package/dist/meta-eval/index.d.ts +3 -3
  147. package/dist/meta-eval/index.js +9 -9
  148. package/dist/meta-eval/index.js.map +1 -1
  149. package/dist/mint-DNU8QPG4.d.ts +81 -0
  150. package/dist/mint-DNU8QPG4.d.ts.map +1 -0
  151. package/dist/{mint-Csor1BLJ.js → mint-QaD5cA0u.js} +3 -3
  152. package/dist/{mint-Csor1BLJ.js.map → mint-QaD5cA0u.js.map} +1 -1
  153. package/dist/{multiplicity-D9cjmStq.js → multiplicity-DQUFcbW4.js} +2 -2
  154. package/dist/{multiplicity-D9cjmStq.js.map → multiplicity-DQUFcbW4.js.map} +1 -1
  155. package/dist/multishot/golden/index.d.ts +1 -1
  156. package/dist/multishot/golden/index.d.ts.map +1 -1
  157. package/dist/multishot/golden/index.js +3 -6
  158. package/dist/multishot/golden/index.js.map +1 -1
  159. package/dist/multishot/index.d.ts +2 -2
  160. package/dist/multishot/index.js +1 -1
  161. package/dist/nonnegative-number-DvdMxg_f.js +9 -0
  162. package/dist/nonnegative-number-DvdMxg_f.js.map +1 -0
  163. package/dist/openapi.json +1 -1
  164. package/dist/{otel-spans-C8YIJWy1.js → otel-spans-B9tUXRHF.js} +3 -3
  165. package/dist/{otel-spans-C8YIJWy1.js.map → otel-spans-B9tUXRHF.js.map} +1 -1
  166. package/dist/{paired-arms-DzKn0TfY.js → paired-arms-CwMGJsrS.js} +5 -5
  167. package/dist/{paired-arms-DzKn0TfY.js.map → paired-arms-CwMGJsrS.js.map} +1 -1
  168. package/dist/{paired-binary-Q36bhn2R.js → paired-binary-CvpFHfKZ.js} +2 -2
  169. package/dist/{paired-binary-Q36bhn2R.js.map → paired-binary-CvpFHfKZ.js.map} +1 -1
  170. package/dist/{paired-promotion-decision-BN6IQTiu.js → paired-promotion-decision-DsAPYGCm.js} +3 -3
  171. package/dist/{paired-promotion-decision-BN6IQTiu.js.map → paired-promotion-decision-DsAPYGCm.js.map} +1 -1
  172. package/dist/{search-kernel-BztlERLv.js → pareto-Cm6ndrWN.js} +883 -861
  173. package/dist/pareto-Cm6ndrWN.js.map +1 -0
  174. package/dist/pipelines/index.d.ts +2 -2
  175. package/dist/pipelines/index.js +3 -3
  176. package/dist/{power-and-mde-fK5Qocwo.js → power-and-mde-Hj2ubb4B.js} +2 -2
  177. package/dist/{power-and-mde-fK5Qocwo.js.map → power-and-mde-Hj2ubb4B.js.map} +1 -1
  178. package/dist/predicate-FdKmElA_.js +38 -0
  179. package/dist/predicate-FdKmElA_.js.map +1 -0
  180. package/dist/{prime-protocol-DcAK9pC8.js → prime-protocol-CHKgA3a6.js} +2 -2
  181. package/dist/{prime-protocol-DcAK9pC8.js.map → prime-protocol-CHKgA3a6.js.map} +1 -1
  182. package/dist/{prime-protocol-CEE4BR9N.d.ts → prime-protocol-HiB9HX7E.d.ts} +3 -3
  183. package/dist/{prime-protocol-CEE4BR9N.d.ts.map → prime-protocol-HiB9HX7E.d.ts.map} +1 -1
  184. package/dist/{produced-state-ZCtDBxAE.js → produced-state-BsDmnwxc.js} +8 -8
  185. package/dist/{produced-state-ZCtDBxAE.js.map → produced-state-BsDmnwxc.js.map} +1 -1
  186. package/dist/profile-cell.js +1 -1
  187. package/dist/{release-confidence-BK2QCB5M.d.ts → promotion-gate-BawrdPYr.d.ts} +102 -102
  188. package/dist/promotion-gate-BawrdPYr.d.ts.map +1 -0
  189. package/dist/{promotion-policy-CWW35UWq.js → promotion-policy-KO57gbyV.js} +4 -4
  190. package/dist/{promotion-policy-CWW35UWq.js.map → promotion-policy-KO57gbyV.js.map} +1 -1
  191. package/dist/{proposal-findings-BZiMTzAF.js → proposal-findings-CY1xKn_a.js} +2 -2
  192. package/dist/{proposal-findings-BZiMTzAF.js.map → proposal-findings-CY1xKn_a.js.map} +1 -1
  193. package/dist/{query-B1D1qp2Z.js → query-BUCZCK7F.js} +3 -3
  194. package/dist/{query-B1D1qp2Z.js.map → query-BUCZCK7F.js.map} +1 -1
  195. package/dist/{random-Dn5fPWkt.js → random-ByUSnV9w.js} +2 -2
  196. package/dist/{random-Dn5fPWkt.js.map → random-ByUSnV9w.js.map} +1 -1
  197. package/dist/{raw-provider-sink-rB2DYxr6.js → raw-provider-sink-DoHz4JNG.js} +2 -2
  198. package/dist/{raw-provider-sink-rB2DYxr6.js.map → raw-provider-sink-DoHz4JNG.js.map} +1 -1
  199. package/dist/{redact-Dk1ZdJEm.js → redact-B5xXKqQ3.js} +97 -98
  200. package/dist/redact-B5xXKqQ3.js.map +1 -0
  201. package/dist/{redact-Cveoq6fJ.d.ts → redact-mtCCcT8z.d.ts} +4 -20
  202. package/dist/redact-mtCCcT8z.d.ts.map +1 -0
  203. package/dist/{registry-JYfPxcVz.d.ts → registry-D7_hm2fK.d.ts} +5 -5
  204. package/dist/{registry-JYfPxcVz.d.ts.map → registry-D7_hm2fK.d.ts.map} +1 -1
  205. package/dist/{release-confidence-Dbe9AS_X.js → release-confidence-CpuP65S5.js} +5 -5
  206. package/dist/{release-confidence-Dbe9AS_X.js.map → release-confidence-CpuP65S5.js.map} +1 -1
  207. package/dist/{report-command-y8H6RSX8.js → report-command-SC9nqb4M.js} +106 -171
  208. package/dist/report-command-SC9nqb4M.js.map +1 -0
  209. package/dist/reporting-html-Kvlc8oMt.js +100 -0
  210. package/dist/reporting-html-Kvlc8oMt.js.map +1 -0
  211. package/dist/reporting.d.ts +3 -3
  212. package/dist/reporting.js +6 -6
  213. package/dist/{researcher-f6mZhh58.d.ts → researcher-CEcfku-T.d.ts} +5 -5
  214. package/dist/{researcher-f6mZhh58.d.ts.map → researcher-CEcfku-T.d.ts.map} +1 -1
  215. package/dist/reward-CpCmAM8L.d.ts +78 -0
  216. package/dist/reward-CpCmAM8L.d.ts.map +1 -0
  217. package/dist/{reward-hacking-BFcQgkux.js → reward-hacking-E0d-WVcP.js} +2 -2
  218. package/dist/{reward-hacking-BFcQgkux.js.map → reward-hacking-E0d-WVcP.js.map} +1 -1
  219. package/dist/{reward-hacking-DHA7c1l8.d.ts → reward-hacking-RVdZ6Kkt.d.ts} +2 -2
  220. package/dist/{reward-hacking-DHA7c1l8.d.ts.map → reward-hacking-RVdZ6Kkt.d.ts.map} +1 -1
  221. package/dist/rl.d.ts +8 -8
  222. package/dist/rl.js +14 -14
  223. package/dist/rollout/index.d.ts +3 -2
  224. package/dist/rollout/index.js +2 -2
  225. package/dist/{rollout-D9bKKBnZ.js → rollout-DZV1t2Wg.js} +2 -2
  226. package/dist/{rollout-D9bKKBnZ.js.map → rollout-DZV1t2Wg.js.map} +1 -1
  227. package/dist/round-decimal-COrKglMh.js +10 -0
  228. package/dist/round-decimal-COrKglMh.js.map +1 -0
  229. package/dist/{rubric-predictive-validity-2SgHxoa5.d.ts → rubric-predictive-validity-C03EC7ZE.d.ts} +2 -2
  230. package/dist/{rubric-predictive-validity-2SgHxoa5.d.ts.map → rubric-predictive-validity-C03EC7ZE.d.ts.map} +1 -1
  231. package/dist/{rubric-predictive-validity-BsgkBfT0.js → rubric-predictive-validity-DaFW70y9.js} +3 -3
  232. package/dist/{rubric-predictive-validity-BsgkBfT0.js.map → rubric-predictive-validity-DaFW70y9.js.map} +1 -1
  233. package/dist/{run-record-DlTZ_lqe.js → run-record-Boc5IUTp.js} +4 -4
  234. package/dist/{run-record-DlTZ_lqe.js.map → run-record-Boc5IUTp.js.map} +1 -1
  235. package/dist/{run-record-D1Hw-Jml.d.ts → run-record-C1E24G2A.d.ts} +2 -2
  236. package/dist/{run-record-D1Hw-Jml.d.ts.map → run-record-C1E24G2A.d.ts.map} +1 -1
  237. package/dist/{run-record-ES07wfz9.js → run-record-C5e7FjhJ.js} +3 -5
  238. package/dist/run-record-C5e7FjhJ.js.map +1 -0
  239. package/dist/search/index.d.ts +46 -32
  240. package/dist/search/index.d.ts.map +1 -1
  241. package/dist/search/index.js +3 -3
  242. package/dist/{search-kernel-CpcKH5Ih.d.ts → search-kernel-DyNEa6IU.d.ts} +14 -10
  243. package/dist/search-kernel-DyNEa6IU.d.ts.map +1 -0
  244. package/dist/{search-ledger-d7V8o9Lk.js → search-ledger-CVUGLDZp.js} +189 -199
  245. package/dist/search-ledger-CVUGLDZp.js.map +1 -0
  246. package/dist/{search-ledger-file-BqOo-bVo.js → search-ledger-file-DDQUgvCg.js} +4 -4
  247. package/dist/{search-ledger-file-BqOo-bVo.js.map → search-ledger-file-DDQUgvCg.js.map} +1 -1
  248. package/dist/search-ledger-types-p2xKfiDJ.d.ts.map +1 -1
  249. package/dist/{search-shipper-er4pK5_Y.js → search-shipper-BOSD46qv.js} +3 -3
  250. package/dist/{search-shipper-er4pK5_Y.js.map → search-shipper-BOSD46qv.js.map} +1 -1
  251. package/dist/{search-summary-CBvz3u_S.js → search-summary-BQCSWf1g.js} +5 -5
  252. package/dist/{search-summary-CBvz3u_S.js.map → search-summary-BQCSWf1g.js.map} +1 -1
  253. package/dist/{semantic-concept-judge-zQBG9hHU.js → semantic-concept-judge-BQF8te0T.js} +12 -14
  254. package/dist/semantic-concept-judge-BQF8te0T.js.map +1 -0
  255. package/dist/{sequential-D-1PPCmM.js → sequential-Bf_pbE50.js} +5 -5
  256. package/dist/{sequential-D-1PPCmM.js.map → sequential-Bf_pbE50.js.map} +1 -1
  257. package/dist/{sequential-eprocess-D1jKoihe.js → sequential-eprocess-DM_qENCl.js} +2 -2
  258. package/dist/{sequential-eprocess-D1jKoihe.js.map → sequential-eprocess-DM_qENCl.js.map} +1 -1
  259. package/dist/{server-DbcC7xMl.js → server-e9oWO_bN.js} +4 -4
  260. package/dist/{server-DbcC7xMl.js.map → server-e9oWO_bN.js.map} +1 -1
  261. package/dist/{single-run-lock-fVu3MZWH.js → single-run-lock-CV9Eyd_q.js} +2 -2
  262. package/dist/{single-run-lock-fVu3MZWH.js.map → single-run-lock-CV9Eyd_q.js.map} +1 -1
  263. package/dist/{skillopt-optimization-method-CCtzralq.js → skillopt-optimization-method-BiwA8nfX.js} +427 -12
  264. package/dist/skillopt-optimization-method-BiwA8nfX.js.map +1 -0
  265. package/dist/{spans-D9_ehFuk.d.ts → spans-BHAUXMGN.d.ts} +2 -2
  266. package/dist/{spans-D9_ehFuk.d.ts.map → spans-BHAUXMGN.d.ts.map} +1 -1
  267. package/dist/{statistical-heldout-1Gbmex7v.js → statistical-heldout-42NlCNDe.js} +3 -3
  268. package/dist/{statistical-heldout-1Gbmex7v.js.map → statistical-heldout-42NlCNDe.js.map} +1 -1
  269. package/dist/{statistical-heldout-BeR4bOdg.d.ts → statistical-heldout-CYpGaoDH.d.ts} +3 -3
  270. package/dist/{statistical-heldout-BeR4bOdg.d.ts.map → statistical-heldout-CYpGaoDH.d.ts.map} +1 -1
  271. package/dist/{store-otlp-DtB4Slsr.js → store-otlp-DJ9dtA5x.js} +135 -132
  272. package/dist/store-otlp-DJ9dtA5x.js.map +1 -0
  273. package/dist/{store-tool-spans-fZIigrpP.js → store-tool-spans-CIX5arAG.js} +7 -7
  274. package/dist/{store-tool-spans-fZIigrpP.js.map → store-tool-spans-CIX5arAG.js.map} +1 -1
  275. package/dist/{store-tool-spans-DR1SrCLK.d.ts → store-tool-spans-DdCSPa7C.d.ts} +162 -161
  276. package/dist/store-tool-spans-DdCSPa7C.d.ts.map +1 -0
  277. package/dist/storyboard/index.d.ts.map +1 -1
  278. package/dist/storyboard/index.js +20 -3
  279. package/dist/storyboard/index.js.map +1 -1
  280. package/dist/{student-t-BQeKJx2N.js → student-t-DVPW7CdL.js} +2 -2
  281. package/dist/{student-t-BQeKJx2N.js.map → student-t-DVPW7CdL.js.map} +1 -1
  282. package/dist/{summary-report-DtdRucM0.js → summary-report-V_JACR4Y.js} +526 -614
  283. package/dist/summary-report-V_JACR4Y.js.map +1 -0
  284. package/dist/{summary-report-C-CtItCN.d.ts → summary-report-bdFDXq0b.d.ts} +10 -5
  285. package/dist/summary-report-bdFDXq0b.d.ts.map +1 -0
  286. package/dist/supervisor-run/index.d.ts +153 -149
  287. package/dist/supervisor-run/index.d.ts.map +1 -1
  288. package/dist/supervisor-run/index.js +65 -3
  289. package/dist/supervisor-run/index.js.map +1 -1
  290. package/dist/{systemone-CpTLAlqb.d.ts → systemone-BomhHr2c.d.ts} +6 -6
  291. package/dist/{systemone-CpTLAlqb.d.ts.map → systemone-BomhHr2c.d.ts.map} +1 -1
  292. package/dist/systemone-protocol.js +1 -1
  293. package/dist/{systemone-review-B_yo1xsd.d.ts → systemone-review-CUVcQJu6.d.ts} +2 -2
  294. package/dist/{systemone-review-B_yo1xsd.d.ts.map → systemone-review-CUVcQJu6.d.ts.map} +1 -1
  295. package/dist/{systemone-review-BZWfrtq1.js → systemone-review-D7sXwsqq.js} +2 -2
  296. package/dist/{systemone-review-BZWfrtq1.js.map → systemone-review-D7sXwsqq.js.map} +1 -1
  297. package/dist/systemone.d.ts +3 -3
  298. package/dist/systemone.js +4 -4
  299. package/dist/{task-failure-attributes-DngaLdE4.js → task-failure-attributes-hEmASjix.js} +2 -2
  300. package/dist/{task-failure-attributes-DngaLdE4.js.map → task-failure-attributes-hEmASjix.js.map} +1 -1
  301. package/dist/{terminal-record-BHocwFw1.js → terminal-record-DZyQZ3pz.js} +14 -10
  302. package/dist/terminal-record-DZyQZ3pz.js.map +1 -0
  303. package/dist/{tool-groups-mcxOXVlb.d.ts → tool-groups-C3NEcdCM.d.ts} +3 -3
  304. package/dist/tool-groups-C3NEcdCM.d.ts.map +1 -0
  305. package/dist/{tool-waste-Wi4g6Ekb.d.ts → tool-waste-BKgvd-TP.d.ts} +30 -30
  306. package/dist/tool-waste-BKgvd-TP.d.ts.map +1 -0
  307. package/dist/{tool-waste-D52PqU9Q.js → tool-waste-BlesqTqW.js} +4 -4
  308. package/dist/{tool-waste-D52PqU9Q.js.map → tool-waste-BlesqTqW.js.map} +1 -1
  309. package/dist/{trace-questions-DG7nqLQ7.d.ts → trace-questions-CM2CAocU.d.ts} +4 -4
  310. package/dist/{trace-questions-DG7nqLQ7.d.ts.map → trace-questions-CM2CAocU.d.ts.map} +1 -1
  311. package/dist/trace-repair/index.d.ts +3 -3
  312. package/dist/trace-repair/index.d.ts.map +1 -1
  313. package/dist/trace-repair/index.js +7 -13
  314. package/dist/trace-repair/index.js.map +1 -1
  315. package/dist/traces.d.ts +76 -58
  316. package/dist/traces.d.ts.map +1 -1
  317. package/dist/traces.js +9 -9
  318. package/dist/trajectory-replay/index.js +3 -3
  319. package/dist/{tree-rXLW3M_4.js → tree-C1XYeXvy.js} +2277 -2339
  320. package/dist/tree-C1XYeXvy.js.map +1 -0
  321. package/dist/{types-DBZ7keha.d.ts → types-C02qtnG8.d.ts} +4 -46
  322. package/dist/types-C02qtnG8.d.ts.map +1 -0
  323. package/dist/{types-oKRhQAde.d.ts → types-C1tnkEgM.d.ts} +4 -4
  324. package/dist/{types-oKRhQAde.d.ts.map → types-C1tnkEgM.d.ts.map} +1 -1
  325. package/dist/{types-CfZMIzB_.d.ts → types-Cbe2fWBa.d.ts} +3 -3
  326. package/dist/{types-CfZMIzB_.d.ts.map → types-Cbe2fWBa.d.ts.map} +1 -1
  327. package/dist/{types-B4C5nFw6.d.ts → types-Cq8mSbq8.d.ts} +78 -72
  328. package/dist/types-Cq8mSbq8.d.ts.map +1 -0
  329. package/dist/{verdict-DhPoXApk.js → verdict-Dl0tiT1X.js} +2 -2
  330. package/dist/{verdict-DhPoXApk.js.map → verdict-Dl0tiT1X.js.map} +1 -1
  331. package/dist/{verdict-cache-BQEsVy9n.js → verdict-cache-Bm8EKL2s.js} +2 -2
  332. package/dist/{verdict-cache-BQEsVy9n.js.map → verdict-cache-Bm8EKL2s.js.map} +1 -1
  333. package/dist/wire/index.d.ts +3 -3
  334. package/dist/wire/index.js +1 -1
  335. package/docs/design/mlbenchmarks-book-review.md +1 -1
  336. package/docs/design/mlbenchmarks-review/probes.mts +23 -31
  337. package/docs/experiment.md +1 -1
  338. package/package.json +1 -1
  339. package/dist/analyze-runs-3xpby3p2.js.map +0 -1
  340. package/dist/analyze-runs-CSDAh8A7.d.ts.map +0 -1
  341. package/dist/ast-DJ6Bc7ab.js +0 -558
  342. package/dist/ast-DJ6Bc7ab.js.map +0 -1
  343. package/dist/ast-hI-vjW6J.d.ts +0 -457
  344. package/dist/ast-hI-vjW6J.d.ts.map +0 -1
  345. package/dist/benchmark-command-CByl9dxG.js.map +0 -1
  346. package/dist/campaign-BQ-Jujuj.js.map +0 -1
  347. package/dist/campaign-evidence-OcUciD-N.js.map +0 -1
  348. package/dist/claim-BXcZw-jo.js.map +0 -1
  349. package/dist/cost-ledger-CO7UyEcQ.d.ts.map +0 -1
  350. package/dist/cost-ledger-D2FnJPBF.js.map +0 -1
  351. package/dist/define-agent-eval-Ch3MWX6k.js.map +0 -1
  352. package/dist/external-optimizer-subprocess-DcerlZSG.js.map +0 -1
  353. package/dist/feedback-trajectory-DkaDj0dj.d.ts.map +0 -1
  354. package/dist/index-CPJJr98o.d.ts.map +0 -1
  355. package/dist/index-DlH0Y9gI.d.ts.map +0 -1
  356. package/dist/index-NvGBiO8H.d.ts.map +0 -1
  357. package/dist/integrity-BV1ZDf42.js.map +0 -1
  358. package/dist/judge-gate-B1qYnkpi.js.map +0 -1
  359. package/dist/llm-client-DQveoxSM.js.map +0 -1
  360. package/dist/llm-judge-PXV7Xljl.js.map +0 -1
  361. package/dist/matrix-_BV9-Lk5.js.map +0 -1
  362. package/dist/mint-DCGoBYhB.d.ts +0 -155
  363. package/dist/mint-DCGoBYhB.d.ts.map +0 -1
  364. package/dist/paired-tests-jbwPdSz5.js.map +0 -1
  365. package/dist/redact-Cveoq6fJ.d.ts.map +0 -1
  366. package/dist/redact-Dk1ZdJEm.js.map +0 -1
  367. package/dist/release-confidence-BK2QCB5M.d.ts.map +0 -1
  368. package/dist/report-command-y8H6RSX8.js.map +0 -1
  369. package/dist/run-record-ES07wfz9.js.map +0 -1
  370. package/dist/search-kernel-BztlERLv.js.map +0 -1
  371. package/dist/search-kernel-CpcKH5Ih.d.ts.map +0 -1
  372. package/dist/search-ledger-d7V8o9Lk.js.map +0 -1
  373. package/dist/semantic-concept-judge-zQBG9hHU.js.map +0 -1
  374. package/dist/skillopt-optimization-method-CCtzralq.js.map +0 -1
  375. package/dist/store-otlp-DtB4Slsr.js.map +0 -1
  376. package/dist/store-tool-spans-DR1SrCLK.d.ts.map +0 -1
  377. package/dist/summary-report-C-CtItCN.d.ts.map +0 -1
  378. package/dist/summary-report-DtdRucM0.js.map +0 -1
  379. package/dist/terminal-record-BHocwFw1.js.map +0 -1
  380. package/dist/tool-groups-mcxOXVlb.d.ts.map +0 -1
  381. package/dist/tool-waste-Wi4g6Ekb.d.ts.map +0 -1
  382. package/dist/tree-rXLW3M_4.js.map +0 -1
  383. package/dist/types-B4C5nFw6.d.ts.map +0 -1
  384. package/dist/types-DBZ7keha.d.ts.map +0 -1
@@ -1,242 +1,310 @@
1
- import { p as hashJson } from "./agent-profile-cell-BYc0bxsL.js";
2
- import { i as makeRng } from "./internal-CRHwS9iz.js";
3
- import { i as pairedCohensDz } from "./effect-sizes-DiH8MGOH.js";
4
- import { t as confidenceInterval } from "./descriptive-CnU8Yq29.js";
5
- import { t as benjaminiHochberg } from "./multiplicity-D9cjmStq.js";
6
- import { r as pairedBootstrap } from "./paired-tests-jbwPdSz5.js";
7
- import { r as pairedMde } from "./power-and-mde-fK5Qocwo.js";
8
- import { a as wilcoxonSignedRank, r as pairRunRecords } from "./paired-arms-DzKn0TfY.js";
1
+ import { p as hashJson } from "./agent-profile-cell-BK8mlqlq.js";
9
2
  import { r as observedSplitScore } from "./reward-nw2xZGZG.js";
10
- //#region src/summary-report.ts
11
- /**
12
- * Table 1 helper. Buckets runs by `candidateId`, computes mean +
13
- * bootstrap CI on the chosen split, and (when a comparator is given)
14
- * BH-adjusted Wilcoxon p + paired Cohen's dz versus that comparator.
15
- */
16
- function summaryTable(runs, opts = {}) {
17
- const split = opts.split ?? "holdout";
18
- const confidence = opts.confidence ?? .95;
19
- const fdr = opts.fdr ?? .05;
20
- const comparator = opts.comparator ?? null;
21
- const byCandidate = /* @__PURE__ */ new Map();
22
- for (const r of runs) {
23
- if (r.splitTag !== split) continue;
24
- const v = observedSplitScore(r, split);
25
- if (typeof v !== "number" || !Number.isFinite(v)) continue;
26
- const bucket = byCandidate.get(r.candidateId) ?? {
27
- runs: [],
28
- scores: []
29
- };
30
- bucket.runs.push(r);
31
- bucket.scores.push(v);
32
- byCandidate.set(r.candidateId, bucket);
33
- }
34
- const candidateIds = [...byCandidate.keys()].sort();
35
- const compRuns = comparator ? byCandidate.get(comparator) : void 0;
36
- const tentative = [];
37
- for (const id of candidateIds) {
38
- const bucket = byCandidate.get(id);
39
- const ci = confidenceInterval(bucket.scores, confidence);
40
- let rawP = null;
41
- let d = null;
42
- let pairedN = null;
43
- let unpairedCandidateN = null;
44
- let unpairedComparatorN = null;
45
- if (comparator && compRuns && id !== comparator) {
46
- const paired = pairScoresByKey(bucket.runs, compRuns.runs, split);
47
- pairedN = paired.before.length;
48
- unpairedCandidateN = paired.unpairedCandidateN;
49
- unpairedComparatorN = paired.unpairedComparatorN;
50
- if (paired.before.length >= 6) rawP = wilcoxonSignedRank(paired.before, paired.after).p;
51
- d = pairedCohensDz(paired.before, paired.after);
52
- }
53
- tentative.push({
54
- candidateId: id,
55
- n: bucket.scores.length,
56
- mean: ci.mean,
57
- ciLow: ci.lower,
58
- ciHigh: ci.upper,
59
- qValue: rawP,
60
- cohensD: d,
61
- pairedN,
62
- unpairedCandidateN,
63
- unpairedComparatorN,
64
- rawP
65
- });
66
- }
67
- if (comparator) {
68
- const idxs = [];
69
- const ps = [];
70
- for (let i = 0; i < tentative.length; i++) {
71
- const r = tentative[i];
72
- if (r.candidateId === comparator) continue;
73
- if (r.rawP === null || !Number.isFinite(r.rawP)) continue;
74
- idxs.push(i);
75
- ps.push(r.rawP);
76
- }
77
- if (ps.length > 0) {
78
- const { qValues } = benjaminiHochberg(ps, fdr);
79
- for (let k = 0; k < idxs.length; k++) tentative[idxs[k]].qValue = qValues[k];
80
- }
81
- }
82
- const rows = tentative.map(({ rawP: _rawP, ...rest }) => rest);
83
- return {
84
- rows,
85
- comparator,
86
- split,
87
- markdown: renderSummaryTableMarkdown(rows, comparator, split)
88
- };
89
- }
90
- function pairScoresByKey(candidate, baseline, split) {
91
- const scoreOf = (run) => {
92
- const v = observedSplitScore(run, split);
93
- return typeof v === "number" && Number.isFinite(v) ? v : void 0;
94
- };
95
- const scoredCandidate = candidate.filter((run) => scoreOf(run) !== void 0);
96
- const scoredBaseline = baseline.filter((run) => scoreOf(run) !== void 0);
97
- const pairing = pairRunRecords(scoredBaseline, scoredCandidate);
98
- return {
99
- before: pairing.pairs.map((pair) => scoreOf(pair.baseline)),
100
- after: pairing.pairs.map((pair) => scoreOf(pair.treatment)),
101
- unpairedCandidateN: pairing.unpairedTreatment.length,
102
- unpairedComparatorN: pairing.unpairedBaseline.length
103
- };
104
- }
105
- function renderSummaryTableMarkdown(rows, comparator, split) {
3
+ import { n as renderResearchHtml } from "./reporting-html-Kvlc8oMt.js";
4
+ import { i as makeRng } from "./internal-Epl-YBZW.js";
5
+ import { t as confidenceInterval } from "./descriptive-DboxPZrG.js";
6
+ import { i as pairedCohensDz } from "./effect-sizes-BhzEpXMc.js";
7
+ import { t as benjaminiHochberg } from "./multiplicity-DQUFcbW4.js";
8
+ import { i as pairedBootstrap, t as mean } from "./mean-DHoMiudD.js";
9
+ import { r as pairedMde } from "./power-and-mde-Hj2ubb4B.js";
10
+ import { a as wilcoxonSignedRank, r as pairRunRecords } from "./paired-arms-CwMGJsrS.js";
11
+ //#region src/research-report-render.ts
12
+ function renderResearchMarkdown(report) {
106
13
  const lines = [];
107
- const cmpLabel = comparator ? ` (vs ${comparator})` : "";
108
- lines.push(`Summary Table — ${split} split${cmpLabel}`);
14
+ lines.push(`# ${report.title}`);
109
15
  lines.push("");
110
- lines.push("| Candidate | N | Pairs | Unpaired | Mean | 95% CI | q (BH) | Cohen's dz |");
111
- lines.push("|---|---:|---:|---:|---:|---|---:|---:|");
112
- for (const r of rows) {
113
- const ci = `[${fmt(r.ciLow)}, ${fmt(r.ciHigh)}]`;
114
- const q = r.qValue !== null ? r.qValue.toFixed(4) : "—";
115
- const d = r.cohensD !== null ? r.cohensD.toFixed(3) : "—";
116
- const paired = r.pairedN ?? "—";
117
- const unpaired = r.unpairedCandidateN === null || r.unpairedComparatorN === null ? "—" : `${r.unpairedCandidateN}/${r.unpairedComparatorN}`;
118
- lines.push(`| ${r.candidateId} | ${r.n} | ${paired} | ${unpaired} | ${fmt(r.mean)} | ${ci} | ${q} | ${d} |`);
16
+ lines.push(`**Generated:** ${report.generatedAt}`);
17
+ lines.push(`**Primary split:** ${report.split}`);
18
+ lines.push(`**Comparator:** ${report.comparator ?? "not configured"}`);
19
+ lines.push(`**ROPE:** ${report.rope ? formatRope(report.rope) : "not configured"}`);
20
+ lines.push(`**Run fingerprint:** \`${report.runFingerprint}\``);
21
+ lines.push(`**Preregistration:** ${report.preregistrationHash ? `\`${report.preregistrationHash}\`` : "none"}`);
22
+ lines.push("");
23
+ lines.push("## Executive Summary");
24
+ lines.push("");
25
+ for (const item of report.executiveSummary) lines.push(`- ${item}`);
26
+ lines.push("");
27
+ lines.push("## Recommendation");
28
+ lines.push("");
29
+ lines.push(`**Decision:** ${report.recommendation.decision}`);
30
+ lines.push(`**Candidate:** ${report.recommendation.candidateId ?? "N/A"}`);
31
+ lines.push("");
32
+ lines.push("### Rationale");
33
+ lines.push("");
34
+ for (const item of report.recommendation.rationale) lines.push(`- ${item}`);
35
+ lines.push("");
36
+ lines.push("### Risks");
37
+ lines.push("");
38
+ for (const item of report.recommendation.risks.length ? report.recommendation.risks : ["No material report-level risks detected."]) lines.push(`- ${item}`);
39
+ lines.push("");
40
+ lines.push("### Next Actions");
41
+ lines.push("");
42
+ for (const item of report.recommendation.nextActions) lines.push(`- ${item}`);
43
+ lines.push("");
44
+ lines.push("## Candidate Decision Table");
45
+ lines.push("");
46
+ lines.push("| Candidate | Decision | Mean | Δ̄ | Pr(Δ>0) | q | dz | Paired N | Median Gain CI | MDE | Pareto | Gate |");
47
+ lines.push("|---|---|---:|---:|---:|---:|---:|---:|---|---:|---|---|");
48
+ for (const c of report.candidates) {
49
+ const delta = c.meanDeltaVsComparator === null ? "-" : signed(c.meanDeltaVsComparator);
50
+ const prGt = c.prGreaterThanZero === null ? "-" : c.prGreaterThanZero.toFixed(3);
51
+ const q = c.qValue !== null ? c.qValue.toFixed(4) : "-";
52
+ const d = c.cohensD !== null ? c.cohensD.toFixed(3) : "-";
53
+ const gain = c.gainCi ? `[${fmt(c.gainCi.low)}, ${fmt(c.gainCi.high)}]` : "-";
54
+ const mde = c.mde === null || !Number.isFinite(c.mde) ? "-" : fmt(c.mde);
55
+ lines.push(`| ${c.candidateId} | ${c.decision} | ${fmt(c.mean)} | ${delta} | ${prGt} | ${q} | ${d} | ${c.pairedN} | ${gain} | ${mde} | ${c.onParetoFrontier ? "yes" : "no"} | ${c.gate ?? "-"} |`);
56
+ }
57
+ lines.push("");
58
+ lines.push("## Statistical Summary");
59
+ lines.push("");
60
+ lines.push(report.summary.markdown);
61
+ lines.push("");
62
+ lines.push("## Methodology");
63
+ lines.push("");
64
+ lines.push("### Assumptions");
65
+ lines.push("");
66
+ for (const item of report.methodology.assumptions) lines.push(`- ${item}`);
67
+ lines.push("");
68
+ lines.push("### Methods");
69
+ lines.push("");
70
+ for (const item of report.methodology.methods) lines.push(`- ${item}`);
71
+ lines.push("");
72
+ lines.push("### Alternatives Considered");
73
+ lines.push("");
74
+ for (const item of report.methodology.alternatives) lines.push(`- ${item}`);
75
+ lines.push("");
76
+ lines.push("### When NOT To Apply");
77
+ lines.push("");
78
+ for (const item of report.methodology.whenNotToApply) lines.push(`- ${item}`);
79
+ lines.push("");
80
+ lines.push("### Citations");
81
+ lines.push("");
82
+ for (const item of report.methodology.citations) lines.push(`- ${item}`);
83
+ lines.push("");
84
+ lines.push("## Chart Specs");
85
+ lines.push("");
86
+ lines.push("The report carries JSON chart specs for Pareto cost/quality and paired gain histograms.");
87
+ lines.push("");
88
+ lines.push("```json");
89
+ lines.push(JSON.stringify({
90
+ pareto: report.pareto,
91
+ gains: report.gains
92
+ }, null, 2));
93
+ lines.push("```");
94
+ if (report.failureClusters) {
95
+ lines.push("");
96
+ lines.push("## Failure Clusters");
97
+ lines.push("");
98
+ lines.push("| Failure Class | Runs | Scenarios | Tool | Example |");
99
+ lines.push("|---|---:|---:|---|---|");
100
+ for (const c of report.failureClusters.clusters.slice(0, 10)) lines.push(`| ${c.failureClass} | ${c.runCount} | ${c.scenarioIds.length} | ${c.toolName ?? "-"} | ${escapePipes(c.exampleError ?? c.exampleRunId)} |`);
119
101
  }
120
102
  return lines.join("\n");
121
103
  }
122
- /**
123
- * Cost vs quality scatter spec. `gateDecisions` is keyed by
124
- * candidate id; if present, every point picks up the gate verdict
125
- * for overlay.
126
- */
127
- function paretoChart(runs, opts = {}) {
128
- const split = opts.split ?? "holdout";
129
- const buckets = /* @__PURE__ */ new Map();
130
- for (const r of runs) {
131
- if (r.splitTag !== split) continue;
132
- const v = observedSplitScore(r, split);
133
- if (typeof v !== "number" || !Number.isFinite(v)) continue;
134
- if (r.costUsd === null) continue;
135
- const bucket = buckets.get(r.candidateId) ?? {
136
- cost: [],
137
- quality: []
138
- };
139
- bucket.cost.push(r.costUsd);
140
- bucket.quality.push(v);
141
- buckets.set(r.candidateId, bucket);
142
- }
143
- const points = [];
144
- for (const [candidateId, bucket] of buckets.entries()) points.push({
145
- candidateId,
146
- cost: avg(bucket.cost),
147
- quality: avg(bucket.quality),
148
- n: bucket.cost.length,
149
- onFrontier: false,
150
- gate: opts.gateDecisions?.[candidateId] ? gateLabel(opts.gateDecisions[candidateId]) : void 0
151
- });
152
- for (const p of points) p.onFrontier = !points.some((q) => q !== p && dominates(q, p));
153
- return {
154
- kind: "pareto-cost-quality",
155
- split,
156
- axes: {
157
- x: "costUsd",
158
- y: "score"
159
- },
160
- points
161
- };
104
+ function escapePipes(s) {
105
+ return s.replace(/\|/g, "\\|");
162
106
  }
163
- function dominates(a, b) {
164
- return a.cost <= b.cost && a.quality >= b.quality && (a.cost < b.cost || a.quality > b.quality);
107
+ function signed(x) {
108
+ return `${x >= 0 ? "+" : ""}${fmt(x)}`;
165
109
  }
166
- function gateLabel(d) {
167
- return d.promote ? "promote" : "reject";
110
+ function formatRope(rope) {
111
+ return `[${fmt(rope.low)}, ${fmt(rope.high)}]`;
112
+ }
113
+ function fmt(x) {
114
+ if (!Number.isFinite(x)) return String(x);
115
+ return x.toFixed(4);
168
116
  }
117
+ //#endregion
118
+ //#region src/research-report-analysis.ts
169
119
  /**
170
- * Held-out improvement distribution: per-pair delta (candidate −
171
- * comparator), histogrammed. Includes the bootstrap CI on the median
172
- * delta — same primitive the promotion gate uses.
120
+ * Hard floor below which a paired comparison is treated as uninformative
121
+ * regardless of `minPairs`. Mirrors the lower limit on Wilcoxon signed-rank
122
+ * exact tables; below this the test has no power to separate effect sizes.
173
123
  */
174
- function gainHistogram(runs, candidateId, comparator, opts = {}) {
175
- const split = opts.split ?? "holdout";
176
- const binCount = opts.bins ?? 11;
177
- if (binCount < 1) throw new Error("gainHistogram: bins must be ≥ 1");
178
- const { before, after, unpairedCandidateN, unpairedComparatorN } = pairScoresByKey(runs.filter((r) => r.candidateId === candidateId && r.splitTag === split), runs.filter((r) => r.candidateId === comparator && r.splitTag === split), split);
179
- const n = before.length;
180
- if (n === 0) return {
181
- kind: "gain-distribution",
182
- candidateId,
183
- comparator,
184
- split,
185
- n: 0,
186
- unpairedCandidateN,
187
- unpairedComparatorN,
188
- bins: [],
189
- median: null,
190
- ci: null
124
+ const RESEARCH_REPORT_HARD_PAIR_FLOOR = 6;
125
+ function buildMethodology(ctx) {
126
+ const assumptions = [
127
+ "Pairs are matched by (experimentId, scenarioId, seed); input order does not affect the comparison.",
128
+ "Paired deltas are exchangeable conditional on the matched scenario — no mid-run distribution shift.",
129
+ `Decisions are pre-specified at fdr=${ctx.fdr}, minPairs=${ctx.minPairs}, confidence=${ctx.confidence}; deviating from these post-hoc invalidates the false-discovery control.`
130
+ ];
131
+ if (ctx.rope) assumptions.push(`The Region of Practical Equivalence ${formatRope(ctx.rope)} is supplied by the domain owner; equivalent verdicts are only meaningful if that range is treated as the standing definition of "no material difference."`);
132
+ if (ctx.comparator === null) assumptions.push("No comparator was configured; this run is descriptive, not causal.");
133
+ return {
134
+ assumptions,
135
+ methods: [
136
+ "Marginal scores summarised with BH-FDR-adjusted Wilcoxon signed-rank q-values and paired Cohen's dz via summaryTable.",
137
+ "Paired evidence summarised with a frequentist bootstrap CI on the median delta and a Dirichlet-weight Bayesian bootstrap for Pr(Δ>0) and Pr(Δ∈ROPE) on the mean delta.",
138
+ `Minimum detectable effect reported per candidate at α=${ctx.mdeAlpha} (two-sided), power=${ctx.mdePower}, standardised by the observed paired-delta SD.`,
139
+ "Pareto frontier flagged as a separate axis (cost vs quality); a candidate can be on-frontier without winning the paired test.",
140
+ "Held-out gate decisions, when supplied, override the statistical verdict in the reject direction."
141
+ ],
142
+ alternatives: [
143
+ "Paired t-test rejected: not robust to the heavy-tailed score distributions common in agent benchmarks.",
144
+ "Unpaired Mann–Whitney rejected: matched scenarios make pairing free; unpaired throws away that variance reduction.",
145
+ "Sequential / always-valid inference (e-values, mSPRT) is the right tool for iterative sweeps and is out of scope for this single-look report — preregister and run once, or wrap this report in an alpha-spending schedule.",
146
+ "Hierarchical Bayesian shrinkage across many candidates is future work; the current ranking uses raw paired statistics."
147
+ ],
148
+ whenNotToApply: [
149
+ `Paired N below 6 on any candidate — the bootstrap CI is degenerate.`,
150
+ "Comparator chosen post-hoc by inspecting the same data; q-values are no longer false-discovery-controlled.",
151
+ "Scenarios not drawn under a stable preregistered protocol; the report can describe the data but cannot anchor a launch decision.",
152
+ "Score distributions with mid-run shift (judge model swap, rubric change, infra outage) — pair exchangeability is violated."
153
+ ],
154
+ citations: [
155
+ "Benjamini, Y. & Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. JRSS B, 57(1), 289–300.",
156
+ "Wilcoxon, F. (1945). Individual comparisons by ranking methods. Biometrics Bulletin, 1(6), 80–83.",
157
+ "Efron, B. (1979). Bootstrap methods: another look at the jackknife. Annals of Statistics, 7(1), 1–26.",
158
+ "Rubin, D. B. (1981). The Bayesian bootstrap. Annals of Statistics, 9(1), 130–134.",
159
+ "Kruschke, J. K. (2018). Rejecting or accepting parameter values in Bayesian estimation. Advances in Methods and Practices in Psychological Science, 1(2), 270–280. (ROPE.)"
160
+ ]
161
+ };
162
+ }
163
+ function classifyCandidate(row, ctx) {
164
+ if (ctx.comparator && row.candidateId === ctx.comparator) return {
165
+ decision: "hold",
166
+ reason: "Comparator baseline."
167
+ };
168
+ if (ctx.gateDecision && !ctx.gateDecision.promote) return {
169
+ decision: "reject",
170
+ reason: `Held-out gate returned ${ctx.gateDecision.rejectionCode ?? "rejected"}: ${ctx.gateDecision.reason}`
171
+ };
172
+ if (!ctx.comparator) return {
173
+ decision: ctx.point?.onFrontier ? "hold" : "needs_more_data",
174
+ reason: "No comparator configured; report ranks candidates but cannot anchor a promotion call."
175
+ };
176
+ if (!ctx.posterior || ctx.posterior.n < 6) return {
177
+ decision: "needs_more_data",
178
+ reason: `Only ${ctx.posterior?.n ?? 0} paired observations; below hard floor of 6 for any paired inference.`
179
+ };
180
+ const ci = ctx.posterior.ci;
181
+ if (ctx.split === "search") return {
182
+ decision: "hold",
183
+ reason: "Search-split evidence is descriptive; release decisions require matched holdout runs."
184
+ };
185
+ const degenerate = !Number.isFinite(ci.low) || !Number.isFinite(ci.high) || ci.low === ci.high;
186
+ if (!degenerate && ctx.rope && ci.low >= ctx.rope.low && ci.high <= ctx.rope.high) return {
187
+ decision: "equivalent",
188
+ reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] is fully inside ROPE ${formatRope(ctx.rope)}; candidate is practically equivalent to comparator.`
189
+ };
190
+ const gainPositive = !degenerate && ci.low > 0;
191
+ if (!degenerate && ci.high < 0) return {
192
+ decision: "reject",
193
+ reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] lies entirely below zero.`
194
+ };
195
+ if (ctx.posterior.n < ctx.minPairs) return {
196
+ decision: "needs_more_data",
197
+ reason: `Only ${ctx.posterior.n} paired observations; minimum detectable effect at this N is ${fmt(ctx.posterior.mde)} score units (need ≥ ${ctx.minPairs} pairs to issue a directional verdict).`
198
+ };
199
+ if (degenerate) return {
200
+ decision: "needs_more_data",
201
+ reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] has zero width — every resample was identical, so the interval carries no information about how far the estimate could be wrong and cannot support a promote or equivalence call.`
202
+ };
203
+ if (row.qValue !== null && row.qValue <= ctx.fdr && gainPositive) return {
204
+ decision: "promote",
205
+ reason: `BH-adjusted q=${fmt(row.qValue)} ≤ ${ctx.fdr} and paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] excludes zero; Pr(Δ>0)=${fmt(ctx.posterior.prGreaterThanZero)}.`
191
206
  };
192
- const deltas = before.map((b, i) => after[i] - b);
193
- const sortedDeltas = [...deltas].sort((a, b) => a - b);
194
- const median = medianOfSorted(sortedDeltas);
195
- const min = sortedDeltas[0];
196
- const max = sortedDeltas[sortedDeltas.length - 1];
197
- const bound = Math.max(Math.abs(min), Math.abs(max), 1e-6);
198
- const lo = -bound;
199
- const width = (bound - lo) / binCount;
200
- const bins = [];
201
- for (let i = 0; i < binCount; i++) bins.push({
202
- lo: lo + i * width,
203
- hi: lo + (i + 1) * width,
204
- count: 0
205
- });
206
- for (const d of deltas) {
207
- let idx = Math.floor((d - lo) / width);
208
- if (idx < 0) idx = 0;
209
- if (idx >= binCount) idx = binCount - 1;
210
- bins[idx].count += 1;
211
- }
212
- const ci = pairedBootstrap(before, after, {
213
- confidence: opts.confidence ?? .95,
214
- resamples: opts.resamples ?? 2e3,
215
- statistic: "median",
216
- seed: opts.seed
217
- });
218
207
  return {
219
- kind: "gain-distribution",
220
- candidateId,
221
- comparator,
222
- split,
223
- n,
224
- unpairedCandidateN,
225
- unpairedComparatorN,
226
- bins,
227
- median,
228
- ci: {
229
- low: ci.low,
230
- high: ci.high
208
+ decision: "hold",
209
+ reason: `Pr(Δ>0)=${fmt(ctx.posterior.prGreaterThanZero)} but CI [${fmt(ci.low)}, ${fmt(ci.high)}] crosses zero; effect not decisive at fdr=${ctx.fdr}.`
210
+ };
211
+ }
212
+ function buildRecommendation(candidates, ctx) {
213
+ const nonComparator = candidates.filter((c) => c.candidateId !== ctx.comparator);
214
+ const bestPromote = nonComparator.find((c) => c.decision === "promote");
215
+ const bestEquivalent = nonComparator.find((c) => c.decision === "equivalent");
216
+ const chosen = bestPromote ?? bestEquivalent ?? nonComparator[0] ?? null;
217
+ const decision = bestPromote ? "promote" : nonComparator.some((c) => c.decision === "needs_more_data") ? "needs_more_data" : bestEquivalent ? "equivalent" : nonComparator.some((c) => c.decision === "hold") ? "hold" : "reject";
218
+ const rationale = [];
219
+ const risks = [];
220
+ const nextActions = [];
221
+ if (chosen) {
222
+ rationale.push(`${chosen.candidateId}: ${chosen.decisionReason}`);
223
+ if (chosen.gainCi) {
224
+ const probSummary = chosen.prGreaterThanZero !== null ? `, Pr(Δ>0)=${fmt(chosen.prGreaterThanZero)}` : "";
225
+ rationale.push(`Median paired gain CI: [${fmt(chosen.gainCi.low)}, ${fmt(chosen.gainCi.high)}]${probSummary}.`);
231
226
  }
227
+ if (chosen.mde !== null && Number.isFinite(chosen.mde)) rationale.push(`MDE at current paired N=${chosen.pairedN}: ${fmt(chosen.mde)} score units.`);
228
+ }
229
+ if (!ctx.comparator) {
230
+ risks.push("No comparator was configured; verdict is descriptive, not causal.");
231
+ nextActions.push("Re-run with a stable comparator candidate for paired inference.");
232
+ }
233
+ if (!ctx.preregistrationHash) {
234
+ risks.push("No preregistration hash supplied; readers cannot verify the analysis was specified before data inspection.");
235
+ nextActions.push("Sign a HypothesisManifest before the next sweep and pass `preregistrationHash` so the report cites it.");
236
+ }
237
+ if (ctx.rope === null && nonComparator.length > 0) {
238
+ risks.push("No ROPE configured; the report cannot distinguish \"equivalent\" from \"inconclusive\".");
239
+ nextActions.push("Define a domain-specific Region of Practical Equivalence and pass it to lock in the equivalence threshold.");
240
+ }
241
+ const inconclusive = nonComparator.filter((c) => c.decision === "needs_more_data");
242
+ if (inconclusive.length > 0) {
243
+ const worst = inconclusive.reduce((a, b) => b.pairedN < a.pairedN ? b : a);
244
+ risks.push(`${inconclusive.length} candidate(s) below soft floor (${ctx.minPairs} pairs); thinnest is ${worst.candidateId} with ${worst.pairedN}.`);
245
+ nextActions.push(`Collect at least ${ctx.minPairs - worst.pairedN} more matched holdout runs for ${worst.candidateId}.`);
246
+ }
247
+ const rejected = nonComparator.filter((c) => c.decision === "reject");
248
+ if (rejected.length > 0) risks.push(`${rejected.length} candidate(s) failed the paired test or held-out gate; do not ship those variants.`);
249
+ if (ctx.failureClusters && ctx.failureClusters.clusters.length > 0) {
250
+ const top = ctx.failureClusters.clusters[0];
251
+ risks.push(`Top failure cluster: ${top.failureClass} across ${top.runCount} run(s).`);
252
+ nextActions.push("Prioritize the largest failure cluster before broad rollout.");
253
+ }
254
+ if (decision === "promote") nextActions.push("Ship behind the existing promotion gate and monitor canaries.");
255
+ else if (decision === "hold") nextActions.push("Keep current production candidate while expanding holdout evidence.");
256
+ else if (decision === "equivalent") nextActions.push("Either keep the comparator (no quality regression) or promote on cost/latency grounds — equivalence does not justify either; the choice is a product decision, not a stats one.");
257
+ else if (decision === "reject") nextActions.push("Do not promote this sweep; inspect failures and generate a revised candidate.");
258
+ return {
259
+ decision,
260
+ candidateId: chosen?.candidateId ?? null,
261
+ rationale,
262
+ risks,
263
+ nextActions
264
+ };
265
+ }
266
+ function buildExecutiveSummary(candidates, recommendation, ctx) {
267
+ const lines = [];
268
+ const nonComparator = candidates.filter((c) => c.candidateId !== ctx.comparator);
269
+ lines.push(`Evaluated ${nonComparator.length} candidate(s) on the ${ctx.split} split${ctx.comparator ? ` against ${ctx.comparator}` : ""}.`);
270
+ lines.push(`Recommendation: ${recommendation.decision}${recommendation.candidateId ? ` ${recommendation.candidateId}` : ""}.`);
271
+ const promoted = nonComparator.filter((c) => c.decision === "promote").length;
272
+ const held = nonComparator.filter((c) => c.decision === "hold").length;
273
+ const equivalent = nonComparator.filter((c) => c.decision === "equivalent").length;
274
+ const rejected = nonComparator.filter((c) => c.decision === "reject").length;
275
+ const more = nonComparator.filter((c) => c.decision === "needs_more_data").length;
276
+ lines.push(`Decision mix: ${promoted} promote, ${equivalent} equivalent, ${held} hold, ${rejected} reject, ${more} need more data.`);
277
+ const frontier = nonComparator.filter((c) => c.onParetoFrontier).map((c) => c.candidateId);
278
+ if (frontier.length > 0) lines.push(`Pareto-frontier candidates: ${frontier.join(", ")}.`);
279
+ if (ctx.failureClusters) lines.push(`Failure clustering found ${ctx.failureClusters.totalFailures}/${ctx.failureClusters.totalRuns} failed runs across ${ctx.failureClusters.clusters.length} reportable cluster(s).`);
280
+ lines.push(ctx.preregistrationHash ? `Preregistered analysis: ${ctx.preregistrationHash.slice(0, 12)}…` : "Analysis is post-hoc — no preregistration hash supplied.");
281
+ return lines;
282
+ }
283
+ function decisionWeight(decision) {
284
+ if (decision === "promote") return 5;
285
+ if (decision === "equivalent") return 4;
286
+ if (decision === "hold") return 3;
287
+ if (decision === "needs_more_data") return 2;
288
+ return 1;
289
+ }
290
+ //#endregion
291
+ //#region src/summary-report-evidence.ts
292
+ /** Matched split scores and paired statistical evidence for report consumers. */
293
+ function pairScoresByKey(candidate, baseline, split) {
294
+ const scoreOf = (run) => {
295
+ const v = observedSplitScore(run, split);
296
+ return typeof v === "number" && Number.isFinite(v) ? v : void 0;
297
+ };
298
+ const scoredCandidate = candidate.filter((run) => scoreOf(run) !== void 0);
299
+ const scoredBaseline = baseline.filter((run) => scoreOf(run) !== void 0);
300
+ const pairing = pairRunRecords(scoredBaseline, scoredCandidate);
301
+ return {
302
+ before: pairing.pairs.map((pair) => scoreOf(pair.baseline)),
303
+ after: pairing.pairs.map((pair) => scoreOf(pair.treatment)),
304
+ unpairedCandidateN: pairing.unpairedTreatment.length,
305
+ unpairedComparatorN: pairing.unpairedBaseline.length
232
306
  };
233
307
  }
234
- /**
235
- * Hard floor below which a paired comparison is treated as uninformative
236
- * regardless of `minPairs`. Mirrors the lower limit on Wilcoxon signed-rank
237
- * exact tables; below this the test has no power to separate effect sizes.
238
- */
239
- const RESEARCH_REPORT_HARD_PAIR_FLOOR = 6;
240
308
  /**
241
309
  * Internal: paired posterior summary on (candidate − comparator) deltas.
242
310
  *
@@ -310,23 +378,240 @@ function stdev(xs, mean) {
310
378
  for (const x of xs) sse += (x - mean) ** 2;
311
379
  return Math.sqrt(sse / (xs.length - 1));
312
380
  }
381
+ function medianOfSorted(sorted) {
382
+ if (sorted.length === 0) return 0;
383
+ const mid = Math.floor(sorted.length / 2);
384
+ return sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
385
+ }
386
+ //#endregion
387
+ //#region src/summary-report-figures.ts
313
388
  /**
314
- * Executive research report for CPO / AI-lead / launch-review consumption.
315
- *
316
- * Composes:
317
- * - `summaryTable` marginal stats with BH-FDR-adjusted q-values
318
- * - `paretoChart` cost-vs-quality frontier with gate overlay
319
- * - `gainHistogram` per-candidate paired-delta distribution
320
- * - paired posterior (this file): bootstrap CI on median, Bayesian-bootstrap Pr(Δ>0),
321
- * Pr(Δ∈ROPE), MDE at the configured power
322
- *
323
- * Decisions are made on paired evidence — never on marginal means alone —
324
- * and respect any held-out gate decision the caller passes through. The
325
- * report embeds a SHA-256 fingerprint of the input run set and, optionally,
326
- * the hash of a preregistered protocol so a downstream reader can verify
327
- * provenance and that the analysis was the preregistered one.
328
- *
329
- * Async because the fingerprint uses Web Crypto via `hashJson`; deterministic
389
+ * Table 1 helper. Buckets runs by `candidateId`, computes mean +
390
+ * bootstrap CI on the chosen split, and (when a comparator is given)
391
+ * BH-adjusted Wilcoxon p + paired Cohen's dz versus that comparator.
392
+ */
393
+ function summaryTable(runs, opts = {}) {
394
+ const split = opts.split ?? "holdout";
395
+ const confidence = opts.confidence ?? .95;
396
+ const fdr = opts.fdr ?? .05;
397
+ const comparator = opts.comparator ?? null;
398
+ const byCandidate = /* @__PURE__ */ new Map();
399
+ for (const r of runs) {
400
+ if (r.splitTag !== split) continue;
401
+ const v = observedSplitScore(r, split);
402
+ if (typeof v !== "number" || !Number.isFinite(v)) continue;
403
+ const bucket = byCandidate.get(r.candidateId) ?? {
404
+ runs: [],
405
+ scores: []
406
+ };
407
+ bucket.runs.push(r);
408
+ bucket.scores.push(v);
409
+ byCandidate.set(r.candidateId, bucket);
410
+ }
411
+ const candidateIds = [...byCandidate.keys()].sort();
412
+ const compRuns = comparator ? byCandidate.get(comparator) : void 0;
413
+ const tentative = [];
414
+ for (const id of candidateIds) {
415
+ const bucket = byCandidate.get(id);
416
+ const ci = confidenceInterval(bucket.scores, confidence);
417
+ let rawP = null;
418
+ let d = null;
419
+ let pairedN = null;
420
+ let unpairedCandidateN = null;
421
+ let unpairedComparatorN = null;
422
+ if (comparator && compRuns && id !== comparator) {
423
+ const paired = pairScoresByKey(bucket.runs, compRuns.runs, split);
424
+ pairedN = paired.before.length;
425
+ unpairedCandidateN = paired.unpairedCandidateN;
426
+ unpairedComparatorN = paired.unpairedComparatorN;
427
+ if (paired.before.length >= 6) rawP = wilcoxonSignedRank(paired.before, paired.after).p;
428
+ d = pairedCohensDz(paired.before, paired.after);
429
+ }
430
+ tentative.push({
431
+ candidateId: id,
432
+ n: bucket.scores.length,
433
+ mean: ci.mean,
434
+ ciLow: ci.lower,
435
+ ciHigh: ci.upper,
436
+ qValue: rawP,
437
+ cohensD: d,
438
+ pairedN,
439
+ unpairedCandidateN,
440
+ unpairedComparatorN,
441
+ rawP
442
+ });
443
+ }
444
+ if (comparator) {
445
+ const idxs = [];
446
+ const ps = [];
447
+ for (let i = 0; i < tentative.length; i++) {
448
+ const r = tentative[i];
449
+ if (r.candidateId === comparator) continue;
450
+ if (r.rawP === null || !Number.isFinite(r.rawP)) continue;
451
+ idxs.push(i);
452
+ ps.push(r.rawP);
453
+ }
454
+ if (ps.length > 0) {
455
+ const { qValues } = benjaminiHochberg(ps, fdr);
456
+ for (let k = 0; k < idxs.length; k++) tentative[idxs[k]].qValue = qValues[k];
457
+ }
458
+ }
459
+ const rows = tentative.map(({ rawP: _rawP, ...rest }) => rest);
460
+ return {
461
+ rows,
462
+ comparator,
463
+ split,
464
+ markdown: renderSummaryTableMarkdown(rows, comparator, split)
465
+ };
466
+ }
467
+ function renderSummaryTableMarkdown(rows, comparator, split) {
468
+ const lines = [];
469
+ const cmpLabel = comparator ? ` (vs ${comparator})` : "";
470
+ lines.push(`Summary Table — ${split} split${cmpLabel}`);
471
+ lines.push("");
472
+ lines.push("| Candidate | N | Pairs | Unpaired | Mean | 95% CI | q (BH) | Cohen's dz |");
473
+ lines.push("|---|---:|---:|---:|---:|---|---:|---:|");
474
+ for (const r of rows) {
475
+ const ci = `[${fmt(r.ciLow)}, ${fmt(r.ciHigh)}]`;
476
+ const q = r.qValue !== null ? r.qValue.toFixed(4) : "—";
477
+ const d = r.cohensD !== null ? r.cohensD.toFixed(3) : "—";
478
+ const paired = r.pairedN ?? "—";
479
+ const unpaired = r.unpairedCandidateN === null || r.unpairedComparatorN === null ? "—" : `${r.unpairedCandidateN}/${r.unpairedComparatorN}`;
480
+ lines.push(`| ${r.candidateId} | ${r.n} | ${paired} | ${unpaired} | ${fmt(r.mean)} | ${ci} | ${q} | ${d} |`);
481
+ }
482
+ return lines.join("\n");
483
+ }
484
+ /**
485
+ * Cost vs quality scatter spec. `gateDecisions` is keyed by
486
+ * candidate id; if present, every point picks up the gate verdict
487
+ * for overlay.
488
+ */
489
+ function paretoChart(runs, opts = {}) {
490
+ const split = opts.split ?? "holdout";
491
+ const buckets = /* @__PURE__ */ new Map();
492
+ for (const r of runs) {
493
+ if (r.splitTag !== split) continue;
494
+ const v = observedSplitScore(r, split);
495
+ if (typeof v !== "number" || !Number.isFinite(v)) continue;
496
+ if (r.costUsd === null) continue;
497
+ const bucket = buckets.get(r.candidateId) ?? {
498
+ cost: [],
499
+ quality: []
500
+ };
501
+ bucket.cost.push(r.costUsd);
502
+ bucket.quality.push(v);
503
+ buckets.set(r.candidateId, bucket);
504
+ }
505
+ const points = [];
506
+ for (const [candidateId, bucket] of buckets.entries()) points.push({
507
+ candidateId,
508
+ cost: mean(bucket.cost),
509
+ quality: mean(bucket.quality),
510
+ n: bucket.cost.length,
511
+ onFrontier: false,
512
+ gate: opts.gateDecisions?.[candidateId] ? gateLabel(opts.gateDecisions[candidateId]) : void 0
513
+ });
514
+ for (const p of points) p.onFrontier = !points.some((q) => q !== p && dominates(q, p));
515
+ return {
516
+ kind: "pareto-cost-quality",
517
+ split,
518
+ axes: {
519
+ x: "costUsd",
520
+ y: "score"
521
+ },
522
+ points
523
+ };
524
+ }
525
+ function dominates(a, b) {
526
+ return a.cost <= b.cost && a.quality >= b.quality && (a.cost < b.cost || a.quality > b.quality);
527
+ }
528
+ function gateLabel(d) {
529
+ return d.promote ? "promote" : "reject";
530
+ }
531
+ /**
532
+ * Held-out improvement distribution: per-pair delta (candidate −
533
+ * comparator), histogrammed. Includes the bootstrap CI on the median
534
+ * delta — same primitive the promotion gate uses.
535
+ */
536
+ function gainHistogram(runs, candidateId, comparator, opts = {}) {
537
+ const split = opts.split ?? "holdout";
538
+ const binCount = opts.bins ?? 11;
539
+ if (binCount < 1) throw new Error("gainHistogram: bins must be ≥ 1");
540
+ const { before, after, unpairedCandidateN, unpairedComparatorN } = pairScoresByKey(runs.filter((r) => r.candidateId === candidateId && r.splitTag === split), runs.filter((r) => r.candidateId === comparator && r.splitTag === split), split);
541
+ const n = before.length;
542
+ if (n === 0) return {
543
+ kind: "gain-distribution",
544
+ candidateId,
545
+ comparator,
546
+ split,
547
+ n: 0,
548
+ unpairedCandidateN,
549
+ unpairedComparatorN,
550
+ bins: [],
551
+ median: null,
552
+ ci: null
553
+ };
554
+ const deltas = before.map((b, i) => after[i] - b);
555
+ const sortedDeltas = [...deltas].sort((a, b) => a - b);
556
+ const median = medianOfSorted(sortedDeltas);
557
+ const min = sortedDeltas[0];
558
+ const max = sortedDeltas[sortedDeltas.length - 1];
559
+ const bound = Math.max(Math.abs(min), Math.abs(max), 1e-6);
560
+ const lo = -bound;
561
+ const width = (bound - lo) / binCount;
562
+ const bins = [];
563
+ for (let i = 0; i < binCount; i++) bins.push({
564
+ lo: lo + i * width,
565
+ hi: lo + (i + 1) * width,
566
+ count: 0
567
+ });
568
+ for (const d of deltas) {
569
+ let idx = Math.floor((d - lo) / width);
570
+ if (idx < 0) idx = 0;
571
+ if (idx >= binCount) idx = binCount - 1;
572
+ bins[idx].count += 1;
573
+ }
574
+ const ci = pairedBootstrap(before, after, {
575
+ confidence: opts.confidence ?? .95,
576
+ resamples: opts.resamples ?? 2e3,
577
+ statistic: "median",
578
+ seed: opts.seed
579
+ });
580
+ return {
581
+ kind: "gain-distribution",
582
+ candidateId,
583
+ comparator,
584
+ split,
585
+ n,
586
+ unpairedCandidateN,
587
+ unpairedComparatorN,
588
+ bins,
589
+ median,
590
+ ci: {
591
+ low: ci.low,
592
+ high: ci.high
593
+ }
594
+ };
595
+ }
596
+ //#endregion
597
+ //#region src/research-report.ts
598
+ /**
599
+ * Executive research report for CPO / AI-lead / launch-review consumption.
600
+ *
601
+ * Composes:
602
+ * - `summaryTable` marginal stats with BH-FDR-adjusted q-values
603
+ * - `paretoChart` cost-vs-quality frontier with gate overlay
604
+ * - `gainHistogram` per-candidate paired-delta distribution
605
+ * - paired posterior (this file): bootstrap CI on median, Bayesian-bootstrap Pr(Δ>0),
606
+ * Pr(Δ∈ROPE), MDE at the configured power
607
+ *
608
+ * Decisions are made on paired evidence — never on marginal means alone —
609
+ * and respect any held-out gate decision the caller passes through. The
610
+ * report embeds a SHA-256 fingerprint of the input run set and, optionally,
611
+ * the hash of a preregistered protocol so a downstream reader can verify
612
+ * provenance and that the analysis was the preregistered one.
613
+ *
614
+ * Async because the fingerprint uses Web Crypto via `hashJson`; deterministic
330
615
  * for any fixed `runs`, `seed`, and ROPE.
331
616
  */
332
617
  async function researchReport(runs, opts = {}) {
@@ -483,380 +768,7 @@ async function researchReport(runs, opts = {}) {
483
768
  html
484
769
  };
485
770
  }
486
- function buildMethodology(ctx) {
487
- const assumptions = [
488
- "Pairs are matched by (experimentId, scenarioId, seed); input order does not affect the comparison.",
489
- "Paired deltas are exchangeable conditional on the matched scenario — no mid-run distribution shift.",
490
- `Decisions are pre-specified at fdr=${ctx.fdr}, minPairs=${ctx.minPairs}, confidence=${ctx.confidence}; deviating from these post-hoc invalidates the false-discovery control.`
491
- ];
492
- if (ctx.rope) assumptions.push(`The Region of Practical Equivalence ${formatRope(ctx.rope)} is supplied by the domain owner; equivalent verdicts are only meaningful if that range is treated as the standing definition of "no material difference."`);
493
- if (ctx.comparator === null) assumptions.push("No comparator was configured; this run is descriptive, not causal.");
494
- return {
495
- assumptions,
496
- methods: [
497
- "Marginal scores summarised with BH-FDR-adjusted Wilcoxon signed-rank q-values and paired Cohen's dz via summaryTable.",
498
- "Paired evidence summarised with a frequentist bootstrap CI on the median delta and a Dirichlet-weight Bayesian bootstrap for Pr(Δ>0) and Pr(Δ∈ROPE) on the mean delta.",
499
- `Minimum detectable effect reported per candidate at α=${ctx.mdeAlpha} (two-sided), power=${ctx.mdePower}, standardised by the observed paired-delta SD.`,
500
- "Pareto frontier flagged as a separate axis (cost vs quality); a candidate can be on-frontier without winning the paired test.",
501
- "Held-out gate decisions, when supplied, override the statistical verdict in the reject direction."
502
- ],
503
- alternatives: [
504
- "Paired t-test rejected: not robust to the heavy-tailed score distributions common in agent benchmarks.",
505
- "Unpaired Mann–Whitney rejected: matched scenarios make pairing free; unpaired throws away that variance reduction.",
506
- "Sequential / always-valid inference (e-values, mSPRT) is the right tool for iterative sweeps and is out of scope for this single-look report — preregister and run once, or wrap this report in an alpha-spending schedule.",
507
- "Hierarchical Bayesian shrinkage across many candidates is future work; the current ranking uses raw paired statistics."
508
- ],
509
- whenNotToApply: [
510
- `Paired N below 6 on any candidate — the bootstrap CI is degenerate.`,
511
- "Comparator chosen post-hoc by inspecting the same data; q-values are no longer false-discovery-controlled.",
512
- "Scenarios not drawn under a stable preregistered protocol; the report can describe the data but cannot anchor a launch decision.",
513
- "Score distributions with mid-run shift (judge model swap, rubric change, infra outage) — pair exchangeability is violated."
514
- ],
515
- citations: [
516
- "Benjamini, Y. & Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. JRSS B, 57(1), 289–300.",
517
- "Wilcoxon, F. (1945). Individual comparisons by ranking methods. Biometrics Bulletin, 1(6), 80–83.",
518
- "Efron, B. (1979). Bootstrap methods: another look at the jackknife. Annals of Statistics, 7(1), 1–26.",
519
- "Rubin, D. B. (1981). The Bayesian bootstrap. Annals of Statistics, 9(1), 130–134.",
520
- "Kruschke, J. K. (2018). Rejecting or accepting parameter values in Bayesian estimation. Advances in Methods and Practices in Psychological Science, 1(2), 270–280. (ROPE.)"
521
- ]
522
- };
523
- }
524
- function formatRope(rope) {
525
- return `[${fmt(rope.low)}, ${fmt(rope.high)}]`;
526
- }
527
- function classifyCandidate(row, ctx) {
528
- if (ctx.comparator && row.candidateId === ctx.comparator) return {
529
- decision: "hold",
530
- reason: "Comparator baseline."
531
- };
532
- if (ctx.gateDecision && !ctx.gateDecision.promote) return {
533
- decision: "reject",
534
- reason: `Held-out gate returned ${ctx.gateDecision.rejectionCode ?? "rejected"}: ${ctx.gateDecision.reason}`
535
- };
536
- if (!ctx.comparator) return {
537
- decision: ctx.point?.onFrontier ? "hold" : "needs_more_data",
538
- reason: "No comparator configured; report ranks candidates but cannot anchor a promotion call."
539
- };
540
- if (!ctx.posterior || ctx.posterior.n < 6) return {
541
- decision: "needs_more_data",
542
- reason: `Only ${ctx.posterior?.n ?? 0} paired observations; below hard floor of 6 for any paired inference.`
543
- };
544
- const ci = ctx.posterior.ci;
545
- if (ctx.split === "search") return {
546
- decision: "hold",
547
- reason: "Search-split evidence is descriptive; release decisions require matched holdout runs."
548
- };
549
- const degenerate = !Number.isFinite(ci.low) || !Number.isFinite(ci.high) || ci.low === ci.high;
550
- if (!degenerate && ctx.rope && ci.low >= ctx.rope.low && ci.high <= ctx.rope.high) return {
551
- decision: "equivalent",
552
- reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] is fully inside ROPE ${formatRope(ctx.rope)}; candidate is practically equivalent to comparator.`
553
- };
554
- const gainPositive = !degenerate && ci.low > 0;
555
- if (!degenerate && ci.high < 0) return {
556
- decision: "reject",
557
- reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] lies entirely below zero.`
558
- };
559
- if (ctx.posterior.n < ctx.minPairs) return {
560
- decision: "needs_more_data",
561
- reason: `Only ${ctx.posterior.n} paired observations; minimum detectable effect at this N is ${fmt(ctx.posterior.mde)} score units (need ≥ ${ctx.minPairs} pairs to issue a directional verdict).`
562
- };
563
- if (degenerate) return {
564
- decision: "needs_more_data",
565
- reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] has zero width — every resample was identical, so the interval carries no information about how far the estimate could be wrong and cannot support a promote or equivalence call.`
566
- };
567
- if (row.qValue !== null && row.qValue <= ctx.fdr && gainPositive) return {
568
- decision: "promote",
569
- reason: `BH-adjusted q=${fmt(row.qValue)} ≤ ${ctx.fdr} and paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] excludes zero; Pr(Δ>0)=${fmt(ctx.posterior.prGreaterThanZero)}.`
570
- };
571
- return {
572
- decision: "hold",
573
- reason: `Pr(Δ>0)=${fmt(ctx.posterior.prGreaterThanZero)} but CI [${fmt(ci.low)}, ${fmt(ci.high)}] crosses zero; effect not decisive at fdr=${ctx.fdr}.`
574
- };
575
- }
576
- function buildRecommendation(candidates, ctx) {
577
- const nonComparator = candidates.filter((c) => c.candidateId !== ctx.comparator);
578
- const bestPromote = nonComparator.find((c) => c.decision === "promote");
579
- const bestEquivalent = nonComparator.find((c) => c.decision === "equivalent");
580
- const chosen = bestPromote ?? bestEquivalent ?? nonComparator[0] ?? null;
581
- const decision = bestPromote ? "promote" : nonComparator.some((c) => c.decision === "needs_more_data") ? "needs_more_data" : bestEquivalent ? "equivalent" : nonComparator.some((c) => c.decision === "hold") ? "hold" : "reject";
582
- const rationale = [];
583
- const risks = [];
584
- const nextActions = [];
585
- if (chosen) {
586
- rationale.push(`${chosen.candidateId}: ${chosen.decisionReason}`);
587
- if (chosen.gainCi) {
588
- const probSummary = chosen.prGreaterThanZero !== null ? `, Pr(Δ>0)=${fmt(chosen.prGreaterThanZero)}` : "";
589
- rationale.push(`Median paired gain CI: [${fmt(chosen.gainCi.low)}, ${fmt(chosen.gainCi.high)}]${probSummary}.`);
590
- }
591
- if (chosen.mde !== null && Number.isFinite(chosen.mde)) rationale.push(`MDE at current paired N=${chosen.pairedN}: ${fmt(chosen.mde)} score units.`);
592
- }
593
- if (!ctx.comparator) {
594
- risks.push("No comparator was configured; verdict is descriptive, not causal.");
595
- nextActions.push("Re-run with a stable comparator candidate for paired inference.");
596
- }
597
- if (!ctx.preregistrationHash) {
598
- risks.push("No preregistration hash supplied; readers cannot verify the analysis was specified before data inspection.");
599
- nextActions.push("Sign a HypothesisManifest before the next sweep and pass `preregistrationHash` so the report cites it.");
600
- }
601
- if (ctx.rope === null && nonComparator.length > 0) {
602
- risks.push("No ROPE configured; the report cannot distinguish \"equivalent\" from \"inconclusive\".");
603
- nextActions.push("Define a domain-specific Region of Practical Equivalence and pass it to lock in the equivalence threshold.");
604
- }
605
- const inconclusive = nonComparator.filter((c) => c.decision === "needs_more_data");
606
- if (inconclusive.length > 0) {
607
- const worst = inconclusive.reduce((a, b) => b.pairedN < a.pairedN ? b : a);
608
- risks.push(`${inconclusive.length} candidate(s) below soft floor (${ctx.minPairs} pairs); thinnest is ${worst.candidateId} with ${worst.pairedN}.`);
609
- nextActions.push(`Collect at least ${ctx.minPairs - worst.pairedN} more matched holdout runs for ${worst.candidateId}.`);
610
- }
611
- const rejected = nonComparator.filter((c) => c.decision === "reject");
612
- if (rejected.length > 0) risks.push(`${rejected.length} candidate(s) failed the paired test or held-out gate; do not ship those variants.`);
613
- if (ctx.failureClusters && ctx.failureClusters.clusters.length > 0) {
614
- const top = ctx.failureClusters.clusters[0];
615
- risks.push(`Top failure cluster: ${top.failureClass} across ${top.runCount} run(s).`);
616
- nextActions.push("Prioritize the largest failure cluster before broad rollout.");
617
- }
618
- if (decision === "promote") nextActions.push("Ship behind the existing promotion gate and monitor canaries.");
619
- else if (decision === "hold") nextActions.push("Keep current production candidate while expanding holdout evidence.");
620
- else if (decision === "equivalent") nextActions.push("Either keep the comparator (no quality regression) or promote on cost/latency grounds — equivalence does not justify either; the choice is a product decision, not a stats one.");
621
- else if (decision === "reject") nextActions.push("Do not promote this sweep; inspect failures and generate a revised candidate.");
622
- return {
623
- decision,
624
- candidateId: chosen?.candidateId ?? null,
625
- rationale,
626
- risks,
627
- nextActions
628
- };
629
- }
630
- function buildExecutiveSummary(candidates, recommendation, ctx) {
631
- const lines = [];
632
- const nonComparator = candidates.filter((c) => c.candidateId !== ctx.comparator);
633
- lines.push(`Evaluated ${nonComparator.length} candidate(s) on the ${ctx.split} split${ctx.comparator ? ` against ${ctx.comparator}` : ""}.`);
634
- lines.push(`Recommendation: ${recommendation.decision}${recommendation.candidateId ? ` ${recommendation.candidateId}` : ""}.`);
635
- const promoted = nonComparator.filter((c) => c.decision === "promote").length;
636
- const held = nonComparator.filter((c) => c.decision === "hold").length;
637
- const equivalent = nonComparator.filter((c) => c.decision === "equivalent").length;
638
- const rejected = nonComparator.filter((c) => c.decision === "reject").length;
639
- const more = nonComparator.filter((c) => c.decision === "needs_more_data").length;
640
- lines.push(`Decision mix: ${promoted} promote, ${equivalent} equivalent, ${held} hold, ${rejected} reject, ${more} need more data.`);
641
- const frontier = nonComparator.filter((c) => c.onParetoFrontier).map((c) => c.candidateId);
642
- if (frontier.length > 0) lines.push(`Pareto-frontier candidates: ${frontier.join(", ")}.`);
643
- if (ctx.failureClusters) lines.push(`Failure clustering found ${ctx.failureClusters.totalFailures}/${ctx.failureClusters.totalRuns} failed runs across ${ctx.failureClusters.clusters.length} reportable cluster(s).`);
644
- lines.push(ctx.preregistrationHash ? `Preregistered analysis: ${ctx.preregistrationHash.slice(0, 12)}…` : "Analysis is post-hoc — no preregistration hash supplied.");
645
- return lines;
646
- }
647
- function renderResearchMarkdown(report) {
648
- const lines = [];
649
- lines.push(`# ${report.title}`);
650
- lines.push("");
651
- lines.push(`**Generated:** ${report.generatedAt}`);
652
- lines.push(`**Primary split:** ${report.split}`);
653
- lines.push(`**Comparator:** ${report.comparator ?? "not configured"}`);
654
- lines.push(`**ROPE:** ${report.rope ? formatRope(report.rope) : "not configured"}`);
655
- lines.push(`**Run fingerprint:** \`${report.runFingerprint}\``);
656
- lines.push(`**Preregistration:** ${report.preregistrationHash ? `\`${report.preregistrationHash}\`` : "none"}`);
657
- lines.push("");
658
- lines.push("## Executive Summary");
659
- lines.push("");
660
- for (const item of report.executiveSummary) lines.push(`- ${item}`);
661
- lines.push("");
662
- lines.push("## Recommendation");
663
- lines.push("");
664
- lines.push(`**Decision:** ${report.recommendation.decision}`);
665
- lines.push(`**Candidate:** ${report.recommendation.candidateId ?? "N/A"}`);
666
- lines.push("");
667
- lines.push("### Rationale");
668
- lines.push("");
669
- for (const item of report.recommendation.rationale) lines.push(`- ${item}`);
670
- lines.push("");
671
- lines.push("### Risks");
672
- lines.push("");
673
- for (const item of report.recommendation.risks.length ? report.recommendation.risks : ["No material report-level risks detected."]) lines.push(`- ${item}`);
674
- lines.push("");
675
- lines.push("### Next Actions");
676
- lines.push("");
677
- for (const item of report.recommendation.nextActions) lines.push(`- ${item}`);
678
- lines.push("");
679
- lines.push("## Candidate Decision Table");
680
- lines.push("");
681
- lines.push("| Candidate | Decision | Mean | Δ̄ | Pr(Δ>0) | q | dz | Paired N | Median Gain CI | MDE | Pareto | Gate |");
682
- lines.push("|---|---|---:|---:|---:|---:|---:|---:|---|---:|---|---|");
683
- for (const c of report.candidates) {
684
- const delta = c.meanDeltaVsComparator === null ? "-" : signed(c.meanDeltaVsComparator);
685
- const prGt = c.prGreaterThanZero === null ? "-" : c.prGreaterThanZero.toFixed(3);
686
- const q = c.qValue !== null ? c.qValue.toFixed(4) : "-";
687
- const d = c.cohensD !== null ? c.cohensD.toFixed(3) : "-";
688
- const gain = c.gainCi ? `[${fmt(c.gainCi.low)}, ${fmt(c.gainCi.high)}]` : "-";
689
- const mde = c.mde === null || !Number.isFinite(c.mde) ? "-" : fmt(c.mde);
690
- lines.push(`| ${c.candidateId} | ${c.decision} | ${fmt(c.mean)} | ${delta} | ${prGt} | ${q} | ${d} | ${c.pairedN} | ${gain} | ${mde} | ${c.onParetoFrontier ? "yes" : "no"} | ${c.gate ?? "-"} |`);
691
- }
692
- lines.push("");
693
- lines.push("## Statistical Summary");
694
- lines.push("");
695
- lines.push(report.summary.markdown);
696
- lines.push("");
697
- lines.push("## Methodology");
698
- lines.push("");
699
- lines.push("### Assumptions");
700
- lines.push("");
701
- for (const item of report.methodology.assumptions) lines.push(`- ${item}`);
702
- lines.push("");
703
- lines.push("### Methods");
704
- lines.push("");
705
- for (const item of report.methodology.methods) lines.push(`- ${item}`);
706
- lines.push("");
707
- lines.push("### Alternatives Considered");
708
- lines.push("");
709
- for (const item of report.methodology.alternatives) lines.push(`- ${item}`);
710
- lines.push("");
711
- lines.push("### When NOT To Apply");
712
- lines.push("");
713
- for (const item of report.methodology.whenNotToApply) lines.push(`- ${item}`);
714
- lines.push("");
715
- lines.push("### Citations");
716
- lines.push("");
717
- for (const item of report.methodology.citations) lines.push(`- ${item}`);
718
- lines.push("");
719
- lines.push("## Chart Specs");
720
- lines.push("");
721
- lines.push("The report carries JSON chart specs for Pareto cost/quality and paired gain histograms.");
722
- lines.push("");
723
- lines.push("```json");
724
- lines.push(JSON.stringify({
725
- pareto: report.pareto,
726
- gains: report.gains
727
- }, null, 2));
728
- lines.push("```");
729
- if (report.failureClusters) {
730
- lines.push("");
731
- lines.push("## Failure Clusters");
732
- lines.push("");
733
- lines.push("| Failure Class | Runs | Scenarios | Tool | Example |");
734
- lines.push("|---|---:|---:|---|---|");
735
- for (const c of report.failureClusters.clusters.slice(0, 10)) lines.push(`| ${c.failureClass} | ${c.runCount} | ${c.scenarioIds.length} | ${c.toolName ?? "-"} | ${escapePipes(c.exampleError ?? c.exampleRunId)} |`);
736
- }
737
- return lines.join("\n");
738
- }
739
- function renderResearchHtml(markdown, title) {
740
- const body = markdownToHtml(markdown);
741
- return [
742
- "<!doctype html>",
743
- "<html lang=\"en\">",
744
- "<head>",
745
- "<meta charset=\"utf-8\">",
746
- "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">",
747
- `<title>${escapeHtml(title)}</title>`,
748
- "<style>",
749
- "body{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif;margin:0;color:#172026;background:#f7f8f8;}",
750
- "main{max-width:1080px;margin:0 auto;padding:40px 24px 64px;background:#fff;min-height:100vh;}",
751
- "h1{font-size:34px;line-height:1.15;margin:0 0 20px;}h2{margin-top:34px;border-top:1px solid #d9dfdf;padding-top:22px;}h3{margin-top:22px;}",
752
- "p,li{line-height:1.55;}table{border-collapse:collapse;width:100%;margin:16px 0;font-size:14px;}th,td{border:1px solid #d9dfdf;padding:8px;text-align:left;}th{background:#eef2f2;}",
753
- "code,pre{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;}pre{overflow:auto;background:#111827;color:#f9fafb;padding:16px;border-radius:6px;}",
754
- "</style>",
755
- "</head>",
756
- "<body><main>",
757
- body,
758
- "</main></body></html>"
759
- ].join("\n");
760
- }
761
- function markdownToHtml(markdown) {
762
- const lines = markdown.split("\n");
763
- const html = [];
764
- let inList = false;
765
- let inCode = false;
766
- let code = [];
767
- let table = [];
768
- const flushList = () => {
769
- if (inList) {
770
- html.push("</ul>");
771
- inList = false;
772
- }
773
- };
774
- const flushTable = () => {
775
- if (table.length === 0) return;
776
- html.push(renderMarkdownTable(table));
777
- table = [];
778
- };
779
- for (const line of lines) {
780
- if (line.startsWith("```")) {
781
- if (inCode) {
782
- html.push(`<pre><code>${escapeHtml(code.join("\n"))}</code></pre>`);
783
- code = [];
784
- inCode = false;
785
- } else {
786
- flushList();
787
- flushTable();
788
- inCode = true;
789
- }
790
- continue;
791
- }
792
- if (inCode) {
793
- code.push(line);
794
- continue;
795
- }
796
- if (line.startsWith("|")) {
797
- flushList();
798
- table.push(line);
799
- continue;
800
- }
801
- flushTable();
802
- if (line.startsWith("- ")) {
803
- if (!inList) {
804
- html.push("<ul>");
805
- inList = true;
806
- }
807
- html.push(`<li>${inlineMarkdown(line.slice(2))}</li>`);
808
- continue;
809
- }
810
- flushList();
811
- if (line.startsWith("# ")) html.push(`<h1>${inlineMarkdown(line.slice(2))}</h1>`);
812
- else if (line.startsWith("## ")) html.push(`<h2>${inlineMarkdown(line.slice(3))}</h2>`);
813
- else if (line.startsWith("### ")) html.push(`<h3>${inlineMarkdown(line.slice(4))}</h3>`);
814
- else if (line.trim() === "") html.push("");
815
- else html.push(`<p>${inlineMarkdown(line)}</p>`);
816
- }
817
- flushList();
818
- flushTable();
819
- return html.join("\n");
820
- }
821
- function renderMarkdownTable(lines) {
822
- const rows = lines.filter((line) => !/^\|[-:\s|]+\|$/.test(line)).map((line) => line.slice(1, -1).split("|").map((cell) => inlineMarkdown(cell.trim())));
823
- if (rows.length === 0) return "";
824
- const [head, ...body] = rows;
825
- return `<table><thead><tr>${head.map((cell) => `<th>${cell}</th>`).join("")}</tr></thead><tbody>${body.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("\n")}</tbody></table>`;
826
- }
827
- function inlineMarkdown(s) {
828
- return escapeHtml(s).replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
829
- }
830
- function escapeHtml(s) {
831
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
832
- }
833
- function escapePipes(s) {
834
- return s.replace(/\|/g, "\\|");
835
- }
836
- function decisionWeight(decision) {
837
- if (decision === "promote") return 5;
838
- if (decision === "equivalent") return 4;
839
- if (decision === "hold") return 3;
840
- if (decision === "needs_more_data") return 2;
841
- return 1;
842
- }
843
- function signed(x) {
844
- return `${x >= 0 ? "+" : ""}${fmt(x)}`;
845
- }
846
- function avg(xs) {
847
- if (xs.length === 0) return NaN;
848
- return xs.reduce((s, x) => s + x, 0) / xs.length;
849
- }
850
- function medianOfSorted(sorted) {
851
- if (sorted.length === 0) return 0;
852
- const mid = Math.floor(sorted.length / 2);
853
- return sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
854
- }
855
- function fmt(x) {
856
- if (!Number.isFinite(x)) return String(x);
857
- return x.toFixed(4);
858
- }
859
771
  //#endregion
860
- export { summaryTable as a, researchReport as i, gainHistogram as n, paretoChart as r, RESEARCH_REPORT_HARD_PAIR_FLOOR as t };
772
+ export { RESEARCH_REPORT_HARD_PAIR_FLOOR as a, summaryTable as i, gainHistogram as n, paretoChart as r, researchReport as t };
861
773
 
862
- //# sourceMappingURL=summary-report-DtdRucM0.js.map
774
+ //# sourceMappingURL=summary-report-V_JACR4Y.js.map