eutaxy 0.18.0 → 0.19.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 +15 -12
- package/dist/aws.d.mts +2 -2
- package/dist/aws.mjs +3 -2
- package/dist/aws.mjs.map +1 -1
- package/dist/bin.mjs +1 -1
- package/dist/check-zkHLdWyf.mjs +1281 -0
- package/dist/check-zkHLdWyf.mjs.map +1 -0
- package/dist/cli-CNAKqV9R.mjs +297 -0
- package/dist/cli-CNAKqV9R.mjs.map +1 -0
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cloudflare.d.mts +37 -5
- package/dist/cloudflare.d.mts.map +1 -1
- package/dist/cloudflare.mjs +6417 -3
- package/dist/cloudflare.mjs.map +1 -0
- package/dist/{delivery-invariants-BRwfZJrs.mjs → delivery-invariants-BJDck0K8.mjs} +2 -2
- package/dist/{delivery-invariants-BRwfZJrs.mjs.map → delivery-invariants-BJDck0K8.mjs.map} +1 -1
- package/dist/{delivery-invariants-D-_GPOqE.d.mts → delivery-invariants-C3GXJIbg.d.mts} +2 -2
- package/dist/{delivery-invariants-D-_GPOqE.d.mts.map → delivery-invariants-C3GXJIbg.d.mts.map} +1 -1
- package/dist/draft-DEUDffHa.mjs +467 -0
- package/dist/draft-DEUDffHa.mjs.map +1 -0
- package/dist/{src-H1Q8ytEx.mjs → generate-TBJM3-2P.mjs} +3 -618
- package/dist/generate-TBJM3-2P.mjs.map +1 -0
- package/dist/index.d.mts +36 -36
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/dist/install-DkzpGA5D.mjs +611 -0
- package/dist/install-DkzpGA5D.mjs.map +1 -0
- package/dist/{explore-D33RP9hF.d.mts → ir-KpC2epGn.d.mts} +70 -70
- package/dist/ir-KpC2epGn.d.mts.map +1 -0
- package/dist/keys-xtanNmuR.mjs +111 -0
- package/dist/keys-xtanNmuR.mjs.map +1 -0
- package/dist/mcp-B64Ko6y7.mjs +539 -0
- package/dist/mcp-B64Ko6y7.mjs.map +1 -0
- package/dist/{platform-CawKCUru.d.mts → platform-Cs9V9t2k.d.mts} +25 -11
- package/dist/platform-Cs9V9t2k.d.mts.map +1 -0
- package/dist/pool-CXN4CwGY.mjs +61 -0
- package/dist/pool-CXN4CwGY.mjs.map +1 -0
- package/dist/{provers-DS44OeEm.mjs → provers-D8VaY_OM.mjs} +18 -2
- package/dist/provers-D8VaY_OM.mjs.map +1 -0
- package/dist/reader-B9FSoEYW.mjs +1 -0
- package/dist/reader-Cz6_bLf6.mjs +3774 -0
- package/dist/reader-Cz6_bLf6.mjs.map +1 -0
- package/dist/report-_Vzavqg0.mjs +310 -0
- package/dist/report-_Vzavqg0.mjs.map +1 -0
- package/dist/src-B2DpVbMN.mjs +2 -0
- package/dist/src-BFGTvuA_.mjs +1235 -0
- package/dist/src-BFGTvuA_.mjs.map +1 -0
- package/dist/src-BtLZPRyG.mjs +120 -0
- package/dist/src-BtLZPRyG.mjs.map +1 -0
- package/dist/src-CB8DcvsK.mjs +1 -0
- package/dist/src-COuquJvI.mjs +269 -0
- package/dist/src-COuquJvI.mjs.map +1 -0
- package/dist/src-Chn-m_r1.mjs +1082 -0
- package/dist/src-Chn-m_r1.mjs.map +1 -0
- package/dist/src-DwYD3QQJ.mjs +346 -0
- package/dist/src-DwYD3QQJ.mjs.map +1 -0
- package/dist/{src-Whn0RMSh.mjs → src-Dx4QvrQb.mjs} +559 -517
- package/dist/src-Dx4QvrQb.mjs.map +1 -0
- package/dist/toolchain-DWfymxAJ.mjs +80 -0
- package/dist/toolchain-DWfymxAJ.mjs.map +1 -0
- package/dist/verdict-evEM5Gxx.mjs +12 -0
- package/dist/verdict-evEM5Gxx.mjs.map +1 -0
- package/package.json +4 -1
- package/dist/cli-DyA7uTBg.mjs +0 -9447
- package/dist/cli-DyA7uTBg.mjs.map +0 -1
- package/dist/explore-D33RP9hF.d.mts.map +0 -1
- package/dist/platform-CawKCUru.d.mts.map +0 -1
- package/dist/provers-DS44OeEm.mjs.map +0 -1
- package/dist/src-H1Q8ytEx.mjs.map +0 -1
- package/dist/src-Whn0RMSh.mjs.map +0 -1
- package/dist/workerd-tI8INa6v.mjs +0 -6334
- package/dist/workerd-tI8INa6v.mjs.map +0 -1
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as isSpec } from "./combinators-CLfsPfhT.mjs";
|
|
3
|
-
// packages/core/src/verdict.ts
|
|
4
|
-
/** One line per verdict, for error messages; full rendering lives in `report`. */
|
|
5
|
-
function describeVerdict(v) {
|
|
6
|
-
switch (v.kind) {
|
|
7
|
-
case "VIOLATED": return `VIOLATED ${v.scenario}: ${v.violation.message} (seed ${v.schedule.seed}, ${v.reached.runs} run(s))`;
|
|
8
|
-
case "BOUNDED": return `BOUNDED ${v.scenario}: no violation in ${v.reached.runs} run(s), ${v.reached.effectPoints} effect point(s), ${v.reached.faultsInjected} fault(s)`;
|
|
9
|
-
case "UNSUPPORTED": return `UNSUPPORTED ${v.scenario}: ${v.cause}: ${v.reason}`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
import { n as nextInt, r as nextU32, t as nextFloat } from "./src-BtLZPRyG.mjs";
|
|
12
2
|
// packages/spec/src/ir.ts
|
|
13
3
|
/** A type, for messages. */
|
|
14
4
|
function describeType(t) {
|
|
@@ -1079,611 +1069,6 @@ function candidatesOf(type, hint, v) {
|
|
|
1079
1069
|
}
|
|
1080
1070
|
}
|
|
1081
1071
|
}
|
|
1082
|
-
|
|
1083
|
-
/**
|
|
1084
|
-
* One assignment through a spec. The precondition decides whether the
|
|
1085
|
-
* assignment is inside the claim; a precondition that throws or does not
|
|
1086
|
-
* answer a boolean is a malformed property, since it cannot tell. The
|
|
1087
|
-
* claim then holds, or is false, or throws: a throw from the claim, the
|
|
1088
|
-
* function's own included, means the claim is not true there. A claim
|
|
1089
|
-
* that returns something other than a boolean is malformed.
|
|
1090
|
-
*/
|
|
1091
|
-
function evaluate(spec, values, copied = false) {
|
|
1092
|
-
const fresh = () => copied ? copy(values) : values;
|
|
1093
|
-
if (spec.when) {
|
|
1094
|
-
let inside;
|
|
1095
|
-
try {
|
|
1096
|
-
inside = spec.when(...fresh());
|
|
1097
|
-
} catch (err) {
|
|
1098
|
-
return { malformed: `the precondition threw ${String(err)}` };
|
|
1099
|
-
}
|
|
1100
|
-
if (typeof inside !== "boolean") return { malformed: `the precondition returned ${render(inside)}, not a boolean` };
|
|
1101
|
-
if (!inside) return { outcome: "discarded" };
|
|
1102
|
-
}
|
|
1103
|
-
let claim;
|
|
1104
|
-
try {
|
|
1105
|
-
claim = spec.ensures(...fresh());
|
|
1106
|
-
} catch (err) {
|
|
1107
|
-
return {
|
|
1108
|
-
outcome: "refuted",
|
|
1109
|
-
error: String(err)
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
if (typeof claim !== "boolean") return { malformed: `the claim returned ${render(claim)}, not a boolean` };
|
|
1113
|
-
return { outcome: claim ? "held" : "refuted" };
|
|
1114
|
-
}
|
|
1115
|
-
/** How every rung words an `UNKNOWN` for a property that cannot be evaluated; the ladder recognizes it. */
|
|
1116
|
-
const malformedReason = (detail) => `the property could not be evaluated: ${detail}`;
|
|
1117
|
-
/** The `CHECKED` rung: evaluate the property on every distinct input the simulator passed the function. */
|
|
1118
|
-
function checkedRung(input) {
|
|
1119
|
-
const { module, fn, property } = input;
|
|
1120
|
-
const base = {
|
|
1121
|
-
module,
|
|
1122
|
-
function: fn.name,
|
|
1123
|
-
property: property.name,
|
|
1124
|
-
text: property.text
|
|
1125
|
-
};
|
|
1126
|
-
const unknown = (cause, reason) => ({
|
|
1127
|
-
...base,
|
|
1128
|
-
kind: "UNKNOWN",
|
|
1129
|
-
cause,
|
|
1130
|
-
reason,
|
|
1131
|
-
assumptions: []
|
|
1132
|
-
});
|
|
1133
|
-
if (property.kind === "total") return unknown("unsupported", "termination is not observable on the inputs the simulator passed; total needs a prover");
|
|
1134
|
-
if (input.unobservable) return unknown("unavailable", `calls to ${fn.name} could not be observed: ${input.unobservable}`);
|
|
1135
|
-
const spec = input.spec;
|
|
1136
|
-
if (!spec) return unknown("unavailable", `the spec file's export ${property.name} was not loaded`);
|
|
1137
|
-
const binders = property.binders;
|
|
1138
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1139
|
-
let held = 0;
|
|
1140
|
-
let discarded = 0;
|
|
1141
|
-
for (const call of input.calls) {
|
|
1142
|
-
const values = binders.map((_, i) => call.args[i]);
|
|
1143
|
-
const key = values.map(render).join(", ");
|
|
1144
|
-
if (seen.has(key)) continue;
|
|
1145
|
-
seen.add(key);
|
|
1146
|
-
if (!binders.every((b, i) => conforms(b.type, values[i]))) {
|
|
1147
|
-
discarded++;
|
|
1148
|
-
continue;
|
|
1149
|
-
}
|
|
1150
|
-
const counterexample = (error) => ({
|
|
1151
|
-
binders: binders.map((b, i) => ({
|
|
1152
|
-
name: b.name,
|
|
1153
|
-
value: render(values[i])
|
|
1154
|
-
})),
|
|
1155
|
-
call: `${fn.name}(${call.args.map(render).join(", ")})`,
|
|
1156
|
-
...error === void 0 ? {} : { error }
|
|
1157
|
-
});
|
|
1158
|
-
const result = evaluate(spec, values);
|
|
1159
|
-
if ("malformed" in result) return unknown("unsupported", malformedReason(result.malformed));
|
|
1160
|
-
if (result.outcome === "refuted") return {
|
|
1161
|
-
...base,
|
|
1162
|
-
kind: "REFUTED",
|
|
1163
|
-
rung: "CHECKED",
|
|
1164
|
-
counterexample: counterexample(result.error),
|
|
1165
|
-
assumptions: []
|
|
1166
|
-
};
|
|
1167
|
-
if (result.outcome === "discarded") discarded++;
|
|
1168
|
-
else held++;
|
|
1169
|
-
}
|
|
1170
|
-
if (held === 0) return unknown("gave_up", input.calls.length === 0 ? `the simulator never called ${fn.name}` : `none of the ${seen.size} distinct input(s) the simulator passed is inside the claim (the precondition)`);
|
|
1171
|
-
return {
|
|
1172
|
-
...base,
|
|
1173
|
-
kind: "CHECKED",
|
|
1174
|
-
inputs: held,
|
|
1175
|
-
discarded,
|
|
1176
|
-
assumptions: [`held on the ${held} distinct input(s) the simulator passed to ${fn.name}; inputs it never passed are not covered`]
|
|
1177
|
-
};
|
|
1178
|
-
}
|
|
1179
|
-
// packages/prover/src/shrink.ts
|
|
1180
|
-
/** How many evaluations shrinking may spend on one counterexample. */
|
|
1181
|
-
const shrinkBudget = 500;
|
|
1182
|
-
function shrinkRefutation(spec, binders, start, startEvaluation) {
|
|
1183
|
-
let values = [...start];
|
|
1184
|
-
let error = refutes(startEvaluation) ?? {};
|
|
1185
|
-
let spent = 0;
|
|
1186
|
-
let progress = true;
|
|
1187
|
-
while (progress && spent < shrinkBudget) {
|
|
1188
|
-
progress = false;
|
|
1189
|
-
for (let i = 0; i < binders.length && spent < shrinkBudget; i++) {
|
|
1190
|
-
const b = binders[i];
|
|
1191
|
-
let moved = true;
|
|
1192
|
-
while (moved && spent < shrinkBudget) {
|
|
1193
|
-
moved = false;
|
|
1194
|
-
for (const candidate of shrinkCandidates(b, values[i])) {
|
|
1195
|
-
if (spent >= shrinkBudget) break;
|
|
1196
|
-
spent++;
|
|
1197
|
-
const trial = values.with(i, candidate);
|
|
1198
|
-
if (spec.sample && !inSample(spec, trial)) continue;
|
|
1199
|
-
const still = refutes(evaluate(spec, trial, true));
|
|
1200
|
-
if (still === void 0) continue;
|
|
1201
|
-
values = trial;
|
|
1202
|
-
error = still;
|
|
1203
|
-
moved = true;
|
|
1204
|
-
progress = true;
|
|
1205
|
-
break;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
return error.error === void 0 ? { values } : {
|
|
1211
|
-
values,
|
|
1212
|
-
error: error.error
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
/** Whether an evaluation still refutes: an object (holding the error text, if any), or undefined. */
|
|
1216
|
-
function refutes(e) {
|
|
1217
|
-
if ("malformed" in e || e.outcome !== "refuted") return void 0;
|
|
1218
|
-
return "error" in e && e.error !== void 0 ? { error: e.error } : {};
|
|
1219
|
-
}
|
|
1220
|
-
/** Whether the spec's sample holds of the values (a sample that throws or answers other than true does not). */
|
|
1221
|
-
function inSample(spec, values) {
|
|
1222
|
-
try {
|
|
1223
|
-
return spec.sample?.(...copy(values)) === true;
|
|
1224
|
-
} catch {
|
|
1225
|
-
return false;
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
// packages/prover/src/tested.ts
|
|
1229
|
-
/**
|
|
1230
|
-
* The `TESTED` rung: a property evaluated on assignments drawn from its
|
|
1231
|
-
* binders' types, steered by the precondition's hints, with a seed, so the
|
|
1232
|
-
* same seed draws the same assignments everywhere. An assignment where the
|
|
1233
|
-
* claim is false is shrunk toward smaller values that still break it and
|
|
1234
|
-
* reported as a counterexample. Holding on every drawn assignment is
|
|
1235
|
-
* `TESTED`: evidence from sampling, which says nothing about the inputs
|
|
1236
|
-
* never drawn.
|
|
1237
|
-
*/
|
|
1238
|
-
/** The `TESTED` rung: evaluate the property on inputs generated from its binders' domains, drawn from the seed. */
|
|
1239
|
-
function testedRung(input) {
|
|
1240
|
-
const { module, fn, property } = input;
|
|
1241
|
-
const base = {
|
|
1242
|
-
module,
|
|
1243
|
-
function: fn.name,
|
|
1244
|
-
property: property.name,
|
|
1245
|
-
text: property.text
|
|
1246
|
-
};
|
|
1247
|
-
const unknown = (cause, reason) => ({
|
|
1248
|
-
...base,
|
|
1249
|
-
kind: "UNKNOWN",
|
|
1250
|
-
cause,
|
|
1251
|
-
reason,
|
|
1252
|
-
assumptions: []
|
|
1253
|
-
});
|
|
1254
|
-
if (property.kind === "total") return unknown("unsupported", "termination is not observable on generated inputs; total needs a prover");
|
|
1255
|
-
const spec = input.spec;
|
|
1256
|
-
if (!spec) return unknown("unavailable", `the spec file's export ${property.name} was not loaded`);
|
|
1257
|
-
const binders = property.binders;
|
|
1258
|
-
const wanted = input.inputs ?? 100;
|
|
1259
|
-
if (!Number.isInteger(wanted) || wanted < 1) throw new RangeError(`inputs must be a positive integer, got ${String(input.inputs)}`);
|
|
1260
|
-
const seed = `${input.seed}:${module}:${fn.name}:${property.name}`;
|
|
1261
|
-
let state = seedPrng(seed);
|
|
1262
|
-
let held = 0;
|
|
1263
|
-
let discarded = 0;
|
|
1264
|
-
let sampledOut = 0;
|
|
1265
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1266
|
-
const counterexample = (values, error) => ({
|
|
1267
|
-
binders: binders.map((b, i) => ({
|
|
1268
|
-
name: b.name,
|
|
1269
|
-
value: render(values[i])
|
|
1270
|
-
})),
|
|
1271
|
-
...error === void 0 ? {} : { error }
|
|
1272
|
-
});
|
|
1273
|
-
const edges = edgeLists(binders);
|
|
1274
|
-
const edgeTotal = edgeAssignmentCount(edges);
|
|
1275
|
-
const randomWanted = Math.ceil(wanted / 2);
|
|
1276
|
-
let randomHeld = 0;
|
|
1277
|
-
for (let draws = 0; draws < edgeTotal || (held < wanted || randomHeld < randomWanted) && draws < edgeTotal + wanted * 20; draws++) {
|
|
1278
|
-
let values;
|
|
1279
|
-
try {
|
|
1280
|
-
[values, state] = (draws < edgeTotal ? edgeAssignment(binders, edges, draws, state) : void 0) ?? generateAssignment(binders, state);
|
|
1281
|
-
} catch (err) {
|
|
1282
|
-
if (err instanceof CannotGenerate) return unknown(err.why, err.message);
|
|
1283
|
-
throw err;
|
|
1284
|
-
}
|
|
1285
|
-
const key = values.map(render).join(", ");
|
|
1286
|
-
if (seen.has(key)) continue;
|
|
1287
|
-
seen.add(key);
|
|
1288
|
-
if (spec.sample) {
|
|
1289
|
-
let inSample;
|
|
1290
|
-
try {
|
|
1291
|
-
inSample = spec.sample(...copy(values));
|
|
1292
|
-
} catch (err) {
|
|
1293
|
-
return unknown("unsupported", malformedReason(`the sample threw ${String(err)}`));
|
|
1294
|
-
}
|
|
1295
|
-
if (typeof inSample !== "boolean") return unknown("unsupported", malformedReason(`the sample returned ${render(inSample)}, not a boolean`));
|
|
1296
|
-
if (!inSample) {
|
|
1297
|
-
sampledOut++;
|
|
1298
|
-
continue;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
const result = evaluate(spec, values, true);
|
|
1302
|
-
if ("malformed" in result) return unknown("unsupported", malformedReason(result.malformed));
|
|
1303
|
-
if (result.outcome === "discarded") {
|
|
1304
|
-
discarded++;
|
|
1305
|
-
continue;
|
|
1306
|
-
}
|
|
1307
|
-
if (result.outcome === "refuted") {
|
|
1308
|
-
const smallest = shrinkRefutation(spec, binders, values, result);
|
|
1309
|
-
return {
|
|
1310
|
-
...base,
|
|
1311
|
-
kind: "REFUTED",
|
|
1312
|
-
rung: "TESTED",
|
|
1313
|
-
counterexample: counterexample(smallest.values, smallest.error),
|
|
1314
|
-
assumptions: [`found on an input generated with seed ${input.seed}, then shrunk`]
|
|
1315
|
-
};
|
|
1316
|
-
}
|
|
1317
|
-
held++;
|
|
1318
|
-
if (draws >= edgeTotal) randomHeld++;
|
|
1319
|
-
}
|
|
1320
|
-
if (held === 0) return unknown("gave_up", sampledOut > 0 && discarded === 0 ? `all ${sampledOut} distinct generated inputs were outside the sample: it admits too few of the parameter types to draw` : `all ${discarded + sampledOut} distinct generated inputs were outside the claim or the sample: its precondition admits too few of the parameter types to sample`);
|
|
1321
|
-
return {
|
|
1322
|
-
...base,
|
|
1323
|
-
kind: "TESTED",
|
|
1324
|
-
inputs: held,
|
|
1325
|
-
discarded,
|
|
1326
|
-
seed: input.seed,
|
|
1327
|
-
assumptions: [
|
|
1328
|
-
`held on ${held} distinct input(s) generated from the parameter types with seed ${input.seed}; inputs never drawn are not covered`,
|
|
1329
|
-
`${fn.name} was called on generated inputs outside the simulator, so it is assumed pure`,
|
|
1330
|
-
...spec.sample ? [`drawn only where the sample holds${property.sample ? ` (${property.sample.body.replace(/\s+/g, " ").trim()})` : ""}; the claim itself is not limited to it`] : []
|
|
1331
|
-
]
|
|
1332
|
-
};
|
|
1333
|
-
}
|
|
1334
|
-
// packages/prover/src/ladder.ts
|
|
1335
|
-
/** One property through the ladder's rungs. */
|
|
1336
|
-
function specLadder(input, options = {}) {
|
|
1337
|
-
if (options.checked === false) {
|
|
1338
|
-
if (!options.tested) throw new RangeError("a ladder without CHECKED needs the TESTED rung");
|
|
1339
|
-
return testedRung({
|
|
1340
|
-
module: input.module,
|
|
1341
|
-
fn: input.fn,
|
|
1342
|
-
property: input.property,
|
|
1343
|
-
spec: input.spec,
|
|
1344
|
-
...options.tested
|
|
1345
|
-
});
|
|
1346
|
-
}
|
|
1347
|
-
const checked = checkedRung(input);
|
|
1348
|
-
if (checked.kind === "REFUTED" || options.tested === false || options.tested === void 0) return checked;
|
|
1349
|
-
if (input.property.kind === "total") return checked;
|
|
1350
|
-
if (checked.kind === "UNKNOWN" && checked.reason.startsWith(malformedReason(""))) return checked;
|
|
1351
|
-
const tested = testedRung({
|
|
1352
|
-
module: input.module,
|
|
1353
|
-
fn: input.fn,
|
|
1354
|
-
property: input.property,
|
|
1355
|
-
spec: input.spec,
|
|
1356
|
-
...options.tested
|
|
1357
|
-
});
|
|
1358
|
-
if (tested.kind === "REFUTED") return tested;
|
|
1359
|
-
if (tested.kind === "UNKNOWN" && tested.reason.startsWith(malformedReason(""))) return tested;
|
|
1360
|
-
if (tested.kind === "TESTED") {
|
|
1361
|
-
if (checked.kind !== "CHECKED") return {
|
|
1362
|
-
...tested,
|
|
1363
|
-
assumptions: [...tested.assumptions, reason(checked)]
|
|
1364
|
-
};
|
|
1365
|
-
return {
|
|
1366
|
-
...tested,
|
|
1367
|
-
checked: checked.inputs,
|
|
1368
|
-
assumptions: [...tested.assumptions, ...checked.assumptions]
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
if (checked.kind !== "UNKNOWN") return {
|
|
1372
|
-
...checked,
|
|
1373
|
-
assumptions: [...checked.assumptions, `not TESTED: ${reason(tested)}`]
|
|
1374
|
-
};
|
|
1375
|
-
if (reason(tested) === checked.reason) return checked;
|
|
1376
|
-
return {
|
|
1377
|
-
...checked,
|
|
1378
|
-
reason: `${checked.reason}; generated inputs: ${reason(tested)}`
|
|
1379
|
-
};
|
|
1380
|
-
}
|
|
1381
|
-
function reason(v) {
|
|
1382
|
-
return v.kind === "UNKNOWN" ? v.reason : v.kind;
|
|
1383
|
-
}
|
|
1384
|
-
/**
|
|
1385
|
-
* Every spec verdict for one module: each property through the ladder.
|
|
1386
|
-
* `props` is the spec file's namespace, `namespace` the module's (after
|
|
1387
|
-
* observation ended, so it holds the functions themselves); a spec whose
|
|
1388
|
-
* function is not the module's export of that name is not evaluated.
|
|
1389
|
-
*/
|
|
1390
|
-
function checkSpecModule(module, specs, props, namespace, observed, options = {}) {
|
|
1391
|
-
return specs.functions.flatMap((fn) => {
|
|
1392
|
-
const calls = observed.calls.filter((c) => c.function === fn.name);
|
|
1393
|
-
const unobservable = Object.hasOwn(observed.unobservable, fn.name) ? observed.unobservable[fn.name] : void 0;
|
|
1394
|
-
return fn.properties.map((property) => {
|
|
1395
|
-
const exported = Object.hasOwn(props, property.name) ? props[property.name] : void 0;
|
|
1396
|
-
let spec;
|
|
1397
|
-
let mismatch;
|
|
1398
|
-
if (!isSpec(exported)) mismatch = `the spec file exports no spec named ${property.name}`;
|
|
1399
|
-
else if (exported.fn !== namespace[fn.name]) mismatch = `${property.name} names a function that is not the module's export ${fn.name}`;
|
|
1400
|
-
else if (exported.kind === "forall") spec = exported;
|
|
1401
|
-
if (mismatch !== void 0) return {
|
|
1402
|
-
module,
|
|
1403
|
-
function: fn.name,
|
|
1404
|
-
property: property.name,
|
|
1405
|
-
text: property.text,
|
|
1406
|
-
kind: "UNKNOWN",
|
|
1407
|
-
cause: "unavailable",
|
|
1408
|
-
reason: mismatch,
|
|
1409
|
-
assumptions: []
|
|
1410
|
-
};
|
|
1411
|
-
return specLadder({
|
|
1412
|
-
module,
|
|
1413
|
-
fn,
|
|
1414
|
-
property,
|
|
1415
|
-
calls,
|
|
1416
|
-
spec,
|
|
1417
|
-
...unobservable === void 0 ? {} : { unobservable }
|
|
1418
|
-
}, options);
|
|
1419
|
-
});
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
// packages/report/src/regression.ts
|
|
1423
|
-
/**
|
|
1424
|
-
* The Vitest regression emitter. Given a violation, produce a test file that
|
|
1425
|
-
* replays its shrunk schedule on the restricted scenario. By default the
|
|
1426
|
-
* test expects the invariants to hold, so it fails while the bug exists and
|
|
1427
|
-
* passes once it is fixed. With `expect: "violates"` it asserts the recorded
|
|
1428
|
-
* violation instead, which is how Eutaxy's own corpus exercises the emitter.
|
|
1429
|
-
*
|
|
1430
|
-
* The emitter knows nothing about any platform: the caller supplies the
|
|
1431
|
-
* import lines and the expression that builds the platform.
|
|
1432
|
-
*/
|
|
1433
|
-
/**
|
|
1434
|
-
* A Vitest test file that replays a violation's shrunk schedule: by default it fails while the bug is
|
|
1435
|
-
* there and passes once it is fixed.
|
|
1436
|
-
*/
|
|
1437
|
-
function emitRegressionTest(verdict, options) {
|
|
1438
|
-
const engineModule = options.engineModule ?? "eutaxy";
|
|
1439
|
-
const mode = options.expect ?? "holds";
|
|
1440
|
-
const schedule = canonicalJson(verdict.schedule);
|
|
1441
|
-
const kept = canonicalJson([...verdict.keptEvents]);
|
|
1442
|
-
const keys = canonicalJson([...verdict.violation.keys]);
|
|
1443
|
-
const title = mode === "holds" ? `${verdict.scenario}: ${verdict.violation.invariant} holds on the recorded schedule` : `${verdict.scenario}: ${verdict.violation.invariant} is still violated on the recorded schedule`;
|
|
1444
|
-
const assertion = mode === "holds" ? ` expect(violations.map((v) => \`\${v.invariant}: \${v.message}\`)).toEqual([]);` : ` expect(violations.map((v) => [v.invariant, v.keys])).toContainEqual([${JSON.stringify(verdict.violation.invariant)}, ${keys}]);`;
|
|
1445
|
-
const observe = options.observe ?? [];
|
|
1446
|
-
const replayLines = observe.length === 0 ? [" const log = await replay(spec, platform, schedule);"] : [
|
|
1447
|
-
` const observers = [${observe.map((o) => `observeCore(${o.namespace}, ${JSON.stringify(o.functions)})`).join(", ")}];`,
|
|
1448
|
-
" const log = await replay(spec, platform, schedule).finally(() => {",
|
|
1449
|
-
" for (const o of observers) o.restore();",
|
|
1450
|
-
" });"
|
|
1451
|
-
];
|
|
1452
|
-
return [
|
|
1453
|
-
"// Generated by Eutaxy. Replays a recorded violation; regenerate rather than edit.",
|
|
1454
|
-
`// Scenario ${verdict.scenario}, seed ${String(verdict.seed)}: ${verdict.violation.message}`,
|
|
1455
|
-
...verdict.pinned === void 0 ? [] : [`// The run of the scenario's pinned schedule ${JSON.stringify(verdict.pinned)} under seed ${verdict.schedule.seed}, as it ran.`],
|
|
1456
|
-
`import { checkInvariants, ${observe.length > 0 ? "observeCore, " : ""}replay, restrictSpec } from ${JSON.stringify(engineModule)};`,
|
|
1457
|
-
...options.imports,
|
|
1458
|
-
"import { expect, test } from \"vitest\";",
|
|
1459
|
-
"",
|
|
1460
|
-
`const schedule = ${schedule} as const;`,
|
|
1461
|
-
`const keptEvents = ${kept} as const;`,
|
|
1462
|
-
"",
|
|
1463
|
-
`test(${JSON.stringify(title)}, async () => {`,
|
|
1464
|
-
` const platform = ${options.platform};`,
|
|
1465
|
-
` const spec = restrictSpec(platform, ${options.scenario}, keptEvents);`,
|
|
1466
|
-
...replayLines,
|
|
1467
|
-
" const violations = checkInvariants(log, spec.invariants);",
|
|
1468
|
-
assertion,
|
|
1469
|
-
"});",
|
|
1470
|
-
""
|
|
1471
|
-
].join("\n");
|
|
1472
|
-
}
|
|
1473
|
-
/**
|
|
1474
|
-
* A Vitest test file that replays the run that made a check `UNSUPPORTED`, as its verdict's `replay`
|
|
1475
|
-
* names it (each fault at the call it hit, by target, op, arguments and call number), and expects
|
|
1476
|
-
* the run to place every fault and reach the same reason: a reproduction to look into, which fails
|
|
1477
|
-
* once the run no longer gets there. Only for `unsupported_api`, which one run reaches again (other
|
|
1478
|
-
* causes throw). `engineModule` as for `emitRegressionTest`; it exports `runPinned`.
|
|
1479
|
-
*/
|
|
1480
|
-
function emitUnsupportedTest(verdict, options) {
|
|
1481
|
-
if (verdict.cause !== "unsupported_api") throw new Error(`a ${verdict.cause} verdict is not reached again by replaying one run; only unsupported_api is`);
|
|
1482
|
-
if (verdict.replay === void 0) throw new Error("the verdict has no run to replay: it was reached before any run");
|
|
1483
|
-
const engineModule = options.engineModule ?? "eutaxy";
|
|
1484
|
-
const pinned = canonicalJson(verdict.replay);
|
|
1485
|
-
const observe = options.observe ?? [];
|
|
1486
|
-
const runLines = observe.length === 0 ? [` const run = await runPinned(${options.scenario}, platform, pinned);`] : [
|
|
1487
|
-
` const observers = [${observe.map((o) => `observeCore(${o.namespace}, ${JSON.stringify(o.functions)})`).join(", ")}];`,
|
|
1488
|
-
` const run = await runPinned(${options.scenario}, platform, pinned).finally(() => {`,
|
|
1489
|
-
" for (const o of observers) o.restore();",
|
|
1490
|
-
" });"
|
|
1491
|
-
];
|
|
1492
|
-
return [
|
|
1493
|
-
"// Generated by Eutaxy. Replays the run that made a check UNSUPPORTED; regenerate rather than edit.",
|
|
1494
|
-
`// Scenario ${verdict.scenario}, seed ${String(verdict.seed)}: ${verdict.cause}: ${verdict.reason.replace(/\s+/g, " ")}`,
|
|
1495
|
-
`import { ${observe.length > 0 ? "observeCore, " : ""}runPinned } from ${JSON.stringify(engineModule)};`,
|
|
1496
|
-
...options.imports,
|
|
1497
|
-
"import { expect, test } from \"vitest\";",
|
|
1498
|
-
"",
|
|
1499
|
-
pinned.includes("\"__proto__\"") ? `const pinned = JSON.parse(${JSON.stringify(pinned)});` : `const pinned = ${pinned} as const;`,
|
|
1500
|
-
"",
|
|
1501
|
-
`test(${JSON.stringify(`${verdict.scenario}: the recorded run still reaches what made the check UNSUPPORTED`)}, async () => {`,
|
|
1502
|
-
` const platform = ${options.platform};`,
|
|
1503
|
-
...runLines,
|
|
1504
|
-
" expect(run.unplaced).toEqual([]);",
|
|
1505
|
-
` expect(run.unsupportedReasons.join("; ")).toBe(${JSON.stringify(verdict.reason)});`,
|
|
1506
|
-
"});",
|
|
1507
|
-
""
|
|
1508
|
-
].join("\n");
|
|
1509
|
-
}
|
|
1510
|
-
/**
|
|
1511
|
-
* The JSON report: one object, canonical, with a schema version at the top.
|
|
1512
|
-
* Spec verdicts, when there are any, sit beside the scenario's, never in it.
|
|
1513
|
-
*/
|
|
1514
|
-
function renderJson(verdict, specs = []) {
|
|
1515
|
-
return canonicalJson({
|
|
1516
|
-
schemaVersion: 1,
|
|
1517
|
-
generator: "eutaxy",
|
|
1518
|
-
verdict,
|
|
1519
|
-
...specs.length > 0 ? { specs } : {}
|
|
1520
|
-
});
|
|
1521
|
-
}
|
|
1522
|
-
const specsHeader = "Specs (CHECKED means held on the inputs the simulator passed, TESTED on generated ones too; neither is a proof. PROVEN is one, by the named engine)";
|
|
1523
|
-
/** Spec verdicts as text: one line each, a counterexample under a refutation. */
|
|
1524
|
-
function renderSpecs(specs) {
|
|
1525
|
-
if (specs.length === 0) return "";
|
|
1526
|
-
return [specsHeader, ...specs.flatMap(specLines)].join("\n");
|
|
1527
|
-
}
|
|
1528
|
-
/** The order a report counts verdicts in: strongest evidence first, then what needs attention. */
|
|
1529
|
-
const verdictOrder = [
|
|
1530
|
-
"PROVEN",
|
|
1531
|
-
"TESTED",
|
|
1532
|
-
"CHECKED",
|
|
1533
|
-
"REFUTED",
|
|
1534
|
-
"CONFLICT",
|
|
1535
|
-
"UNKNOWN"
|
|
1536
|
-
];
|
|
1537
|
-
/**
|
|
1538
|
-
* `eutaxy report` as text: the spec verdicts grouped by module, in the
|
|
1539
|
-
* order given, and one closing line counting them by verdict.
|
|
1540
|
-
*/
|
|
1541
|
-
function renderSpecReport(specs) {
|
|
1542
|
-
if (specs.length === 0) return "No specs found.";
|
|
1543
|
-
const modules = [...new Set(specs.map((v) => v.module))];
|
|
1544
|
-
const out = ["Specs (TESTED means held on inputs generated from the parameter types, which is not a proof; PROVEN is one, by the named engine)"];
|
|
1545
|
-
for (const m of modules) {
|
|
1546
|
-
out.push("", m);
|
|
1547
|
-
for (const v of specs) if (v.module === m) out.push(...specLines(v));
|
|
1548
|
-
}
|
|
1549
|
-
const counts = verdictOrder.map((k) => [k, specs.filter((v) => v.kind === k).length]).filter(([, n]) => n > 0).map(([k, n]) => `${n} ${k}`);
|
|
1550
|
-
out.push("", `${specs.length} propert${specs.length === 1 ? "y" : "ies"} in ${modules.length} module${modules.length === 1 ? "" : "s"}: ${counts.join(", ")}`);
|
|
1551
|
-
return out.join("\n");
|
|
1552
|
-
}
|
|
1553
|
-
/** `eutaxy report --json`: canonical, with the schema version, the spec verdicts and nothing else. */
|
|
1554
|
-
function renderSpecReportJson(specs) {
|
|
1555
|
-
return canonicalJson({
|
|
1556
|
-
schemaVersion: 1,
|
|
1557
|
-
generator: "eutaxy",
|
|
1558
|
-
specs
|
|
1559
|
-
});
|
|
1560
|
-
}
|
|
1561
|
-
function specLines(v) {
|
|
1562
|
-
const out = [];
|
|
1563
|
-
const what = `${v.function} ${v.property}`;
|
|
1564
|
-
switch (v.kind) {
|
|
1565
|
-
case "CHECKED":
|
|
1566
|
-
out.push(` CHECKED ${what}: held on ${v.inputs} input(s)${v.discarded > 0 ? `, ${v.discarded} outside the claim` : ""}`);
|
|
1567
|
-
break;
|
|
1568
|
-
case "TESTED":
|
|
1569
|
-
out.push(` TESTED ${what}: held on ${v.inputs} generated input(s)${v.checked === void 0 ? "" : ` and ${v.checked} the simulator passed`}${v.discarded > 0 ? `, ${v.discarded} outside the claim` : ""}`);
|
|
1570
|
-
break;
|
|
1571
|
-
case "PROVEN": {
|
|
1572
|
-
const beside = [...v.tested === void 0 ? [] : [`${v.tested} generated input(s)`], ...v.checked === void 0 ? [] : [`${v.checked} the simulator passed`]];
|
|
1573
|
-
out.push(` PROVEN ${what}: by ${v.engine.name} ${v.engine.version}${beside.length > 0 ? `; also held on ${beside.join(" and ")}` : ""}`);
|
|
1574
|
-
break;
|
|
1575
|
-
}
|
|
1576
|
-
case "CONFLICT":
|
|
1577
|
-
out.push(` CONFLICT ${what}: ${v.proven.name} ${v.proven.version} proves it, ${v.refuted.name} ${v.refuted.version} refutes it; not resolved automatically`);
|
|
1578
|
-
if (v.refuted.counterexample) out.push(` ${v.refuted.counterexample.binders.map((b) => `${b.name} = ${b.value}`).join(", ")}`);
|
|
1579
|
-
break;
|
|
1580
|
-
case "REFUTED": {
|
|
1581
|
-
const c = v.counterexample;
|
|
1582
|
-
const where = v.rung === "PROVEN" ? `by ${v.engine?.name ?? "an engine"}` : c.call === void 0 ? "on a generated input" : `at ${c.call}`;
|
|
1583
|
-
out.push(` REFUTED ${what}: false ${where}${c.error ? `, which threw ${c.error}` : ""}`);
|
|
1584
|
-
if (c.binders.length > 0) out.push(` ${c.binders.map((b) => `${b.name} = ${b.value}`).join(", ")}`);
|
|
1585
|
-
out.push(` ${v.text.replace(/\s+/g, " ")}`);
|
|
1586
|
-
break;
|
|
1587
|
-
}
|
|
1588
|
-
case "UNKNOWN": out.push(` UNKNOWN ${what}: ${v.cause}: ${v.reason}`);
|
|
1589
|
-
}
|
|
1590
|
-
for (const a of v.assumptions) if (v.kind === "PROVEN" || a.startsWith("not PROVEN by ")) out.push(` ${a}`);
|
|
1591
|
-
return out;
|
|
1592
|
-
}
|
|
1593
|
-
function clip(s, max) {
|
|
1594
|
-
return s.length <= max ? s : `${s.slice(0, max - 1)}…`;
|
|
1595
|
-
}
|
|
1596
|
-
function pad(s, width) {
|
|
1597
|
-
return s.length >= width ? s : s + " ".repeat(width - s.length);
|
|
1598
|
-
}
|
|
1599
|
-
/** The trace as a fixed-width table; evidence rows are marked with `*`. */
|
|
1600
|
-
function renderTrace(log, evidence = []) {
|
|
1601
|
-
const rows = log.entries.map((e) => [
|
|
1602
|
-
evidence.includes(e.seq) ? "*" : " ",
|
|
1603
|
-
String(e.seq),
|
|
1604
|
-
e.invocation,
|
|
1605
|
-
e.kind,
|
|
1606
|
-
e.target,
|
|
1607
|
-
e.op,
|
|
1608
|
-
clip(canonicalJson(e.payload), 72)
|
|
1609
|
-
]);
|
|
1610
|
-
const header = [
|
|
1611
|
-
" ",
|
|
1612
|
-
"seq",
|
|
1613
|
-
"invocation",
|
|
1614
|
-
"kind",
|
|
1615
|
-
"target",
|
|
1616
|
-
"op",
|
|
1617
|
-
"payload"
|
|
1618
|
-
];
|
|
1619
|
-
const widths = header.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length)));
|
|
1620
|
-
const line = (cells) => cells.map((c, i) => i === cells.length - 1 ? c : pad(c, widths[i])).join(" ").trimEnd();
|
|
1621
|
-
return [line(header), ...rows.map(line)].join("\n");
|
|
1622
|
-
}
|
|
1623
|
-
/** A schedule's faults, one a line, as a report lists them. */
|
|
1624
|
-
function faultLines(schedule) {
|
|
1625
|
-
if (schedule.faults.length === 0) return [" no injected faults"];
|
|
1626
|
-
return schedule.faults.map((f) => ` ${f.fault} at ${f.invocation} effect #${f.ordinal} (${f.target} ${f.op})`);
|
|
1627
|
-
}
|
|
1628
|
-
/**
|
|
1629
|
-
* A readable report: verdict, what it rests on, for a violation the schedule and trace, and for a
|
|
1630
|
-
* scenario that could not be decided the schedule of the run that reached that.
|
|
1631
|
-
*/
|
|
1632
|
-
function renderText(verdict) {
|
|
1633
|
-
const out = [];
|
|
1634
|
-
const r = verdict.reached;
|
|
1635
|
-
out.push(`${verdict.kind} ${verdict.scenario} (seed ${String(verdict.seed)})`);
|
|
1636
|
-
switch (verdict.kind) {
|
|
1637
|
-
case "VIOLATED":
|
|
1638
|
-
out.push("");
|
|
1639
|
-
out.push(`Invariant ${verdict.violation.invariant} is violated: ${verdict.violation.message}`);
|
|
1640
|
-
out.push(`Keys: ${verdict.violation.keys.join(", ")}`);
|
|
1641
|
-
out.push("");
|
|
1642
|
-
if (verdict.pinned === void 0) {
|
|
1643
|
-
out.push(`Schedule (run seed ${verdict.schedule.seed}), events kept: ${verdict.keptEvents.join(", ")}`);
|
|
1644
|
-
out.push(...faultLines(verdict.schedule));
|
|
1645
|
-
out.push(`Shrunk: ${verdict.shrunk.eventsRemoved} event(s) and ${verdict.shrunk.faultsRemoved} fault(s) removed in ${verdict.shrunk.runs} run(s)`);
|
|
1646
|
-
} else {
|
|
1647
|
-
out.push(`Pinned schedule ${JSON.stringify(verdict.pinned)} (run seed ${verdict.schedule.seed}), as it ran, not shrunk; events: ${verdict.keptEvents.join(", ")}`);
|
|
1648
|
-
out.push(...faultLines(verdict.schedule));
|
|
1649
|
-
for (const u of verdict.unplaced ?? []) out.push(` not placed: ${u}`);
|
|
1650
|
-
}
|
|
1651
|
-
out.push("");
|
|
1652
|
-
out.push("Trace:");
|
|
1653
|
-
out.push(renderTrace(verdict.trace, verdict.violation.evidence));
|
|
1654
|
-
break;
|
|
1655
|
-
case "BOUNDED": {
|
|
1656
|
-
const b = verdict.bounds;
|
|
1657
|
-
out.push("");
|
|
1658
|
-
out.push("No violation found within the stated bounds. This is not a proof.");
|
|
1659
|
-
out.push(`Bounds: faults per run ≤ ${b.maxFaultsPerRun}, redeliveries ≤ ${b.maxRedeliveries}, concurrent invocations ≤ ${b.maxConcurrentInvocations}, budget ${b.budgetMs} ms`);
|
|
1660
|
-
break;
|
|
1661
|
-
}
|
|
1662
|
-
case "UNSUPPORTED":
|
|
1663
|
-
out.push("");
|
|
1664
|
-
out.push(`Eutaxy could not decide this scenario (${verdict.cause}): ${verdict.reason}`);
|
|
1665
|
-
if (verdict.schedule) {
|
|
1666
|
-
out.push("");
|
|
1667
|
-
out.push(`Schedule of the run that reached it (run seed ${verdict.schedule.seed}), as it ran, not shrunk:`);
|
|
1668
|
-
out.push(...faultLines(verdict.schedule));
|
|
1669
|
-
if (verdict.schedule.turns) out.push(` ${verdict.schedule.turns.length} turn(s) picked; the JSON report has them, to replay the run`);
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
out.push("");
|
|
1673
|
-
out.push(`Explored: ${r.runs} run(s), ${r.effectPoints} effect point(s), ${r.faultsInjected} fault(s) injected, ${r.elapsedMs} ms`);
|
|
1674
|
-
const e = r.exhaustive;
|
|
1675
|
-
if (e) {
|
|
1676
|
-
const stopped = {
|
|
1677
|
-
VIOLATED: "stopped at the first violation",
|
|
1678
|
-
BOUNDED: "stopped at the budget before every schedule ran",
|
|
1679
|
-
UNSUPPORTED: "stopped where the scenario could not be decided"
|
|
1680
|
-
}[verdict.kind];
|
|
1681
|
-
out.push(`Exhaustive: ${e.complete ? "every schedule within the bounds ran" : stopped} (${e.schedules} schedules${e.reduction ? ", partial-order reduction" : ""})`);
|
|
1682
|
-
}
|
|
1683
|
-
out.push("Assumptions:");
|
|
1684
|
-
for (const a of verdict.assumptions) out.push(` - ${a}`);
|
|
1685
|
-
return out.join("\n");
|
|
1686
|
-
}
|
|
1687
|
-
export { endpointNumber as _, renderText as a, describeVerdict as b, emitUnsupportedTest as c, testedRung as d, shrinkRefutation as f, endpointBigInt as g, conforms as h, renderSpecs as i, checkSpecModule as l, evaluate as m, renderSpecReport as n, renderTrace as o, checkedRung as p, renderSpecReportJson as r, emitRegressionTest as s, renderJson as t, specLadder as u, render as v, describeType as y };
|
|
1072
|
+
export { edgeLists as a, generateAssignment as c, render as d, describeType as f, edgeAssignmentCount as i, shrinkCandidates as l, conforms as n, endpointBigInt as o, edgeAssignment as r, endpointNumber as s, CannotGenerate as t, copy as u };
|
|
1688
1073
|
|
|
1689
|
-
//# sourceMappingURL=
|
|
1074
|
+
//# sourceMappingURL=generate-TBJM3-2P.mjs.map
|