@tangle-network/agent-eval 0.133.2 → 0.133.3

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 (103) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/dist/{analyze-runs-BmX-h_yn.d.ts → analyze-runs-BClW9OSe.d.ts} +3 -3
  3. package/dist/{analyze-runs-BmX-h_yn.d.ts.map → analyze-runs-BClW9OSe.d.ts.map} +1 -1
  4. package/dist/{analyze-runs-B-afTpCv.js → analyze-runs-qk8op0tN.js} +63 -42
  5. package/dist/analyze-runs-qk8op0tN.js.map +1 -0
  6. package/dist/baseline-BaPxoROc.js +149 -0
  7. package/dist/baseline-BaPxoROc.js.map +1 -0
  8. package/dist/{baseline-hG3K85h4.d.ts → baseline-D_fT6277.d.ts} +43 -11
  9. package/dist/baseline-D_fT6277.d.ts.map +1 -0
  10. package/dist/benchmarks/index.d.ts +1 -1
  11. package/dist/benchmarks/index.js +1 -1
  12. package/dist/{benchmarks-CJr1H1_a.js → benchmarks-BP9sgMia.js} +3 -3
  13. package/dist/{benchmarks-CJr1H1_a.js.map → benchmarks-BP9sgMia.js.map} +1 -1
  14. package/dist/builder-eval/index.js +1 -1
  15. package/dist/campaign/index.d.ts +2 -2
  16. package/dist/campaign/index.js +2 -2
  17. package/dist/{campaign-BJjn1rhw.js → campaign--V4ffEKR.js} +12 -6
  18. package/dist/{campaign-BJjn1rhw.js.map → campaign--V4ffEKR.js.map} +1 -1
  19. package/dist/{client-COvaLoQG.d.ts → client-Du7B81wW.d.ts} +28 -14
  20. package/dist/client-Du7B81wW.d.ts.map +1 -0
  21. package/dist/{client-CYzbdJOZ.js → client-LIuo-KPv.js} +19 -7
  22. package/dist/client-LIuo-KPv.js.map +1 -0
  23. package/dist/contract/index.d.ts +3 -3
  24. package/dist/contract/index.d.ts.map +1 -1
  25. package/dist/contract/index.js +9 -8
  26. package/dist/contract/index.js.map +1 -1
  27. package/dist/{eval-campaign-DXhpZghy.js → eval-campaign-CvPcvqXC.js} +2 -2
  28. package/dist/{eval-campaign-DXhpZghy.js.map → eval-campaign-CvPcvqXC.js.map} +1 -1
  29. package/dist/hosted/index.d.ts +1 -1
  30. package/dist/hosted/index.d.ts.map +1 -1
  31. package/dist/hosted/index.js +1 -1
  32. package/dist/{index-BREtv3ZZ.d.ts → index-B5MNN1f1.d.ts} +3 -3
  33. package/dist/{index-BREtv3ZZ.d.ts.map → index-B5MNN1f1.d.ts.map} +1 -1
  34. package/dist/{index-C7Wue8R6.d.ts → index-DOqvIJ8I.d.ts} +27 -10
  35. package/dist/index-DOqvIJ8I.d.ts.map +1 -0
  36. package/dist/{index-DSC51roc.d.ts → index-DSC51roc2.d.ts} +1 -1
  37. package/dist/index-DSC51roc2.d.ts.map +1 -0
  38. package/dist/{index-nhIYz9hn.d.ts → index-DuhJaaiH.d.ts} +68 -7
  39. package/dist/index-DuhJaaiH.d.ts.map +1 -0
  40. package/dist/index.d.ts +56 -10
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +29 -20
  43. package/dist/index.js.map +1 -1
  44. package/dist/ledger-core/index.d.ts +2 -2
  45. package/dist/ledger-core/index.js +2 -2
  46. package/dist/{ledger-core-CPZfcrC2.js → ledger-core-DAKFKRzi.js} +136 -18
  47. package/dist/ledger-core-DAKFKRzi.js.map +1 -0
  48. package/dist/matrix/index.d.ts +1 -1
  49. package/dist/meta-eval/index.d.ts +1 -1
  50. package/dist/meta-eval/index.js +2 -2
  51. package/dist/multishot/index.d.ts +1 -1
  52. package/dist/openapi.json +1 -1
  53. package/dist/{paired-arms-6XItKzd1.js → paired-arms-CA_8pN01.js} +2 -2
  54. package/dist/{paired-arms-6XItKzd1.js.map → paired-arms-CA_8pN01.js.map} +1 -1
  55. package/dist/pipelines/index.d.ts +1 -1
  56. package/dist/pipelines/index.js +3 -2
  57. package/dist/pipelines/index.js.map +1 -1
  58. package/dist/{release-report-wuilQkvK.js → release-report-BVZBmRZp.js} +2 -2
  59. package/dist/{release-report-wuilQkvK.js.map → release-report-BVZBmRZp.js.map} +1 -1
  60. package/dist/{release-report-CjHWa8Ia.d.ts → release-report-DKBtegGt.d.ts} +2 -2
  61. package/dist/{release-report-CjHWa8Ia.d.ts.map → release-report-DKBtegGt.d.ts.map} +1 -1
  62. package/dist/reporting.d.ts +3 -3
  63. package/dist/reporting.js +4 -4
  64. package/dist/{researcher-CbSKhK8z.d.ts → researcher-BtD5U1Up.d.ts} +2 -2
  65. package/dist/{researcher-CbSKhK8z.d.ts.map → researcher-BtD5U1Up.d.ts.map} +1 -1
  66. package/dist/{reward-hacking-Dl2UBzej.js → reward-hacking-DCdRK9TY.js} +2 -2
  67. package/dist/{reward-hacking-Dl2UBzej.js.map → reward-hacking-DCdRK9TY.js.map} +1 -1
  68. package/dist/rl.d.ts +1 -1
  69. package/dist/rl.js +4 -4
  70. package/dist/{rubric-predictive-validity-QG7ydk0s.js → rubric-predictive-validity-D6Q6n9oq.js} +2 -2
  71. package/dist/{rubric-predictive-validity-QG7ydk0s.js.map → rubric-predictive-validity-D6Q6n9oq.js.map} +1 -1
  72. package/dist/{skillopt-optimization-method-wHF5xsUv.d.ts → skillopt-optimization-method-Dxr8pdZd.d.ts} +12 -7
  73. package/dist/{skillopt-optimization-method-wHF5xsUv.d.ts.map → skillopt-optimization-method-Dxr8pdZd.d.ts.map} +1 -1
  74. package/dist/{skillopt-optimization-method-CF6a327Q.js → skillopt-optimization-method-vvJ4bMNI.js} +119 -24
  75. package/dist/skillopt-optimization-method-vvJ4bMNI.js.map +1 -0
  76. package/dist/{statistics-DbvkkDPa.d.ts → statistics-D_4Snl-5.d.ts} +158 -30
  77. package/dist/statistics-D_4Snl-5.d.ts.map +1 -0
  78. package/dist/{statistics-DWM_AyLe.js → statistics-RwRNu2__.js} +546 -98
  79. package/dist/statistics-RwRNu2__.js.map +1 -0
  80. package/dist/{summary-report-Ci17nIdU.js → summary-report-BxtossFi.js} +3 -3
  81. package/dist/{summary-report-Ci17nIdU.js.map → summary-report-BxtossFi.js.map} +1 -1
  82. package/dist/{summary-report-CFnQgNfg.d.ts → summary-report-DyOhItws.d.ts} +3 -2
  83. package/dist/summary-report-DyOhItws.d.ts.map +1 -0
  84. package/dist/{baseline-DcX5hQDv.js → tool-use-metrics-DEGMKycK.js} +2 -114
  85. package/dist/tool-use-metrics-DEGMKycK.js.map +1 -0
  86. package/docs/design/statistics-decisions.md +271 -0
  87. package/docs/design.md +1 -0
  88. package/docs/insight-report.md +1 -1
  89. package/docs/research-report-methodology.md +4 -1
  90. package/package.json +2 -1
  91. package/dist/analyze-runs-B-afTpCv.js.map +0 -1
  92. package/dist/baseline-DcX5hQDv.js.map +0 -1
  93. package/dist/baseline-hG3K85h4.d.ts.map +0 -1
  94. package/dist/client-COvaLoQG.d.ts.map +0 -1
  95. package/dist/client-CYzbdJOZ.js.map +0 -1
  96. package/dist/index-C7Wue8R6.d.ts.map +0 -1
  97. package/dist/index-DSC51roc.d.ts.map +0 -1
  98. package/dist/index-nhIYz9hn.d.ts.map +0 -1
  99. package/dist/ledger-core-CPZfcrC2.js.map +0 -1
  100. package/dist/skillopt-optimization-method-CF6a327Q.js.map +0 -1
  101. package/dist/statistics-DWM_AyLe.js.map +0 -1
  102. package/dist/statistics-DbvkkDPa.d.ts.map +0 -1
  103. package/dist/summary-report-CFnQgNfg.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,162 @@ All notable changes to `@tangle-network/agent-eval` and its sibling `agent-eval-
4
4
 
5
5
  ---
6
6
 
7
+ ## [0.133.3] - 2026-07-27 - trustworthy statistical decisions
8
+
9
+ ### Consumer notice — reported p-values were too small in every release from 0.1.0 to 0.133.0
10
+
11
+ 0.133.1 corrected the standard-normal CDF. This release carries the rest, and
12
+ restates the notice because the re-check bands and the affected version range are
13
+ what a consumer actually needs.
14
+
15
+ A standard-normal CDF mixed the arguments of the Abramowitz–Stegun error-function
16
+ approximation, giving up to `3.7189e-2` absolute CDF error where a correct
17
+ implementation is bounded by `7.5e-8`. Every p-value routed through it was too
18
+ small by 26–36 % relative, so the module's real type-I error rate was **6.53 % at
19
+ a nominal 5 %** and **1.34 % at a nominal 1 %**. The defect entered at the initial
20
+ commit (`7d5032b`, 2026-04-20) and shipped in every release through 0.133.0.
21
+
22
+ **Affected:** `mannWhitneyU`, `wilcoxonSignedRank`, `pairedTTest`, `welchsTTest`,
23
+ `compareToBaseline`, `mcnemarPower`.
24
+
25
+ **Unaffected** (verified numerically identical before and after, because they route
26
+ through the inverse normal rather than the forward CDF): `requiredSampleSize`,
27
+ `requiredPairedSampleSize`, `pairedMde`, `mcnemarRequiredN`, `mcnemar`,
28
+ `pairedSignTest`, `wilson`, `passAtK`, `corpusInterRaterAgreement`, `eProcess`,
29
+ `holm`, `ranks`, `pearsonR`, `spearmanR`, `cliffsDelta`, `pairedCohensDz`.
30
+
31
+ **How to re-check a decision you already made.** The error is monotone in `|z|`, so
32
+ the affected band is exact and narrow:
33
+
34
+ - Any recorded p in `[0.038053, 0.050000)` crossed a 5 % gate it should not have.
35
+ - At `α = 0.01` the band is `[0.007443, 0.010000)`; at `α = 0.10`, `[0.077398, 0.100000)`.
36
+ - A recorded p below `0.038053` was significant either way; at or above `0.05`, not
37
+ significant either way. Neither needs re-checking.
38
+
39
+ Three further cautions, independent of the CDF:
40
+
41
+ - A `wilcoxonSignedRank` leg that reported `p = 1` on fewer than six non-zero
42
+ differences measured nothing — the function hard-returned `p = 1` there with no
43
+ flag. A clean 5-of-5 shift reported `1.0` where the exact answer is `0.0625`.
44
+ Exact ties are dropped before ranking, so ten pairs with five tied deltas also
45
+ fell into that branch. Re-run those on this release.
46
+ - A promotion that turned on a `pairedBootstrap` `low > 0` check below 20 pairs was
47
+ never valid at the stated confidence: measured false-positive rate is 13.53 % at
48
+ `n = 3` against a nominal 2.5 %. `gateEligible` now reports this.
49
+ - A bootstrap interval recorded through `analyze-runs.ts` at or before 0.133.0 is
50
+ not reproducible — that call site passed no seed and `makeRng` fell back to
51
+ `Math.random`.
52
+
53
+ Full evidence, per-statistic verdicts, and the dependency argument:
54
+ [`docs/design/statistics-decisions.md`](./docs/design/statistics-decisions.md).
55
+
56
+ ### Fixed
57
+
58
+ - `regularizedIncompleteBeta` takes the mandatory symmetry branch `I_x(a,b) = 1 − I_{1−x}(b,a)`.
59
+ `studentTCdf(0.005, 100)` returned `0.89152130` against a true `0.50198972`; a
60
+ perfectly null paired result reported `p < 0.05`. This survived 0.133.1, which
61
+ corrected the normal CDF but not the beta continued fraction beneath it, and
62
+ 0.133.2, which changed no statistics math.
63
+ - `mannWhitneyU` and `wilcoxonSignedRank` compute an EXACT conditional p by default
64
+ inside the enumeration thresholds, conditioning on the observed tie pattern.
65
+ - `mannWhitneyU` chooses exact computation from bounded state and work estimates,
66
+ so imbalanced designs such as 1 v 24 remain exact without admitting expensive
67
+ balanced designs. Its automatic permutation seed is invariant to observation
68
+ order and to swapping the two groups.
69
+ - Deleted `wilcoxonSignedRank`'s `n < 6` hard return of `{w: 0, p: 1}`.
70
+ - The asymptotic rank-test path applies the tie correction and the continuity
71
+ correction; both were missing.
72
+ - `mannWhitneyU` and `wilcoxonSignedRank` reject non-finite input. A single `NaN`
73
+ previously spun forever: the tie-grouping loop advanced on `===`, and
74
+ `NaN === NaN` is false.
75
+ - `bonferroni` and `benjaminiHochberg` reject at the inclusive boundary (`p ≤ α`,
76
+ `q ≤ fdr`), matching `holm`, and validate `alpha`/`fdr` and the p-value range.
77
+ `bonferroni([0.0125]×4, 0.05)` returned all-false where `holm` returned all-true.
78
+ BH q-values use R's `(n/rank)·p` form; `(p·n)/rank` lands one ULP above the
79
+ boundary at `p = 0.05, n = 3`.
80
+ - `interRaterReliability` groups by (dimension, item) across judges. It was
81
+ bucketing consecutive scores from the SAME judge, so it measured within-judge
82
+ spread: two identical judges returned `−0.5` where the true α is `+1.0`.
83
+ - `mulberry32(0)` is its own stream. `seed | 0 || 0x9e3779b9` collapsed seed 0 onto
84
+ the golden-ratio constant, so two runs a caller believed were independent
85
+ replicates were the same run. Non-finite seeds now throw.
86
+ - Unseeded bootstraps derive their seed from the data instead of `Math.random`, so
87
+ an interval is reproducible whether or not the caller passes a seed.
88
+ - `studentTCdf` uses the regularized incomplete beta for every finite degree of
89
+ freedom. The deleted normal shortcut changed `df = 102, t = 1.98` from the true
90
+ two-sided `p = 0.050398` to `0.047703`.
91
+ - At the default 95% confidence, campaign promotion decisions use an exact
92
+ one-sided sign test from 6 through 19 paired observations and the bootstrap
93
+ interval from 20 onward. Samples too small to attain the requested confidence
94
+ remain inconclusive.
95
+ - Prior-period reports use the shared Welch implementation. Zero-variance and
96
+ under-sized comparisons carry an explicit status and null inferential fields
97
+ instead of fabricated `p = 1`, `d = 0`, and a zero-width interval.
98
+
99
+ ### Changed — BREAKING
100
+
101
+ - `mannWhitneyU(a, b, opts?)` returns `{ u, uA, p, method, pFloor }`. `p` is now the
102
+ exact conditional p inside the threshold: `mannWhitneyU([1,2,3],[4,5,6]).p` moves
103
+ from `0.03769147` to `0.10000000`, which is the smallest p attainable at 3 v 3.
104
+ `uA` carries the direction that `u = min(u₁,u₂)` discards.
105
+ - `wilcoxonSignedRank(before, after, opts?)` returns
106
+ `{ w, p, method, pFloor, nNonZero }`.
107
+ - Both take `method: 'auto' | 'exact' | 'asymptotic'`, default `'auto'`. `'auto'`
108
+ never selects `'asymptotic'`. Requesting `'asymptotic'` where an exact answer
109
+ exists THROWS a `ValidationError` naming the attainable floor, and requesting
110
+ `'exact'` above the threshold throws rather than enumerating an unbounded
111
+ distribution.
112
+ - `pairedTTest` returns `{ t: number | null, df, p: number | null }`. A non-zero
113
+ constant delta returned `{t: Infinity, p: 0}` — absolute certainty from three
114
+ observations — and now returns null, matching `pairedCohensDz`. An all-zero delta
115
+ is still `{t: 0, p: 1}`.
116
+ - `cohensD` returns `number | null`. It returned a silent `0` for a maximal
117
+ zero-variance separation and for under-sized groups.
118
+ - `MetricVerdict.cohensD` and `LiftInsight.pValue` are nullable accordingly.
119
+ - `PairedBootstrapResult` carries `gateEligible`, false below
120
+ `BOOTSTRAP_GATE_MIN_N = 20`.
121
+ - `welchsTTest` returns a status-tagged full result with means, delta, standard
122
+ error, degrees of freedom, Student-t interval, p-value, and Cohen's d.
123
+ - Prior-period `MetricDelta` values carry the same status. Invalid inference has
124
+ null `ci95`, `pValue`, and `cohensD`, and the comparison lists those metric
125
+ names in `inconclusiveMetrics`.
126
+
127
+ ### Added
128
+
129
+ - `scripts/generate-statistics-oracle.py` + `tests/fixtures/statistics-oracle.json`:
130
+ 154 scipy/statsmodels-generated golden values across 22 statistics, asserted by
131
+ `tests/statistics-oracle.test.ts`. scipy is a CI oracle and is never a runtime
132
+ dependency.
133
+ - `tests/statistics-library-crosscheck.test.ts` cross-checks untied exact null
134
+ distributions against `lib-r-math.js`. Multiple-comparison functions are pinned
135
+ to statsmodels-generated fixture values; `@stdlib/stats-padjust` was removed.
136
+ - First test coverage for `welchsTTest` / `compareToBaseline`, which gated
137
+ improved / regressed / stable verdicts with nothing asserting their numbers.
138
+ - Exported `normalCdf`, `studentTCdf`, `BOOTSTRAP_GATE_MIN_N`,
139
+ `MANN_WHITNEY_EXACT_MAX_STATES`, `MANN_WHITNEY_EXACT_MAX_WORK`,
140
+ `WILCOXON_EXACT_MAX_N`, `DEFAULT_PERMUTATIONS`, and `pairedDeltaTest`.
141
+
142
+ ### Trusted-head recovery
143
+
144
+ #### Fixed
145
+
146
+ - A trusted-head pin write that fails after its journal row is already durable no longer leaves that row permanently unpinned.
147
+ Retrying the same `eventId` moves the pin up to the acknowledged entry when the entry is ahead of the pin, so the last row of a ledger — the promotion decision — cannot be truncated away undetected after a full disk or a read-only mount.
148
+ - A pin whose journal was deleted or rebuilt is recoverable instead of refusing every later append and replay forever.
149
+ The refusal still stands, since a missing journal beside a live pin is the deletion the pin exists to catch, but it now names the sidecar file and the operation that resolves it.
150
+ - Trusted-head read and write faults are reported through the journal codec's error taxonomy instead of escaping as raw Node filesystem errors.
151
+
152
+ #### Added
153
+
154
+ - `clearTrustedHeadFile`, exposed as `FileLedgerJournal.clearTrustedHead()` and `SearchLedger.clearTrustedHead()`, discards a pin and returns the guarantee it gave up.
155
+ - `SearchLedger.pinTrustedHead()`, the campaign-level route to adopting a pin for a ledger that has none.
156
+ - `readTrustedHeadFile` is exported from `@tangle-network/agent-eval/ledger-core`, so a consumer of `verifyEntriesAgainstTrustedHead` has a shape-validating way to load a pin.
157
+
158
+ #### Changed
159
+
160
+ - **Breaking:** `verifyEntriesAgainstTrustedHead` takes `{ subject, trustedHeadPath }` as its fourth argument instead of a bare `subject` string, so every refusal can name the sidecar file. Passing the old string throws a `TypeError`.
161
+ - **Breaking:** `SearchLedger` declares `pinTrustedHead` and `clearTrustedHead`; an external implementation of the interface must supply them.
162
+
7
163
  ## [0.133.2] - 2026-07-27 - protect final evaluation data
8
164
 
9
165
  ### Fixed
@@ -1,8 +1,8 @@
1
1
  import { a as RunRecord } from "./run-record-DcObtIGh.js";
2
2
  import { i as AnalystRegistry } from "./default-registry-Cl3pHo4n.js";
3
3
  import { a as DatasetScenario } from "./dataset-BvtnC8Dc.js";
4
- import "./summary-report-CFnQgNfg.js";
5
- import { C as InsightReport, b as ExecutionInsight, v as CostProvenanceSummary } from "./client-COvaLoQG.js";
4
+ import "./summary-report-DyOhItws.js";
5
+ import { C as InsightReport, b as ExecutionInsight, v as CostProvenanceSummary } from "./client-Du7B81wW.js";
6
6
  //#region src/contract/analyze-runs.d.ts
7
7
  interface AnalyzeRunsOptions {
8
8
  /** The runs to analyze. */
@@ -69,4 +69,4 @@ declare function summarizeExecution(opts: SummarizeExecutionOptions): ExecutionR
69
69
  declare function analyzeRuns(opts: AnalyzeRunsOptions): Promise<InsightReport>;
70
70
  //#endregion
71
71
  export { summarizeExecution as a, analyzeRuns as i, ExecutionReport as n, SummarizeExecutionOptions as r, AnalyzeRunsOptions as t };
72
- //# sourceMappingURL=analyze-runs-BmX-h_yn.d.ts.map
72
+ //# sourceMappingURL=analyze-runs-BClW9OSe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analyze-runs-BmX-h_yn.d.ts","names":[],"sources":["../src/contract/analyze-runs.ts"],"mappings":";;;;;;UAmEiB;;EAEf,MAAM;;;EAGN;;;;;EAKA;EACA;;;EAGA,kBAAkB;;;EAGlB,UAAU;;;;EAIV;IACE;IACA,cAAc;;;;;EAKhB,cAAc;IAAQ;IAAe;IAAe;;;EAEpD;;;;EAIA;;;;;;;;;EASA,eAAe;;;EAGf;;UAGe;EACf,MAAM;EACN;;UAGe;EACf,WAAW;EACX,gBAAgB;;;iBAIF,mBAAmB,MAAM,4BAA4B;iBAS/C,YAAY,MAAM,qBAAqB,QAAQ"}
1
+ {"version":3,"file":"analyze-runs-BClW9OSe.d.ts","names":[],"sources":["../src/contract/analyze-runs.ts"],"mappings":";;;;;;UAoEiB;;EAEf,MAAM;;;EAGN;;;;;EAKA;EACA;;;EAGA,kBAAkB;;;EAGlB,UAAU;;;;EAIV;IACE;IACA,cAAc;;;;;EAKhB,cAAc;IAAQ;IAAe;IAAe;;;EAEpD;;;;EAIA;;;;;;;;;EASA,eAAe;;;EAGf;;UAGe;EACf,MAAM;EACN;;UAGe;EACf,WAAW;EACX,gBAAgB;;;iBAIF,mBAAmB,MAAM,4BAA4B;iBAS/C,YAAY,MAAM,qBAAqB,QAAQ"}
@@ -1,9 +1,10 @@
1
- import { A as spearmanR, C as pairedTTest, E as pearsonR, I as normalCdf, O as requiredPairedSampleSize, b as pairedMde, v as pairedBootstrap, y as pairedCohensDz, z as continuousAgreement } from "./statistics-DWM_AyLe.js";
2
- import { r as pairRunRecords } from "./paired-arms-6XItKzd1.js";
1
+ import { C as pairedBootstrap, F as spearmanR, G as continuousAgreement, N as requiredPairedSampleSize, O as pairedTTest, T as pairedMde, j as pearsonR, w as pairedCohensDz } from "./statistics-RwRNu2__.js";
2
+ import { r as pairRunRecords } from "./paired-arms-CA_8pN01.js";
3
3
  import { r as observedSplitScore } from "./reward-nw2xZGZG.js";
4
4
  import { s as validateRunRecord } from "./run-record-BIwU2wdV.js";
5
+ import { r as welchsTTest } from "./baseline-BaPxoROc.js";
5
6
  import { o as llmSpans } from "./query-Di7eEQ79.js";
6
- import { r as paretoChart } from "./summary-report-Ci17nIdU.js";
7
+ import { r as paretoChart } from "./summary-report-BxtossFi.js";
7
8
  //#region src/contamination-guard.ts
8
9
  function checkCanaries(output, scenarios) {
9
10
  const leaks = [];
@@ -469,7 +470,12 @@ function computePriorPeriodComparison(current, baseline, split, windowLabel) {
469
470
  }
470
471
  const regressedMetrics = [];
471
472
  const improvedMetrics = [];
473
+ const inconclusiveMetrics = [];
472
474
  for (const [name, delta] of Object.entries(metrics)) {
475
+ if (delta.status !== "ok") {
476
+ inconclusiveMetrics.push(name);
477
+ continue;
478
+ }
473
479
  if (!delta.significant) continue;
474
480
  if ((directions[name] ?? "higher-is-better") === "higher-is-better" ? delta.delta > 0 : delta.delta < 0) improvedMetrics.push(name);
475
481
  else regressedMetrics.push(name);
@@ -480,7 +486,8 @@ function computePriorPeriodComparison(current, baseline, split, windowLabel) {
480
486
  ...windowLabel ? { windowLabel } : {},
481
487
  metrics,
482
488
  regressedMetrics,
483
- improvedMetrics
489
+ improvedMetrics,
490
+ inconclusiveMetrics
484
491
  };
485
492
  }
486
493
  function knownCostValues(runs) {
@@ -503,41 +510,33 @@ function collectPerDimension(runs) {
503
510
  }
504
511
  return out;
505
512
  }
506
- /** Two-sample Welch comparison: unequal-variance t-test + CI on the delta
507
- * + Cohen's d (pooled stddev). Significance = p < 0.05 AND |d| >= 0.2. */
513
+ /** Adapt the shared two-sample Welch result to the report contract. */
508
514
  function welchCompare(baseline, current) {
509
- const baselineMean = mean(baseline);
510
- const currentMean = mean(current);
511
- const baselineVar = sampleVariance(baseline, baselineMean);
512
- const currentVar = sampleVariance(current, currentMean);
513
- const baselineN = baseline.length;
514
- const currentN = current.length;
515
- const delta = currentMean - baselineMean;
516
- const se = Math.sqrt(baselineVar / baselineN + currentVar / currentN);
517
- const halfWidth = 1.96 * (se > 0 ? se : 0);
518
- const ci95 = [delta - halfWidth, delta + halfWidth];
519
- const t = se > 0 ? delta / se : 0;
520
- const pValue = se > 0 ? 2 * (1 - normalCdf(Math.abs(t))) : 1;
521
- const pooledStddev = Math.sqrt(((baselineN - 1) * baselineVar + (currentN - 1) * currentVar) / Math.max(1, baselineN + currentN - 2));
522
- const cohensD = pooledStddev > 0 ? delta / pooledStddev : 0;
515
+ const result = welchsTTest(baseline, current);
516
+ const base = {
517
+ current: result.meanB,
518
+ baseline: result.meanA,
519
+ delta: result.delta,
520
+ baselineN: baseline.length,
521
+ currentN: current.length
522
+ };
523
+ if (result.status !== "ok") return {
524
+ ...base,
525
+ status: result.status,
526
+ ci95: null,
527
+ pValue: null,
528
+ cohensD: null,
529
+ significant: false
530
+ };
523
531
  return {
524
- current: currentMean,
525
- baseline: baselineMean,
526
- delta,
527
- ci95,
528
- pValue,
529
- cohensD,
530
- baselineN,
531
- currentN,
532
- significant: pValue < .05 && Math.abs(cohensD) >= .2
532
+ ...base,
533
+ status: "ok",
534
+ ci95: result.ci95,
535
+ pValue: result.p,
536
+ cohensD: result.cohensD,
537
+ significant: result.p < .05 && Math.abs(result.cohensD) >= .2
533
538
  };
534
539
  }
535
- function sampleVariance(xs, xsMean) {
536
- if (xs.length < 2) return 0;
537
- let s = 0;
538
- for (const x of xs) s += (x - xsMean) ** 2;
539
- return s / (xs.length - 1);
540
- }
541
540
  function resolveSplit(runs, pref) {
542
541
  if (pref !== "auto") return pref;
543
542
  return runs.some((r) => Number.isFinite(observedSplitScore(r, "holdout"))) ? "holdout" : "search";
@@ -769,6 +768,8 @@ function computeLift(runs, baselineId, candidateId, split) {
769
768
  ci95: [bootstrap.low, bootstrap.high],
770
769
  pValue: tTest.p,
771
770
  n: pairedBaseline.length,
771
+ minimumRequired: 20,
772
+ decisionEligible: bootstrap.gateEligible,
772
773
  unpairedBaseline: pairing.unpairedBaseline.length,
773
774
  unpairedCandidate: pairing.unpairedTreatment.length,
774
775
  cohensD: d,
@@ -893,11 +894,11 @@ function computeOutcomeCorrelation(runs, outcome, split) {
893
894
  }
894
895
  function buildReleaseScorecard(composite, lift, contamination) {
895
896
  const axes = [];
896
- const liftPass = lift === void 0 ? "not_evaluated" : lift.ci95[0] > 0 ? "pass" : lift.delta > 0 ? "warn" : "fail";
897
+ const liftPass = lift === void 0 ? "not_evaluated" : !lift.decisionEligible ? "not_evaluated" : lift.ci95[0] > 0 ? "pass" : lift.delta > 0 ? "warn" : "fail";
897
898
  axes.push({
898
899
  name: "quality-lift",
899
900
  status: liftPass,
900
- detail: lift ? `delta=${lift.delta.toFixed(3)}, CI95=[${lift.ci95[0].toFixed(3)}, ${lift.ci95[1].toFixed(3)}], n=${lift.n}` : "no baseline/candidate pair available"
901
+ detail: lift ? `delta=${lift.delta.toFixed(3)}, CI95=[${lift.ci95[0].toFixed(3)}, ${lift.ci95[1].toFixed(3)}], n=${lift.n}${lift.decisionEligible ? "" : ` (descriptive only; ${lift.minimumRequired} required)`}` : "no baseline/candidate pair available"
901
902
  });
902
903
  const contamPass = contamination === void 0 ? "not_evaluated" : contamination.leaks === 0 ? "pass" : "fail";
903
904
  axes.push({
@@ -927,7 +928,7 @@ function buildRecommendations(ctx) {
927
928
  const label = ppc.windowLabel ?? "baseline period";
928
929
  for (const name of ppc.regressedMetrics) {
929
930
  const d = ppc.metrics[name];
930
- if (!d) continue;
931
+ if (d?.status !== "ok") continue;
931
932
  out.push({
932
933
  priority: "critical",
933
934
  kind: "investigate",
@@ -938,7 +939,7 @@ function buildRecommendations(ctx) {
938
939
  }
939
940
  for (const name of ppc.improvedMetrics) {
940
941
  const d = ppc.metrics[name];
941
- if (!d) continue;
942
+ if (d?.status !== "ok") continue;
942
943
  out.push({
943
944
  priority: "low",
944
945
  kind: "ship",
@@ -947,6 +948,18 @@ function buildRecommendations(ctx) {
947
948
  evidencePath: `priorPeriodComparison.metrics.${name}`
948
949
  });
949
950
  }
951
+ for (const name of ppc.inconclusiveMetrics) {
952
+ const d = ppc.metrics[name];
953
+ if (!d || d.status === "ok" || d.delta === 0) continue;
954
+ const reason = d.status === "zero-variance" ? "both periods have zero observed variance" : "one or both periods have fewer than two observations";
955
+ out.push({
956
+ priority: "high",
957
+ kind: "investigate",
958
+ title: `${name} changed from ${d.baseline.toFixed(3)} → ${d.current.toFixed(3)} vs ${label}; inference unavailable`,
959
+ detail: `Observed delta ${d.delta.toFixed(3)} across n_current=${d.currentN} and n_baseline=${d.baselineN}, but ${reason}. The report does not fabricate a p-value, confidence interval, or effect size; inspect independence and data capture before acting.`,
960
+ evidencePath: `priorPeriodComparison.metrics.${name}`
961
+ });
962
+ }
950
963
  }
951
964
  if (ctx.composite.n > 0 && ctx.composite.mean !== null && ctx.composite.p50 !== null && ctx.composite.p95 !== null) {
952
965
  if (ctx.composite.mean < .3) {
@@ -988,8 +1001,16 @@ function buildRecommendations(ctx) {
988
1001
  detail: "Records have no `outcome.judgeScores`. To unlock perDimension, judges, and calibration, attach a Judge run during your eval pass and populate `outcome.judgeScores.perJudge[judgeName][dimension] = score`. See `docs/insight-report.md` for the expected shape.",
989
1002
  evidencePath: "judges"
990
1003
  });
991
- if (ctx.lift) {
1004
+ if (ctx.lift) if (!ctx.lift.decisionEligible) out.push({
1005
+ priority: "high",
1006
+ kind: "expand-corpus",
1007
+ title: `Inconclusive — ${ctx.lift.n} paired runs; ${ctx.lift.minimumRequired} required`,
1008
+ detail: `The bootstrap interval is descriptive below ${ctx.lift.minimumRequired} paired observations and cannot support a ship decision.`,
1009
+ evidencePath: "lift"
1010
+ });
1011
+ else {
992
1012
  const pairedEffect = ctx.lift.cohensD === null ? "undefined (zero delta variance)" : ctx.lift.cohensD.toFixed(2);
1013
+ const pairedP = ctx.lift.pValue === null ? "undefined (zero delta variance)" : ctx.lift.pValue.toFixed(4);
993
1014
  const requiredRuns = ctx.lift.requiredN === null ? "not estimable" : `~${ctx.lift.requiredN} paired runs`;
994
1015
  const decisive = ctx.lift.ci95[0] > ctx.threshold;
995
1016
  const inconclusive = ctx.lift.ci95[0] <= ctx.threshold && ctx.lift.ci95[1] > ctx.threshold;
@@ -997,7 +1018,7 @@ function buildRecommendations(ctx) {
997
1018
  priority: "critical",
998
1019
  kind: "ship",
999
1020
  title: `Ship — lift ${ctx.lift.delta.toFixed(3)} (95% CI ${ctx.lift.ci95[0].toFixed(3)}..${ctx.lift.ci95[1].toFixed(3)})`,
1000
- detail: `Holdout lift exceeds threshold ${ctx.threshold} with 95% bootstrap confidence (n=${ctx.lift.n}, p=${ctx.lift.pValue.toFixed(4)}, paired d=${pairedEffect}).`,
1021
+ detail: `Holdout lift exceeds threshold ${ctx.threshold} with 95% bootstrap confidence (n=${ctx.lift.n}, p=${pairedP}, paired d=${pairedEffect}).`,
1001
1022
  evidencePath: "lift"
1002
1023
  });
1003
1024
  else if (inconclusive) out.push({
@@ -1051,4 +1072,4 @@ function buildRecommendations(ctx) {
1051
1072
  //#endregion
1052
1073
  export { checkBehavioralCanary as a, canaryLeakView as i, summarizeExecution as n, checkCanaries as o, HoldoutAuditor as r, runBehavioralCanaries as s, analyzeRuns as t };
1053
1074
 
1054
- //# sourceMappingURL=analyze-runs-B-afTpCv.js.map
1075
+ //# sourceMappingURL=analyze-runs-qk8op0tN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze-runs-qk8op0tN.js","names":[],"sources":["../src/contamination-guard.ts","../src/contract/analyze-runs.ts"],"sourcesContent":["/**\n * ContaminationGuard — ensures held-out scenarios don't leak into\n * training/prompt paths, and flags model memorization.\n *\n * Three probes:\n * 1. `checkCanaries(output, scenario)` — if the scenario carries a\n * canary token, it MUST NOT appear in the agent's output.\n * Canaries are strings that are statistically impossible to\n * reconstruct from the scenario description alone — so if they\n * echo back, the model memorized them.\n * 2. `canaryLeakView(store)` — cross-corpus view of every run whose\n * output contained a canary, with the offending scenario + run.\n * 3. `HoldoutAuditor` — wraps a Dataset and emits a structured error\n * on any code path that reads holdout scenarios but doesn't flag\n * `purpose: 'evaluation'`. Keeps engineers honest.\n */\n\nimport type { DatasetScenario } from './dataset'\nimport { llmSpans } from './trace/query'\nimport type { TraceStore } from './trace/store'\n\nexport interface CanaryLeak {\n scenarioId: string\n canary: string\n runId?: string\n evidence: string\n}\n\nexport function checkCanaries(output: string, scenarios: DatasetScenario[]): CanaryLeak[] {\n const leaks: CanaryLeak[] = []\n for (const s of scenarios) {\n if (!s.canary) continue\n if (output.includes(s.canary)) {\n leaks.push({ scenarioId: s.id, canary: s.canary, evidence: excerpt(output, s.canary) })\n }\n }\n return leaks\n}\n\n/**\n * Behavioral canary: tests the AGENT, not the eval grep.\n *\n * - `forbiddenPattern` PRESENT in output ⇒ AGENT EMITTED BAD CONTENT ⇒ LEAK.\n * - `forbiddenPattern` ABSENT from output ⇒ AGENT HELD THE LINE ⇒ PASS.\n *\n * Use when running known-bad-prompt scenarios against the agent under\n * test and you want to know if the agent misbehaved. The classical\n * {@link checkCanaries} / {@link import('./canary').runCanaries | runCanaries}\n * test whether the eval check fires when the bad output is forced\n * into the eval flow — different question, different answer.\n *\n * Pattern resolution order (first match wins):\n * 1. `scenario.forbiddenPattern` — if it parses as `/body/flags`,\n * treated as a regex; otherwise a literal substring.\n * 2. `scenario.canary` — literal substring fallback so the helper\n * works on existing scenario fixtures.\n *\n * Returns `null` when nothing forbidden was found OR the scenario\n * declared no pattern.\n */\nexport function checkBehavioralCanary(\n output: string,\n scenario: DatasetScenario,\n): CanaryLeak | null {\n const pattern = scenario.forbiddenPattern ?? scenario.canary\n if (!pattern) return null\n const hit = matchForbidden(output, pattern)\n if (!hit) return null\n return {\n scenarioId: scenario.id,\n canary: pattern,\n evidence: excerpt(output, hit),\n }\n}\n\n/**\n * Behavioral canary over many (scenario, output) pairs. Sibling to\n * {@link import('./canary').runCanaries | runCanaries} — same idea\n * (run-many → report) but the question being answered is \"did the\n * AGENT misbehave?\" rather than \"did the EVAL grep fire?\".\n *\n * Returns one `CanaryLeak` per pair where the agent's output\n * contained its scenario's `forbiddenPattern` (or `canary` fallback).\n */\nexport function runBehavioralCanaries(\n cases: Array<{ scenario: DatasetScenario; output: string; runId?: string }>,\n): CanaryLeak[] {\n const leaks: CanaryLeak[] = []\n for (const c of cases) {\n const leak = checkBehavioralCanary(c.output, c.scenario)\n if (leak) leaks.push({ ...leak, runId: c.runId ?? leak.runId })\n }\n return leaks\n}\n\n/**\n * Resolve a forbidden-pattern string to the matched substring inside\n * `output`. `/body/flags` notation is interpreted as a regex; anything\n * else is a literal substring.\n */\nfunction matchForbidden(output: string, pattern: string): string | null {\n const re = tryParseRegex(pattern)\n if (re) {\n const m = output.match(re)\n return m && m[0].length > 0 ? m[0] : null\n }\n return output.includes(pattern) ? pattern : null\n}\n\nfunction tryParseRegex(pattern: string): RegExp | null {\n if (pattern.length < 2 || pattern[0] !== '/') return null\n const last = pattern.lastIndexOf('/')\n if (last <= 0) return null\n const body = pattern.slice(1, last)\n const flags = pattern.slice(last + 1)\n if (!/^[gimsuy]*$/.test(flags)) return null\n try {\n return new RegExp(body, flags)\n } catch {\n return null\n }\n}\n\n/**\n * Scan the LLM-output history in a corpus; returns every case where a\n * canary from a known scenario appeared in agent output. Pass the full\n * set of scenarios whose canaries you care about (typically the whole\n * held-out slice).\n */\nexport async function canaryLeakView(\n store: TraceStore,\n scenarios: DatasetScenario[],\n): Promise<CanaryLeak[]> {\n const targets = scenarios.filter((s) => !!s.canary)\n if (targets.length === 0) return []\n const spans = await llmSpans(store)\n const leaks: CanaryLeak[] = []\n for (const span of spans) {\n const output = span.output ?? ''\n for (const s of targets) {\n if (s.canary && output.includes(s.canary)) {\n leaks.push({\n scenarioId: s.id,\n canary: s.canary,\n runId: span.runId,\n evidence: excerpt(output, s.canary),\n })\n }\n }\n }\n return leaks\n}\n\nexport class HoldoutAuditor {\n private scenarios: DatasetScenario[]\n private accessLog: Array<{ scenarioId: string; purpose: string; at: number }> = []\n\n constructor(scenarios: DatasetScenario[]) {\n this.scenarios = scenarios\n }\n\n /** Retrieve a holdout scenario for a declared purpose. Non-'evaluation' throws. */\n get(scenarioId: string, purpose: 'evaluation' | 'debugging'): DatasetScenario {\n if (purpose !== 'evaluation' && purpose !== 'debugging') {\n throw new Error(\n `HoldoutAuditor.get: purpose must be 'evaluation' or 'debugging', got ${purpose}`,\n )\n }\n const s = this.scenarios.find((x) => x.id === scenarioId)\n if (!s) throw new Error(`holdout scenario \"${scenarioId}\" not found`)\n this.accessLog.push({ scenarioId, purpose, at: Date.now() })\n return s\n }\n\n getAccessLog(): ReadonlyArray<{ scenarioId: string; purpose: string; at: number }> {\n return this.accessLog\n }\n}\n\nfunction excerpt(source: string, needle: string): string {\n const at = source.indexOf(needle)\n if (at < 0) return ''\n const start = Math.max(0, at - 30)\n const end = Math.min(source.length, at + needle.length + 30)\n return (start > 0 ? '…' : '') + source.slice(start, end) + (end < source.length ? '…' : '')\n}\n","/**\n * # `analyzeRuns()` — turn a set of agent runs into an actionable decision packet.\n *\n * Wires the substrate's statistical, calibration, clustering, Pareto, and\n * release-confidence primitives into one `InsightReport`. Two top-level\n * entry points use this function:\n *\n * - `selfImprove()` calls it on the campaign output to attach a packet\n * to every run.\n * - Consumers with observed `RunRecord[]` (production traces, gold\n * corpora, approve/reject tables) call it directly via `analyzeRuns()`\n * for analysis without a closed loop.\n *\n * Every section is opt-in based on what the input data supports — the\n * function never invents signal. If runs carry no judge scores, `judges`\n * is empty. If there's no baseline/candidate split, `lift` is undefined.\n * If no `analyst` is wired, `failureClusters` is undefined.\n *\n * The `recommendations` array is the human-readable layer; everything\n * else is the evidence backing each recommendation.\n */\n\nimport type { AnalystRegistry } from '../analyst/registry'\nimport type { AnalystFinding } from '../analyst/types'\nimport { welchsTTest } from '../baseline'\nimport { checkCanaries } from '../contamination-guard'\nimport type { DatasetScenario } from '../dataset'\nimport { continuousAgreement } from '../judge-calibration'\nimport { pairRunRecords } from '../paired-arms'\nimport { observedSplitScore } from '../rollout/reward'\nimport {\n type RunRecord,\n type RunTerminalOutcome,\n type RunTokenUsage,\n validateRunRecord,\n} from '../run-record'\nimport {\n BOOTSTRAP_GATE_MIN_N,\n pairedBootstrap,\n pairedCohensDz,\n pairedMde,\n pairedTTest,\n pearsonR,\n requiredPairedSampleSize,\n spearmanR,\n} from '../statistics'\nimport { type ParetoFigureSpec, paretoChart } from '../summary-report'\nimport type { FailureClass } from '../trace/schema'\n\nimport type {\n CostProvenanceSummary,\n ExecutionInsight,\n FailureClassTally,\n FailureClusterInsight,\n InsightReport,\n InterRaterInsight,\n JudgeInsight,\n LiftInsight,\n MetricDelta,\n OutcomeCorrelationInsight,\n PriorPeriodComparison,\n Recommendation,\n ScalarDistribution,\n TokenUsageInsight,\n} from './insight-report'\n\n// ── Public API ───────────────────────────────────────────────────────\n\nexport interface AnalyzeRunsOptions {\n /** The runs to analyze. */\n runs: RunRecord[]\n /** Which split to score against when reading composite from RunOutcome.\n * Default: holdout when ANY run has a `holdoutScore`, else search. */\n split?: 'search' | 'holdout' | 'auto'\n /** Pairwise analysis configuration. When both `baselineCandidateId` and\n * `candidateCandidateId` are present, lift is computed on paired\n * (experimentId, scenarioId, seed) identities shared between the two sides.\n * Unmatched rows remain visible in the lift result. */\n baselineCandidateId?: string\n candidateCandidateId?: string\n /** Canary scenarios — checked against every run's raw output for\n * holdout contamination. */\n canaryScenarios?: DatasetScenario[]\n /** Analyst registry for failure clustering. When omitted, the\n * `failureClusters` section is left undefined. */\n analyst?: AnalystRegistry\n /** Downstream outcome metric per run (e.g. engagement rate, approval\n * rate, downstream pass rate). When present, the report includes\n * `outcomeCorrelation` + a simple linear reward model fit. */\n outcomeSignal?: {\n metric: string\n valueByRunId: Record<string, number>\n }\n /** Multi-rater feedback for inter-rater agreement. Each entry is one\n * rater's score for one run. Two or more raters → kappa + disagreement\n * triage list. */\n raterScores?: Array<{ runId: string; rater: string; score: number }>\n /** Number of histogram bins for distributional summaries. Default 12. */\n histogramBins?: number\n /** Decision threshold — the smallest composite lift the caller cares\n * about. Used by the recommendations engine to call ship vs hold.\n * Default 0.02. */\n decisionThreshold?: number\n /** Optional prior-period runs. When set, the report includes\n * `priorPeriodComparison` with per-metric Welch-CI deltas and\n * recommendations fire on statistically significant regressions.\n * The two windows do NOT have to share scenarios — the comparison\n * is two-sample unpaired (the substrate's `lift` field uses paired\n * bootstrap on shared (experimentId, scenarioId, seed) identities; this is the\n * shape for \"this week vs last week\" rather than \"candidate vs\n * baseline within a campaign\"). */\n baselineRuns?: RunRecord[]\n /** Human-readable label for the baseline window, e.g. \"vs prior 7\n * days\", \"vs v3.1 release\". Surfaces in recommendations + UI. */\n baselineLabel?: string\n}\n\nexport interface SummarizeExecutionOptions {\n runs: RunRecord[]\n histogramBins?: number\n}\n\nexport interface ExecutionReport {\n execution: ExecutionInsight\n costProvenance: CostProvenanceSummary\n}\n\n/** Summarize runtime facts without interpreting task quality or promotion readiness. */\nexport function summarizeExecution(opts: SummarizeExecutionOptions): ExecutionReport {\n const runs = opts.runs.map(validateRunRecord)\n const bins = opts.histogramBins ?? 12\n return {\n execution: computeExecutionInsight(runs, bins),\n costProvenance: summarizeCostProvenance(runs),\n }\n}\n\nexport async function analyzeRuns(opts: AnalyzeRunsOptions): Promise<InsightReport> {\n const runs = opts.runs.map(validateRunRecord)\n const bins = opts.histogramBins ?? 12\n const threshold = opts.decisionThreshold ?? 0.02\n const split = resolveSplit(runs, opts.split ?? 'auto')\n\n const compositeWithIds = runs\n .map((r) => ({ runId: r.runId, score: compositeOf(r, split) }))\n .filter((p) => Number.isFinite(p.score))\n const composite = distributionOf(\n compositeWithIds.map((p) => p.score),\n bins,\n compositeWithIds,\n )\n\n const perDimension = computePerDimension(runs, bins)\n const { execution, costProvenance: provenance } = summarizeExecution({\n runs,\n histogramBins: bins,\n })\n const knownCostRuns = runs.filter((run) => run.costProvenance.kind !== 'uncaptured')\n const costs = knownCostRuns.map((r) => r.costUsd).filter(isFiniteNumber)\n const costDist = distributionOf(costs, bins)\n const pareto = paretoChart(knownCostRuns, { split })\n const degraded: { cost?: string; pareto?: string } = {}\n if (provenance.uncaptured.n > 0) {\n degraded.cost = diagnoseCostCoverage(runs, provenance)\n } else if (costs.length === 0 || costs.every((c) => c === 0)) {\n degraded.cost = `all ${runs.length} explicitly observed or estimated USD values are $0`\n }\n if (pareto.points.length < 2) {\n degraded.pareto =\n pareto.points.length === 0\n ? 'no candidates — Pareto unavailable'\n : 'single candidate — Pareto is a single point, not a frontier'\n }\n const costQuality = {\n cost: costDist,\n pareto,\n provenance,\n ...(degraded.cost || degraded.pareto ? { degraded } : {}),\n }\n\n const judges = computeJudgeInsights(runs)\n\n const interRater = opts.raterScores ? computeInterRater(opts.raterScores) : undefined\n\n const lift = computeLift(runs, opts.baselineCandidateId, opts.candidateCandidateId, split)\n\n const failureClusters = opts.analyst\n ? await computeFailureClusters(runs, opts.analyst, split)\n : undefined\n\n const failureClasses = computeFailureClasses(runs, split)\n\n const contamination = opts.canaryScenarios\n ? computeContamination(runs, opts.canaryScenarios)\n : undefined\n\n const outcomeCorrelation = opts.outcomeSignal\n ? computeOutcomeCorrelation(runs, opts.outcomeSignal, split)\n : undefined\n\n const release = buildReleaseScorecard(composite, lift, contamination)\n\n const priorPeriodComparison = opts.baselineRuns\n ? computePriorPeriodComparison(runs, opts.baselineRuns, split, opts.baselineLabel)\n : undefined\n\n const recommendations = buildRecommendations({\n composite,\n judges,\n interRater,\n lift,\n failureClusters,\n failureClasses,\n contamination,\n outcomeCorrelation,\n priorPeriodComparison,\n threshold,\n })\n\n return {\n n: runs.length,\n execution,\n composite,\n perDimension,\n costQuality,\n judges,\n interRater,\n lift,\n failureClusters,\n contamination,\n outcomeCorrelation,\n release,\n ...(failureClasses ? { failureClasses } : {}),\n ...(priorPeriodComparison ? { priorPeriodComparison } : {}),\n recommendations,\n }\n}\n\nfunction computeExecutionInsight(runs: RunRecord[], bins: number): ExecutionInsight {\n const aggregateRows = runs.flatMap((run) => {\n const usage = aggregateTokenUsage(run)\n return usage ? [{ usage, costUsd: finiteRaw(run, 'aggregate_cost_usd') }] : []\n })\n const aggregateCosts = aggregateRows.flatMap((row) =>\n row.costUsd !== undefined ? [row.costUsd] : [],\n )\n const modelCounts = new Map<string, number>()\n let executionErrorRuns = 0\n let executionErrorEvents = 0\n let errorReportingRuns = 0\n let errorSpanEvents = 0\n let errorSpanReportingRuns = 0\n const terminalOutcomes: Record<RunTerminalOutcome, number> = {\n succeeded: 0,\n failed: 0,\n cancelled: 0,\n incomplete: 0,\n unknown: 0,\n }\n const errorsByTerminalOutcome: ExecutionInsight['executionErrors']['byTerminalOutcome'] = {\n succeeded: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n failed: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n cancelled: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n incomplete: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n unknown: { withErrors: 0, withoutErrors: 0, unreported: 0 },\n }\n let modelCallRuns = 0\n let modelCallEvents = 0\n let modelCallReportingRuns = 0\n\n for (const run of runs) {\n modelCounts.set(run.model, (modelCounts.get(run.model) ?? 0) + 1)\n const terminalOutcome = run.terminalOutcome\n terminalOutcomes[terminalOutcome] += 1\n const modelCalls = nonNegativeCountRaw(run, 'llm_span_count')\n if (modelCalls !== undefined) {\n modelCallEvents += modelCalls\n modelCallReportingRuns += 1\n }\n const usage = run.tokenUsage\n if (\n (modelCalls ?? 0) > 0 ||\n usage.input > 0 ||\n usage.output > 0 ||\n (usage.cached ?? 0) > 0 ||\n (usage.cacheWrite ?? 0) > 0\n ) {\n modelCallRuns += 1\n }\n const errorEvents = reportedExecutionErrorEvents(run)\n if (errorEvents !== undefined) {\n executionErrorEvents += errorEvents\n errorReportingRuns += 1\n if (errorEvents > 0) {\n executionErrorRuns += 1\n errorsByTerminalOutcome[terminalOutcome].withErrors += 1\n } else errorsByTerminalOutcome[terminalOutcome].withoutErrors += 1\n } else errorsByTerminalOutcome[terminalOutcome].unreported += 1\n const reportedErrorSpans = nonNegativeCountRaw(run, 'error_span_count')\n if (reportedErrorSpans !== undefined) {\n errorSpanEvents += reportedErrorSpans\n errorSpanReportingRuns += 1\n }\n }\n\n return {\n durationMs: distributionOf(\n runs.map((run) => run.wallMs),\n bins,\n ),\n queueMs: distributionOf(\n runs.filter((run) => run.queueMs !== undefined).map((run) => run.queueMs!),\n bins,\n ),\n tokenUsage: summarizeTokenUsage(\n runs.map((run) => run.tokenUsage),\n bins,\n ),\n aggregateUsage: {\n runs: aggregateRows.length,\n tokenUsage: summarizeTokenUsage(\n aggregateRows.map((row) => row.usage),\n bins,\n ),\n costUsd: distributionOf(aggregateCosts, bins),\n totalCostUsd: aggregateCosts.reduce((total, value) => total + value, 0),\n },\n models: [...modelCounts.entries()]\n .map(([model, count]) => ({ model, runs: count }))\n .sort((left, right) => right.runs - left.runs || left.model.localeCompare(right.model)),\n modelCalls: {\n runs: modelCallRuns,\n events: modelCallEvents,\n reportingRuns: modelCallReportingRuns,\n },\n executionErrors: {\n runs: executionErrorRuns,\n fraction: errorReportingRuns > 0 ? executionErrorRuns / errorReportingRuns : null,\n events: executionErrorEvents,\n reportingRuns: errorReportingRuns,\n errorSpanEvents,\n errorSpanReportingRuns,\n byTerminalOutcome: errorsByTerminalOutcome,\n },\n terminalOutcomes,\n }\n}\n\nfunction reportedExecutionErrorEvents(run: RunRecord): number | undefined {\n return nonNegativeCountRaw(run, 'execution_error_count')\n}\n\nfunction nonNegativeCountRaw(run: RunRecord, key: string): number | undefined {\n const value = finiteRaw(run, key)\n return value !== undefined && Number.isInteger(value) && value >= 0 ? value : undefined\n}\n\nfunction summarizeTokenUsage(usages: RunTokenUsage[], bins: number): TokenUsageInsight {\n const reasoning = usages.flatMap((usage) =>\n usage.reasoning !== undefined ? [usage.reasoning] : [],\n )\n const cached = usages.flatMap((usage) => (usage.cached !== undefined ? [usage.cached] : []))\n const cacheWrite = usages.flatMap((usage) =>\n usage.cacheWrite !== undefined ? [usage.cacheWrite] : [],\n )\n return {\n input: distributionOf(\n usages.map((usage) => usage.input),\n bins,\n ),\n output: distributionOf(\n usages.map((usage) => usage.output),\n bins,\n ),\n reasoning: distributionOf(reasoning, bins),\n cached: distributionOf(cached, bins),\n cacheWrite: distributionOf(cacheWrite, bins),\n totals: {\n input: usages.reduce((total, usage) => total + usage.input, 0),\n output: usages.reduce((total, usage) => total + usage.output, 0),\n reasoning: reasoning.reduce((total, value) => total + value, 0),\n cached: cached.reduce((total, value) => total + value, 0),\n cacheWrite: cacheWrite.reduce((total, value) => total + value, 0),\n },\n }\n}\n\nfunction aggregateTokenUsage(run: RunRecord): RunTokenUsage | undefined {\n const input = finiteRaw(run, 'aggregate_prompt_tokens')\n const output = finiteRaw(run, 'aggregate_completion_tokens')\n const reasoning = finiteRaw(run, 'aggregate_reasoning_tokens')\n const cached = finiteRaw(run, 'aggregate_cached_tokens')\n const cacheWrite = finiteRaw(run, 'aggregate_cache_write_tokens')\n if (\n input === undefined &&\n output === undefined &&\n reasoning === undefined &&\n cached === undefined &&\n cacheWrite === undefined\n )\n return undefined\n return {\n input: input ?? 0,\n output: output ?? 0,\n ...(reasoning !== undefined ? { reasoning } : {}),\n ...(cached !== undefined ? { cached } : {}),\n ...(cacheWrite !== undefined ? { cacheWrite } : {}),\n }\n}\n\nfunction finiteRaw(run: RunRecord, key: string): number | undefined {\n const value = run.outcome.raw[key]\n return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined\n}\n\nfunction summarizeCostProvenance(runs: RunRecord[]): CostProvenanceSummary {\n const summary: CostProvenanceSummary = {\n observed: { n: 0, totalUsd: 0 },\n estimated: { n: 0, totalUsd: 0 },\n uncaptured: { n: 0 },\n knownFraction: 0,\n }\n for (const run of runs) {\n const cost = run.costProvenance\n if (cost.kind === 'uncaptured') {\n summary.uncaptured.n += 1\n } else {\n summary[cost.kind].n += 1\n summary[cost.kind].totalUsd += cost.usd\n }\n }\n const known = summary.observed.n + summary.estimated.n\n summary.knownFraction = runs.length > 0 ? known / runs.length : 0\n return summary\n}\n\nfunction diagnoseCostCoverage(runs: RunRecord[], provenance: CostProvenanceSummary): string {\n const uncaptured = provenance.uncaptured.n\n const known = provenance.observed.n + provenance.estimated.n\n if (uncaptured === runs.length) {\n return `USD cost uncaptured for all ${runs.length} runs — no observed or estimated USD values; token and wall-time metrics remain available.`\n }\n return `USD cost uncaptured for ${uncaptured}/${runs.length} runs; excluded those rows from cost statistics (${known}/${runs.length} retained: ${provenance.observed.n} observed, ${provenance.estimated.n} estimated).`\n}\n\n/**\n * Model-free task-failure tally.\n *\n * Explicit non-success classes are task-failure evidence.\n * A low task score without a class is counted as `unknown`.\n */\nfunction computeFailureClasses(\n runs: RunRecord[],\n split: 'search' | 'holdout',\n): FailureClassTally[] | undefined {\n const counts = new Map<FailureClass, number>()\n for (const r of runs) {\n if (!isTaskFailure(r, split)) continue\n const key =\n r.failureClass !== undefined && r.failureClass !== 'success' ? r.failureClass : 'unknown'\n counts.set(key, (counts.get(key) ?? 0) + 1)\n }\n if (counts.size === 0) return undefined\n const n = runs.length\n return [...counts.entries()]\n .map(([failureClass, count]) => ({\n failureClass,\n count,\n share: n > 0 ? count / n : 0,\n }))\n .sort((a, b) => b.count - a.count || a.failureClass.localeCompare(b.failureClass))\n}\n\n// ── Prior-period comparison ─────────────────────────────────────────\n\n/** Direction of the metric — does \"higher current\" mean better or worse?\n * Composite + judge dimensions: higher is better. Cost + duration: lower\n * is better. The recommendations engine flips the sign before judging\n * regressed vs improved. */\ntype MetricDirection = 'higher-is-better' | 'lower-is-better'\n\nfunction computePriorPeriodComparison(\n current: RunRecord[],\n baseline: RunRecord[],\n split: 'search' | 'holdout',\n windowLabel: string | undefined,\n): PriorPeriodComparison | undefined {\n if (current.length === 0 || baseline.length === 0) return undefined\n\n const metrics: Record<string, MetricDelta> = {}\n const directions: Record<string, MetricDirection> = {}\n\n const compositeCurrent = current\n .map((r) => compositeOf(r, split))\n .filter(Number.isFinite) as number[]\n const compositeBaseline = baseline\n .map((r) => compositeOf(r, split))\n .filter(Number.isFinite) as number[]\n if (compositeCurrent.length > 0 && compositeBaseline.length > 0) {\n metrics.composite = welchCompare(compositeBaseline, compositeCurrent)\n directions.composite = 'higher-is-better'\n }\n\n const costCurrent = knownCostValues(current)\n const costBaseline = knownCostValues(baseline)\n if (costCurrent.length > 0 && costBaseline.length > 0) {\n metrics.cost = welchCompare(costBaseline, costCurrent)\n directions.cost = 'lower-is-better'\n }\n\n const durCurrent = current.map((r) => r.wallMs).filter(Number.isFinite)\n const durBaseline = baseline.map((r) => r.wallMs).filter(Number.isFinite)\n if (durCurrent.length > 0 && durBaseline.length > 0) {\n metrics.duration = welchCompare(durBaseline, durCurrent)\n directions.duration = 'lower-is-better'\n }\n\n const tokCurrent = current\n .map((r) => (r.tokenUsage.input ?? 0) + (r.tokenUsage.output ?? 0))\n .filter(Number.isFinite)\n const tokBaseline = baseline\n .map((r) => (r.tokenUsage.input ?? 0) + (r.tokenUsage.output ?? 0))\n .filter(Number.isFinite)\n if (tokCurrent.length > 0 && tokBaseline.length > 0) {\n metrics.tokenUsage = welchCompare(tokBaseline, tokCurrent)\n directions.tokenUsage = 'lower-is-better'\n }\n\n // Per-dimension judge comparisons — only for dimensions present in BOTH\n // windows. We use perDimMean since per-judge nesting is finicky for\n // two-sample comparisons across different judge configurations.\n const dimsCurrent = collectPerDimension(current)\n const dimsBaseline = collectPerDimension(baseline)\n for (const dim of Object.keys(dimsCurrent)) {\n const b = dimsBaseline[dim]\n const c = dimsCurrent[dim]\n if (!b || b.length === 0 || !c || c.length === 0) continue\n metrics[`dim.${dim}`] = welchCompare(b, c)\n directions[`dim.${dim}`] = 'higher-is-better'\n }\n\n const regressedMetrics: string[] = []\n const improvedMetrics: string[] = []\n const inconclusiveMetrics: string[] = []\n for (const [name, delta] of Object.entries(metrics)) {\n if (delta.status !== 'ok') {\n inconclusiveMetrics.push(name)\n continue\n }\n if (!delta.significant) continue\n const dir = directions[name] ?? 'higher-is-better'\n const better = dir === 'higher-is-better' ? delta.delta > 0 : delta.delta < 0\n if (better) improvedMetrics.push(name)\n else regressedMetrics.push(name)\n }\n\n return {\n baselineN: baseline.length,\n currentN: current.length,\n ...(windowLabel ? { windowLabel } : {}),\n metrics,\n regressedMetrics,\n improvedMetrics,\n inconclusiveMetrics,\n }\n}\n\nfunction knownCostValues(runs: RunRecord[]): number[] {\n return runs\n .filter((run) => run.costProvenance.kind !== 'uncaptured')\n .map((run) => run.costUsd)\n .filter(isFiniteNumber)\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value)\n}\n\n/** Collect per-dimension values across runs (from outcome.judgeScores.perDimMean). */\nfunction collectPerDimension(runs: RunRecord[]): Record<string, number[]> {\n const out: Record<string, number[]> = {}\n for (const r of runs) {\n const perDim = r.outcome.judgeScores?.perDimMean\n if (!perDim) continue\n for (const [dim, value] of Object.entries(perDim)) {\n if (!Number.isFinite(value)) continue\n if (!out[dim]) out[dim] = []\n out[dim].push(value as number)\n }\n }\n return out\n}\n\n/** Adapt the shared two-sample Welch result to the report contract. */\nfunction welchCompare(baseline: number[], current: number[]): MetricDelta {\n const result = welchsTTest(baseline, current)\n const base = {\n current: result.meanB,\n baseline: result.meanA,\n delta: result.delta,\n baselineN: baseline.length,\n currentN: current.length,\n }\n if (result.status !== 'ok') {\n return {\n ...base,\n status: result.status,\n ci95: null,\n pValue: null,\n cohensD: null,\n significant: false,\n }\n }\n return {\n ...base,\n status: 'ok',\n ci95: result.ci95,\n pValue: result.p,\n cohensD: result.cohensD,\n significant: result.p < 0.05 && Math.abs(result.cohensD) >= 0.2,\n }\n}\n\n// ── Composite + split selection ─────────────────────────────────────\n\nfunction resolveSplit(\n runs: RunRecord[],\n pref: 'search' | 'holdout' | 'auto',\n): 'search' | 'holdout' {\n if (pref !== 'auto') return pref\n const hasHoldout = runs.some((r) => Number.isFinite(observedSplitScore(r, 'holdout')))\n return hasHoldout ? 'holdout' : 'search'\n}\n\n/**\n * RAW (`observedSplitScore`): `analyzeRuns` describes what a set of runs\n * reported, and every downstream reader of this composite — distributions,\n * per-candidate summaries, the reward-hacking correlation — needs the ungated\n * number to see an inflated run at all.\n */\nfunction compositeOf(run: RunRecord, split: 'search' | 'holdout'): number {\n // Split-exact, no cross-split fallthrough: answering \"what did this run\n // score on the split I am summarising\" with the other split's number\n // silently mixes populations.\n const score = observedSplitScore(run, split)\n return Number.isFinite(score) ? (score as number) : Number.NaN\n}\n\n// ── Distribution helpers ────────────────────────────────────────────\n\nfunction distributionOf(\n values: number[],\n bins: number,\n withIds?: Array<{ runId: string; score: number }>,\n): ScalarDistribution {\n if (values.length === 0) {\n return {\n n: 0,\n mean: null,\n p50: null,\n p95: null,\n stddev: null,\n min: null,\n max: null,\n histogram: [],\n }\n }\n const sorted = [...values].sort((a, b) => a - b)\n const n = sorted.length\n const mean = sorted.reduce((s, v) => s + v, 0) / n\n const variance = sorted.reduce((s, v) => s + (v - mean) ** 2, 0) / n\n const stddev = Math.sqrt(variance)\n const tailRuns = withIds\n ? [...withIds].sort((a, b) => a.score - b.score).slice(0, Math.min(5, withIds.length))\n : undefined\n return {\n n,\n mean,\n p50: percentile(sorted, 0.5),\n p95: percentile(sorted, 0.95),\n stddev,\n min: sorted[0]!,\n max: sorted[n - 1]!,\n histogram: histogram(sorted, bins),\n ...(tailRuns ? { tailRuns } : {}),\n }\n}\n\nfunction percentile(sorted: number[], q: number): number {\n if (sorted.length === 0) return 0\n if (sorted.length === 1) return sorted[0]!\n const idx = (sorted.length - 1) * q\n const lo = Math.floor(idx)\n const hi = Math.ceil(idx)\n if (lo === hi) return sorted[lo]!\n const w = idx - lo\n return sorted[lo]! * (1 - w) + sorted[hi]! * w\n}\n\n/** Even-width histogram over the value range. Returns inclusive-lo /\n * exclusive-hi bins (closed on right for the last bin) compatible with\n * the substrate's `GainDistributionBin` shape. */\nfunction histogram(sorted: number[], bins: number): ScalarDistribution['histogram'] {\n if (sorted.length === 0 || bins < 1) return []\n const min = sorted[0]!\n const max = sorted[sorted.length - 1]!\n if (min === max) return [{ lo: min, hi: max, count: sorted.length }]\n const width = (max - min) / bins\n const out: ScalarDistribution['histogram'] = []\n for (let i = 0; i < bins; i++) {\n const lo = min + i * width\n const hi = i === bins - 1 ? max : lo + width\n out.push({ lo, hi, count: 0 })\n }\n for (const v of sorted) {\n const idx = Math.min(bins - 1, Math.floor((v - min) / width))\n out[idx]!.count++\n }\n return out\n}\n\nfunction computePerDimension(runs: RunRecord[], bins: number): Record<string, ScalarDistribution> {\n // JudgeScoresRecord pre-aggregates `perDimMean` (mean across judges per\n // dimension). We collect those means across runs to produce a per-dim\n // distribution at the corpus level. Consumers who want per-judge\n // dimension values reach into `perJudge[judgeId][dim]` themselves.\n const byDim = new Map<string, number[]>()\n for (const run of runs) {\n const scores = run.outcome.judgeScores\n if (!scores) continue\n for (const [dim, value] of Object.entries(scores.perDimMean ?? {})) {\n if (!Number.isFinite(value)) continue\n const arr = byDim.get(dim) ?? []\n arr.push(value)\n byDim.set(dim, arr)\n }\n }\n const out: Record<string, ScalarDistribution> = {}\n for (const [dim, values] of byDim) out[dim] = distributionOf(values, bins)\n return out\n}\n\n// ── Judge insights ──────────────────────────────────────────────────\n\nfunction computeJudgeInsights(runs: RunRecord[]): Record<string, JudgeInsight> {\n // Each judge's per-run mean is the average of its per-dimension scores\n // for that run. We aggregate those means across all runs each judge\n // scored — giving consumers a \"this judge's typical verdict\" reading.\n const out: Record<string, JudgeInsight> = {}\n const byJudge = new Map<string, number[]>()\n for (const run of runs) {\n const scores = run.outcome.judgeScores\n if (!scores?.perJudge) continue\n for (const [judgeId, dims] of Object.entries(scores.perJudge)) {\n const dimValues = Object.values(dims).filter(Number.isFinite) as number[]\n if (dimValues.length === 0) continue\n const judgeMean = dimValues.reduce((s, v) => s + v, 0) / dimValues.length\n const arr = byJudge.get(judgeId) ?? []\n arr.push(judgeMean)\n byJudge.set(judgeId, arr)\n }\n }\n for (const [judgeId, values] of byJudge) {\n out[judgeId] = {\n n: values.length,\n meanScore: values.reduce((s, v) => s + v, 0) / values.length,\n }\n }\n return out\n}\n\n// ── Inter-rater agreement ───────────────────────────────────────────\n\nfunction computeInterRater(\n ratings: Array<{ runId: string; rater: string; score: number }>,\n): InterRaterInsight | undefined {\n const byRun = new Map<string, Array<{ rater: string; score: number }>>()\n for (const r of ratings) {\n if (!Number.isFinite(r.score)) continue\n const list = byRun.get(r.runId) ?? []\n list.push({ rater: r.rater, score: r.score })\n byRun.set(r.runId, list)\n }\n const raters = new Set(ratings.map((r) => r.rater))\n const jointlyRated: string[] = []\n for (const [runId, ratersForRun] of byRun) {\n const seen = new Set(ratersForRun.map((r) => r.rater))\n let all = true\n for (const r of raters) if (!seen.has(r)) all = false\n if (all) jointlyRated.push(runId)\n }\n if (raters.size < 2 || jointlyRated.length === 0) return undefined\n\n const raterList = [...raters].sort()\n const perPair: Record<string, number> = {}\n for (let i = 0; i < raterList.length; i++) {\n for (let j = i + 1; j < raterList.length; j++) {\n const a = raterList[i]!\n const b = raterList[j]!\n const aScores: number[] = []\n const bScores: number[] = []\n for (const runId of jointlyRated) {\n const ratersForRun = byRun.get(runId)!\n const sa = ratersForRun.find((r) => r.rater === a)?.score\n const sb = ratersForRun.find((r) => r.rater === b)?.score\n if (sa !== undefined && sb !== undefined) {\n aScores.push(sa)\n bScores.push(sb)\n }\n }\n const agreement = continuousAgreement(\n aScores.map((score, index) => [score, bScores[index]!]),\n { bootstrap: 0 },\n )\n perPair[`${a}::${b}`] = agreement.weightedKappa\n }\n }\n const matrix = jointlyRated.map((runId) => {\n const ratingsByRater = new Map(byRun.get(runId)!.map((rating) => [rating.rater, rating.score]))\n return raterList.map((rater) => ratingsByRater.get(rater)!)\n })\n const agreement = continuousAgreement(matrix, { bootstrap: 0 })\n\n const disagreementCases = jointlyRated\n .map((runId) => {\n const ratersForRun = byRun.get(runId)!\n const scores = ratersForRun.map((r) => r.score)\n const range = Math.max(...scores) - Math.min(...scores)\n return { runId, ratings: ratersForRun, range }\n })\n .sort((a, b) => b.range - a.range)\n .slice(0, 20)\n\n return {\n raters: raters.size,\n jointlyRated: jointlyRated.length,\n kappa: Number.isFinite(agreement.weightedKappa) ? agreement.weightedKappa : 0,\n icc: agreement.icc,\n pearson: agreement.pearson,\n spearman: agreement.spearman,\n perPair,\n disagreementCases,\n }\n}\n\n// ── Lift ────────────────────────────────────────────────────────────\n\nfunction computeLift(\n runs: RunRecord[],\n baselineId: string | undefined,\n candidateId: string | undefined,\n split: 'search' | 'holdout',\n): LiftInsight | undefined {\n let bId = baselineId\n let cId = candidateId\n if (!bId || !cId) {\n // Auto-detect: when exactly two distinct candidateIds appear, treat the\n // lower-mean side as baseline.\n const ids = [...new Set(runs.map((r) => r.candidateId))]\n if (ids.length !== 2) return undefined\n const [idA, idB] = ids as [string, string]\n const scoresA = finiteCompositeScores(\n runs.filter((run) => run.candidateId === idA),\n split,\n )\n const scoresB = finiteCompositeScores(\n runs.filter((run) => run.candidateId === idB),\n split,\n )\n if (scoresA.length === 0 || scoresB.length === 0) return undefined\n const meanA = mean(scoresA)\n const meanB = mean(scoresB)\n bId = meanA <= meanB ? idA : idB\n cId = meanA <= meanB ? idB : idA\n }\n\n const baseline = runs.filter((r) => r.candidateId === bId)\n const candidate = runs.filter((r) => r.candidateId === cId)\n if (baseline.length === 0 || candidate.length === 0) return undefined\n\n const scoredBaseline = baseline.filter((run) => Number.isFinite(compositeOf(run, split)))\n const scoredCandidate = candidate.filter((run) => Number.isFinite(compositeOf(run, split)))\n const pairing = pairRunRecords(scoredBaseline, scoredCandidate)\n const pairedBaseline = pairing.pairs.map((pair) => compositeOf(pair.baseline, split))\n const pairedCandidate = pairing.pairs.map((pair) => compositeOf(pair.treatment, split))\n if (pairedBaseline.length === 0) return undefined\n\n const baselineMean = mean(pairedBaseline)\n const candidateMean = mean(pairedCandidate)\n const delta = candidateMean - baselineMean\n\n const bootstrap = pairedBootstrap(pairedBaseline, pairedCandidate, {\n confidence: 0.95,\n resamples: 2000,\n statistic: 'mean',\n })\n const tTest = pairedTTest(pairedBaseline, pairedCandidate)\n const d = pairedCohensDz(pairedBaseline, pairedCandidate)\n const mde = pairedMde({ nPaired: pairedBaseline.length, power: 0.8, alpha: 0.05 })\n const requiredN =\n d === null || d === 0\n ? null\n : requiredPairedSampleSize({\n effect: Math.abs(d),\n power: 0.8,\n alpha: 0.05,\n })\n\n return {\n baselineMean,\n candidateMean,\n delta,\n ci95: [bootstrap.low, bootstrap.high],\n pValue: tTest.p,\n n: pairedBaseline.length,\n minimumRequired: BOOTSTRAP_GATE_MIN_N,\n decisionEligible: bootstrap.gateEligible,\n unpairedBaseline: pairing.unpairedBaseline.length,\n unpairedCandidate: pairing.unpairedTreatment.length,\n cohensD: d,\n mde,\n requiredN,\n }\n}\n\nfunction mean(arr: number[]): number {\n return arr.length === 0 ? 0 : arr.reduce((s, v) => s + v, 0) / arr.length\n}\n\n// ── Failure clustering ──────────────────────────────────────────────\n\nasync function computeFailureClusters(\n runs: RunRecord[],\n analyst: AnalystRegistry,\n split: 'search' | 'holdout',\n): Promise<FailureClusterInsight | undefined> {\n const failed = runs.filter((run) => isTaskFailure(run, split))\n if (failed.length === 0) return { clusters: [], totalFailures: 0 }\n\n const clusters = new Map<string, { exemplars: string[]; share: number }>()\n for (const run of failed) {\n try {\n // AnalystRunInputs routes by field name: run-record analysts read\n // `runRecord`. Any other shape makes every analyst skip with\n // \"missing input\" and the clusters come back silently empty.\n const result = await analyst.run(run.runId, { runRecord: run })\n for (const finding of result.findings as AnalystFinding[]) {\n const key = finding.area || finding.analyst_id || 'unclassified'\n const c = clusters.get(key) ?? { exemplars: [], share: 0 }\n if (c.exemplars.length < 5) c.exemplars.push(run.runId)\n clusters.set(key, c)\n }\n } catch {\n const c = clusters.get('analyst-error') ?? { exemplars: [], share: 0 }\n if (c.exemplars.length < 5) c.exemplars.push(run.runId)\n clusters.set('analyst-error', c)\n }\n }\n const clusterList = [...clusters.entries()].map(([id, c]) => ({\n id,\n name: id,\n share: c.exemplars.length / failed.length,\n exemplars: c.exemplars,\n }))\n clusterList.sort((a, b) => b.share - a.share)\n return { clusters: clusterList, totalFailures: failed.length }\n}\n\nfunction finiteCompositeScores(runs: readonly RunRecord[], split: 'search' | 'holdout'): number[] {\n return runs.map((run) => compositeOf(run, split)).filter(Number.isFinite)\n}\n\nfunction isTaskFailure(run: RunRecord, split: 'search' | 'holdout'): boolean {\n if (run.failureClass !== undefined && run.failureClass !== 'success') return true\n const score = compositeOf(run, split)\n return Number.isFinite(score) && score < 0.5\n}\n\n// ── Contamination ──────────────────────────────────────────────────\n\nfunction computeContamination(\n runs: RunRecord[],\n canaries: DatasetScenario[],\n): InsightReport['contamination'] {\n let leaks = 0\n const details: Array<{ runId: string; canary: string; matched: string }> = []\n for (const run of runs) {\n const output = stringifyOutput(run)\n if (!output) continue\n const leaksHere = checkCanaries(output, canaries)\n for (const leak of leaksHere) {\n leaks++\n details.push({ runId: run.runId, canary: leak.canary, matched: leak.evidence })\n }\n }\n return { leaks, holdoutAuditPassed: leaks === 0, details }\n}\n\nfunction stringifyOutput(run: RunRecord): string | undefined {\n // RunRecord doesn't fix where \"the agent's output\" lives — different\n // consumers stash it differently. We probe the common shapes: the\n // outcome.raw map (numeric only by design — unlikely to contain text),\n // and any string-valued fields tucked under metadata via type casting.\n // Consumers with bespoke shapes pass canaryScenarios only when they\n // know their runs carry a stringifiable surface.\n const metadata = (run as unknown as { metadata?: Record<string, unknown> }).metadata\n if (typeof metadata?.output === 'string') return metadata.output\n if (typeof metadata?.text === 'string') return metadata.text\n return undefined\n}\n\n// ── Outcome correlation + linear reward model ──────────────────────\n\nfunction computeOutcomeCorrelation(\n runs: RunRecord[],\n outcome: { metric: string; valueByRunId: Record<string, number> },\n split: 'search' | 'holdout',\n): OutcomeCorrelationInsight | undefined {\n const xs: number[] = []\n const ys: number[] = []\n for (const run of runs) {\n const y = outcome.valueByRunId[run.runId]\n if (y === undefined || !Number.isFinite(y)) continue\n const x = compositeOf(run, split)\n if (!Number.isFinite(x)) continue\n xs.push(x)\n ys.push(y)\n }\n if (xs.length < 3) return undefined\n\n const p = pearsonR(xs, ys)\n const s = spearmanR(xs, ys)\n const meanX = mean(xs)\n const meanY = mean(ys)\n let num = 0\n let denom = 0\n for (let i = 0; i < xs.length; i++) {\n num += (xs[i]! - meanX) * (ys[i]! - meanY)\n denom += (xs[i]! - meanX) ** 2\n }\n const slope = denom === 0 ? 0 : num / denom\n const intercept = meanY - slope * meanX\n const ssTot = ys.reduce((a, y) => a + (y - meanY) ** 2, 0)\n const ssRes = ys.reduce((a, y, i) => a + (y - (intercept + slope * xs[i]!)) ** 2, 0)\n const r2 = ssTot === 0 ? 0 : 1 - ssRes / ssTot\n\n return {\n metric: outcome.metric,\n n: xs.length,\n pearson: p,\n spearman: s,\n rewardModel: { intercept, slope, r2 },\n }\n}\n\n// ── Release confidence scorecard ───────────────────────────────────\n\nfunction buildReleaseScorecard(\n composite: ScalarDistribution,\n lift: LiftInsight | undefined,\n contamination: InsightReport['contamination'],\n): InsightReport['release'] {\n // Synthesise a minimal scorecard from the rolled-up signal. The\n // substrate's `evaluateReleaseConfidence` primitive consumes a richer\n // input shape that callers can produce by wiring SLO definitions; the\n // shape here is the contract `selfImprove`/`analyzeRuns` consumers\n // receive automatically. They can call `evaluateReleaseConfidence`\n // directly when they want SLO-based axis evaluation.\n const axes: InsightReport['release']['axes'] = []\n const liftPass =\n lift === undefined\n ? ('not_evaluated' as const)\n : !lift.decisionEligible\n ? ('not_evaluated' as const)\n : lift.ci95[0] > 0\n ? ('pass' as const)\n : lift.delta > 0\n ? ('warn' as const)\n : ('fail' as const)\n axes.push({\n name: 'quality-lift',\n status: liftPass,\n detail: lift\n ? `delta=${lift.delta.toFixed(3)}, CI95=[${lift.ci95[0].toFixed(3)}, ${lift.ci95[1].toFixed(3)}], n=${lift.n}${lift.decisionEligible ? '' : ` (descriptive only; ${lift.minimumRequired} required)`}`\n : 'no baseline/candidate pair available',\n })\n const contamPass =\n contamination === undefined\n ? ('not_evaluated' as const)\n : contamination.leaks === 0\n ? ('pass' as const)\n : ('fail' as const)\n axes.push({\n name: 'contamination',\n status: contamPass,\n detail: contamination ? `${contamination.leaks} canary leak(s)` : 'no canaries supplied',\n })\n axes.push(\n composite.n === 0\n ? {\n name: 'composite-distribution',\n status: 'not_evaluated',\n detail: 'no task-quality scores available',\n }\n : {\n name: 'composite-distribution',\n status:\n composite.mean !== null && composite.mean >= 0.5\n ? 'pass'\n : composite.mean !== null && composite.mean >= 0.3\n ? 'warn'\n : 'fail',\n detail:\n composite.mean === null || composite.p50 === null || composite.p95 === null\n ? 'task-quality distribution is internally incomplete'\n : `mean=${composite.mean.toFixed(3)}, p50=${composite.p50.toFixed(3)}, p95=${composite.p95.toFixed(3)} over n=${composite.n}`,\n },\n )\n const status = axes.some((a) => a.status === 'fail')\n ? 'fail'\n : axes.some((a) => a.status === 'warn' || a.status === 'not_evaluated')\n ? 'warn'\n : 'pass'\n return {\n status,\n axes,\n issues: [],\n }\n}\n\n// ── Recommendations engine ─────────────────────────────────────────\n\ninterface RecommendationContext {\n composite: ScalarDistribution\n judges: Record<string, JudgeInsight>\n interRater?: InterRaterInsight\n lift?: LiftInsight\n failureClusters?: FailureClusterInsight\n failureClasses?: FailureClassTally[]\n contamination?: InsightReport['contamination']\n outcomeCorrelation?: OutcomeCorrelationInsight\n priorPeriodComparison?: PriorPeriodComparison\n threshold: number\n}\n\nfunction buildRecommendations(ctx: RecommendationContext): Recommendation[] {\n const out: Recommendation[] = []\n\n // Prior-period regressions — highest customer-impact signal when present.\n // \"Did my last change help?\" with a falsifiable answer.\n if (ctx.priorPeriodComparison) {\n const ppc = ctx.priorPeriodComparison\n const label = ppc.windowLabel ?? 'baseline period'\n for (const name of ppc.regressedMetrics) {\n const d = ppc.metrics[name]\n if (d?.status !== 'ok') continue\n out.push({\n priority: 'critical',\n kind: 'investigate',\n title: `${name} regressed from ${d.baseline.toFixed(3)} → ${d.current.toFixed(3)} vs ${label}`,\n detail: `Welch CI95 = [${d.ci95[0].toFixed(3)}, ${d.ci95[1].toFixed(3)}], p=${d.pValue.toFixed(4)}, Cohen's d=${d.cohensD.toFixed(2)} (n_current=${d.currentN}, n_baseline=${d.baselineN}). The regression is statistically significant at p<0.05 with at-least-small effect size.`,\n evidencePath: `priorPeriodComparison.metrics.${name}`,\n })\n }\n for (const name of ppc.improvedMetrics) {\n const d = ppc.metrics[name]\n if (d?.status !== 'ok') continue\n out.push({\n priority: 'low',\n kind: 'ship',\n title: `${name} improved from ${d.baseline.toFixed(3)} → ${d.current.toFixed(3)} vs ${label}`,\n detail: `Welch CI95 = [${d.ci95[0].toFixed(3)}, ${d.ci95[1].toFixed(3)}], p=${d.pValue.toFixed(4)}, Cohen's d=${d.cohensD.toFixed(2)} (n_current=${d.currentN}, n_baseline=${d.baselineN}). Statistically significant improvement worth flagging.`,\n evidencePath: `priorPeriodComparison.metrics.${name}`,\n })\n }\n for (const name of ppc.inconclusiveMetrics) {\n const d = ppc.metrics[name]\n if (!d || d.status === 'ok' || d.delta === 0) continue\n const reason =\n d.status === 'zero-variance'\n ? 'both periods have zero observed variance'\n : 'one or both periods have fewer than two observations'\n out.push({\n priority: 'high',\n kind: 'investigate',\n title: `${name} changed from ${d.baseline.toFixed(3)} → ${d.current.toFixed(3)} vs ${label}; inference unavailable`,\n detail: `Observed delta ${d.delta.toFixed(3)} across n_current=${d.currentN} and n_baseline=${d.baselineN}, but ${reason}. The report does not fabricate a p-value, confidence interval, or effect size; inspect independence and data capture before acting.`,\n evidencePath: `priorPeriodComparison.metrics.${name}`,\n })\n }\n }\n\n // Composite-distribution branch. Fires when the overall quality signal is\n // poor regardless of lift / contamination / clusters — the customer needs\n // to know they have a problem AND which specific runs to inspect.\n if (\n ctx.composite.n > 0 &&\n ctx.composite.mean !== null &&\n ctx.composite.p50 !== null &&\n ctx.composite.p95 !== null\n ) {\n if (ctx.composite.mean < 0.3) {\n const tail = ctx.composite.tailRuns ?? []\n const names = tail\n .slice(0, 5)\n .map((t) => `${t.runId}=${t.score.toFixed(3)}`)\n .join(', ')\n out.push({\n priority: 'critical',\n kind: 'investigate',\n title: `Composite mean ${ctx.composite.mean.toFixed(3)} is below the 0.3 floor — the agent is broken on this corpus`,\n detail:\n tail.length > 0\n ? `Worst ${tail.length} run${tail.length === 1 ? '' : 's'} to inspect first: ${names}. Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`\n : `Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`,\n evidencePath: 'composite.tailRuns',\n })\n } else if (ctx.composite.mean < 0.5) {\n const tail = ctx.composite.tailRuns ?? []\n const names = tail\n .slice(0, 3)\n .map((t) => `${t.runId}=${t.score.toFixed(3)}`)\n .join(', ')\n out.push({\n priority: 'high',\n kind: 'investigate',\n title: `Composite mean ${ctx.composite.mean.toFixed(3)} is below 0.5 — investigate the lower tail before claiming the agent is healthy`,\n detail:\n tail.length > 0\n ? `Worst ${tail.length} run${tail.length === 1 ? '' : 's'}: ${names}. Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`\n : `Histogram p50=${ctx.composite.p50.toFixed(3)}, p95=${ctx.composite.p95.toFixed(3)}.`,\n evidencePath: 'composite.tailRuns',\n })\n }\n }\n\n // A healthy-looking mean can hide a group of failed tasks sharing one\n // producer-reported cause. This path does not require an analyst.\n if (ctx.failureClasses && ctx.failureClasses.length > 0) {\n const top = ctx.failureClasses[0]!\n if (top.count >= 3 && top.share >= 0.15) {\n out.push({\n priority: top.share >= 0.25 ? 'high' : 'medium',\n kind: 'investigate',\n title: `'${top.failureClass}' is the dominant failure class — ${top.count} runs (${(top.share * 100).toFixed(0)}% of the corpus)`,\n detail: `The mean composite can look acceptable while one failure class dominates the lower tail. ${top.count} of ${ctx.composite.n} runs failed with '${top.failureClass}'${ctx.failureClasses.length > 1 ? ` (next: '${ctx.failureClasses[1]!.failureClass}' ×${ctx.failureClasses[1]!.count})` : ''}. Fix this cause first.`,\n evidencePath: 'failureClasses',\n })\n }\n }\n\n // Missing-judges branch. The report can't surface per-dimension or\n // calibration signal when `outcome.judgeScores` is empty across the\n // corpus. Tell the customer how to enrich.\n if (Object.keys(ctx.judges).length === 0 && ctx.composite.n > 0) {\n out.push({\n priority: 'medium',\n kind: 'expand-corpus',\n title: 'No judge scores recorded — per-dimension + calibration insights unavailable',\n detail:\n 'Records have no `outcome.judgeScores`. To unlock perDimension, judges, and calibration, attach a Judge run during your eval pass and populate `outcome.judgeScores.perJudge[judgeName][dimension] = score`. See `docs/insight-report.md` for the expected shape.',\n evidencePath: 'judges',\n })\n }\n\n if (ctx.lift) {\n if (!ctx.lift.decisionEligible) {\n out.push({\n priority: 'high',\n kind: 'expand-corpus',\n title: `Inconclusive — ${ctx.lift.n} paired runs; ${ctx.lift.minimumRequired} required`,\n detail: `The bootstrap interval is descriptive below ${ctx.lift.minimumRequired} paired observations and cannot support a ship decision.`,\n evidencePath: 'lift',\n })\n } else {\n const pairedEffect =\n ctx.lift.cohensD === null ? 'undefined (zero delta variance)' : ctx.lift.cohensD.toFixed(2)\n const pairedP =\n ctx.lift.pValue === null ? 'undefined (zero delta variance)' : ctx.lift.pValue.toFixed(4)\n const requiredRuns =\n ctx.lift.requiredN === null ? 'not estimable' : `~${ctx.lift.requiredN} paired runs`\n const decisive = ctx.lift.ci95[0] > ctx.threshold\n const inconclusive = ctx.lift.ci95[0] <= ctx.threshold && ctx.lift.ci95[1] > ctx.threshold\n if (decisive) {\n out.push({\n priority: 'critical',\n kind: 'ship',\n title: `Ship — lift ${ctx.lift.delta.toFixed(3)} (95% CI ${ctx.lift.ci95[0].toFixed(3)}..${ctx.lift.ci95[1].toFixed(3)})`,\n detail: `Holdout lift exceeds threshold ${ctx.threshold} with 95% bootstrap confidence (n=${ctx.lift.n}, p=${pairedP}, paired d=${pairedEffect}).`,\n evidencePath: 'lift',\n })\n } else if (inconclusive) {\n out.push({\n priority: 'high',\n kind: 'expand-corpus',\n title: `Inconclusive — required sample is ${requiredRuns} (have ${ctx.lift.n}) at current effect size`,\n detail: `CI straddles threshold. Current MDE at 80% power is ${ctx.lift.mde.toFixed(3)}; observed delta is ${ctx.lift.delta.toFixed(3)}.`,\n evidencePath: 'lift',\n })\n } else {\n out.push({\n priority: 'critical',\n kind: 'hold',\n title: `Hold — lift CI lower bound ${ctx.lift.ci95[0].toFixed(3)} is at or below threshold ${ctx.threshold}`,\n detail: `Bootstrap CI provides no statistical evidence the candidate is better. Consider tightening the mutation or expanding the holdout.`,\n evidencePath: 'lift',\n })\n }\n }\n }\n\n if (ctx.contamination && ctx.contamination.leaks > 0) {\n out.push({\n priority: 'critical',\n kind: 'fix',\n title: `${ctx.contamination.leaks} canary leak${ctx.contamination.leaks === 1 ? '' : 's'} detected`,\n detail: `Holdout integrity is compromised. The lift number is unreliable until you investigate.`,\n evidencePath: 'contamination',\n })\n }\n\n if (ctx.interRater && ctx.interRater.kappa < 0.5) {\n out.push({\n priority: 'high',\n kind: 'recalibrate',\n title: `Inter-rater weighted kappa ${ctx.interRater.kappa.toFixed(2)} is below 0.5`,\n detail:\n 'Raters disagree on what good looks like. Review the largest disagreement cases and refine the rubric before automating these decisions.',\n evidencePath: 'interRater',\n })\n }\n\n if (ctx.failureClusters && ctx.failureClusters.clusters.length > 0) {\n const top = ctx.failureClusters.clusters[0]!\n out.push({\n priority: 'high',\n kind: 'investigate',\n title: `Top failure cluster: ${top.name} (${(top.share * 100).toFixed(0)}% of failures)`,\n detail: `${ctx.failureClusters.totalFailures} runs failed. The largest cluster groups ${top.exemplars.length} exemplars under '${top.name}'.`,\n evidencePath: 'failureClusters.clusters[0]',\n })\n }\n\n if (ctx.outcomeCorrelation && Math.abs(ctx.outcomeCorrelation.spearman) < 0.3) {\n out.push({\n priority: 'medium',\n kind: 'recalibrate',\n title: `Judge scores decoupled from ${ctx.outcomeCorrelation.metric} (Spearman ρ=${ctx.outcomeCorrelation.spearman.toFixed(2)})`,\n detail: `Your judges score what they were trained to score, but it isn't predicting downstream ${ctx.outcomeCorrelation.metric}. Consider retraining the judge against ${ctx.outcomeCorrelation.metric} as the gold signal.`,\n evidencePath: 'outcomeCorrelation',\n })\n }\n\n return out\n}\n\n// ── Re-export pareto figure spec for hosted-side rendering ─────────\n\nexport type { ParetoFigureSpec }\n"],"mappings":";;;;;;;;AA4BA,SAAgB,cAAc,QAAgB,WAA4C;CACxF,MAAM,QAAsB,CAAC;CAC7B,KAAK,MAAM,KAAK,WAAW;EACzB,IAAI,CAAC,EAAE,QAAQ;EACf,IAAI,OAAO,SAAS,EAAE,MAAM,GAC1B,MAAM,KAAK;GAAE,YAAY,EAAE;GAAI,QAAQ,EAAE;GAAQ,UAAU,QAAQ,QAAQ,EAAE,MAAM;EAAE,CAAC;CAE1F;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,sBACd,QACA,UACmB;CACnB,MAAM,UAAU,SAAS,oBAAoB,SAAS;CACtD,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,MAAM,eAAe,QAAQ,OAAO;CAC1C,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO;EACL,YAAY,SAAS;EACrB,QAAQ;EACR,UAAU,QAAQ,QAAQ,GAAG;CAC/B;AACF;;;;;;;;;;AAWA,SAAgB,sBACd,OACc;CACd,MAAM,QAAsB,CAAC;CAC7B,KAAK,MAAM,KAAK,OAAO;EACrB,MAAM,OAAO,sBAAsB,EAAE,QAAQ,EAAE,QAAQ;EACvD,IAAI,MAAM,MAAM,KAAK;GAAE,GAAG;GAAM,OAAO,EAAE,SAAS,KAAK;EAAM,CAAC;CAChE;CACA,OAAO;AACT;;;;;;AAOA,SAAS,eAAe,QAAgB,SAAgC;CACtE,MAAM,KAAK,cAAc,OAAO;CAChC,IAAI,IAAI;EACN,MAAM,IAAI,OAAO,MAAM,EAAE;EACzB,OAAO,KAAK,EAAE,EAAE,CAAC,SAAS,IAAI,EAAE,KAAK;CACvC;CACA,OAAO,OAAO,SAAS,OAAO,IAAI,UAAU;A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