@tangle-network/agent-eval 0.203.2 → 0.205.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/analyst/index.d.ts +1 -1
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +5 -5
- package/dist/{analyze-runs-BrIibNd0.js → analyze-runs-d5dcMlxi.js} +9 -9
- package/dist/{analyze-runs-BrIibNd0.js.map → analyze-runs-d5dcMlxi.js.map} +1 -1
- package/dist/baseline-Dm8966du.js +259 -0
- package/dist/baseline-Dm8966du.js.map +1 -0
- package/dist/{benchmark-command-6OBcB0sG.js → benchmark-command-BQhi_BVO.js} +9 -6
- package/dist/benchmark-command-BQhi_BVO.js.map +1 -0
- package/dist/benchmarks/index.js +2 -2
- package/dist/builder-eval/index.js +1 -1
- package/dist/campaign/index.js +9 -9
- package/dist/{campaign-DYhg4SjN.js → campaign-0lmkAMpE.js} +11 -11
- package/dist/{campaign-DYhg4SjN.js.map → campaign-0lmkAMpE.js.map} +1 -1
- package/dist/{campaign-evidence-Dt_rWPk2.js → campaign-evidence-C__cUpCt.js} +2 -2
- package/dist/{campaign-evidence-Dt_rWPk2.js.map → campaign-evidence-C__cUpCt.js.map} +1 -1
- package/dist/cli.js +5 -5
- package/dist/contract/index.js +10 -10
- package/dist/{default-registry-wInsQWlQ.js → default-registry-BthquIoC.js} +2 -2
- package/dist/{default-registry-wInsQWlQ.js.map → default-registry-BthquIoC.js.map} +1 -1
- package/dist/{define-agent-eval-B25Cc3ki.js → define-agent-eval-CeYrXpl7.js} +4 -4
- package/dist/{define-agent-eval-B25Cc3ki.js.map → define-agent-eval-CeYrXpl7.js.map} +1 -1
- package/dist/{descriptive-D9LUFk1-.js → descriptive-CnU8Yq29.js} +2 -2
- package/dist/{descriptive-D9LUFk1-.js.map → descriptive-CnU8Yq29.js.map} +1 -1
- package/dist/diagnosis/index.js +1 -1
- package/dist/{dspy-rlm-engine-D0h-P2Mz.js → dspy-rlm-engine-DCQKNQMn.js} +2 -2
- package/dist/{dspy-rlm-engine-D0h-P2Mz.js.map → dspy-rlm-engine-DCQKNQMn.js.map} +1 -1
- package/dist/{eval-campaign-ha_aWtk7.js → eval-campaign-DsRmYsQI.js} +2 -2
- package/dist/{eval-campaign-ha_aWtk7.js.map → eval-campaign-DsRmYsQI.js.map} +1 -1
- package/dist/experiment/index.js +9 -9
- package/dist/index.d.ts +61 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +102 -25
- package/dist/index.js.map +1 -1
- package/dist/{internal-BOe3zmjQ.js → internal-CRHwS9iz.js} +3 -3
- package/dist/internal-CRHwS9iz.js.map +1 -0
- package/dist/jev.js +1 -1
- package/dist/judge-calibration-DFtEMlde.d.ts.map +1 -1
- package/dist/{judge-calibration-C5zgtiJT.js → judge-calibration-N44V04Se.js} +7 -17
- package/dist/judge-calibration-N44V04Se.js.map +1 -0
- package/dist/{kind-factory-CdPPHtGZ.js → kind-factory-Cn1lbsAd.js} +5 -5
- package/dist/kind-factory-Cn1lbsAd.js.map +1 -0
- package/dist/{llm-judge-DyZdrp6I.js → llm-judge-Bka5q-ds.js} +8 -8
- package/dist/{llm-judge-DyZdrp6I.js.map → llm-judge-Bka5q-ds.js.map} +1 -1
- package/dist/matrix/index.js +1 -1
- package/dist/{matrix-DnlHn5x1.js → matrix-_BV9-Lk5.js} +12 -9
- package/dist/matrix-_BV9-Lk5.js.map +1 -0
- package/dist/meta-eval/index.js +2 -2
- package/dist/multishot/golden/index.js +1 -1
- package/dist/multishot/index.js +1 -1
- package/dist/normal-DsJZtrJc.js +25 -0
- package/dist/normal-DsJZtrJc.js.map +1 -0
- package/dist/openapi.json +1 -1
- package/dist/{paired-arms-DpS_h8ON.js → paired-arms-Dsu-r6xd.js} +6 -27
- package/dist/paired-arms-Dsu-r6xd.js.map +1 -0
- package/dist/{paired-binary-OMBVRtc-.js → paired-binary-DpwwK1fU.js} +2 -2
- package/dist/{paired-binary-OMBVRtc-.js.map → paired-binary-DpwwK1fU.js.map} +1 -1
- package/dist/{paired-promotion-decision-DhrmjdV8.js → paired-promotion-decision-CO0kA0bq.js} +3 -3
- package/dist/{paired-promotion-decision-DhrmjdV8.js.map → paired-promotion-decision-CO0kA0bq.js.map} +1 -1
- package/dist/{paired-tests-Ccr16gcW.js → paired-tests-jbwPdSz5.js} +3 -3
- package/dist/{paired-tests-Ccr16gcW.js.map → paired-tests-jbwPdSz5.js.map} +1 -1
- package/dist/pipelines/index.d.ts +1 -1
- package/dist/pipelines/index.js +2 -2
- package/dist/{power-and-mde-bie6i965.js → power-and-mde-fK5Qocwo.js} +3 -3
- package/dist/{power-and-mde-bie6i965.js.map → power-and-mde-fK5Qocwo.js.map} +1 -1
- package/dist/{produced-state-DLToUXrD.js → produced-state-FdbE-88t.js} +3 -3
- package/dist/{produced-state-DLToUXrD.js.map → produced-state-FdbE-88t.js.map} +1 -1
- package/dist/{promotion-policy-BI1RxzwD.js → promotion-policy-BSbTAMtE.js} +4 -4
- package/dist/{promotion-policy-BI1RxzwD.js.map → promotion-policy-BSbTAMtE.js.map} +1 -1
- package/dist/quantile--0yb07pD.js +15 -0
- package/dist/quantile--0yb07pD.js.map +1 -0
- package/dist/{report-command-D0XL2Cvi.js → report-command-JrjiWReS.js} +2 -2
- package/dist/{report-command-D0XL2Cvi.js.map → report-command-JrjiWReS.js.map} +1 -1
- package/dist/reporting.js +4 -4
- package/dist/{reward-hacking-C-a__ShZ.js → reward-hacking-BFcQgkux.js} +2 -2
- package/dist/{reward-hacking-C-a__ShZ.js.map → reward-hacking-BFcQgkux.js.map} +1 -1
- package/dist/rl.js +7 -7
- package/dist/{rubric-predictive-validity-B0Pg-3I5.js → rubric-predictive-validity-BsgkBfT0.js} +3 -3
- package/dist/{rubric-predictive-validity-B0Pg-3I5.js.map → rubric-predictive-validity-BsgkBfT0.js.map} +1 -1
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-Dpniloks.js → search-kernel-CsISc5t8.js} +5 -5
- package/dist/{search-kernel-Dpniloks.js.map → search-kernel-CsISc5t8.js.map} +1 -1
- package/dist/{search-summary-C1nAHgkB.js → search-summary-BZkoLwbB.js} +4 -4
- package/dist/{search-summary-C1nAHgkB.js.map → search-summary-BZkoLwbB.js.map} +1 -1
- package/dist/{semantic-concept-judge-BgWxa4L_.js → semantic-concept-judge-BbiYuv7U.js} +3 -3
- package/dist/{semantic-concept-judge-BgWxa4L_.js.map → semantic-concept-judge-BbiYuv7U.js.map} +1 -1
- package/dist/{sequential-DWn_np6P.js → sequential-7uxpO0Vm.js} +2 -2
- package/dist/{sequential-DWn_np6P.js.map → sequential-7uxpO0Vm.js.map} +1 -1
- package/dist/{skillopt-optimization-method-Dz5CGZb8.js → skillopt-optimization-method-bEm4jYV4.js} +4 -4
- package/dist/{skillopt-optimization-method-Dz5CGZb8.js.map → skillopt-optimization-method-bEm4jYV4.js.map} +1 -1
- package/dist/{statistical-heldout-CNLOvRq_.js → statistical-heldout-C26hOFWD.js} +3 -3
- package/dist/{statistical-heldout-CNLOvRq_.js.map → statistical-heldout-C26hOFWD.js.map} +1 -1
- package/dist/{store-otlp-yd9lDziN.js → store-otlp-BA7G1Du-.js} +44 -11
- package/dist/store-otlp-BA7G1Du-.js.map +1 -0
- package/dist/{store-tool-spans-CAF3T-BS.d.ts → store-tool-spans-BYIarVrG.d.ts} +17 -8
- package/dist/{store-tool-spans-CAF3T-BS.d.ts.map → store-tool-spans-BYIarVrG.d.ts.map} +1 -1
- package/dist/{store-tool-spans-D5kOU0mr.js → store-tool-spans-DKoVbE-w.js} +3 -3
- package/dist/{store-tool-spans-D5kOU0mr.js.map → store-tool-spans-DKoVbE-w.js.map} +1 -1
- package/dist/{student-t-BBZYka0E.js → student-t-BQeKJx2N.js} +2 -2
- package/dist/{student-t-BBZYka0E.js.map → student-t-BQeKJx2N.js.map} +1 -1
- package/dist/{summary-report-DLzptLSA.js → summary-report-BG6-hOkm.js} +6 -6
- package/dist/{summary-report-DLzptLSA.js.map → summary-report-BG6-hOkm.js.map} +1 -1
- package/dist/supervisor-run/index.js +1 -1
- package/dist/{tool-waste-CP5DO383.d.ts → tool-waste-DxlebQkx.d.ts} +42 -2
- package/dist/tool-waste-DxlebQkx.d.ts.map +1 -0
- package/dist/{tool-waste-B-u3rzCz.js → tool-waste-x_E8h9Ih.js} +3 -3
- package/dist/{tool-waste-B-u3rzCz.js.map → tool-waste-x_E8h9Ih.js.map} +1 -1
- package/dist/trace-repair/index.js +1 -1
- package/dist/traces.d.ts +2 -2
- package/dist/traces.js +4 -4
- package/dist/{tree-D48IJUK0.js → tree-CAQflhLR.js} +5 -5
- package/dist/{tree-D48IJUK0.js.map → tree-CAQflhLR.js.map} +1 -1
- package/docs/concepts.md +21 -0
- package/docs/trace-analysis.md +10 -0
- package/package.json +1 -1
- package/dist/baseline-CVKsfWTg.js +0 -150
- package/dist/baseline-CVKsfWTg.js.map +0 -1
- package/dist/benchmark-command-6OBcB0sG.js.map +0 -1
- package/dist/internal-BOe3zmjQ.js.map +0 -1
- package/dist/judge-calibration-C5zgtiJT.js.map +0 -1
- package/dist/kind-factory-CdPPHtGZ.js.map +0 -1
- package/dist/matrix-DnlHn5x1.js.map +0 -1
- package/dist/paired-arms-DpS_h8ON.js.map +0 -1
- package/dist/store-otlp-yd9lDziN.js.map +0 -1
- package/dist/tool-waste-CP5DO383.d.ts.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { s as ValidationError } from "./errors-Dngq5h35.js";
|
|
2
|
+
import { t as interpolatedQuantile } from "./quantile--0yb07pD.js";
|
|
3
|
+
import { c as lnGamma, l as regularizedIncompleteBeta, t as assertFiniteSample$1 } from "./internal-CRHwS9iz.js";
|
|
4
|
+
import { n as studentTQuantile } from "./student-t-BQeKJx2N.js";
|
|
5
|
+
import { n as cohensD } from "./effect-sizes-DiH8MGOH.js";
|
|
6
|
+
import { t as normalCdf } from "./normal-DsJZtrJc.js";
|
|
7
|
+
//#region src/statistics/inference.ts
|
|
8
|
+
/** Two-sided normal tail, evaluated without subtracting a near-one CDF. */
|
|
9
|
+
function normalTwoSidedPValue(z) {
|
|
10
|
+
if (Number.isNaN(z)) throw new ValidationError("normalTwoSidedPValue: z must not be NaN");
|
|
11
|
+
return Math.min(1, 2 * normalCdf(-Math.abs(z)));
|
|
12
|
+
}
|
|
13
|
+
/** Two-sided Student-t tail, preserving small tail probabilities. */
|
|
14
|
+
function studentTTwoSidedPValue(t, df) {
|
|
15
|
+
if (Number.isNaN(t) || !Number.isFinite(df) || df <= 0) throw new ValidationError("studentTTwoSidedPValue: t must not be NaN and df must be positive and finite");
|
|
16
|
+
return regularizedIncompleteBeta(df / (df + t * t), df / 2, .5);
|
|
17
|
+
}
|
|
18
|
+
function table(a, b, c, d) {
|
|
19
|
+
if (![
|
|
20
|
+
a,
|
|
21
|
+
b,
|
|
22
|
+
c,
|
|
23
|
+
d
|
|
24
|
+
].every((value) => Number.isSafeInteger(value) && value >= 0) || !Number.isSafeInteger(a + b + c + d)) throw new ValidationError("contingency table: counts and total must be nonnegative safe integers");
|
|
25
|
+
return a + b + c + d;
|
|
26
|
+
}
|
|
27
|
+
/** Pearson statistic for a 2x2 table; empty or fixed margins have statistic zero. */
|
|
28
|
+
function chiSquared(a, b, c, d) {
|
|
29
|
+
const n = table(a, b, c, d);
|
|
30
|
+
if (!n) return 0;
|
|
31
|
+
const expected = [
|
|
32
|
+
(a + b) * (a + c) / n,
|
|
33
|
+
(a + b) * (b + d) / n,
|
|
34
|
+
(c + d) * (a + c) / n,
|
|
35
|
+
(c + d) * (b + d) / n
|
|
36
|
+
];
|
|
37
|
+
if (expected.some((value) => value === 0)) return 0;
|
|
38
|
+
return [
|
|
39
|
+
a,
|
|
40
|
+
b,
|
|
41
|
+
c,
|
|
42
|
+
d
|
|
43
|
+
].reduce((sum, value, i) => sum + (value - expected[i]) ** 2 / expected[i], 0);
|
|
44
|
+
}
|
|
45
|
+
/** One-degree-of-freedom chi-squared survival probability. */
|
|
46
|
+
function chiSquaredPValue(statistic) {
|
|
47
|
+
if (Number.isNaN(statistic) || statistic < 0) throw new ValidationError("chiSquaredPValue: statistic must be nonnegative and not NaN");
|
|
48
|
+
return normalTwoSidedPValue(Math.sqrt(statistic));
|
|
49
|
+
}
|
|
50
|
+
/** Fisher two-sided probability: sum all fixed-margin tables no likelier than the observed table. */
|
|
51
|
+
function fisherExactTwoSided(a, b, c, d) {
|
|
52
|
+
const n = table(a, b, c, d), row1 = a + b, row2 = c + d, col1 = a + c;
|
|
53
|
+
if (!n || !row1 || !row2 || !col1 || col1 === n) return 1;
|
|
54
|
+
const logChoose = (total, count) => lnGamma(total + 1) - lnGamma(count + 1) - lnGamma(total - count + 1);
|
|
55
|
+
const denominator = logChoose(n, col1);
|
|
56
|
+
const logP = (count) => logChoose(row1, count) + logChoose(row2, col1 - count) - denominator;
|
|
57
|
+
const threshold = logP(a) + 1e-7;
|
|
58
|
+
let p = 0;
|
|
59
|
+
for (let k = Math.max(0, col1 - row2); k <= Math.min(row1, col1); k++) {
|
|
60
|
+
const probability = logP(k);
|
|
61
|
+
if (probability <= threshold) p += Math.exp(probability);
|
|
62
|
+
}
|
|
63
|
+
return Math.min(1, p);
|
|
64
|
+
}
|
|
65
|
+
/** Fisher when any expected count is below five; otherwise Pearson's chi-squared tail. */
|
|
66
|
+
function twoByTwoPValue(a, b, c, d) {
|
|
67
|
+
const n = table(a, b, c, d);
|
|
68
|
+
if (!n) return 1;
|
|
69
|
+
return Math.min((a + b) * (a + c), (a + b) * (b + d), (c + d) * (a + c), (c + d) * (b + d)) / n < 5 ? fisherExactTwoSided(a, b, c, d) : chiSquaredPValue(chiSquared(a, b, c, d));
|
|
70
|
+
}
|
|
71
|
+
/** Centered least-squares slope; null p-value means no slope test was possible. */
|
|
72
|
+
function linearRegressionSlope(points) {
|
|
73
|
+
assertFiniteSample$1("linearRegressionSlope", "x", points.map((point) => point.x));
|
|
74
|
+
assertFiniteSample$1("linearRegressionSlope", "y", points.map((point) => point.y));
|
|
75
|
+
if (points.length < 2) return {
|
|
76
|
+
slope: 0,
|
|
77
|
+
rSquared: 0,
|
|
78
|
+
slopePValue: null
|
|
79
|
+
};
|
|
80
|
+
const n = points.length;
|
|
81
|
+
const meanX = points.reduce((sum, point) => sum + point.x / n, 0);
|
|
82
|
+
const meanY = points.reduce((sum, point) => sum + point.y / n, 0);
|
|
83
|
+
const sxx = points.reduce((sum, point) => sum + (point.x - meanX) ** 2, 0);
|
|
84
|
+
const syy = points.reduce((sum, point) => sum + (point.y - meanY) ** 2, 0);
|
|
85
|
+
const sxy = points.reduce((sum, point) => sum + (point.x - meanX) * (point.y - meanY), 0);
|
|
86
|
+
if (!sxx) return {
|
|
87
|
+
slope: 0,
|
|
88
|
+
rSquared: 0,
|
|
89
|
+
slopePValue: null
|
|
90
|
+
};
|
|
91
|
+
const slope = sxy / sxx;
|
|
92
|
+
const residual = points.reduce((sum, point) => sum + (point.y - meanY - slope * (point.x - meanX)) ** 2, 0);
|
|
93
|
+
if (![
|
|
94
|
+
slope,
|
|
95
|
+
residual,
|
|
96
|
+
sxx,
|
|
97
|
+
sxy,
|
|
98
|
+
syy
|
|
99
|
+
].every(Number.isFinite)) throw new ValidationError("linearRegressionSlope: sample arithmetic exceeded finite range");
|
|
100
|
+
return {
|
|
101
|
+
slope,
|
|
102
|
+
rSquared: syy === 0 ? 0 : Math.max(0, 1 - residual / syy),
|
|
103
|
+
slopePValue: n < 3 ? null : residual === 0 ? slope === 0 ? 1 : 0 : studentTTwoSidedPValue(slope / Math.sqrt(residual / (n - 2) / sxx), n - 2)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/baseline.ts
|
|
108
|
+
/**
|
|
109
|
+
* Baseline regression detection.
|
|
110
|
+
*
|
|
111
|
+
* Lifted from ADC baseline.ts. Every promotion-blocking signal boils down
|
|
112
|
+
* to: "is this run measurably worse than baseline?" — with enough
|
|
113
|
+
* statistical rigor to distinguish noise from drift.
|
|
114
|
+
*
|
|
115
|
+
* Uses:
|
|
116
|
+
* - Welch's t-test (unequal variance) for per-metric mean comparison
|
|
117
|
+
* - Cohen's d for effect size magnitude
|
|
118
|
+
* - IQR for stability flag (unstable samples can't be trusted for comparisons)
|
|
119
|
+
*
|
|
120
|
+
* Returns a structured verdict: improved | regressed | stable | unstable.
|
|
121
|
+
*/
|
|
122
|
+
/**
|
|
123
|
+
* Compare candidate samples against baseline per metric. Verdict logic:
|
|
124
|
+
* - unstable: IQR/|mean| > threshold on either set — not enough signal
|
|
125
|
+
* - improved: meaningful effect in the "better" direction AND p < alpha
|
|
126
|
+
* - regressed: meaningful effect in the "worse" direction AND p < alpha
|
|
127
|
+
* - stable: otherwise (no significant change)
|
|
128
|
+
*/
|
|
129
|
+
function compareToBaseline(samples, options = {}) {
|
|
130
|
+
const effectThreshold = options.effectThreshold ?? .5;
|
|
131
|
+
const alpha = options.alpha ?? .05;
|
|
132
|
+
const cvThreshold = options.unstableCvThreshold ?? .3;
|
|
133
|
+
const metrics = samples.map((s) => {
|
|
134
|
+
const comparison = welchsTTest(s.baseline, s.candidate);
|
|
135
|
+
if (comparison.status === "insufficient-sample") throw new Error(`compareToBaseline: need ≥2 samples per side for "${s.metric}"`);
|
|
136
|
+
const { meanA: bMean, meanB: cMean, delta, cohensD: d, t, df, p } = comparison;
|
|
137
|
+
const baselineIqr = iqr(s.baseline);
|
|
138
|
+
const candidateIqr = iqr(s.candidate);
|
|
139
|
+
const baselineStable = baselineIqr / Math.max(Math.abs(bMean), 1e-9) <= cvThreshold;
|
|
140
|
+
const candidateStable = candidateIqr / Math.max(Math.abs(cMean), 1e-9) <= cvThreshold;
|
|
141
|
+
const stable = baselineStable && candidateStable;
|
|
142
|
+
const reportedIqr = Math.max(baselineIqr, candidateIqr);
|
|
143
|
+
const effectClears = d === null || Math.abs(d) >= effectThreshold;
|
|
144
|
+
let verdict;
|
|
145
|
+
if (!stable) verdict = "unstable";
|
|
146
|
+
else if (comparison.status === "ok" && p < alpha && effectClears) verdict = (s.higherIsBetter ? delta > 0 : delta < 0) ? "improved" : "regressed";
|
|
147
|
+
else verdict = "stable";
|
|
148
|
+
return {
|
|
149
|
+
metric: s.metric,
|
|
150
|
+
baselineMean: bMean,
|
|
151
|
+
candidateMean: cMean,
|
|
152
|
+
delta,
|
|
153
|
+
cohensD: d,
|
|
154
|
+
welchT: t,
|
|
155
|
+
welchDf: df,
|
|
156
|
+
welchP: p,
|
|
157
|
+
stable,
|
|
158
|
+
iqr: reportedIqr,
|
|
159
|
+
verdict
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
metrics,
|
|
164
|
+
hasRegression: metrics.some((m) => m.verdict === "regressed"),
|
|
165
|
+
hasUnstable: metrics.some((m) => m.verdict === "unstable")
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function mean(xs) {
|
|
169
|
+
return xs.length ? xs.reduce((sum, value) => sum + value / xs.length, 0) : NaN;
|
|
170
|
+
}
|
|
171
|
+
/** Inter-quartile range; 0 when the sample has no spread. */
|
|
172
|
+
function iqr(xs) {
|
|
173
|
+
if (xs.length === 0) return 0;
|
|
174
|
+
const sorted = [...xs].sort((a, b) => a - b);
|
|
175
|
+
return interpolatedQuantile(sorted, .75) - interpolatedQuantile(sorted, .25);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Welch's t-test and 95% interval for two independent samples.
|
|
179
|
+
*
|
|
180
|
+
* Uses the Student-t distribution at every finite degree of freedom. Fewer
|
|
181
|
+
* than two observations per side and zero observed standard error cannot
|
|
182
|
+
* define a t reference distribution; those cases return an explicit status,
|
|
183
|
+
* `NaN` inferential fields, and no interval rather than fabricated certainty.
|
|
184
|
+
*/
|
|
185
|
+
function welchsTTest(a, b) {
|
|
186
|
+
assertFiniteSample("a", a);
|
|
187
|
+
assertFiniteSample("b", b);
|
|
188
|
+
const mA = mean(a);
|
|
189
|
+
const mB = mean(b);
|
|
190
|
+
const delta = mB - mA;
|
|
191
|
+
if (a.length && !Number.isFinite(mA) || b.length && !Number.isFinite(mB) || a.length && b.length && !Number.isFinite(delta)) throw new RangeError("welchsTTest: sample arithmetic exceeded finite range");
|
|
192
|
+
if (a.length < 2 || b.length < 2) return {
|
|
193
|
+
status: "insufficient-sample",
|
|
194
|
+
meanA: mA,
|
|
195
|
+
meanB: mB,
|
|
196
|
+
delta,
|
|
197
|
+
standardError: NaN,
|
|
198
|
+
t: NaN,
|
|
199
|
+
df: NaN,
|
|
200
|
+
p: NaN,
|
|
201
|
+
ci95: null,
|
|
202
|
+
cohensD: null
|
|
203
|
+
};
|
|
204
|
+
const vA = variance(a, mA);
|
|
205
|
+
const vB = variance(b, mB);
|
|
206
|
+
const seSquared = vA / a.length + vB / b.length;
|
|
207
|
+
if (!Number.isFinite(seSquared)) throw new RangeError("welchsTTest: sample arithmetic exceeded finite range");
|
|
208
|
+
const d = cohensD(a, b);
|
|
209
|
+
if (seSquared === 0) return {
|
|
210
|
+
status: "zero-variance",
|
|
211
|
+
meanA: mA,
|
|
212
|
+
meanB: mB,
|
|
213
|
+
delta,
|
|
214
|
+
standardError: 0,
|
|
215
|
+
t: delta === 0 ? 0 : Math.sign(delta) * Number.POSITIVE_INFINITY,
|
|
216
|
+
df: NaN,
|
|
217
|
+
p: NaN,
|
|
218
|
+
ci95: null,
|
|
219
|
+
cohensD: null
|
|
220
|
+
};
|
|
221
|
+
const standardError = Math.sqrt(seSquared);
|
|
222
|
+
const t = delta / standardError;
|
|
223
|
+
const fractionA = vA / a.length / seSquared;
|
|
224
|
+
const fractionB = vB / b.length / seSquared;
|
|
225
|
+
const df = 1 / (fractionA ** 2 / (a.length - 1) + fractionB ** 2 / (b.length - 1));
|
|
226
|
+
const p = studentTTwoSidedPValue(t, df);
|
|
227
|
+
if (d === null) throw new Error("welchsTTest: non-zero standard error produced no pooled effect size");
|
|
228
|
+
const halfWidth = studentTQuantile(.975, df) * standardError;
|
|
229
|
+
if (![
|
|
230
|
+
df,
|
|
231
|
+
d,
|
|
232
|
+
halfWidth,
|
|
233
|
+
delta - halfWidth,
|
|
234
|
+
delta + halfWidth
|
|
235
|
+
].every(Number.isFinite)) throw new RangeError("welchsTTest: sample arithmetic exceeded finite range");
|
|
236
|
+
return {
|
|
237
|
+
status: "ok",
|
|
238
|
+
meanA: mA,
|
|
239
|
+
meanB: mB,
|
|
240
|
+
delta,
|
|
241
|
+
standardError,
|
|
242
|
+
t,
|
|
243
|
+
df,
|
|
244
|
+
p,
|
|
245
|
+
ci95: [delta - halfWidth, delta + halfWidth],
|
|
246
|
+
cohensD: d
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function variance(xs, m) {
|
|
250
|
+
return xs.reduce((acc, x) => acc + (x - m) ** 2, 0) / (xs.length - 1);
|
|
251
|
+
}
|
|
252
|
+
function assertFiniteSample(name, sample) {
|
|
253
|
+
const invalid = sample.find((value) => !Number.isFinite(value));
|
|
254
|
+
if (invalid !== void 0) throw new RangeError(`welchsTTest: sample ${name} must contain only finite values, got ${invalid}`);
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
export { chiSquaredPValue as a, normalTwoSidedPValue as c, chiSquared as i, studentTTwoSidedPValue as l, iqr as n, fisherExactTwoSided as o, welchsTTest as r, linearRegressionSlope as s, compareToBaseline as t, twoByTwoPValue as u };
|
|
258
|
+
|
|
259
|
+
//# sourceMappingURL=baseline-Dm8966du.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline-Dm8966du.js","names":[],"sources":["../src/statistics/inference.ts","../src/baseline.ts"],"sourcesContent":["import { ValidationError } from '../errors'\nimport { normalCdf } from '../math/normal'\nimport { lnGamma, regularizedIncompleteBeta } from '../math/special-functions'\nimport { assertFiniteSample } from './internal'\n\n/** Two-sided normal tail, evaluated without subtracting a near-one CDF. */\nexport function normalTwoSidedPValue(z: number): number {\n if (Number.isNaN(z)) throw new ValidationError('normalTwoSidedPValue: z must not be NaN')\n return Math.min(1, 2 * normalCdf(-Math.abs(z)))\n}\n\n/** Two-sided Student-t tail, preserving small tail probabilities. */\nexport function studentTTwoSidedPValue(t: number, df: number): number {\n if (Number.isNaN(t) || !Number.isFinite(df) || df <= 0) {\n throw new ValidationError(\n 'studentTTwoSidedPValue: t must not be NaN and df must be positive and finite',\n )\n }\n return regularizedIncompleteBeta(df / (df + t * t), df / 2, 0.5)\n}\n\nfunction table(a: number, b: number, c: number, d: number): number {\n if (\n ![a, b, c, d].every((value) => Number.isSafeInteger(value) && value >= 0) ||\n !Number.isSafeInteger(a + b + c + d)\n ) {\n throw new ValidationError(\n 'contingency table: counts and total must be nonnegative safe integers',\n )\n }\n return a + b + c + d\n}\n\n/** Pearson statistic for a 2x2 table; empty or fixed margins have statistic zero. */\nexport function chiSquared(a: number, b: number, c: number, d: number): number {\n const n = table(a, b, c, d)\n if (!n) return 0\n const expected = [\n ((a + b) * (a + c)) / n,\n ((a + b) * (b + d)) / n,\n ((c + d) * (a + c)) / n,\n ((c + d) * (b + d)) / n,\n ]\n if (expected.some((value) => value === 0)) return 0\n return [a, b, c, d].reduce((sum, value, i) => sum + (value - expected[i]!) ** 2 / expected[i]!, 0)\n}\n\n/** One-degree-of-freedom chi-squared survival probability. */\nexport function chiSquaredPValue(statistic: number): number {\n if (Number.isNaN(statistic) || statistic < 0) {\n throw new ValidationError('chiSquaredPValue: statistic must be nonnegative and not NaN')\n }\n return normalTwoSidedPValue(Math.sqrt(statistic))\n}\n\n/** Fisher two-sided probability: sum all fixed-margin tables no likelier than the observed table. */\nexport function fisherExactTwoSided(a: number, b: number, c: number, d: number): number {\n const n = table(a, b, c, d),\n row1 = a + b,\n row2 = c + d,\n col1 = a + c\n if (!n || !row1 || !row2 || !col1 || col1 === n) return 1\n const logChoose = (total: number, count: number) =>\n lnGamma(total + 1) - lnGamma(count + 1) - lnGamma(total - count + 1)\n const denominator = logChoose(n, col1)\n const logP = (count: number) =>\n logChoose(row1, count) + logChoose(row2, col1 - count) - denominator\n const threshold = logP(a) + 1e-7\n let p = 0\n for (let k = Math.max(0, col1 - row2); k <= Math.min(row1, col1); k++) {\n const probability = logP(k)\n if (probability <= threshold) p += Math.exp(probability)\n }\n return Math.min(1, p)\n}\n\n/** Fisher when any expected count is below five; otherwise Pearson's chi-squared tail. */\nexport function twoByTwoPValue(a: number, b: number, c: number, d: number): number {\n const n = table(a, b, c, d)\n if (!n) return 1\n const minimum =\n Math.min((a + b) * (a + c), (a + b) * (b + d), (c + d) * (a + c), (c + d) * (b + d)) / n\n return minimum < 5 ? fisherExactTwoSided(a, b, c, d) : chiSquaredPValue(chiSquared(a, b, c, d))\n}\n\nexport interface LinearRegressionResult {\n slope: number\n rSquared: number\n slopePValue: number | null\n}\n\n/** Centered least-squares slope; null p-value means no slope test was possible. */\nexport function linearRegressionSlope(\n points: readonly { x: number; y: number }[],\n): LinearRegressionResult {\n assertFiniteSample(\n 'linearRegressionSlope',\n 'x',\n points.map((point) => point.x),\n )\n assertFiniteSample(\n 'linearRegressionSlope',\n 'y',\n points.map((point) => point.y),\n )\n if (points.length < 2) return { slope: 0, rSquared: 0, slopePValue: null }\n const n = points.length\n const meanX = points.reduce((sum, point) => sum + point.x / n, 0)\n const meanY = points.reduce((sum, point) => sum + point.y / n, 0)\n const sxx = points.reduce((sum, point) => sum + (point.x - meanX) ** 2, 0)\n const syy = points.reduce((sum, point) => sum + (point.y - meanY) ** 2, 0)\n const sxy = points.reduce((sum, point) => sum + (point.x - meanX) * (point.y - meanY), 0)\n if (!sxx) return { slope: 0, rSquared: 0, slopePValue: null }\n const slope = sxy / sxx\n const residual = points.reduce(\n (sum, point) => sum + (point.y - meanY - slope * (point.x - meanX)) ** 2,\n 0,\n )\n if (![slope, residual, sxx, sxy, syy].every(Number.isFinite)) {\n throw new ValidationError('linearRegressionSlope: sample arithmetic exceeded finite range')\n }\n const rSquared = syy === 0 ? 0 : Math.max(0, 1 - residual / syy)\n const slopePValue =\n n < 3\n ? null\n : residual === 0\n ? slope === 0\n ? 1\n : 0\n : studentTTwoSidedPValue(slope / Math.sqrt(residual / (n - 2) / sxx), n - 2)\n return { slope, rSquared, slopePValue }\n}\n","/**\n * Baseline regression detection.\n *\n * Lifted from ADC baseline.ts. Every promotion-blocking signal boils down\n * to: \"is this run measurably worse than baseline?\" — with enough\n * statistical rigor to distinguish noise from drift.\n *\n * Uses:\n * - Welch's t-test (unequal variance) for per-metric mean comparison\n * - Cohen's d for effect size magnitude\n * - IQR for stability flag (unstable samples can't be trusted for comparisons)\n *\n * Returns a structured verdict: improved | regressed | stable | unstable.\n */\n\nimport { interpolatedQuantile } from './math/quantile'\nimport { studentTQuantile } from './math/student-t'\nimport { cohensD } from './statistics/effect-sizes'\nimport { studentTTwoSidedPValue } from './statistics/inference'\n\nexport interface MetricSamples {\n /** Stable metric key (e.g. \"overallScore\", \"firstTokenMs\"). */\n metric: string\n /** Whether higher values are better. */\n higherIsBetter: boolean\n baseline: number[]\n candidate: number[]\n}\n\nexport interface MetricVerdict {\n metric: string\n baselineMean: number\n candidateMean: number\n delta: number\n /** Null when both samples are constant with unequal means — the\n * standardized effect is unbounded there, not zero. */\n cohensD: number | null\n welchT: number\n welchDf: number\n welchP: number\n stable: boolean\n /** IQR of the combined samples — used as a rough stability indicator. */\n iqr: number\n verdict: 'improved' | 'regressed' | 'stable' | 'unstable'\n}\n\nexport interface BaselineReport {\n metrics: MetricVerdict[]\n /** True if any critical metric regressed. */\n hasRegression: boolean\n /** True if any metric is unstable (too noisy to judge). */\n hasUnstable: boolean\n}\n\nexport interface BaselineOptions {\n /** Effect size threshold for meaningful delta (default 0.5 — medium effect). */\n effectThreshold?: number\n /** p-value threshold for statistical significance (default 0.05). */\n alpha?: number\n /** IQR/mean ratio above which samples are flagged unstable (default 0.30). */\n unstableCvThreshold?: number\n}\n\nexport type WelchTestStatus = 'ok' | 'insufficient-sample' | 'zero-variance'\n\n/**\n * Full unequal-variance comparison for two independent samples.\n *\n * `meanB`, `delta`, `t`, and `cohensD` are oriented as `b - a`. Inferential\n * fields are `NaN` and `ci95` is null when the sample count or observed\n * variance cannot define a Student-t result. `status` makes that state\n * explicit so callers cannot mistake it for evidence of no difference.\n */\ninterface WelchTestResultBase {\n meanA: number\n meanB: number\n delta: number\n}\n\nexport type WelchTestResult =\n | (WelchTestResultBase & {\n status: 'ok'\n standardError: number\n t: number\n df: number\n p: number\n ci95: [number, number]\n cohensD: number\n })\n | (WelchTestResultBase & {\n status: 'insufficient-sample' | 'zero-variance'\n standardError: number\n t: number\n df: number\n p: number\n ci95: null\n cohensD: null\n })\n\n/**\n * Compare candidate samples against baseline per metric. Verdict logic:\n * - unstable: IQR/|mean| > threshold on either set — not enough signal\n * - improved: meaningful effect in the \"better\" direction AND p < alpha\n * - regressed: meaningful effect in the \"worse\" direction AND p < alpha\n * - stable: otherwise (no significant change)\n */\nexport function compareToBaseline(\n samples: MetricSamples[],\n options: BaselineOptions = {},\n): BaselineReport {\n const effectThreshold = options.effectThreshold ?? 0.5\n const alpha = options.alpha ?? 0.05\n const cvThreshold = options.unstableCvThreshold ?? 0.3\n\n const metrics: MetricVerdict[] = samples.map((s) => {\n const comparison = welchsTTest(s.baseline, s.candidate)\n if (comparison.status === 'insufficient-sample') {\n throw new Error(`compareToBaseline: need ≥2 samples per side for \"${s.metric}\"`)\n }\n const { meanA: bMean, meanB: cMean, delta, cohensD: d, t, df, p } = comparison\n // Stability is per-side: a comparison is trustworthy only when BOTH\n // samples are internally consistent. Combining the sides would flag\n // large-but-real deltas as \"unstable\" which is exactly what we want\n // to detect.\n const baselineIqr = iqr(s.baseline)\n const candidateIqr = iqr(s.candidate)\n const baselineStable = baselineIqr / Math.max(Math.abs(bMean), 1e-9) <= cvThreshold\n const candidateStable = candidateIqr / Math.max(Math.abs(cMean), 1e-9) <= cvThreshold\n const stable = baselineStable && candidateStable\n const reportedIqr = Math.max(baselineIqr, candidateIqr)\n\n // Both sides are guaranteed ≥ 2 samples above, so a null d means zero\n // pooled spread across a real mean gap: an unbounded standardized effect,\n // which clears any finite threshold.\n const effectClears = d === null || Math.abs(d) >= effectThreshold\n\n let verdict: MetricVerdict['verdict']\n if (!stable) {\n verdict = 'unstable'\n } else if (comparison.status === 'ok' && p < alpha && effectClears) {\n const candidateIsBetter = s.higherIsBetter ? delta > 0 : delta < 0\n verdict = candidateIsBetter ? 'improved' : 'regressed'\n } else {\n verdict = 'stable'\n }\n\n return {\n metric: s.metric,\n baselineMean: bMean,\n candidateMean: cMean,\n delta,\n cohensD: d,\n welchT: t,\n welchDf: df,\n welchP: p,\n stable,\n iqr: reportedIqr,\n verdict,\n }\n })\n\n return {\n metrics,\n hasRegression: metrics.some((m) => m.verdict === 'regressed'),\n hasUnstable: metrics.some((m) => m.verdict === 'unstable'),\n }\n}\n\nfunction mean(xs: number[]): number {\n return xs.length ? xs.reduce((sum, value) => sum + value / xs.length, 0) : Number.NaN\n}\n\n/** Inter-quartile range; 0 when the sample has no spread. */\nexport function iqr(xs: number[]): number {\n if (xs.length === 0) return 0\n const sorted = [...xs].sort((a, b) => a - b)\n return interpolatedQuantile(sorted, 0.75) - interpolatedQuantile(sorted, 0.25)\n}\n\n/**\n * Welch's t-test and 95% interval for two independent samples.\n *\n * Uses the Student-t distribution at every finite degree of freedom. Fewer\n * than two observations per side and zero observed standard error cannot\n * define a t reference distribution; those cases return an explicit status,\n * `NaN` inferential fields, and no interval rather than fabricated certainty.\n */\nexport function welchsTTest(a: number[], b: number[]): WelchTestResult {\n assertFiniteSample('a', a)\n assertFiniteSample('b', b)\n const mA = mean(a)\n const mB = mean(b)\n const delta = mB - mA\n if (\n (a.length && !Number.isFinite(mA)) ||\n (b.length && !Number.isFinite(mB)) ||\n (a.length && b.length && !Number.isFinite(delta))\n ) {\n throw new RangeError('welchsTTest: sample arithmetic exceeded finite range')\n }\n if (a.length < 2 || b.length < 2) {\n return {\n status: 'insufficient-sample',\n meanA: mA,\n meanB: mB,\n delta,\n standardError: Number.NaN,\n t: Number.NaN,\n df: Number.NaN,\n p: Number.NaN,\n ci95: null,\n cohensD: null,\n }\n }\n\n const vA = variance(a, mA)\n const vB = variance(b, mB)\n const seSquared = vA / a.length + vB / b.length\n if (!Number.isFinite(seSquared)) {\n throw new RangeError('welchsTTest: sample arithmetic exceeded finite range')\n }\n const d = cohensD(a, b)\n if (seSquared === 0) {\n return {\n status: 'zero-variance',\n meanA: mA,\n meanB: mB,\n delta,\n standardError: 0,\n t: delta === 0 ? 0 : Math.sign(delta) * Number.POSITIVE_INFINITY,\n df: Number.NaN,\n p: Number.NaN,\n ci95: null,\n cohensD: null,\n }\n }\n\n const standardError = Math.sqrt(seSquared)\n const t = delta / standardError\n const fractionA = vA / a.length / seSquared\n const fractionB = vB / b.length / seSquared\n const df = 1 / (fractionA ** 2 / (a.length - 1) + fractionB ** 2 / (b.length - 1))\n const p = studentTTwoSidedPValue(t, df)\n if (d === null) {\n throw new Error('welchsTTest: non-zero standard error produced no pooled effect size')\n }\n const halfWidth = studentTQuantile(0.975, df) * standardError\n if (![df, d, halfWidth, delta - halfWidth, delta + halfWidth].every(Number.isFinite)) {\n throw new RangeError('welchsTTest: sample arithmetic exceeded finite range')\n }\n return {\n status: 'ok',\n meanA: mA,\n meanB: mB,\n delta,\n standardError,\n t,\n df,\n p,\n ci95: [delta - halfWidth, delta + halfWidth],\n cohensD: d,\n }\n}\n\nfunction variance(xs: number[], m: number): number {\n return xs.reduce((acc, x) => acc + (x - m) ** 2, 0) / (xs.length - 1)\n}\n\nfunction assertFiniteSample(name: string, sample: readonly number[]): void {\n const invalid = sample.find((value) => !Number.isFinite(value))\n if (invalid !== undefined) {\n throw new RangeError(\n `welchsTTest: sample ${name} must contain only finite values, got ${invalid}`,\n )\n }\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,qBAAqB,GAAmB;CACtD,IAAI,OAAO,MAAM,CAAC,GAAG,MAAM,IAAI,gBAAgB,yCAAyC;CACxF,OAAO,KAAK,IAAI,GAAG,IAAI,UAAU,CAAC,KAAK,IA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,MAAM,qEAAqE;CAEvF,MAAM,YAAY,iBAAiB,MAAO,EAAE,IAAI;CAChD,IAAI,CAAC;EAAC;EAAI;EAAG;EAAW,QAAQ;EAAW,QAAQ;CAAS,CAAC,CAAC,MAAM,OAAO,QAAQ,GACjF,MAAM,IAAI,WAAW,sDAAsD;CAE7E,OAAO;EACL,QAAQ;EACR,OAAO;EACP,OAAO;EACP;EACA;EACA;EACA;EACA;EACA,MAAM,CAAC,QAAQ,WAAW,QAAQ,SAAS;EAC3C,SAAS;CACX;AACF;AAEA,SAAS,SAAS,IAAc,GAAmB;CACjD,OAAO,GAAG,QAAQ,KAAK,MAAM,OAAO,IAAI,MAAM,GAAG,CAAC,KAAK,GAAG,SAAS;AACrE;AAEA,SAAS,mBAAmB,MAAc,QAAiC;CACzE,MAAM,UAAU,OAAO,MAAM,UAAU,CAAC,OAAO,SAAS,KAAK,CAAC;CAC9D,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,WACR,uBAAuB,KAAK,wCAAwC,SACtE;AAEJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as ValidationError, t as AgentEvalError } from "./errors-Dngq5h35.js";
|
|
2
2
|
import { a as hashCanonical, i as compareCodeUnits, o as jsonDocument, r as canonicalString } from "./canonical-BsZVgBhW.js";
|
|
3
|
-
import { r as pairedBootstrap } from "./paired-tests-
|
|
3
|
+
import { r as pairedBootstrap } from "./paired-tests-jbwPdSz5.js";
|
|
4
4
|
import { a as resolveModelPricing } from "./metrics-DOMpkoeb.js";
|
|
5
5
|
import { a as CostLedgerPersistenceError, i as CostLedger, n as CostCallConflictError, o as CostReceiptCaptureError, r as CostCeilingReachedError, s as CostReservationExceededError, t as CostAccountingIncompleteError } from "./cost-ledger-_IbkejCF.js";
|
|
6
6
|
import { d as withLedgerFileLock, f as writeLedgerFileAtomically } from "./journal-DvKCvjty.js";
|
|
@@ -9,11 +9,11 @@ import { S as fsCampaignStorage, i as startExternalOptimizerModelProxy, r as run
|
|
|
9
9
|
import { f as redactText } from "./redact-Dk1ZdJEm.js";
|
|
10
10
|
import { t as acquireSingleRunLock } from "./single-run-lock-fVu3MZWH.js";
|
|
11
11
|
import { a as callLlmJson, r as LlmResponseError, t as LlmCallError } from "./llm-client-DmCNzrc9.js";
|
|
12
|
-
import {
|
|
12
|
+
import { F as evidenceRefsFromRawFinding, N as RAW_FINDING_SCHEMA_PROMPT, P as RawAnalystFindingSchema, _ as TRACE_ANALYSIS_LIMITS, r as runTraceAnalyst } from "./kind-factory-Cn1lbsAd.js";
|
|
13
13
|
import { r as usageReceiptFromCostLedger } from "./usage-receipt-Cx3xNeyB.js";
|
|
14
14
|
import { r as makeFinding } from "./types-CW5b90JH.js";
|
|
15
|
-
import { t as createDspyRlmTraceEngine } from "./dspy-rlm-engine-
|
|
16
|
-
import { i as otlpTextToTraceAnalysisStore, r as createOtlpBufferTraceStore, t as DEFAULT_MAX_TRACE_FILE_BYTES } from "./store-otlp-
|
|
15
|
+
import { t as createDspyRlmTraceEngine } from "./dspy-rlm-engine-DCQKNQMn.js";
|
|
16
|
+
import { i as otlpTextToTraceAnalysisStore, r as createOtlpBufferTraceStore, t as DEFAULT_MAX_TRACE_FILE_BYTES } from "./store-otlp-BA7G1Du-.js";
|
|
17
17
|
import { i as summarizeAnalystBenchmarkRunner, n as runAnalystBenchmark, r as traceStoreEvidenceResolver } from "./benchmark-BywPeAUo.js";
|
|
18
18
|
import "./external-optimizer-process-CIV4EqiT.js";
|
|
19
19
|
import { t as assertEqualDeclarativeTerms } from "./equal-terms-Blx9Zk5I.js";
|
|
@@ -1501,6 +1501,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1501
1501
|
"src/ledger-core/trusted-head.ts",
|
|
1502
1502
|
"src/llm-client.ts",
|
|
1503
1503
|
"src/math/normal.ts",
|
|
1504
|
+
"src/math/quantile.ts",
|
|
1504
1505
|
"src/math/special-functions.ts",
|
|
1505
1506
|
"src/math/student-t.ts",
|
|
1506
1507
|
"src/metrics.ts",
|
|
@@ -1509,6 +1510,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1509
1510
|
"src/statistics/descriptive.ts",
|
|
1510
1511
|
"src/statistics/effect-sizes.ts",
|
|
1511
1512
|
"src/statistics/index.ts",
|
|
1513
|
+
"src/statistics/inference.ts",
|
|
1512
1514
|
"src/statistics/internal.ts",
|
|
1513
1515
|
"src/statistics/multiplicity.ts",
|
|
1514
1516
|
"src/statistics/paired-binary.ts",
|
|
@@ -1516,6 +1518,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1516
1518
|
"src/statistics/power-and-mde.ts",
|
|
1517
1519
|
"src/statistics/random.ts",
|
|
1518
1520
|
"src/statistics/rank-tests.ts",
|
|
1521
|
+
"src/statistics/samples.ts",
|
|
1519
1522
|
"src/statistics/sequential-eprocess.ts",
|
|
1520
1523
|
"src/trace-analyst/errors.ts",
|
|
1521
1524
|
"src/trace-analyst/otlp-span.ts",
|
|
@@ -1534,7 +1537,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1534
1537
|
"src/trace/redact.ts",
|
|
1535
1538
|
"src/verdict-cache.ts"
|
|
1536
1539
|
]);
|
|
1537
|
-
const ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 = "
|
|
1540
|
+
const ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 = "67a117a6fa1df65e3407a6c193492dd7aee7a809a95570d83d5b04cb88c9237b";
|
|
1538
1541
|
function analystBenchmarkImplementationDigest() {
|
|
1539
1542
|
return ANALYST_BENCHMARK_IMPLEMENTATION_SHA256;
|
|
1540
1543
|
}
|
|
@@ -6321,4 +6324,4 @@ function shellQuote(value) {
|
|
|
6321
6324
|
//#endregion
|
|
6322
6325
|
export { ANALYST_BENCHMARK_MANIFEST_FILE as $, readAnalystInstructionsOverride as A, parseVerificationOutcome as B, emptyPublicBenchmarkRunner as C, summarizeCodeTraceCalibration as D, renderCodeTraceCalibrationMarkdown as E, publicBenchmarkRlmInstructions as F, ANALYST_BENCHMARK_EVIDENCE_IMPLEMENTATION_SHA256 as G, ANALYST_BENCHMARK_DEPENDENCY_LOCK_FILES as H, publicBenchmarkSystemPrompt as I, ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 as J, ANALYST_BENCHMARK_IMPLEMENTATION_DIGEST_ALGORITHM as K, DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES as L, MAX_INCORRECT_BLOCKS as M, MAX_INCORRECT_BLOCK_STEPS as N, analystInstructionsOverrideFromText as O, publicBenchmarkProtocolSha256 as P, ANALYST_BENCHMARK_LOCAL_RECEIPT_FILE as Q, appendVerificationArtifactsToOtlp as R, adaptPublicBenchmarkFindings as S, readAnalystBenchmarkArtifact as T, ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 as U, ANALYST_BENCHMARK_DEPENDENCY_LOCK_DIGEST_ALGORITHM as V, ANALYST_BENCHMARK_EVIDENCE_DEPENDENCY_LOCK_SHA256 as W, analystBenchmarkImplementationDigest as X, analystBenchmarkDependencyLockDigest as Y, ANALYST_BENCHMARK_COST_LEDGER_FILE as Z, publicDirectAnalystDefinition as _, primeCodeTraceAnalystDefinition as a, codeTraceBenchCase as at, analystDefinitionAsymmetries as b, preparePublicAnalystBenchmark as c, agentRxPredictionsToFindings as ct, selectPublicBenchmarkRows as d, normalizeBenchmarkLabel as dt, ANALYST_BENCHMARK_OBSERVATIONS_FILE as et, createPublicBenchmarkRlmRunner as f, createPublicBenchmarkDirectRunner as g, runReplVariableAnalystDefinition as h, primeAnalystProtocolSha256 as i, summarizeAgentRxCalibration as it, CODE_TRACE_BENCH_ANALYST_PROMPT as j, effectiveAnalystProtocolSha256 as k, publicBenchmarkDistributions as l, normalizeAgentRxCategory as lt, rlmEngineLimits as m, renderAnalystBenchmarkMarkdown as n, AGENT_RX_UPSTREAM_REVISION as nt, runInlineAnalystDefinition as o, codeTracerPredictionsToFindings as ot, publicRlmAnalystDefinition as p, ANALYST_BENCHMARK_IMPLEMENTATION_FILES as q, createPrimeBenchmarkRunner as r, renderAgentRxCalibrationMarkdown as rt, loadPublicBenchmarkRows as s, agentRxBenchmarkCase as st, runAnalystBenchmarkCommand as t, compareAnalystRunners as tt, publicBenchmarkSelectionReport as u, roundAgentRxStep as ut, runChunkedAnalystDefinition as v, expandCodeTraceFailureBlocks as w, analystDefinitionProtocolSha256 as x, AnalystExpressivenessError as y, loadCodeTraceVerificationArtifacts as z };
|
|
6323
6326
|
|
|
6324
|
-
//# sourceMappingURL=benchmark-command-
|
|
6327
|
+
//# sourceMappingURL=benchmark-command-BQhi_BVO.js.map
|