eutaxy 0.17.1 → 0.18.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/README.md +6 -6
- package/dist/aws.d.mts +2 -2
- package/dist/aws.mjs +2 -2
- package/dist/bin.mjs +1 -1
- package/dist/{cli-CxbXc1j2.mjs → cli-DyA7uTBg.mjs} +801 -449
- package/dist/cli-DyA7uTBg.mjs.map +1 -0
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cloudflare.d.mts +22 -3
- package/dist/cloudflare.d.mts.map +1 -1
- package/dist/cloudflare.mjs +3 -3
- package/dist/{delivery-invariants-DO3j1mmD.mjs → delivery-invariants-BRwfZJrs.mjs} +2 -2
- package/dist/{delivery-invariants-DO3j1mmD.mjs.map → delivery-invariants-BRwfZJrs.mjs.map} +1 -1
- package/dist/{delivery-invariants-D7DI7i8x.d.mts → delivery-invariants-D-_GPOqE.d.mts} +2 -2
- package/dist/{delivery-invariants-D7DI7i8x.d.mts.map → delivery-invariants-D-_GPOqE.d.mts.map} +1 -1
- package/dist/{explore-CkKiOuz6.d.mts → explore-D33RP9hF.d.mts} +43 -8
- package/dist/explore-D33RP9hF.d.mts.map +1 -0
- package/dist/index.d.mts +11 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{platform-D4hlJjm3.d.mts → platform-CawKCUru.d.mts} +69 -2
- package/dist/platform-CawKCUru.d.mts.map +1 -0
- package/dist/{src-fxWc6oGc.mjs → src-H1Q8ytEx.mjs} +50 -6
- package/dist/src-H1Q8ytEx.mjs.map +1 -0
- package/dist/{src-D_hHC_-3.mjs → src-Whn0RMSh.mjs} +406 -51
- package/dist/src-Whn0RMSh.mjs.map +1 -0
- package/dist/{workerd-DhrzU6AZ.mjs → workerd-tI8INa6v.mjs} +43 -9
- package/dist/workerd-tI8INa6v.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/cli-CxbXc1j2.mjs.map +0 -1
- package/dist/explore-CkKiOuz6.d.mts.map +0 -1
- package/dist/platform-D4hlJjm3.d.mts.map +0 -1
- package/dist/src-D_hHC_-3.mjs.map +0 -1
- package/dist/src-fxWc6oGc.mjs.map +0 -1
- package/dist/workerd-DhrzU6AZ.mjs.map +0 -1
|
@@ -129,6 +129,80 @@ function serializeLog(log) {
|
|
|
129
129
|
payload: e.payload
|
|
130
130
|
})).join("\n");
|
|
131
131
|
}
|
|
132
|
+
// packages/core/src/fault-sites.ts
|
|
133
|
+
/**
|
|
134
|
+
* Fault sites: where a scenario's bounds let faults go. A run spends its
|
|
135
|
+
* faults only at effect points a site matches, and only of the kinds the
|
|
136
|
+
* matching sites list, so a bug that needs faults at a few chosen points
|
|
137
|
+
* (every attempt of one step) is not left to the odds of sampling among
|
|
138
|
+
* every point a run has.
|
|
139
|
+
*/
|
|
140
|
+
/** Every fault kind, in the order the fault model lists them. */
|
|
141
|
+
const faultKinds = [
|
|
142
|
+
"crash_before",
|
|
143
|
+
"crash_after",
|
|
144
|
+
"ambiguous",
|
|
145
|
+
"error",
|
|
146
|
+
"cut_off"
|
|
147
|
+
];
|
|
148
|
+
/** Every reason the sites are not usable, under `bounds.faultsAt`; empty when they are. */
|
|
149
|
+
function validateFaultSites(sites) {
|
|
150
|
+
if (sites.length === 0) return ["bounds.faultsAt must name at least one site; leave it out for faults anywhere"];
|
|
151
|
+
return sites.flatMap((site, i) => siteErrors(site, `bounds.faultsAt[${i}]`));
|
|
152
|
+
}
|
|
153
|
+
/** Every reason one site is not usable, each message starting with `label`, where it sits in the scenario. */
|
|
154
|
+
function siteErrors(site, label) {
|
|
155
|
+
const errors = [];
|
|
156
|
+
if (!site.target) errors.push(`${label} needs a target`);
|
|
157
|
+
for (const field of ["where", "atLeast"]) for (const path of Object.keys(site[field] ?? {})) if (path !== "args" && !path.startsWith("args.")) errors.push(`${label}.${field}: ${JSON.stringify(path)} is not a path into the call's arguments; a site matches the call, so its paths start with "args."`);
|
|
158
|
+
if (site.faults === void 0) return errors;
|
|
159
|
+
if (site.faults.length === 0) errors.push(`${label}.faults must name at least one fault kind; leave it out for every kind`);
|
|
160
|
+
for (const f of site.faults) if (!faultKinds.includes(f)) errors.push(`${label}.faults: ${JSON.stringify(f)} is not a fault kind (${faultKinds.join(", ")})`);
|
|
161
|
+
return errors;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The sites prepared once: for a point, the kinds it allows that some
|
|
165
|
+
* matching site lists, in the point's own order; none when no site matches.
|
|
166
|
+
* Without sites, a point keeps every kind it allows.
|
|
167
|
+
*/
|
|
168
|
+
function compileFaultSites(sites) {
|
|
169
|
+
if (sites === void 0) return (point) => point.allowed;
|
|
170
|
+
const compiled = sites.map(({ target, op, where, atLeast, faults }) => ({
|
|
171
|
+
matches: compileSelector({
|
|
172
|
+
target,
|
|
173
|
+
...op === void 0 ? {} : { op },
|
|
174
|
+
...where === void 0 ? {} : { where },
|
|
175
|
+
...atLeast === void 0 ? {} : { atLeast }
|
|
176
|
+
}),
|
|
177
|
+
faults
|
|
178
|
+
}));
|
|
179
|
+
return (point) => {
|
|
180
|
+
const record = {
|
|
181
|
+
seq: 0,
|
|
182
|
+
kind: "call",
|
|
183
|
+
invocation: "",
|
|
184
|
+
target: point.target,
|
|
185
|
+
op: point.op,
|
|
186
|
+
payload: { args: point.args }
|
|
187
|
+
};
|
|
188
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
189
|
+
for (const { matches, faults } of compiled) {
|
|
190
|
+
if (!matches(record)) continue;
|
|
191
|
+
for (const f of faults ?? point.allowed) kinds.add(f);
|
|
192
|
+
}
|
|
193
|
+
return point.allowed.filter((f) => kinds.has(f));
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/** One line for a verdict's assumptions: which faults the sites let through, and where. */
|
|
197
|
+
function describeFaultSites(sites) {
|
|
198
|
+
const one = (s) => {
|
|
199
|
+
const kinds = s.faults === void 0 ? "any fault" : s.faults.join(" or ");
|
|
200
|
+
const where = s.where === void 0 ? "" : ` where ${canonicalJson(s.where)}`;
|
|
201
|
+
const atLeast = s.atLeast === void 0 ? "" : ` at least ${canonicalJson(s.atLeast)}`;
|
|
202
|
+
return `${kinds} at ${s.target}${s.op === void 0 ? "" : ` ${s.op}`}${where}${atLeast}`;
|
|
203
|
+
};
|
|
204
|
+
return `faults only where the scenario's bounds say: ${sites.map(one).join("; ")}`;
|
|
205
|
+
}
|
|
132
206
|
// packages/core/src/prng.ts
|
|
133
207
|
function rotl(x, k) {
|
|
134
208
|
return (x << k | x >>> 32 - k) >>> 0;
|
|
@@ -561,6 +635,55 @@ function checkInvariants(log, invariants) {
|
|
|
561
635
|
}
|
|
562
636
|
return out;
|
|
563
637
|
}
|
|
638
|
+
// packages/core/src/pinned-schedules.ts
|
|
639
|
+
/**
|
|
640
|
+
* Pinned schedules: runs a scenario carries, each placing its faults at
|
|
641
|
+
* calls it names by what stays put in a run (a call's target, method and
|
|
642
|
+
* arguments, and its number among the calls that match), so a schedule
|
|
643
|
+
* found once is checked on every run of the command, however the faults
|
|
644
|
+
* placed before a call move the invocations and positions a recorded
|
|
645
|
+
* schedule names.
|
|
646
|
+
*/
|
|
647
|
+
/** The seeds a pinned schedule runs under. */
|
|
648
|
+
function pinnedSeeds(pinned) {
|
|
649
|
+
return pinned.seeds ?? [0];
|
|
650
|
+
}
|
|
651
|
+
/** Every reason the pinned schedules are not usable, under `pinned`; empty when they are. */
|
|
652
|
+
function validatePinnedSchedules(pinned) {
|
|
653
|
+
if (pinned.length === 0) return ["pinned must name at least one schedule; leave it out for none"];
|
|
654
|
+
const errors = [];
|
|
655
|
+
const names = /* @__PURE__ */ new Set();
|
|
656
|
+
pinned.forEach((p, i) => {
|
|
657
|
+
const label = `pinned[${i}]`;
|
|
658
|
+
if (!p.name) errors.push(`${label} needs a name`);
|
|
659
|
+
else if (names.has(p.name)) errors.push(`duplicate pinned schedule ${JSON.stringify(p.name)}`);
|
|
660
|
+
names.add(p.name);
|
|
661
|
+
p.faults.forEach((f, j) => {
|
|
662
|
+
const at = `${label}.faults[${j}]`;
|
|
663
|
+
errors.push(...siteErrors(f.at, `${at}.at`));
|
|
664
|
+
if (f.at.faults !== void 0) errors.push(`${at}.at.faults: a pinned fault names its one kind in fault; leave it out`);
|
|
665
|
+
if (!faultKinds.includes(f.fault)) errors.push(`${at}.fault: ${JSON.stringify(f.fault)} is not a fault kind (${faultKinds.join(", ")})`);
|
|
666
|
+
if (f.call !== void 0 && !(Number.isInteger(f.call) && f.call >= 1)) errors.push(`${at}.call counts from 1, got ${String(f.call)}`);
|
|
667
|
+
});
|
|
668
|
+
if (p.seeds !== void 0) {
|
|
669
|
+
if (p.seeds.length === 0) errors.push(`${label}.seeds must name at least one seed; leave it out for seed 0`);
|
|
670
|
+
for (const s of p.seeds) if (!(Number.isInteger(s) && s >= 0 && s <= 4294967295)) errors.push(`${label}.seeds: ${String(s)} is not a run seed (an integer, 0 to 2^32 - 1)`);
|
|
671
|
+
}
|
|
672
|
+
for (const t of p.turns ?? []) if (!(Number.isInteger(t) && t >= 0)) errors.push(`${label}.turns: ${String(t)} is not a turn (an index from 0)`);
|
|
673
|
+
});
|
|
674
|
+
return errors;
|
|
675
|
+
}
|
|
676
|
+
/** One pinned fault for people: its kind, the calls it may hit, and which of them. */
|
|
677
|
+
function describePinnedFault(f) {
|
|
678
|
+
const { target, op, where, atLeast } = f.at;
|
|
679
|
+
return [
|
|
680
|
+
`${f.fault} at ${target}`,
|
|
681
|
+
op === void 0 ? "" : ` ${op}`,
|
|
682
|
+
where === void 0 ? "" : ` where ${canonicalJson(where)}`,
|
|
683
|
+
atLeast === void 0 ? "" : ` at least ${canonicalJson(atLeast)}`,
|
|
684
|
+
`, call ${f.call ?? 1}`
|
|
685
|
+
].join("");
|
|
686
|
+
}
|
|
564
687
|
// packages/core/src/scenario.ts
|
|
565
688
|
const defaultBounds = {
|
|
566
689
|
maxFaultsPerRun: 1,
|
|
@@ -612,6 +735,8 @@ function validateScenario(spec) {
|
|
|
612
735
|
if (!(Number.isInteger(v) && v >= 0)) errors.push(`bounds.${k} must be a non-negative integer`);
|
|
613
736
|
}
|
|
614
737
|
for (const k of ["maxConcurrentInvocations", "budgetMs"]) if (!isPositiveInt(spec.bounds[k])) errors.push(`bounds.${k} must be a positive integer`);
|
|
738
|
+
if (spec.bounds.faultsAt !== void 0) errors.push(...validateFaultSites(spec.bounds.faultsAt));
|
|
739
|
+
if (spec.pinned !== void 0) errors.push(...validatePinnedSchedules(spec.pinned));
|
|
615
740
|
return errors;
|
|
616
741
|
}
|
|
617
742
|
// packages/core/src/shrink.ts
|
|
@@ -778,6 +903,66 @@ function replayChooser(schedule) {
|
|
|
778
903
|
};
|
|
779
904
|
}
|
|
780
905
|
/**
|
|
906
|
+
* Choices a pinned schedule makes: each of its faults at the `call`-th
|
|
907
|
+
* point of the run whose call its address matches (counting the points put
|
|
908
|
+
* to the chooser, in the order the run reaches them), none elsewhere, and
|
|
909
|
+
* turns from the seed as a seeded run draws them (or the schedule's own
|
|
910
|
+
* turns, when it has them), so a pinned schedule is replayed by its run's
|
|
911
|
+
* recorded schedule. When two of its faults want one point, the first
|
|
912
|
+
* listed takes it.
|
|
913
|
+
*/
|
|
914
|
+
function pinnedChooser(pinned, seed) {
|
|
915
|
+
const matchers = pinned.faults.map((f) => compileFaultSites([f.at]));
|
|
916
|
+
const counts = pinned.faults.map(() => 0);
|
|
917
|
+
/** Per fault: "placed", why it could not be at its call, or null while its call has not come. */
|
|
918
|
+
const outcomes = pinned.faults.map(() => null);
|
|
919
|
+
let turns = seedPrng(`turns:${seed}`);
|
|
920
|
+
const recorded = pinned.turns;
|
|
921
|
+
let replayed = 0;
|
|
922
|
+
return {
|
|
923
|
+
seed,
|
|
924
|
+
recordsTurns: recorded !== void 0,
|
|
925
|
+
choose(kind, options) {
|
|
926
|
+
if (kind === "turn") {
|
|
927
|
+
if (options.length < 2) return 0;
|
|
928
|
+
if (recorded) return recorded[replayed++] ?? 0;
|
|
929
|
+
const [i, next] = nextInt(turns, options.length);
|
|
930
|
+
turns = next;
|
|
931
|
+
return i;
|
|
932
|
+
}
|
|
933
|
+
const call = options[0]?.call;
|
|
934
|
+
if (call === void 0 || options.length < 2) return 0;
|
|
935
|
+
const allowed = options.slice(1).map((o) => o.label);
|
|
936
|
+
let taken = 0;
|
|
937
|
+
pinned.faults.forEach((f, j) => {
|
|
938
|
+
if (matchers[j]?.({
|
|
939
|
+
...call,
|
|
940
|
+
allowed
|
|
941
|
+
}).length === 0) return;
|
|
942
|
+
const n = (counts[j] ?? 0) + 1;
|
|
943
|
+
counts[j] = n;
|
|
944
|
+
if (n !== (f.call ?? 1)) return;
|
|
945
|
+
const i = options.findIndex((o) => o.label === f.fault);
|
|
946
|
+
if (i < 1) outcomes[j] = `met call ${n}, which allows only ${allowed.join(", ")}`;
|
|
947
|
+
else if (taken > 0) outcomes[j] = `met call ${n}, which an earlier fault of the schedule took`;
|
|
948
|
+
else {
|
|
949
|
+
taken = i;
|
|
950
|
+
outcomes[j] = "placed";
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
return taken;
|
|
954
|
+
},
|
|
955
|
+
unplaced() {
|
|
956
|
+
return pinned.faults.flatMap((f, j) => {
|
|
957
|
+
const outcome = outcomes[j];
|
|
958
|
+
if (outcome === "placed") return [];
|
|
959
|
+
const why = outcome ?? `met no such call: the run made ${counts[j]} matching call(s)`;
|
|
960
|
+
return [`fault ${j + 1} (${describePinnedFault(f)}) ${why}`];
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
781
966
|
* The chooser under the run's fault bound: once it has taken `max` faults,
|
|
782
967
|
* no further fault decision is put to it (the enumerator then sees no
|
|
783
968
|
* choice there).
|
|
@@ -2125,6 +2310,12 @@ var Run = class {
|
|
|
2125
2310
|
*/
|
|
2126
2311
|
logView = null;
|
|
2127
2312
|
faults = [];
|
|
2313
|
+
/**
|
|
2314
|
+
* The call at each point put to the chooser, in order, and the position among them of each
|
|
2315
|
+
* fault taken: what `asPinned` addresses the faults by, worked out only when asked.
|
|
2316
|
+
*/
|
|
2317
|
+
eligibleCalls = [];
|
|
2318
|
+
faultPositions = [];
|
|
2128
2319
|
effectIndex = 0;
|
|
2129
2320
|
eligibleSeen = 0;
|
|
2130
2321
|
invocations = /* @__PURE__ */ new Map();
|
|
@@ -2192,8 +2383,11 @@ var Run = class {
|
|
|
2192
2383
|
/** Whether several invocations may be in flight (`maxConcurrentInvocations` above 1). */
|
|
2193
2384
|
concurrent;
|
|
2194
2385
|
options;
|
|
2386
|
+
/** The kinds a point may take under the bounds' fault sites (all it allows, without sites). */
|
|
2387
|
+
sited;
|
|
2195
2388
|
constructor(options) {
|
|
2196
2389
|
this.options = options;
|
|
2390
|
+
this.sited = compileFaultSites(options.bounds.faultsAt);
|
|
2197
2391
|
this.turns = new Turns(options.chooser, this.frames, (id) => this.runAs(id), () => this.patched?.reads, () => this.firedPending() + this.releasedUnseen(), () => this.hasAfterWork(), () => this.timersAllowed() !== null || this.idleBehindParked());
|
|
2198
2392
|
this.concurrent = options.bounds.maxConcurrentInvocations > 1;
|
|
2199
2393
|
}
|
|
@@ -2210,6 +2404,42 @@ var Run = class {
|
|
|
2210
2404
|
...recordsTurns ? { turns: [...this.turns.picks] } : {}
|
|
2211
2405
|
};
|
|
2212
2406
|
}
|
|
2407
|
+
/**
|
|
2408
|
+
* The run as a pinned schedule: each fault taken at the call it hit, by that call's target, op
|
|
2409
|
+
* and arguments and its number among the run's calls with all three the same (counting the points
|
|
2410
|
+
* put to the chooser, as `pinnedChooser` counts them), under the run's seed and, when it recorded
|
|
2411
|
+
* them, its turns.
|
|
2412
|
+
*/
|
|
2413
|
+
asPinned(name) {
|
|
2414
|
+
const { schedule } = this;
|
|
2415
|
+
return {
|
|
2416
|
+
name,
|
|
2417
|
+
faults: schedule.faults.map((f, k) => {
|
|
2418
|
+
const at = this.faultPositions[k] ?? 0;
|
|
2419
|
+
const call = this.eligibleCalls[at] ?? {
|
|
2420
|
+
target: f.target,
|
|
2421
|
+
op: f.op,
|
|
2422
|
+
args: null
|
|
2423
|
+
};
|
|
2424
|
+
let n = 0;
|
|
2425
|
+
for (let i = 0; i <= at; i++) {
|
|
2426
|
+
const c = this.eligibleCalls[i];
|
|
2427
|
+
if (c && c.target === call.target && c.op === call.op && jsonEqual(c.args, call.args)) n++;
|
|
2428
|
+
}
|
|
2429
|
+
return {
|
|
2430
|
+
at: {
|
|
2431
|
+
target: call.target,
|
|
2432
|
+
op: call.op,
|
|
2433
|
+
where: { args: call.args }
|
|
2434
|
+
},
|
|
2435
|
+
call: n,
|
|
2436
|
+
fault: f.fault
|
|
2437
|
+
};
|
|
2438
|
+
}),
|
|
2439
|
+
seeds: [schedule.seed],
|
|
2440
|
+
...schedule.turns === void 0 ? {} : { turns: schedule.turns }
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2213
2443
|
get effectPoints() {
|
|
2214
2444
|
return this.effectIndex;
|
|
2215
2445
|
}
|
|
@@ -2766,22 +2996,33 @@ var Run = class {
|
|
|
2766
2996
|
get eligiblePoints() {
|
|
2767
2997
|
return this.eligibleSeen;
|
|
2768
2998
|
}
|
|
2769
|
-
/**
|
|
2999
|
+
/**
|
|
3000
|
+
* The fault at an eligible point, if any: the chooser's pick among none and the kinds the point
|
|
3001
|
+
* allows that the bounds' fault sites let through. A point no site matches is not eligible.
|
|
3002
|
+
*/
|
|
2770
3003
|
decide(point, ordinal) {
|
|
2771
|
-
|
|
3004
|
+
const allowed = this.sited(point);
|
|
3005
|
+
if (allowed.length === 0) return null;
|
|
2772
3006
|
this.eligibleSeen++;
|
|
3007
|
+
const call = {
|
|
3008
|
+
target: point.target,
|
|
3009
|
+
op: point.op,
|
|
3010
|
+
args: point.args
|
|
3011
|
+
};
|
|
3012
|
+
this.eligibleCalls.push(call);
|
|
2773
3013
|
const at = {
|
|
2774
3014
|
invocation: point.invocation,
|
|
2775
|
-
ordinal
|
|
3015
|
+
ordinal,
|
|
3016
|
+
call
|
|
2776
3017
|
};
|
|
2777
3018
|
const i = this.options.chooser.choose("fault", [{
|
|
2778
3019
|
label: "none",
|
|
2779
3020
|
...at
|
|
2780
|
-
}, ...
|
|
3021
|
+
}, ...allowed.map((fault) => ({
|
|
2781
3022
|
label: fault,
|
|
2782
3023
|
...at
|
|
2783
3024
|
}))]);
|
|
2784
|
-
return i === 0 ? null :
|
|
3025
|
+
return i === 0 ? null : allowed[i - 1] ?? null;
|
|
2785
3026
|
}
|
|
2786
3027
|
/** Append one record, with the next sequence number: O(1), so a long run's log stays cheap. */
|
|
2787
3028
|
append(effect) {
|
|
@@ -2807,13 +3048,16 @@ var Run = class {
|
|
|
2807
3048
|
const ordinal = inv.ordinal++;
|
|
2808
3049
|
this.record(point, "call", { args: point.args });
|
|
2809
3050
|
const fault = this.decide(point, ordinal);
|
|
2810
|
-
if (fault)
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
3051
|
+
if (fault) {
|
|
3052
|
+
this.faultPositions.push(this.eligibleCalls.length - 1);
|
|
3053
|
+
this.faults.push({
|
|
3054
|
+
invocation: point.invocation,
|
|
3055
|
+
ordinal,
|
|
3056
|
+
fault,
|
|
3057
|
+
target: point.target,
|
|
3058
|
+
op: point.op
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
2817
3061
|
return fault;
|
|
2818
3062
|
}
|
|
2819
3063
|
async effect(point, perform, summarize, options = {}) {
|
|
@@ -3681,9 +3925,17 @@ async function shrink(spec, platform, schedule, violation, trace, options) {
|
|
|
3681
3925
|
* an invariant breaks or the budget is spent; replay any violation before
|
|
3682
3926
|
* reporting it.
|
|
3683
3927
|
*/
|
|
3928
|
+
/** Where faults go: at any effect point, or only where the bounds' fault sites say. */
|
|
3929
|
+
function faultAssumption(bounds) {
|
|
3930
|
+
return `${bounds.faultsAt === void 0 ? "faults: crash_before, crash_after, ambiguous, error at any effect point" : describeFaultSites(bounds.faultsAt)}; redelivery per the platform's queue model`;
|
|
3931
|
+
}
|
|
3932
|
+
/** What the pinned schedules ran before exploration: each one's name, seeds and faults. */
|
|
3933
|
+
function pinnedAssumption(pinned) {
|
|
3934
|
+
const one = (p) => `${JSON.stringify(p.name)} under seed(s) ${pinnedSeeds(p).join(", ")}: ${p.faults.map(describePinnedFault).join("; ")}`;
|
|
3935
|
+
return `pinned schedules ran before exploration, each fault at the call it names, however many faults the bounds allow a run: ${pinned.map(one).join(" | ")}`;
|
|
3936
|
+
}
|
|
3684
3937
|
const engineAssumptions = [
|
|
3685
3938
|
"schedule points are effect boundaries: proxied bindings, patched timers and fetch; other awaits run in program order",
|
|
3686
|
-
"faults: crash_before, crash_after, ambiguous, error at any effect point; redelivery per the platform's queue model",
|
|
3687
3939
|
"Date, Math.random, crypto.randomUUID, crypto.getRandomValues, performance.now and timers are virtualised per run from the seed; time starts at 2026-01-01T00:00:00Z and advances 1 ms per effect and to each timer's due time",
|
|
3688
3940
|
"timers fire in due order; one at a time, only while the invocation is idle (no effect in flight); with several in flight, as the concurrency assumption says; an invocation waiting on something outside Eutaxy makes the run UNSUPPORTED",
|
|
3689
3941
|
"an effect whose real I/O takes longer than the time budget (the scenario's budgetMs, or the budgetMs option replacing it) is treated as hung: the run is UNSUPPORTED and names the effect",
|
|
@@ -3869,14 +4121,42 @@ async function replayRun(spec, platform, schedule) {
|
|
|
3869
4121
|
await runOnce(spec, platform, run);
|
|
3870
4122
|
return run;
|
|
3871
4123
|
}
|
|
4124
|
+
/** One run of a pinned schedule under one seed: the run, its chooser and its log. */
|
|
4125
|
+
async function pinnedRun(spec, platform, pinned, seed) {
|
|
4126
|
+
const chooser = pinnedChooser(pinned, seed);
|
|
4127
|
+
const run = new Run({
|
|
4128
|
+
bounds: spec.bounds,
|
|
4129
|
+
chooser
|
|
4130
|
+
});
|
|
4131
|
+
return {
|
|
4132
|
+
run,
|
|
4133
|
+
chooser,
|
|
4134
|
+
log: await runOnce(spec, platform, run)
|
|
4135
|
+
};
|
|
4136
|
+
}
|
|
4137
|
+
/**
|
|
4138
|
+
* Run a pinned schedule once, under `seed` (default its first), each fault at the call it names:
|
|
4139
|
+
* the replay of an `UNSUPPORTED` verdict's `replay`, or of one of a scenario's pinned schedules.
|
|
4140
|
+
*/
|
|
4141
|
+
async function runPinned(spec, platform, pinned, seed = pinnedSeeds(pinned)[0] ?? 0) {
|
|
4142
|
+
const errors = validatePinnedSchedules([pinned]);
|
|
4143
|
+
if (errors.length > 0) throw new Error(errors.join("; "));
|
|
4144
|
+
const { run, chooser, log } = await pinnedRun(spec, platform, pinned, seed);
|
|
4145
|
+
return {
|
|
4146
|
+
log,
|
|
4147
|
+
schedule: run.schedule,
|
|
4148
|
+
unsupportedReasons: run.unsupportedReasons,
|
|
4149
|
+
unplaced: chooser.unplaced()
|
|
4150
|
+
};
|
|
4151
|
+
}
|
|
3872
4152
|
/** Re-run a recorded schedule exactly. */
|
|
3873
4153
|
async function replay(spec, platform, schedule) {
|
|
3874
4154
|
return (await replayRun(spec, platform, schedule)).log;
|
|
3875
4155
|
}
|
|
3876
4156
|
/**
|
|
3877
|
-
* Explore a scenario on a platform: run it under schedules drawn from the
|
|
3878
|
-
* the bounds, when exhaustive), shrink the first violation
|
|
3879
|
-
* unless `maxRuns` says otherwise.
|
|
4157
|
+
* Explore a scenario on a platform: run its pinned schedules, then run it under schedules drawn from the
|
|
4158
|
+
* seed (or every schedule within the bounds, when exhaustive), shrink the first violation exploration
|
|
4159
|
+
* found, and return the verdict. At most 100 runs of exploration unless `maxRuns` says otherwise.
|
|
3880
4160
|
*/
|
|
3881
4161
|
async function explore(scenario, platform, options) {
|
|
3882
4162
|
const budgetMs = options.budgetMs;
|
|
@@ -3888,13 +4168,18 @@ async function explore(scenario, platform, options) {
|
|
|
3888
4168
|
budgetMs
|
|
3889
4169
|
}
|
|
3890
4170
|
};
|
|
4171
|
+
const specErrors = [...spec.bounds.faultsAt === void 0 ? [] : validateFaultSites(spec.bounds.faultsAt), ...spec.pinned === void 0 ? [] : validatePinnedSchedules(spec.pinned)];
|
|
4172
|
+
if (specErrors.length > 0) throw new Error(specErrors.join("; "));
|
|
3891
4173
|
const now = options.now ?? (() => Date.now());
|
|
3892
4174
|
const maxRuns = options.maxRuns ?? 100;
|
|
3893
4175
|
const faultProbability = options.faultProbability ?? .9;
|
|
3894
4176
|
const assumptions = [
|
|
3895
|
-
...engineAssumptions,
|
|
4177
|
+
...engineAssumptions.slice(0, 1),
|
|
4178
|
+
faultAssumption(spec.bounds),
|
|
4179
|
+
...engineAssumptions.slice(1),
|
|
3896
4180
|
concurrencyAssumption(spec.bounds),
|
|
3897
4181
|
...explorationAssumption(options),
|
|
4182
|
+
...spec.pinned === void 0 ? [] : [pinnedAssumption(spec.pinned)],
|
|
3898
4183
|
...platform.assumptions
|
|
3899
4184
|
];
|
|
3900
4185
|
const start = now();
|
|
@@ -3928,14 +4213,110 @@ async function explore(scenario, platform, options) {
|
|
|
3928
4213
|
});
|
|
3929
4214
|
if (spec.bounds.maxConcurrentInvocations > 1 && !concurrencySupported) return unsupported("unsupported_bounds", "maxConcurrentInvocations above 1 needs AsyncLocalStorage (Node, or workerd with nodejs_compat or nodejs_als)");
|
|
3930
4215
|
if (spec.bounds.maxConcurrentInvocations > 1 && !platform.concurrent) return unsupported("unsupported_bounds", `maxConcurrentInvocations above 1 is not supported on the ${platform.name} platform yet`);
|
|
4216
|
+
/**
|
|
4217
|
+
* A run met something outside the model: the verdict carries its schedule and, when the run
|
|
4218
|
+
* replayed alone by its faults' calls gets there again (checked here, with one more run), the
|
|
4219
|
+
* same run as a pinned schedule, which a test can replay. A run that got there only through what
|
|
4220
|
+
* earlier runs left behind does not, and carries its schedule alone.
|
|
4221
|
+
*/
|
|
4222
|
+
const unsupportedApi = async (run) => {
|
|
4223
|
+
const reason = run.unsupportedReasons.join("; ");
|
|
4224
|
+
const verdict = unsupported("unsupported_api", reason, run.schedule);
|
|
4225
|
+
const replay = run.asPinned("the run that reached UNSUPPORTED");
|
|
4226
|
+
const again = await pinnedRun(spec, platform, replay, run.schedule.seed);
|
|
4227
|
+
reached.runs++;
|
|
4228
|
+
return again.chooser.unplaced().length === 0 && again.run.unsupportedReasons.join("; ") === reason ? {
|
|
4229
|
+
...verdict,
|
|
4230
|
+
replay,
|
|
4231
|
+
reached: doneNow()
|
|
4232
|
+
} : {
|
|
4233
|
+
...verdict,
|
|
4234
|
+
reached: doneNow()
|
|
4235
|
+
};
|
|
4236
|
+
};
|
|
4237
|
+
/**
|
|
4238
|
+
* A run broke an invariant: replay it, which must give the same log, then report it, shrunk
|
|
4239
|
+
* when exploration found it and as it ran when it is a pinned schedule's.
|
|
4240
|
+
*/
|
|
4241
|
+
const violated = async (run, log, violation, pinned) => {
|
|
4242
|
+
const schedule = run.schedule;
|
|
4243
|
+
const replayedRun = await replayRun(spec, platform, schedule);
|
|
4244
|
+
const replayed = replayedRun.log;
|
|
4245
|
+
reached.runs++;
|
|
4246
|
+
if (replayedRun.unsupportedReasons.length > 0) return unsupported("unsupported_api", replayedRun.unsupportedReasons.join("; "), schedule);
|
|
4247
|
+
const differed = whatDiffered(log, replayed);
|
|
4248
|
+
if (differed) return unsupported("not_replayable", `the violating run of seed ${schedule.seed} did not reproduce on replay: ${differed}`, schedule);
|
|
4249
|
+
if (pinned !== void 0) return {
|
|
4250
|
+
...base,
|
|
4251
|
+
kind: "VIOLATED",
|
|
4252
|
+
violation,
|
|
4253
|
+
trace: replayed,
|
|
4254
|
+
schedule,
|
|
4255
|
+
keptEvents: platform.initialEvents(spec).map((e) => e.id),
|
|
4256
|
+
shrunk: {
|
|
4257
|
+
faultsRemoved: 0,
|
|
4258
|
+
eventsRemoved: 0,
|
|
4259
|
+
runs: 0
|
|
4260
|
+
},
|
|
4261
|
+
pinned: pinned.name,
|
|
4262
|
+
...pinned.unplaced.length === 0 ? {} : { unplaced: pinned.unplaced },
|
|
4263
|
+
reached: doneNow()
|
|
4264
|
+
};
|
|
4265
|
+
const shrunk = await shrink(spec, platform, schedule, violation, replayed, {
|
|
4266
|
+
maxRuns: options.maxShrinkRuns ?? 200,
|
|
4267
|
+
deadline: now() + spec.bounds.budgetMs,
|
|
4268
|
+
now
|
|
4269
|
+
});
|
|
4270
|
+
reached.runs += shrunk.runs;
|
|
4271
|
+
return {
|
|
4272
|
+
...base,
|
|
4273
|
+
kind: "VIOLATED",
|
|
4274
|
+
violation: shrunk.violation,
|
|
4275
|
+
trace: shrunk.trace,
|
|
4276
|
+
schedule: shrunk.schedule,
|
|
4277
|
+
keptEvents: shrunk.keptEvents,
|
|
4278
|
+
shrunk: {
|
|
4279
|
+
faultsRemoved: shrunk.faultsRemoved,
|
|
4280
|
+
eventsRemoved: shrunk.eventsRemoved,
|
|
4281
|
+
runs: shrunk.runs
|
|
4282
|
+
},
|
|
4283
|
+
reached: doneNow()
|
|
4284
|
+
};
|
|
4285
|
+
};
|
|
4286
|
+
/** Whether any run had a point that may take a fault: sites that matched none say nothing. */
|
|
4287
|
+
let anyEligible = false;
|
|
3931
4288
|
const leakCheckRuns = options.leakCheckRuns ?? 2;
|
|
3932
|
-
/**
|
|
4289
|
+
/**
|
|
4290
|
+
* The first runs' schedules and logs, the pinned ones' included, replayed in reverse order before
|
|
4291
|
+
* BOUNDED: state a first run leaves behind shows as a difference wherever that run came from.
|
|
4292
|
+
*/
|
|
3933
4293
|
const witnesses = [];
|
|
4294
|
+
for (const pinned of spec.pinned ?? []) for (const seed of pinnedSeeds(pinned)) {
|
|
4295
|
+
const { run, chooser, log } = await pinnedRun(spec, platform, pinned, seed);
|
|
4296
|
+
reached.runs++;
|
|
4297
|
+
reached.effectPoints += run.effectPoints;
|
|
4298
|
+
reached.faultsInjected += run.faultsInjected;
|
|
4299
|
+
if (run.unsupportedReasons.length > 0) return await unsupportedApi(run);
|
|
4300
|
+
if (run.eligiblePoints > 0) anyEligible = true;
|
|
4301
|
+
const unplaced = chooser.unplaced();
|
|
4302
|
+
const violation = checkInvariants(log, spec.invariants)[0];
|
|
4303
|
+
if (violation) return await violated(run, log, violation, {
|
|
4304
|
+
name: pinned.name,
|
|
4305
|
+
unplaced
|
|
4306
|
+
});
|
|
4307
|
+
if (unplaced.length > 0) return unsupported("pin_not_placed", `pinned schedule ${JSON.stringify(pinned.name)} under seed ${seed}: ${unplaced.join("; ")}`, run.schedule);
|
|
4308
|
+
if (witnesses.length < leakCheckRuns) witnesses.push({
|
|
4309
|
+
schedule: run.schedule,
|
|
4310
|
+
log
|
|
4311
|
+
});
|
|
4312
|
+
}
|
|
4313
|
+
/** Runs before exploration (the pinned schedules'), which the run cap does not count. */
|
|
4314
|
+
const pinnedRuns = reached.runs;
|
|
3934
4315
|
let master = seedPrng(options.seed);
|
|
3935
4316
|
/** Eligible points of a run without faults, and the most any run has had: seeded fault positions. */
|
|
3936
4317
|
let baseline = 0;
|
|
3937
4318
|
let longest = 0;
|
|
3938
|
-
while ((exhaustive?.hasMore ?? true) && reached.runs < maxRuns && now() - start < spec.bounds.budgetMs) {
|
|
4319
|
+
while ((exhaustive?.hasMore ?? true) && reached.runs - pinnedRuns < maxRuns && (reached.runs === pinnedRuns || now() - start < spec.bounds.budgetMs)) {
|
|
3939
4320
|
const [runSeed, next] = nextU32(master);
|
|
3940
4321
|
master = next;
|
|
3941
4322
|
let faultPlan = [];
|
|
@@ -3952,6 +4333,7 @@ async function explore(scenario, platform, options) {
|
|
|
3952
4333
|
reached.runs++;
|
|
3953
4334
|
if (run.faultsInjected === 0) baseline = Math.max(baseline, run.eligiblePoints);
|
|
3954
4335
|
longest = Math.max(longest, run.eligiblePoints);
|
|
4336
|
+
if (run.eligiblePoints > 0) anyEligible = true;
|
|
3955
4337
|
if (exhaustive) {
|
|
3956
4338
|
if (exhaustive.mismatch) return unsupported("not_replayable", `exhaustive exploration needs deterministic runs: ${exhaustive.mismatch}`, run.schedule);
|
|
3957
4339
|
if (!exhaustive.ran(() => run.turnsMayNotCommute)) continue;
|
|
@@ -3962,39 +4344,12 @@ async function explore(scenario, platform, options) {
|
|
|
3962
4344
|
schedule: run.schedule,
|
|
3963
4345
|
log
|
|
3964
4346
|
});
|
|
3965
|
-
if (run.unsupportedReasons.length > 0) return
|
|
4347
|
+
if (run.unsupportedReasons.length > 0) return await unsupportedApi(run);
|
|
3966
4348
|
const violation = checkInvariants(log, spec.invariants)[0];
|
|
3967
|
-
if (violation)
|
|
3968
|
-
const schedule = run.schedule;
|
|
3969
|
-
const replayedRun = await replayRun(spec, platform, schedule);
|
|
3970
|
-
const replayed = replayedRun.log;
|
|
3971
|
-
reached.runs++;
|
|
3972
|
-
if (replayedRun.unsupportedReasons.length > 0) return unsupported("unsupported_api", replayedRun.unsupportedReasons.join("; "), schedule);
|
|
3973
|
-
const differed = whatDiffered(log, replayed);
|
|
3974
|
-
if (differed) return unsupported("not_replayable", `the violating run of seed ${schedule.seed} did not reproduce on replay: ${differed}`, schedule);
|
|
3975
|
-
const shrunk = await shrink(spec, platform, schedule, violation, replayed, {
|
|
3976
|
-
maxRuns: options.maxShrinkRuns ?? 200,
|
|
3977
|
-
deadline: now() + spec.bounds.budgetMs,
|
|
3978
|
-
now
|
|
3979
|
-
});
|
|
3980
|
-
reached.runs += shrunk.runs;
|
|
3981
|
-
return {
|
|
3982
|
-
...base,
|
|
3983
|
-
kind: "VIOLATED",
|
|
3984
|
-
violation: shrunk.violation,
|
|
3985
|
-
trace: shrunk.trace,
|
|
3986
|
-
schedule: shrunk.schedule,
|
|
3987
|
-
keptEvents: shrunk.keptEvents,
|
|
3988
|
-
shrunk: {
|
|
3989
|
-
faultsRemoved: shrunk.faultsRemoved,
|
|
3990
|
-
eventsRemoved: shrunk.eventsRemoved,
|
|
3991
|
-
runs: shrunk.runs
|
|
3992
|
-
},
|
|
3993
|
-
reached: doneNow()
|
|
3994
|
-
};
|
|
3995
|
-
}
|
|
4349
|
+
if (violation) return await violated(run, log, violation);
|
|
3996
4350
|
exhaustive?.checked();
|
|
3997
4351
|
}
|
|
4352
|
+
if (spec.bounds.faultsAt !== void 0 && spec.bounds.maxFaultsPerRun > 0 && !anyEligible) return unsupported("unsupported_bounds", `bounds.faultsAt matched no effect point that may take a fault in ${reached.runs - pinnedRuns} run(s) of exploration, so no fault was injected; compare the sites' targets, ops, conditions and kinds with the effects a trace shows`);
|
|
3998
4353
|
for (const witness of [...witnesses].reverse()) {
|
|
3999
4354
|
const again = await replayRun(spec, platform, witness.schedule);
|
|
4000
4355
|
reached.runs++;
|
|
@@ -4227,6 +4582,6 @@ function observeCore(namespace, functions) {
|
|
|
4227
4582
|
}
|
|
4228
4583
|
};
|
|
4229
4584
|
}
|
|
4230
|
-
export {
|
|
4585
|
+
export { readFaults as A, patchProperty as C, checkInvariant as D, validateScenario as E, seedPrng as F, getPath as I, invocationOf as L, nextFloat as M, nextInt as N, checkInvariants as O, nextU32 as P, redelivery as R, virtualEpoch as S, defaultBounds as T, parseBody as _, explore as a, withoutNetwork as b, restrictSpec as c, note as d, runInvocation as f, isRedirect as g, findResponse as h, rawRun as i, writeFaults as j, decisionFaults as k, decide as l, InjectedEffectError as m, compareSides as n, replay as o, CrashSignal as p, proxiedSide as r, runPinned as s, observeCore as t, hostInvocation as u, replyOf as v, toJson as w, realTick as x, toResponse as y, canonicalJson as z };
|
|
4231
4586
|
|
|
4232
|
-
//# sourceMappingURL=src-
|
|
4587
|
+
//# sourceMappingURL=src-Whn0RMSh.mjs.map
|