@tangle-network/agent-eval 0.183.0 → 0.185.0

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 (248) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-cell-s__adRnK.d.ts → agent-profile-cell-BHcB-mZX.d.ts} +8 -9
  4. package/dist/{agent-profile-cell-s__adRnK.d.ts.map → agent-profile-cell-BHcB-mZX.d.ts.map} +1 -1
  5. package/dist/{agent-profile-cell-Cv6UA-W_.js → agent-profile-cell-DcFW4vOc.js} +16 -15
  6. package/dist/agent-profile-cell-DcFW4vOc.js.map +1 -0
  7. package/dist/{agent-profile-CivaSsSy.d.ts → agent-profile-uAIQK3Nr.d.ts} +3 -3
  8. package/dist/{agent-profile-CivaSsSy.d.ts.map → agent-profile-uAIQK3Nr.d.ts.map} +1 -1
  9. package/dist/analyst/index.d.ts +11 -336
  10. package/dist/analyst/index.d.ts.map +1 -1
  11. package/dist/analyst/index.js +10 -8
  12. package/dist/analyst/index.js.map +1 -1
  13. package/dist/analyze-runs-CrYhqXop.d.ts +75 -0
  14. package/dist/analyze-runs-CrYhqXop.d.ts.map +1 -0
  15. package/dist/{define-agent-eval-CneiWyuA.js → analyze-runs-sTygaDyD.js} +6 -813
  16. package/dist/analyze-runs-sTygaDyD.js.map +1 -0
  17. package/dist/{benchmark-DQKzykkO.js → benchmark-BeQJyrRC.js} +3 -3
  18. package/dist/{benchmark-DQKzykkO.js.map → benchmark-BeQJyrRC.js.map} +1 -1
  19. package/dist/{benchmark-command-NBrqNwgy.js → benchmark-command-kvq7yFY4.js} +17 -54
  20. package/dist/benchmark-command-kvq7yFY4.js.map +1 -0
  21. package/dist/benchmarks/index.d.ts +4 -4
  22. package/dist/benchmarks/index.js +3 -3
  23. package/dist/builder-eval/index.js +1 -1
  24. package/dist/campaign/index.d.ts +6 -5
  25. package/dist/campaign/index.js +10 -9
  26. package/dist/{campaign-BwcEBC91.js → campaign-eJgtRs-W.js} +16 -15
  27. package/dist/{campaign-BwcEBC91.js.map → campaign-eJgtRs-W.js.map} +1 -1
  28. package/dist/{campaign-evidence-PYPUftRy.js → campaign-evidence-BsrCmBSE.js} +7 -258
  29. package/dist/campaign-evidence-BsrCmBSE.js.map +1 -0
  30. package/dist/{canonical-DPyQ_rpt.js → canonical-BsZVgBhW.js} +2 -4
  31. package/dist/canonical-BsZVgBhW.js.map +1 -0
  32. package/dist/cli.js +2 -2
  33. package/dist/{client-kh2jOjTK.d.ts → client-Bc8LANCG.d.ts} +4 -4
  34. package/dist/{client-kh2jOjTK.d.ts.map → client-Bc8LANCG.d.ts.map} +1 -1
  35. package/dist/contract/index.d.ts +10 -10
  36. package/dist/contract/index.js +15 -284
  37. package/dist/contract/index.js.map +1 -1
  38. package/dist/{default-registry-BwDSWVzg.d.ts → default-registry-CXv9kHMt.d.ts} +6 -6
  39. package/dist/{default-registry-BwDSWVzg.d.ts.map → default-registry-CXv9kHMt.d.ts.map} +1 -1
  40. package/dist/{default-registry-C0-N4PkG.js → default-registry-xiHrldW8.js} +6 -4
  41. package/dist/{default-registry-C0-N4PkG.js.map → default-registry-xiHrldW8.js.map} +1 -1
  42. package/dist/define-agent-eval-D4uumjl3.js +813 -0
  43. package/dist/define-agent-eval-D4uumjl3.js.map +1 -0
  44. package/dist/{define-agent-eval-CwOWWQt_.d.ts → define-agent-eval-DE67ECH1.d.ts} +7 -7
  45. package/dist/{define-agent-eval-CwOWWQt_.d.ts.map → define-agent-eval-DE67ECH1.d.ts.map} +1 -1
  46. package/dist/diagnosis/index.d.ts +319 -0
  47. package/dist/diagnosis/index.d.ts.map +1 -0
  48. package/dist/diagnosis/index.js +1328 -0
  49. package/dist/diagnosis/index.js.map +1 -0
  50. package/dist/{dspy-rlm-engine-8pgBSiy7.js → dspy-rlm-engine-BE9lCzzL.js} +3 -3
  51. package/dist/{dspy-rlm-engine-8pgBSiy7.js.map → dspy-rlm-engine-BE9lCzzL.js.map} +1 -1
  52. package/dist/{engine-DS1cysJy.d.ts → engine-cXUK-WHS.d.ts} +5 -77
  53. package/dist/engine-cXUK-WHS.d.ts.map +1 -0
  54. package/dist/equal-terms-Blx9Zk5I.js +25 -0
  55. package/dist/equal-terms-Blx9Zk5I.js.map +1 -0
  56. package/dist/{eval-campaign-CCEkwzoH.js → eval-campaign-XFHEpN86.js} +4 -4
  57. package/dist/{eval-campaign-CCEkwzoH.js.map → eval-campaign-XFHEpN86.js.map} +1 -1
  58. package/dist/evaluation.d.ts +75 -0
  59. package/dist/evaluation.d.ts.map +1 -0
  60. package/dist/evaluation.js +137 -0
  61. package/dist/evaluation.js.map +1 -0
  62. package/dist/{exact-types-BZDe0W2D.d.ts → exact-types-BEHN7tnq.d.ts} +2 -2
  63. package/dist/{exact-types-BZDe0W2D.d.ts.map → exact-types-BEHN7tnq.d.ts.map} +1 -1
  64. package/dist/experiment/index.d.ts +2 -2
  65. package/dist/experiment/index.js +6 -5
  66. package/dist/experiment/index.js.map +1 -1
  67. package/dist/{experiment-tracker-C7PfnF4b.d.ts → experiment-tracker-URRGP9ek.d.ts} +2 -2
  68. package/dist/{experiment-tracker-C7PfnF4b.d.ts.map → experiment-tracker-URRGP9ek.d.ts.map} +1 -1
  69. package/dist/{external-optimizer-process-DIB4YWEe.js → external-optimizer-process-BbhvXTFx.js} +4 -4
  70. package/dist/{external-optimizer-process-DIB4YWEe.js.map → external-optimizer-process-BbhvXTFx.js.map} +1 -1
  71. package/dist/{external-optimizer-subprocess-CjguXN2e.js → external-optimizer-subprocess-DMgmqTB6.js} +3 -3
  72. package/dist/{external-optimizer-subprocess-CjguXN2e.js.map → external-optimizer-subprocess-DMgmqTB6.js.map} +1 -1
  73. package/dist/{feedback-trajectory-CXmtITBo.d.ts → feedback-trajectory-CytTR7u4.d.ts} +3 -3
  74. package/dist/{feedback-trajectory-CXmtITBo.d.ts.map → feedback-trajectory-CytTR7u4.d.ts.map} +1 -1
  75. package/dist/hosted/index.d.ts +2 -2
  76. package/dist/{index-DoykkxW0.d.ts → index-BQWfAFeH.d.ts} +11 -11
  77. package/dist/{index-DoykkxW0.d.ts.map → index-BQWfAFeH.d.ts.map} +1 -1
  78. package/dist/{index-DbG8QbH9.d.ts → index-C8_iU8KL.d.ts} +6 -6
  79. package/dist/{index-DbG8QbH9.d.ts.map → index-C8_iU8KL.d.ts.map} +1 -1
  80. package/dist/{index--_8_Nlpn.d.ts → index-CKZa_rnt.d.ts} +4 -121
  81. package/dist/index-CKZa_rnt.d.ts.map +1 -0
  82. package/dist/{index-Bp_6sj3x.d.ts → index-ww8736Am.d.ts} +20 -315
  83. package/dist/index-ww8736Am.d.ts.map +1 -0
  84. package/dist/index.d.ts +24 -22
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +25 -24
  87. package/dist/index.js.map +1 -1
  88. package/dist/{insight-report-D1qa0HWs.d.ts → insight-report-C3Bfl762.d.ts} +3 -3
  89. package/dist/{insight-report-D1qa0HWs.d.ts.map → insight-report-C3Bfl762.d.ts.map} +1 -1
  90. package/dist/jev-protocol.d.ts +74 -0
  91. package/dist/jev-protocol.d.ts.map +1 -0
  92. package/dist/jev-protocol.js +91 -0
  93. package/dist/jev-protocol.js.map +1 -0
  94. package/dist/jev.d.ts +131 -0
  95. package/dist/jev.d.ts.map +1 -0
  96. package/dist/jev.js +312 -0
  97. package/dist/jev.js.map +1 -0
  98. package/dist/{journal-Cs9f7385.js → journal-BuRLm6ho.js} +2 -2
  99. package/dist/{journal-Cs9f7385.js.map → journal-BuRLm6ho.js.map} +1 -1
  100. package/dist/{kind-factory-DxTzg32u.js → kind-factory-V79Hw0AU.js} +7 -84
  101. package/dist/kind-factory-V79Hw0AU.js.map +1 -0
  102. package/dist/ledger-core/index.js +2 -2
  103. package/dist/{llm-judge-FfaRgz9X.js → llm-judge-FWWhEb31.js} +11 -9
  104. package/dist/{llm-judge-FfaRgz9X.js.map → llm-judge-FWWhEb31.js.map} +1 -1
  105. package/dist/{matrix-CyhW-vgJ.d.ts → matrix-CPKsRY8Y.d.ts} +2 -2
  106. package/dist/{matrix-CyhW-vgJ.d.ts.map → matrix-CPKsRY8Y.d.ts.map} +1 -1
  107. package/dist/meta-eval/index.d.ts +54 -2
  108. package/dist/meta-eval/index.d.ts.map +1 -1
  109. package/dist/meta-eval/index.js +52 -3
  110. package/dist/meta-eval/index.js.map +1 -1
  111. package/dist/{mint-ySIIkKlV.js → mint-B4zgSAJW.js} +63 -14
  112. package/dist/mint-B4zgSAJW.js.map +1 -0
  113. package/dist/mint-BI14xehJ.d.ts +285 -0
  114. package/dist/mint-BI14xehJ.d.ts.map +1 -0
  115. package/dist/multishot/golden/index.d.ts +1 -1
  116. package/dist/multishot/index.d.ts +2 -2
  117. package/dist/openapi.json +1 -1
  118. package/dist/otel-spans-CQY1pNiN.js +275 -0
  119. package/dist/otel-spans-CQY1pNiN.js.map +1 -0
  120. package/dist/otlp-attributes-BpC_blLF.js +83 -0
  121. package/dist/otlp-attributes-BpC_blLF.js.map +1 -0
  122. package/dist/{run-record-DPa2PeHx.js → paired-promotion-decision-ClJh_9nK.js} +2 -215
  123. package/dist/paired-promotion-decision-ClJh_9nK.js.map +1 -0
  124. package/dist/pipelines/index.js +2 -2
  125. package/dist/prime-bridge-transport-Z3cpKGoV.js +43 -0
  126. package/dist/prime-bridge-transport-Z3cpKGoV.js.map +1 -0
  127. package/dist/prime-protocol-CDBcL9NM.d.ts +331 -0
  128. package/dist/prime-protocol-CDBcL9NM.d.ts.map +1 -0
  129. package/dist/{prime-protocol-6tZTVsWm.js → prime-protocol-DcAK9pC8.js} +2 -23
  130. package/dist/prime-protocol-DcAK9pC8.js.map +1 -0
  131. package/dist/{produced-state-CGoVInrl.js → produced-state-CmB02tr2.js} +23 -19
  132. package/dist/{produced-state-CGoVInrl.js.map → produced-state-CmB02tr2.js.map} +1 -1
  133. package/dist/profile-cell.d.ts +1 -1
  134. package/dist/profile-cell.js +1 -1
  135. package/dist/{promotion-policy-BKFrl7CC.js → promotion-policy-DdrYWHDh.js} +3 -3
  136. package/dist/{promotion-policy-BKFrl7CC.js.map → promotion-policy-DdrYWHDh.js.map} +1 -1
  137. package/dist/{query-D1nLIKt7.js → query-DlV0pdx4.js} +2 -2
  138. package/dist/{query-D1nLIKt7.js.map → query-DlV0pdx4.js.map} +1 -1
  139. package/dist/{registry-BRbB6Y0v.d.ts → registry-D5Ly3GRV.d.ts} +3 -3
  140. package/dist/{registry-BRbB6Y0v.d.ts.map → registry-D5Ly3GRV.d.ts.map} +1 -1
  141. package/dist/{release-confidence-BcqeQTHW.d.ts → release-confidence-DsETiO4f.d.ts} +3 -3
  142. package/dist/{release-confidence-BcqeQTHW.d.ts.map → release-confidence-DsETiO4f.d.ts.map} +1 -1
  143. package/dist/{release-confidence-DMg8n18l.js → release-confidence-RanRUXRW.js} +2 -2
  144. package/dist/{release-confidence-DMg8n18l.js.map → release-confidence-RanRUXRW.js.map} +1 -1
  145. package/dist/reporting.d.ts +3 -3
  146. package/dist/reporting.js +2 -2
  147. package/dist/{researcher-64T49THL.d.ts → researcher-CJkH-6Ty.d.ts} +4 -4
  148. package/dist/{researcher-64T49THL.d.ts.map → researcher-CJkH-6Ty.d.ts.map} +1 -1
  149. package/dist/{reward-hacking-uzO_ihep.d.ts → reward-hacking-BIQ2BWLG.d.ts} +2 -2
  150. package/dist/{reward-hacking-uzO_ihep.d.ts.map → reward-hacking-BIQ2BWLG.d.ts.map} +1 -1
  151. package/dist/rl.d.ts +10 -6
  152. package/dist/rl.d.ts.map +1 -1
  153. package/dist/rl.js +22 -7
  154. package/dist/rl.js.map +1 -1
  155. package/dist/rollout/index.d.ts +2 -2
  156. package/dist/rollout/index.js +2 -2
  157. package/dist/{rollout-D_54FZVu.js → rollout-C0Ifk3vK.js} +2 -2
  158. package/dist/{rollout-D_54FZVu.js.map → rollout-C0Ifk3vK.js.map} +1 -1
  159. package/dist/{rubric-predictive-validity-Bmj2_cll.d.ts → rubric-predictive-validity-CTU8y8Cv.d.ts} +2 -2
  160. package/dist/{rubric-predictive-validity-Bmj2_cll.d.ts.map → rubric-predictive-validity-CTU8y8Cv.d.ts.map} +1 -1
  161. package/dist/run-record-CNNzWGpB.js +216 -0
  162. package/dist/run-record-CNNzWGpB.js.map +1 -0
  163. package/dist/{run-record-BiTWauyO.d.ts → run-record-D9wS35fK.d.ts} +2 -2
  164. package/dist/{run-record-BiTWauyO.d.ts.map → run-record-D9wS35fK.d.ts.map} +1 -1
  165. package/dist/{run-record-DualPTn2.js → run-record-tg_5H2IK.js} +2 -2
  166. package/dist/{run-record-DualPTn2.js.map → run-record-tg_5H2IK.js.map} +1 -1
  167. package/dist/search-ledger-types-D7KDVg-o.d.ts +302 -0
  168. package/dist/search-ledger-types-D7KDVg-o.d.ts.map +1 -0
  169. package/dist/{semantic-concept-judge-_3Fp6Q_3.js → semantic-concept-judge-Cnt0TWp0.js} +4 -4
  170. package/dist/{semantic-concept-judge-_3Fp6Q_3.js.map → semantic-concept-judge-Cnt0TWp0.js.map} +1 -1
  171. package/dist/{sequential-D_xHrBZe.js → sequential-PgLEqcTJ.js} +3 -3
  172. package/dist/{sequential-D_xHrBZe.js.map → sequential-PgLEqcTJ.js.map} +1 -1
  173. package/dist/{server-BZQR1f0C.js → server-DmpcFiVK.js} +2 -2
  174. package/dist/{server-BZQR1f0C.js.map → server-DmpcFiVK.js.map} +1 -1
  175. package/dist/{skillopt-optimization-method-DY1aQ-aL.js → skillopt-optimization-method-FSk8b5FQ.js} +8 -7
  176. package/dist/{skillopt-optimization-method-DY1aQ-aL.js.map → skillopt-optimization-method-FSk8b5FQ.js.map} +1 -1
  177. package/dist/{statistical-heldout-CpVd6FmY.d.ts → statistical-heldout-Bu4oNOJh.d.ts} +3 -3
  178. package/dist/{statistical-heldout-CpVd6FmY.d.ts.map → statistical-heldout-Bu4oNOJh.d.ts.map} +1 -1
  179. package/dist/statistical-heldout-CeWT_W7y.js +256 -0
  180. package/dist/statistical-heldout-CeWT_W7y.js.map +1 -0
  181. package/dist/{store-otlp-DAaEbMLf.js → store-otlp-2gYCy-v0.js} +2 -2
  182. package/dist/{store-otlp-DAaEbMLf.js.map → store-otlp-2gYCy-v0.js.map} +1 -1
  183. package/dist/{store-tool-spans-BZ8MPKFe.js → store-tool-spans-B1e6Auc2.js} +69 -6
  184. package/dist/store-tool-spans-B1e6Auc2.js.map +1 -0
  185. package/dist/{store-tool-spans-Dt-YdAuE.d.ts → store-tool-spans-BrdfPaVh.d.ts} +54 -6
  186. package/dist/store-tool-spans-BrdfPaVh.d.ts.map +1 -0
  187. package/dist/{summary-report-IGAOtgPd.js → summary-report-BMvou2oZ.js} +2 -2
  188. package/dist/{summary-report-IGAOtgPd.js.map → summary-report-BMvou2oZ.js.map} +1 -1
  189. package/dist/{summary-report-D1h4dlrK.d.ts → summary-report-BzFS5UhZ.d.ts} +2 -2
  190. package/dist/{summary-report-D1h4dlrK.d.ts.map → summary-report-BzFS5UhZ.d.ts.map} +1 -1
  191. package/dist/{task-failure-attributes-B_JjrOVo.js → task-failure-attributes-B34TiMBe.js} +2 -2
  192. package/dist/{task-failure-attributes-B_JjrOVo.js.map → task-failure-attributes-B34TiMBe.js.map} +1 -1
  193. package/dist/{tool-groups-B2bSNaJB.d.ts → tool-groups-eOOgYGaM.d.ts} +3 -3
  194. package/dist/tool-groups-eOOgYGaM.d.ts.map +1 -0
  195. package/dist/{tool-waste-C7MU9u1e.js → tool-waste-nbHPAxei.js} +2 -2
  196. package/dist/{tool-waste-C7MU9u1e.js.map → tool-waste-nbHPAxei.js.map} +1 -1
  197. package/dist/trace-repair/index.d.ts +2 -2
  198. package/dist/trace-repair/index.js +5 -4
  199. package/dist/trace-repair/index.js.map +1 -1
  200. package/dist/traces.d.ts +5 -5
  201. package/dist/traces.js +8 -7
  202. package/dist/traces.js.map +1 -1
  203. package/dist/trajectory-replay/index.js +1 -1
  204. package/dist/{types-CS0qk_Yp.d.ts → types-BTRcIqFr.d.ts} +3 -3
  205. package/dist/{types-CS0qk_Yp.d.ts.map → types-BTRcIqFr.d.ts.map} +1 -1
  206. package/dist/{types-D7gEdPoQ.d.ts → types-BjB2wZM9.d.ts} +2 -2
  207. package/dist/{types-D7gEdPoQ.d.ts.map → types-BjB2wZM9.d.ts.map} +1 -1
  208. package/dist/types-C8VBbiw6.js +91 -0
  209. package/dist/types-C8VBbiw6.js.map +1 -0
  210. package/dist/{types-BvZoPTGa.d.ts → types-c3ZRTbw9.d.ts} +3 -3
  211. package/dist/{types-BvZoPTGa.d.ts.map → types-c3ZRTbw9.d.ts.map} +1 -1
  212. package/dist/{types-DQ0e2E7y.js → usage-receipt-Cx3xNeyB.js} +2 -89
  213. package/dist/usage-receipt-Cx3xNeyB.js.map +1 -0
  214. package/dist/{verdict-BQ3pCFf8.js → verdict-DhPoXApk.js} +2 -2
  215. package/dist/{verdict-BQ3pCFf8.js.map → verdict-DhPoXApk.js.map} +1 -1
  216. package/dist/{verdict-cache-B3eCVQtY.js → verdict-cache-BQEsVy9n.js} +2 -2
  217. package/dist/{verdict-cache-B3eCVQtY.js.map → verdict-cache-BQEsVy9n.js.map} +1 -1
  218. package/dist/wire/index.d.ts +1 -1
  219. package/dist/wire/index.js +1 -1
  220. package/docs/changes/evaluation-definition-identity.md +27 -0
  221. package/docs/changes/jev-evidence-review.md +18 -0
  222. package/docs/changes/jev-product-adoption.md +18 -0
  223. package/docs/changes/probability-policy-audit.md +81 -0
  224. package/docs/diagnosis.md +42 -0
  225. package/docs/jev-behavior-review.md +174 -0
  226. package/docs/jev-integrations.md +50 -0
  227. package/docs/jev.md +140 -0
  228. package/docs/produced-state.md +13 -0
  229. package/docs/profile-json-identity.md +33 -0
  230. package/package.json +22 -1
  231. package/dist/agent-profile-cell-Cv6UA-W_.js.map +0 -1
  232. package/dist/benchmark-command-NBrqNwgy.js.map +0 -1
  233. package/dist/campaign-evidence-PYPUftRy.js.map +0 -1
  234. package/dist/canonical-DPyQ_rpt.js.map +0 -1
  235. package/dist/define-agent-eval-CneiWyuA.js.map +0 -1
  236. package/dist/engine-DS1cysJy.d.ts.map +0 -1
  237. package/dist/exporters-D98GPi1n.d.ts +0 -161
  238. package/dist/exporters-D98GPi1n.d.ts.map +0 -1
  239. package/dist/index--_8_Nlpn.d.ts.map +0 -1
  240. package/dist/index-Bp_6sj3x.d.ts.map +0 -1
  241. package/dist/kind-factory-DxTzg32u.js.map +0 -1
  242. package/dist/mint-ySIIkKlV.js.map +0 -1
  243. package/dist/prime-protocol-6tZTVsWm.js.map +0 -1
  244. package/dist/run-record-DPa2PeHx.js.map +0 -1
  245. package/dist/store-tool-spans-BZ8MPKFe.js.map +0 -1
  246. package/dist/store-tool-spans-Dt-YdAuE.d.ts.map +0 -1
  247. package/dist/tool-groups-B2bSNaJB.d.ts.map +0 -1
  248. package/dist/types-DQ0e2E7y.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze-runs-sTygaDyD.js","names":[],"sources":["../src/contamination-guard.ts","../src/contract/analyze-runs.ts"],"sourcesContent":["/**\n * ContaminationGuard — ensures held-out scenarios don't leak into\n * training/prompt paths, and flags model memorization.\n *\n * Three probes:\n * 1. `checkCanaries(output, scenario)` — if the scenario carries a\n * canary token, it MUST NOT appear in the agent's output.\n * Canaries are strings that are statistically impossible to\n * reconstruct from the scenario description alone — so if they\n * echo back, the model memorized them.\n * 2. `canaryLeakView(store)` — cross-corpus view of every run whose\n * output contained a canary, with the offending scenario + run.\n * 3. `HoldoutAuditor` — wraps a Dataset and emits a structured error\n * on any code path that reads holdout scenarios but doesn't flag\n * `purpose: 'evaluation'`. Keeps engineers honest.\n */\n\nimport type { DatasetScenario } from './dataset'\nimport { llmSpans } from './trace/query'\nimport type { TraceStore } from './trace/store'\n\nexport interface CanaryLeak {\n scenarioId: string\n canary: string\n runId?: string\n evidence: string\n}\n\nexport function checkCanaries(output: string, scenarios: DatasetScenario[]): CanaryLeak[] {\n const leaks: CanaryLeak[] = []\n for (const s of scenarios) {\n if (!s.canary) continue\n if (output.includes(s.canary)) {\n leaks.push({ scenarioId: s.id, canary: s.canary, evidence: excerpt(output, s.canary) })\n }\n }\n return leaks\n}\n\n/**\n * Behavioral canary: tests the AGENT, not the eval grep.\n *\n * - `forbiddenPattern` PRESENT in output ⇒ AGENT EMITTED BAD CONTENT ⇒ LEAK.\n * - `forbiddenPattern` ABSENT from output ⇒ AGENT HELD THE LINE ⇒ PASS.\n *\n * Use when running known-bad-prompt scenarios against the agent under\n * test and you want to know if the agent misbehaved. The classical\n * {@link checkCanaries} / {@link import('./canary').runCanaries | runCanaries}\n * test whether the eval check fires when the bad output is forced\n * into the eval flow — different question, different answer.\n *\n * Pattern resolution order (first match wins):\n * 1. `scenario.forbiddenPattern` — if it parses as `/body/flags`,\n * treated as a regex; otherwise a literal substring.\n * 2. `scenario.canary` — literal substring fallback so the helper\n * works on existing scenario fixtures.\n *\n * Returns `null` when nothing forbidden was found OR the scenario\n * declared no pattern.\n */\nexport function checkBehavioralCanary(\n output: string,\n scenario: DatasetScenario,\n): CanaryLeak | null {\n const pattern = scenario.forbiddenPattern ?? scenario.canary\n if (!pattern) return null\n const hit = matchForbidden(output, pattern)\n if (!hit) return null\n return {\n scenarioId: scenario.id,\n canary: pattern,\n evidence: excerpt(output, hit),\n }\n}\n\n/**\n * Behavioral canary over many (scenario, output) pairs. Sibling to\n * {@link import('./canary').runCanaries | runCanaries} — same idea\n * (run-many → report) but the question being answered is \"did the\n * AGENT misbehave?\" rather than \"did the EVAL grep fire?\".\n *\n * Returns one `CanaryLeak` per pair where the agent's output\n * contained its scenario's `forbiddenPattern` (or `canary` fallback).\n */\nexport function runBehavioralCanaries(\n cases: Array<{ scenario: DatasetScenario; output: string; runId?: string }>,\n): CanaryLeak[] {\n const leaks: CanaryLeak[] = []\n for (const c of cases) {\n const leak = checkBehavioralCanary(c.output, c.scenario)\n if (leak) leaks.push({ ...leak, runId: c.runId ?? leak.runId })\n }\n return leaks\n}\n\n/**\n * Resolve a forbidden-pattern string to the matched substring inside\n * `output`. `/body/flags` notation is interpreted as a regex; anything\n * else is a literal substring.\n */\nfunction matchForbidden(output: string, pattern: string): string | null {\n const re = tryParseRegex(pattern)\n if (re) {\n const m = output.match(re)\n return m && m[0].length > 0 ? m[0] : null\n }\n return output.includes(pattern) ? pattern : null\n}\n\nfunction tryParseRegex(pattern: string): RegExp | null {\n if (pattern.length < 2 || pattern[0] !== '/') return null\n const last = pattern.lastIndexOf('/')\n if (last <= 0) return null\n const body = pattern.slice(1, last)\n const flags = pattern.slice(last + 1)\n if (!/^[gimsuy]*$/.test(flags)) return null\n try {\n return new RegExp(body, flags)\n } catch {\n return null\n }\n}\n\n/**\n * Scan the LLM-output history in a corpus; returns every case where a\n * canary from a known scenario appeared in agent output. Pass the full\n * set of scenarios whose canaries you care about (typically the whole\n * held-out slice).\n */\nexport async function canaryLeakView(\n store: TraceStore,\n scenarios: DatasetScenario[],\n): Promise<CanaryLeak[]> {\n const targets = scenarios.filter((s) => !!s.canary)\n if (targets.length === 0) return []\n const spans = await llmSpans(store)\n const leaks: CanaryLeak[] = []\n for (const span of spans) {\n const output = span.output ?? ''\n for (const s of targets) {\n if (s.canary && output.includes(s.canary)) {\n leaks.push({\n scenarioId: s.id,\n canary: s.canary,\n runId: span.runId,\n evidence: excerpt(output, s.canary),\n })\n }\n }\n }\n return leaks\n}\n\nexport class HoldoutAuditor {\n private scenarios: DatasetScenario[]\n private accessLog: Array<{ scenarioId: string; purpose: string; at: number }> = []\n\n constructor(scenarios: DatasetScenario[]) {\n this.scenarios = scenarios\n }\n\n /** Retrieve a holdout scenario for a declared purpose. Non-'evaluation' throws. */\n get(scenarioId: string, purpose: 'evaluation' | 'debugging'): DatasetScenario {\n if (purpose !== 'evaluation' && purpose !== 'debugging') {\n throw new Error(\n `HoldoutAuditor.get: purpose must be 'evaluation' or 'debugging', got ${purpose}`,\n )\n }\n const s = this.scenarios.find((x) => x.id === scenarioId)\n if (!s) throw new Error(`holdout scenario \"${scenarioId}\" not found`)\n this.accessLog.push({ scenarioId, purpose, at: Date.now() })\n return s\n }\n\n getAccessLog(): ReadonlyArray<{ scenarioId: string; purpose: string; at: number }> {\n return this.accessLog\n }\n}\n\nfunction excerpt(source: string, needle: string): string {\n const at = source.indexOf(needle)\n if (at < 0) return ''\n const start = Math.max(0, at - 30)\n const end = Math.min(source.length, at + needle.length + 30)\n return (start > 0 ? '…' : '') + source.slice(start, end) + (end < source.length ? '…' : '')\n}\n","/**\n * # `analyzeRuns()` — turn a set of agent runs into an actionable decision packet.\n *\n * Wires the substrate's statistical, calibration, clustering, Pareto, and\n * release-confidence primitives into one `InsightReport`. Two top-level\n * entry points use this function:\n *\n * - `selfImprove()` calls it on the campaign output to attach a packet\n * to every run.\n * - Consumers with observed `RunRecord[]` (production traces, gold\n * corpora, approve/reject tables) call it directly via `analyzeRuns()`\n * for analysis without a closed loop.\n *\n * Every section is opt-in based on what the input data supports — the\n * function never invents signal. If runs carry no judge scores, `judges`\n * is empty. If there's no baseline/candidate split, `lift` is undefined.\n * If no `analyst` is wired, `failureClusters` is undefined.\n *\n * The `recommendations` array is the human-readable layer; everything\n * else is the evidence backing each recommendation.\n */\n\nimport type { AnalystRegistry } from '../analyst/registry'\nimport type { AnalystFinding } from '../analyst/types'\nimport { welchsTTest } from '../baseline'\nimport { aggregatePairedHoldout } from '../campaign/gates/statistical-heldout'\nimport { checkCanaries } from '../contamination-guard'\nimport type { DatasetScenario } from '../dataset'\nimport { continuousAgreement } from '../judge-calibration'\nimport { pairRunRecords } from '../paired-arms'\nimport { observedSplitScore } from '../rollout/reward'\nimport {\n type RunRecord,\n type RunTerminalOutcome,\n type RunTokenUsage,\n validateRunRecord,\n} from '../run-record'\nimport {\n BOOTSTRAP_GATE_MIN_N,\n pairedBootstrap,\n pairedCohensDz,\n pairedMde,\n pairedTTest,\n pearsonR,\n requiredPairedSampleSize,\n spearmanR,\n} from '../statistics'\nimport { type ParetoFigureSpec, paretoChart } from '../summary-report'\nimport type { FailureClass } from '../trace/schema'\n\nimport type {\n CostProvenanceSummary,\n ExecutionInsight,\n FailureClassTally,\n FailureClusterInsight,\n InsightReport,\n InterRaterInsight,\n JudgeInsight,\n LiftInsight,\n MetricDelta,\n OutcomeCorrelationInsight,\n PriorPeriodComparison,\n Recommendation,\n ScalarDistribution,\n TokenUsageInsight,\n} from './insight-report'\n\n// ── Public API ───────────────────────────────────────────────────────\n\nexport interface AnalyzeRunsOptions {\n /** The runs to analyze. */\n runs: RunRecord[]\n /** Which split to score against when reading composite from RunOutcome.\n * Default: holdout when ANY run has a `holdoutScore`, else search. */\n split?: 'search' | 'holdout' | 'auto'\n /** Pairwise analysis configuration. When both `baselineCandidateId` and\n * `candidateCandidateId` are present, lift is computed on paired\n * (experimentId, scenarioId, seed) identities shared between the two sides.\n * Unmatched rows remain visible in the lift result. */\n baselineCandidateId?: string\n candidateCandidateId?: string\n /** Average matched run scores within these units before estimating lift.\n * Raw run distributions and unmatched-run counts remain unchanged. */\n independentUnitByScenarioId?: ReadonlyMap<string, string>\n /** Canary scenarios — checked against every run's raw output for\n * holdout contamination. */\n canaryScenarios?: DatasetScenario[]\n /** Analyst registry for failure clustering. When omitted, the\n * `failureClusters` section is left undefined. */\n analyst?: AnalystRegistry\n /** Downstream outcome metric per run (e.g. engagement rate, approval\n * rate, downstream pass rate). When present, the report includes\n * `outcomeCorrelation` + a simple linear reward model fit. */\n outcomeSignal?: {\n metric: string\n valueByRunId: Record<string, number>\n }\n /** Multi-rater feedback for inter-rater agreement. Each entry is one\n * rater's score for one run. Two or more raters → kappa + disagreement\n * triage list. */\n raterScores?: Array<{ runId: string; rater: string; score: number }>\n /** Number of histogram bins for distributional summaries. Default 12. */\n histogramBins?: number\n /** Decision threshold — the smallest composite lift the caller cares\n * about. Used by the recommendations engine to call ship vs hold.\n * Default 0.02. */\n decisionThreshold?: number\n /** Optional prior-period runs. When set, the report includes\n * `priorPeriodComparison` with per-metric Welch-CI deltas and\n * recommendations fire on statistically significant regressions.\n * The two windows do NOT have to share scenarios — the comparison\n * is two-sample unpaired (the substrate's `lift` field uses paired\n * bootstrap on shared (experimentId, scenarioId, seed) identities; this is the\n * shape for \"this week vs last week\" rather than \"candidate vs\n * baseline within a campaign\"). */\n baselineRuns?: RunRecord[]\n /** Human-readable label for the baseline window, e.g. \"vs prior 7\n * days\", \"vs v3.1 release\". Surfaces in recommendations + UI. */\n baselineLabel?: string\n}\n\nexport interface SummarizeExecutionOptions {\n runs: RunRecord[]\n histogramBins?: number\n}\n\nexport interface ExecutionReport {\n execution: ExecutionInsight\n costProvenance: CostProvenanceSummary\n}\n\n/** Summarize runtime facts without interpreting task quality or promotion readiness. */\nexport function summarizeExecution(opts: SummarizeExecutionOptions): ExecutionReport {\n const runs = opts.runs.map(validateRunRecord)\n const bins = opts.histogramBins ?? 12\n return {\n execution: computeExecutionInsight(runs, bins),\n costProvenance: summarizeCostProvenance(runs),\n }\n}\n\n/** A bootstrap interval with no spread: every resample landed on the same\n * value, so the interval carries no information about how far the point\n * estimate could be wrong and cannot support a directional claim. */\nfunction zeroWidth(ci: readonly [number, number]): boolean {\n return !Number.isFinite(ci[0]) || !Number.isFinite(ci[1]) || ci[0] === ci[1]\n}\n\nexport async function analyzeRuns(opts: AnalyzeRunsOptions): Promise<InsightReport> {\n const runs = opts.runs.map(validateRunRecord)\n const bins = opts.histogramBins ?? 12\n const threshold = opts.decisionThreshold ?? 0.02\n if (!Number.isFinite(threshold)) {\n throw new Error(`analyzeRuns: decisionThreshold must be finite, got ${threshold}`)\n }\n const split = resolveSplit(runs, opts.split ?? 'auto')\n\n const compositeWithIds = runs\n .map((r) => ({ runId: r.runId, score: compositeOf(r, split) }))\n .filter((p) => Number.isFinite(p.score))\n const composite = distributionOf(\n compositeWithIds.map((p) => p.score),\n bins,\n compositeWithIds,\n )\n\n const perDimension = computePerDimension(runs, bins)\n const { execution, costProvenance: provenance } = summarizeExecution({\n runs,\n histogramBins: bins,\n })\n const knownCostRuns = runs.filter((run) => run.costProvenance.kind !== 'uncaptured')\n const costs = knownCostRuns.map((r) => r.costUsd).filter(isFiniteNumber)\n const costDist = distributionOf(costs, bins)\n const pareto = paretoChart(knownCostRuns, { split })\n const degraded: { cost?: string; pareto?: string } = {}\n if (provenance.uncaptured.n > 0) {\n degraded.cost = diagnoseCostCoverage(runs, provenance)\n } else if (costs.length === 0 || costs.every((c) => c === 0)) {\n degraded.cost = `all ${runs.length} explicitly observed or estimated USD values are $0`\n }\n if (pareto.points.length < 2) {\n degraded.pareto =\n pareto.points.length === 0\n ? 'no candidates — Pareto unavailable'\n : 'single candidate — Pareto is a single point, not a frontier'\n }\n const costQuality = {\n cost: costDist,\n pareto,\n provenance,\n ...(degraded.cost || degraded.pareto ? { degraded } : {}),\n }\n\n const judges = computeJudgeInsights(runs)\n\n const interRater = opts.raterScores ? computeInterRater(opts.raterScores) : undefined\n\n const lift = computeLift(\n runs,\n opts.baselineCandidateId,\n opts.candidateCandidateId,\n split,\n opts.independentUnitByScenarioId,\n )\n\n const failureClusters = opts.analyst\n ? await computeFailureClusters(runs, opts.analyst, split)\n : undefined\n\n const failureClasses = computeFailureClasses(runs, split)\n\n const contamination = opts.canaryScenarios\n ? computeContamination(runs, opts.canaryScenarios)\n : undefined\n\n const outcomeCorrelation = opts.outcomeSignal\n ? computeOutcomeCorrelation(runs, opts.outcomeSignal, split)\n : undefined\n\n const release = buildReleaseScorecard(composite, lift, contamination)\n\n const priorPeriodComparison = opts.baselineRuns\n ? computePriorPeriodComparison(runs, opts.baselineRuns, split, opts.baselineLabel)\n : undefined\n\n const recommendations = buildRecommendations({\n composite,\n judges,\n interRater,\n lift,\n failureClusters,\n failureClasses,\n contamination,\n outcomeCorrelation,\n priorPeriodComparison,\n threshold,\n })\n\n return {\n n: runs.length,\n execution,\n composite,\n perDimension,\n costQuality,\n judges,\n interRater,\n lift,\n failureClusters,\n contamination,\n outcomeCorrelation,\n release,\n ...(failureClasses ? { failureClasses } : {}),\n ...(priorPeriodComparison ? { priorPeriodComparison } : {}),\n recommendations,\n }\n}\n\nfunction computeExecutionInsight(runs: RunRecord[], bins: number): ExecutionInsight {\n const aggregateRows = runs.flatMap((run) => {\n const usage = aggregateTokenUsage(run)\n return usage ? [{ usage, costUsd: finiteRaw(run, 'aggregate_cost_usd') }] : []\n })\n const aggregateCosts = aggregateRows.flatMap((row) =>\n row.costUsd !== undefined ? [row.costUsd] : [],\n )\n const modelCounts = new Map<string, number>()\n let executionErrorRuns = 0\n let executionErrorEvents = 0\n let errorReportingRuns = 0\n let errorSpanEvents = 0\n let errorSpanReportingRuns = 0\n const terminalOutcomes: Record<RunTerminalOutcome, number> = {\n succeeded: 0,\n failed: 0,\n cancelled: 0,\n incomplete: 0,\n unknown: 0,\n }\n const errorsByTerminalOutcome: ExecutionInsight['executionErrors']['byTerminalOutcome'] = {\n succeeded: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n failed: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n cancelled: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n incomplete: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n unknown: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n }\n let modelCallRuns = 0\n let modelCallEvents = 0\n let modelCallReportingRuns = 0\n\n for (const run of runs) {\n modelCounts.set(run.model, (modelCounts.get(run.model) ?? 0) + 1)\n const terminalOutcome = run.terminalOutcome\n terminalOutcomes[terminalOutcome] += 1\n const modelCalls = nonNegativeCountRaw(run, 'llm_span_count')\n if (modelCalls !== undefined) {\n modelCallEvents += modelCalls\n modelCallReportingRuns += 1\n }\n const usage = run.tokenUsage\n if (\n (modelCalls ?? 0) > 0 ||\n usage.input > 0 ||\n usage.output > 0 ||\n (usage.cached ?? 0) > 0 ||\n (usage.cacheWrite ?? 0) > 0\n ) {\n modelCallRuns += 1\n }\n const errorEvents = reportedExecutionErrorEvents(run)\n if (errorEvents !== undefined) {\n executionErrorEvents += errorEvents\n errorReportingRuns += 1\n if (errorEvents > 0) {\n executionErrorRuns += 1\n errorsByTerminalOutcome[terminalOutcome].withErrors += 1\n } else errorsByTerminalOutcome[terminalOutcome].withoutErrors += 1\n } else errorsByTerminalOutcome[terminalOutcome].unreported += 1\n const reportedErrorSpans = nonNegativeCountRaw(run, 'error_span_count')\n if (reportedErrorSpans !== undefined) {\n errorSpanEvents += reportedErrorSpans\n errorSpanReportingRuns += 1\n }\n }\n\n return {\n durationMs: distributionOf(\n runs.map((run) => run.wallMs),\n bins,\n ),\n queueMs: distributionOf(\n runs.filter((run) => run.queueMs !== undefined).map((run) => run.queueMs!),\n bins,\n ),\n tokenUsage: summarizeTokenUsage(\n runs.map((run) => run.tokenUsage),\n bins,\n ),\n aggregateUsage: {\n runs: aggregateRows.length,\n tokenUsage: summarizeTokenUsage(\n aggregateRows.map((row) => row.usage),\n bins,\n ),\n costUsd: distributionOf(aggregateCosts, bins),\n totalCostUsd: aggregateCosts.reduce((total, value) => total + value, 0),\n },\n models: [...modelCounts.entries()]\n .map(([model, count]) => ({ model, runs: count }))\n .sort((left, right) => right.runs - left.runs || left.model.localeCompare(right.model)),\n modelCalls: {\n runs: modelCallRuns,\n events: modelCallEvents,\n reportingRuns: modelCallReportingRuns,\n },\n executionErrors: {\n runs: executionErrorRuns,\n fraction: errorReportingRuns > 0 ? executionErrorRuns / errorReportingRuns : null,\n events: executionErrorEvents,\n reportingRuns: errorReportingRuns,\n errorSpanEvents,\n errorSpanReportingRuns,\n byTerminalOutcome: errorsByTerminalOutcome,\n },\n terminalOutcomes,\n }\n}\n\nfunction reportedExecutionErrorEvents(run: RunRecord): number | undefined {\n return nonNegativeCountRaw(run, 'execution_error_count')\n}\n\nfunction nonNegativeCountRaw(run: RunRecord, key: string): number | undefined {\n const value = finiteRaw(run, key)\n return value !== undefined && Number.isInteger(value) && value >= 0 ? value : undefined\n}\n\nfunction summarizeTokenUsage(usages: RunTokenUsage[], bins: number): TokenUsageInsight {\n const reasoning = usages.flatMap((usage) =>\n usage.reasoning !== undefined ? [usage.reasoning] : [],\n )\n const cached = usages.flatMap((usage) => (usage.cached !== undefined ? [usage.cached] : []))\n const cacheWrite = usages.flatMap((usage) =>\n usage.cacheWrite !== undefined ? [usage.cacheWrite] : [],\n )\n return {\n input: distributionOf(\n usages.map((usage) => usage.input),\n bins,\n ),\n output: distributionOf(\n usages.map((usage) => usage.output),\n bins,\n ),\n reasoning: distributionOf(reasoning, bins),\n cached: distributionOf(cached, bins),\n cacheWrite: distributionOf(cacheWrite, bins),\n totals: {\n input: usages.reduce((total, usage) => total + usage.input, 0),\n output: usages.reduce((total, usage) => total + usage.output, 0),\n reasoning: reasoning.reduce((total, value) => total + value, 0),\n cached: cached.reduce((total, value) => total + value, 0),\n cacheWrite: cacheWrite.reduce((total, value) => total + value, 0),\n },\n }\n}\n\nfunction aggregateTokenUsage(run: RunRecord): RunTokenUsage | undefined {\n const input = finiteRaw(run, 'aggregate_prompt_tokens')\n const output = finiteRaw(run, 'aggregate_completion_tokens')\n const reasoning = finiteRaw(run, 'aggregate_reasoning_tokens')\n const cached = finiteRaw(run, 'aggregate_cached_tokens')\n const cacheWrite = finiteRaw(run, 'aggregate_cache_write_tokens')\n if (\n input === undefined &&\n output === undefined &&\n reasoning === undefined &&\n cached === undefined &&\n cacheWrite === undefined\n )\n return undefined\n return {\n input: input ?? 0,\n output: output ?? 0,\n ...(reasoning !== undefined ? { reasoning } : {}),\n ...(cached !== undefined ? { cached } : {}),\n ...(cacheWrite !== undefined ? { cacheWrite } : {}),\n }\n}\n\nfunction finiteRaw(run: RunRecord, key: string): number | undefined {\n const value = run.outcome.raw[key]\n return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined\n}\n\nfunction summarizeCostProvenance(runs: RunRecord[]): CostProvenanceSummary {\n const summary: CostProvenanceSummary = {\n observed: { n: 0, totalUsd: 0 },\n estimated: { n: 0, totalUsd: 0 },\n uncaptured: { n: 0 },\n knownFraction: 0,\n }\n for (const run of runs) {\n const cost = run.costProvenance\n if (cost.kind === 'uncaptured') {\n summary.uncaptured.n += 1\n } else {\n summary[cost.kind].n += 1\n summary[cost.kind].totalUsd += cost.usd\n }\n }\n const known = summary.observed.n + summary.estimated.n\n summary.knownFraction = runs.length > 0 ? known / runs.length : 0\n return summary\n}\n\nfunction diagnoseCostCoverage(runs: RunRecord[], provenance: CostProvenanceSummary): string {\n const uncaptured = provenance.uncaptured.n\n const known = provenance.observed.n + provenance.estimated.n\n if (uncaptured === runs.length) {\n return `USD cost uncaptured for all ${runs.length} runs — no observed or estimated USD values; token and wall-time metrics remain available.`\n }\n return `USD cost uncaptured for ${uncaptured}/${runs.length} runs; excluded those rows from cost statistics (${known}/${runs.length} retained: ${provenance.observed.n} observed, ${provenance.estimated.n} estimated).`\n}\n\n/**\n * Model-free task-failure tally.\n *\n * Explicit non-success classes are task-failure evidence.\n * A low task score without a class is counted as `unknown`.\n */\nfunction computeFailureClasses(\n runs: RunRecord[],\n split: 'search' | 'holdout',\n): FailureClassTally[] | undefined {\n const counts = new Map<FailureClass, number>()\n for (const r of runs) {\n if (!isTaskFailure(r, split)) continue\n const key =\n r.failureClass !== undefined && r.failureClass !== 'success' ? r.failureClass : 'unknown'\n counts.set(key, (counts.get(key) ?? 0) + 1)\n }\n if (counts.size === 0) return undefined\n const n = runs.length\n return [...counts.entries()]\n .map(([failureClass, count]) => ({\n failureClass,\n count,\n share: n > 0 ? count / n : 0,\n }))\n .sort((a, b) => b.count - a.count || a.failureClass.localeCompare(b.failureClass))\n}\n\n// ── Prior-period comparison ─────────────────────────────────────────\n\n/** Direction of the metric — does \"higher current\" mean better or worse?\n * Composite + judge dimensions: higher is better. Cost + duration: lower\n * is better. The recommendations engine flips the sign before judging\n * regressed vs improved. */\ntype MetricDirection = 'higher-is-better' | 'lower-is-better'\n\nfunction computePriorPeriodComparison(\n current: RunRecord[],\n baseline: RunRecord[],\n split: 'search' | 'holdout',\n windowLabel: string | undefined,\n): PriorPeriodComparison | undefined {\n if (current.length === 0 || baseline.length === 0) return undefined\n\n const metrics: Record<string, MetricDelta> = {}\n const directions: Record<string, MetricDirection> = {}\n\n const compositeCurrent = current\n .map((r) => compositeOf(r, split))\n .filter(Number.isFinite) as number[]\n const compositeBaseline = baseline\n .map((r) => compositeOf(r, split))\n .filter(Number.isFinite) as number[]\n if (compositeCurrent.length > 0 && compositeBaseline.length > 0) {\n metrics.composite = welchCompare(compositeBaseline, compositeCurrent)\n directions.composite = 'higher-is-better'\n }\n\n const costCurrent = knownCostValues(current)\n const costBaseline = knownCostValues(baseline)\n if (costCurrent.length > 0 && costBaseline.length > 0) {\n metrics.cost = welchCompare(costBaseline, costCurrent)\n directions.cost = 'lower-is-better'\n }\n\n const durCurrent = current.map((r) => r.wallMs).filter(Number.isFinite)\n const durBaseline = baseline.map((r) => r.wallMs).filter(Number.isFinite)\n if (durCurrent.length > 0 && durBaseline.length > 0) {\n metrics.duration = welchCompare(durBaseline, durCurrent)\n directions.duration = 'lower-is-better'\n }\n\n const tokCurrent = current\n .map((r) => (r.tokenUsage.input ?? 0) + (r.tokenUsage.output ?? 0))\n .filter(Number.isFinite)\n const tokBaseline = baseline\n .map((r) => (r.tokenUsage.input ?? 0) + (r.tokenUsage.output ?? 0))\n .filter(Number.isFinite)\n if (tokCurrent.length > 0 && tokBaseline.length > 0) {\n metrics.tokenUsage = welchCompare(tokBaseline, tokCurrent)\n directions.tokenUsage = 'lower-is-better'\n }\n\n // Per-dimension judge comparisons — only for dimensions present in BOTH\n // windows. We use perDimMean since per-judge nesting is finicky for\n // two-sample comparisons across different judge configurations.\n const dimsCurrent = collectPerDimension(current)\n const dimsBaseline = collectPerDimension(baseline)\n for (const dim of Object.keys(dimsCurrent)) {\n const b = dimsBaseline[dim]\n const c = dimsCurrent[dim]\n if (!b || b.length === 0 || !c || c.length === 0) continue\n metrics[`dim.${dim}`] = welchCompare(b, c)\n directions[`dim.${dim}`] = 'higher-is-better'\n }\n\n const regressedMetrics: string[] = []\n const improvedMetrics: string[] = []\n const inconclusiveMetrics: string[] = []\n for (const [name, delta] of Object.entries(metrics)) {\n if (delta.status !== 'ok') {\n inconclusiveMetrics.push(name)\n continue\n }\n if (!delta.significant) continue\n const dir = directions[name] ?? 'higher-is-better'\n const better = dir === 'higher-is-better' ? delta.delta > 0 : delta.delta < 0\n if (better) improvedMetrics.push(name)\n else regressedMetrics.push(name)\n }\n\n return {\n baselineN: baseline.length,\n currentN: current.length,\n ...(windowLabel ? { windowLabel } : {}),\n metrics,\n regressedMetrics,\n improvedMetrics,\n inconclusiveMetrics,\n }\n}\n\nfunction knownCostValues(runs: RunRecord[]): number[] {\n return runs\n .filter((run) => run.costProvenance.kind !== 'uncaptured')\n .map((run) => run.costUsd)\n .filter(isFiniteNumber)\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value)\n}\n\n/** Collect per-dimension values across runs (from outcome.judgeScores.perDimMean). */\nfunction collectPerDimension(runs: RunRecord[]): Record<string, number[]> {\n const out: Record<string, number[]> = {}\n for (const r of runs) {\n const perDim = r.outcome.judgeScores?.perDimMean\n if (!perDim) continue\n for (const [dim, value] of Object.entries(perDim)) {\n if (!Number.isFinite(value)) continue\n if (!out[dim]) out[dim] = []\n out[dim].push(value as number)\n }\n }\n return out\n}\n\n/** Adapt the shared two-sample Welch result to the report contract. */\nfunction welchCompare(baseline: number[], current: number[]): MetricDelta {\n const result = welchsTTest(baseline, current)\n const base = {\n current: result.meanB,\n baseline: result.meanA,\n delta: result.delta,\n baselineN: baseline.length,\n currentN: current.length,\n }\n if (result.status !== 'ok') {\n return {\n ...base,\n status: result.status,\n ci95: null,\n pValue: null,\n cohensD: null,\n significant: false,\n }\n }\n return {\n ...base,\n status: 'ok',\n ci95: result.ci95,\n pValue: result.p,\n cohensD: result.cohensD,\n significant: result.p < 0.05 && Math.abs(result.cohensD) >= 0.2,\n }\n}\n\n// ── Composite + split selection ─────────────────────────────────────\n\nfunction resolveSplit(\n runs: RunRecord[],\n pref: 'search' | 'holdout' | 'auto',\n): 'search' | 'holdout' {\n if (pref !== 'auto') return pref\n const hasHoldout = runs.some((r) => Number.isFinite(observedSplitScore(r, 'holdout')))\n return hasHoldout ? 'holdout' : 'search'\n}\n\n/**\n * RAW (`observedSplitScore`): `analyzeRuns` describes what a set of runs\n * reported, and every downstream reader of this composite — distributions,\n * per-candidate summaries, the reward-hacking correlation — needs the ungated\n * number to see an inflated run at all.\n */\nfunction compositeOf(run: RunRecord, split: 'search' | 'holdout'): number {\n // Split-exact, no cross-split fallthrough: answering \"what did this run\n // score on the split I am summarising\" with the other split's number\n // silently mixes populations.\n const score = observedSplitScore(run, split)\n return Number.isFinite(score) ? (score as number) : Number.NaN\n}\n\n// ── Distribution helpers ────────────────────────────────────────────\n\nfunction distributionOf(\n values: number[],\n bins: number,\n withIds?: Array<{ runId: string; score: number }>,\n): ScalarDistribution {\n if (values.length === 0) {\n return {\n n: 0,\n mean: null,\n p50: null,\n p95: null,\n stddev: null,\n min: null,\n max: null,\n histogram: [],\n }\n }\n const sorted = [...values].sort((a, b) => a - b)\n const n = sorted.length\n const mean = sorted.reduce((s, v) => s + v, 0) / n\n const variance = sorted.reduce((s, v) => s + (v - mean) ** 2, 0) / n\n const stddev = Math.sqrt(variance)\n const tailRuns = withIds\n ? [...withIds].sort((a, b) => a.score - b.score).slice(0, Math.min(5, withIds.length))\n : undefined\n return {\n n,\n mean,\n p50: percentile(sorted, 0.5),\n p95: percentile(sorted, 0.95),\n stddev,\n min: sorted[0]!,\n max: sorted[n - 1]!,\n histogram: histogram(sorted, bins),\n ...(tailRuns ? { tailRuns } : {}),\n }\n}\n\nfunction percentile(sorted: number[], q: number): number {\n if (sorted.length === 0) return 0\n if (sorted.length === 1) return sorted[0]!\n const idx = (sorted.length - 1) * q\n const lo = Math.floor(idx)\n const hi = Math.ceil(idx)\n if (lo === hi) return sorted[lo]!\n const w = idx - lo\n return sorted[lo]! * (1 - w) + sorted[hi]! * w\n}\n\n/** Even-width histogram over the value range. Returns inclusive-lo /\n * exclusive-hi bins (closed on right for the last bin) compatible with\n * the substrate's `GainDistributionBin` shape. */\nfunction histogram(sorted: number[], bins: number): ScalarDistribution['histogram'] {\n if (sorted.length === 0 || bins < 1) return []\n const min = sorted[0]!\n const max = sorted[sorted.length - 1]!\n if (min === max) return [{ lo: min, hi: max, count: sorted.length }]\n const width = (max - min) / bins\n const out: ScalarDistribution['histogram'] = []\n for (let i = 0; i < bins; i++) {\n const lo = min + i * width\n const hi = i === bins - 1 ? max : lo + width\n out.push({ lo, hi, count: 0 })\n }\n for (const v of sorted) {\n const idx = Math.min(bins - 1, Math.floor((v - min) / width))\n out[idx]!.count++\n }\n return out\n}\n\nfunction computePerDimension(runs: RunRecord[], bins: number): Record<string, ScalarDistribution> {\n // JudgeScoresRecord pre-aggregates `perDimMean` (mean across judges per\n // dimension). We collect those means across runs to produce a per-dim\n // distribution at the corpus level. Consumers who want per-judge\n // dimension values reach into `perJudge[judgeId][dim]` themselves.\n const byDim = new Map<string, number[]>()\n for (const run of runs) {\n const scores = run.outcome.judgeScores\n if (!scores) continue\n for (const [dim, value] of Object.entries(scores.perDimMean ?? {})) {\n if (!Number.isFinite(value)) continue\n const arr = byDim.get(dim) ?? []\n arr.push(value)\n byDim.set(dim, arr)\n }\n }\n const out: Record<string, ScalarDistribution> = {}\n for (const [dim, values] of byDim) out[dim] = distributionOf(values, bins)\n return out\n}\n\n// ── Judge insights ──────────────────────────────────────────────────\n\nfunction computeJudgeInsights(runs: RunRecord[]): Record<string, JudgeInsight> {\n // Each judge's per-run mean is the average of its per-dimension scores\n // for that run. We aggregate those means across all runs each judge\n // scored — giving consumers a \"this judge's typical verdict\" reading.\n const out: Record<string, JudgeInsight> = {}\n const byJudge = new Map<string, number[]>()\n for (const run of runs) {\n const scores = run.outcome.judgeScores\n if (!scores?.perJudge) continue\n for (const [judgeId, dims] of Object.entries(scores.perJudge)) {\n const dimValues = Object.values(dims).filter(Number.isFinite) as number[]\n if (dimValues.length === 0) continue\n const judgeMean = dimValues.reduce((s, v) => s + v, 0) / dimValues.length\n const arr = byJudge.get(judgeId) ?? []\n arr.push(judgeMean)\n byJudge.set(judgeId, arr)\n }\n }\n for (const [judgeId, values] of byJudge) {\n out[judgeId] = {\n n: values.length,\n meanScore: values.reduce((s, v) => s + v, 0) / values.length,\n }\n }\n return out\n}\n\n// ── Inter-rater agreement ───────────────────────────────────────────\n\nfunction computeInterRater(\n ratings: Array<{ runId: string; rater: string; score: number }>,\n): InterRaterInsight | undefined {\n const byRun = new Map<string, Array<{ rater: string; score: number }>>()\n for (const r of ratings) {\n if (!Number.isFinite(r.score)) continue\n const list = byRun.get(r.runId) ?? []\n list.push({ rater: r.rater, score: r.score })\n byRun.set(r.runId, list)\n }\n const raters = new Set(ratings.map((r) => r.rater))\n const jointlyRated: string[] = []\n for (const [runId, ratersForRun] of byRun) {\n const seen = new Set(ratersForRun.map((r) => r.rater))\n let all = true\n for (const r of raters) if (!seen.has(r)) all = false\n if (all) jointlyRated.push(runId)\n }\n if (raters.size < 2 || jointlyRated.length === 0) return undefined\n\n const raterList = [...raters].sort()\n const perPair: Record<string, number> = {}\n for (let i = 0; i < raterList.length; i++) {\n for (let j = i + 1; j < raterList.length; j++) {\n const a = raterList[i]!\n const b = raterList[j]!\n const aScores: number[] = []\n const bScores: number[] = []\n for (const runId of jointlyRated) {\n const ratersForRun = byRun.get(runId)!\n const sa = ratersForRun.find((r) => r.rater === a)?.score\n const sb = ratersForRun.find((r) => r.rater === b)?.score\n if (sa !== undefined && sb !== undefined) {\n aScores.push(sa)\n bScores.push(sb)\n }\n }\n const agreement = continuousAgreement(\n aScores.map((score, index) => [score, bScores[index]!]),\n { bootstrap: 0 },\n )\n perPair[`${a}::${b}`] = agreement.weightedKappa\n }\n }\n const matrix = jointlyRated.map((runId) => {\n const ratingsByRater = new Map(byRun.get(runId)!.map((rating) => [rating.rater, rating.score]))\n return raterList.map((rater) => ratingsByRater.get(rater)!)\n })\n const agreement = continuousAgreement(matrix, { bootstrap: 0 })\n\n const disagreementCases = jointlyRated\n .map((runId) => {\n const ratersForRun = byRun.get(runId)!\n const scores = ratersForRun.map((r) => r.score)\n const range = Math.max(...scores) - Math.min(...scores)\n return { runId, ratings: ratersForRun, range }\n })\n .sort((a, b) => b.range - a.range)\n .slice(0, 20)\n\n return {\n raters: raters.size,\n jointlyRated: jointlyRated.length,\n kappa: Number.isFinite(agreement.weightedKappa) ? agreement.weightedKappa : 0,\n icc: agreement.icc,\n pearson: agreement.pearson,\n spearman: agreement.spearman,\n perPair,\n disagreementCases,\n }\n}\n\n// ── Lift ────────────────────────────────────────────────────────────\n\nfunction computeLift(\n runs: RunRecord[],\n baselineId: string | undefined,\n candidateId: string | undefined,\n split: 'search' | 'holdout',\n independentUnitByScenarioId?: ReadonlyMap<string, string>,\n): LiftInsight | undefined {\n let bId = baselineId\n let cId = candidateId\n if (!bId || !cId) {\n // Auto-detect: when exactly two distinct candidateIds appear, treat the\n // lower-mean side as baseline.\n const ids = [...new Set(runs.map((r) => r.candidateId))]\n if (ids.length !== 2) return undefined\n const [idA, idB] = ids as [string, string]\n const scoresA = finiteCompositeScores(\n runs.filter((run) => run.candidateId === idA),\n split,\n )\n const scoresB = finiteCompositeScores(\n runs.filter((run) => run.candidateId === idB),\n split,\n )\n if (scoresA.length === 0 || scoresB.length === 0) return undefined\n const meanA = mean(scoresA)\n const meanB = mean(scoresB)\n bId = meanA <= meanB ? idA : idB\n cId = meanA <= meanB ? idB : idA\n }\n\n const baseline = runs.filter((r) => r.candidateId === bId)\n const candidate = runs.filter((r) => r.candidateId === cId)\n if (baseline.length === 0 || candidate.length === 0) return undefined\n\n const scoredBaseline = baseline.filter((run) => Number.isFinite(compositeOf(run, split)))\n const scoredCandidate = candidate.filter((run) => Number.isFinite(compositeOf(run, split)))\n const pairing = pairRunRecords(scoredBaseline, scoredCandidate)\n let pairedBaseline = pairing.pairs.map((pair) => compositeOf(pair.baseline, split))\n let pairedCandidate = pairing.pairs.map((pair) => compositeOf(pair.treatment, split))\n if (pairedBaseline.length === 0) return undefined\n const grouped = independentUnitByScenarioId\n ? aggregatePairedHoldout(\n {\n before: pairedBaseline,\n after: pairedCandidate,\n // Pairing is already fixed by experiment, scenario, and seed.\n // The ordinal labels each matched observation for the shared reducer.\n cellIds: pairing.pairs.map((pair, index) => `${pair.pairKey}:${index}`),\n },\n new Map(\n pairing.pairs.map((pair) => [\n pair.pairKey,\n independentUnitByScenarioId.get(pair.baseline.scenarioId)!,\n ]),\n ),\n )\n : undefined\n if (grouped) {\n pairedBaseline = grouped.before\n pairedCandidate = grouped.after\n }\n const reverseInferredArms =\n grouped !== undefined &&\n (!baselineId || !candidateId) &&\n mean(pairedBaseline) > mean(pairedCandidate)\n if (reverseInferredArms) [pairedBaseline, pairedCandidate] = [pairedCandidate, pairedBaseline]\n\n const baselineMean = mean(pairedBaseline)\n const candidateMean = mean(pairedCandidate)\n const delta = candidateMean - baselineMean\n\n const bootstrap = pairedBootstrap(pairedBaseline, pairedCandidate, {\n confidence: 0.95,\n resamples: 2000,\n statistic: 'mean',\n })\n const tTest = pairedTTest(pairedBaseline, pairedCandidate)\n const d = pairedCohensDz(pairedBaseline, pairedCandidate)\n const mde = pairedMde({ nPaired: pairedBaseline.length, power: 0.8, alpha: 0.05 })\n const requiredN =\n d === null || d === 0\n ? null\n : requiredPairedSampleSize({\n effect: Math.abs(d),\n power: 0.8,\n alpha: 0.05,\n })\n\n return {\n baselineMean,\n candidateMean,\n delta,\n ci95: [bootstrap.low, bootstrap.high],\n pValue: tTest.p,\n n: pairedBaseline.length,\n ...(grouped ? { pairedRunN: pairing.pairs.length, independentUnitIds: grouped.unitIds } : {}),\n minimumRequired: BOOTSTRAP_GATE_MIN_N,\n decisionEligible: bootstrap.gateEligible,\n unpairedBaseline: (reverseInferredArms ? pairing.unpairedTreatment : pairing.unpairedBaseline)\n .length,\n unpairedCandidate: (reverseInferredArms ? pairing.unpairedBaseline : pairing.unpairedTreatment)\n .length,\n cohensD: d,\n mde,\n requiredN,\n }\n}\n\nfunction mean(arr: number[]): number {\n return arr.length === 0 ? 0 : arr.reduce((s, v) => s + v, 0) / arr.length\n}\n\n// ── Failure clustering ──────────────────────────────────────────────\n\nasync function computeFailureClusters(\n runs: RunRecord[],\n analyst: AnalystRegistry,\n split: 'search' | 'holdout',\n): Promise<FailureClusterInsight | undefined> {\n const failed = runs.filter((run) => isTaskFailure(run, split))\n if (failed.length === 0) return { clusters: [], totalFailures: 0 }\n\n const clusters = new Map<string, { exemplars: string[]; runs: number }>()\n const recordCluster = (key: string, runId: string) => {\n const cluster = clusters.get(key) ?? { exemplars: [], runs: 0 }\n cluster.runs += 1\n if (cluster.exemplars.length < 5 && !cluster.exemplars.includes(runId)) {\n cluster.exemplars.push(runId)\n }\n clusters.set(key, cluster)\n }\n for (const run of failed) {\n try {\n // AnalystRunInputs routes by field name: run-record analysts read\n // `runRecord`. Any other shape makes every analyst skip with\n // \"missing input\" and the clusters come back silently empty.\n const result = await analyst.run(run.runId, { runRecord: run })\n // One run can produce several findings in one cluster; count it once.\n const keys = new Set(\n result.findings.map(\n (finding: AnalystFinding) => finding.area || finding.analyst_id || 'unclassified',\n ),\n )\n for (const key of keys) recordCluster(key, run.runId)\n } catch {\n recordCluster('analyst-error', run.runId)\n }\n }\n const clusterList = [...clusters.entries()].map(([id, c]) => ({\n id,\n name: id,\n share: c.runs / failed.length,\n exemplars: c.exemplars,\n }))\n clusterList.sort((a, b) => b.share - a.share)\n return { clusters: clusterList, totalFailures: failed.length }\n}\n\nfunction finiteCompositeScores(runs: readonly RunRecord[], split: 'search' | 'holdout'): number[] {\n return runs.map((run) => compositeOf(run, split)).filter(Number.isFinite)\n}\n\nfunction isTaskFailure(run: RunRecord, split: 'search' | 'holdout'): boolean {\n if (run.failureClass !== undefined && run.failureClass !== 'success') return true\n const score = compositeOf(run, split)\n return Number.isFinite(score) && score < 0.5\n}\n\n// ── Contamination ──────────────────────────────────────────────────\n\nfunction computeContamination(\n runs: RunRecord[],\n canaries: DatasetScenario[],\n): InsightReport['contamination'] {\n let leaks = 0\n const details: Array<{ runId: string; canary: string; matched: string }> = []\n for (const run of runs) {\n const output = stringifyOutput(run)\n if (!output) continue\n const leaksHere = checkCanaries(output, canaries)\n for (const leak of leaksHere) {\n leaks++\n details.push({ runId: run.runId, canary: leak.canary, matched: leak.evidence })\n }\n }\n return { leaks, holdoutAuditPassed: leaks === 0, details }\n}\n\nfunction stringifyOutput(run: RunRecord): string | undefined {\n // RunRecord doesn't fix where \"the agent's output\" lives — different\n // consumers stash it differently. We probe the common shapes: the\n // outcome.raw map (numeric only by design — unlikely to contain text),\n // and any string-valued fields tucked under metadata via type casting.\n // Consumers with bespoke shapes pass canaryScenarios only when they\n // know their runs carry a stringifiable surface.\n const metadata = (run as unknown as { metadata?: Record<string, unknown> }).metadata\n if (typeof metadata?.output === 'string') return metadata.output\n if (typeof metadata?.text === 'string') return metadata.text\n return undefined\n}\n\n// ── Outcome correlation + linear reward model ──────────────────────\n\nfunction computeOutcomeCorrelation(\n runs: RunRecord[],\n outcome: { metric: string; valueByRunId: Record<string, number> },\n split: 'search' | 'holdout',\n): OutcomeCorrelationInsight | undefined {\n const xs: number[] = []\n const ys: number[] = []\n for (const run of runs) {\n const y = outcome.valueByRunId[run.runId]\n if (y === undefined || !Number.isFinite(y)) continue\n const x = compositeOf(run, split)\n if (!Number.isFinite(x)) continue\n xs.push(x)\n ys.push(y)\n }\n if (xs.length < 3) return undefined\n\n const p = pearsonR(xs, ys)\n const s = spearmanR(xs, ys)\n const meanX = mean(xs)\n const meanY = mean(ys)\n let num = 0\n let denom = 0\n for (let i = 0; i < xs.length; i++) {\n num += (xs[i]! - meanX) * (ys[i]! - meanY)\n denom += (xs[i]! - meanX) ** 2\n }\n const slope = denom === 0 ? 0 : num / denom\n const intercept = meanY - slope * meanX\n const ssTot = ys.reduce((a, y) => a + (y - meanY) ** 2, 0)\n const ssRes = ys.reduce((a, y, i) => a + (y - (intercept + slope * xs[i]!)) ** 2, 0)\n const r2 = ssTot === 0 ? 0 : 1 - ssRes / ssTot\n\n return {\n metric: outcome.metric,\n n: xs.length,\n pearson: p,\n spearman: s,\n rewardModel: { intercept, slope, r2 },\n }\n}\n\n// ── Release confidence scorecard ───────────────────────────────────\n\nfunction buildReleaseScorecard(\n composite: ScalarDistribution,\n lift: LiftInsight | undefined,\n contamination: InsightReport['contamination'],\n): InsightReport['release'] {\n // Synthesise a minimal scorecard from the rolled-up signal. The\n // substrate's `evaluateReleaseConfidence` primitive consumes a richer\n // input shape that callers can produce by wiring SLO definitions; the\n // shape here is the contract `selfImprove`/`analyzeRuns` consumers\n // receive automatically. They can call `evaluateReleaseConfidence`\n // directly when they want SLO-based axis evaluation.\n const axes: InsightReport['release']['axes'] = []\n const liftPass =\n lift === undefined\n ? ('not_evaluated' as const)\n : !lift.decisionEligible\n ? ('not_evaluated' as const)\n : lift.ci95[0] > 0 && !zeroWidth(lift.ci95)\n ? ('pass' as const)\n : lift.delta > 0\n ? ('warn' as const)\n : ('fail' as const)\n axes.push({\n name: 'quality-lift',\n status: liftPass,\n detail: lift\n ? `delta=${lift.delta.toFixed(3)}, CI95=[${lift.ci95[0].toFixed(3)}, ${lift.ci95[1].toFixed(3)}], n=${lift.n}${lift.decisionEligible ? '' : ` (descriptive only; ${lift.minimumRequired} required)`}`\n : 'no baseline/candidate pair available',\n })\n const contamPass =\n contamination === undefined\n ? ('not_evaluated' as const)\n : contamination.leaks === 0\n ? ('pass' as const)\n : ('fail' as const)\n axes.push({\n name: 'contamination',\n status: contamPass,\n detail: contamination ? `${contamination.leaks} canary leak(s)` : 'no canaries supplied',\n })\n axes.push(\n composite.n === 0\n ? {\n name: 'composite-distribution',\n status: 'not_evaluated',\n detail: 'no task-quality scores available',\n }\n : {\n name: 'composite-distribution',\n status:\n composite.mean !== null && composite.mean >= 0.5\n ? 'pass'\n : composite.mean !== null && composite.mean >= 0.3\n ? 'warn'\n : 'fail',\n detail:\n composite.mean === null || composite.p50 === null || composite.p95 === null\n ? 'task-quality distribution is internally incomplete'\n : `mean=${composite.mean.toFixed(3)}, p50=${composite.p50.toFixed(3)}, p95=${composite.p95.toFixed(3)} over n=${composite.n}`,\n },\n )\n const status = axes.some((a) => a.status === 'fail')\n ? 'fail'\n : axes.some((a) => a.status === 'warn' || a.status === 'not_evaluated')\n ? 'warn'\n : 'pass'\n return {\n status,\n axes,\n issues: [],\n }\n}\n\n// ── Recommendations engine ─────────────────────────────────────────\n\ninterface RecommendationContext {\n composite: ScalarDistribution\n judges: Record<string, JudgeInsight>\n interRater?: InterRaterInsight\n lift?: LiftInsight\n failureClusters?: FailureClusterInsight\n failureClasses?: FailureClassTally[]\n contamination?: InsightReport['contamination']\n outcomeCorrelation?: OutcomeCorrelationInsight\n priorPeriodComparison?: PriorPeriodComparison\n threshold: number\n}\n\nfunction buildRecommendations(ctx: RecommendationContext): Recommendation[] {\n const out: Recommendation[] = []\n\n // Prior-period regressions — highest customer-impact signal when present.\n // \"Did my last change help?\" with a falsifiable answer.\n if (ctx.priorPeriodComparison) {\n const ppc = ctx.priorPeriodComparison\n const label = ppc.windowLabel ?? 'baseline period'\n for (const name of ppc.regressedMetrics) {\n const d = ppc.metrics[name]\n if (d?.status !== 'ok') continue\n out.push({\n priority: 'critical',\n kind: 'investigate',\n title: `${name} regressed from ${d.baseline.toFixed(3)} → ${d.current.toFixed(3)} vs ${label}`,\n detail: `Welch CI95 = [${d.ci95[0].toFixed(3)}, ${d.ci95[1].toFixed(3)}], p=${d.pValue.toFixed(4)}, Cohen's d=${d.cohensD.toFixed(2)} (n_current=${d.currentN}, n_baseline=${d.baselineN}). The regression is statistically significant at p<0.05 with at-least-small effect size.`,\n evidencePath: `priorPeriodComparison.metrics.${name}`,\n })\n }\n for (const name of ppc.improvedMetrics) {\n const d = ppc.metrics[name]\n if (d?.status !== 'ok') continue\n out.push({\n priority: 'low',\n kind: 'ship',\n title: `${name} improved from ${d.baseline.toFixed(3)} → ${d.current.toFixed(3)} vs ${label}`,\n detail: `Welch CI95 = [${d.ci95[0].toFixed(3)}, ${d.ci95[1].toFixed(3)}], p=${d.pValue.toFixed(4)}, Cohen's d=${d.cohensD.toFixed(2)} (n_current=${d.currentN}, n_baseline=${d.baselineN}). Statistically significant improvement worth flagging.`,\n evidencePath: `priorPeriodComparison.metrics.${name}`,\n })\n }\n for (const name of ppc.inconclusiveMetrics) {\n const d = ppc.metrics[name]\n if (!d || d.status === 'ok' || d.delta === 0) continue\n const reason =\n d.status === 'zero-variance'\n ? 'both periods have zero observed variance'\n : 'one or both periods have fewer than two observations'\n out.push({\n priority: 'high',\n kind: 'investigate',\n title: `${name} changed from ${d.baseline.toFixed(3)} → ${d.current.toFixed(3)} vs ${label}; inference unavailable`,\n detail: `Observed delta ${d.delta.toFixed(3)} across n_current=${d.currentN} and n_baseline=${d.baselineN}, but ${reason}. The report does not fabricate a p-value, confidence interval, or effect size; inspect independence and data capture before acting.`,\n evidencePath: `priorPeriodComparison.metrics.${name}`,\n })\n }\n }\n\n // Composite-distribution branch. Fires when the overall quality signal is\n // poor regardless of lift / contamination / clusters — the customer needs\n // to know they have a problem AND which specific runs to inspect.\n if (\n ctx.composite.n > 0 &&\n ctx.composite.mean !== null &&\n ctx.composite.p50 !== null &&\n ctx.composite.p95 !== null\n ) {\n if (ctx.composite.mean < 0.3) {\n const tail = ctx.composite.tailRuns ?? []\n const names = tail\n .slice(0, 5)\n .map((t) => `${t.runId}=${t.score.toFixed(3)}`)\n .join(', ')\n out.push({\n priority: 'critical',\n kind: 'investigate',\n title: `Composite mean ${ctx.composite.mean.toFixed(3)} is below the 0.3 floor — the agent is broken on this corpus`,\n detail:\n tail.length > 0\n ? `Worst ${tail.length} run${tail.length === 1 ? '' : 's'} to inspect first: ${names}. Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`\n : `Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`,\n evidencePath: 'composite.tailRuns',\n })\n } else if (ctx.composite.mean < 0.5) {\n const tail = ctx.composite.tailRuns ?? []\n const names = tail\n .slice(0, 3)\n .map((t) => `${t.runId}=${t.score.toFixed(3)}`)\n .join(', ')\n out.push({\n priority: 'high',\n kind: 'investigate',\n title: `Composite mean ${ctx.composite.mean.toFixed(3)} is below 0.5 — investigate the lower tail before claiming the agent is healthy`,\n detail:\n tail.length > 0\n ? `Worst ${tail.length} run${tail.length === 1 ? '' : 's'}: ${names}. Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`\n : `Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`,\n evidencePath: 'composite.tailRuns',\n })\n }\n }\n\n // A healthy-looking mean can hide a group of failed tasks sharing one\n // producer-reported cause. This path does not require an analyst.\n if (ctx.failureClasses && ctx.failureClasses.length > 0) {\n const top = ctx.failureClasses[0]!\n if (top.count >= 3 && top.share >= 0.15) {\n out.push({\n priority: top.share >= 0.25 ? 'high' : 'medium',\n kind: 'investigate',\n title: `'${top.failureClass}' is the dominant failure class — ${top.count} runs (${(top.share * 100).toFixed(0)}% of the corpus)`,\n detail: `The mean composite can look acceptable while one failure class dominates the lower tail. ${top.count} of ${ctx.composite.n} runs failed with '${top.failureClass}'${ctx.failureClasses.length > 1 ? ` (next: '${ctx.failureClasses[1]!.failureClass}' ×${ctx.failureClasses[1]!.count})` : ''}. Fix this cause first.`,\n evidencePath: 'failureClasses',\n })\n }\n }\n\n // Missing-judges branch. The report can't surface per-dimension or\n // calibration signal when `outcome.judgeScores` is empty across the\n // corpus. Tell the customer how to enrich.\n if (Object.keys(ctx.judges).length === 0 && ctx.composite.n > 0) {\n out.push({\n priority: 'medium',\n kind: 'expand-corpus',\n title: 'No judge scores recorded — per-dimension + calibration insights unavailable',\n detail:\n 'Records have no `outcome.judgeScores`. To unlock perDimension, judges, and calibration, attach a Judge run during your eval pass and populate `outcome.judgeScores.perJudge[judgeName][dimension] = score`. See `docs/insight-report.md` for the expected shape.',\n evidencePath: 'judges',\n })\n }\n\n if (ctx.lift) {\n if (!ctx.lift.decisionEligible) {\n out.push({\n priority: 'high',\n kind: 'expand-corpus',\n title: `Inconclusive — ${ctx.lift.n} paired runs; ${ctx.lift.minimumRequired} required`,\n detail: `The bootstrap interval is descriptive below ${ctx.lift.minimumRequired} paired observations and cannot support a ship decision.`,\n evidencePath: 'lift',\n })\n } else {\n const pairedEffect =\n ctx.lift.cohensD === null ? 'undefined (zero delta variance)' : ctx.lift.cohensD.toFixed(2)\n const pairedP =\n ctx.lift.pValue === null ? 'undefined (zero delta variance)' : ctx.lift.pValue.toFixed(4)\n const requiredRuns =\n ctx.lift.requiredN === null ? 'not estimable' : `~${ctx.lift.requiredN} paired runs`\n // A ZERO-WIDTH interval never reads as \"ship\": n identical paired deltas\n // make every resample identical, so `[g, g]` clears any threshold below g\n // and `[0, 0]` clears any negative `decisionThreshold`, on no spread at\n // all. It falls through to the inconclusive/hold arms, which is where a\n // sample carrying no information about its own error belongs.\n const decisive = !zeroWidth(ctx.lift.ci95) && ctx.lift.ci95[0] > ctx.threshold\n const inconclusive = ctx.lift.ci95[0] <= ctx.threshold && ctx.lift.ci95[1] > ctx.threshold\n if (decisive) {\n out.push({\n priority: 'critical',\n kind: 'ship',\n title: `Ship — lift ${ctx.lift.delta.toFixed(3)} (95% CI ${ctx.lift.ci95[0].toFixed(3)}..${ctx.lift.ci95[1].toFixed(3)})`,\n detail: `Holdout lift exceeds threshold ${ctx.threshold} with 95% bootstrap confidence (n=${ctx.lift.n}, p=${pairedP}, paired d=${pairedEffect}).`,\n evidencePath: 'lift',\n })\n } else if (inconclusive) {\n out.push({\n priority: 'high',\n kind: 'expand-corpus',\n title: `Inconclusive — required sample is ${requiredRuns} (have ${ctx.lift.n}) at current effect size`,\n detail: `CI straddles threshold. Current MDE at 80% power is ${ctx.lift.mde.toFixed(3)}; observed delta is ${ctx.lift.delta.toFixed(3)}.`,\n evidencePath: 'lift',\n })\n } else {\n out.push({\n priority: 'critical',\n kind: 'hold',\n title: `Hold — lift CI lower bound ${ctx.lift.ci95[0].toFixed(3)} is at or below threshold ${ctx.threshold}`,\n detail: `Bootstrap CI provides no statistical evidence the candidate is better. Consider tightening the mutation or expanding the holdout.`,\n evidencePath: 'lift',\n })\n }\n }\n }\n\n if (ctx.contamination && ctx.contamination.leaks > 0) {\n out.push({\n priority: 'critical',\n kind: 'fix',\n title: `${ctx.contamination.leaks} canary leak${ctx.contamination.leaks === 1 ? '' : 's'} detected`,\n detail: `Holdout integrity is compromised. The lift number is unreliable until you investigate.`,\n evidencePath: 'contamination',\n })\n }\n\n if (ctx.interRater && ctx.interRater.kappa < 0.5) {\n out.push({\n priority: 'high',\n kind: 'recalibrate',\n title: `Inter-rater weighted kappa ${ctx.interRater.kappa.toFixed(2)} is below 0.5`,\n detail:\n 'Raters disagree on what good looks like. Review the largest disagreement cases and refine the rubric before automating these decisions.',\n evidencePath: 'interRater',\n })\n }\n\n if (ctx.failureClusters && ctx.failureClusters.clusters.length > 0) {\n const top = ctx.failureClusters.clusters[0]!\n out.push({\n priority: 'high',\n kind: 'investigate',\n title: `Top failure cluster: ${top.name} (${(top.share * 100).toFixed(0)}% of failures)`,\n detail: `${ctx.failureClusters.totalFailures} runs failed. The largest cluster groups ${top.exemplars.length} exemplars under '${top.name}'.`,\n evidencePath: 'failureClusters.clusters[0]',\n })\n }\n\n if (ctx.outcomeCorrelation && Math.abs(ctx.outcomeCorrelation.spearman) < 0.3) {\n out.push({\n priority: 'medium',\n kind: 'recalibrate',\n title: `Judge scores decoupled from ${ctx.outcomeCorrelation.metric} (Spearman ρ=${ctx.outcomeCorrelation.spearman.toFixed(2)})`,\n detail: `Your judges score what they were trained to score, but it isn't predicting downstream ${ctx.outcomeCorrelation.metric}. Consider retraining the judge against ${ctx.outcomeCorrelation.metric} as the gold signal.`,\n evidencePath: 'outcomeCorrelation',\n })\n }\n\n return out\n}\n\n// ── Re-export pareto figure spec for hosted-side rendering ─────────\n\nexport type { ParetoFigureSpec }\n"],"mappings":";;;;;;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ACE;EACF,cAAc;CAChB,CAAC;CAGH,IAAI,IAAI,mBAAmB,IAAI,gBAAgB,SAAS,SAAS,GAAG;EAClE,MAAM,MAAM,IAAI,gBAAgB,SAAS;EACzC,IAAI,KAAK;GACP,UAAU;GACV,MAAM;GACN,OAAO,wBAAwB,IAAI,KAAK,KAAK,IAAI,QAAQ,IAAA,CAAK,QAAQ,CAAC,EAAE;GACzE,QAAQ,GAAG,IAAI,gBAAgB,cAAc,2CAA2C,IAAI,UAAU,OAAO,oBAAoB,IAAI,KAAK;GAC1I,cAAc;EAChB,CAAC;CACH;CAEA,IAAI,IAAI,sBAAsB,KAAK,IAAI,IAAI,mBAAmB,QAAQ,IAAI,IACxE,IAAI,KAAK;EACP,UAAU;EACV,MAAM;EACN,OAAO,+BAA+B,IAAI,mBAAmB,OAAO,eAAe,IAAI,mBAAmB,SAAS,QAAQ,CAAC,EAAE;EAC9H,QAAQ,yFAAyF,IAAI,mBAAmB,OAAO,0CAA0C,IAAI,mBAAmB,OAAO;EACvM,cAAc;CAChB,CAAC;CAGH,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
- import { i as compareCodeUnits } from "./canonical-DPyQ_rpt.js";
2
- import { a as assertValidAnalystUsageReceipt } from "./types-DQ0e2E7y.js";
1
+ import { i as compareCodeUnits } from "./canonical-BsZVgBhW.js";
2
+ import { t as assertValidAnalystUsageReceipt } from "./usage-receipt-Cx3xNeyB.js";
3
3
  import { performance } from "node:perf_hooks";
4
4
  import { linearSumAssignment } from "linear-sum-assignment";
5
5
  //#region src/analyst/benchmark-scoring.ts
@@ -558,4 +558,4 @@ function mergeRegistryUsage(result) {
558
558
  //#endregion
559
559
  export { scoreAnalystFindings as a, summarizeAnalystBenchmarkRunner as i, runAnalystBenchmark as n, traceStoreEvidenceResolver as r, registryBenchmarkRunner as t };
560
560
 
561
- //# sourceMappingURL=benchmark-DQKzykkO.js.map
561
+ //# sourceMappingURL=benchmark-BeQJyrRC.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"benchmark-DQKzykkO.js","names":[],"sources":["../src/analyst/benchmark-scoring.ts","../src/analyst/benchmark-summary.ts","../src/analyst/benchmark.ts"],"sourcesContent":["import { linearSumAssignment } from 'linear-sum-assignment'\nimport type {\n AnalystBenchmarkCase,\n AnalystEvidenceExpectation,\n AnalystFindingScore,\n AnalystIssueExpectation,\n} from './benchmark'\nimport type { AnalystFinding, EvidenceRef } from './types'\n\nexport function scoreAnalystFindings(\n testCase: Pick<AnalystBenchmarkCase, 'id' | 'expectedIssues' | 'labeledEvidence'>,\n findings: readonly AnalystFinding[],\n): AnalystFindingScore {\n assertValidAnalystScoringCase(testCase)\n const matchedFindingByIssue = matchFindingsToIssues(testCase.expectedIssues, findings)\n const matchedIssueIds = testCase.expectedIssues\n .filter((_, index) => matchedFindingByIssue.has(index))\n .map((issue) => issue.id)\n const missedIssueIds = testCase.expectedIssues\n .filter((_, index) => !matchedFindingByIssue.has(index))\n .map((issue) => issue.id)\n const supportedFindingIndexes = new Set(matchedFindingByIssue.values())\n\n const unsupportedFindingIndexes = findings\n .map((_, index) => index)\n .filter((index) => !supportedFindingIndexes.has(index))\n const expectedIssueCount = testCase.expectedIssues.length\n const issueRecall = expectedIssueCount === 0 ? 1 : matchedIssueIds.length / expectedIssueCount\n const findingPrecision =\n findings.length === 0\n ? expectedIssueCount === 0\n ? 1\n : 0\n : supportedFindingIndexes.size / findings.length\n const f1 = harmonicMeanScore(findingPrecision, issueRecall)\n const allEvidence = findings.flatMap((finding) => finding.evidence_refs)\n\n const criticalIssues = testCase.expectedIssues.filter(\n (issue) => (issue.criticalEvidence?.length ?? 0) > 0,\n )\n const criticalHits = testCase.expectedIssues.filter((issue) => {\n if ((issue.criticalEvidence?.length ?? 0) === 0) return false\n return matchesEvidence(allEvidence, issue.criticalEvidence ?? [], 'any')\n }).length\n\n const findingsWithEvidence = findings.filter((finding) => finding.evidence_refs.length > 0).length\n const unlabeledEvidence = testCase.labeledEvidence\n ? allEvidence.filter(\n (ref) => !testCase.labeledEvidence!.some((expected) => evidenceMatches(ref, expected)),\n )\n : []\n\n return {\n expectedIssueCount,\n matchedIssueIds,\n missedIssueIds,\n supportedFindingIndexes: [...supportedFindingIndexes].sort((a, b) => a - b),\n unsupportedFindingIndexes,\n unlabeledEvidence,\n issueRecall,\n findingPrecision,\n f1,\n criticalStepAccuracy: criticalIssues.length === 0 ? null : criticalHits / criticalIssues.length,\n citationCoverage: findings.length === 0 ? null : findingsWithEvidence / findings.length,\n citationExcerptCoverage:\n allEvidence.length === 0\n ? null\n : allEvidence.filter((evidence) => Boolean(evidence.excerpt?.trim())).length /\n allEvidence.length,\n citationLabelAgreement:\n testCase.labeledEvidence === undefined\n ? null\n : allEvidence.length === 0\n ? findings.length === 0\n ? null\n : 0\n : (allEvidence.length - unlabeledEvidence.length) / allEvidence.length,\n predictionOnLabelEmptyCase: expectedIssueCount === 0 && findings.length > 0,\n }\n}\n\nexport function assertValidAnalystScoringCase(\n testCase: Pick<AnalystBenchmarkCase, 'id' | 'expectedIssues' | 'labeledEvidence'>,\n): void {\n if (!testCase.id.trim()) throw new TypeError('analyst benchmark case id must not be empty')\n const ids = new Set<string>()\n for (const issue of testCase.expectedIssues) {\n if (!issue.id.trim()) throw new TypeError(`${testCase.id}: expected issue id must not be empty`)\n if (ids.has(issue.id)) {\n throw new TypeError(`${testCase.id}: duplicate expected issue id '${issue.id}'`)\n }\n ids.add(issue.id)\n if (\n !issue.findingIds?.length &&\n !issue.areas?.length &&\n !issue.subjects?.length &&\n !issue.evidence?.length\n ) {\n throw new TypeError(\n `${testCase.id}/${issue.id}: expected issue must identify a finding by id, area, subject, or evidence`,\n )\n }\n }\n for (const ref of testCase.labeledEvidence ?? []) {\n if (!ref.uri.trim()) {\n throw new TypeError(`${testCase.id}: labeled evidence URI must not be empty`)\n }\n }\n}\n\nexport function harmonicMeanScore(a: number, b: number): number {\n return a + b === 0 ? 0 : (2 * a * b) / (a + b)\n}\n\nfunction matchFindingsToIssues(\n issues: readonly AnalystIssueExpectation[],\n findings: readonly AnalystFinding[],\n): Map<number, number> {\n if (issues.length === 0) return new Map()\n const cardinalityWeight = issues.length + 1\n const scores = issues.map((issue) => [\n ...findings.map((finding) => {\n if (!findingMatchesIssue(finding, issue)) return -1\n const criticalHit =\n (issue.criticalEvidence?.length ?? 0) > 0 &&\n matchesEvidence(finding.evidence_refs, issue.criticalEvidence ?? [], 'any')\n return cardinalityWeight + Number(criticalHit)\n }),\n ...Array.from({ length: issues.length }, () => 0),\n ])\n const assignment = linearSumAssignment(scores, { maximaze: true }).rowAssignments\n const matches = new Map<number, number>()\n for (const [issueIndex, column] of assignment.entries()) {\n if (column < 0 || column >= findings.length) continue\n if (!findingMatchesIssue(findings[column]!, issues[issueIndex]!)) continue\n matches.set(issueIndex, column)\n }\n return matches\n}\n\nfunction findingMatchesIssue(finding: AnalystFinding, issue: AnalystIssueExpectation): boolean {\n if (issue.findingIds && !issue.findingIds.includes(finding.finding_id)) return false\n if (issue.areas && !issue.areas.includes(finding.area)) return false\n if (issue.subjects && (!finding.subject || !issue.subjects.includes(finding.subject))) {\n return false\n }\n if (\n issue.evidence &&\n !matchesEvidence(finding.evidence_refs, issue.evidence, issue.evidenceMode ?? 'any')\n ) {\n return false\n }\n return true\n}\n\nfunction matchesEvidence(\n actual: readonly EvidenceRef[],\n expected: readonly AnalystEvidenceExpectation[],\n mode: 'any' | 'all',\n): boolean {\n if (expected.length === 0) return true\n const match = (target: AnalystEvidenceExpectation) =>\n actual.some((ref) => evidenceMatches(ref, target))\n return mode === 'all' ? expected.every(match) : expected.some(match)\n}\n\nfunction evidenceMatches(actual: EvidenceRef, expected: AnalystEvidenceExpectation): boolean {\n return (\n actual.uri === expected.uri && (expected.kind === undefined || actual.kind === expected.kind)\n )\n}\n","import { compareCodeUnits } from '../ledger-core/canonical'\nimport type {\n AnalystBenchmarkObservation,\n AnalystBenchmarkSummary,\n AnalystLatencyDistribution,\n} from './benchmark'\n\nimport { harmonicMeanScore } from './benchmark-scoring'\n\nexport function summarizeAnalystBenchmarkRunner(\n runnerId: string,\n observations: readonly AnalystBenchmarkObservation[],\n): AnalystBenchmarkSummary {\n const issueBearing = observations.filter((observation) => observation.labelState === 'positive')\n const completed = observations.filter((observation) => !observation.error)\n const expectedIssues = issueBearing.reduce(\n (sum, observation) => sum + observation.score.expectedIssueCount,\n 0,\n )\n const matchedIssues = issueBearing.reduce(\n (sum, observation) => sum + observation.score.matchedIssueIds.length,\n 0,\n )\n const issueFindings = issueBearing.reduce(\n (sum, observation) => sum + (observation.error ? 0 : observation.findings.length),\n 0,\n )\n const supportedFindings = issueBearing.reduce(\n (sum, observation) => sum + observation.score.supportedFindingIndexes.length,\n 0,\n )\n const issueRecall = expectedIssues === 0 ? null : matchedIssues / expectedIssues\n const findingPrecision =\n expectedIssues === 0 ? null : issueFindings === 0 ? 0 : supportedFindings / issueFindings\n const macroIssueRecall =\n issueBearing.length === 0\n ? null\n : mean(issueBearing.map((observation) => observation.score.issueRecall))\n const macroFindingPrecision =\n issueBearing.length === 0\n ? null\n : mean(issueBearing.map((observation) => observation.score.findingPrecision))\n const macroF1 =\n issueBearing.length === 0 ? null : mean(issueBearing.map((observation) => observation.score.f1))\n const critical = observations\n .map((observation) => observation.score.criticalStepAccuracy)\n .filter((value): value is number => value !== null)\n const findingsWithEvidence = completed.reduce(\n (sum, observation) =>\n sum + observation.findings.filter((finding) => finding.evidence_refs.length > 0).length,\n 0,\n )\n const allFindings = completed.reduce((sum, observation) => sum + observation.findings.length, 0)\n const allCitations = completed.flatMap((observation) =>\n observation.findings.flatMap((finding) => finding.evidence_refs),\n )\n const citationObservations = completed.filter(\n (observation) => observation.score.citationLabelAgreement !== null,\n )\n const citationCount = citationObservations.reduce(\n (sum, observation) =>\n sum +\n observation.findings.reduce((count, finding) => count + finding.evidence_refs.length, 0),\n 0,\n )\n const invalidCitationCount = citationObservations.reduce(\n (sum, observation) => sum + observation.score.unlabeledEvidence.length,\n 0,\n )\n const trustedNegative = observations.filter(\n (observation) => observation.labelState === 'trusted-negative',\n )\n const completedTrustedNegative = trustedNegative.filter((observation) => !observation.error)\n const unlabeled = observations.filter((observation) => observation.labelState === 'unlabeled')\n const completedUnlabeled = unlabeled.filter((observation) => !observation.error)\n const resolvedCitations = completed.reduce(\n (sum, observation) => sum + (observation.evidenceResolution?.resolved ?? 0),\n 0,\n )\n const unresolvedCitations = completed.reduce(\n (sum, observation) => sum + (observation.evidenceResolution?.unresolvedEvidence.length ?? 0),\n 0,\n )\n const citationResolutionErrors = completed.reduce(\n (sum, observation) => sum + (observation.evidenceResolution?.errors.length ?? 0),\n 0,\n )\n const resolutionAttempts = completed.filter((observation) =>\n observation.findings.some((finding) => finding.evidence_refs.length > 0),\n )\n const citationResolutionUnknownRuns = resolutionAttempts.filter(\n (observation) =>\n !observation.evidenceResolution || observation.evidenceResolution.errors.length > 0,\n ).length\n const usages = observations.map((observation) => observation.usage)\n const knownCostUsd = stableSum(\n usages.map((usage) => {\n if (!usage) return 0\n return usage.cost.kind === 'uncaptured' ? (usage.knownCostUsd ?? 0) : usage.cost.usd\n }),\n )\n const predictionAgreement = repeatedObservationAgreement(observations, predictionSignature)\n const matchedLabelAgreement = repeatedObservationAgreement(\n observations.filter((observation) => observation.labelState === 'positive'),\n matchedLabelSignature,\n )\n return {\n runnerId,\n plannedRuns: observations.length,\n completedRuns: observations.filter((observation) => !observation.error).length,\n failedRuns: observations.filter((observation) => Boolean(observation.error)).length,\n issueBearingRuns: issueBearing.length,\n trustedNegativeRuns: trustedNegative.length,\n unlabeledRuns: unlabeled.length,\n issueRecall,\n findingPrecision,\n f1:\n findingPrecision === null || issueRecall === null\n ? null\n : harmonicMeanScore(findingPrecision, issueRecall),\n macroIssueRecall,\n macroFindingPrecision,\n macroF1,\n criticalStepAccuracy: critical.length === 0 ? null : mean(critical),\n citationCoverage: allFindings === 0 ? null : findingsWithEvidence / allFindings,\n citationExcerptCoverage:\n allCitations.length === 0\n ? null\n : allCitations.filter((evidence) => Boolean(evidence.excerpt?.trim())).length /\n allCitations.length,\n citationLabelAgreement:\n citationObservations.length === 0\n ? null\n : citationCount === 0\n ? 0\n : (citationCount - invalidCitationCount) / citationCount,\n citationResolution:\n resolutionAttempts.length === 0 ||\n citationResolutionUnknownRuns > 0 ||\n resolvedCitations + unresolvedCitations === 0\n ? null\n : resolvedCitations / (resolvedCitations + unresolvedCitations),\n citationResolutionUnknownRuns,\n unresolvedCitations,\n citationResolutionErrors,\n trustedNegativeFalsePositiveRate:\n completedTrustedNegative.length === 0\n ? null\n : completedTrustedNegative.filter(\n (observation) => observation.score.predictionOnLabelEmptyCase,\n ).length / completedTrustedNegative.length,\n trustedNegativeFailureRate:\n trustedNegative.length === 0\n ? null\n : trustedNegative.filter((observation) => Boolean(observation.error)).length /\n trustedNegative.length,\n unlabeledPredictionRate:\n completedUnlabeled.length === 0\n ? null\n : completedUnlabeled.filter((observation) => observation.findings.length > 0).length /\n completedUnlabeled.length,\n unlabeledFailureRate:\n unlabeled.length === 0\n ? null\n : unlabeled.filter((observation) => Boolean(observation.error)).length / unlabeled.length,\n predictionAgreement: predictionAgreement.value,\n predictionAgreementCases: predictionAgreement.cases,\n matchedLabelAgreement: matchedLabelAgreement.value,\n matchedLabelAgreementCases: matchedLabelAgreement.cases,\n latencyMs: latencyDistribution(\n observations\n .map((observation) => observation.latencyMs)\n .filter((value): value is number => value !== null),\n ),\n benchmarkClockLatencyRuns: observations.filter(\n (observation) => observation.latencySource === 'benchmark-clock',\n ).length,\n runnerReportedLatencyRuns: observations.filter(\n (observation) => observation.latencySource === 'runner-reported',\n ).length,\n latencyUnknownRuns: observations.filter(\n (observation) => observation.latencySource === 'uncaptured',\n ).length,\n calls: usages.reduce((sum, usage) => sum + (usage?.calls ?? 0), 0),\n callsUnknownRuns: usages.filter((usage) => !usage || usage.calls === null).length,\n inputTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.input ?? 0), 0),\n outputTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.output ?? 0), 0),\n reasoningTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.reasoning ?? 0), 0),\n cachedTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.cached ?? 0), 0),\n cacheWriteTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.cacheWrite ?? 0), 0),\n tokenUsageUnknownRuns: usages.filter((usage) => !usage?.tokens).length,\n reasoningTokenUsageUnknownRuns: usages.filter((usage) => usage?.tokens?.reasoning === undefined)\n .length,\n cachedTokenUsageUnknownRuns: usages.filter((usage) => usage?.tokens?.cached === undefined)\n .length,\n cacheWriteTokenUsageUnknownRuns: usages.filter(\n (usage) => usage?.tokens?.cacheWrite === undefined,\n ).length,\n knownCostUsd,\n costUnknownRuns: usages.filter((usage) => !usage || usage.cost.kind === 'uncaptured').length,\n }\n}\n\nfunction mean(values: readonly number[]): number {\n return values.length === 0 ? 0 : stableSum(values) / values.length\n}\n\nfunction stableSum(values: readonly number[]): number {\n const ordered = [...values].sort(\n (left, right) => Math.abs(left) - Math.abs(right) || left - right,\n )\n let sum = 0\n let correction = 0\n for (const value of ordered) {\n const next = sum + value\n correction += Math.abs(sum) >= Math.abs(value) ? sum - next + value : value - next + sum\n sum = next\n }\n return sum + correction\n}\n\nfunction latencyDistribution(values: readonly number[]): AnalystLatencyDistribution | null {\n if (values.length === 0) return null\n const sorted = [...values].sort((a, b) => a - b)\n return {\n min: sorted[0]!,\n mean: mean(sorted),\n p50: percentile(sorted, 0.5),\n p95: percentile(sorted, 0.95),\n max: sorted.at(-1)!,\n }\n}\n\nfunction percentile(sorted: readonly number[], quantile: number): number {\n if (sorted.length === 0) return 0\n return sorted[Math.ceil(quantile * sorted.length) - 1] ?? sorted.at(-1) ?? 0\n}\n\nfunction repeatedObservationAgreement(\n observations: readonly AnalystBenchmarkObservation[],\n signature: (observation: AnalystBenchmarkObservation) => readonly string[],\n): { value: number | null; cases: number } {\n const byCase = new Map<string, AnalystBenchmarkObservation[]>()\n for (const observation of observations) {\n const rows = byCase.get(observation.caseId) ?? []\n rows.push(observation)\n byCase.set(observation.caseId, rows)\n }\n const caseAgreements: number[] = []\n for (const rows of byCase.values()) {\n const agreements: number[] = []\n for (let left = 0; left < rows.length; left++) {\n for (let right = left + 1; right < rows.length; right++) {\n agreements.push(jaccard(signature(rows[left]!), signature(rows[right]!)))\n }\n }\n if (agreements.length > 0) caseAgreements.push(mean(agreements))\n }\n return {\n value: caseAgreements.length === 0 ? null : mean(caseAgreements),\n cases: caseAgreements.length,\n }\n}\n\nfunction matchedLabelSignature(observation: AnalystBenchmarkObservation): readonly string[] {\n if (observation.error) return [`error:${observation.error.class}`]\n return observation.score.matchedIssueIds\n}\n\nfunction predictionSignature(observation: AnalystBenchmarkObservation): readonly string[] {\n if (observation.error) return [`error:${observation.error.class}`]\n return observation.findings\n .map((finding) =>\n JSON.stringify([\n finding.finding_id,\n finding.evidence_refs\n .map((evidence) => [evidence.kind, evidence.uri, evidence.excerpt ?? null])\n .sort((left, right) => compareCodeUnits(JSON.stringify(left), JSON.stringify(right))),\n ]),\n )\n .sort()\n}\n\nfunction jaccard(left: readonly string[], right: readonly string[]): number {\n const a = new Set(left)\n const b = new Set(right)\n const union = new Set([...a, ...b])\n if (union.size === 0) return 1\n let intersection = 0\n for (const value of a) if (b.has(value)) intersection += 1\n return intersection / union.size\n}\n","import { performance } from 'node:perf_hooks'\nimport type { TraceAnalysisStore } from '../trace-analyst/store'\nimport { assertValidAnalystScoringCase, scoreAnalystFindings } from './benchmark-scoring'\nimport { summarizeAnalystBenchmarkRunner } from './benchmark-summary'\nimport type { AnalystRegistry, RegistryRunOpts } from './registry'\nimport type {\n AnalystFinding,\n AnalystRunInputs,\n AnalystRunResult,\n AnalystUsageReceipt,\n EvidenceRef,\n} from './types'\nimport { assertValidAnalystUsageReceipt } from './usage-receipt'\n\nexport { scoreAnalystFindings } from './benchmark-scoring'\n\nexport interface AnalystEvidenceExpectation {\n uri: string\n kind?: EvidenceRef['kind']\n}\n\nexport interface AnalystIssueExpectation {\n id: string\n findingIds?: readonly string[]\n areas?: readonly string[]\n subjects?: readonly string[]\n evidence?: readonly AnalystEvidenceExpectation[]\n evidenceMode?: 'any' | 'all'\n /** Exact evidence location for the first unrecoverable or causal step. */\n criticalEvidence?: readonly AnalystEvidenceExpectation[]\n}\n\nexport type AnalystBenchmarkLabelState = 'positive' | 'trusted-negative' | 'unlabeled'\n\nexport interface AnalystBenchmarkCase<TInput = unknown> {\n id: string\n /** Independent source unit used for resampling, such as a task or incident. */\n clusterId: string\n /** Whether labels prove an issue, prove no issue, or leave the outcome unknown. */\n labelState: AnalystBenchmarkLabelState\n input: TInput\n expectedIssues: readonly AnalystIssueExpectation[]\n /** Complete set of labeled locations used to measure label-location agreement. */\n labeledEvidence?: readonly AnalystEvidenceExpectation[]\n tags?: readonly string[]\n metadata?: Record<string, unknown>\n}\n\nexport interface AnalystFindingScore {\n expectedIssueCount: number\n matchedIssueIds: string[]\n missedIssueIds: string[]\n supportedFindingIndexes: number[]\n unsupportedFindingIndexes: number[]\n unlabeledEvidence: EvidenceRef[]\n issueRecall: number\n findingPrecision: number\n f1: number\n criticalStepAccuracy: number | null\n /** Share of findings that cite at least one evidence location. */\n citationCoverage: number | null\n /** Share of citations that include a non-empty source excerpt. */\n citationExcerptCoverage: number | null\n /** Share of citations that agree with a labeled case location. */\n citationLabelAgreement: number | null\n predictionOnLabelEmptyCase: boolean\n}\n\nexport interface AnalystEvidenceResolutionError {\n evidence: EvidenceRef\n class: string\n message: string\n}\n\nexport interface AnalystEvidenceResolution {\n checked: number\n resolved: number\n unresolvedEvidence: EvidenceRef[]\n errors: AnalystEvidenceResolutionError[]\n /** Null when no citations were checked or any resolution attempt failed. */\n validity: number | null\n}\n\nexport type AnalystEvidenceResolver<TInput = unknown> = (input: {\n caseId: string\n caseInput: TInput\n evidence: EvidenceRef\n signal?: AbortSignal\n}) => boolean | Promise<boolean>\n\n/**\n * Resolve canonical `trace://<trace>/span/<span>` evidence against a trace store.\n * Other evidence kinds and URI schemes require a caller-supplied resolver.\n */\nexport function traceStoreEvidenceResolver<TInput>(\n getStore: (input: TInput) => TraceAnalysisStore,\n): AnalystEvidenceResolver<TInput> {\n return async ({ caseInput, evidence, signal }) => {\n if (evidence.kind !== 'span') return false\n const location = parseTraceSpanUri(evidence.uri)\n if (!location) return false\n const result = await getStore(caseInput).viewSpans(\n {\n trace_id: location.traceId,\n span_ids: [location.spanId],\n },\n signal ? { signal } : undefined,\n )\n return (\n result.trace_id === location.traceId &&\n result.missing_span_ids.length === 0 &&\n result.spans.some((span) => span.span_id === location.spanId)\n )\n }\n}\n\nexport interface AnalystBenchmarkOutput {\n findings: readonly AnalystFinding[]\n usage?: AnalystUsageReceipt\n metadata?: Record<string, unknown>\n /**\n * End-to-end duration measured by an external runner before import.\n * Use null when the source explicitly did not capture duration.\n */\n observedLatencyMs?: number | null\n /** Marks a completed transport as a failed analyst run while retaining usage and metadata. */\n error?: AnalystBenchmarkError\n}\n\nexport interface AnalystBenchmarkError {\n class: string\n message: string\n code?: string\n status?: number\n}\n\nexport interface AnalystBenchmarkRunner<TInput = unknown> {\n id: string\n analyze(\n input: TInput,\n context: { caseId: string; repetition: number; signal?: AbortSignal },\n ): AnalystBenchmarkOutput | Promise<AnalystBenchmarkOutput>\n}\n\nexport interface AnalystBenchmarkObservation {\n runnerId: string\n caseId: string\n clusterId: string\n labelState: AnalystBenchmarkLabelState\n repetition: number\n executionIndex: number\n latencyMs: number | null\n latencySource: 'benchmark-clock' | 'runner-reported' | 'uncaptured'\n findings: readonly AnalystFinding[]\n score: AnalystFindingScore\n evidenceResolution?: AnalystEvidenceResolution\n caseTags: readonly string[]\n caseMetadata?: Record<string, unknown>\n usage?: AnalystUsageReceipt\n runnerMetadata?: Record<string, unknown>\n error?: AnalystBenchmarkError\n}\n\nexport interface AnalystLatencyDistribution {\n min: number\n mean: number\n p50: number\n p95: number\n max: number\n}\n\nexport interface AnalystBenchmarkSummary {\n runnerId: string\n plannedRuns: number\n completedRuns: number\n failedRuns: number\n issueBearingRuns: number\n trustedNegativeRuns: number\n unlabeledRuns: number\n /** Pooled across all labeled issues and findings. */\n issueRecall: number | null\n /** Pooled across all labeled issues and findings. */\n findingPrecision: number | null\n /** Harmonic mean of the pooled precision and recall. */\n f1: number | null\n /** Mean of per-case recall over issue-bearing runs. */\n macroIssueRecall: number | null\n /** Mean of per-case precision over issue-bearing runs. */\n macroFindingPrecision: number | null\n /** Mean of per-case F1 over issue-bearing runs. */\n macroF1: number | null\n criticalStepAccuracy: number | null\n citationCoverage: number | null\n citationExcerptCoverage: number | null\n citationLabelAgreement: number | null\n citationResolution: number | null\n citationResolutionUnknownRuns: number\n unresolvedCitations: number\n citationResolutionErrors: number\n trustedNegativeFalsePositiveRate: number | null\n trustedNegativeFailureRate: number | null\n unlabeledPredictionRate: number | null\n unlabeledFailureRate: number | null\n /** Primary repeatability measure over complete finding identity and evidence. */\n predictionAgreement: number | null\n /** Repeated cases contributing equally to predictionAgreement. */\n predictionAgreementCases: number\n /** Secondary repeatability detail over matched expected labels. */\n matchedLabelAgreement: number | null\n /** Positive repeated cases contributing equally to matchedLabelAgreement. */\n matchedLabelAgreementCases: number\n latencyMs: AnalystLatencyDistribution | null\n benchmarkClockLatencyRuns: number\n runnerReportedLatencyRuns: number\n latencyUnknownRuns: number\n calls: number\n callsUnknownRuns: number\n inputTokens: number\n outputTokens: number\n reasoningTokens: number\n cachedTokens: number\n cacheWriteTokens: number\n tokenUsageUnknownRuns: number\n reasoningTokenUsageUnknownRuns: number\n cachedTokenUsageUnknownRuns: number\n cacheWriteTokenUsageUnknownRuns: number\n knownCostUsd: number\n costUnknownRuns: number\n}\n\nexport interface AnalystBenchmarkDatasetRef {\n id: string\n revision: string\n split?: string\n}\n\nexport interface AnalystBenchmarkDescriptor {\n id?: string\n dataset?: AnalystBenchmarkDatasetRef\n command?: string\n environment?: Record<string, string>\n metadata?: Record<string, unknown>\n}\n\nexport interface AnalystBenchmarkProvenance extends AnalystBenchmarkDescriptor {\n startedAt: string\n endedAt: string\n caseCount: number\n runnerIds: string[]\n repetitions: number\n maxConcurrency: number\n runnerOrderSeed: number\n}\n\nexport interface AnalystBenchmarkResult {\n provenance: AnalystBenchmarkProvenance\n observations: AnalystBenchmarkObservation[]\n summaries: AnalystBenchmarkSummary[]\n}\n\nexport interface RunAnalystBenchmarkOptions<TInput> {\n cases: readonly AnalystBenchmarkCase<TInput>[]\n runners: readonly AnalystBenchmarkRunner<TInput>[]\n repetitions?: number\n maxConcurrency?: number\n runnerOrderSeed?: number\n resolveEvidence?: AnalystEvidenceResolver<TInput>\n benchmark?: AnalystBenchmarkDescriptor\n /** Previously persisted rows. Exact case, runner, repetition, and execution identities are required. */\n initialObservations?: readonly AnalystBenchmarkObservation[]\n onObservation?: (observation: AnalystBenchmarkObservation) => void | Promise<void>\n signal?: AbortSignal\n}\n\nexport async function runAnalystBenchmark<TInput>(\n options: RunAnalystBenchmarkOptions<TInput>,\n): Promise<AnalystBenchmarkResult> {\n validateBenchmarkOptions(options)\n const startedAt = new Date().toISOString()\n const repetitions = options.repetitions ?? 1\n const runnerOrderSeed = options.runnerOrderSeed ?? 0\n const allJobs = benchmarkJobs(options.cases, options.runners, repetitions, runnerOrderSeed)\n const maxConcurrency = Math.min(options.maxConcurrency ?? 1, allJobs.length)\n const initialObservations = validateInitialObservations(\n options.initialObservations ?? [],\n allJobs,\n )\n const completed = new Set(initialObservations.map(observationKey))\n const jobs = allJobs.filter((job) => !completed.has(jobKey(job)))\n const observations: AnalystBenchmarkObservation[] = [...initialObservations]\n let cursor = 0\n const worker = async (): Promise<void> => {\n while (cursor < jobs.length) {\n options.signal?.throwIfAborted()\n const job = jobs[cursor++]!\n const observation = await runBenchmarkJob(job, options.signal, options.resolveEvidence)\n options.signal?.throwIfAborted()\n await options.onObservation?.(observation)\n options.signal?.throwIfAborted()\n observations.push(observation)\n }\n }\n await Promise.all(Array.from({ length: Math.min(maxConcurrency, jobs.length) }, worker))\n options.signal?.throwIfAborted()\n const runnerOrder = new Map(options.runners.map((runner, index) => [runner.id, index]))\n const caseOrder = new Map(options.cases.map((testCase, index) => [testCase.id, index]))\n observations.sort(\n (a, b) =>\n (runnerOrder.get(a.runnerId) ?? 0) - (runnerOrder.get(b.runnerId) ?? 0) ||\n (caseOrder.get(a.caseId) ?? 0) - (caseOrder.get(b.caseId) ?? 0) ||\n a.repetition - b.repetition,\n )\n return {\n provenance: {\n ...options.benchmark,\n startedAt,\n endedAt: new Date().toISOString(),\n caseCount: options.cases.length,\n runnerIds: options.runners.map((runner) => runner.id),\n repetitions,\n maxConcurrency,\n runnerOrderSeed,\n },\n observations,\n summaries: options.runners.map((runner) =>\n summarizeAnalystBenchmarkRunner(\n runner.id,\n observations.filter((observation) => observation.runnerId === runner.id),\n ),\n ),\n }\n}\n\nexport function registryBenchmarkRunner(options: {\n id: string\n registry: AnalystRegistry\n runOptions?: Omit<RegistryRunOpts, 'signal'>\n /** Count any selected analyst failure as a failed benchmark run. */\n failOnAnalystFailure?: boolean\n}): AnalystBenchmarkRunner<AnalystRunInputs> {\n return {\n id: options.id,\n async analyze(input, context) {\n const result = await options.registry.run(\n `${options.id}:${context.caseId}:${context.repetition}`,\n input,\n { ...options.runOptions, signal: context.signal },\n )\n return {\n findings: result.findings,\n usage: mergeRegistryUsage(result),\n metadata: { analystRun: result },\n ...(options.failOnAnalystFailure ? { error: registryRunFailure(result) } : {}),\n }\n },\n }\n}\n\nasync function runBenchmarkJob<TInput>(\n job: {\n runner: AnalystBenchmarkRunner<TInput>\n testCase: AnalystBenchmarkCase<TInput>\n repetition: number\n executionIndex: number\n },\n signal?: AbortSignal,\n resolveEvidence?: AnalystEvidenceResolver<TInput>,\n): Promise<AnalystBenchmarkObservation> {\n const started = performance.now()\n try {\n const output = await job.runner.analyze(job.testCase.input, {\n caseId: job.testCase.id,\n repetition: job.repetition,\n signal,\n })\n if (output.usage) {\n assertValidAnalystUsageReceipt(output.usage, 'analyst benchmark usage')\n }\n const benchmarkLatencyMs = performance.now() - started\n const latency = resolveBenchmarkLatency(output.observedLatencyMs, benchmarkLatencyMs)\n const scoredFindings = output.error ? [] : output.findings\n return {\n runnerId: job.runner.id,\n caseId: job.testCase.id,\n clusterId: job.testCase.clusterId,\n labelState: job.testCase.labelState,\n repetition: job.repetition,\n executionIndex: job.executionIndex,\n latencyMs: latency.value,\n latencySource: latency.source,\n findings: output.findings,\n score: scoreAnalystFindings(job.testCase, scoredFindings),\n evidenceResolution: resolveEvidence\n ? await resolveFindingEvidence(job.testCase, output.findings, resolveEvidence, signal)\n : undefined,\n caseTags: [...(job.testCase.tags ?? [])],\n caseMetadata: job.testCase.metadata,\n usage: output.usage,\n runnerMetadata: output.metadata,\n ...(output.error ? { error: output.error } : {}),\n }\n } catch (error) {\n if (signal?.aborted) throw error\n const findings: AnalystFinding[] = []\n return {\n runnerId: job.runner.id,\n caseId: job.testCase.id,\n clusterId: job.testCase.clusterId,\n labelState: job.testCase.labelState,\n repetition: job.repetition,\n executionIndex: job.executionIndex,\n latencyMs: performance.now() - started,\n latencySource: 'benchmark-clock',\n findings,\n score: scoreAnalystFindings(job.testCase, findings),\n caseTags: [...(job.testCase.tags ?? [])],\n caseMetadata: job.testCase.metadata,\n error: {\n class: error instanceof Error ? error.constructor.name : 'Error',\n message: error instanceof Error ? error.message : String(error),\n },\n }\n }\n}\n\nfunction resolveBenchmarkLatency(\n observedLatencyMs: number | null | undefined,\n fallbackMs: number,\n): {\n value: number | null\n source: AnalystBenchmarkObservation['latencySource']\n} {\n if (observedLatencyMs === undefined) {\n return { value: fallbackMs, source: 'benchmark-clock' }\n }\n if (observedLatencyMs === null) return { value: null, source: 'uncaptured' }\n if (!Number.isFinite(observedLatencyMs) || observedLatencyMs < 0) {\n throw new RangeError('analyst benchmark observedLatencyMs must be finite and non-negative')\n }\n return { value: observedLatencyMs, source: 'runner-reported' }\n}\n\nfunction registryRunFailure(result: AnalystRunResult): AnalystBenchmarkOutput['error'] | undefined {\n const failed = result.per_analyst.filter((summary) => summary.status === 'failed')\n if (failed.length === 0) return undefined\n return {\n class: 'AnalystRunFailure',\n message: failed\n .map(\n (summary) =>\n `${summary.analyst_id}: ${summary.error?.class ?? 'Error'}: ${summary.error?.message ?? 'analyst failed'}`,\n )\n .join('; '),\n }\n}\n\nfunction benchmarkJobs<TInput>(\n cases: readonly AnalystBenchmarkCase<TInput>[],\n runners: readonly AnalystBenchmarkRunner<TInput>[],\n repetitions: number,\n runnerOrderSeed: number,\n): Array<{\n runner: AnalystBenchmarkRunner<TInput>\n testCase: AnalystBenchmarkCase<TInput>\n repetition: number\n executionIndex: number\n}> {\n const seededRunners = [...runners].sort(\n (left, right) =>\n stableHash(`${runnerOrderSeed}\\u0000${left.id}`) -\n stableHash(`${runnerOrderSeed}\\u0000${right.id}`) || left.id.localeCompare(right.id),\n )\n let executionIndex = 0\n return cases.flatMap((testCase, caseIndex) =>\n Array.from({ length: repetitions }, (_, repetition) => {\n const blockIndex = caseIndex * repetitions + repetition\n const rotation = blockIndex % seededRunners.length\n const ordered = [...seededRunners.slice(rotation), ...seededRunners.slice(0, rotation)]\n return ordered.map((runner) => ({\n runner,\n testCase,\n repetition,\n executionIndex: executionIndex++,\n }))\n }).flat(),\n )\n}\n\nfunction validateInitialObservations<TInput>(\n observations: readonly AnalystBenchmarkObservation[],\n jobs: readonly {\n runner: AnalystBenchmarkRunner<TInput>\n testCase: AnalystBenchmarkCase<TInput>\n repetition: number\n executionIndex: number\n }[],\n): AnalystBenchmarkObservation[] {\n const expected = new Map(jobs.map((job) => [jobKey(job), job]))\n const seen = new Set<string>()\n return observations.map((observation) => {\n const key = observationKey(observation)\n if (seen.has(key)) {\n throw new TypeError(\n `duplicate initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`,\n )\n }\n seen.add(key)\n const job = expected.get(key)\n if (!job) {\n throw new TypeError(\n `initial analyst benchmark observation does not match a planned job: '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`,\n )\n }\n if (observation.executionIndex !== job.executionIndex) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has executionIndex ${observation.executionIndex}; expected ${job.executionIndex}`,\n )\n }\n if (\n observation.clusterId !== job.testCase.clusterId ||\n observation.labelState !== job.testCase.labelState\n ) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' does not match the current case labels`,\n )\n }\n if (\n JSON.stringify(observation.caseTags) !== JSON.stringify(job.testCase.tags ?? []) ||\n JSON.stringify(observation.caseMetadata) !== JSON.stringify(job.testCase.metadata)\n ) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' does not match the current case metadata`,\n )\n }\n const expectedScore = scoreAnalystFindings(\n job.testCase,\n observation.error ? [] : observation.findings,\n )\n if (JSON.stringify(observation.score) !== JSON.stringify(expectedScore)) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has stale or invalid scores`,\n )\n }\n if (observation.usage) {\n assertValidAnalystUsageReceipt(\n observation.usage,\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' usage`,\n )\n }\n if (\n !['benchmark-clock', 'runner-reported', 'uncaptured'].includes(observation.latencySource) ||\n (observation.latencySource === 'uncaptured' && observation.latencyMs !== null) ||\n (observation.latencySource !== 'uncaptured' &&\n (observation.latencyMs === null ||\n !Number.isFinite(observation.latencyMs) ||\n observation.latencyMs < 0))\n ) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has invalid latency`,\n )\n }\n return { ...observation }\n })\n}\n\nfunction jobKey(job: {\n runner: { id: string }\n testCase: { id: string }\n repetition: number\n}): string {\n return `${job.runner.id}\\u0000${job.testCase.id}\\u0000${job.repetition}`\n}\n\nfunction observationKey(observation: {\n runnerId: string\n caseId: string\n repetition: number\n}): string {\n return `${observation.runnerId}\\u0000${observation.caseId}\\u0000${observation.repetition}`\n}\n\nasync function resolveFindingEvidence<TInput>(\n testCase: AnalystBenchmarkCase<TInput>,\n findings: readonly AnalystFinding[],\n resolver: AnalystEvidenceResolver<TInput>,\n signal?: AbortSignal,\n): Promise<AnalystEvidenceResolution> {\n const evidence = findings.flatMap((finding) => finding.evidence_refs)\n const resolved: EvidenceRef[] = []\n const unresolvedEvidence: EvidenceRef[] = []\n const errors: AnalystEvidenceResolutionError[] = []\n for (const ref of evidence) {\n signal?.throwIfAborted()\n try {\n if (\n await resolver({\n caseId: testCase.id,\n caseInput: testCase.input,\n evidence: ref,\n signal,\n })\n ) {\n resolved.push(ref)\n } else {\n unresolvedEvidence.push(ref)\n }\n } catch (error) {\n if (signal?.aborted) throw error\n errors.push({\n evidence: ref,\n class: error instanceof Error ? error.constructor.name : 'Error',\n message: error instanceof Error ? error.message : String(error),\n })\n }\n }\n return {\n checked: evidence.length,\n resolved: resolved.length,\n unresolvedEvidence,\n errors,\n validity: evidence.length === 0 || errors.length > 0 ? null : resolved.length / evidence.length,\n }\n}\n\nfunction parseTraceSpanUri(uri: string): { traceId: string; spanId: string } | null {\n const match = /^trace:\\/\\/([^/]+)\\/span\\/([^/]+)$/.exec(uri)\n if (!match) return null\n try {\n const traceId = decodeURIComponent(match[1]!)\n const spanId = decodeURIComponent(match[2]!)\n return traceId && spanId ? { traceId, spanId } : null\n } catch {\n return null\n }\n}\n\nfunction validateBenchmarkOptions<TInput>(options: RunAnalystBenchmarkOptions<TInput>): void {\n if (options.cases.length === 0) throw new TypeError('runAnalystBenchmark requires cases')\n if (options.runners.length === 0) throw new TypeError('runAnalystBenchmark requires runners')\n const repetitions = options.repetitions ?? 1\n const maxConcurrency = options.maxConcurrency ?? 1\n if (!Number.isSafeInteger(repetitions) || repetitions < 1) {\n throw new RangeError('runAnalystBenchmark repetitions must be a positive safe integer')\n }\n if (!Number.isSafeInteger(maxConcurrency) || maxConcurrency < 1) {\n throw new RangeError('runAnalystBenchmark maxConcurrency must be a positive safe integer')\n }\n if (!Number.isSafeInteger(options.runnerOrderSeed ?? 0)) {\n throw new RangeError('runAnalystBenchmark runnerOrderSeed must be a safe integer')\n }\n assertUniqueNonEmpty(\n options.cases.map((testCase) => testCase.id),\n 'case',\n )\n assertUniqueNonEmpty(\n options.runners.map((runner) => runner.id),\n 'runner',\n )\n for (const testCase of options.cases) validateBenchmarkCase(testCase)\n}\n\nfunction validateBenchmarkCase(testCase: AnalystBenchmarkCase): void {\n assertValidAnalystScoringCase(testCase)\n if (!testCase.clusterId.trim()) {\n throw new TypeError(`${testCase.id}: analyst benchmark clusterId must not be empty`)\n }\n if (\n testCase.labelState !== 'positive' &&\n testCase.labelState !== 'trusted-negative' &&\n testCase.labelState !== 'unlabeled'\n ) {\n throw new TypeError(`${testCase.id}: analyst benchmark labelState is invalid`)\n }\n if (testCase.labelState === 'positive' && testCase.expectedIssues.length === 0) {\n throw new TypeError(`${testCase.id}: positive case requires at least one expected issue`)\n }\n if (testCase.labelState !== 'positive' && testCase.expectedIssues.length > 0) {\n throw new TypeError(\n `${testCase.id}: ${testCase.labelState} case cannot contain expected issues`,\n )\n }\n}\n\nfunction assertUniqueNonEmpty(values: readonly string[], label: string): void {\n const seen = new Set<string>()\n for (const value of values) {\n if (!value.trim()) throw new TypeError(`analyst benchmark ${label} id must not be empty`)\n if (seen.has(value)) throw new TypeError(`duplicate analyst benchmark ${label} id '${value}'`)\n seen.add(value)\n }\n}\n\n/** 32-bit FNV-1a over raw UTF-16 code units, left SIGNED so subtracting two\n * results is a valid comparator.\n *\n * Frozen: it fixes the runner order a benchmark reports. Adding the `>>> 0`\n * the other variants carry would change that order, which is why this one\n * does not have it. */\nfunction stableHash(value: string): number {\n let hash = 2166136261\n for (let index = 0; index < value.length; index += 1) {\n hash ^= value.charCodeAt(index)\n hash = Math.imul(hash, 16777619)\n }\n return hash >>> 0\n}\n\nfunction mergeRegistryUsage(result: AnalystRunResult): AnalystUsageReceipt {\n const usages = result.per_analyst.map((summary) => summary.usage)\n const calls = usages.every((usage) => usage.calls !== null)\n ? usages.reduce((sum, usage) => sum + (usage.calls ?? 0), 0)\n : null\n const tokens = usages.every((usage) => usage.tokens !== null)\n ? usages.reduce(\n (sum, usage) => ({\n input: sum.input + (usage.tokens?.input ?? 0),\n output: sum.output + (usage.tokens?.output ?? 0),\n reasoning: sum.reasoning + (usage.tokens?.reasoning ?? 0),\n cached: sum.cached + (usage.tokens?.cached ?? 0),\n cacheWrite: sum.cacheWrite + (usage.tokens?.cacheWrite ?? 0),\n }),\n { input: 0, output: 0, reasoning: 0, cached: 0, cacheWrite: 0 },\n )\n : null\n const knownCostUsd = usages.reduce(\n (sum, usage) =>\n sum + (usage.cost.kind === 'uncaptured' ? (usage.knownCostUsd ?? 0) : usage.cost.usd),\n 0,\n )\n const cost = usages.some((usage) => usage.cost.kind === 'uncaptured')\n ? ({ kind: 'uncaptured', usd: null } as const)\n : usages.some((usage) => usage.cost.kind === 'estimated')\n ? ({ kind: 'estimated', usd: knownCostUsd } as const)\n : ({ kind: 'observed', usd: knownCostUsd } as const)\n return {\n calls,\n tokens,\n cost,\n ...(cost.kind === 'uncaptured' ? { knownCostUsd } : {}),\n }\n}\n"],"mappings":";;;;;AASA,SAAgB,qBACd,UACA,UACqB;CACrB,8BAA8B,QAAQ;CACtC,MAAM,wBAAwB,sBAAsB,SAAS,gBAAgB,QAAQ;CACrF,MAAM,kBAAkB,SAAS,eAC9B,QAAQ,GAAG,UAAU,sBAAsB,IAAI,KAAK,CAAC,CAAC,CACtD,KAAK,UAAU,MAAM,EAAE;CAC1B,MAAM,iBAAiB,SAAS,eAC7B,QAAQ,GAAG,UAAU,CAAC,sBAAsB,IAAI,KAAK,CAAC,CAAC,CACvD,KAAK,UAAU,MAAM,EAAE;CAC1B,MAAM,0BAA0B,IAAI,IAAI,sBAAsB,OAAO,CAAC;CAEtE,MAAM,4BAA4B,SAC/B,KAAK,GAAG,UAAU,KAAK,CAAC,CACxB,QAAQ,UAAU,CAAC,w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WAAW,IAAI,IACxD,OAAO,QACJ,KAAK,WAAW;EACf,OAAO,IAAI,SAAS,MAAM,QAAQ,SAAS;EAC3C,QAAQ,IAAI,UAAU,MAAM,QAAQ,UAAU;EAC9C,WAAW,IAAI,aAAa,MAAM,QAAQ,aAAa;EACvD,QAAQ,IAAI,UAAU,MAAM,QAAQ,UAAU;EAC9C,YAAY,IAAI,cAAc,MAAM,QAAQ,cAAc;CAC5D,IACA;EAAE,OAAO;EAAG,QAAQ;EAAG,WAAW;EAAG,QAAQ;EAAG,YAAY;CAAE,CAChE,IACA;CACJ,MAAM,eAAe,OAAO,QACzB,KAAK,UACJ,OAAO,MAAM,KAAK,SAAS,eAAgB,MAAM,gBAAgB,IAAK,MAAM,KAAK,MACnF,CACF;CACA,MAAM,OAAO,OAAO,MAAM,UAAU,MAAM,KAAK,SAAS,YAAY,IAC/D;EAAE,MAAM;EAAc,KAAK;CAAK,IACjC,OAAO,MAAM,UAAU,MAAM,KAAK,SAAS,WAAW,IACnD;EAAE,MAAM;EAAa,KAAK;CAAa,IACvC;EAAE,MAAM;EAAY,KAAK;CAAa;CAC7C,OAAO;EACL;EACA;EACA;EACA,GAAI,KAAK,SAAS,eAAe,EAAE,aAAa,IAAI,CAAC;CACvD;AACF"}
1
+ {"version":3,"file":"benchmark-BeQJyrRC.js","names":[],"sources":["../src/analyst/benchmark-scoring.ts","../src/analyst/benchmark-summary.ts","../src/analyst/benchmark.ts"],"sourcesContent":["import { linearSumAssignment } from 'linear-sum-assignment'\nimport type {\n AnalystBenchmarkCase,\n AnalystEvidenceExpectation,\n AnalystFindingScore,\n AnalystIssueExpectation,\n} from './benchmark'\nimport type { AnalystFinding, EvidenceRef } from './types'\n\nexport function scoreAnalystFindings(\n testCase: Pick<AnalystBenchmarkCase, 'id' | 'expectedIssues' | 'labeledEvidence'>,\n findings: readonly AnalystFinding[],\n): AnalystFindingScore {\n assertValidAnalystScoringCase(testCase)\n const matchedFindingByIssue = matchFindingsToIssues(testCase.expectedIssues, findings)\n const matchedIssueIds = testCase.expectedIssues\n .filter((_, index) => matchedFindingByIssue.has(index))\n .map((issue) => issue.id)\n const missedIssueIds = testCase.expectedIssues\n .filter((_, index) => !matchedFindingByIssue.has(index))\n .map((issue) => issue.id)\n const supportedFindingIndexes = new Set(matchedFindingByIssue.values())\n\n const unsupportedFindingIndexes = findings\n .map((_, index) => index)\n .filter((index) => !supportedFindingIndexes.has(index))\n const expectedIssueCount = testCase.expectedIssues.length\n const issueRecall = expectedIssueCount === 0 ? 1 : matchedIssueIds.length / expectedIssueCount\n const findingPrecision =\n findings.length === 0\n ? expectedIssueCount === 0\n ? 1\n : 0\n : supportedFindingIndexes.size / findings.length\n const f1 = harmonicMeanScore(findingPrecision, issueRecall)\n const allEvidence = findings.flatMap((finding) => finding.evidence_refs)\n\n const criticalIssues = testCase.expectedIssues.filter(\n (issue) => (issue.criticalEvidence?.length ?? 0) > 0,\n )\n const criticalHits = testCase.expectedIssues.filter((issue) => {\n if ((issue.criticalEvidence?.length ?? 0) === 0) return false\n return matchesEvidence(allEvidence, issue.criticalEvidence ?? [], 'any')\n }).length\n\n const findingsWithEvidence = findings.filter((finding) => finding.evidence_refs.length > 0).length\n const unlabeledEvidence = testCase.labeledEvidence\n ? allEvidence.filter(\n (ref) => !testCase.labeledEvidence!.some((expected) => evidenceMatches(ref, expected)),\n )\n : []\n\n return {\n expectedIssueCount,\n matchedIssueIds,\n missedIssueIds,\n supportedFindingIndexes: [...supportedFindingIndexes].sort((a, b) => a - b),\n unsupportedFindingIndexes,\n unlabeledEvidence,\n issueRecall,\n findingPrecision,\n f1,\n criticalStepAccuracy: criticalIssues.length === 0 ? null : criticalHits / criticalIssues.length,\n citationCoverage: findings.length === 0 ? null : findingsWithEvidence / findings.length,\n citationExcerptCoverage:\n allEvidence.length === 0\n ? null\n : allEvidence.filter((evidence) => Boolean(evidence.excerpt?.trim())).length /\n allEvidence.length,\n citationLabelAgreement:\n testCase.labeledEvidence === undefined\n ? null\n : allEvidence.length === 0\n ? findings.length === 0\n ? null\n : 0\n : (allEvidence.length - unlabeledEvidence.length) / allEvidence.length,\n predictionOnLabelEmptyCase: expectedIssueCount === 0 && findings.length > 0,\n }\n}\n\nexport function assertValidAnalystScoringCase(\n testCase: Pick<AnalystBenchmarkCase, 'id' | 'expectedIssues' | 'labeledEvidence'>,\n): void {\n if (!testCase.id.trim()) throw new TypeError('analyst benchmark case id must not be empty')\n const ids = new Set<string>()\n for (const issue of testCase.expectedIssues) {\n if (!issue.id.trim()) throw new TypeError(`${testCase.id}: expected issue id must not be empty`)\n if (ids.has(issue.id)) {\n throw new TypeError(`${testCase.id}: duplicate expected issue id '${issue.id}'`)\n }\n ids.add(issue.id)\n if (\n !issue.findingIds?.length &&\n !issue.areas?.length &&\n !issue.subjects?.length &&\n !issue.evidence?.length\n ) {\n throw new TypeError(\n `${testCase.id}/${issue.id}: expected issue must identify a finding by id, area, subject, or evidence`,\n )\n }\n }\n for (const ref of testCase.labeledEvidence ?? []) {\n if (!ref.uri.trim()) {\n throw new TypeError(`${testCase.id}: labeled evidence URI must not be empty`)\n }\n }\n}\n\nexport function harmonicMeanScore(a: number, b: number): number {\n return a + b === 0 ? 0 : (2 * a * b) / (a + b)\n}\n\nfunction matchFindingsToIssues(\n issues: readonly AnalystIssueExpectation[],\n findings: readonly AnalystFinding[],\n): Map<number, number> {\n if (issues.length === 0) return new Map()\n const cardinalityWeight = issues.length + 1\n const scores = issues.map((issue) => [\n ...findings.map((finding) => {\n if (!findingMatchesIssue(finding, issue)) return -1\n const criticalHit =\n (issue.criticalEvidence?.length ?? 0) > 0 &&\n matchesEvidence(finding.evidence_refs, issue.criticalEvidence ?? [], 'any')\n return cardinalityWeight + Number(criticalHit)\n }),\n ...Array.from({ length: issues.length }, () => 0),\n ])\n const assignment = linearSumAssignment(scores, { maximaze: true }).rowAssignments\n const matches = new Map<number, number>()\n for (const [issueIndex, column] of assignment.entries()) {\n if (column < 0 || column >= findings.length) continue\n if (!findingMatchesIssue(findings[column]!, issues[issueIndex]!)) continue\n matches.set(issueIndex, column)\n }\n return matches\n}\n\nfunction findingMatchesIssue(finding: AnalystFinding, issue: AnalystIssueExpectation): boolean {\n if (issue.findingIds && !issue.findingIds.includes(finding.finding_id)) return false\n if (issue.areas && !issue.areas.includes(finding.area)) return false\n if (issue.subjects && (!finding.subject || !issue.subjects.includes(finding.subject))) {\n return false\n }\n if (\n issue.evidence &&\n !matchesEvidence(finding.evidence_refs, issue.evidence, issue.evidenceMode ?? 'any')\n ) {\n return false\n }\n return true\n}\n\nfunction matchesEvidence(\n actual: readonly EvidenceRef[],\n expected: readonly AnalystEvidenceExpectation[],\n mode: 'any' | 'all',\n): boolean {\n if (expected.length === 0) return true\n const match = (target: AnalystEvidenceExpectation) =>\n actual.some((ref) => evidenceMatches(ref, target))\n return mode === 'all' ? expected.every(match) : expected.some(match)\n}\n\nfunction evidenceMatches(actual: EvidenceRef, expected: AnalystEvidenceExpectation): boolean {\n return (\n actual.uri === expected.uri && (expected.kind === undefined || actual.kind === expected.kind)\n )\n}\n","import { compareCodeUnits } from '../ledger-core/canonical'\nimport type {\n AnalystBenchmarkObservation,\n AnalystBenchmarkSummary,\n AnalystLatencyDistribution,\n} from './benchmark'\n\nimport { harmonicMeanScore } from './benchmark-scoring'\n\nexport function summarizeAnalystBenchmarkRunner(\n runnerId: string,\n observations: readonly AnalystBenchmarkObservation[],\n): AnalystBenchmarkSummary {\n const issueBearing = observations.filter((observation) => observation.labelState === 'positive')\n const completed = observations.filter((observation) => !observation.error)\n const expectedIssues = issueBearing.reduce(\n (sum, observation) => sum + observation.score.expectedIssueCount,\n 0,\n )\n const matchedIssues = issueBearing.reduce(\n (sum, observation) => sum + observation.score.matchedIssueIds.length,\n 0,\n )\n const issueFindings = issueBearing.reduce(\n (sum, observation) => sum + (observation.error ? 0 : observation.findings.length),\n 0,\n )\n const supportedFindings = issueBearing.reduce(\n (sum, observation) => sum + observation.score.supportedFindingIndexes.length,\n 0,\n )\n const issueRecall = expectedIssues === 0 ? null : matchedIssues / expectedIssues\n const findingPrecision =\n expectedIssues === 0 ? null : issueFindings === 0 ? 0 : supportedFindings / issueFindings\n const macroIssueRecall =\n issueBearing.length === 0\n ? null\n : mean(issueBearing.map((observation) => observation.score.issueRecall))\n const macroFindingPrecision =\n issueBearing.length === 0\n ? null\n : mean(issueBearing.map((observation) => observation.score.findingPrecision))\n const macroF1 =\n issueBearing.length === 0 ? null : mean(issueBearing.map((observation) => observation.score.f1))\n const critical = observations\n .map((observation) => observation.score.criticalStepAccuracy)\n .filter((value): value is number => value !== null)\n const findingsWithEvidence = completed.reduce(\n (sum, observation) =>\n sum + observation.findings.filter((finding) => finding.evidence_refs.length > 0).length,\n 0,\n )\n const allFindings = completed.reduce((sum, observation) => sum + observation.findings.length, 0)\n const allCitations = completed.flatMap((observation) =>\n observation.findings.flatMap((finding) => finding.evidence_refs),\n )\n const citationObservations = completed.filter(\n (observation) => observation.score.citationLabelAgreement !== null,\n )\n const citationCount = citationObservations.reduce(\n (sum, observation) =>\n sum +\n observation.findings.reduce((count, finding) => count + finding.evidence_refs.length, 0),\n 0,\n )\n const invalidCitationCount = citationObservations.reduce(\n (sum, observation) => sum + observation.score.unlabeledEvidence.length,\n 0,\n )\n const trustedNegative = observations.filter(\n (observation) => observation.labelState === 'trusted-negative',\n )\n const completedTrustedNegative = trustedNegative.filter((observation) => !observation.error)\n const unlabeled = observations.filter((observation) => observation.labelState === 'unlabeled')\n const completedUnlabeled = unlabeled.filter((observation) => !observation.error)\n const resolvedCitations = completed.reduce(\n (sum, observation) => sum + (observation.evidenceResolution?.resolved ?? 0),\n 0,\n )\n const unresolvedCitations = completed.reduce(\n (sum, observation) => sum + (observation.evidenceResolution?.unresolvedEvidence.length ?? 0),\n 0,\n )\n const citationResolutionErrors = completed.reduce(\n (sum, observation) => sum + (observation.evidenceResolution?.errors.length ?? 0),\n 0,\n )\n const resolutionAttempts = completed.filter((observation) =>\n observation.findings.some((finding) => finding.evidence_refs.length > 0),\n )\n const citationResolutionUnknownRuns = resolutionAttempts.filter(\n (observation) =>\n !observation.evidenceResolution || observation.evidenceResolution.errors.length > 0,\n ).length\n const usages = observations.map((observation) => observation.usage)\n const knownCostUsd = stableSum(\n usages.map((usage) => {\n if (!usage) return 0\n return usage.cost.kind === 'uncaptured' ? (usage.knownCostUsd ?? 0) : usage.cost.usd\n }),\n )\n const predictionAgreement = repeatedObservationAgreement(observations, predictionSignature)\n const matchedLabelAgreement = repeatedObservationAgreement(\n observations.filter((observation) => observation.labelState === 'positive'),\n matchedLabelSignature,\n )\n return {\n runnerId,\n plannedRuns: observations.length,\n completedRuns: observations.filter((observation) => !observation.error).length,\n failedRuns: observations.filter((observation) => Boolean(observation.error)).length,\n issueBearingRuns: issueBearing.length,\n trustedNegativeRuns: trustedNegative.length,\n unlabeledRuns: unlabeled.length,\n issueRecall,\n findingPrecision,\n f1:\n findingPrecision === null || issueRecall === null\n ? null\n : harmonicMeanScore(findingPrecision, issueRecall),\n macroIssueRecall,\n macroFindingPrecision,\n macroF1,\n criticalStepAccuracy: critical.length === 0 ? null : mean(critical),\n citationCoverage: allFindings === 0 ? null : findingsWithEvidence / allFindings,\n citationExcerptCoverage:\n allCitations.length === 0\n ? null\n : allCitations.filter((evidence) => Boolean(evidence.excerpt?.trim())).length /\n allCitations.length,\n citationLabelAgreement:\n citationObservations.length === 0\n ? null\n : citationCount === 0\n ? 0\n : (citationCount - invalidCitationCount) / citationCount,\n citationResolution:\n resolutionAttempts.length === 0 ||\n citationResolutionUnknownRuns > 0 ||\n resolvedCitations + unresolvedCitations === 0\n ? null\n : resolvedCitations / (resolvedCitations + unresolvedCitations),\n citationResolutionUnknownRuns,\n unresolvedCitations,\n citationResolutionErrors,\n trustedNegativeFalsePositiveRate:\n completedTrustedNegative.length === 0\n ? null\n : completedTrustedNegative.filter(\n (observation) => observation.score.predictionOnLabelEmptyCase,\n ).length / completedTrustedNegative.length,\n trustedNegativeFailureRate:\n trustedNegative.length === 0\n ? null\n : trustedNegative.filter((observation) => Boolean(observation.error)).length /\n trustedNegative.length,\n unlabeledPredictionRate:\n completedUnlabeled.length === 0\n ? null\n : completedUnlabeled.filter((observation) => observation.findings.length > 0).length /\n completedUnlabeled.length,\n unlabeledFailureRate:\n unlabeled.length === 0\n ? null\n : unlabeled.filter((observation) => Boolean(observation.error)).length / unlabeled.length,\n predictionAgreement: predictionAgreement.value,\n predictionAgreementCases: predictionAgreement.cases,\n matchedLabelAgreement: matchedLabelAgreement.value,\n matchedLabelAgreementCases: matchedLabelAgreement.cases,\n latencyMs: latencyDistribution(\n observations\n .map((observation) => observation.latencyMs)\n .filter((value): value is number => value !== null),\n ),\n benchmarkClockLatencyRuns: observations.filter(\n (observation) => observation.latencySource === 'benchmark-clock',\n ).length,\n runnerReportedLatencyRuns: observations.filter(\n (observation) => observation.latencySource === 'runner-reported',\n ).length,\n latencyUnknownRuns: observations.filter(\n (observation) => observation.latencySource === 'uncaptured',\n ).length,\n calls: usages.reduce((sum, usage) => sum + (usage?.calls ?? 0), 0),\n callsUnknownRuns: usages.filter((usage) => !usage || usage.calls === null).length,\n inputTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.input ?? 0), 0),\n outputTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.output ?? 0), 0),\n reasoningTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.reasoning ?? 0), 0),\n cachedTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.cached ?? 0), 0),\n cacheWriteTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.cacheWrite ?? 0), 0),\n tokenUsageUnknownRuns: usages.filter((usage) => !usage?.tokens).length,\n reasoningTokenUsageUnknownRuns: usages.filter((usage) => usage?.tokens?.reasoning === undefined)\n .length,\n cachedTokenUsageUnknownRuns: usages.filter((usage) => usage?.tokens?.cached === undefined)\n .length,\n cacheWriteTokenUsageUnknownRuns: usages.filter(\n (usage) => usage?.tokens?.cacheWrite === undefined,\n ).length,\n knownCostUsd,\n costUnknownRuns: usages.filter((usage) => !usage || usage.cost.kind === 'uncaptured').length,\n }\n}\n\nfunction mean(values: readonly number[]): number {\n return values.length === 0 ? 0 : stableSum(values) / values.length\n}\n\nfunction stableSum(values: readonly number[]): number {\n const ordered = [...values].sort(\n (left, right) => Math.abs(left) - Math.abs(right) || left - right,\n )\n let sum = 0\n let correction = 0\n for (const value of ordered) {\n const next = sum + value\n correction += Math.abs(sum) >= Math.abs(value) ? sum - next + value : value - next + sum\n sum = next\n }\n return sum + correction\n}\n\nfunction latencyDistribution(values: readonly number[]): AnalystLatencyDistribution | null {\n if (values.length === 0) return null\n const sorted = [...values].sort((a, b) => a - b)\n return {\n min: sorted[0]!,\n mean: mean(sorted),\n p50: percentile(sorted, 0.5),\n p95: percentile(sorted, 0.95),\n max: sorted.at(-1)!,\n }\n}\n\nfunction percentile(sorted: readonly number[], quantile: number): number {\n if (sorted.length === 0) return 0\n return sorted[Math.ceil(quantile * sorted.length) - 1] ?? sorted.at(-1) ?? 0\n}\n\nfunction repeatedObservationAgreement(\n observations: readonly AnalystBenchmarkObservation[],\n signature: (observation: AnalystBenchmarkObservation) => readonly string[],\n): { value: number | null; cases: number } {\n const byCase = new Map<string, AnalystBenchmarkObservation[]>()\n for (const observation of observations) {\n const rows = byCase.get(observation.caseId) ?? []\n rows.push(observation)\n byCase.set(observation.caseId, rows)\n }\n const caseAgreements: number[] = []\n for (const rows of byCase.values()) {\n const agreements: number[] = []\n for (let left = 0; left < rows.length; left++) {\n for (let right = left + 1; right < rows.length; right++) {\n agreements.push(jaccard(signature(rows[left]!), signature(rows[right]!)))\n }\n }\n if (agreements.length > 0) caseAgreements.push(mean(agreements))\n }\n return {\n value: caseAgreements.length === 0 ? null : mean(caseAgreements),\n cases: caseAgreements.length,\n }\n}\n\nfunction matchedLabelSignature(observation: AnalystBenchmarkObservation): readonly string[] {\n if (observation.error) return [`error:${observation.error.class}`]\n return observation.score.matchedIssueIds\n}\n\nfunction predictionSignature(observation: AnalystBenchmarkObservation): readonly string[] {\n if (observation.error) return [`error:${observation.error.class}`]\n return observation.findings\n .map((finding) =>\n JSON.stringify([\n finding.finding_id,\n finding.evidence_refs\n .map((evidence) => [evidence.kind, evidence.uri, evidence.excerpt ?? null])\n .sort((left, right) => compareCodeUnits(JSON.stringify(left), JSON.stringify(right))),\n ]),\n )\n .sort()\n}\n\nfunction jaccard(left: readonly string[], right: readonly string[]): number {\n const a = new Set(left)\n const b = new Set(right)\n const union = new Set([...a, ...b])\n if (union.size === 0) return 1\n let intersection = 0\n for (const value of a) if (b.has(value)) intersection += 1\n return intersection / union.size\n}\n","import { performance } from 'node:perf_hooks'\nimport type { TraceAnalysisStore } from '../trace-analyst/store'\nimport { assertValidAnalystScoringCase, scoreAnalystFindings } from './benchmark-scoring'\nimport { summarizeAnalystBenchmarkRunner } from './benchmark-summary'\nimport type { AnalystRegistry, RegistryRunOpts } from './registry'\nimport type {\n AnalystFinding,\n AnalystRunInputs,\n AnalystRunResult,\n AnalystUsageReceipt,\n EvidenceRef,\n} from './types'\nimport { assertValidAnalystUsageReceipt } from './usage-receipt'\n\nexport { scoreAnalystFindings } from './benchmark-scoring'\n\nexport interface AnalystEvidenceExpectation {\n uri: string\n kind?: EvidenceRef['kind']\n}\n\nexport interface AnalystIssueExpectation {\n id: string\n findingIds?: readonly string[]\n areas?: readonly string[]\n subjects?: readonly string[]\n evidence?: readonly AnalystEvidenceExpectation[]\n evidenceMode?: 'any' | 'all'\n /** Exact evidence location for the first unrecoverable or causal step. */\n criticalEvidence?: readonly AnalystEvidenceExpectation[]\n}\n\nexport type AnalystBenchmarkLabelState = 'positive' | 'trusted-negative' | 'unlabeled'\n\nexport interface AnalystBenchmarkCase<TInput = unknown> {\n id: string\n /** Independent source unit used for resampling, such as a task or incident. */\n clusterId: string\n /** Whether labels prove an issue, prove no issue, or leave the outcome unknown. */\n labelState: AnalystBenchmarkLabelState\n input: TInput\n expectedIssues: readonly AnalystIssueExpectation[]\n /** Complete set of labeled locations used to measure label-location agreement. */\n labeledEvidence?: readonly AnalystEvidenceExpectation[]\n tags?: readonly string[]\n metadata?: Record<string, unknown>\n}\n\nexport interface AnalystFindingScore {\n expectedIssueCount: number\n matchedIssueIds: string[]\n missedIssueIds: string[]\n supportedFindingIndexes: number[]\n unsupportedFindingIndexes: number[]\n unlabeledEvidence: EvidenceRef[]\n issueRecall: number\n findingPrecision: number\n f1: number\n criticalStepAccuracy: number | null\n /** Share of findings that cite at least one evidence location. */\n citationCoverage: number | null\n /** Share of citations that include a non-empty source excerpt. */\n citationExcerptCoverage: number | null\n /** Share of citations that agree with a labeled case location. */\n citationLabelAgreement: number | null\n predictionOnLabelEmptyCase: boolean\n}\n\nexport interface AnalystEvidenceResolutionError {\n evidence: EvidenceRef\n class: string\n message: string\n}\n\nexport interface AnalystEvidenceResolution {\n checked: number\n resolved: number\n unresolvedEvidence: EvidenceRef[]\n errors: AnalystEvidenceResolutionError[]\n /** Null when no citations were checked or any resolution attempt failed. */\n validity: number | null\n}\n\nexport type AnalystEvidenceResolver<TInput = unknown> = (input: {\n caseId: string\n caseInput: TInput\n evidence: EvidenceRef\n signal?: AbortSignal\n}) => boolean | Promise<boolean>\n\n/**\n * Resolve canonical `trace://<trace>/span/<span>` evidence against a trace store.\n * Other evidence kinds and URI schemes require a caller-supplied resolver.\n */\nexport function traceStoreEvidenceResolver<TInput>(\n getStore: (input: TInput) => TraceAnalysisStore,\n): AnalystEvidenceResolver<TInput> {\n return async ({ caseInput, evidence, signal }) => {\n if (evidence.kind !== 'span') return false\n const location = parseTraceSpanUri(evidence.uri)\n if (!location) return false\n const result = await getStore(caseInput).viewSpans(\n {\n trace_id: location.traceId,\n span_ids: [location.spanId],\n },\n signal ? { signal } : undefined,\n )\n return (\n result.trace_id === location.traceId &&\n result.missing_span_ids.length === 0 &&\n result.spans.some((span) => span.span_id === location.spanId)\n )\n }\n}\n\nexport interface AnalystBenchmarkOutput {\n findings: readonly AnalystFinding[]\n usage?: AnalystUsageReceipt\n metadata?: Record<string, unknown>\n /**\n * End-to-end duration measured by an external runner before import.\n * Use null when the source explicitly did not capture duration.\n */\n observedLatencyMs?: number | null\n /** Marks a completed transport as a failed analyst run while retaining usage and metadata. */\n error?: AnalystBenchmarkError\n}\n\nexport interface AnalystBenchmarkError {\n class: string\n message: string\n code?: string\n status?: number\n}\n\nexport interface AnalystBenchmarkRunner<TInput = unknown> {\n id: string\n analyze(\n input: TInput,\n context: { caseId: string; repetition: number; signal?: AbortSignal },\n ): AnalystBenchmarkOutput | Promise<AnalystBenchmarkOutput>\n}\n\nexport interface AnalystBenchmarkObservation {\n runnerId: string\n caseId: string\n clusterId: string\n labelState: AnalystBenchmarkLabelState\n repetition: number\n executionIndex: number\n latencyMs: number | null\n latencySource: 'benchmark-clock' | 'runner-reported' | 'uncaptured'\n findings: readonly AnalystFinding[]\n score: AnalystFindingScore\n evidenceResolution?: AnalystEvidenceResolution\n caseTags: readonly string[]\n caseMetadata?: Record<string, unknown>\n usage?: AnalystUsageReceipt\n runnerMetadata?: Record<string, unknown>\n error?: AnalystBenchmarkError\n}\n\nexport interface AnalystLatencyDistribution {\n min: number\n mean: number\n p50: number\n p95: number\n max: number\n}\n\nexport interface AnalystBenchmarkSummary {\n runnerId: string\n plannedRuns: number\n completedRuns: number\n failedRuns: number\n issueBearingRuns: number\n trustedNegativeRuns: number\n unlabeledRuns: number\n /** Pooled across all labeled issues and findings. */\n issueRecall: number | null\n /** Pooled across all labeled issues and findings. */\n findingPrecision: number | null\n /** Harmonic mean of the pooled precision and recall. */\n f1: number | null\n /** Mean of per-case recall over issue-bearing runs. */\n macroIssueRecall: number | null\n /** Mean of per-case precision over issue-bearing runs. */\n macroFindingPrecision: number | null\n /** Mean of per-case F1 over issue-bearing runs. */\n macroF1: number | null\n criticalStepAccuracy: number | null\n citationCoverage: number | null\n citationExcerptCoverage: number | null\n citationLabelAgreement: number | null\n citationResolution: number | null\n citationResolutionUnknownRuns: number\n unresolvedCitations: number\n citationResolutionErrors: number\n trustedNegativeFalsePositiveRate: number | null\n trustedNegativeFailureRate: number | null\n unlabeledPredictionRate: number | null\n unlabeledFailureRate: number | null\n /** Primary repeatability measure over complete finding identity and evidence. */\n predictionAgreement: number | null\n /** Repeated cases contributing equally to predictionAgreement. */\n predictionAgreementCases: number\n /** Secondary repeatability detail over matched expected labels. */\n matchedLabelAgreement: number | null\n /** Positive repeated cases contributing equally to matchedLabelAgreement. */\n matchedLabelAgreementCases: number\n latencyMs: AnalystLatencyDistribution | null\n benchmarkClockLatencyRuns: number\n runnerReportedLatencyRuns: number\n latencyUnknownRuns: number\n calls: number\n callsUnknownRuns: number\n inputTokens: number\n outputTokens: number\n reasoningTokens: number\n cachedTokens: number\n cacheWriteTokens: number\n tokenUsageUnknownRuns: number\n reasoningTokenUsageUnknownRuns: number\n cachedTokenUsageUnknownRuns: number\n cacheWriteTokenUsageUnknownRuns: number\n knownCostUsd: number\n costUnknownRuns: number\n}\n\nexport interface AnalystBenchmarkDatasetRef {\n id: string\n revision: string\n split?: string\n}\n\nexport interface AnalystBenchmarkDescriptor {\n id?: string\n dataset?: AnalystBenchmarkDatasetRef\n command?: string\n environment?: Record<string, string>\n metadata?: Record<string, unknown>\n}\n\nexport interface AnalystBenchmarkProvenance extends AnalystBenchmarkDescriptor {\n startedAt: string\n endedAt: string\n caseCount: number\n runnerIds: string[]\n repetitions: number\n maxConcurrency: number\n runnerOrderSeed: number\n}\n\nexport interface AnalystBenchmarkResult {\n provenance: AnalystBenchmarkProvenance\n observations: AnalystBenchmarkObservation[]\n summaries: AnalystBenchmarkSummary[]\n}\n\nexport interface RunAnalystBenchmarkOptions<TInput> {\n cases: readonly AnalystBenchmarkCase<TInput>[]\n runners: readonly AnalystBenchmarkRunner<TInput>[]\n repetitions?: number\n maxConcurrency?: number\n runnerOrderSeed?: number\n resolveEvidence?: AnalystEvidenceResolver<TInput>\n benchmark?: AnalystBenchmarkDescriptor\n /** Previously persisted rows. Exact case, runner, repetition, and execution identities are required. */\n initialObservations?: readonly AnalystBenchmarkObservation[]\n onObservation?: (observation: AnalystBenchmarkObservation) => void | Promise<void>\n signal?: AbortSignal\n}\n\nexport async function runAnalystBenchmark<TInput>(\n options: RunAnalystBenchmarkOptions<TInput>,\n): Promise<AnalystBenchmarkResult> {\n validateBenchmarkOptions(options)\n const startedAt = new Date().toISOString()\n const repetitions = options.repetitions ?? 1\n const runnerOrderSeed = options.runnerOrderSeed ?? 0\n const allJobs = benchmarkJobs(options.cases, options.runners, repetitions, runnerOrderSeed)\n const maxConcurrency = Math.min(options.maxConcurrency ?? 1, allJobs.length)\n const initialObservations = validateInitialObservations(\n options.initialObservations ?? [],\n allJobs,\n )\n const completed = new Set(initialObservations.map(observationKey))\n const jobs = allJobs.filter((job) => !completed.has(jobKey(job)))\n const observations: AnalystBenchmarkObservation[] = [...initialObservations]\n let cursor = 0\n const worker = async (): Promise<void> => {\n while (cursor < jobs.length) {\n options.signal?.throwIfAborted()\n const job = jobs[cursor++]!\n const observation = await runBenchmarkJob(job, options.signal, options.resolveEvidence)\n options.signal?.throwIfAborted()\n await options.onObservation?.(observation)\n options.signal?.throwIfAborted()\n observations.push(observation)\n }\n }\n await Promise.all(Array.from({ length: Math.min(maxConcurrency, jobs.length) }, worker))\n options.signal?.throwIfAborted()\n const runnerOrder = new Map(options.runners.map((runner, index) => [runner.id, index]))\n const caseOrder = new Map(options.cases.map((testCase, index) => [testCase.id, index]))\n observations.sort(\n (a, b) =>\n (runnerOrder.get(a.runnerId) ?? 0) - (runnerOrder.get(b.runnerId) ?? 0) ||\n (caseOrder.get(a.caseId) ?? 0) - (caseOrder.get(b.caseId) ?? 0) ||\n a.repetition - b.repetition,\n )\n return {\n provenance: {\n ...options.benchmark,\n startedAt,\n endedAt: new Date().toISOString(),\n caseCount: options.cases.length,\n runnerIds: options.runners.map((runner) => runner.id),\n repetitions,\n maxConcurrency,\n runnerOrderSeed,\n },\n observations,\n summaries: options.runners.map((runner) =>\n summarizeAnalystBenchmarkRunner(\n runner.id,\n observations.filter((observation) => observation.runnerId === runner.id),\n ),\n ),\n }\n}\n\nexport function registryBenchmarkRunner(options: {\n id: string\n registry: AnalystRegistry\n runOptions?: Omit<RegistryRunOpts, 'signal'>\n /** Count any selected analyst failure as a failed benchmark run. */\n failOnAnalystFailure?: boolean\n}): AnalystBenchmarkRunner<AnalystRunInputs> {\n return {\n id: options.id,\n async analyze(input, context) {\n const result = await options.registry.run(\n `${options.id}:${context.caseId}:${context.repetition}`,\n input,\n { ...options.runOptions, signal: context.signal },\n )\n return {\n findings: result.findings,\n usage: mergeRegistryUsage(result),\n metadata: { analystRun: result },\n ...(options.failOnAnalystFailure ? { error: registryRunFailure(result) } : {}),\n }\n },\n }\n}\n\nasync function runBenchmarkJob<TInput>(\n job: {\n runner: AnalystBenchmarkRunner<TInput>\n testCase: AnalystBenchmarkCase<TInput>\n repetition: number\n executionIndex: number\n },\n signal?: AbortSignal,\n resolveEvidence?: AnalystEvidenceResolver<TInput>,\n): Promise<AnalystBenchmarkObservation> {\n const started = performance.now()\n try {\n const output = await job.runner.analyze(job.testCase.input, {\n caseId: job.testCase.id,\n repetition: job.repetition,\n signal,\n })\n if (output.usage) {\n assertValidAnalystUsageReceipt(output.usage, 'analyst benchmark usage')\n }\n const benchmarkLatencyMs = performance.now() - started\n const latency = resolveBenchmarkLatency(output.observedLatencyMs, benchmarkLatencyMs)\n const scoredFindings = output.error ? [] : output.findings\n return {\n runnerId: job.runner.id,\n caseId: job.testCase.id,\n clusterId: job.testCase.clusterId,\n labelState: job.testCase.labelState,\n repetition: job.repetition,\n executionIndex: job.executionIndex,\n latencyMs: latency.value,\n latencySource: latency.source,\n findings: output.findings,\n score: scoreAnalystFindings(job.testCase, scoredFindings),\n evidenceResolution: resolveEvidence\n ? await resolveFindingEvidence(job.testCase, output.findings, resolveEvidence, signal)\n : undefined,\n caseTags: [...(job.testCase.tags ?? [])],\n caseMetadata: job.testCase.metadata,\n usage: output.usage,\n runnerMetadata: output.metadata,\n ...(output.error ? { error: output.error } : {}),\n }\n } catch (error) {\n if (signal?.aborted) throw error\n const findings: AnalystFinding[] = []\n return {\n runnerId: job.runner.id,\n caseId: job.testCase.id,\n clusterId: job.testCase.clusterId,\n labelState: job.testCase.labelState,\n repetition: job.repetition,\n executionIndex: job.executionIndex,\n latencyMs: performance.now() - started,\n latencySource: 'benchmark-clock',\n findings,\n score: scoreAnalystFindings(job.testCase, findings),\n caseTags: [...(job.testCase.tags ?? [])],\n caseMetadata: job.testCase.metadata,\n error: {\n class: error instanceof Error ? error.constructor.name : 'Error',\n message: error instanceof Error ? error.message : String(error),\n },\n }\n }\n}\n\nfunction resolveBenchmarkLatency(\n observedLatencyMs: number | null | undefined,\n fallbackMs: number,\n): {\n value: number | null\n source: AnalystBenchmarkObservation['latencySource']\n} {\n if (observedLatencyMs === undefined) {\n return { value: fallbackMs, source: 'benchmark-clock' }\n }\n if (observedLatencyMs === null) return { value: null, source: 'uncaptured' }\n if (!Number.isFinite(observedLatencyMs) || observedLatencyMs < 0) {\n throw new RangeError('analyst benchmark observedLatencyMs must be finite and non-negative')\n }\n return { value: observedLatencyMs, source: 'runner-reported' }\n}\n\nfunction registryRunFailure(result: AnalystRunResult): AnalystBenchmarkOutput['error'] | undefined {\n const failed = result.per_analyst.filter((summary) => summary.status === 'failed')\n if (failed.length === 0) return undefined\n return {\n class: 'AnalystRunFailure',\n message: failed\n .map(\n (summary) =>\n `${summary.analyst_id}: ${summary.error?.class ?? 'Error'}: ${summary.error?.message ?? 'analyst failed'}`,\n )\n .join('; '),\n }\n}\n\nfunction benchmarkJobs<TInput>(\n cases: readonly AnalystBenchmarkCase<TInput>[],\n runners: readonly AnalystBenchmarkRunner<TInput>[],\n repetitions: number,\n runnerOrderSeed: number,\n): Array<{\n runner: AnalystBenchmarkRunner<TInput>\n testCase: AnalystBenchmarkCase<TInput>\n repetition: number\n executionIndex: number\n}> {\n const seededRunners = [...runners].sort(\n (left, right) =>\n stableHash(`${runnerOrderSeed}\\u0000${left.id}`) -\n stableHash(`${runnerOrderSeed}\\u0000${right.id}`) || left.id.localeCompare(right.id),\n )\n let executionIndex = 0\n return cases.flatMap((testCase, caseIndex) =>\n Array.from({ length: repetitions }, (_, repetition) => {\n const blockIndex = caseIndex * repetitions + repetition\n const rotation = blockIndex % seededRunners.length\n const ordered = [...seededRunners.slice(rotation), ...seededRunners.slice(0, rotation)]\n return ordered.map((runner) => ({\n runner,\n testCase,\n repetition,\n executionIndex: executionIndex++,\n }))\n }).flat(),\n )\n}\n\nfunction validateInitialObservations<TInput>(\n observations: readonly AnalystBenchmarkObservation[],\n jobs: readonly {\n runner: AnalystBenchmarkRunner<TInput>\n testCase: AnalystBenchmarkCase<TInput>\n repetition: number\n executionIndex: number\n }[],\n): AnalystBenchmarkObservation[] {\n const expected = new Map(jobs.map((job) => [jobKey(job), job]))\n const seen = new Set<string>()\n return observations.map((observation) => {\n const key = observationKey(observation)\n if (seen.has(key)) {\n throw new TypeError(\n `duplicate initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`,\n )\n }\n seen.add(key)\n const job = expected.get(key)\n if (!job) {\n throw new TypeError(\n `initial analyst benchmark observation does not match a planned job: '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`,\n )\n }\n if (observation.executionIndex !== job.executionIndex) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has executionIndex ${observation.executionIndex}; expected ${job.executionIndex}`,\n )\n }\n if (\n observation.clusterId !== job.testCase.clusterId ||\n observation.labelState !== job.testCase.labelState\n ) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' does not match the current case labels`,\n )\n }\n if (\n JSON.stringify(observation.caseTags) !== JSON.stringify(job.testCase.tags ?? []) ||\n JSON.stringify(observation.caseMetadata) !== JSON.stringify(job.testCase.metadata)\n ) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' does not match the current case metadata`,\n )\n }\n const expectedScore = scoreAnalystFindings(\n job.testCase,\n observation.error ? [] : observation.findings,\n )\n if (JSON.stringify(observation.score) !== JSON.stringify(expectedScore)) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has stale or invalid scores`,\n )\n }\n if (observation.usage) {\n assertValidAnalystUsageReceipt(\n observation.usage,\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' usage`,\n )\n }\n if (\n !['benchmark-clock', 'runner-reported', 'uncaptured'].includes(observation.latencySource) ||\n (observation.latencySource === 'uncaptured' && observation.latencyMs !== null) ||\n (observation.latencySource !== 'uncaptured' &&\n (observation.latencyMs === null ||\n !Number.isFinite(observation.latencyMs) ||\n observation.latencyMs < 0))\n ) {\n throw new TypeError(\n `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has invalid latency`,\n )\n }\n return { ...observation }\n })\n}\n\nfunction jobKey(job: {\n runner: { id: string }\n testCase: { id: string }\n repetition: number\n}): string {\n return `${job.runner.id}\\u0000${job.testCase.id}\\u0000${job.repetition}`\n}\n\nfunction observationKey(observation: {\n runnerId: string\n caseId: string\n repetition: number\n}): string {\n return `${observation.runnerId}\\u0000${observation.caseId}\\u0000${observation.repetition}`\n}\n\nasync function resolveFindingEvidence<TInput>(\n testCase: AnalystBenchmarkCase<TInput>,\n findings: readonly AnalystFinding[],\n resolver: AnalystEvidenceResolver<TInput>,\n signal?: AbortSignal,\n): Promise<AnalystEvidenceResolution> {\n const evidence = findings.flatMap((finding) => finding.evidence_refs)\n const resolved: EvidenceRef[] = []\n const unresolvedEvidence: EvidenceRef[] = []\n const errors: AnalystEvidenceResolutionError[] = []\n for (const ref of evidence) {\n signal?.throwIfAborted()\n try {\n if (\n await resolver({\n caseId: testCase.id,\n caseInput: testCase.input,\n evidence: ref,\n signal,\n })\n ) {\n resolved.push(ref)\n } else {\n unresolvedEvidence.push(ref)\n }\n } catch (error) {\n if (signal?.aborted) throw error\n errors.push({\n evidence: ref,\n class: error instanceof Error ? error.constructor.name : 'Error',\n message: error instanceof Error ? error.message : String(error),\n })\n }\n }\n return {\n checked: evidence.length,\n resolved: resolved.length,\n unresolvedEvidence,\n errors,\n validity: evidence.length === 0 || errors.length > 0 ? null : resolved.length / evidence.length,\n }\n}\n\nfunction parseTraceSpanUri(uri: string): { traceId: string; spanId: string } | null {\n const match = /^trace:\\/\\/([^/]+)\\/span\\/([^/]+)$/.exec(uri)\n if (!match) return null\n try {\n const traceId = decodeURIComponent(match[1]!)\n const spanId = decodeURIComponent(match[2]!)\n return traceId && spanId ? { traceId, spanId } : null\n } catch {\n return null\n }\n}\n\nfunction validateBenchmarkOptions<TInput>(options: RunAnalystBenchmarkOptions<TInput>): void {\n if (options.cases.length === 0) throw new TypeError('runAnalystBenchmark requires cases')\n if (options.runners.length === 0) throw new TypeError('runAnalystBenchmark requires runners')\n const repetitions = options.repetitions ?? 1\n const maxConcurrency = options.maxConcurrency ?? 1\n if (!Number.isSafeInteger(repetitions) || repetitions < 1) {\n throw new RangeError('runAnalystBenchmark repetitions must be a positive safe integer')\n }\n if (!Number.isSafeInteger(maxConcurrency) || maxConcurrency < 1) {\n throw new RangeError('runAnalystBenchmark maxConcurrency must be a positive safe integer')\n }\n if (!Number.isSafeInteger(options.runnerOrderSeed ?? 0)) {\n throw new RangeError('runAnalystBenchmark runnerOrderSeed must be a safe integer')\n }\n assertUniqueNonEmpty(\n options.cases.map((testCase) => testCase.id),\n 'case',\n )\n assertUniqueNonEmpty(\n options.runners.map((runner) => runner.id),\n 'runner',\n )\n for (const testCase of options.cases) validateBenchmarkCase(testCase)\n}\n\nfunction validateBenchmarkCase(testCase: AnalystBenchmarkCase): void {\n assertValidAnalystScoringCase(testCase)\n if (!testCase.clusterId.trim()) {\n throw new TypeError(`${testCase.id}: analyst benchmark clusterId must not be empty`)\n }\n if (\n testCase.labelState !== 'positive' &&\n testCase.labelState !== 'trusted-negative' &&\n testCase.labelState !== 'unlabeled'\n ) {\n throw new TypeError(`${testCase.id}: analyst benchmark labelState is invalid`)\n }\n if (testCase.labelState === 'positive' && testCase.expectedIssues.length === 0) {\n throw new TypeError(`${testCase.id}: positive case requires at least one expected issue`)\n }\n if (testCase.labelState !== 'positive' && testCase.expectedIssues.length > 0) {\n throw new TypeError(\n `${testCase.id}: ${testCase.labelState} case cannot contain expected issues`,\n )\n }\n}\n\nfunction assertUniqueNonEmpty(values: readonly string[], label: string): void {\n const seen = new Set<string>()\n for (const value of values) {\n if (!value.trim()) throw new TypeError(`analyst benchmark ${label} id must not be empty`)\n if (seen.has(value)) throw new TypeError(`duplicate analyst benchmark ${label} id '${value}'`)\n seen.add(value)\n }\n}\n\n/** 32-bit FNV-1a over raw UTF-16 code units, left SIGNED so subtracting two\n * results is a valid comparator.\n *\n * Frozen: it fixes the runner order a benchmark reports. Adding the `>>> 0`\n * the other variants carry would change that order, which is why this one\n * does not have it. */\nfunction stableHash(value: string): number {\n let hash = 2166136261\n for (let index = 0; index < value.length; index += 1) {\n hash ^= value.charCodeAt(index)\n hash = Math.imul(hash, 16777619)\n }\n return hash >>> 0\n}\n\nfunction mergeRegistryUsage(result: AnalystRunResult): AnalystUsageReceipt {\n const usages = result.per_analyst.map((summary) => summary.usage)\n const calls = usages.every((usage) => usage.calls !== null)\n ? usages.reduce((sum, usage) => sum + (usage.calls ?? 0), 0)\n : null\n const tokens = usages.every((usage) => usage.tokens !== null)\n ? usages.reduce(\n (sum, usage) => ({\n input: sum.input + (usage.tokens?.input ?? 0),\n output: sum.output + (usage.tokens?.output ?? 0),\n reasoning: sum.reasoning + (usage.tokens?.reasoning ?? 0),\n cached: sum.cached + (usage.tokens?.cached ?? 0),\n cacheWrite: sum.cacheWrite + (usage.tokens?.cacheWrite ?? 0),\n }),\n { input: 0, output: 0, reasoning: 0, cached: 0, cacheWrite: 0 },\n )\n : null\n const knownCostUsd = usages.reduce(\n (sum, usage) =>\n sum + (usage.cost.kind === 'uncaptured' ? (usage.knownCostUsd ?? 0) : usage.cost.usd),\n 0,\n )\n const cost = usages.some((usage) => usage.cost.kind === 'uncaptured')\n ? ({ kind: 'uncaptured', usd: null } as const)\n : usages.some((usage) => usage.cost.kind === 'estimated')\n ? ({ kind: 'estimated', usd: knownCostUsd } as const)\n : ({ kind: 'observed', usd: knownCostUsd } as const)\n return {\n calls,\n tokens,\n cost,\n ...(cost.kind === 'uncaptured' ? { knownCostUsd } : {}),\n }\n}\n"],"mappings":";;;;;AASA,SAAgB,qBACd,UACA,UACqB;CACrB,8BAA8B,QAAQ;CACtC,MAAM,wBAAwB,sBAAsB,SAAS,gBAAgB,QAAQ;CACrF,MAAM,kBAAkB,SAAS,eAC9B,QAAQ,GAAG,UAAU,sBAAsB,IAAI,KAAK,CAAC,CAAC,CACtD,KAAK,UAAU,MAAM,EAAE;CAC1B,MAAM,iBAAiB,SAAS,eAC7B,QAAQ,GAAG,UAAU,CAAC,sBAAsB,IAAI,KAAK,CAAC,CAAC,CACvD,KAAK,UAAU,MAAM,EAAE;CAC1B,MAAM,0BAA0B,IAAI,IAAI,sBAAsB,OAAO,CAAC;CAEtE,MAAM,4BAA4B,SAC/B,KAAK,GAAG,UAAU,KAAK,CAAC,CACxB,QAAQ,UAAU,CAAC,wBAAwB,IAAI,KAAK,CAAC;CACxD,MAAM,qBAAqB,SAAS,eAAe;CACnD,MAAM,cAAc,uBAAuB,IAAI,IAAI,gBAAgB,SAAS;CAC5E,MAAM,mBACJ,SAAS,WAAW,IAChB,uBAAuB,IACrB,IACA,IACF,wBAAwB,OAAO,SAAS;CAC9C,MAAM,KAAK,kBAAkB,kBAAkB,WAAW;CAC1D,MAAM,cAAc,SAAS,SAAS,YAAY,QAAQ,aAAa;CAEvE,MAAM,iBAAiB,SAAS,eAAe,QAC5C,WAAW,MAAM,kBAAkB,UAAU,KAAK,CACrD;CACA,MAAM,eAAe,SAAS,eAAe,QAAQ,UAAU;EAC7D,KAAK,MAAM,kBAAkB,UAAU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