@tangle-network/agent-eval 0.220.2 → 0.221.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-D01Io2Xw.d.ts → agent-profile-Bc7ADJY4.d.ts} +2 -2
  4. package/dist/{agent-profile-D01Io2Xw.d.ts.map → agent-profile-Bc7ADJY4.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +77 -78
  6. package/dist/analyst/index.d.ts.map +1 -1
  7. package/dist/analyst/index.js +204 -25
  8. package/dist/analyst/index.js.map +1 -1
  9. package/dist/{analyze-runs-DqPJaJ4X.js → analyze-runs-CHmsykNJ.js} +4 -4
  10. package/dist/{analyze-runs-DqPJaJ4X.js.map → analyze-runs-CHmsykNJ.js.map} +1 -1
  11. package/dist/{analyze-runs-BWAHBDAw.d.ts → analyze-runs-D7In4c3z.d.ts} +2 -2
  12. package/dist/{analyze-runs-BWAHBDAw.d.ts.map → analyze-runs-D7In4c3z.d.ts.map} +1 -1
  13. package/dist/{benchmark-command-Dx0E4a6z.js → benchmark-command-DiGqnGUt.js} +13 -11
  14. package/dist/benchmark-command-DiGqnGUt.js.map +1 -0
  15. package/dist/benchmarks/index.d.ts +4 -4
  16. package/dist/benchmarks/index.js +3 -3
  17. package/dist/calibration-CTwxpJ-t.js +197 -0
  18. package/dist/calibration-CTwxpJ-t.js.map +1 -0
  19. package/dist/campaign/index.d.ts +6 -6
  20. package/dist/campaign/index.js +5 -5
  21. package/dist/{campaign-BVPC6ODQ.js → campaign-Bt6rbWIU.js} +9 -8
  22. package/dist/{campaign-BVPC6ODQ.js.map → campaign-Bt6rbWIU.js.map} +1 -1
  23. package/dist/cli.js +1 -1
  24. package/dist/{completion-verifier-Cigap8CG.js → completion-verifier-YwoeujPl.js} +2 -2
  25. package/dist/completion-verifier-YwoeujPl.js.map +1 -0
  26. package/dist/contract/index.d.ts +10 -10
  27. package/dist/contract/index.js +7 -7
  28. package/dist/decision-point-Co3u3W8k.js +831 -0
  29. package/dist/decision-point-Co3u3W8k.js.map +1 -0
  30. package/dist/default-registry-BMHqNR6_.d.ts +257 -0
  31. package/dist/default-registry-BMHqNR6_.d.ts.map +1 -0
  32. package/dist/{default-registry-ovrIBGmH.js → default-registry-BbFCkqvB.js} +607 -14
  33. package/dist/default-registry-BbFCkqvB.js.map +1 -0
  34. package/dist/{define-agent-eval-C2nFhHPu.d.ts → define-agent-eval-Bsoi2GUV.d.ts} +7 -7
  35. package/dist/{define-agent-eval-C2nFhHPu.d.ts.map → define-agent-eval-Bsoi2GUV.d.ts.map} +1 -1
  36. package/dist/{define-agent-eval-UQY3VbJ2.js → define-agent-eval-CJhECJNL.js} +4 -4
  37. package/dist/{define-agent-eval-UQY3VbJ2.js.map → define-agent-eval-CJhECJNL.js.map} +1 -1
  38. package/dist/diagnosis/index.d.ts +2 -2
  39. package/dist/diagnosis/index.js +1 -1
  40. package/dist/{dspy-rlm-engine-Bn_Mt_LW.js → dspy-rlm-engine-BTy7u0jQ.js} +3 -3
  41. package/dist/{dspy-rlm-engine-Bn_Mt_LW.js.map → dspy-rlm-engine-BTy7u0jQ.js.map} +1 -1
  42. package/dist/{engine-BpGGw6cd.d.ts → engine-BF95CWzH.d.ts} +2 -2
  43. package/dist/{engine-BpGGw6cd.d.ts.map → engine-BF95CWzH.d.ts.map} +1 -1
  44. package/dist/{eval-campaign-BUMIxKTE.js → eval-campaign-DoX5vz3E.js} +2 -2
  45. package/dist/{eval-campaign-BUMIxKTE.js.map → eval-campaign-DoX5vz3E.js.map} +1 -1
  46. package/dist/{evaluation-CBdQt_kr.d.ts → evaluation-D1PGzkPR.d.ts} +3 -3
  47. package/dist/{evaluation-CBdQt_kr.d.ts.map → evaluation-D1PGzkPR.d.ts.map} +1 -1
  48. package/dist/evaluation-wdGyZ7jV.js +147 -0
  49. package/dist/evaluation-wdGyZ7jV.js.map +1 -0
  50. package/dist/evaluation.d.ts +1 -1
  51. package/dist/evaluation.js +1 -136
  52. package/dist/{exact-types-BYFmYq44.d.ts → exact-types-CVn1QxFO.d.ts} +2 -2
  53. package/dist/{exact-types-BYFmYq44.d.ts.map → exact-types-CVn1QxFO.d.ts.map} +1 -1
  54. package/dist/experiment/index.d.ts +3 -3
  55. package/dist/experiment/index.js +2 -2
  56. package/dist/{external-optimizer-process-wOLfzsCC.js → external-optimizer-process-E5yY2SYS.js} +2 -2
  57. package/dist/{external-optimizer-process-wOLfzsCC.js.map → external-optimizer-process-E5yY2SYS.js.map} +1 -1
  58. package/dist/{external-optimizer-subprocess-D670Oxf2.js → external-optimizer-subprocess-DA02c_L6.js} +12 -19
  59. package/dist/{external-optimizer-subprocess-D670Oxf2.js.map → external-optimizer-subprocess-DA02c_L6.js.map} +1 -1
  60. package/dist/{feedback-trajectory-DhB9WzYg.d.ts → feedback-trajectory-BZhVCWuz.d.ts} +3 -3
  61. package/dist/{feedback-trajectory-DhB9WzYg.d.ts.map → feedback-trajectory-BZhVCWuz.d.ts.map} +1 -1
  62. package/dist/finding-composition-8n0fFgVI.js +131 -0
  63. package/dist/finding-composition-8n0fFgVI.js.map +1 -0
  64. package/dist/{findings-store-CvNo712L.js → findings-store-DRiFdoid.js} +4 -4
  65. package/dist/{findings-store-CvNo712L.js.map → findings-store-DRiFdoid.js.map} +1 -1
  66. package/dist/{index-CVFStrQD.d.ts → index-BJZ7s-sv.d.ts} +7 -58
  67. package/dist/index-BJZ7s-sv.d.ts.map +1 -0
  68. package/dist/{index-Q6DvdcwI.d.ts → index-BvX3CFNS.d.ts} +6 -6
  69. package/dist/{index-Q6DvdcwI.d.ts.map → index-BvX3CFNS.d.ts.map} +1 -1
  70. package/dist/index-DWd1gUwR.d.ts +1086 -0
  71. package/dist/index-DWd1gUwR.d.ts.map +1 -0
  72. package/dist/{index-DAXfpVf7.d.ts → index-y7i8l6Y_.d.ts} +8 -8
  73. package/dist/{index-DAXfpVf7.d.ts.map → index-y7i8l6Y_.d.ts.map} +1 -1
  74. package/dist/index.d.ts +18 -17
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +15 -15
  77. package/dist/{kind-factory-BhxbtUsQ.js → kind-factory-Dl0PmNQL.js} +2 -2
  78. package/dist/{kind-factory-BhxbtUsQ.js.map → kind-factory-Dl0PmNQL.js.map} +1 -1
  79. package/dist/{llm-judge-Cc8vDJh_.js → llm-judge-3uAeRawE.js} +4 -4
  80. package/dist/{llm-judge-Cc8vDJh_.js.map → llm-judge-3uAeRawE.js.map} +1 -1
  81. package/dist/{matrix-Cf-AGxGh.d.ts → matrix-BXo3PSqM.d.ts} +2 -2
  82. package/dist/{matrix-Cf-AGxGh.d.ts.map → matrix-BXo3PSqM.d.ts.map} +1 -1
  83. package/dist/meta-eval/index.d.ts +3 -638
  84. package/dist/meta-eval/index.js +3 -193
  85. package/dist/meta-eval/index.js.map +1 -1
  86. package/dist/multishot/golden/index.d.ts +1 -1
  87. package/dist/multishot/index.d.ts +2 -2
  88. package/dist/openapi.json +1 -1
  89. package/dist/outcome-observations-FLmRpgYa.js +78 -0
  90. package/dist/outcome-observations-FLmRpgYa.js.map +1 -0
  91. package/dist/{paired-arms-Ct4LTKc1.js → paired-arms-B2ttLc0_.js} +108 -31
  92. package/dist/paired-arms-B2ttLc0_.js.map +1 -0
  93. package/dist/{power-and-mde-N5nU4_Ly.js → power-and-mde-CQX-0weG.js} +2 -2
  94. package/dist/{power-and-mde-N5nU4_Ly.js.map → power-and-mde-CQX-0weG.js.map} +1 -1
  95. package/dist/{prime-protocol-CckHBxGu.d.ts → prime-protocol-BEaqBoQE.d.ts} +2 -2
  96. package/dist/{prime-protocol-CckHBxGu.d.ts.map → prime-protocol-BEaqBoQE.d.ts.map} +1 -1
  97. package/dist/{proposal-findings-E1aSC_cU.js → proposal-findings-D0_zkQ2l.js} +2 -2
  98. package/dist/{proposal-findings-E1aSC_cU.js.map → proposal-findings-D0_zkQ2l.js.map} +1 -1
  99. package/dist/{registry-B_yG-1jh.d.ts → registry-DDKaUrmM.d.ts} +3 -3
  100. package/dist/{registry-B_yG-1jh.d.ts.map → registry-DDKaUrmM.d.ts.map} +1 -1
  101. package/dist/reporting.d.ts +1 -1
  102. package/dist/reporting.js +3 -3
  103. package/dist/rl.d.ts +4 -5
  104. package/dist/rl.d.ts.map +1 -1
  105. package/dist/rl.js +5 -4
  106. package/dist/rl.js.map +1 -1
  107. package/dist/{rubric-predictive-validity-noY7uE03.d.ts → rubric-predictive-validity-Cd5SCtAf.d.ts} +58 -3
  108. package/dist/rubric-predictive-validity-Cd5SCtAf.d.ts.map +1 -0
  109. package/dist/{rubric-predictive-validity-D3_oI72N.js → rubric-predictive-validity-CeKW2GQN.js} +3 -77
  110. package/dist/rubric-predictive-validity-CeKW2GQN.js.map +1 -0
  111. package/dist/search/index.d.ts +2 -2
  112. package/dist/{search-kernel-Dloxd6gs.d.ts → search-kernel-C6__V0IS.d.ts} +2 -2
  113. package/dist/{search-kernel-Dloxd6gs.d.ts.map → search-kernel-C6__V0IS.d.ts.map} +1 -1
  114. package/dist/{skillopt-optimization-method-DLKqdhcR.js → skillopt-optimization-method-D21dH_Bh.js} +4 -4
  115. package/dist/{skillopt-optimization-method-DLKqdhcR.js.map → skillopt-optimization-method-D21dH_Bh.js.map} +1 -1
  116. package/dist/{statistical-heldout-3z3I-kJN.d.ts → statistical-heldout-pD1Yah-0.d.ts} +58 -8
  117. package/dist/statistical-heldout-pD1Yah-0.d.ts.map +1 -0
  118. package/dist/{store-otlp-dyWE3wAG.js → store-otlp-BVZfR168.js} +2 -2
  119. package/dist/{store-otlp-dyWE3wAG.js.map → store-otlp-BVZfR168.js.map} +1 -1
  120. package/dist/{store-tool-spans-DIUgZbzu.js → store-tool-spans-CjYiF4fF.js} +3 -3
  121. package/dist/{store-tool-spans-DIUgZbzu.js.map → store-tool-spans-CjYiF4fF.js.map} +1 -1
  122. package/dist/{store-tool-spans-DPwXHQkH.d.ts → store-tool-spans-DfnwWMFR.d.ts} +4 -4
  123. package/dist/{store-tool-spans-DPwXHQkH.d.ts.map → store-tool-spans-DfnwWMFR.d.ts.map} +1 -1
  124. package/dist/{summary-report-BsXJoYX5.js → summary-report-DHDWxe6p.js} +3 -3
  125. package/dist/{summary-report-BsXJoYX5.js.map → summary-report-DHDWxe6p.js.map} +1 -1
  126. package/dist/systemone-D3MrW63C.d.ts +400 -0
  127. package/dist/systemone-D3MrW63C.d.ts.map +1 -0
  128. package/dist/{systemone-protocol-DKoi1NdK.d.ts → systemone-protocol-Bl2EI2KQ.d.ts} +4 -2
  129. package/dist/{systemone-protocol-DKoi1NdK.d.ts.map → systemone-protocol-Bl2EI2KQ.d.ts.map} +1 -1
  130. package/dist/systemone-protocol.d.ts +2 -2
  131. package/dist/systemone-protocol.js +7 -7
  132. package/dist/systemone-protocol.js.map +1 -1
  133. package/dist/{systemone-review-CUBMuTLi.d.ts → systemone-review-C8DRiT_-.d.ts} +3 -3
  134. package/dist/{systemone-review-CUBMuTLi.d.ts.map → systemone-review-C8DRiT_-.d.ts.map} +1 -1
  135. package/dist/{systemone-review-DzdOJ8I6.js → systemone-review-DFGtIUcf.js} +2 -2
  136. package/dist/{systemone-review-DzdOJ8I6.js.map → systemone-review-DFGtIUcf.js.map} +1 -1
  137. package/dist/systemone.d.ts +5 -5
  138. package/dist/systemone.js +5 -343
  139. package/dist/{tool-groups-LISbBWCg.d.ts → tool-groups-DK1bu5TD.d.ts} +3 -3
  140. package/dist/tool-groups-DK1bu5TD.d.ts.map +1 -0
  141. package/dist/{trace-questions-C42fYEE4.d.ts → trace-questions-D_OKYZ6u.d.ts} +3 -3
  142. package/dist/{trace-questions-C42fYEE4.d.ts.map → trace-questions-D_OKYZ6u.d.ts.map} +1 -1
  143. package/dist/trace-repair/index.d.ts +1 -1
  144. package/dist/traces.d.ts +3 -3
  145. package/dist/traces.js +3 -3
  146. package/dist/{types-DqFMNTgK.js → types-CnWmj8NW.js} +19 -6
  147. package/dist/types-CnWmj8NW.js.map +1 -0
  148. package/dist/{types-CHfn1zg5.d.ts → types-DDKfH-N6.d.ts} +2 -2
  149. package/dist/{types-CHfn1zg5.d.ts.map → types-DDKfH-N6.d.ts.map} +1 -1
  150. package/dist/{types-8yQzNm8u.d.ts → types-DGImvHIr.d.ts} +150 -4
  151. package/dist/types-DGImvHIr.d.ts.map +1 -0
  152. package/dist/{types-D8GXK9Z5.d.ts → types-IERw_HxR.d.ts} +2 -2
  153. package/dist/{types-D8GXK9Z5.d.ts.map → types-IERw_HxR.d.ts.map} +1 -1
  154. package/dist/wire/index.d.ts +1 -1
  155. package/docs/behavioral-trace-questions.md +99 -0
  156. package/docs/experiment.md +27 -0
  157. package/docs/finding-layers.md +54 -1
  158. package/docs/systemone.md +107 -0
  159. package/package.json +4 -4
  160. package/dist/benchmark-command-Dx0E4a6z.js.map +0 -1
  161. package/dist/completion-verifier-Cigap8CG.js.map +0 -1
  162. package/dist/default-registry-Cwg_QN3d.d.ts +0 -70
  163. package/dist/default-registry-Cwg_QN3d.d.ts.map +0 -1
  164. package/dist/default-registry-ovrIBGmH.js.map +0 -1
  165. package/dist/evaluation.js.map +0 -1
  166. package/dist/index-CVFStrQD.d.ts.map +0 -1
  167. package/dist/judge-gate-Dc_mXQsL.d.ts +0 -453
  168. package/dist/judge-gate-Dc_mXQsL.d.ts.map +0 -1
  169. package/dist/meta-eval/index.d.ts.map +0 -1
  170. package/dist/outcome-store-CNt4iZ67.d.ts +0 -58
  171. package/dist/outcome-store-CNt4iZ67.d.ts.map +0 -1
  172. package/dist/paired-arms-Ct4LTKc1.js.map +0 -1
  173. package/dist/rubric-predictive-validity-D3_oI72N.js.map +0 -1
  174. package/dist/rubric-predictive-validity-noY7uE03.d.ts.map +0 -1
  175. package/dist/statistical-heldout-3z3I-kJN.d.ts.map +0 -1
  176. package/dist/systemone-DVA7t76V.d.ts +0 -135
  177. package/dist/systemone-DVA7t76V.d.ts.map +0 -1
  178. package/dist/systemone.js.map +0 -1
  179. package/dist/tool-groups-LISbBWCg.d.ts.map +0 -1
  180. package/dist/types-8yQzNm8u.d.ts.map +0 -1
  181. package/dist/types-DqFMNTgK.js.map +0 -1
@@ -1,453 +0,0 @@
1
- import { a as JudgeError } from "./errors-DEE6u6ot.js";
2
- import { o as DimensionJudgeScore } from "./types-eMhdacVp.js";
3
- import { a as ContinuousCalibrationResult, i as ContinuousAgreementOptions, n as CandidateScore, o as GoldenItem, r as ContinuousAgreement, t as CalibrationResult } from "./judge-calibration-DFtEMlde.js";
4
- import { t as ComputedInterval } from "./interval-ohuOJurX.js";
5
- //#region src/statistics/agreement-irr.d.ts
6
- /**
7
- * Inter-rater reliability — Krippendorff's α under the squared-difference
8
- * metric, pooled across dimensions.
9
- *
10
- * Each inner array is one judge's scores. Items are matched by position
11
- * WITHIN a dimension: the k-th score a judge supplies carrying dimension
12
- * `d` is item k of `d`, and the ratings compared against each other are
13
- * the ones different judges gave to the same item. Every judge that scores
14
- * a dimension at all must supply the same number of scores for it —
15
- * ragged input cannot be aligned into items and throws rather than
16
- * comparing mismatched items.
17
- *
18
- * α = 1 − D_observed / D_expected: D_observed averages the squared
19
- * difference over within-item judge pairs, D_expected over every pair of
20
- * ratings irrespective of item. α = 1 is perfect agreement, 0 is chance,
21
- * negative is systematic disagreement.
22
- */
23
- declare function interRaterReliability(judgeScores: DimensionJudgeScore[][]): number;
24
- interface CorpusScoreRecord {
25
- /** Stable identifier for the rated item (scenario, span, turn, …). */
26
- itemId: string;
27
- /** Identifier for the judge that produced this score. */
28
- judgeName: string;
29
- /** Dimension name (matches `DimensionJudgeScore.dimension`). */
30
- dimension: string;
31
- /** Numeric score; must be finite. */
32
- score: number;
33
- }
34
- interface CorpusAgreementPerDimension extends ContinuousAgreement {
35
- dimension: string;
36
- /** Item IDs that contributed to this dimension's matrix (every judge scored them). */
37
- itemIds: string[];
38
- /** Judge IDs that contributed to this dimension's matrix. */
39
- judgeIds: string[];
40
- }
41
- interface CorpusAgreementReport {
42
- /** Per-dimension ICC(2,1) + κ_w + Pearson + Spearman + bootstrap CIs. */
43
- perDimension: CorpusAgreementPerDimension[];
44
- /** Mean ICC across dimensions (NaN if no dimension yielded a finite ICC). */
45
- overallIcc: number;
46
- /** Mean weighted κ across dimensions (NaN if none finite). */
47
- overallWeightedKappa: number;
48
- /** Dimensions evaluated (sorted). */
49
- dimensions: string[];
50
- /** Judges seen across the corpus (sorted). */
51
- judgeIds: string[];
52
- }
53
- interface CorpusAgreementOptions extends ContinuousAgreementOptions {
54
- /**
55
- * Restrict the audit to these dimensions. Default = every dimension
56
- * that appears in the input. A dimension named here but absent from
57
- * the input throws — silent omission would corrupt the overall metric.
58
- */
59
- dimensions?: string[];
60
- /**
61
- * Restrict the audit to these judges. Default = every judge that
62
- * appears in the input. A judge named here but absent from a
63
- * dimension throws (see "fail loud" below).
64
- */
65
- judges?: string[];
66
- }
67
- /**
68
- * Corpus-wide inter-rater agreement across N items × M judges × D dimensions.
69
- *
70
- * For each dimension, builds the [n_items][n_judges] matrix of scores
71
- * (keeping only items every judge rated on that dimension), then runs
72
- * `continuousAgreement` to get ICC(2,1), κ_w, Pearson, Spearman, and
73
- * bootstrap CIs. Reports a pooled mean across dimensions as a single
74
- * "is this judge panel reliable on this corpus?" number.
75
- *
76
- * Fail-loud contract:
77
- * - Empty input throws.
78
- * - Fewer than 2 judges or fewer than 2 items per dimension throws.
79
- * - A judge present in some dimensions but with zero scored items on
80
- * another dimension throws (would silently shrink the matrix).
81
- * - Duplicate (itemId, judgeName, dimension) records throw.
82
- */
83
- declare function corpusInterRaterAgreement(records: CorpusScoreRecord[], opts?: CorpusAgreementOptions): CorpusAgreementReport;
84
- /**
85
- * Convenience adapter for `DimensionJudgeScore[]` data keyed externally by item.
86
- *
87
- * Use when you have per-item arrays of `DimensionJudgeScore[]` (e.g. one
88
- * `ScenarioResult.judgeScores` per scenario) and want corpus-wide
89
- * agreement without manually flattening. `itemId` must be unique per
90
- * row of `itemsScores`.
91
- */
92
- declare function corpusInterRaterAgreementFromJudgeScores(itemsScores: Array<{
93
- itemId: string;
94
- scores: DimensionJudgeScore[];
95
- }>, opts?: CorpusAgreementOptions): CorpusAgreementReport;
96
- //#endregion
97
- //#region src/series-convergence.d.ts
98
- /**
99
- * Series convergence — detects whether a sequence of scalar measurements
100
- * is stabilizing, drifting, or noisy. It reads drift *across* runs, e.g.
101
- * "are my nightly eval scores stabilizing?".
102
- *
103
- * Three signals:
104
- * - stabilized: last K values have low variance (< epsilon) — done
105
- * - drifting: recent trend is monotonic and beyond noise — regressing or improving
106
- * - noisy: neither — keep iterating, but flag as untrustworthy for gating
107
- */
108
- interface SeriesConvergenceOptions {
109
- /** Window size for "recent" analysis (default 5). */
110
- window?: number;
111
- /** Coefficient-of-variation threshold below which the window is stabilized (default 0.05 = 5%). */
112
- stableCv?: number;
113
- /** Minimum monotone run length to call drift (default 3). */
114
- driftRun?: number;
115
- }
116
- interface SeriesConvergenceResult {
117
- state: 'stabilized' | 'drifting-up' | 'drifting-down' | 'noisy' | 'insufficient-data';
118
- windowMean: number;
119
- windowCv: number;
120
- /** Longest monotonic run at the tail of the series (positive for up, negative for down). */
121
- tailRun: number;
122
- /** True when n ≥ window AND windowCv ≤ stableCv. */
123
- stable: boolean;
124
- }
125
- declare function analyzeSeries(values: number[], options?: SeriesConvergenceOptions): SeriesConvergenceResult;
126
- //#endregion
127
- //#region src/meta-eval/sentinel.d.ts
128
- declare const SENTINEL_METRIC_NAMES: readonly ['irr', 'calibrationKappa', 'sentinelPassRate'];
129
- type SentinelMetricName = (typeof SENTINEL_METRIC_NAMES)[number];
130
- interface SentinelMetrics {
131
- /** Inter-rater reliability — ICC(2,1) from agreement instruments. */
132
- irr?: number;
133
- /** Weighted κ vs the human golden set (`calibrateJudge*`). */
134
- calibrationKappa?: number;
135
- /** Fraction of a fixed sentinel golden set the judge still scores within tolerance. */
136
- sentinelPassRate?: number;
137
- }
138
- interface SentinelSnapshot {
139
- /** Caller-supplied ISO-8601 timestamp — the module never reads a clock. */
140
- at: string;
141
- judgeId: string;
142
- /** Exact model identity behind the judge (pin the full version string). */
143
- judgeModel: string;
144
- /**
145
- * Metrics measured at `at`. May be empty: an empty-metrics snapshot is a
146
- * model-change marker — it records the new `judgeModel` immediately and
147
- * the silent-upgrade alarm stays raised until a golden-grounded snapshot
148
- * (calibrationKappa or sentinelPassRate) follows.
149
- */
150
- metrics: SentinelMetrics;
151
- }
152
- /** Identity + timestamp the caller supplies alongside an instrument output. */
153
- interface SnapshotMeta {
154
- at: string;
155
- judgeId: string;
156
- judgeModel: string;
157
- }
158
- /** Shape guard for snapshots crossing a boundary (store append, JSONL load, report input). */
159
- declare function validateSentinelSnapshot(snapshot: SentinelSnapshot, source?: string): void;
160
- /**
161
- * From `calibrateJudge` / `calibrateJudgeContinuous` output. Prefers the
162
- * un-rounded continuous κ_w when the report carries one (integer κ
163
- * discards information for [0,1] judges).
164
- */
165
- declare function snapshotFromCalibration(report: CalibrationResult | ContinuousCalibrationResult, meta: SnapshotMeta): SentinelSnapshot;
166
- /**
167
- * From `corpusInterRaterAgreement` (statistics.ts) or `continuousAgreement`
168
- * (judge-calibration.ts) output. IRR = ICC(2,1) — the reliability
169
- * coefficient both instruments compute. For ensemble-level agreement,
170
- * `meta.judgeId` names the ensemble and `meta.judgeModel` pins its
171
- * composition (e.g. a joined list of member model strings).
172
- */
173
- declare function snapshotFromAgreement(report: CorpusAgreementReport | ContinuousAgreement, meta: SnapshotMeta): SentinelSnapshot;
174
- interface SentinelSetOptions {
175
- /** Max |judge − human| for an item to count as passed. Default 0.1 (tuned for [0,1] scores). */
176
- tolerance?: number;
177
- }
178
- /**
179
- * From a rerun of a fixed sentinel golden set: the same `GoldenItem`s the
180
- * judge was originally calibrated on, re-scored periodically. Pass rate =
181
- * fraction of joined items where the judge stays within `tolerance` of the
182
- * human score. Items the judge didn't score are excluded from the
183
- * denominator; zero joined items is an error, not a 0% pass rate.
184
- */
185
- declare function snapshotFromSentinelSet(scores: CandidateScore[], golden: GoldenItem[], meta: SnapshotMeta, options?: SentinelSetOptions): SentinelSnapshot;
186
- interface SentinelStore {
187
- append(snapshot: SentinelSnapshot): Promise<void>;
188
- /** All snapshots (optionally for one judge), in append order. */
189
- history(judgeId?: string): Promise<SentinelSnapshot[]>;
190
- }
191
- /**
192
- * JSONL store — one snapshot per line, appended atomically per call.
193
- * A corrupt or shape-invalid line is a loud error naming the file and
194
- * line number: a sentinel history that silently drops records would
195
- * defeat the drift detection it exists to provide.
196
- */
197
- declare function fileSentinelStore(path: string): SentinelStore;
198
- interface SentinelThresholds {
199
- /** Floor for irr — below it the judge ensemble is unreliable regardless of trend. Default 0.6. */
200
- minIrr?: number;
201
- /** Max tolerated calibrationKappa drop vs the series baseline. Default 0.15. */
202
- maxKappaDrop?: number;
203
- /** Max tolerated sentinelPassRate drop vs the series baseline. Default 0.1. */
204
- maxSentinelDrop?: number;
205
- /** Newest snapshot older than this (days, vs asOf) = the sentinel itself went blind. Default 30. */
206
- staleAfterDays?: number;
207
- }
208
- interface JudgeSentinelOptions {
209
- /** Caller-supplied ISO timestamp staleness is measured against. */
210
- asOf: string;
211
- thresholds?: SentinelThresholds;
212
- /** Forwarded to `analyzeSeries` (window, stableCv, driftRun). */
213
- convergence?: SeriesConvergenceOptions;
214
- }
215
- interface SentinelTrend {
216
- judgeId: string;
217
- metric: SentinelMetricName;
218
- /** Verbatim `analyzeSeries` state for this judge×metric history. */
219
- state: SeriesConvergenceResult['state'];
220
- /** Newest value in the series. */
221
- current: number;
222
- /** Oldest value in the series — the reference the drop thresholds compare against. */
223
- baseline: number;
224
- /** current − baseline (signed; negative = decayed). */
225
- drift: number;
226
- alarmed: boolean;
227
- reason?: string;
228
- }
229
- interface SentinelReport {
230
- perJudge: SentinelTrend[];
231
- alarms: string[];
232
- healthy: boolean;
233
- /**
234
- * `judgeId:metric` pairs with too few snapshots for the convergence
235
- * machine. Named, not counted — a blind spot you can't see is a blind
236
- * spot you won't fix. Floor/drop checks still apply to thin series, so
237
- * insufficient history alone never masks an alarm.
238
- */
239
- insufficientHistory: string[];
240
- }
241
- declare function judgeSentinelReport(history: SentinelSnapshot[], opts: JudgeSentinelOptions): SentinelReport;
242
- interface EvalHealthStamp {
243
- healthy: boolean;
244
- alarms: string[];
245
- }
246
- /**
247
- * The object a campaign attaches to its verdicts. Compute it from the
248
- * sentinel report in a post-campaign hook (or a nightly job feeding the
249
- * next day's campaigns) and store it alongside the verdict payload.
250
- * `healthy: false` means the judges that produced those verdicts have an
251
- * unresolved drift / decay / silent-upgrade / staleness alarm — treat the
252
- * verdicts as carrying an integrity warning until recalibration clears it.
253
- */
254
- declare function evalHealthStamp(report: SentinelReport): EvalHealthStamp;
255
- //#endregion
256
- //#region src/meta-eval/judge-gate.d.ts
257
- type OwnerVerdict = 'pass' | 'fail';
258
- /** One item the owner decided, with where that decision is recorded. */
259
- interface CalibrationExample {
260
- /** Stable id of the decided item; a judge run names it in `exampleId`. */
261
- id: string;
262
- verdict: OwnerVerdict;
263
- /** The person whose verdict this is. Never a model. */
264
- labeledBy: string;
265
- /** ISO-8601 time the verdict was given. */
266
- labeledAt: string;
267
- /** Where the verdict is recorded, e.g. `gtm:asset_decision:<id>`. */
268
- source: string;
269
- /** What the owner judged (an image digest, a run id), so a replay judges the same thing. */
270
- evidenceRef?: string;
271
- note?: string;
272
- }
273
- interface JudgeCalibrationSet {
274
- judgeId: string;
275
- /** Whose verdicts the judge stands in for. */
276
- owner: string;
277
- examples: readonly CalibrationExample[];
278
- }
279
- /**
280
- * Validate a calibration set and return a normalized copy ordered by example
281
- * id. Every verdict needs its person, time and source; ids are unique.
282
- */
283
- declare function registerCalibrationSet(set: JudgeCalibrationSet): JudgeCalibrationSet;
284
- interface CalibrationMerge {
285
- set: JudgeCalibrationSet;
286
- /** Ids that joined the set. */
287
- added: string[];
288
- /** Ids whose verdict a later decision replaced. */
289
- superseded: string[];
290
- /** Ids whose incoming verdict was already recorded, or older than the recorded one. */
291
- unchanged: string[];
292
- }
293
- /**
294
- * Join new owner verdicts to a set. A verdict already recorded from the same
295
- * source is unchanged, so ingestion can rerun. A later verdict on an item
296
- * replaces an earlier one: the owner changed their mind, and the set keeps
297
- * what they decided last.
298
- */
299
- declare function addCalibrationVerdicts(set: JudgeCalibrationSet, verdicts: readonly CalibrationExample[]): CalibrationMerge;
300
- /** One gate decision the judge made on a calibration example. */
301
- interface JudgeRun {
302
- exampleId: string;
303
- /** The judge's decision after its own sample aggregation (median, majority). */
304
- verdict: OwnerVerdict;
305
- /** The per-sample verdicts behind that decision, when the judge samples. */
306
- samples?: readonly OwnerVerdict[];
307
- }
308
- interface JudgeRunMeta {
309
- judgeId: string;
310
- /** Exact model identity, or `deterministic` for a grader without one. */
311
- judgeModel: string;
312
- rubricVersion: string;
313
- measuredAt: string;
314
- }
315
- interface JudgeConfusion {
316
- /** Judge pass, owner pass. */
317
- truePass: number;
318
- /** Judge fail, owner fail. */
319
- trueFail: number;
320
- /** Judge pass, owner fail: the judge let through what the owner rejected. */
321
- falsePass: number;
322
- /** Judge fail, owner pass: the judge blocked what the owner accepted. */
323
- falseFail: number;
324
- }
325
- interface JudgeExampleAgreement {
326
- id: string;
327
- verdict: OwnerVerdict;
328
- runs: number;
329
- /** Share of runs that passed. */
330
- passRate: number;
331
- /** Share of runs that reached the owner's verdict. */
332
- agreement: number;
333
- }
334
- interface JudgeAgreement extends JudgeRunMeta {
335
- owner: string;
336
- /** Examples in the calibration set. */
337
- examples: number;
338
- /** Examples the judge ran on at least once. */
339
- judged: number;
340
- /** Judged examples per owner verdict. */
341
- judgedByVerdict: Record<OwnerVerdict, number>;
342
- runs: number;
343
- /** Runs that reached the owner's verdict, over all runs; null with no runs. */
344
- accuracy: number | null;
345
- /**
346
- * Exact (Clopper-Pearson) 95% interval for the share of judged examples on
347
- * which every run reached the owner's verdict. Examples, not runs, are the
348
- * independent units.
349
- */
350
- exampleAccuracy: {
351
- agreed: number;
352
- judged: number;
353
- interval: ComputedInterval;
354
- } | null;
355
- /**
356
- * Cohen's κ between the judge and the owner over runs. Null when undefined:
357
- * no runs, or both sides used a single verdict.
358
- */
359
- kappa: number | null;
360
- /** Runs that failed what the owner passed, over runs on owner passes; null with none. A veto judge is held to this. */
361
- falseFailRate: number | null;
362
- /** Runs that failed what the owner failed, over runs on owner fails; null with none. */
363
- catchRate: number | null;
364
- confusion: JudgeConfusion;
365
- variance: {
366
- /** Mean over judged examples of p(1 − p), p the example's run pass rate. 0 = no run changed its mind. */
367
- betweenRuns: number | null;
368
- /** Mean over runs that reported samples of p(1 − p) across those samples; null when none did. */
369
- withinRun: number | null;
370
- /** Examples whose runs disagree with each other. */
371
- unstable: string[];
372
- };
373
- /** Examples with at least one run against the owner, least agreement first. */
374
- disagreements: JudgeExampleAgreement[];
375
- /** Examples without any run. */
376
- unjudged: string[];
377
- }
378
- /**
379
- * Agreement between a judge's runs and the owner's verdicts on one
380
- * calibration set. A run that names an example outside the set is an error:
381
- * a silently dropped run would overstate agreement.
382
- */
383
- declare function measureJudgeAgreement(set: JudgeCalibrationSet, runs: readonly JudgeRun[], meta: JudgeRunMeta): JudgeAgreement;
384
- interface JudgeGatePolicy {
385
- /**
386
- * `verdict`: the judge passes and blocks, so accuracy and κ must hold.
387
- * `veto`: it only blocks, so its false-fail rate on owner passes must hold.
388
- */
389
- decides: 'verdict' | 'veto';
390
- /** Judged examples required before the judge may gate; for a veto judge, owner passes. */
391
- minExamples: number;
392
- /** Judged examples required of each owner verdict, so κ is defined. */
393
- minPerVerdict: number;
394
- /** Floor on run accuracy. */
395
- minAccuracy: number;
396
- /** Floor on Cohen's κ. */
397
- minKappa: number;
398
- /** Ceiling on a veto judge's false-fail rate. */
399
- maxFalseFailRate: number;
400
- /** A report older than this (days, vs `asOf`) no longer calibrates the judge. */
401
- maxAgeDays: number;
402
- /** Drift thresholds forwarded to `judgeSentinelReport` over the history. */
403
- drift?: SentinelThresholds;
404
- }
405
- declare const DEFAULT_JUDGE_GATE_POLICY: Readonly<JudgeGatePolicy>;
406
- type JudgeGateStatus = 'calibrated' | 'uncalibrated' | 'below-threshold' | 'drifted';
407
- interface JudgeGateDecision {
408
- judgeId: string;
409
- judgeModel: string;
410
- rubricVersion: string;
411
- /** True only for `calibrated`. */
412
- mayGate: boolean;
413
- status: JudgeGateStatus;
414
- /** Why the judge may not gate; empty when it may. */
415
- reasons: string[];
416
- agreement: JudgeAgreement | null;
417
- policy: JudgeGatePolicy;
418
- }
419
- interface JudgeGateInput {
420
- judgeId: string;
421
- /** The model the judge runs now. */
422
- judgeModel: string;
423
- /** The rubric the judge runs now. */
424
- rubricVersion: string;
425
- /** The latest calibration report; null when the judge was never measured. */
426
- agreement: JudgeAgreement | null;
427
- asOf: string;
428
- /** Sentinel snapshots for this judge, oldest first or in any order. */
429
- history?: readonly SentinelSnapshot[];
430
- policy?: Partial<JudgeGatePolicy>;
431
- }
432
- /** Whether a judge may gate now, and every reason it may not. */
433
- declare function judgeGateDecision(input: JudgeGateInput): JudgeGateDecision;
434
- /** Thrown by `assertJudgeMayGate`; carries the refused decision. */
435
- declare class JudgeGateRefusedError extends JudgeError {
436
- readonly decision: JudgeGateDecision;
437
- constructor(decision: JudgeGateDecision);
438
- }
439
- /** Throw unless the decision lets the judge gate. */
440
- declare function assertJudgeMayGate(decision: JudgeGateDecision): void;
441
- /**
442
- * The sentinel snapshot for one calibration run. A deciding judge records
443
- * accuracy as `sentinelPassRate` and κ as `calibrationKappa` when it is
444
- * defined; a veto judge records the share of owner passes it let through as
445
- * `sentinelPassRate`. Append it to the judge's `SentinelStore`; the gate reads
446
- * drift from that history.
447
- */
448
- declare function snapshotFromJudgeAgreement(agreement: JudgeAgreement, options?: {
449
- decides?: JudgeGatePolicy['decides'];
450
- }): SentinelSnapshot;
451
- //#endregion
452
- export { SentinelThresholds as A, SeriesConvergenceOptions as B, JudgeSentinelOptions as C, SentinelSetOptions as D, SentinelReport as E, judgeSentinelReport as F, CorpusAgreementReport as G, analyzeSeries as H, snapshotFromAgreement as I, corpusInterRaterAgreementFromJudgeScores as J, CorpusScoreRecord as K, snapshotFromCalibration as L, SnapshotMeta as M, evalHealthStamp as N, SentinelSnapshot as O, fileSentinelStore as P, snapshotFromSentinelSet as R, EvalHealthStamp as S, SentinelMetrics as T, CorpusAgreementOptions as U, SeriesConvergenceResult as V, CorpusAgreementPerDimension as W, interRaterReliability as Y, assertJudgeMayGate as _, JudgeCalibrationSet as a, registerCalibrationSet as b, JudgeGateDecision as c, JudgeGateRefusedError as d, JudgeGateStatus as f, addCalibrationVerdicts as g, OwnerVerdict as h, JudgeAgreement as i, SentinelTrend as j, SentinelStore as k, JudgeGateInput as l, JudgeRunMeta as m, CalibrationMerge as n, JudgeConfusion as o, JudgeRun as p, corpusInterRaterAgreement as q, DEFAULT_JUDGE_GATE_POLICY as r, JudgeExampleAgreement as s, CalibrationExample as t, JudgeGatePolicy as u, judgeGateDecision as v, SentinelMetricName as w, snapshotFromJudgeAgreement as x, measureJudgeAgreement as y, validateSentinelSnapshot as z };
453
- //# sourceMappingURL=judge-gate-Dc_mXQsL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"judge-gate-Dc_mXQsL.d.ts","names":[],"sources":["../src/statistics/agreement-irr.ts","../src/series-convergence.ts","../src/meta-eval/sentinel.ts","../src/meta-eval/judge-gate.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;iBAyBgB,sBAAsB,aAAa;UA0ElC;;EAEf;;EAEA;;EAEA;;EAEA;;UAGe,oCAAoC;EACnD;;EAEA;;EAEA;;UAGe;;EAEf,cAAc;;EAEd;;EAEA;;EAEA;;EAEA;;UAGe,+BAA+B;;;;;;EAM9C;;;;;;EAMA;;;;;;;;;;;;;;;;;;iBAmBc,0BACd,SAAS,qBACT,OAAM,yBACL;;;;;;;;;iBA0Ha,yCACd,aAAa;EAAQ;EAAgB,QAAQ;IAC7C,OAAM,yBACL;;;;;;;;;;;;;UCvRc;;EAEf;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;;EAEA;;EAEA;;iBA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B,UAAU;;;;;;EAK7D;;EAEA;;EAEA;EACA,WAAW;EACX;;IAEE;;IAEA;;IAEA;;;EAGF,eAAe;;EAEf;;;;;;;iBAyBc,sBACd,KAAK,qBACL,eAAe,YACf,MAAM,eACL;UA+Gc;;;;;EAKf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,QAAQ;;cAGG,2BAA2B,SAAS;KAUrC;UAEK;EACf;EACA;EACA;;EAEA;EACA,QAAQ;;EAER;EACA,WAAW;EACX,QAAQ;;UAGO;EACf;;EAEA;;EAEA;;EAEA,WAAW;EACX;;EAEA,mBAAmB;EACnB,SAAS,QAAQ;;;iBAUH,kBAAkB,OAAO,iBAAiB;;cA2G7C,8BAA8B;WAChC,UAAU;EAEnB,YAAY,UAAU;;;iBASR,mBAAmB,UAAU;;;;;;;;iBAW7B,2BACd,WAAW,gBACX;EAAW,UAAU;IACpB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/meta-eval/correlation-study.ts","../../src/meta-eval/calibration.ts","../../src/meta-eval/cluster-bootstrap.ts","../../src/meta-eval/evaluator-admission.ts","../../src/meta-eval/plants.ts"],"mappings":";;;;;;;;;;iBAoBiB;EACf;;;EAGA,WAAW,KAAK,KAAK,OAAO,eAAe;;iBAG5B;EACf;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;EAEA;IAAe;IAAe;;;EAE9B;IAAgB;IAAe;;;EAE/B;;iBAGe;EACf,OAAO;;EAEP,eAAe,MACb;IACE;IACA;;EAGJ;EACA;;iBAGe;;EAEf;;EAEA,gBAAgB;;EAEhB;;EAEA;;;EAGA;;wBAGoB,iBACpB,YAAY,YACZ,cAAc,cACd,aAAa,kBACb,8BACA,UAAS,0BACR,QAAQ;;;iBChEM;EACf;EACA;EACA;EACA;EACA;;EAEA;;iBAGe;EACf;EACA;EACA;EACA,MAAM;;EAEN;;EAEA;;iBAGe;;EAEf;;EAEA;;EAEA;IAAU;IAAY;;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;;;;;;;;;;;;;;;;;;;;;;;;GAG1B,EAAA,KAAA;;KAGU,8BAA8B,EAAE,aAAa;UAExC,qCAAqC;EACpD;IACE,uBAAuB;IACvB,YAAY;;IAEZ,cAAc;MAAQ;MAAY;;;;;;;;;wBAStB,uBACd,OAAO,8BACN;;;;;;;;YC1TS;;;;;;;;;;YAkBA;iBAOK;;EAEf;EACA,MAAM;;EAEN,MAAM;;EAEN,iBAAiB;;;;;;;;;;;;;;wBAeH,YAAY;EAC1B;EACA,MAAM;EACN,MAAM;EACN,iBAAiB;IACf;;;;;iBAqDa;;EAEf;;EAEA;;;YAIU;;YAGA;iBAEK;;EAEf,UAAU;;EAEV,OAAO;;EAEP,KAAK;;;;;;EAML;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsJc,gBAAgB,UAAU,gBAAgB;iBA8BzC;EACf,OAAO;;EAEP,UAAU;EACV,OAAO;EACP,KAAK;EACL;EACA;;;;;;;;;;;;;;;;;;;;;;wBAuBc,oBAAoB;EAClC;EACA;EACA,UAAU;;EAEV;EACA;IACE;iBA0Ba;;;;;;EAMf,MAAM;;EAEN;;EAEA;;EAEA;;EAEA,QAAQ;;iBAGO;;;;;;EAMf,OAAO;EACP,UAAU;;iBAGK;;;;;EAKf;;;;;;EAMA;;;;;;;;;;;wBAYc,WACd,kBAAkB,cAClB,iBAAiB,SACjB,UAAS,oBACR;;;;;;iBAqGc;EACf;EACA;;;;;;YAOU;iBAEK;EACf;EACA;EACA;EACA;;EAEA;;;;;;;;iBASe;EACf;EACA;EACA;;EAEA;;iBAGe;EACf,QAAQ;;EAER;EACA;EACA;EACA;;;;;EAKA;;EAEA;;EAEA,QAAQ,QAAQ,OAAO,WAAW;;EAElC;;EAEA;EACA,UAAU;;;;;;;;;;wBAWI,UACd,kBAAkB,gBAClB,UAAU,gBACT"}
@@ -1,58 +0,0 @@
1
- //#region src/meta-eval/outcome-store.d.ts
2
- /** Deployment observations join to evaluation records through their runId. */
3
- interface DeploymentOutcome {
4
- runId: string;
5
- capturedAt: number;
6
- /** Finite numeric outcomes; absence of a key means unmeasured. */
7
- metrics: Record<string, number>;
8
- labels?: Record<string, string>;
9
- /** Source system or pipeline version. */
10
- source?: string;
11
- }
12
- interface OutcomeFilter {
13
- runIds?: string[];
14
- since?: number;
15
- until?: number;
16
- label?: {
17
- key: string;
18
- value: string;
19
- };
20
- source?: string;
21
- }
22
- interface OutcomeStore {
23
- append(outcome: DeploymentOutcome): Promise<void>;
24
- forRun(runId: string): Promise<DeploymentOutcome[]>;
25
- list(filter?: OutcomeFilter): Promise<DeploymentOutcome[]>;
26
- }
27
- declare class InMemoryOutcomeStore implements OutcomeStore {
28
- private items;
29
- append(outcome: DeploymentOutcome): Promise<void>;
30
- forRun(runId: string): Promise<DeploymentOutcome[]>;
31
- list(filter?: OutcomeFilter): Promise<DeploymentOutcome[]>;
32
- }
33
- interface FileSystemOutcomeStoreOptions {
34
- dir: string;
35
- /** Rotate before a write once the active file reaches this size. Default 32 MiB. */
36
- maxBytes?: number;
37
- }
38
- /** Storage failures retain operation, path, source line, and the original cause. */
39
- declare class OutcomeStoreError extends Error {
40
- readonly operation: 'read' | 'decode' | 'write';
41
- readonly path: string;
42
- readonly line?: number | undefined;
43
- constructor(operation: 'read' | 'decode' | 'write', path: string, cause: unknown, line?: number | undefined);
44
- }
45
- /** Local storage with serialized operations per instance; use one writer per directory. */
46
- declare class FileSystemOutcomeStore implements OutcomeStore {
47
- private readonly dir;
48
- private readonly maxBytes;
49
- private pending;
50
- constructor(options: FileSystemOutcomeStoreOptions);
51
- append(outcome: DeploymentOutcome): Promise<void>;
52
- forRun(runId: string): Promise<DeploymentOutcome[]>;
53
- list(filter?: OutcomeFilter): Promise<DeploymentOutcome[]>;
54
- private serialize;
55
- }
56
- //#endregion
57
- export { OutcomeFilter as a, InMemoryOutcomeStore as i, FileSystemOutcomeStore as n, OutcomeStore as o, FileSystemOutcomeStoreOptions as r, OutcomeStoreError as s, DeploymentOutcome as t };
58
- //# sourceMappingURL=outcome-store-CNt4iZ67.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"outcome-store-CNt4iZ67.d.ts","names":[],"sources":["../src/meta-eval/outcome-store.ts"],"mappings":";;UAIiB;EACf;EACA;;EAEA,SAAS;EACT,SAAS;;EAET;;UAGe;EACf;EACA;EACA;EACA;IAAU;IAAa;;EACvB;;UAGe;EACf,OAAO,SAAS,oBAAoB;EACpC,OAAO,gBAAgB,QAAQ;EAC/B,KAAK,SAAS,gBAAgB,QAAQ;;cAa3B,gCAAgC;UACnC;EAEF,OAAO,SAAS,oBAAoB;EAIpC,OAAO,gBAAgB,QAAQ;EAI/B,KAAK,SAAQ,gBAAqB,QAAQ;;UAOjC;EACf;;EAEA;;;cAIW,0BAA0B;WAEnB;WACA;WAEA;EAJlB,YACkB,wCACA,cAChB,gBACgB;;;cAUP,kCAAkC;mBAC5B;mBACA;UACT;EAER,YAAY,SAAS;EASf,OAAO,SAAS,oBAAoB;EA8BpC,OAAO,gBAAgB,QAAQ;EAI/B,KAAK,SAAQ,gBAAqB,QAAQ;UAqCxC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"paired-arms-Ct4LTKc1.js","names":[],"sources":["../src/math/normal.ts","../src/statistics/rank-tests.ts","../src/paired-arms.ts"],"sourcesContent":["/**\n * Standard normal cumulative distribution using Abramowitz and Stegun 7.1.26.\n *\n * The approximation is evaluated as erf(x / sqrt(2)). Computing the negative\n * tail from the complementary term avoids cancellation when x is far below 0.\n * The maximum absolute CDF error is approximately 7.5e-8.\n */\nexport function normalCdf(x: number): number {\n if (x === 0) return 0.5\n\n const a1 = 0.254829592\n const a2 = -0.284496736\n const a3 = 1.421413741\n const a4 = -1.453152027\n const a5 = 1.061405429\n const p = 0.3275911\n\n const scaled = Math.abs(x) / Math.SQRT2\n const t = 1 / (1 + p * scaled)\n const complement = ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t * Math.exp(-scaled * scaled)\n\n return x < 0 ? complement / 2 : 1 - complement / 2\n}\n","import { ValidationError } from '../errors'\nimport { normalCdf } from '../math/normal'\nimport { lnGamma } from '../math/special-functions'\nimport {\n assertFiniteSample,\n binomialSignTwoSided,\n makeRng,\n symmetricTwoSampleSeed,\n} from './internal'\n\n// ── Rank tests: exact by default ─────────────────────────────────────\n//\n// At 3–10 repetitions per arm the binding constraint on a rank test is\n// combinatorial, not numerical. Three versus three admits only 20 splits, so\n// the attainable two-sided p-grid starts at 0.1000 and α = 0.05 is out of\n// reach at that design; a normal approximation reports 0.0495, a p-value that\n// describes no attainable outcome. No better approximation fixes this — adding\n// the tie correction moves `[0,0,0]` versus `[1,1,1]` from 0.0495 to 0.0469,\n// further from its exact 0.1000, not closer.\n//\n// So both null distributions are enumerated exactly inside bounded state and\n// work budgets, by convolution over the observed midranks (identical to\n// enumerating every split / sign pattern, and cheaper), which conditions on the\n// realised tie pattern for free. Above those budgets the default is a seeded\n// Monte Carlo permutation. The asymptotic path is never chosen automatically,\n// and asking for it inside the exact-feasible range throws.\n//\n// Every result carries `method` and `pFloor` so a downstream gate can SEE the\n// discreteness rather than infer it: a gate handed data whose `pFloor` exceeds\n// its alpha is underpowered by construction, which is a true statement about\n// the experiment, not a false one about the effect.\n\n/** How a rank test's p-value was actually computed. */\nexport type RankTestMethod = 'exact' | 'permutation' | 'asymptotic'\n\n/**\n * What the caller asks for. `'auto'` selects `'exact'` inside the enumeration\n * threshold and `'permutation'` above it, and never selects `'asymptotic'`.\n */\nexport type RankTestMethodRequest = 'auto' | 'exact' | 'asymptotic'\n\nexport interface RankTestOptions {\n /** Default `'auto'`. `'asymptotic'` inside the exact-feasible range throws. */\n method?: RankTestMethodRequest\n /** Resamples on the Monte Carlo permutation path. Default 100000. */\n permutations?: number\n /** Seed for the permutation path. Omitted ⇒ derived from the data itself, so\n * the result is reproducible either way. */\n seed?: number\n}\n\n/** Maximum dynamic-programming cells used by an exact two-sample rank test. */\nconst MANN_WHITNEY_EXACT_MAX_STATES = 8_192\n/** Maximum inner-loop transitions used by an exact two-sample rank test. */\nconst MANN_WHITNEY_EXACT_MAX_WORK = 250_000\n/** Non-zero differences up to which the signed-rank null is enumerated exactly. */\nconst WILCOXON_EXACT_MAX_N = 20\n/** Resamples used when a rank test falls back to Monte Carlo permutation. */\nconst DEFAULT_PERMUTATIONS = 100_000\n\nexport interface MannWhitneyResult {\n /** `min(U_a, U_b)` — the conventional reported statistic. */\n u: number\n /** U for sample `a`. Carries the direction of the effect, which `u` discards. */\n uA: number\n /** Two-sided p-value. */\n p: number\n /** How `p` was computed. */\n method: RankTestMethod\n /** Smallest two-sided p this design can produce. `p` can never be below it. */\n pFloor: number\n}\n\n/**\n * Mann-Whitney U — two independent samples, no distributional assumption.\n *\n * Exact conditional (permutation) p by default when the dynamic program fits\n * {@link MANN_WHITNEY_EXACT_MAX_STATES} cells and\n * {@link MANN_WHITNEY_EXACT_MAX_WORK} transitions, seeded Monte Carlo\n * permutation above those limits. This keeps imbalanced designs such as 1+24\n * exact without admitting expensive balanced designs merely because they have\n * the same total size. Throws on non-finite input and on `method:\n * 'asymptotic'` where an exact answer is available. Empty input yields `p = 1,\n * pFloor = 1` — no design, no attainable evidence.\n */\nexport function mannWhitneyU(\n a: number[],\n b: number[],\n opts: RankTestOptions = {},\n): MannWhitneyResult {\n assertFiniteSample('mannWhitneyU', 'a', a)\n assertFiniteSample('mannWhitneyU', 'b', b)\n\n const n1 = a.length\n const n2 = b.length\n if (n1 === 0 || n2 === 0) return { u: 0, uA: 0, p: 1, method: 'exact', pFloor: 1 }\n\n const total = n1 + n2\n const combined = [\n ...a.map((v) => ({ v, fromA: true })),\n ...b.map((v) => ({ v, fromA: false })),\n ].sort((x, y) => x.v - y.v)\n\n const { midranks, tieTerm } = midranksWithTieTerm(combined.map((entry) => entry.v))\n let rankSumA = 0\n for (let k = 0; k < total; k++) {\n if (combined[k]!.fromA) rankSumA += midranks[k]!\n }\n\n const uA = rankSumA - (n1 * (n1 + 1)) / 2\n const u = Math.min(uA, n1 * n2 - uA)\n // Midranks are integers or halves, so doubling makes the null convolution\n // integral. U is centred on n₁n₂/2, hence a doubled centre of n₁n₂.\n const doubled = midranks.map((rank) => Math.round(rank * 2))\n const doubledDeviation = Math.abs(2 * uA - n1 * n2)\n const selectedN = Math.min(n1, n2)\n const otherN = total - selectedN\n const exactCost = exactTwoSampleCost(doubled, selectedN)\n\n const designFloor = exactTwoSampleFloor(doubled, selectedN)\n const method = selectRankTestMethod(\n 'mannWhitneyU',\n opts.method ?? 'auto',\n `n1=${n1}, n2=${n2}`,\n exactCost.states <= MANN_WHITNEY_EXACT_MAX_STATES &&\n exactCost.work <= MANN_WHITNEY_EXACT_MAX_WORK,\n designFloor,\n `${MANN_WHITNEY_EXACT_MAX_STATES.toLocaleString('en-US')} states and ` +\n `${MANN_WHITNEY_EXACT_MAX_WORK.toLocaleString('en-US')} transitions`,\n )\n\n if (method === 'exact') {\n const { p, pFloor } = exactTwoSampleP(doubled, selectedN, otherN, doubledDeviation)\n return { u, uA, p, method, pFloor }\n }\n\n if (method === 'asymptotic') {\n return {\n u,\n uA,\n p: asymptoticTwoSidedP(doubledDeviation / 2, twoSampleSigma(n1, n2, total, tieTerm)),\n method,\n pFloor: designFloor,\n }\n }\n\n const permutations = resolvePermutations('mannWhitneyU', opts.permutations)\n const rng = opts.seed === undefined ? makeRng(symmetricTwoSampleSeed(a, b)) : makeRng(opts.seed)\n let atLeastAsExtreme = 0\n const pool = [...doubled]\n for (let iteration = 0; iteration < permutations; iteration++) {\n let doubledRankSum = 0\n for (let k = 0; k < selectedN; k++) {\n const pick = k + Math.floor(rng() * (total - k))\n const swapped = pool[pick]!\n pool[pick] = pool[k]!\n pool[k] = swapped\n doubledRankSum += swapped\n }\n if (\n Math.abs(doubledRankSum - selectedN * (selectedN + 1) - selectedN * otherN) >=\n doubledDeviation\n ) {\n atLeastAsExtreme++\n }\n }\n const pFloor = Math.max(1 / (permutations + 1), designFloor)\n return {\n u,\n uA,\n p: Math.max((1 + atLeastAsExtreme) / (permutations + 1), pFloor),\n method,\n pFloor,\n }\n}\n\nexport interface WilcoxonSignedRankResult {\n /** W⁺, the rank sum of the positive differences. (scipy reports\n * `min(W⁺, W⁻)`; compare statistics only after converting.) */\n w: number\n /** Two-sided p-value. */\n p: number\n /** How `p` was computed. */\n method: RankTestMethod\n /** Smallest two-sided p this design can produce. */\n pFloor: number\n /** Non-zero differences — zero differences are dropped and carry no rank. */\n nNonZero: number\n}\n\n/**\n * Wilcoxon signed-rank — paired, no distributional assumption on the deltas.\n *\n * Exact conditional (sign-flip) p by default at `n ≤\n * {@link WILCOXON_EXACT_MAX_N}` non-zero differences, seeded Monte Carlo\n * permutation above it. Throws on non-finite input and on `method:\n * 'asymptotic'` where an exact answer is available.\n *\n * `n` is the count of NON-ZERO differences: exact ties are dropped before\n * ranking, so a run of tied pairs shrinks the design and raises `pFloor`.\n * All-tied input yields `p = 1, pFloor = 1` — no attainable evidence, which\n * `pFloor` states rather than leaving `p = 1` to be read as a measured null.\n */\nexport function wilcoxonSignedRank(\n before: number[],\n after: number[],\n opts: RankTestOptions = {},\n): WilcoxonSignedRankResult {\n if (before.length !== after.length) {\n throw new ValidationError(\n `wilcoxonSignedRank: unequal sample sizes (${before.length} vs ${after.length})`,\n )\n }\n assertFiniteSample('wilcoxonSignedRank', 'before', before)\n assertFiniteSample('wilcoxonSignedRank', 'after', after)\n\n const diffs = before.map((b, i) => after[i]! - b).filter((d) => d !== 0)\n const n = diffs.length\n if (n === 0) return { w: 0, p: 1, method: 'exact', pFloor: 1, nNonZero: 0 }\n\n // When every non-zero difference has the same magnitude, the signed-rank\n // null reduces exactly to a binomial sign distribution. This is the common\n // pass/fail shape ({-1, 0, +1}); recognizing it avoids a 100k-draw\n // permutation for every repeated gate evaluation while preserving the exact\n // p-value and attainable floor. Explicit method requests still retain their\n // documented behavior.\n const abs = Math.abs(diffs[0]!)\n const allEqualAbs = diffs.every((d) => Math.abs(d) === abs)\n if ((opts.method === undefined || opts.method === 'auto') && allEqualAbs) {\n const positive = diffs.filter((d) => d > 0).length\n const negative = n - positive\n return {\n w: (positive * (n + 1)) / 2,\n p: binomialSignTwoSided(positive, negative),\n method: 'exact',\n pFloor: Math.min(1, 2 ** (1 - n)),\n nNonZero: n,\n }\n }\n\n const order = diffs.map((d, i) => ({ abs: Math.abs(d), i })).sort((x, y) => x.abs - y.abs)\n const { midranks, tieTerm } = midranksWithTieTerm(order.map((entry) => entry.abs))\n const ranks: number[] = new Array(n)\n for (let k = 0; k < n; k++) ranks[order[k]!.i] = midranks[k]!\n\n let wPlus = 0\n for (let k = 0; k < n; k++) if (diffs[k]! > 0) wPlus += ranks[k]!\n\n // Midranks are integers or halves; doubling makes the convolution integral.\n // Σ midranks = n(n+1)/2 whatever the tie pattern, so E[W⁺] = n(n+1)/4 and\n // the doubled centre is n(n+1)/2.\n const doubled = midranks.map((rank) => Math.round(rank * 2))\n const doubledDeviation = Math.abs(2 * wPlus - (n * (n + 1)) / 2)\n\n const designFloor = Math.min(1, 2 ** (1 - n))\n const method = selectRankTestMethod(\n 'wilcoxonSignedRank',\n opts.method ?? 'auto',\n `n=${n} non-zero differences`,\n n <= WILCOXON_EXACT_MAX_N,\n designFloor,\n `${WILCOXON_EXACT_MAX_N} non-zero differences`,\n )\n\n if (method === 'exact') {\n const { p, pFloor } = exactSignedRankP(doubled, doubledDeviation)\n return { w: wPlus, p, method, pFloor, nNonZero: n }\n }\n\n if (method === 'asymptotic') {\n const variance = (n * (n + 1) * (2 * n + 1)) / 24 - tieTerm / 48\n return {\n w: wPlus,\n p: asymptoticTwoSidedP(doubledDeviation / 2, Math.sqrt(variance)),\n method,\n pFloor: designFloor,\n nNonZero: n,\n }\n }\n\n const permutations = resolvePermutations('wilcoxonSignedRank', opts.permutations)\n const rng = makeRng(opts.seed, before, after)\n const doubledCentre = (n * (n + 1)) / 2\n let atLeastAsExtreme = 0\n for (let iteration = 0; iteration < permutations; iteration++) {\n let doubledWPlus = 0\n for (let k = 0; k < n; k++) if (rng() < 0.5) doubledWPlus += doubled[k]!\n if (Math.abs(doubledWPlus - doubledCentre) >= doubledDeviation) atLeastAsExtreme++\n }\n return {\n w: wPlus,\n p: (1 + atLeastAsExtreme) / (permutations + 1),\n method,\n pFloor: Math.max(1 / (permutations + 1), designFloor),\n nNonZero: n,\n }\n}\n\n/**\n * Average ranks over an ASCENDING-sorted array, plus `Σ(t³ − t)` over tie\n * groups of size `t` — the correction term both asymptotic rank-test variances\n * need.\n */\nfunction midranksWithTieTerm(sorted: readonly number[]): { midranks: number[]; tieTerm: number } {\n const midranks = new Array<number>(sorted.length)\n let tieTerm = 0\n let i = 0\n while (i < sorted.length) {\n let j = i\n while (j < sorted.length && sorted[j] === sorted[i]) j++\n const average = (i + 1 + j) / 2\n for (let k = i; k < j; k++) midranks[k] = average\n const groupSize = j - i\n if (groupSize > 1) tieTerm += groupSize ** 3 - groupSize\n i = j\n }\n return { midranks, tieTerm }\n}\n\nfunction selectRankTestMethod(\n fn: string,\n request: RankTestMethodRequest,\n design: string,\n exactFeasible: boolean,\n designFloor: number,\n threshold: string,\n): RankTestMethod {\n if (request === 'auto') return exactFeasible ? 'exact' : 'permutation'\n if (request === 'exact') {\n if (exactFeasible) return 'exact'\n throw new ValidationError(\n `${fn}: method 'exact' is out of range at ${design} — enumeration is bounded by ` +\n `${threshold}. Use 'auto' for the seeded Monte Carlo permutation, which converges ` +\n 'to the same answer.',\n )\n }\n if (exactFeasible) {\n throw new ValidationError(\n `${fn}: method 'asymptotic' is refused at ${design} — the exact p-grid at this design ` +\n `starts at ${formatProbability(designFloor)}, so an asymptotic p below it describes no ` +\n `attainable outcome. Use method 'exact' (the default) or add repetitions past ` +\n `${threshold}.`,\n )\n }\n return 'asymptotic'\n}\n\nfunction resolvePermutations(fn: string, permutations: number | undefined): number {\n if (permutations === undefined) return DEFAULT_PERMUTATIONS\n if (!Number.isInteger(permutations) || permutations < 1) {\n throw new ValidationError(`${fn}: permutations must be a positive integer, got ${permutations}`)\n }\n return permutations\n}\n\n/** Two-sided normal-approximation tail with the continuity correction. */\nfunction asymptoticTwoSidedP(deviation: number, sigma: number): number {\n if (!(sigma > 0)) return 1\n return Math.min(1, 2 * (1 - normalCdf(Math.max(0, deviation - 0.5) / sigma)))\n}\n\n/** SD of U under the permutation null, corrected for the realised ties. The\n * tie term reduces (N+1) and reaches it exactly when every value is tied, so\n * the variance floors at 0 rather than going negative. */\nfunction twoSampleSigma(n1: number, n2: number, total: number, tieTerm: number): number {\n if (total < 2) return 0\n const variance = ((n1 * n2) / 12) * (total + 1 - tieTerm / (total * (total - 1)))\n return Math.sqrt(Math.max(0, variance))\n}\n\nfunction logChoose(n: number, k: number): number {\n return lnGamma(n + 1) - lnGamma(k + 1) - lnGamma(n - k + 1)\n}\n\nfunction formatProbability(value: number): string {\n return value >= 1e-4 || value === 0 ? value.toFixed(4) : value.toExponential(3)\n}\n\n/**\n * Exact DP allocation and loop count for this observed rank vector.\n *\n * The smaller arm is sufficient because selecting its complement produces the\n * same two-sided U deviation while using fewer rows in the state table.\n */\nfunction exactTwoSampleCost(\n doubledRanks: readonly number[],\n selectedN: number,\n): { states: number; work: number } {\n const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0)\n let work = 0\n for (let placed = 0; placed < doubledRanks.length; placed++) {\n work += Math.min(selectedN, placed + 1) * (maxSum - doubledRanks[placed]! + 1)\n }\n return {\n states: (selectedN + 1) * (maxSum + 1),\n work,\n }\n}\n\n/**\n * Smallest attainable two-sided p under the observed ties.\n *\n * Only subsets with the minimum or maximum rank sum can attain the largest\n * deviation. Their multiplicity is the number of ways to choose within the\n * tie group at each boundary, so this calculation is exact without allocating\n * the full null distribution.\n */\nfunction exactTwoSampleFloor(doubledRanks: readonly number[], selectedN: number): number {\n const total = doubledRanks.length\n const otherN = total - selectedN\n const minimumSum = doubledRanks.slice(0, selectedN).reduce((sum, rank) => sum + rank, 0)\n const maximumSum = doubledRanks.slice(total - selectedN).reduce((sum, rank) => sum + rank, 0)\n if (minimumSum === maximumSum) return 1\n\n const centre = selectedN * (selectedN + 1) + selectedN * otherN\n const minimumDeviation = Math.abs(minimumSum - centre)\n const maximumDeviation = Math.abs(maximumSum - centre)\n const totalLogWays = logChoose(total, selectedN)\n const minimumMass = Math.exp(\n logExtremeSubsetWays(doubledRanks, selectedN, 'minimum') - totalLogWays,\n )\n const maximumMass = Math.exp(\n logExtremeSubsetWays(doubledRanks, selectedN, 'maximum') - totalLogWays,\n )\n\n if (minimumDeviation > maximumDeviation) return minimumMass\n if (maximumDeviation > minimumDeviation) return maximumMass\n return Math.min(1, minimumMass + maximumMass)\n}\n\nfunction logExtremeSubsetWays(\n sortedRanks: readonly number[],\n selectedN: number,\n side: 'minimum' | 'maximum',\n): number {\n const boundaryIndex = side === 'minimum' ? selectedN - 1 : sortedRanks.length - selectedN\n const boundary = sortedRanks[boundaryIndex]!\n let first = boundaryIndex\n let afterLast = boundaryIndex + 1\n while (first > 0 && sortedRanks[first - 1] === boundary) first--\n while (afterLast < sortedRanks.length && sortedRanks[afterLast] === boundary) afterLast++\n\n const tieSize = afterLast - first\n const fixed = side === 'minimum' ? first : sortedRanks.length - afterLast\n return logChoose(tieSize, selectedN - fixed)\n}\n\n/**\n * Exact conditional two-sided p for the two-sample rank test.\n *\n * Convolves the observed doubled midranks into the null distribution of group\n * a's rank sum over every `C(n₁+n₂, n₁)` split — identical to enumerating the\n * splits, but `O(N·n₁·ΣR)` instead of `O(C(N,n₁)·n₁n₂)`. Conditioning on the\n * realised multiset makes the tie handling exact rather than a correction.\n *\n * The null is symmetric about `n₁n₂/2` (negating every value maps `U → n₁n₂ −\n * U` and permutes the split set onto itself), so the two-sided p is the mass\n * at least as far from the centre as the observation.\n */\nfunction exactTwoSampleP(\n doubledRanks: readonly number[],\n n1: number,\n n2: number,\n doubledDeviation: number,\n): { p: number; pFloor: number } {\n const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0)\n const width = maxSum + 1\n // ways[k][s] = number of size-k subsets whose doubled rank sum is s.\n const ways: Float64Array[] = Array.from({ length: n1 + 1 }, () => new Float64Array(width))\n ways[0]![0] = 1\n let placed = 0\n for (const rank of doubledRanks) {\n for (let k = Math.min(n1, placed + 1); k >= 1; k--) {\n const from = ways[k - 1]!\n const into = ways[k]!\n for (let sum = maxSum - rank; sum >= 0; sum--) {\n const count = from[sum]!\n if (count !== 0) into[sum + rank]! += count\n }\n }\n placed++\n }\n\n // U = rankSum − n₁(n₁+1)/2, so doubled U = s − n₁(n₁+1), and the doubled\n // centre 2·(n₁n₂/2) is n₁n₂.\n const shift = n1 * (n1 + 1) + n1 * n2\n const chosen = ways[n1]!\n let totalWays = 0\n let extremeWays = 0\n let tailWays = 0\n let maxDeviation = -1\n for (let sum = 0; sum < width; sum++) {\n const count = chosen[sum]!\n if (count === 0) continue\n totalWays += count\n const deviation = Math.abs(sum - shift)\n if (deviation >= doubledDeviation) tailWays += count\n if (deviation > maxDeviation) {\n maxDeviation = deviation\n extremeWays = count\n } else if (deviation === maxDeviation) {\n extremeWays += count\n }\n }\n return { p: tailWays / totalWays, pFloor: extremeWays / totalWays }\n}\n\n/**\n * Exact conditional two-sided p for the paired signed-rank test.\n *\n * Convolves the observed doubled absolute midranks over all `2ⁿ` sign\n * assignments in `O(n·ΣR)`. Probabilities rather than counts keep `2ⁿ` off the\n * arithmetic. The null is symmetric about `n(n+1)/4`.\n */\nfunction exactSignedRankP(\n doubledRanks: readonly number[],\n doubledDeviation: number,\n): { p: number; pFloor: number } {\n const maxSum = doubledRanks.reduce((sum, rank) => sum + rank, 0)\n const width = maxSum + 1\n let mass = new Float64Array(width)\n mass[0] = 1\n for (const rank of doubledRanks) {\n const next = new Float64Array(width)\n for (let sum = 0; sum < width; sum++) {\n const probability = mass[sum]!\n if (probability === 0) continue\n next[sum]! += probability * 0.5\n next[sum + rank]! += probability * 0.5\n }\n mass = next\n }\n\n const centre = maxSum / 2\n let tail = 0\n let extreme = 0\n let maxDeviation = -1\n for (let sum = 0; sum < width; sum++) {\n const probability = mass[sum]!\n if (probability === 0) continue\n const deviation = Math.abs(sum - centre)\n if (deviation >= doubledDeviation) tail += probability\n if (deviation > maxDeviation) {\n maxDeviation = deviation\n extreme = probability\n } else if (deviation === maxDeviation) {\n extreme += probability\n }\n }\n return { p: Math.min(1, tail), pFloor: Math.min(1, extreme) }\n}\n","/**\n * Matched-pair arm comparison — \"did the treatment arm beat the baseline arm\n * on the SAME work items?\"\n *\n * An arm A/B over run records is only trustworthy when it is PAIRED: the same\n * task/scenario/seed evaluated under both arms, compared item-by-item, so\n * inter-item difficulty variance cancels instead of masquerading as an arm\n * effect. This module owns the two error-prone steps every consumer otherwise\n * hand-rolls:\n *\n * 1. Pairing — matching rows across arms by `pairKey` (and by `repKey`\n * within multi-rep items), with leftovers REPORTED rather than silently\n * dropped (a silently unbalanced pairing biases every paired statistic\n * downstream). Pairing never keys on outcome content: matching reps by\n * their outcomes deflates discordant-pair counts and makes McNemar\n * anti-conservative, so reps pair only by (`pairKey`, `repKey`) identity.\n * 2. Composition — feeding the matched pairs to the correct paired\n * estimators that already live in `statistics`: `mcnemar` +\n * `pairedRiskDifference` for pass/fail, `pairedBootstrap` +\n * `wilcoxonSignedRank` for continuous metrics. No statistic is\n * re-implemented here.\n *\n * The row shape is deliberately structural — callers project a `RunRecord`\n * (or any record) into `{ pairKey, arm, pass?, metrics? }`. Arm names are\n * caller-supplied parameters; the module ships no domain literal.\n */\n\nimport { ValidationError } from './errors'\nimport type { RunRecord } from './run-record'\nimport type { McNemarResult, PairedBootstrapOptions, PairedBootstrapResult } from './statistics'\nimport {\n mcnemar,\n pairedBootstrap,\n pairedRiskDifference,\n type RiskDifferenceResult,\n wilcoxonSignedRank,\n} from './statistics'\n\n/** One arm observation of one work item. Structural on purpose: callers\n * project their own record type (e.g. a `RunRecord`) into this shape. */\nexport interface PairedArmRow {\n /** Matching key — rows sharing a `pairKey` across both arms form pairs\n * (typically the task/scenario/seed identity). */\n pairKey: string\n /** Rep identity within a `pairKey` (e.g. a seed or rep number). Required on\n * every row of a `pairKey` that has more than one rep in either arm; reps\n * then pair only on exact (`pairKey`, `repKey`) match, never on outcome\n * content. Optional when each arm has at most one rep of the item. */\n repKey?: string\n /** Arm label this row was produced under. */\n arm: string\n /** Binary outcome; omit when the comparison has no pass/fail notion. */\n pass?: boolean\n /** Named numeric measurements (score, cost, latency, …). */\n metrics?: Record<string, number>\n}\n\nexport interface PairArmsOptions {\n /** Arm treated as the control side of every pair. */\n baselineArm: string\n /** Arm treated as the treatment side of every pair. */\n treatmentArm: string\n}\n\n/** One matched (baseline, treatment) observation of the same work item. */\nexport interface MatchedPair {\n pairKey: string\n /** 0-based position of this pair within its `pairKey`, ordered by sorted\n * `repKey` (always 0 for a single-rep item). The rep identity itself is on\n * the rows (`baseline.repKey` / `treatment.repKey`). */\n repIndex: number\n baseline: PairedArmRow\n treatment: PairedArmRow\n}\n\nexport interface PairArmsResult {\n /** Matched pairs, ordered by (`pairKey`, `repIndex`). */\n pairs: MatchedPair[]\n /** Baseline rows left without a treatment counterpart — reported, never\n * silently dropped. */\n unpairedBaseline: PairedArmRow[]\n /** Treatment rows left without a baseline counterpart. */\n unpairedTreatment: PairedArmRow[]\n}\n\n/**\n * Match rows across two arms into (baseline, treatment) pairs by `pairKey`.\n *\n * A `pairKey` with at most one row per arm pairs directly, no `repKey`\n * needed. A `pairKey` with multiple reps in either arm requires `repKey` on\n * every one of its rows, and reps pair only on exact (`pairKey`, `repKey`)\n * match — pairing is keyed purely on row identity, never on outcome content\n * (outcome-keyed matching deflates discordant counts and biases McNemar), and\n * is therefore independent of input order. Reps whose `repKey` has no\n * counterpart in the other arm, and items present in only one arm, land in\n * the unpaired lists — reported, never truncated.\n *\n * Fail-loud: throws when either named arm has zero rows (an unknown arm\n * name would otherwise read as \"everything unpaired\"), when the two arm\n * names are equal, when a multi-rep `pairKey` has a row without `repKey`, or\n * when a (`pairKey`, arm) group repeats a `repKey` (the match would be\n * ambiguous).\n */\nexport function pairArms(rows: readonly PairedArmRow[], opts: PairArmsOptions): PairArmsResult {\n const { baselineArm, treatmentArm } = opts\n if (baselineArm === treatmentArm) {\n throw new ValidationError(\n `pairArms: baselineArm and treatmentArm are both '${baselineArm}' — an arm cannot be compared to itself`,\n )\n }\n\n // arm → pairKey → rows\n const byArm = new Map<string, Map<string, PairedArmRow[]>>()\n const armsSeen = new Set<string>()\n for (const row of rows) {\n armsSeen.add(row.arm)\n if (row.arm !== baselineArm && row.arm !== treatmentArm) continue\n const byKey = byArm.get(row.arm) ?? new Map<string, PairedArmRow[]>()\n const group = byKey.get(row.pairKey) ?? []\n group.push(row)\n byKey.set(row.pairKey, group)\n byArm.set(row.arm, byKey)\n }\n\n for (const arm of [baselineArm, treatmentArm]) {\n if (!byArm.has(arm)) {\n const seen = [...armsSeen].sort().join(', ') || '<none>'\n throw new ValidationError(`pairArms: no rows for arm '${arm}' (arms present: ${seen})`)\n }\n }\n\n const baselineByKey = byArm.get(baselineArm)!\n const treatmentByKey = byArm.get(treatmentArm)!\n\n const allKeys = [...new Set([...baselineByKey.keys(), ...treatmentByKey.keys()])].sort()\n const pairs: MatchedPair[] = []\n const unpairedBaseline: PairedArmRow[] = []\n const unpairedTreatment: PairedArmRow[] = []\n for (const pairKey of allKeys) {\n const b = baselineByKey.get(pairKey) ?? []\n const t = treatmentByKey.get(pairKey) ?? []\n\n if (b.length <= 1 && t.length <= 1) {\n if (b.length === 1 && t.length === 1) {\n const baseline = b[0]!\n const treatment = t[0]!\n if (baseline.repKey !== undefined || treatment.repKey !== undefined) {\n if (\n baseline.repKey === undefined ||\n treatment.repKey === undefined ||\n baseline.repKey !== treatment.repKey\n ) {\n unpairedBaseline.push(baseline)\n unpairedTreatment.push(treatment)\n continue\n }\n }\n pairs.push({ pairKey, repIndex: 0, baseline, treatment })\n } else {\n unpairedBaseline.push(...b)\n unpairedTreatment.push(...t)\n }\n continue\n }\n\n const bByRep = indexByRepKey(b, pairKey, baselineArm)\n const tByRep = indexByRepKey(t, pairKey, treatmentArm)\n const repKeys = [...new Set([...bByRep.keys(), ...tByRep.keys()])].sort()\n let repIndex = 0\n for (const repKey of repKeys) {\n const baseline = bByRep.get(repKey)\n const treatment = tByRep.get(repKey)\n if (baseline !== undefined && treatment !== undefined) {\n pairs.push({ pairKey, repIndex: repIndex++, baseline, treatment })\n } else if (baseline !== undefined) {\n unpairedBaseline.push(baseline)\n } else if (treatment !== undefined) {\n unpairedTreatment.push(treatment)\n }\n }\n }\n\n return { pairs, unpairedBaseline, unpairedTreatment }\n}\n\n/** Index a multi-rep (pairKey, arm) group by `repKey`, enforcing that every\n * row carries one and that no repKey repeats within the group. */\nfunction indexByRepKey(\n group: readonly PairedArmRow[],\n pairKey: string,\n arm: string,\n): Map<string, PairedArmRow> {\n const byRep = new Map<string, PairedArmRow>()\n for (const row of group) {\n if (row.repKey === undefined) {\n throw new ValidationError(\n `pairArms: pairKey '${pairKey}' has multiple reps in an arm, but a row in arm '${arm}' ` +\n `is missing repKey — multi-rep items require an explicit repKey on every row so reps ` +\n `pair by identity (pairing reps by outcome or by index would bias the paired statistics)`,\n )\n }\n if (byRep.has(row.repKey)) {\n throw new ValidationError(\n `pairArms: duplicate repKey '${row.repKey}' for pairKey '${pairKey}' in arm '${arm}' — ` +\n `(pairKey, repKey) must uniquely identify a rep within an arm`,\n )\n }\n byRep.set(row.repKey, row)\n }\n return byRep\n}\n\n/** Paired pass/fail comparison over the pairs where BOTH sides carry `pass`. */\nexport interface PairedCorrectness {\n /** Discordant pairs where the treatment passed and the baseline failed. */\n b10: number\n /** Discordant pairs where the baseline passed and the treatment failed. */\n b01: number\n /** Exact McNemar significance over the paired outcomes (`b === b10`, `c === b01`). */\n mcnemar: McNemarResult\n /** Paired effect size: p(treatment) − p(baseline) with a paired-variance CI. */\n riskDifference: RiskDifferenceResult\n}\n\n/** Paired delta summary for one named metric (delta = treatment − baseline). */\nexport interface PairedMetricDelta {\n name: string\n /** Pairs where BOTH sides carry a finite value for this metric. */\n n: number\n /** Pairs where at least one side does not carry the metric. */\n nMissing: number\n /** Median paired delta, or null when `n === 0`. */\n medianDelta: number | null\n /** Mean paired delta, or null when `n === 0`. */\n meanDelta: number | null\n /** Bootstrap CI on the paired delta (`pairedBootstrap`); null when\n * `n === 0` — a zero-width [0, 0] interval on no data would read as a\n * measured tight null. */\n bootstrapCi: PairedBootstrapResult | null\n /** Wilcoxon signed-rank test on the paired deltas; null when `n === 0`. */\n wilcoxon: { w: number; p: number } | null\n}\n\nexport interface ComparePairedArmsOptions extends PairArmsOptions {\n /** Metrics to compare. Default: every metric name observed on any matched\n * pair, sorted. A name that appears on no pair is still reported (with\n * `n = 0`) so a misspelled metric is visible instead of vanishing. */\n metricNames?: string[]\n /** Passed through to `pairedBootstrap` — set `seed` for reproducible CIs. */\n bootstrap?: PairedBootstrapOptions\n}\n\nexport interface PairedArmsComparison {\n nPairs: number\n nUnpairedBaseline: number\n nUnpairedTreatment: number\n /** null when no matched pair carries `pass` on both sides — a pass/fail\n * verdict over rows that never measured pass/fail would be fabricated. */\n correctness: PairedCorrectness | null\n metricDeltas: PairedMetricDelta[]\n}\n\n/**\n * Full matched-pair arm comparison: pair via {@link pairArms}, then compose\n * the paired estimators from `statistics` over the matched pairs.\n *\n * Correctness uses only the pairs where both sides carry `pass` (`mcnemar.n`\n * is that subset's size); each metric uses only the pairs where both sides\n * carry a finite value for it, with the remainder counted in `nMissing`.\n * Deltas are treatment − baseline throughout.\n *\n * Fail-loud: inherits {@link pairArms}'s unknown-arm throw, and throws on a\n * non-finite metric value — silently treating corrupt telemetry as \"metric\n * absent\" would misreport it as missing coverage.\n */\nexport function comparePairedArms(\n rows: readonly PairedArmRow[],\n opts: ComparePairedArmsOptions,\n): PairedArmsComparison {\n const { pairs, unpairedBaseline, unpairedTreatment } = pairArms(rows, opts)\n\n let correctness: PairedCorrectness | null = null\n const baselinePass: number[] = []\n const treatmentPass: number[] = []\n for (const pair of pairs) {\n if (pair.baseline.pass === undefined || pair.treatment.pass === undefined) continue\n baselinePass.push(pair.baseline.pass ? 1 : 0)\n treatmentPass.push(pair.treatment.pass ? 1 : 0)\n }\n if (baselinePass.length > 0) {\n const mc = mcnemar(baselinePass, treatmentPass)\n correctness = {\n b10: mc.b,\n b01: mc.c,\n mcnemar: mc,\n riskDifference: pairedRiskDifference(baselinePass, treatmentPass),\n }\n }\n\n const metricNames =\n opts.metricNames ??\n [\n ...new Set(\n pairs.flatMap((p) => [\n ...Object.keys(p.baseline.metrics ?? {}),\n ...Object.keys(p.treatment.metrics ?? {}),\n ]),\n ),\n ].sort()\n\n const metricDeltas: PairedMetricDelta[] = metricNames.map((name) => {\n const before: number[] = []\n const after: number[] = []\n let nMissing = 0\n for (const pair of pairs) {\n const b = metricValue(pair.baseline, name)\n const t = metricValue(pair.treatment, name)\n if (b === undefined || t === undefined) {\n nMissing++\n continue\n }\n before.push(b)\n after.push(t)\n }\n const bootstrapCi = before.length === 0 ? null : pairedBootstrap(before, after, opts.bootstrap)\n return {\n name,\n n: before.length,\n nMissing,\n medianDelta: bootstrapCi?.median ?? null,\n meanDelta: bootstrapCi?.mean ?? null,\n bootstrapCi,\n wilcoxon: before.length === 0 ? null : wilcoxonSignedRank(before, after),\n }\n })\n\n return {\n nPairs: pairs.length,\n nUnpairedBaseline: unpairedBaseline.length,\n nUnpairedTreatment: unpairedTreatment.length,\n correctness,\n metricDeltas,\n }\n}\n\nexport interface MatchedRunRecordPair {\n pairKey: string\n repKey: string\n baseline: RunRecord\n treatment: RunRecord\n}\n\nexport interface PairRunRecordsResult {\n pairs: MatchedRunRecordPair[]\n unpairedBaseline: RunRecord[]\n unpairedTreatment: RunRecord[]\n}\n\ninterface RunRecordArmRow extends PairedArmRow {\n run: RunRecord\n repKey: string\n}\n\n/**\n * Pair two RunRecord arms by the identity of the evaluated work:\n * `(experimentId, scenarioId, seed)`.\n *\n * Falling back to array order, candidate id, or experiment id can compare\n * different tasks and fabricate lift. Duplicate identities throw.\n */\nexport function pairRunRecords(\n baselineRuns: readonly RunRecord[],\n treatmentRuns: readonly RunRecord[],\n): PairRunRecordsResult {\n const baselineRows = runRecordArmRows(baselineRuns, 'baseline')\n const treatmentRows = runRecordArmRows(treatmentRuns, 'treatment')\n validateRunRecordArmRows(baselineRows, 'baseline')\n validateRunRecordArmRows(treatmentRows, 'treatment')\n if (baselineRows.length === 0 || treatmentRows.length === 0) {\n return {\n pairs: [],\n unpairedBaseline: baselineRows.map((row) => row.run),\n unpairedTreatment: treatmentRows.map((row) => row.run),\n }\n }\n\n const result = pairArms([...baselineRows, ...treatmentRows], {\n baselineArm: 'baseline',\n treatmentArm: 'treatment',\n })\n return {\n pairs: result.pairs.map((pair) => {\n const baseline = pair.baseline as RunRecordArmRow\n const treatment = pair.treatment as RunRecordArmRow\n return {\n pairKey: pair.pairKey,\n repKey: baseline.repKey,\n baseline: baseline.run,\n treatment: treatment.run,\n }\n }),\n unpairedBaseline: result.unpairedBaseline.map((row) => (row as RunRecordArmRow).run),\n unpairedTreatment: result.unpairedTreatment.map((row) => (row as RunRecordArmRow).run),\n }\n}\n\nfunction runRecordArmRows(runs: readonly RunRecord[], arm: string): RunRecordArmRow[] {\n return runs.map((run) => {\n const scenarioId = run.scenarioId.trim()\n if (!scenarioId) {\n throw new ValidationError(\n `pairRunRecords: run '${run.runId}' is missing scenarioId; paired comparisons require explicit scenario identity`,\n )\n }\n return {\n pairKey: JSON.stringify([run.experimentId, scenarioId]),\n repKey: String(run.seed),\n arm,\n run,\n }\n })\n}\n\nfunction validateRunRecordArmRows(rows: readonly RunRecordArmRow[], arm: string): void {\n const byPairKey = new Map<string, RunRecordArmRow[]>()\n for (const row of rows) {\n const group = byPairKey.get(row.pairKey) ?? []\n group.push(row)\n byPairKey.set(row.pairKey, group)\n }\n for (const [pairKey, group] of byPairKey) {\n if (group.length > 1) indexByRepKey(group, pairKey, arm)\n }\n}\n\nfunction metricValue(row: PairedArmRow, name: string): number | undefined {\n const v = row.metrics?.[name]\n if (v === undefined) return undefined\n if (!Number.isFinite(v)) {\n throw new ValidationError(\n `comparePairedArms: non-finite value for metric '${name}' on pairKey '${row.pairKey}' (arm '${row.arm}'): ${v}`,\n )\n }\n return v\n}\n"],"mappings":";;;;;;;;;;;;AAOA,SAAgB,UAAU,GAAmB;CAC3C,IAAI,MAAM,GAAG,OAAO;CAEpB,MAAM,KAAK;CACX,MAAM,KAAK;CACX,MAAM,KAAK;CACX,MAAM,KAAK;CACX,MAAM,KAAK;CACX,MAAM,IAAI;CAEV,MAAM,SAAS,KAAK,IAAI,CAAC,IAAI,KAAK;CAClC,MAAM,IAAI,KAAK,IAAI,IAAI;CACvB,MAAM,iBAAiB,KAAK,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,CAAC,SAAS,MAAM;CAEjG,OAAO,IAAI,IAAI,aAAa,IAAI,IAAI,aAAa;AACnD;;;;AC8BA,MAAM,gCAAgC;;AAEtC,MAAM,8BAA8B;;AAEpC,MAAM,uBAAuB;;AAE7B,MAAM,uBAAuB;;;;;;;;;;;;;AA2B7B,SAAgB,aACd,GACA,GACA,OAAwB,CAAC,GACN;CACnB,mBAAmB,gBAAgB,KAAK,CAAC;CACzC,mBAAmB,gBAAgB,KAAK,CAAC;CAEzC,MAAM,KAAK,EAAE;CACb,MAAM,KAAK,EAAE;CACb,IAAI,OAAO,KAAK,OAAO,GAAG,OAAO;EAAE,GAAG;EAAG,IAAI;EAAG,GAAG;EAAG,QAAQ;EAAS,QAAQ;CAAE;CAEjF,MAAM,QAAQ,KAAK;CACnB,MAAM,WAAW,CACf,GAAG,EAAE,KAAK,OAAO;EAAE;EAAG,OAAO;CAAK,EAAE,GACpC,GAAG,EAAE,KAAK,OAAO;EAAE;EAAG,OAAO;CAAM,EAAE,CACvC,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;CAE1B,MAAM,EAAE,UAAU,YAAY,oBAAoB,SAAS,KAAK,UAAU,MAAM,CAAC,CAAC;CAClF,IAAI,WAAW;CAC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