@tangle-network/agent-eval 0.196.0 → 0.198.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 (155) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/active-curriculum-B_Lc9kfO.js +61 -0
  3. package/dist/active-curriculum-B_Lc9kfO.js.map +1 -0
  4. package/dist/adapters/http.d.ts +2 -2
  5. package/dist/analyst/index.d.ts +5 -5
  6. package/dist/analyst/index.js +3 -3
  7. package/dist/{analyze-runs-B6gv7vAT.js → analyze-runs-DFbp2gB8.js} +5 -5
  8. package/dist/{analyze-runs-B6gv7vAT.js.map → analyze-runs-DFbp2gB8.js.map} +1 -1
  9. package/dist/{benchmark-command-Bw1he2JM.js → benchmark-command-D8E5TaPC.js} +6 -5
  10. package/dist/{benchmark-command-Bw1he2JM.js.map → benchmark-command-D8E5TaPC.js.map} +1 -1
  11. package/dist/benchmarks/index.d.ts +4 -3
  12. package/dist/benchmarks/index.d.ts.map +1 -1
  13. package/dist/benchmarks/index.js +3 -3
  14. package/dist/campaign/index.d.ts +5 -4
  15. package/dist/campaign/index.js +13 -11
  16. package/dist/{campaign-qe1WC3Sz.js → campaign-Dlg2iOzH.js} +13 -12
  17. package/dist/{campaign-qe1WC3Sz.js.map → campaign-Dlg2iOzH.js.map} +1 -1
  18. package/dist/{campaign-evidence-DJc60F9C.js → campaign-evidence-jL_U7Ikv.js} +2 -2
  19. package/dist/{campaign-evidence-DJc60F9C.js.map → campaign-evidence-jL_U7Ikv.js.map} +1 -1
  20. package/dist/cli.js +243 -13
  21. package/dist/cli.js.map +1 -1
  22. package/dist/contract/index.d.ts +7 -6
  23. package/dist/contract/index.js +9 -9
  24. package/dist/{default-registry-D2csUBBQ.d.ts → default-registry-oK9hHfX_.d.ts} +3 -3
  25. package/dist/{default-registry-D2csUBBQ.d.ts.map → default-registry-oK9hHfX_.d.ts.map} +1 -1
  26. package/dist/{define-agent-eval-DwAaPvvH.d.ts → define-agent-eval-By9PImpa.d.ts} +5 -4
  27. package/dist/define-agent-eval-By9PImpa.d.ts.map +1 -0
  28. package/dist/{define-agent-eval-h2qYe0xY.js → define-agent-eval-DvBgSzAI.js} +6 -6
  29. package/dist/{define-agent-eval-h2qYe0xY.js.map → define-agent-eval-DvBgSzAI.js.map} +1 -1
  30. package/dist/diagnosis/index.js +1 -1
  31. package/dist/{dspy-rlm-engine-k_QdEBZo.js → dspy-rlm-engine-B5T43BkZ.js} +2 -2
  32. package/dist/{dspy-rlm-engine-k_QdEBZo.js.map → dspy-rlm-engine-B5T43BkZ.js.map} +1 -1
  33. package/dist/{engine-De2hfuiQ.d.ts → engine-Dc996kAg.d.ts} +2 -2
  34. package/dist/{engine-De2hfuiQ.d.ts.map → engine-Dc996kAg.d.ts.map} +1 -1
  35. package/dist/{eval-campaign-CXT2WYUe.js → eval-campaign-GapmPHIA.js} +2 -2
  36. package/dist/{eval-campaign-CXT2WYUe.js.map → eval-campaign-GapmPHIA.js.map} +1 -1
  37. package/dist/evaluation.d.ts +1 -1
  38. package/dist/experiment/index.d.ts +1 -1
  39. package/dist/experiment/index.js +8 -6
  40. package/dist/experiment/index.js.map +1 -1
  41. package/dist/{external-optimizer-process-_YIECYJ7.js → external-optimizer-process-CEXcCKqd.js} +2 -2
  42. package/dist/{external-optimizer-process-_YIECYJ7.js.map → external-optimizer-process-CEXcCKqd.js.map} +1 -1
  43. package/dist/{external-optimizer-subprocess-BrghTvEp.js → external-optimizer-subprocess-laM1-UDV.js} +2 -61
  44. package/dist/external-optimizer-subprocess-laM1-UDV.js.map +1 -0
  45. package/dist/fuzz.d.ts.map +1 -1
  46. package/dist/fuzz.js +2 -3
  47. package/dist/fuzz.js.map +1 -1
  48. package/dist/hosted/index.js +1 -1
  49. package/dist/{index-CigojbNH.d.ts → index-BhoOCduB.d.ts} +38 -945
  50. package/dist/index-BhoOCduB.d.ts.map +1 -0
  51. package/dist/{index-CpCIXObe.d.ts → index-D-tI1vgf.d.ts} +6 -6
  52. package/dist/{index-CpCIXObe.d.ts.map → index-D-tI1vgf.d.ts.map} +1 -1
  53. package/dist/{index-kKECJfib.d.ts → index-lbwvO9vJ.d.ts} +3 -3
  54. package/dist/{index-kKECJfib.d.ts.map → index-lbwvO9vJ.d.ts.map} +1 -1
  55. package/dist/index.d.ts +9 -9
  56. package/dist/index.js +15 -13
  57. package/dist/index.js.map +1 -1
  58. package/dist/jev-protocol.d.ts +17 -9
  59. package/dist/jev-protocol.d.ts.map +1 -1
  60. package/dist/jev-protocol.js +22 -14
  61. package/dist/jev-protocol.js.map +1 -1
  62. package/dist/jev.d.ts +3 -3
  63. package/dist/jev.js +3 -7
  64. package/dist/jev.js.map +1 -1
  65. package/dist/{llm-judge-CxfoYqdk.js → llm-judge-BYWXsxhZ.js} +529 -2079
  66. package/dist/llm-judge-BYWXsxhZ.js.map +1 -0
  67. package/dist/{matrix-C1X-fIVX.d.ts → matrix-BnksRaDD.d.ts} +2 -2
  68. package/dist/{matrix-C1X-fIVX.d.ts.map → matrix-BnksRaDD.d.ts.map} +1 -1
  69. package/dist/multiplicity-D9cjmStq.js +101 -0
  70. package/dist/multiplicity-D9cjmStq.js.map +1 -0
  71. package/dist/multishot/golden/index.d.ts +1 -1
  72. package/dist/multishot/golden/index.js +1 -1
  73. package/dist/multishot/index.d.ts +2 -2
  74. package/dist/multishot/index.js +1 -1
  75. package/dist/openapi.json +1 -1
  76. package/dist/{paired-arms-JSDcs2zx.js → paired-arms-DKZFVPt8.js} +4 -398
  77. package/dist/paired-arms-DKZFVPt8.js.map +1 -0
  78. package/dist/paired-binary-fzkwENI4.js +399 -0
  79. package/dist/paired-binary-fzkwENI4.js.map +1 -0
  80. package/dist/{paired-promotion-decision-DTKl6-G8.js → paired-promotion-decision-D5B1Cxc2.js} +78 -5
  81. package/dist/paired-promotion-decision-D5B1Cxc2.js.map +1 -0
  82. package/dist/{power-and-mde-BJOpt6pq.js → power-and-mde-K_CmO3dc.js} +3 -101
  83. package/dist/power-and-mde-K_CmO3dc.js.map +1 -0
  84. package/dist/{produced-state-B0QMdiLh.js → produced-state-DOfmCEwP.js} +3 -3
  85. package/dist/{produced-state-B0QMdiLh.js.map → produced-state-DOfmCEwP.js.map} +1 -1
  86. package/dist/{promotion-policy-Cy5OV8BV.js → promotion-policy-C6FAJvmZ.js} +3 -3
  87. package/dist/{promotion-policy-Cy5OV8BV.js.map → promotion-policy-C6FAJvmZ.js.map} +1 -1
  88. package/dist/reporting.js +3 -3
  89. package/dist/rl.d.ts +17 -39
  90. package/dist/rl.d.ts.map +1 -1
  91. package/dist/rl.js +5 -5
  92. package/dist/search/index.d.ts +1162 -0
  93. package/dist/search/index.d.ts.map +1 -0
  94. package/dist/search/index.js +187 -0
  95. package/dist/search/index.js.map +1 -0
  96. package/dist/search-kernel-CuvbakC_.d.ts +1176 -0
  97. package/dist/search-kernel-CuvbakC_.d.ts.map +1 -0
  98. package/dist/search-kernel-D8_kxChy.js +2399 -0
  99. package/dist/search-kernel-D8_kxChy.js.map +1 -0
  100. package/dist/{search-ledger-9W0g5FP6.js → search-ledger-BnUytR8X.js} +3 -1
  101. package/dist/search-ledger-BnUytR8X.js.map +1 -0
  102. package/dist/{search-shipper-CYbmJQx8.js → search-shipper-Cn8cxcyp.js} +2 -2
  103. package/dist/{search-shipper-CYbmJQx8.js.map → search-shipper-Cn8cxcyp.js.map} +1 -1
  104. package/dist/search-summary-Dmppg8kV.js +133 -0
  105. package/dist/search-summary-Dmppg8kV.js.map +1 -0
  106. package/dist/{semantic-concept-judge-Bh5lvKGg.js → semantic-concept-judge-2SE_kXGF.js} +2 -2
  107. package/dist/{semantic-concept-judge-Bh5lvKGg.js.map → semantic-concept-judge-2SE_kXGF.js.map} +1 -1
  108. package/dist/{sequential-C21_PP7F.js → sequential-Yz3OSskl.js} +2 -2
  109. package/dist/{sequential-C21_PP7F.js.map → sequential-Yz3OSskl.js.map} +1 -1
  110. package/dist/single-run-lock-fVu3MZWH.js +62 -0
  111. package/dist/single-run-lock-fVu3MZWH.js.map +1 -0
  112. package/dist/{skillopt-optimization-method-IbEhlA1V.js → skillopt-optimization-method-BMP2qV_1.js} +46 -33
  113. package/dist/{skillopt-optimization-method-IbEhlA1V.js.map → skillopt-optimization-method-BMP2qV_1.js.map} +1 -1
  114. package/dist/{statistical-heldout-DANVmyug.js → statistical-heldout-BAFDCo07.js} +2 -2
  115. package/dist/{statistical-heldout-DANVmyug.js.map → statistical-heldout-BAFDCo07.js.map} +1 -1
  116. package/dist/{statistical-heldout-BedVSZb2.d.ts → statistical-heldout-CMpxMjlQ.d.ts} +2 -2
  117. package/dist/{statistical-heldout-BedVSZb2.d.ts.map → statistical-heldout-CMpxMjlQ.d.ts.map} +1 -1
  118. package/dist/{store-tool-spans-CawP-WxM.d.ts → store-tool-spans-CUwWSXoj.d.ts} +3 -3
  119. package/dist/{store-tool-spans-CawP-WxM.d.ts.map → store-tool-spans-CUwWSXoj.d.ts.map} +1 -1
  120. package/dist/{summary-report-BMvou2oZ.js → summary-report-BeYnvddy.js} +4 -3
  121. package/dist/{summary-report-BMvou2oZ.js.map → summary-report-BeYnvddy.js.map} +1 -1
  122. package/dist/{tool-groups-B4JVrH3g.d.ts → tool-groups-DVJAR1GE.d.ts} +2 -2
  123. package/dist/tool-groups-DVJAR1GE.d.ts.map +1 -0
  124. package/dist/trace-repair/index.d.ts +1 -1
  125. package/dist/traces.d.ts +2 -2
  126. package/dist/tree-DHHWsH-X.js +4045 -0
  127. package/dist/tree-DHHWsH-X.js.map +1 -0
  128. package/dist/{types-B3jzCp0p.js → types-B3jzCp0p2.js} +1 -1
  129. package/dist/types-B3jzCp0p2.js.map +1 -0
  130. package/dist/{types-CjFDKMDe.d.ts → types-D94EanDL.d.ts} +2 -2
  131. package/dist/{types-CjFDKMDe.d.ts.map → types-D94EanDL.d.ts.map} +1 -1
  132. package/dist/{types-B2673PBj.d.ts → types-EBUav9Bu.d.ts} +8 -4
  133. package/dist/types-EBUav9Bu.d.ts.map +1 -0
  134. package/docs/campaign-proposers.md +2 -0
  135. package/docs/design/statistics-decisions.md +1 -1
  136. package/docs/jev.md +3 -2
  137. package/docs/search-ledger.md +145 -8
  138. package/package.json +6 -1
  139. package/dist/active-curriculum-OjIWgrUJ.js +0 -204
  140. package/dist/active-curriculum-OjIWgrUJ.js.map +0 -1
  141. package/dist/define-agent-eval-DwAaPvvH.d.ts.map +0 -1
  142. package/dist/external-optimizer-subprocess-BrghTvEp.js.map +0 -1
  143. package/dist/index-CigojbNH.d.ts.map +0 -1
  144. package/dist/llm-judge-CxfoYqdk.js.map +0 -1
  145. package/dist/paired-arms-JSDcs2zx.js.map +0 -1
  146. package/dist/paired-delta-test-BF-FEP8V.js +0 -78
  147. package/dist/paired-delta-test-BF-FEP8V.js.map +0 -1
  148. package/dist/paired-promotion-decision-DTKl6-G8.js.map +0 -1
  149. package/dist/power-and-mde-BJOpt6pq.js.map +0 -1
  150. package/dist/search-ledger-9W0g5FP6.js.map +0 -1
  151. package/dist/search-summary-CcavvYLe.js +0 -378
  152. package/dist/search-summary-CcavvYLe.js.map +0 -1
  153. package/dist/tool-groups-B4JVrH3g.d.ts.map +0 -1
  154. package/dist/types-B2673PBj.d.ts.map +0 -1
  155. package/dist/types-B3jzCp0p.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { p as CostProvenance } from "./cost-ledger-DbQdN3nO.js";
2
- import { w as JudgeScore } from "./types-B2673PBj.js";
2
+ import { w as JudgeScore } from "./types-EBUav9Bu.js";
3
3
  import { o as MatrixResult } from "./index-DNgf5gyG.js";
4
4
  import { AgentProfile } from "@tangle-network/agent-interface";
5
5
  //#region src/multishot/types.d.ts
@@ -398,4 +398,4 @@ interface RunMultishotMatrixResult {
398
398
  declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
399
399
  //#endregion
400
400
  export { MultishotToolExecutor as A, MultishotFatalToolError as C, MultishotShape as D, MultishotResult as E, assertMultishotShotResult as F, MultishotTransportRequest as M, MultishotTransportResponse as N, MultishotShotResultError as O, MultishotTransportToolCall as P, MultishotDriverEmptyError as S, MultishotPersona as T, JudgeRunResult as _, MultishotCellOutput as a, runJudge as b, RunMultishotMatrixResult as c, MultishotShot as d, RunMultishotOptions as f, JudgeDimension as g, JudgeConfig as h, ConversationJudgeInput as i, MultishotTransport as j, MultishotToolDefinition as k, computeCellComposite as l, DEFAULT_JUDGE_MODEL as m, CellCompositeInput as n, MultishotJudges as o, runMultishot as p, CellCompositeScore as r, RunMultishotMatrixOptions as s, ArtifactJudgeInput as t, runMultishotMatrix as u, renderDimensions as v, MultishotMessage as w, MultishotArtifact as x, renderJsonFooter as y };
401
- //# sourceMappingURL=matrix-C1X-fIVX.d.ts.map
401
+ //# sourceMappingURL=matrix-BnksRaDD.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix-C1X-fIVX.d.ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;;UAIiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;;;EAGA;;;;;;;;EAQA,iBAAiB;;UAGF;EACf;EACA;IACE;IACA;IACA,YAAY;;;;;;UAOC;EACf;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;;EAGlC;;;;EAIA;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;;EAEE,WAAW;EACX,SAAS;MAER;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA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,eAAe;;EAEvB,QAAQ,gBAAgB;;EAExB,QAAQ;;EAER,gBAAgB,eAAe;;EAE/B,mBAAmB;;EAEnB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,gBAAgB;;EAEhB,iBAAiB;;;EAGjB,gBAAgB;;;;;;;;;;;;;;;EAehB,UAAU,cAAc;;;;;UAMT;EACf;EACA;EACA;;UAoBe;EACf,cAAc;;EAEd,cAAc,cAAc;;EAE5B,iBAAiB,cAAc;;;;;;;iBAQjB,qBAAqB,OAAO;EAC1C;EACA;EACA;EACA;;UAuBe;EACf,QAAQ,aAAa;;iBAGD,mBAAmB,iBAAiB,kBACxD,MAAM,0BAA0B,YAC/B,QAAQ"}
1
+ {"version":3,"file":"matrix-BnksRaDD.d.ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;;UAIiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;;;EAGA;;;;;;;;EAQA,iBAAiB;;UAGF;EACf;EACA;IACE;IACA;IACA,YAAY;;;;;;UAOC;EACf;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;;EAGlC;;;;EAIA;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;;EAEE,WAAW;EACX,SAAS;MAER;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA2B,SAAS;;cAGzB,kCAAk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gBAAgB;;EAExB,QAAQ;;EAER,gBAAgB,eAAe;;EAE/B,mBAAmB;;EAEnB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,gBAAgB;;EAEhB,iBAAiB;;;EAGjB,gBAAgB;;;;;;;;;;;;;;;EAehB,UAAU,cAAc;;;;;UAMT;EACf;EACA;EACA;;UAoBe;EACf,cAAc;;EAEd,cAAc,cAAc;;EAE5B,iBAAiB,cAAc;;;;;;;iBAQjB,qBAAqB,OAAO;EAC1C;EACA;EACA;EACA;;UAuBe;EACf,QAAQ,aAAa;;iBAGD,mBAAmB,iBAAiB,kBACxD,MAAM,0BAA0B,YAC/B,QAAQ"}
@@ -0,0 +1,101 @@
1
+ import { s as ValidationError } from "./errors-Dngq5h35.js";
2
+ //#region src/statistics/multiplicity.ts
3
+ /**
4
+ * Multiple-comparison corrections: family-wise error (Bonferroni, Holm) and
5
+ * false discovery rate (Benjamini-Hochberg), with inclusive rejection
6
+ * boundaries throughout.
7
+ */
8
+ /**
9
+ * Bonferroni adjustment: multiply every p-value by the test count, clamp at 1.
10
+ *
11
+ * Rejects at `p_adjusted ≤ alpha` — the boundary is inclusive, matching
12
+ * {@link holm}, which uniformly dominates this correction and must therefore
13
+ * never reject less. Validates its inputs on the same terms.
14
+ */
15
+ function bonferroni(pValues, alpha = .05) {
16
+ assertAlpha("bonferroni", "alpha", alpha);
17
+ assertPValues("bonferroni", pValues);
18
+ const k = pValues.length;
19
+ const adjusted = pValues.map((p) => Math.min(1, p * k));
20
+ return {
21
+ adjusted,
22
+ significant: adjusted.map((p) => p <= alpha)
23
+ };
24
+ }
25
+ /**
26
+ * Holm step-down family-wise error adjustment.
27
+ *
28
+ * P-values are sorted from smallest to largest, multiplied by their remaining
29
+ * hypothesis count, and made monotonically non-decreasing before being mapped
30
+ * back to input order. This uniformly dominates plain Bonferroni while keeping
31
+ * strong family-wise error control under arbitrary dependence.
32
+ */
33
+ function holm(pValues, alpha = .05) {
34
+ assertAlpha("holm", "alpha", alpha);
35
+ assertPValues("holm", pValues);
36
+ const count = pValues.length;
37
+ if (count === 0) return {
38
+ adjusted: [],
39
+ significant: []
40
+ };
41
+ const ordered = pValues.map((pValue, index) => ({
42
+ pValue,
43
+ index
44
+ })).sort((a, b) => a.pValue - b.pValue || a.index - b.index);
45
+ const adjusted = new Array(count);
46
+ let previous = 0;
47
+ for (let rank = 0; rank < count; rank++) {
48
+ const entry = ordered[rank];
49
+ const stepAdjusted = Math.min(1, entry.pValue * (count - rank));
50
+ previous = Math.max(previous, stepAdjusted);
51
+ adjusted[entry.index] = previous;
52
+ }
53
+ return {
54
+ adjusted,
55
+ significant: adjusted.map((pValue) => pValue <= alpha)
56
+ };
57
+ }
58
+ /**
59
+ * Benjamini–Hochberg false discovery rate. Returns adjusted q-values and
60
+ * significance at the target FDR; handles ties and preserves q monotonicity.
61
+ *
62
+ * Rejects at `q ≤ fdr` — the BH rule is inclusive at the boundary, so an
63
+ * exactly-`fdr` q-value is a discovery.
64
+ */
65
+ function benjaminiHochberg(pValues, fdr = .05) {
66
+ assertAlpha("benjaminiHochberg", "fdr", fdr);
67
+ assertPValues("benjaminiHochberg", pValues);
68
+ const n = pValues.length;
69
+ if (n === 0) return {
70
+ qValues: [],
71
+ significant: []
72
+ };
73
+ const indexed = pValues.map((p, i) => ({
74
+ p,
75
+ i
76
+ })).sort((a, b) => a.p - b.p);
77
+ const q = new Array(n);
78
+ let minRight = 1;
79
+ for (let k = n - 1; k >= 0; k--) {
80
+ const rank = k + 1;
81
+ const entry = indexed[k];
82
+ const raw = n / rank * entry.p;
83
+ const bounded = Math.min(minRight, raw);
84
+ minRight = bounded;
85
+ q[entry.i] = Math.min(1, bounded);
86
+ }
87
+ return {
88
+ qValues: q,
89
+ significant: q.map((v) => v <= fdr)
90
+ };
91
+ }
92
+ function assertAlpha(fn, label, value) {
93
+ if (!Number.isFinite(value) || value <= 0 || value >= 1) throw new ValidationError(`${fn}: ${label} must be in (0,1), got ${value}`);
94
+ }
95
+ function assertPValues(fn, pValues) {
96
+ for (const [index, pValue] of pValues.entries()) if (!Number.isFinite(pValue) || pValue < 0 || pValue > 1) throw new ValidationError(`${fn}: pValues[${index}] must be in [0,1], got ${pValue}`);
97
+ }
98
+ //#endregion
99
+ export { bonferroni as n, holm as r, benjaminiHochberg as t };
100
+
101
+ //# sourceMappingURL=multiplicity-D9cjmStq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplicity-D9cjmStq.js","names":[],"sources":["../src/statistics/multiplicity.ts"],"sourcesContent":["/**\n * Multiple-comparison corrections: family-wise error (Bonferroni, Holm) and\n * false discovery rate (Benjamini-Hochberg), with inclusive rejection\n * boundaries throughout.\n */\n\nimport { ValidationError } from '../errors'\n\n/**\n * Bonferroni adjustment: multiply every p-value by the test count, clamp at 1.\n *\n * Rejects at `p_adjusted ≤ alpha` — the boundary is inclusive, matching\n * {@link holm}, which uniformly dominates this correction and must therefore\n * never reject less. Validates its inputs on the same terms.\n */\nexport function bonferroni(\n pValues: readonly number[],\n alpha = 0.05,\n): { adjusted: number[]; significant: boolean[] } {\n assertAlpha('bonferroni', 'alpha', alpha)\n assertPValues('bonferroni', pValues)\n const k = pValues.length\n const adjusted = pValues.map((p) => Math.min(1, p * k))\n return { adjusted, significant: adjusted.map((p) => p <= alpha) }\n}\n\n/**\n * Holm step-down family-wise error adjustment.\n *\n * P-values are sorted from smallest to largest, multiplied by their remaining\n * hypothesis count, and made monotonically non-decreasing before being mapped\n * back to input order. This uniformly dominates plain Bonferroni while keeping\n * strong family-wise error control under arbitrary dependence.\n */\nexport function holm(\n pValues: readonly number[],\n alpha = 0.05,\n): { adjusted: number[]; significant: boolean[] } {\n assertAlpha('holm', 'alpha', alpha)\n assertPValues('holm', pValues)\n const count = pValues.length\n if (count === 0) return { adjusted: [], significant: [] }\n\n const ordered = pValues\n .map((pValue, index) => ({ pValue, index }))\n .sort((a, b) => a.pValue - b.pValue || a.index - b.index)\n const adjusted = new Array<number>(count)\n let previous = 0\n for (let rank = 0; rank < count; rank++) {\n const entry = ordered[rank]!\n const stepAdjusted = Math.min(1, entry.pValue * (count - rank))\n previous = Math.max(previous, stepAdjusted)\n adjusted[entry.index] = previous\n }\n // Holm's rejection rule is inclusive at the adjusted alpha boundary.\n return { adjusted, significant: adjusted.map((pValue) => pValue <= alpha) }\n}\n\n/**\n * Benjamini–Hochberg false discovery rate. Returns adjusted q-values and\n * significance at the target FDR; handles ties and preserves q monotonicity.\n *\n * Rejects at `q ≤ fdr` — the BH rule is inclusive at the boundary, so an\n * exactly-`fdr` q-value is a discovery.\n */\nexport function benjaminiHochberg(\n pValues: readonly number[],\n fdr = 0.05,\n): { qValues: number[]; significant: boolean[] } {\n assertAlpha('benjaminiHochberg', 'fdr', fdr)\n assertPValues('benjaminiHochberg', pValues)\n const n = pValues.length\n if (n === 0) return { qValues: [], significant: [] }\n const indexed = pValues.map((p, i) => ({ p, i })).sort((a, b) => a.p - b.p)\n const q = new Array<number>(n)\n let minRight = 1\n for (let k = n - 1; k >= 0; k--) {\n const rank = k + 1\n const entry = indexed[k]!\n // (n/rank)·p, not (p·n)/rank: the latter lands one ULP above `fdr` at an\n // exact boundary (p = 0.05, n = 3, rank = 3 gives 0.05000000000000001),\n // which silently turns a discovery into a non-discovery. This is R's\n // `p.adjust(method = \"BH\")` formulation.\n const raw = (n / rank) * entry.p\n const bounded = Math.min(minRight, raw)\n minRight = bounded\n q[entry.i] = Math.min(1, bounded)\n }\n return { qValues: q, significant: q.map((v) => v <= fdr) }\n}\n\nfunction assertAlpha(fn: string, label: string, value: number): void {\n if (!Number.isFinite(value) || value <= 0 || value >= 1) {\n throw new ValidationError(`${fn}: ${label} must be in (0,1), got ${value}`)\n }\n}\n\nfunction assertPValues(fn: string, pValues: readonly number[]): void {\n for (const [index, pValue] of pValues.entries()) {\n if (!Number.isFinite(pValue) || pValue < 0 || pValue > 1) {\n throw new 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ACnD,MAAM,UAAU,QAAQ,KAAK,GAAG,OAAO;EAAE;EAAG;CAAE,EAAE,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;CAC1E,MAAM,IAAI,IAAI,MAAc,CAAC;CAC7B,IAAI,WAAW;CACf,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,GAAG,KAAK;EAC/B,MAAM,OAAO,IAAI;EACjB,MAAM,QAAQ,QAAQ;EAKtB,MAAM,MAAO,IAAI,OAAQ,MAAM;EAC/B,MAAM,UAAU,KAAK,IAAI,UAAU,GAAG;EACtC,WAAW;EACX,EAAE,MAAM,KAAK,KAAK,IAAI,GAAG,OAAO;CAClC;CACA,OAAO;EAAE,SAAS;EAAG,aAAa,EAAE,KAAK,MAAM,KAAK,GAAG;CAAE;AAC3D;AAEA,SAAS,YAAY,IAAY,OAAe,OAAqB;CACnE,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,KAAK,SAAS,GACpD,MAAM,IAAI,gBAAgB,GAAG,GAAG,IAAI,MAAM,yBAAyB,OAAO;AAE9E;AAEA,SAAS,cAAc,IAAY,SAAkC;CACnE,KAAK,MAAM,CAAC,OAAO,WAAW,QAAQ,QAAQ,GAC5C,IAAI,CAAC,OAAO,SAAS,MAAM,KAAK,SAAS,KAAK,SAAS,GACrD,MAAM,IAAI,gBAAgB,GAAG,GAAG,YAAY,MAAM,0BAA0B,QAAQ;AAG1F"}
@@ -1,4 +1,4 @@
1
- import { E as MultishotResult, M as MultishotTransportRequest, T as MultishotPersona, c as RunMultishotMatrixResult, f as RunMultishotOptions, k as MultishotToolDefinition, s as RunMultishotMatrixOptions } from "../../matrix-C1X-fIVX.js";
1
+ import { E as MultishotResult, M as MultishotTransportRequest, T as MultishotPersona, c as RunMultishotMatrixResult, f as RunMultishotOptions, k as MultishotToolDefinition, s as RunMultishotMatrixOptions } from "../../matrix-BnksRaDD.js";
2
2
  //#region src/multishot/golden/compare.d.ts
3
3
  interface CompareOptions {
4
4
  /** Stop after this many mismatches. A structural divergence high in the
@@ -1,5 +1,5 @@
1
1
  import { n as readCellSpend } from "../../matrix-pWinRMPl.js";
2
- import { n as MultishotFatalToolError } from "../../types-B3jzCp0p.js";
2
+ import { n as MultishotFatalToolError } from "../../types-B3jzCp0p2.js";
3
3
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
4
4
  import { join, posix, relative, sep } from "node:path";
5
5
  //#region src/multishot/golden/compare.ts
@@ -1,5 +1,5 @@
1
- import { w as JudgeScore } from "../types-B2673PBj.js";
2
- import { A as MultishotToolExecutor, C as MultishotFatalToolError, D as MultishotShape, E as MultishotResult, F as assertMultishotShotResult, M as MultishotTransportRequest, N as MultishotTransportResponse, O as MultishotShotResultError, P as MultishotTransportToolCall, S as MultishotDriverEmptyError, T as MultishotPersona, _ as JudgeRunResult, a as MultishotCellOutput, b as runJudge, c as RunMultishotMatrixResult, d as MultishotShot, f as RunMultishotOptions, g as JudgeDimension, h as JudgeConfig, i as ConversationJudgeInput, j as MultishotTransport, k as MultishotToolDefinition, l as computeCellComposite, m as DEFAULT_JUDGE_MODEL, n as CellCompositeInput, o as MultishotJudges, p as runMultishot, r as CellCompositeScore, s as RunMultishotMatrixOptions, t as ArtifactJudgeInput, u as runMultishotMatrix, v as renderDimensions, w as MultishotMessage, x as MultishotArtifact, y as renderJsonFooter } from "../matrix-C1X-fIVX.js";
1
+ import { w as JudgeScore } from "../types-EBUav9Bu.js";
2
+ import { A as MultishotToolExecutor, C as MultishotFatalToolError, D as MultishotShape, E as MultishotResult, F as assertMultishotShotResult, M as MultishotTransportRequest, N as MultishotTransportResponse, O as MultishotShotResultError, P as MultishotTransportToolCall, S as MultishotDriverEmptyError, T as MultishotPersona, _ as JudgeRunResult, a as MultishotCellOutput, b as runJudge, c as RunMultishotMatrixResult, d as MultishotShot, f as RunMultishotOptions, g as JudgeDimension, h as JudgeConfig, i as ConversationJudgeInput, j as MultishotTransport, k as MultishotToolDefinition, l as computeCellComposite, m as DEFAULT_JUDGE_MODEL, n as CellCompositeInput, o as MultishotJudges, p as runMultishot, r as CellCompositeScore, s as RunMultishotMatrixOptions, t as ArtifactJudgeInput, u as runMultishotMatrix, v as renderDimensions, w as MultishotMessage, x as MultishotArtifact, y as renderJsonFooter } from "../matrix-BnksRaDD.js";
3
3
  import { AgentProfile } from "@tangle-network/agent-interface";
4
4
  //#region src/multishot/cost.d.ts
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { i as isModelPriced, n as estimateCost } from "../metrics-DOMpkoeb.js";
2
2
  import { r as withCellSpend, t as runAgentMatrix } from "../matrix-pWinRMPl.js";
3
- import { i as assertMultishotShotResult, n as MultishotFatalToolError, r as MultishotShotResultError, t as MultishotDriverEmptyError } from "../types-B3jzCp0p.js";
3
+ import { i as assertMultishotShotResult, n as MultishotFatalToolError, r as MultishotShotResultError, t as MultishotDriverEmptyError } from "../types-B3jzCp0p2.js";
4
4
  import { mkdirSync, writeFileSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  //#region src/multishot/cost.ts
package/dist/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "@tangle-network/agent-eval — wire protocol",
5
- "version": "0.196.0",
5
+ "version": "0.198.0",
6
6
  "description": "HTTP and stdio RPC interface to agent-eval. The TypeScript runtime is the source of truth; this spec is the contract that cross-language clients (Python, Rust, Go) generate from.\n\nWire-protocol version: 1.1.0. Bumps on breaking changes to request/response schemas.",
7
7
  "contact": {
8
8
  "name": "Tangle Network",
@@ -1,401 +1,7 @@
1
1
  import { s as ValidationError } from "./errors-Dngq5h35.js";
2
- import { c as lnGamma, i as makeRng, l as regularizedIncompleteBeta, o as symmetricTwoSampleSeed, r as binomialSignTwoSided, s as zQuantile, t as assertFiniteSample } from "./internal-BMFSR8Ns.js";
2
+ import { c as lnGamma, i as makeRng, o as symmetricTwoSampleSeed, r as binomialSignTwoSided, t as assertFiniteSample } from "./internal-BMFSR8Ns.js";
3
+ import { i as pairedRiskDifference, n as mcnemar } from "./paired-binary-fzkwENI4.js";
3
4
  import { r as pairedBootstrap } from "./paired-tests-C8iCsioC.js";
4
- //#region src/statistics/paired-binary.ts
5
- /**
6
- * Wilson score interval for a binomial proportion. Correct at small n and near
7
- * 0/1, where the normal (Wald) approximation produces bounds outside [0, 1] and
8
- * understates coverage. Use this for any pass-rate / hit-rate / realness-rate
9
- * CI — the continuous `confidenceInterval` assumes the wrong distribution for a
10
- * proportion. `n = 0 ⇒ {0, 0, 0}`.
11
- */
12
- function wilson(successes, n, confidence = .95) {
13
- if (n <= 0) return {
14
- estimate: 0,
15
- lower: 0,
16
- upper: 0
17
- };
18
- if (successes < 0 || successes > n) throw new Error(`wilson: successes (${successes}) must be in [0, ${n}]`);
19
- const z = zQuantile(1 - (1 - confidence) / 2);
20
- const p = successes / n;
21
- const z2 = z * z;
22
- const denom = 1 + z2 / n;
23
- const center = (p + z2 / (2 * n)) / denom;
24
- const half = z * Math.sqrt((p * (1 - p) + z2 / (4 * n)) / n) / denom;
25
- return {
26
- estimate: p,
27
- lower: Math.max(0, center - half),
28
- upper: Math.min(1, center + half)
29
- };
30
- }
31
- /**
32
- * Are these per-item outcomes binary (every value exactly 0 or 1)?
33
- *
34
- * The discriminator a promotion gate needs before choosing a paired statistic.
35
- * On binary outcomes the paired delta vector lives in {-1, 0, +1} and is
36
- * normally dominated by zeros (both arms solve, or both arms miss, most items),
37
- * so its MEDIAN is pinned at exactly 0 no matter how large the real shift in
38
- * success rate is — and a bootstrap CI on that median collapses to [0, 0].
39
- * A gate keying on `ci.low > threshold` is then structurally unable to see
40
- * either a gain or a regression. Detect this shape and switch to the
41
- * paired-binary estimators ({@link mcnemar}, {@link pairedRiskDifference})
42
- * instead of silently answering "no" forever.
43
- *
44
- * Empty input is NOT binary: there is no evidence of the outcome's shape, and
45
- * defaulting an empty vector into the binary branch would pick a statistic on
46
- * no data at all.
47
- *
48
- * NOT the right discriminator for a gate. It recognises the literal {0, 1}
49
- * encoding and nothing else, so a pass/fail dimension emitted on 0-100 — which
50
- * judges in this codebase do routinely — reads as non-binary, and a single
51
- * partial-credit score in an otherwise pass/fail vector flips it to false while
52
- * leaving the median just as blind. Gates want {@link pairedBinaryScale} (any
53
- * two-point encoding). This predicate remains for callers that specifically
54
- * mean "literally 0/1".
55
- */
56
- function isBinaryOutcomeVector(values) {
57
- if (values.length === 0) return false;
58
- for (let i = 0; i < values.length; i++) {
59
- const v = values[i];
60
- if (v !== 0 && v !== 1) return false;
61
- }
62
- return true;
63
- }
64
- /**
65
- * McNemar's test for paired binary outcomes — the correct significance test for
66
- * "does treatment change the success rate vs control on the SAME items". Only
67
- * discordant pairs (one arm right, the other wrong) carry information; concordant
68
- * pairs are uninformative, so a paired t-test / two-proportion z-test on the raw
69
- * rates is wrong here. The p-value is exact: under H0 the b "treatment-wins" are
70
- * Binomial(b + c, 0.5), so the two-sided p is the doubled binomial tail — correct
71
- * at the small discordant counts typical of eval runs (no continuity-corrected
72
- * chi-square approximation needed, though it is returned as `statistic` for
73
- * reference). Inputs are paired 0/1 (or boolean) arrays, control first to match
74
- * the module's (before, after) convention. Throws on unequal lengths.
75
- */
76
- function mcnemar(control, treatment) {
77
- if (control.length !== treatment.length) throw new Error(`mcnemar: unequal sample sizes (${control.length} vs ${treatment.length})`);
78
- const n = control.length;
79
- let b = 0;
80
- let c = 0;
81
- for (let i = 0; i < n; i++) {
82
- const ctrl = control[i] ? 1 : 0;
83
- const treat = treatment[i] ? 1 : 0;
84
- if (treat === 1 && ctrl === 0) b++;
85
- else if (treat === 0 && ctrl === 1) c++;
86
- }
87
- const nDiscordant = b + c;
88
- const statistic = nDiscordant === 0 ? 0 : (Math.abs(b - c) - 1) ** 2 / nDiscordant;
89
- return {
90
- n,
91
- nDiscordant,
92
- b,
93
- c,
94
- statistic,
95
- pValue: binomialSignTwoSided(b, c)
96
- };
97
- }
98
- /**
99
- * Paired risk difference (the effect-size companion to {@link mcnemar}): the
100
- * change in success rate p(treatment) − p(control) on matched items, which for
101
- * paired binary data equals (b − c) / n. The CI uses the paired variance from
102
- * the discordant counts, not the independent-samples formula (which overstates
103
- * the interval by ignoring the pairing). Inputs are paired 0/1 (or boolean)
104
- * arrays, control first. Throws on unequal lengths.
105
- *
106
- * REPORTING ONLY — do NOT decide a promotion on this interval. The CI is a Wald
107
- * normal approximation, which badly UNDERCOVERS when only a handful of pairs are
108
- * discordant: at n = 3 with b = 2, c = 0 it returns [0.133, 1.000], excluding 0,
109
- * while McNemar's exact test on the same data gives p = 0.50. A gate keying on
110
- * `lower > 0` would promote noise. Use {@link pairedRiskDifferenceExact}, whose
111
- * interval is dual to the exact test by construction, for any decision.
112
- */
113
- function pairedRiskDifference(control, treatment, confidence = .95) {
114
- if (control.length !== treatment.length) throw new Error(`pairedRiskDifference: unequal sample sizes (${control.length} vs ${treatment.length})`);
115
- const n = control.length;
116
- if (n === 0) return {
117
- n: 0,
118
- b: 0,
119
- c: 0,
120
- riskDifference: 0,
121
- lower: 0,
122
- upper: 0,
123
- confidence
124
- };
125
- let b = 0;
126
- let c = 0;
127
- for (let i = 0; i < n; i++) {
128
- const ctrl = control[i] ? 1 : 0;
129
- const treat = treatment[i] ? 1 : 0;
130
- if (treat === 1 && ctrl === 0) b++;
131
- else if (treat === 0 && ctrl === 1) c++;
132
- }
133
- const rd = (b - c) / n;
134
- const variance = (b + c - (b - c) ** 2 / n) / (n * n);
135
- const half = zQuantile(1 - (1 - confidence) / 2) * Math.sqrt(Math.max(0, variance));
136
- return {
137
- n,
138
- b,
139
- c,
140
- riskDifference: rd,
141
- lower: Math.max(-1, rd - half),
142
- upper: Math.min(1, rd + half),
143
- confidence
144
- };
145
- }
146
- /**
147
- * Paired risk difference with the EXACT CONDITIONAL interval — the estimator a
148
- * promotion gate may decide on.
149
- *
150
- * Conditional on the number of discordant pairs m = b + c, the treatment-win
151
- * count b is Binomial(m, π) with π = P(treatment wins | discordant), and the
152
- * risk difference is an exact reparameterisation: RD = (2π − 1)·m/n. So a
153
- * Clopper-Pearson exact interval for π maps straight onto RD. This buys the
154
- * property the Wald interval in {@link pairedRiskDifference} does not have:
155
- *
156
- * **`lower > 0` ⟺ McNemar's exact test rejects at α = 1 − confidence.**
157
- *
158
- * Clopper-Pearson excludes π = 0.5 exactly when the two-sided exact binomial
159
- * test of π = 0.5 rejects, and that test IS {@link mcnemar}'s p-value — so the
160
- * interval and the test can never disagree, and a gate keyed on `lower` cannot
161
- * promote what the exact test refuses. The exact p is returned in the same
162
- * object so the two are impossible to compute apart.
163
- *
164
- * The interval is conservative (exact intervals over-cover; conditioning on m
165
- * discards the concordant pairs' information about m itself). That is the
166
- * correct direction for a promotion gate: it refuses more often, never less.
167
- *
168
- * With m = 0 there are no discordant pairs and π is not identified: the result
169
- * is the degenerate [0, 0] with p = 1. That is NOT evidence of equivalence —
170
- * callers must treat a zero-width interval as "cannot decide", not as "no
171
- * difference". Inputs are paired 0/1 (or boolean) arrays, control first.
172
- * Throws on unequal lengths.
173
- */
174
- function pairedRiskDifferenceExact(control, treatment, confidence = .95) {
175
- if (control.length !== treatment.length) throw new Error(`pairedRiskDifferenceExact: unequal sample sizes (${control.length} vs ${treatment.length})`);
176
- if (confidence <= 0 || confidence >= 1) throw new Error(`pairedRiskDifferenceExact: confidence must be in (0,1), got ${confidence}`);
177
- const n = control.length;
178
- if (n === 0) return {
179
- n: 0,
180
- b: 0,
181
- c: 0,
182
- nDiscordant: 0,
183
- riskDifference: 0,
184
- lower: 0,
185
- upper: 0,
186
- confidence,
187
- pValue: 1
188
- };
189
- let b = 0;
190
- let c = 0;
191
- for (let i = 0; i < n; i++) {
192
- const ctrl = control[i] ? 1 : 0;
193
- const treat = treatment[i] ? 1 : 0;
194
- if (treat === 1 && ctrl === 0) b++;
195
- else if (treat === 0 && ctrl === 1) c++;
196
- }
197
- const m = b + c;
198
- const riskDifference = (b - c) / n;
199
- const pValue = binomialSignTwoSided(b, c);
200
- if (m === 0) return {
201
- n,
202
- b,
203
- c,
204
- nDiscordant: 0,
205
- riskDifference: 0,
206
- lower: 0,
207
- upper: 0,
208
- confidence,
209
- pValue
210
- };
211
- const alpha = 1 - confidence;
212
- const piLow = b === 0 ? 0 : betaQuantile(alpha / 2, b, m - b + 1);
213
- const piHigh = b === m ? 1 : betaQuantile(1 - alpha / 2, b + 1, m - b);
214
- const scale = m / n;
215
- return {
216
- n,
217
- b,
218
- c,
219
- nDiscordant: m,
220
- riskDifference,
221
- lower: Math.max(-1, (2 * piLow - 1) * scale),
222
- upper: Math.min(1, (2 * piHigh - 1) * scale),
223
- confidence,
224
- pValue
225
- };
226
- }
227
- /** Inverse regularized incomplete beta by bisection on
228
- * {@link regularizedIncompleteBeta}, which is monotone increasing in x. 80
229
- * halvings of [0,1] resolve to ~8e-25, far past the continued fraction's own
230
- * 3e-15 tolerance, so the quantile is as exact as the CDF it inverts. */
231
- function betaQuantile(p, a, b) {
232
- if (p <= 0) return 0;
233
- if (p >= 1) return 1;
234
- let lo = 0;
235
- let hi = 1;
236
- for (let i = 0; i < 80; i++) {
237
- const mid = (lo + hi) / 2;
238
- if (regularizedIncompleteBeta(mid, a, b) < p) lo = mid;
239
- else hi = mid;
240
- }
241
- return (lo + hi) / 2;
242
- }
243
- /**
244
- * Constrained MLE of q = P(treatment loses) under the hypothesis RD = `delta`.
245
- *
246
- * Profiling the two concordant cells out of the multinomial leaves
247
- * `L(q) = b·log(q+delta) + c·log(q) + e·log(1 − 2q − delta)` with `e = n − b − c`,
248
- * whose stationary point is the positive root of
249
- * `2n·q² − [(b + c) − delta·(b + 3c + 2e)]·q − c·delta·(1 − delta) = 0`.
250
- * At `delta = 0` this returns `(b + c) / 2n`, the familiar null.
251
- */
252
- function constrainedLossRate(b, c, n, delta) {
253
- const e = n - b - c;
254
- const quadratic = 2 * n;
255
- const linear = -(b + c - delta * (b + 3 * c + 2 * e));
256
- const constant = -c * delta * (1 - delta);
257
- const discriminant = linear * linear - 4 * quadratic * constant;
258
- const root = discriminant > 0 ? Math.sqrt(discriminant) : 0;
259
- const q = (-linear + root) / (2 * quadratic);
260
- return Math.min(Math.max(q, Math.max(0, -delta)), Math.max(0, (1 - delta) / 2));
261
- }
262
- /** Tango's score statistic for H0: RD = `delta`. `Var(b − c) = n·(2q + delta −
263
- * delta²)` under that hypothesis, evaluated at the constrained MLE of q. */
264
- function tangoScore(b, c, n, delta) {
265
- const numerator = b - c - n * delta;
266
- const variance = n * (2 * constrainedLossRate(b, c, n, delta) + delta * (1 - delta));
267
- if (!(variance > 0)) {
268
- if (numerator === 0) return 0;
269
- return numerator > 0 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
270
- }
271
- return numerator / Math.sqrt(variance);
272
- }
273
- /**
274
- * Paired risk difference with TANGO'S (1998) SCORE INTERVAL — the estimator a
275
- * promotion gate may decide on **at a nonzero margin**.
276
- *
277
- * {@link pairedRiskDifferenceExact} conditions on the observed discordant count
278
- * `m = b + c`, builds a Clopper-Pearson interval for the win share among those
279
- * `m` pairs, and multiplies by the observed `m/n`. That is exact for testing
280
- * RD = 0 — it is dual to McNemar — but it is NOT a confidence interval for the
281
- * population risk difference at a nonzero margin, because the sampling
282
- * variability of `m/n` itself is discarded. The gap is not academic: with the
283
- * production caller's `pairedDeltaThreshold: -0.05`, a process whose true risk
284
- * difference sits exactly on that margin clears a nominal-95 % `lower > margin`
285
- * check 24.75 % of the time at n = 40 and 43.95 % at n = 76 (2000 replicates
286
- * each) when the conditional interval decides.
287
- *
288
- * Tango's interval inverts the score test of RD = delta, which estimates the
289
- * nuisance loss rate under each hypothesised delta instead of fixing it at the
290
- * observed value, so `m` contributes its own uncertainty. It is the method
291
- * `ratesci::scorepairci` uses for paired risk-difference noninferiority, and it
292
- * is not conditional, so it stays valid as the margin moves away from zero.
293
- *
294
- * The bounds are found by bisecting `tangoScore(delta) = ±z` — the score is
295
- * monotone decreasing in delta, so each crossing is unique. Inputs are paired
296
- * 0/1 (or boolean) arrays, control first. Throws on unequal lengths.
297
- */
298
- function pairedRiskDifferenceScore(control, treatment, confidence = .95) {
299
- if (control.length !== treatment.length) throw new Error(`pairedRiskDifferenceScore: unequal sample sizes (${control.length} vs ${treatment.length})`);
300
- if (confidence <= 0 || confidence >= 1) throw new Error(`pairedRiskDifferenceScore: confidence must be in (0,1), got ${confidence}`);
301
- const n = control.length;
302
- if (n === 0) return {
303
- n: 0,
304
- b: 0,
305
- c: 0,
306
- nDiscordant: 0,
307
- riskDifference: 0,
308
- lower: -1,
309
- upper: 1,
310
- confidence
311
- };
312
- let b = 0;
313
- let c = 0;
314
- for (let i = 0; i < n; i++) {
315
- const ctrl = control[i] ? 1 : 0;
316
- const treat = treatment[i] ? 1 : 0;
317
- if (treat === 1 && ctrl === 0) b++;
318
- else if (treat === 0 && ctrl === 1) c++;
319
- }
320
- const riskDifference = (b - c) / n;
321
- const z = zQuantile(1 - (1 - confidence) / 2);
322
- let lo = -1;
323
- let hi = riskDifference;
324
- for (let i = 0; i < 64; i++) {
325
- const mid = (lo + hi) / 2;
326
- if (tangoScore(b, c, n, mid) > z) lo = mid;
327
- else hi = mid;
328
- }
329
- const lower = (lo + hi) / 2;
330
- let ulo = riskDifference;
331
- let uhi = 1;
332
- for (let i = 0; i < 64; i++) {
333
- const mid = (ulo + uhi) / 2;
334
- if (tangoScore(b, c, n, mid) > -z) ulo = mid;
335
- else uhi = mid;
336
- }
337
- const upper = (ulo + uhi) / 2;
338
- return {
339
- n,
340
- b,
341
- c,
342
- nDiscordant: b + c,
343
- riskDifference,
344
- lower: Math.max(-1, lower),
345
- upper: Math.min(1, upper),
346
- confidence
347
- };
348
- }
349
- /**
350
- * The common positive level `s` such that EVERY value across both paired arms is
351
- * exactly 0 or `s` — i.e. the outcome is pass/fail, whatever encoding it arrived
352
- * in. Returns null when the outcomes are not two-point, when the two arms use
353
- * different levels, or when no positive value was observed at all (all-zero
354
- * arms: the level is not identified, and there is nothing to decide anyway).
355
- *
356
- * This is the scale-aware successor to {@link isBinaryOutcomeVector}, which only
357
- * recognises literal {0, 1}. Judges in this codebase emit dimensions on 0-100 as
358
- * well as [0,1] (see `detectScale` in `campaign/gates/statistical-heldout.ts`),
359
- * so a pass/fail dimension routinely arrives as {0, 100} and a {0,1}-only test
360
- * silently sends it down the median path that cannot see it. Any positive level
361
- * is accepted, not just 1 and 100: for a two-point {0, s} outcome the mean paired
362
- * delta is exactly s·(b − c)/n, so the binary estimators apply after dividing by
363
- * s and rescaling the result back into the caller's native units.
364
- *
365
- * Non-finite values ⇒ null: an unusable outcome must not be classified as a
366
- * clean pass/fail shape.
367
- */
368
- function pairedBinaryScale(before, after) {
369
- let level = null;
370
- for (const arm of [before, after]) for (let i = 0; i < arm.length; i++) {
371
- const v = arm[i];
372
- if (!Number.isFinite(v)) return null;
373
- if (v === 0) continue;
374
- if (v < 0) return null;
375
- if (level === null) level = v;
376
- else if (v !== level) return null;
377
- }
378
- return level;
379
- }
380
- /**
381
- * Unbiased pass@k for code generation (Chen et al. 2021, "Evaluating Large
382
- * Language Models Trained on Code"). Given `n` independent samples for one
383
- * problem of which `c` pass, the probability that at least one of a random k of
384
- * them passes is 1 − C(n−c, k) / C(n, k). Estimating pass@k as "did any of the
385
- * first k pass" is biased high at small n; this is the variance-reduced estimator
386
- * averaged implicitly over all k-subsets. Average the per-problem values across
387
- * the suite for the corpus pass@k. Computed in the numerically stable product
388
- * form. Requires 1 ≤ k ≤ n and 0 ≤ c ≤ n.
389
- */
390
- function passAtK(n, c, k) {
391
- if (!Number.isInteger(n) || !Number.isInteger(c) || !Number.isInteger(k)) throw new Error(`passAtK: n, c, k must be integers (got n=${n}, c=${c}, k=${k})`);
392
- if (k < 1 || k > n || c < 0 || c > n) throw new Error(`passAtK: require 1 ≤ k ≤ n and 0 ≤ c ≤ n (got n=${n}, c=${c}, k=${k})`);
393
- if (n - c < k) return 1;
394
- let prob = 1;
395
- for (let i = n - c + 1; i <= n; i++) prob *= 1 - k / i;
396
- return 1 - prob;
397
- }
398
- //#endregion
399
5
  //#region src/math/normal.ts
400
6
  /**
401
7
  * Standard normal cumulative distribution using Abramowitz and Stegun 7.1.26.
@@ -1053,6 +659,6 @@ function metricValue(row, name) {
1053
659
  return v;
1054
660
  }
1055
661
  //#endregion
1056
- export { passAtK as _, MANN_WHITNEY_EXACT_MAX_STATES as a, mannWhitneyU as c, isBinaryOutcomeVector as d, mcnemar as f, pairedRiskDifferenceScore as g, pairedRiskDifferenceExact as h, DEFAULT_PERMUTATIONS as i, wilcoxonSignedRank as l, pairedRiskDifference as m, pairArms as n, MANN_WHITNEY_EXACT_MAX_WORK as o, pairedBinaryScale as p, pairRunRecords as r, WILCOXON_EXACT_MAX_N as s, comparePairedArms as t, normalCdf as u, wilson as v };
662
+ export { MANN_WHITNEY_EXACT_MAX_STATES as a, mannWhitneyU as c, DEFAULT_PERMUTATIONS as i, wilcoxonSignedRank as l, pairArms as n, MANN_WHITNEY_EXACT_MAX_WORK as o, pairRunRecords as r, WILCOXON_EXACT_MAX_N as s, comparePairedArms as t, normalCdf as u };
1057
663
 
1058
- //# sourceMappingURL=paired-arms-JSDcs2zx.js.map
664
+ //# sourceMappingURL=paired-arms-DKZFVPt8.js.map