@ac-bench/gate 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE +28 -0
  3. package/README.md +81 -2
  4. package/dist/baseline/compare-environments.d.ts +27 -0
  5. package/dist/baseline/compare-environments.d.ts.map +1 -0
  6. package/dist/baseline/compare-environments.js +60 -0
  7. package/dist/baseline/compare-environments.js.map +1 -0
  8. package/dist/decision/decide.d.ts +16 -0
  9. package/dist/decision/decide.d.ts.map +1 -0
  10. package/dist/decision/decide.js +234 -0
  11. package/dist/decision/decide.js.map +1 -0
  12. package/dist/decision/needs-more-evidence.d.ts +18 -0
  13. package/dist/decision/needs-more-evidence.d.ts.map +1 -0
  14. package/dist/decision/needs-more-evidence.js +34 -0
  15. package/dist/decision/needs-more-evidence.js.map +1 -0
  16. package/dist/declaration/instantiate.d.ts +68 -0
  17. package/dist/declaration/instantiate.d.ts.map +1 -0
  18. package/dist/declaration/instantiate.js +254 -0
  19. package/dist/declaration/instantiate.js.map +1 -0
  20. package/dist/declaration/options.d.ts +36 -0
  21. package/dist/declaration/options.d.ts.map +1 -0
  22. package/dist/declaration/options.js +39 -0
  23. package/dist/declaration/options.js.map +1 -0
  24. package/dist/evaluate-archives.d.ts +45 -0
  25. package/dist/evaluate-archives.d.ts.map +1 -0
  26. package/dist/evaluate-archives.js +195 -0
  27. package/dist/evaluate-archives.js.map +1 -0
  28. package/dist/evidence/_run-order.d.ts +7 -0
  29. package/dist/evidence/_run-order.d.ts.map +1 -0
  30. package/dist/evidence/_run-order.js +9 -0
  31. package/dist/evidence/_run-order.js.map +1 -0
  32. package/dist/evidence/evidence.d.ts +56 -0
  33. package/dist/evidence/evidence.d.ts.map +1 -0
  34. package/dist/evidence/evidence.js +108 -0
  35. package/dist/evidence/evidence.js.map +1 -0
  36. package/dist/exit-code.d.ts +48 -0
  37. package/dist/exit-code.d.ts.map +1 -0
  38. package/dist/exit-code.js +55 -0
  39. package/dist/exit-code.js.map +1 -0
  40. package/dist/index.d.ts +12 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +11 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/test/_stats.d.ts +55 -0
  45. package/dist/test/_stats.d.ts.map +1 -0
  46. package/dist/test/_stats.js +62 -0
  47. package/dist/test/_stats.js.map +1 -0
  48. package/dist/test/test-gate.d.ts +65 -0
  49. package/dist/test/test-gate.d.ts.map +1 -0
  50. package/dist/test/test-gate.js +414 -0
  51. package/dist/test/test-gate.js.map +1 -0
  52. package/package.json +67 -3
@@ -0,0 +1,195 @@
1
+ import { compareEnvironments } from "./baseline/compare-environments.js";
2
+ import { decideGates } from "./decision/decide.js";
3
+ import { instantiateGates } from "./declaration/instantiate.js";
4
+ import { resolveGateOptions } from "./declaration/options.js";
5
+ import { inRunOrder } from "./evidence/_run-order.js";
6
+ import { caseKeyId, evidenceFromArchives } from "./evidence/evidence.js";
7
+ import { benchExitCode } from "./exit-code.js";
8
+ import { settleGate, testGate } from "./test/test-gate.js";
9
+ /**
10
+ * Every case of the pool, once per fork unit. A case is selected when any run
11
+ * selected it (see {@link evidenceFromArchives} for what each run then
12
+ * contributes); a baseline holds the cases its runs selected.
13
+ */
14
+ function catalogOf_(archives, baselines) {
15
+ const cases = new Map();
16
+ for (const archive of archives) {
17
+ for (const condition of archive.conditions) {
18
+ for (const archived of condition.cases) {
19
+ const key = {
20
+ runtime: condition.runtime,
21
+ file: condition.file,
22
+ conditionTitles: condition.titles,
23
+ caseTitle: archived.title,
24
+ };
25
+ const id = JSON.stringify([caseKeyId(key), condition.conditionPath]);
26
+ cases.set(id, {
27
+ key,
28
+ conditionPath: condition.conditionPath,
29
+ measure: condition.measure,
30
+ selected: archived.selected || cases.get(id)?.selected === true,
31
+ });
32
+ }
33
+ }
34
+ }
35
+ return {
36
+ cases: [...cases.values()],
37
+ ...(baselines.length === 0
38
+ ? {}
39
+ : {
40
+ baseline: baselines.flatMap((archive) => archive.conditions.flatMap((condition) => condition.cases
41
+ .filter((archived) => archived.selected)
42
+ .map((archived) => ({
43
+ runtime: condition.runtime,
44
+ file: condition.file,
45
+ conditionTitles: condition.titles,
46
+ caseTitle: archived.title,
47
+ })))),
48
+ }),
49
+ };
50
+ }
51
+ /** The archives among `pool` whose executions `evidence` holds for `keys`. */
52
+ function contributorsOf_(pool, evidence, keys) {
53
+ const runs = new Set(keys.flatMap((key) => evidence.get(key)?.executions.map((execution) => execution.run) ?? []));
54
+ return pool.filter((archive) => runs.has(archive.run.id));
55
+ }
56
+ function declarationsOf_(archives, extra, options) {
57
+ const withNormalizer = (declaration) => declaration.kind === "baseline" &&
58
+ declaration.normalizeBy === undefined &&
59
+ options.normalizeBy !== undefined
60
+ ? { ...declaration, normalizeBy: options.normalizeBy }
61
+ : declaration;
62
+ const all = [
63
+ ...archives.flatMap((archive) => archive.gates.map((gate) => gate.origin === "suite"
64
+ ? gate
65
+ : { ...gate, declaration: withNormalizer(gate.declaration) })),
66
+ ...extra.map((declaration) => ({
67
+ origin: "config",
68
+ declaration: withNormalizer(declaration),
69
+ })),
70
+ ];
71
+ if ((options.baselines?.length ?? 0) > 0 &&
72
+ !all.some((gate) => gate.declaration.kind === "baseline")) {
73
+ all.push({
74
+ origin: "cli",
75
+ declaration: withNormalizer({
76
+ kind: "baseline",
77
+ ...(options.maxRegression === undefined
78
+ ? {}
79
+ : { maxRegression: options.maxRegression }),
80
+ }),
81
+ });
82
+ }
83
+ const seen = new Set();
84
+ return all.filter((gate) => {
85
+ const id = JSON.stringify(gate);
86
+ if (seen.has(id)) {
87
+ return false;
88
+ }
89
+ seen.add(id);
90
+ return true;
91
+ });
92
+ }
93
+ /**
94
+ * Offline: `measure gate run-1.json run-2.json run-3.json`. Pools the archives
95
+ * as more executions and re-evaluates every gate they recorded plus `extra`,
96
+ * against `options.baselines` when there are any.
97
+ *
98
+ * A run and its archive evaluated later give the same verdicts: the online path
99
+ * calls the same instantiation, test and decision.
100
+ *
101
+ * The result does not depend on the order of `archives` or of the baselines:
102
+ * both pool in run id order. A case is selected when any run selected it; a run
103
+ * that filtered a case out contributes nothing to it, so the case is judged on
104
+ * the runs that selected it (failed in all of them is an error, not a skip),
105
+ * and a case no run selected makes its gates `skipped`. A baseline gate
106
+ * compares the environments of the archives that contribute executions to it
107
+ * only, on either side.
108
+ *
109
+ * @returns The verdicts, the exit code, and the references that did not resolve
110
+ * (each makes the exit code 4).
111
+ * @throws {RangeError} When `archives` is empty.
112
+ * @throws {GateDeclarationError} On a contradictory declaration.
113
+ */
114
+ export function evaluateArchives(archives, extra, options = {}) {
115
+ if (archives.length === 0) {
116
+ throw new RangeError("evaluateArchives needs at least one archive");
117
+ }
118
+ const pool = inRunOrder(archives);
119
+ const resolved = resolveGateOptions(options);
120
+ const baselines = inRunOrder(options.baselines ?? []);
121
+ const runtimes = [
122
+ ...new Set(pool.flatMap((archive) => archive.conditions.map((condition) => condition.runtime))),
123
+ ];
124
+ const { instances, errors } = instantiateGates(declarationsOf_(pool, extra, options), catalogOf_(pool, baselines), runtimes);
125
+ const evidence = evidenceFromArchives(pool);
126
+ const baselineEvidence = baselines.length === 0 ? undefined : evidenceFromArchives(baselines);
127
+ const tests = instances.map((instance) => {
128
+ const test = testGate(instance, evidence, resolved, baselineEvidence);
129
+ if (instance.kind !== "baseline" || baselineEvidence === undefined) {
130
+ return test;
131
+ }
132
+ // Only the archives whose executions enter this gate are compared, each
133
+ // current one with each baseline: a pool is as comparable as its least
134
+ // comparable contributing member, and an archive that holds nothing of
135
+ // the gate (another runtime, other cases) has no say.
136
+ const keys = [
137
+ ...instance.subjects,
138
+ ...(instance.normalizer === null ? [] : [instance.normalizer]),
139
+ ];
140
+ const currentContributors = contributorsOf_(pool, evidence, keys);
141
+ const baselineContributors = contributorsOf_(baselines, baselineEvidence, keys);
142
+ const mismatches = [
143
+ ...new Map(currentContributors
144
+ .flatMap((current) => baselineContributors.flatMap((baseline) => compareEnvironments(current, baseline, instance.runtime)
145
+ .mismatches))
146
+ .map((mismatch) => [JSON.stringify(mismatch), mismatch])).values(),
147
+ ];
148
+ if (mismatches.length === 0) {
149
+ return test;
150
+ }
151
+ const fields = mismatches
152
+ .map((mismatch) => `${mismatch.field}: ${mismatch.current} against ${mismatch.baseline}`)
153
+ .join("; ");
154
+ if (options.allowForeignBaseline === true && instance.normalizer !== null) {
155
+ return {
156
+ ...test,
157
+ notes: [
158
+ ...test.notes,
159
+ `baseline from another environment (${fields}): the double ratio against ${instance.normalizer.caseTitle} cancels machine speed to first order, what remains is the relative cost shift between the two machines`,
160
+ ],
161
+ };
162
+ }
163
+ return settleGate(instance, {
164
+ verdict: "incomparable",
165
+ reason: "baseline-environment-mismatch",
166
+ message: options.allowForeignBaseline === true
167
+ ? `the baseline comes from another environment (${fields}) and the gate names no normalizeBy to compare through`
168
+ : `the baseline comes from another environment (${fields}): compare it with allowForeignBaseline and a normalizeBy`,
169
+ });
170
+ });
171
+ const verdicts = decideGates(tests, resolved);
172
+ const cases = archives.flatMap((archive) => archive.conditions.flatMap((condition) => condition.cases));
173
+ const failedScopes = cases.filter((archived) => archived.status === "failed").length +
174
+ archives
175
+ .flatMap((archive) => archive.conditions)
176
+ .filter((condition) => condition.status === "failed").length +
177
+ archives
178
+ .flatMap((archive) => archive.diagnostics)
179
+ .filter((diagnostic) => diagnostic.code === "load-error").length;
180
+ return {
181
+ verdicts,
182
+ errors,
183
+ exitCode: benchExitCode({
184
+ interrupted: false,
185
+ usageErrors: errors.length,
186
+ failedScopes,
187
+ verdicts,
188
+ measuredCases: cases.filter((archived) => archived.status === "measured").length,
189
+ }, {
190
+ allowInconclusive: options.allowInconclusive ??
191
+ archives.every((archive) => archive.run.mode === "quick"),
192
+ }),
193
+ };
194
+ }
195
+ //# sourceMappingURL=evaluate-archives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate-archives.js","sourceRoot":"","sources":["../src/evaluate-archives.ts"],"names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,GACjB,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM;QAC/D,QAAQ;aACN,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;aACxC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM;QAC7D,QAAQ;aACN,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;aACzC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,MAAM,CAAC;IAEnE,OAAO;QACN,QAAQ;QACR,MAAM;QACN,QAAQ,EAAE,aAAa,CACtB;YACC,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,MAAM,CAAC,MAAM;YAC1B,YAAY;YACZ,QAAQ;YACR,aAAa,EAAE,KAAK,CAAC,MAAM,CAC1B,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,KAAK,UAAU,CAC5C,CAAC,MAAM;SACR,EACD;YACC,iBAAiB,EAChB,OAAO,CAAC,iBAAiB;gBACzB,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC;SAC1D,CACD;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { BenchArchive } from "@ac-bench/core/plugin";
2
+ /**
3
+ * `archives` sorted by run id, by code unit: the canonical order of a pool, so
4
+ * that nothing pooled depends on the order the archives were given in.
5
+ */
6
+ export declare function inRunOrder(archives: readonly BenchArchive[]): readonly BenchArchive[];
7
+ //# sourceMappingURL=_run-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_run-order.d.ts","sourceRoot":"","sources":["../../src/evidence/_run-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D;;;GAGG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,SAAS,YAAY,EAAE,GAC/B,SAAS,YAAY,EAAE,CAIzB"}
@@ -0,0 +1,9 @@
1
+ import { compareNaturalAscending } from "@ac-kit/core";
2
+ /**
3
+ * `archives` sorted by run id, by code unit: the canonical order of a pool, so
4
+ * that nothing pooled depends on the order the archives were given in.
5
+ */
6
+ export function inRunOrder(archives) {
7
+ return archives.toSorted((left, right) => compareNaturalAscending(left.run.id, right.run.id));
8
+ }
9
+ //# sourceMappingURL=_run-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_run-order.js","sourceRoot":"","sources":["../../src/evidence/_run-order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,UAAU,CACzB,QAAiC;IAEjC,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACxC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAClD,CAAC;AACH,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { ArchivedCase, BenchArchive, CaseKey, GateMetricDescriptor, GateObservation } from "@ac-bench/core/plugin";
2
+ /** What one execution of a case says about each gate metric. */
3
+ export type ExecutionEvidence = {
4
+ /** The run that produced it: archives pooled together keep their runs apart. */
5
+ readonly run: string;
6
+ /** Executions sharing a process share this key; `null` when alone. */
7
+ readonly processKey: string | null;
8
+ readonly observations: Readonly<Record<string, GateObservation>>;
9
+ };
10
+ /** Every observation of a case, across executions, runs and archives. */
11
+ export type CaseEvidence = {
12
+ readonly key: CaseKey;
13
+ /** The fork unit's position in its file: part of the evidence's identity. */
14
+ readonly conditionPath: readonly number[];
15
+ readonly status: ArchivedCase["status"];
16
+ /**
17
+ * The gate metrics of the first run, in run id order, that contributed
18
+ * executions; of the first that selected it when none did.
19
+ */
20
+ readonly metrics: readonly GateMetricDescriptor[];
21
+ /**
22
+ * The gate metrics each run that contributed executions declares, by run id
23
+ * in run id order: a gate checks they agree before pooling. A run with no
24
+ * kept execution is absent, as it adds nothing to pool.
25
+ */
26
+ readonly metricsByRun: ReadonlyMap<string, readonly GateMetricDescriptor[]>;
27
+ /** Kept executions only: an attempt the run threw away is no evidence. */
28
+ readonly executions: readonly ExecutionEvidence[];
29
+ };
30
+ export interface EvidenceSource {
31
+ get(key: CaseKey): CaseEvidence | undefined;
32
+ }
33
+ /** A case's identity as a string: a JSON tuple, so no title can imitate a part. */
34
+ export declare function caseKeyId(key: CaseKey): string;
35
+ /**
36
+ * Builds evidence from archives: one run, several runs pooled as more
37
+ * executions, or a baseline.
38
+ *
39
+ * A case is looked up by runtime, file, condition titles and title, so the same
40
+ * case of two archives is one case with the executions of both. A case key does
41
+ * not carry the condition's position, so evidence is refused where it would
42
+ * merge distinct fork units: two conditions sharing their titles in one file,
43
+ * or one case at two positions across the pooled archives.
44
+ *
45
+ * The result does not depend on the order of `archives`: they are pooled in run
46
+ * id order. A run whose filter excluded a case contributes nothing to it,
47
+ * neither executions nor status, so a case is judged on the runs that selected
48
+ * it, as each of them alone would judge it; a case no run selected has no
49
+ * evidence. The statuses of the selecting runs merge by precedence: `measured`
50
+ * anywhere, else `failed`, else `not-run`, else `unsupported`.
51
+ *
52
+ * @throws {Error} On an ambiguous case, or when two archives share a run id
53
+ * (the same run replayed is not independent evidence).
54
+ */
55
+ export declare function evidenceFromArchives(archives: readonly BenchArchive[]): EvidenceSource;
56
+ //# sourceMappingURL=evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../../src/evidence/evidence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YA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: a JSON tuple, so no title can imitate a part. */
4
+ export function caseKeyId(key) {
5
+ return JSON.stringify([
6
+ key.runtime,
7
+ key.file,
8
+ key.conditionTitles,
9
+ key.caseTitle,
10
+ ]);
11
+ }
12
+ /**
13
+ * Builds evidence from archives: one run, several runs pooled as more
14
+ * executions, or a baseline.
15
+ *
16
+ * A case is looked up by runtime, file, condition titles and title, so the same
17
+ * case of two archives is one case with the executions of both. A case key does
18
+ * not carry the condition's position, so evidence is refused where it would
19
+ * merge distinct fork units: two conditions sharing their titles in one file,
20
+ * or one case at two positions across the pooled archives.
21
+ *
22
+ * The result does not depend on the order of `archives`: they are pooled in run
23
+ * id order. A run whose filter excluded a case contributes nothing to it,
24
+ * neither executions nor status, so a case is judged on the runs that selected
25
+ * it, as each of them alone would judge it; a case no run selected has no
26
+ * evidence. The statuses of the selecting runs merge by precedence: `measured`
27
+ * anywhere, else `failed`, else `not-run`, else `unsupported`.
28
+ *
29
+ * @throws {Error} On an ambiguous case, or when two archives share a run id
30
+ * (the same run replayed is not independent evidence).
31
+ */
32
+ export function evidenceFromArchives(archives) {
33
+ const cases = new Map();
34
+ const runs = new Set();
35
+ for (const archive of inRunOrder(archives)) {
36
+ if (runs.has(archive.run.id)) {
37
+ throw new Error(`run id "${archive.run.id}" appears in more than one archive: a run replayed is not independent evidence`);
38
+ }
39
+ runs.add(archive.run.id);
40
+ for (const condition of archive.conditions) {
41
+ for (const archived of condition.cases) {
42
+ if (!archived.selected) {
43
+ continue;
44
+ }
45
+ const key = {
46
+ runtime: condition.runtime,
47
+ file: condition.file,
48
+ conditionTitles: condition.titles,
49
+ caseTitle: archived.title,
50
+ };
51
+ const id = caseKeyId(key);
52
+ const executions = archived.executions
53
+ .filter((execution) => execution.disposition === "kept")
54
+ .map((execution) => ({
55
+ run: archive.run.id,
56
+ processKey: execution.processKey,
57
+ observations: execution.observations,
58
+ }));
59
+ const known = cases.get(id);
60
+ if (known !== undefined &&
61
+ !isDeepEqual(known.conditionPath, condition.conditionPath)) {
62
+ throw new Error(`ambiguous case ${JSON.stringify([...condition.titles, archived.title])} in ${condition.file}: conditions at ${JSON.stringify(known.conditionPath)} and ${JSON.stringify(condition.conditionPath)} share their titles`);
63
+ }
64
+ // Only a run that contributes executions says anything about how the
65
+ // case's metrics read; one with none cannot block the pool.
66
+ const contributes = executions.length > 0;
67
+ if (known === undefined) {
68
+ cases.set(id, {
69
+ key,
70
+ conditionPath: condition.conditionPath,
71
+ status: archived.status,
72
+ metrics: condition.metrics,
73
+ metricsByRun: contributes
74
+ ? new Map([[archive.run.id, condition.metrics]])
75
+ : new Map(),
76
+ executions,
77
+ });
78
+ }
79
+ else {
80
+ known.status = mergedStatus_(known.status, archived.status);
81
+ if (contributes) {
82
+ if (known.metricsByRun.size === 0) {
83
+ known.metrics = condition.metrics;
84
+ }
85
+ known.metricsByRun.set(archive.run.id, condition.metrics);
86
+ }
87
+ for (const execution of executions) {
88
+ known.executions.push(execution);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ return { get: (key) => cases.get(caseKeyId(key)) };
95
+ }
96
+ const STATUS_PRECEDENCE_ = [
97
+ "measured",
98
+ "failed",
99
+ "not-run",
100
+ "unsupported",
101
+ ];
102
+ /** Measured anywhere counts as measured; then a failure, then a case not run. */
103
+ function mergedStatus_(known, added) {
104
+ return STATUS_PRECEDENCE_.indexOf(added) < STATUS_PRECEDENCE_.indexOf(known)
105
+ ? added
106
+ : known;
107
+ }
108
+ //# sourceMappingURL=evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence.js","sourceRoot":"","sources":["../../src/evidence/evidence.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAoC7C,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,GAAY;IACrC,OAAO,IAAI,CAAC,SAAS,CAAC;QACrB,GAAG,CAAC,OAAO;QACX,G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,CAAC,MAAM,CAAC,CAAC;oBAC5D,IAAI,WAAW,EAAE,CAAC;wBACjB,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;4BACnC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;wBACnC,CAAC;wBACD,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;oBAC3D,CAAC;oBACD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;wBACpC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAClC,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;AACpD,CAAC;AAYD,MAAM,kBAAkB,GAAsC;IAC7D,UAAU;IACV,QAAQ;IACR,SAAS;IACT,aAAa;CACb,CAAC;AAEF,iFAAiF;AACjF,SAAS,aAAa,CACrB,KAA6B,EAC7B,KAA6B;IAE7B,OAAO,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3E,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,CAAC;AACV,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { GateVerdict } from "@ac-bench/core/plugin";
2
+ export declare const BENCH_EXIT_CODES: {
3
+ /** Every gate passed or reported; nothing failed to measure. */
4
+ readonly success: 0;
5
+ /** At least one gate failed: a threshold exceeded beyond the measured spread. */
6
+ readonly gateFailed: 1;
7
+ /**
8
+ * No failure, at least one gate undecided. `allowInconclusive` turns this
9
+ * into 0.
10
+ */
11
+ readonly inconclusive: 2;
12
+ /**
13
+ * A case, condition or child failed, a file did not load, or a gate's subject
14
+ * is missing.
15
+ */
16
+ readonly measurementError: 3;
17
+ /**
18
+ * Invalid flag, config or gate declaration; unknown runtime; incomparable
19
+ * baseline.
20
+ */
21
+ readonly usageError: 4;
22
+ /** Nothing matched: no file, or every case filtered out. */
23
+ readonly nothingRan: 5;
24
+ /** SIGINT. */
25
+ readonly interrupted: 130;
26
+ };
27
+ export type BenchExitCode = (typeof BENCH_EXIT_CODES)[keyof typeof BENCH_EXIT_CODES];
28
+ export type RunSummary = {
29
+ readonly interrupted: boolean;
30
+ /** Bad flags, config or declarations, and gate references that do not resolve. */
31
+ readonly usageErrors: number;
32
+ /** Cases, conditions, children and files that failed. */
33
+ readonly failedScopes: number;
34
+ readonly verdicts: readonly GateVerdict[];
35
+ readonly measuredCases: number;
36
+ };
37
+ /**
38
+ * The exit code of a run. Precedence: 130 > 4 > 3 > 1 > 2 > 5 > 0.
39
+ *
40
+ * Measurement errors outrank a gate failure because a run with a crashed case
41
+ * has an incomplete gate set: the reader must fix the run before trusting any
42
+ * verdict. An `error` verdict is a measurement error (a subject is missing); an
43
+ * `incomparable` one is a usage error (the baseline cannot be used).
44
+ */
45
+ export declare function benchExitCode(summary: RunSummary, options?: {
46
+ readonly allowInconclusive?: boolean;
47
+ }): BenchExitCode;
48
+ //# sourceMappingURL=exit-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-code.d.ts","sourceRoot":"","sources":["../src/exit-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,eAAO,MAAM,gBAAgB;IAC5B,gEAAgE;aAChE,OAAO,EAAE,CAAC;IACV,iFAAiF;aACjF,UAAU,EAAE,CAAC;IACb;;;OAGG;aACH,YAAY,EAAE,CAAC;IACf;;;OAGG;aACH,gBAAgB,EAAE,CAAC;IACnB;;;OAGG;aACH,UAAU,EAAE,CAAC;IACb,4DAA4D;aAC5D,UAAU,EAAE,CAAC;IACb,cAAc;aACd,WAAW,EAAE,GAAG;CACP,CAAC;AACX,MAAM,MAAM,aAAa,GACxB,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE1D,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC5B,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,GACpD,aAAa,CA2Bf"}
@@ -0,0 +1,55 @@
1
+ export const BENCH_EXIT_CODES = {
2
+ /** Every gate passed or reported; nothing failed to measure. */
3
+ success: 0,
4
+ /** At least one gate failed: a threshold exceeded beyond the measured spread. */
5
+ gateFailed: 1,
6
+ /**
7
+ * No failure, at least one gate undecided. `allowInconclusive` turns this
8
+ * into 0.
9
+ */
10
+ inconclusive: 2,
11
+ /**
12
+ * A case, condition or child failed, a file did not load, or a gate's subject
13
+ * is missing.
14
+ */
15
+ measurementError: 3,
16
+ /**
17
+ * Invalid flag, config or gate declaration; unknown runtime; incomparable
18
+ * baseline.
19
+ */
20
+ usageError: 4,
21
+ /** Nothing matched: no file, or every case filtered out. */
22
+ nothingRan: 5,
23
+ /** SIGINT. */
24
+ interrupted: 130,
25
+ };
26
+ /**
27
+ * The exit code of a run. Precedence: 130 > 4 > 3 > 1 > 2 > 5 > 0.
28
+ *
29
+ * Measurement errors outrank a gate failure because a run with a crashed case
30
+ * has an incomplete gate set: the reader must fix the run before trusting any
31
+ * verdict. An `error` verdict is a measurement error (a subject is missing); an
32
+ * `incomparable` one is a usage error (the baseline cannot be used).
33
+ */
34
+ export function benchExitCode(summary, options = {}) {
35
+ const has = (kind) => summary.verdicts.some((verdict) => verdict.verdict === kind);
36
+ if (summary.interrupted) {
37
+ return BENCH_EXIT_CODES.interrupted;
38
+ }
39
+ if (summary.usageErrors > 0 || has("incomparable")) {
40
+ return BENCH_EXIT_CODES.usageError;
41
+ }
42
+ if (summary.failedScopes > 0 || has("error")) {
43
+ return BENCH_EXIT_CODES.measurementError;
44
+ }
45
+ if (has("fail")) {
46
+ return BENCH_EXIT_CODES.gateFailed;
47
+ }
48
+ if (has("inconclusive") && options.allowInconclusive !== true) {
49
+ return BENCH_EXIT_CODES.inconclusive;
50
+ }
51
+ return summary.measuredCases === 0
52
+ ? BENCH_EXIT_CODES.nothingRan
53
+ : BENCH_EXIT_CODES.success;
54
+ }
55
+ //# sourceMappingURL=exit-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-code.js","sourceRoot":"","sources":["../src/exit-code.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,gEAAgE;IAChE,OAAO,EAAE,CAAC;IACV,iFAAiF;IACjF,UAAU,EAAE,CAAC;IACb;;;OAGG;IACH,YAAY,EAAE,CAAC;IACf;;;OAGG;IACH,gBAAgB,EAAE,CAAC;IACnB;;;OAGG;IACH,UAAU,EAAE,CAAC;IACb,4DAA4D;IAC5D,UAAU,EAAE,CAAC;IACb,cAAc;IACd,WAAW,EAAE,GAAG;CACP,CAAC;AAcX;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC5B,OAAmB,EACnB,OAAO,GAA6C,EAAE;IAEtD,MAAM,GAAG,GAAG,CAAC,IAA4B,EAAW,EAAE,CACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;IAE9D,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,OAAO,gBAAgB,CAAC,WAAW,CAAC;IACrC,CAAC;IAED,IAAI,OAAO,CAAC,WAAW,GAAG,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QACpD,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACpC,CAAC;IAED,IAAI,OAAO,CAAC,YAAY,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9C,OAAO,gBAAgB,CAAC,gBAAgB,CAAC;IAC1C,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACjB,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACpC,CAAC;IAED,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,iBAAiB,KAAK,IAAI,EAAE,CAAC;QAC/D,OAAO,gBAAgB,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,OAAO,OAAO,CAAC,aAAa,KAAK,CAAC;QACjC,CAAC,CAAC,gBAAgB,CAAC,UAAU;QAC7B,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from "./baseline/compare-environments.js";
2
+ export * from "./decision/decide.js";
3
+ export * from "./decision/needs-more-evidence.js";
4
+ export * from "./declaration/instantiate.js";
5
+ export * from "./declaration/options.js";
6
+ export * from "./evaluate-archives.js";
7
+ export * from "./evidence/evidence.js";
8
+ export * from "./exit-code.js";
9
+ export * from "./test/test-gate.js";
10
+ export type { LocatedGateDeclaration, GateVerdict, GateVerdictKind, GateReason, GateThreshold, } from "@ac-bench/core/plugin";
11
+ export { GateReferenceError } from "@ac-bench/core/plugin";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAEpC,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,UAAU,EACV,aAAa,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from "./baseline/compare-environments.js";
2
+ export * from "./decision/decide.js";
3
+ export * from "./decision/needs-more-evidence.js";
4
+ export * from "./declaration/instantiate.js";
5
+ export * from "./declaration/options.js";
6
+ export * from "./evaluate-archives.js";
7
+ export * from "./evidence/evidence.js";
8
+ export * from "./exit-code.js";
9
+ export * from "./test/test-gate.js";
10
+ export { GateReferenceError } from "@ac-bench/core/plugin";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AASpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { ResolvedGateOptions } from "../declaration/options.js";
2
+ /** One execution's estimate on the scale the test runs on, and its variance. */
3
+ export type ScaledObservation = {
4
+ readonly y: number;
5
+ readonly v: number;
6
+ readonly run: string;
7
+ readonly processKey: string | null;
8
+ readonly dispersion: number | null;
9
+ };
10
+ /**
11
+ * An estimate, the variance of that estimate and the degrees of freedom behind
12
+ * it: a term `combineIndependentEstimates` takes.
13
+ */
14
+ export type Estimate = {
15
+ readonly estimate: number;
16
+ readonly variance: number;
17
+ readonly degreesOfFreedom: number;
18
+ };
19
+ /**
20
+ * Pools executions under a random-effects model: the between-execution spread
21
+ * is the uncertainty, the within-execution variance only a weight.
22
+ *
23
+ * @param groups At least two.
24
+ */
25
+ export declare function poolExecutions(groups: readonly {
26
+ readonly y: number;
27
+ readonly v: number;
28
+ }[], options: ResolvedGateOptions): Estimate;
29
+ /** Two-sided p-value of `statistic` under Student's t (normal when infinite). */
30
+ export declare function twoSidedPValue(statistic: number, degreesOfFreedom: number): number;
31
+ /** The upper `1 − tail` quantile of Student's t (normal when infinite). */
32
+ export declare function criticalValue(degreesOfFreedom: number, tail: number): number;
33
+ export type ProcessModes = {
34
+ readonly low: {
35
+ readonly centre: number;
36
+ readonly count: number;
37
+ };
38
+ readonly high: {
39
+ readonly centre: number;
40
+ readonly count: number;
41
+ };
42
+ };
43
+ /**
44
+ * Whether executions of one subject fall in two groups: the largest gap between
45
+ * neighbours exceeds four times the larger of the two sides' MAD and the
46
+ * within-execution standard error, and each side holds at least two
47
+ * executions.
48
+ *
49
+ * Hartung–Knapp already widens the interval for it; this says why it is wide.
50
+ */
51
+ export declare function processModes(groups: readonly {
52
+ readonly y: number;
53
+ readonly v: number;
54
+ }[]): ProcessModes | null;
55
+ //# sourceMappingURL=_stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_stats.d.ts","sourceRoot":"","sources":["../../src/test/_stats.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,gFAAgF;AAChF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ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