eutaxy 0.15.0 → 0.16.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 (34) hide show
  1. package/README.md +6 -6
  2. package/dist/aws.d.mts +2 -2
  3. package/dist/aws.d.mts.map +1 -1
  4. package/dist/aws.mjs +53 -79
  5. package/dist/aws.mjs.map +1 -1
  6. package/dist/bin.mjs +1 -1
  7. package/dist/{cli-CzGCMudc.mjs → cli-DbLlYHTY.mjs} +406 -196
  8. package/dist/cli-DbLlYHTY.mjs.map +1 -0
  9. package/dist/cli.mjs +1 -1
  10. package/dist/cloudflare.d.mts +7 -7
  11. package/dist/cloudflare.d.mts.map +1 -1
  12. package/dist/cloudflare.mjs +2 -2
  13. package/dist/delivery-invariants-90c5xBcd.mjs +44 -0
  14. package/dist/delivery-invariants-90c5xBcd.mjs.map +1 -0
  15. package/dist/{delivery-invariants-DzMy3iPs.d.mts → delivery-invariants-B8ZZnCZg.d.mts} +2 -2
  16. package/dist/{delivery-invariants-DzMy3iPs.d.mts.map → delivery-invariants-B8ZZnCZg.d.mts.map} +1 -1
  17. package/dist/{explore-B52m-wmk.d.mts → explore-DlwIUowm.d.mts} +2 -2
  18. package/dist/{explore-B52m-wmk.d.mts.map → explore-DlwIUowm.d.mts.map} +1 -1
  19. package/dist/index.d.mts +2 -2
  20. package/dist/index.mjs +2 -2
  21. package/dist/{platform-Ba1Kvdza.d.mts → platform-DPJTjpSr.d.mts} +56 -4
  22. package/dist/{platform-Ba1Kvdza.d.mts.map → platform-DPJTjpSr.d.mts.map} +1 -1
  23. package/dist/{src-ud5wEfnx.mjs → src-CmHdPsZy.mjs} +1297 -388
  24. package/dist/src-CmHdPsZy.mjs.map +1 -0
  25. package/dist/{src-nwQA9Xwr.mjs → src-Dz9Wn2vL.mjs} +2 -2
  26. package/dist/{src-nwQA9Xwr.mjs.map → src-Dz9Wn2vL.mjs.map} +1 -1
  27. package/dist/{workerd-Be43_PZo.mjs → workerd-D9cUGjYv.mjs} +571 -483
  28. package/dist/workerd-D9cUGjYv.mjs.map +1 -0
  29. package/package.json +3 -3
  30. package/dist/cli-CzGCMudc.mjs.map +0 -1
  31. package/dist/delivery-invariants-BCtvzAfW.mjs +0 -67
  32. package/dist/delivery-invariants-BCtvzAfW.mjs.map +0 -1
  33. package/dist/src-ud5wEfnx.mjs.map +0 -1
  34. package/dist/workerd-Be43_PZo.mjs.map +0 -1
@@ -1,13 +1,13 @@
1
- import { L as canonicalJson } from "./src-ud5wEfnx.mjs";
2
- import { _ as render, a as renderText, c as checkSpecModule, d as shrinkRefutation, g as endpointNumber, h as endpointBigInt, i as renderSpecs, m as conforms, n as renderSpecReport, p as evaluate, r as renderSpecReportJson, v as describeType } from "./src-nwQA9Xwr.mjs";
1
+ import { R as canonicalJson } from "./src-CmHdPsZy.mjs";
2
+ import { _ as render, a as renderText, c as checkSpecModule, d as shrinkRefutation, g as endpointNumber, h as endpointBigInt, i as renderSpecs, m as conforms, n as renderSpecReport, p as evaluate, r as renderSpecReportJson, v as describeType } from "./src-Dz9Wn2vL.mjs";
3
3
  import { n as isSpec } from "./combinators-CLfsPfhT.mjs";
4
4
  import { t as aggregate } from "./provers-DS44OeEm.mjs";
5
- import { G as cloudflareRegressionTest, n as globKey, r as specKey } from "./workerd-Be43_PZo.mjs";
5
+ import { G as cloudflareRegressionTest, n as globKey, r as specKey } from "./workerd-D9cUGjYv.mjs";
6
6
  import { createRequire, registerHooks } from "node:module";
7
7
  import { Readable } from "node:stream";
8
8
  import { createHash, randomBytes } from "node:crypto";
9
- import { chmodSync, closeSync, copyFileSync, createReadStream, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, renameSync, rmSync, symlinkSync, writeFileSync, writeSync } from "node:fs";
10
- import { homedir, tmpdir } from "node:os";
9
+ import { chmodSync, closeSync, copyFileSync, createReadStream, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, symlinkSync, writeFileSync, writeSync } from "node:fs";
10
+ import { availableParallelism, homedir, tmpdir } from "node:os";
11
11
  import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
12
12
  import { createZstdDecompress, inflateRawSync } from "node:zlib";
13
13
  import { fork, spawn } from "node:child_process";
@@ -17,6 +17,65 @@ import { API, DiagnosticCategory, SymbolFlags, TypeFlags, TypeFormatFlags } from
17
17
  import * as is from "typescript/ast/is";
18
18
  import { fileURLToPath, pathToFileURL } from "node:url";
19
19
  import { createInterface } from "node:readline";
20
+ import { StringDecoder } from "node:string_decoder";
21
+ // packages/prover/src/pool.ts
22
+ /**
23
+ * Independent jobs run a few at a time, with their results in the order of
24
+ * the items whatever order the jobs finish in: what an engine needs to run
25
+ * one solver process per property, or the report one process per module,
26
+ * without the answer depending on which finished first. A job that throws
27
+ * rejects the pool, and no job is started after it.
28
+ */
29
+ /** `work` on every item, at most `limit` at once; the results in item order. */
30
+ async function inPool(items, limit, work) {
31
+ const results = new Array(items.length);
32
+ let next = 0;
33
+ let failed = false;
34
+ const worker = async () => {
35
+ while (next < items.length && !failed) {
36
+ const i = next++;
37
+ try {
38
+ results[i] = await work(items[i], i);
39
+ } catch (err) {
40
+ failed = true;
41
+ throw err;
42
+ }
43
+ }
44
+ };
45
+ const workers = Math.max(1, Math.min(Math.floor(limit), items.length));
46
+ await Promise.all(Array.from({ length: workers }, worker));
47
+ return results;
48
+ }
49
+ /**
50
+ * `inPool`, and no item starts `size` or more places past the earliest one
51
+ * not yet finished: when an early job is slow, the jobs behind it wait
52
+ * rather than run ahead, so whatever the finished ones hold for their turn
53
+ * (the report's held output) is never more than `size - 1` items' worth.
54
+ */
55
+ async function inWindow(items, size, work) {
56
+ const n = Math.max(1, Math.floor(size));
57
+ const finished = items.map(() => false);
58
+ let earliest = 0;
59
+ let failed = false;
60
+ const waiting = /* @__PURE__ */ new Map();
61
+ return inPool(items, n, async (item, i) => {
62
+ if (i >= earliest + n) await new Promise((go) => waiting.set(i, go));
63
+ if (failed) throw new Error("an earlier job failed");
64
+ try {
65
+ return await work(item, i);
66
+ } catch (err) {
67
+ failed = true;
68
+ throw err;
69
+ } finally {
70
+ finished[i] = true;
71
+ while (finished[earliest]) earliest++;
72
+ for (const [j, go] of waiting) if (j < earliest + n) {
73
+ waiting.delete(j);
74
+ go();
75
+ }
76
+ }
77
+ });
78
+ }
20
79
  // packages/cli/src/args.ts
21
80
  function parseArgs(argv, booleans = []) {
22
81
  const positionals = [];
@@ -5397,8 +5456,9 @@ function prelude(module) {
5397
5456
  * One property's script: the binders as constants, what their types say
5398
5457
  * beyond their sorts, the precondition asserted, the claim's negation
5399
5458
  * asserted. `unsat` proves the claim; `sat` comes with the binders' values.
5459
+ * `definitions` is the module's `prelude`, when the caller already has it.
5400
5460
  */
5401
- function propertyScript(property, module) {
5461
+ function propertyScript(property, module, definitions = prelude(module)) {
5402
5462
  if (property.kind !== "forall" || !property.ensures) fail("not a forall property");
5403
5463
  const e = env(module);
5404
5464
  const types = property.binders.map((b) => binderType(b.name, b.type, module));
@@ -5409,7 +5469,7 @@ function propertyScript(property, module) {
5409
5469
  }));
5410
5470
  return {
5411
5471
  script: `${[
5412
- prelude(module),
5472
+ definitions,
5413
5473
  ...binders.map((b) => `(declare-const ${b.symbol} ${sort(b.type, module)})`),
5414
5474
  ...binders.flatMap((b) => {
5415
5475
  const c = wellFormed(b.symbol, b.type, module);
@@ -5786,7 +5846,7 @@ function prepare(input) {
5786
5846
  for (const property of fn.properties) {
5787
5847
  if (property.kind !== "forall") continue;
5788
5848
  try {
5789
- scripts.set(key(fn.name, property.name), propertyScript(property, module));
5849
+ scripts.set(key(fn.name, property.name), propertyScript(property, module, pre));
5790
5850
  } catch (err) {
5791
5851
  if (!(err instanceof OutsideSubset)) throw err;
5792
5852
  skipped.set(key(fn.name, property.name), err.message);
@@ -5813,6 +5873,8 @@ function prepare(input) {
5813
5873
  * Node does not, is completed in a sibling copy that is imported and then
5814
5874
  * removed, so the copy's own relative imports still resolve.
5815
5875
  */
5876
+ /** Names each sibling copy apart from another made in the same millisecond. */
5877
+ let copies = 0;
5816
5878
  async function importSpecFile(specPath) {
5817
5879
  try {
5818
5880
  return await import(pathToFileURL(specPath).href);
@@ -5823,7 +5885,7 @@ async function importSpecFile(specPath) {
5823
5885
  const dir = dirname(specPath);
5824
5886
  const rewritten = source.replace(/(from\s*["'])(\.{1,2}\/[^"']+?)(\.js)?(["'])/g, (whole, pre, rel, _js, post) => existsSync(join(dir, `${rel}.ts`)) ? `${pre}${rel}.ts${post}` : whole);
5825
5887
  if (rewritten === source) throw err;
5826
- const copy = join(dir, `.eutaxy-replay-${process.pid}-${Date.now()}.props.ts`);
5888
+ const copy = join(dir, `.eutaxy-replay-${process.pid}-${Date.now()}-${copies++}.props.ts`);
5827
5889
  writeFileSync(copy, rewritten);
5828
5890
  try {
5829
5891
  return await import(pathToFileURL(copy).href);
@@ -5832,12 +5894,23 @@ async function importSpecFile(specPath) {
5832
5894
  }
5833
5895
  }
5834
5896
  }
5897
+ function specLoader() {
5898
+ const loaded = /* @__PURE__ */ new Map();
5899
+ return (specPath) => {
5900
+ let ns = loaded.get(specPath);
5901
+ if (ns === void 0) {
5902
+ ns = importSpecFile(specPath);
5903
+ loaded.set(specPath, ns);
5904
+ }
5905
+ return ns;
5906
+ };
5907
+ }
5835
5908
  /** The spec file's export for a property, loaded for replay, or why it could not be. */
5836
- async function loadSpec(specPath, property, fn) {
5909
+ async function loadSpec(load, specPath, property, fn) {
5837
5910
  if (specPath === void 0) return "the engine was not given the spec file's path to replay the counterexample";
5838
5911
  let ns;
5839
5912
  try {
5840
- ns = await importSpecFile(specPath);
5913
+ ns = await load(specPath);
5841
5914
  } catch (err) {
5842
5915
  return `the spec file could not be loaded to replay the counterexample: ${String(err)}`;
5843
5916
  }
@@ -5893,41 +5966,40 @@ async function proveModule(input) {
5893
5966
  const errors = readAnswer(checked.run.stdout).errors;
5894
5967
  if (checked.run.code !== 0 || errors.length > 0 || answers.length !== input.extra.length || failed >= 0) return allWith(unknown("unsupported", `the emitted SMT failed a translation check${failed >= 0 ? ` (${input.extra[failed]})` : ""}: ${errors[0] ?? (checked.run.stderr || checked.run.stdout).trim().split("\n")[0] ?? ""}`));
5895
5968
  }
5896
- for (const fn of inSubset) for (const property of fn.properties) {
5897
- if (property.kind === "total") {
5898
- results.push({
5899
- function: fn.name,
5900
- property: property.name,
5901
- outcome: unknown("unsupported", "total is not decided by this engine (Lean proves it by acceptance)")
5902
- });
5903
- continue;
5904
- }
5969
+ const load = specLoader();
5970
+ const proofs = await inPool(inSubset.flatMap((fn) => fn.properties.map((property) => ({
5971
+ fn,
5972
+ property
5973
+ }))), Math.min(8, availableParallelism()), async ({ fn, property }) => {
5974
+ if (property.kind === "total") return {
5975
+ function: fn.name,
5976
+ property: property.name,
5977
+ outcome: unknown("unsupported", "total is not decided by this engine (Lean proves it by acceptance)")
5978
+ };
5905
5979
  const k = key(fn.name, property.name);
5906
5980
  const why = skipped.get(k);
5907
- if (why !== void 0) {
5908
- results.push({
5909
- function: fn.name,
5910
- property: property.name,
5911
- outcome: unknown("unsupported", why)
5912
- });
5913
- continue;
5914
- }
5981
+ if (why !== void 0) return {
5982
+ function: fn.name,
5983
+ property: property.name,
5984
+ outcome: unknown("unsupported", why)
5985
+ };
5915
5986
  const script = scripts.get(k);
5916
- if (!script) continue;
5987
+ if (!script) return void 0;
5917
5988
  const solved = await solve(solver, script.script, options);
5918
- results.push({
5989
+ return {
5919
5990
  function: fn.name,
5920
5991
  property: property.name,
5921
- outcome: await outcomeOf(solved, script, module, property, fn.name, input)
5922
- });
5923
- }
5992
+ outcome: await outcomeOf(solved, script, module, property, fn.name, input, load)
5993
+ };
5994
+ });
5995
+ for (const proof of proofs) if (proof) results.push(proof);
5924
5996
  return {
5925
5997
  results,
5926
5998
  smt,
5927
5999
  specErrors
5928
6000
  };
5929
6001
  }
5930
- async function outcomeOf(solved, script, module, property, fn, input) {
6002
+ async function outcomeOf(solved, script, module, property, fn, input, load) {
5931
6003
  if (solved.run.timedOut) return unknown("gave_up", `Z3 did not finish within ${input.timeoutMs ?? 12e4} ms`);
5932
6004
  if (solved.run.code === null) return unknown("unavailable", `Z3 could not be run: ${solved.run.stderr.trim()}`);
5933
6005
  const answer = readAnswer(solved.run.stdout);
@@ -5948,7 +6020,7 @@ async function outcomeOf(solved, script, module, property, fn, input) {
5948
6020
  }
5949
6021
  const rendered = property.binders.map((b, i) => `${b.name} = ${render(values[i])}`).join(", ");
5950
6022
  if (!property.binders.every((b, i) => conforms(b.type, values[i]))) return unknown("unsupported", `Z3's model lies outside the parameter types (${rendered}): the engine's model of the types is wider than the types`);
5951
- const spec = await loadSpec(input.specPath, property, fn);
6023
+ const spec = await loadSpec(load, input.specPath, property, fn);
5952
6024
  if (typeof spec === "string") return unknown("unsupported", `${spec} (the model: ${rendered})`);
5953
6025
  const evaluation = evaluate(spec, values);
5954
6026
  if ("malformed" in evaluation) return unknown("unsupported", `the property could not be evaluated on the model (${rendered}): ${evaluation.malformed}`);
@@ -6005,6 +6077,152 @@ function resolveAsTypeScript() {
6005
6077
  }
6006
6078
  } });
6007
6079
  }
6080
+ // packages/cli/src/wrangler.ts
6081
+ /**
6082
+ * Wrangler config reading, one copy for `check` and `draft`: JSON and JSONC
6083
+ * parsing, the bindings a config declares, and the rules that name their
6084
+ * resources (a D1 database's id, an R2 bucket's name, a KV namespace's id,
6085
+ * which Durable Object classes are SQLite-backed). Only JSON and JSONC are
6086
+ * read; a TOML config is refused.
6087
+ */
6088
+ /**
6089
+ * JSON with comments and trailing commas, as wrangler.jsonc allows: comments
6090
+ * are removed outside strings, a comma before `}` or `]` dropped, and the
6091
+ * rest is JSON.
6092
+ */
6093
+ function parseJsonc(text) {
6094
+ let out = "";
6095
+ let i = 0;
6096
+ /** The index of the next character that is neither whitespace nor inside a comment, from `from`. */
6097
+ const nextToken = (from) => {
6098
+ let k = from;
6099
+ for (;;) {
6100
+ while (k < text.length && /\s/.test(text[k])) k++;
6101
+ if (text[k] === "/" && text[k + 1] === "/") while (k < text.length && text[k] !== "\n") k++;
6102
+ else if (text[k] === "/" && text[k + 1] === "*") {
6103
+ const end = text.indexOf("*/", k + 2);
6104
+ k = end < 0 ? text.length : end + 2;
6105
+ } else return k;
6106
+ }
6107
+ };
6108
+ while (i < text.length) {
6109
+ const c = text[i];
6110
+ if (c === "\"") {
6111
+ let j = i + 1;
6112
+ while (j < text.length && text[j] !== "\"") j += text[j] === "\\" ? 2 : 1;
6113
+ out += text.slice(i, j + 1);
6114
+ i = j + 1;
6115
+ } else if (c === "/" && text[i + 1] === "/") while (i < text.length && text[i] !== "\n") i++;
6116
+ else if (c === "/" && text[i + 1] === "*") {
6117
+ const end = text.indexOf("*/", i + 2);
6118
+ i = end < 0 ? text.length : end + 2;
6119
+ } else if (c === ",") {
6120
+ const next = text[nextToken(i + 1)];
6121
+ if (next !== "}" && next !== "]") out += c;
6122
+ i++;
6123
+ } else {
6124
+ out += c;
6125
+ i++;
6126
+ }
6127
+ }
6128
+ return JSON.parse(out);
6129
+ }
6130
+ /** Read a wrangler config as an object; only JSON and JSONC are read. */
6131
+ function readWranglerConfig(path) {
6132
+ const ext = extname(path);
6133
+ if (ext !== ".json" && ext !== ".jsonc") throw new Error(`${basename(path)}: eutaxy reads a wrangler config as JSON or JSONC; a TOML config is not read`);
6134
+ const parsed = parseJsonc(readFileSync(path, "utf8"));
6135
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${basename(path)}: not a wrangler config object`);
6136
+ return parsed;
6137
+ }
6138
+ /** The `name` of a wrangler config, when the config can be read and names one. */
6139
+ function workerName(path) {
6140
+ try {
6141
+ const name = readWranglerConfig(path)["name"];
6142
+ return typeof name === "string" && name ? name : void 0;
6143
+ } catch {
6144
+ return;
6145
+ }
6146
+ }
6147
+ /** The object entries of a config list; anything else is no entry. */
6148
+ const list = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "object" && x) : [];
6149
+ const str$1 = (v, fallback = "") => typeof v === "string" ? v : fallback;
6150
+ const strings$1 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
6151
+ /** A D1 binding's database: its id, else its name, else the binding (the same database in two configs is one). */
6152
+ const d1Id = (db) => str$1(db["database_id"], str$1(db["database_name"], str$1(db["binding"])));
6153
+ /** An R2 binding's bucket: its name, else the binding. */
6154
+ const r2Bucket = (b) => str$1(b["bucket_name"], str$1(b["binding"]));
6155
+ /** A KV binding's namespace: its id, else the binding. */
6156
+ const kvId = (k) => str$1(k["id"], str$1(k["binding"]));
6157
+ /**
6158
+ * The SQLite-backed Durable Object classes of a config, with its migrations applied in order as
6159
+ * wrangler applies them: a class is SQLite-backed from the migration that created it so, through
6160
+ * renames, until one deletes it.
6161
+ */
6162
+ function sqliteClasses(config) {
6163
+ const sqlite = /* @__PURE__ */ new Set();
6164
+ for (const m of list(config["migrations"])) {
6165
+ for (const c of strings$1(m["new_sqlite_classes"])) sqlite.add(c);
6166
+ for (const r of list(m["renamed_classes"])) {
6167
+ const from = str$1(r["from"]);
6168
+ if (sqlite.delete(from)) sqlite.add(str$1(r["to"]));
6169
+ }
6170
+ for (const c of strings$1(m["deleted_classes"])) sqlite.delete(c);
6171
+ }
6172
+ return sqlite;
6173
+ }
6174
+ /** Read a config's bindings. */
6175
+ function readBindings(config) {
6176
+ const sqlite = sqliteClasses(config);
6177
+ const dos = config["durable_objects"];
6178
+ const queues = config["queues"];
6179
+ const vars = {};
6180
+ const rawVars = config["vars"];
6181
+ if (typeof rawVars === "object" && rawVars !== null) for (const [k, v] of Object.entries(rawVars)) vars[k] = v;
6182
+ return {
6183
+ name: str$1(config["name"]) || void 0,
6184
+ main: str$1(config["main"]) || void 0,
6185
+ d1: list(config["d1_databases"]).map((d) => ({
6186
+ binding: str$1(d["binding"]),
6187
+ id: d1Id(d)
6188
+ })),
6189
+ r2: list(config["r2_buckets"]).map((b) => ({
6190
+ binding: str$1(b["binding"]),
6191
+ bucket: r2Bucket(b)
6192
+ })),
6193
+ kv: list(config["kv_namespaces"]).map((k) => ({
6194
+ binding: str$1(k["binding"]),
6195
+ id: kvId(k)
6196
+ })),
6197
+ durableObjects: list(dos?.bindings).map((b) => {
6198
+ const className = str$1(b["class_name"]);
6199
+ return {
6200
+ binding: str$1(b["name"]),
6201
+ className,
6202
+ sqlite: sqlite.has(className),
6203
+ ...b["script_name"] === void 0 ? {} : { scriptName: str$1(b["script_name"]) }
6204
+ };
6205
+ }),
6206
+ workflows: list(config["workflows"]).map((w) => ({
6207
+ binding: str$1(w["binding"]),
6208
+ className: str$1(w["class_name"]),
6209
+ name: str$1(w["name"], str$1(w["binding"]))
6210
+ })),
6211
+ services: list(config["services"]).map((s) => ({
6212
+ binding: str$1(s["binding"]),
6213
+ service: str$1(s["service"]),
6214
+ ...typeof s["entrypoint"] === "string" ? { entrypoint: s["entrypoint"] } : {},
6215
+ ...typeof s["props"] === "object" && s["props"] !== null ? { props: s["props"] } : {}
6216
+ })),
6217
+ queues: list(queues?.producers).map((p) => ({
6218
+ binding: str$1(p["binding"]),
6219
+ queue: str$1(p["queue"])
6220
+ })),
6221
+ vars,
6222
+ sqliteClasses: [...sqlite],
6223
+ keys: Object.keys(config)
6224
+ };
6225
+ }
6008
6226
  // packages/cli/src/callees.ts
6009
6227
  /**
6010
6228
  * The callees a scenario names (`callee()` steps), read on the Node side for
@@ -6127,58 +6345,6 @@ function isolateBindings(callees) {
6127
6345
  }
6128
6346
  return names;
6129
6347
  }
6130
- /**
6131
- * JSON with comments and trailing commas, as wrangler.jsonc allows: comments
6132
- * are removed outside strings, a comma before `}` or `]` dropped, and the
6133
- * rest is JSON.
6134
- */
6135
- function parseJsonc(text) {
6136
- let out = "";
6137
- let i = 0;
6138
- /** The index of the next character that is neither whitespace nor inside a comment, from `from`. */
6139
- const nextToken = (from) => {
6140
- let k = from;
6141
- for (;;) {
6142
- while (k < text.length && /\s/.test(text[k])) k++;
6143
- if (text[k] === "/" && text[k + 1] === "/") while (k < text.length && text[k] !== "\n") k++;
6144
- else if (text[k] === "/" && text[k + 1] === "*") {
6145
- const end = text.indexOf("*/", k + 2);
6146
- k = end < 0 ? text.length : end + 2;
6147
- } else return k;
6148
- }
6149
- };
6150
- while (i < text.length) {
6151
- const c = text[i];
6152
- if (c === "\"") {
6153
- let j = i + 1;
6154
- while (j < text.length && text[j] !== "\"") j += text[j] === "\\" ? 2 : 1;
6155
- out += text.slice(i, j + 1);
6156
- i = j + 1;
6157
- } else if (c === "/" && text[i + 1] === "/") while (i < text.length && text[i] !== "\n") i++;
6158
- else if (c === "/" && text[i + 1] === "*") {
6159
- const end = text.indexOf("*/", i + 2);
6160
- i = end < 0 ? text.length : end + 2;
6161
- } else if (c === ",") {
6162
- const next = text[nextToken(i + 1)];
6163
- if (next !== "}" && next !== "]") out += c;
6164
- i++;
6165
- } else {
6166
- out += c;
6167
- i++;
6168
- }
6169
- }
6170
- return JSON.parse(out);
6171
- }
6172
- /** Read a wrangler config as an object; only JSON and JSONC are read here. */
6173
- function readWranglerConfig(path) {
6174
- const ext = extname(path);
6175
- if (ext !== ".json" && ext !== ".jsonc") throw new Error(`${basename(path)}: eutaxy check reads a callee's wrangler config as JSON or JSONC; a TOML config is not read`);
6176
- const parsed = parseJsonc(readFileSync(path, "utf8"));
6177
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${basename(path)}: not a wrangler config object`);
6178
- return parsed;
6179
- }
6180
- const list$1 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "object" && x) : [];
6181
- const str$1 = (v, fallback = "") => typeof v === "string" ? v : fallback;
6182
6348
  /** The keys of a wrangler config whose bindings the command carries into the isolate. */
6183
6349
  const carried = /* @__PURE__ */ new Set([
6184
6350
  "name",
@@ -6211,67 +6377,22 @@ const carried = /* @__PURE__ */ new Set([
6211
6377
  /** Read a callee's wrangler config into what the isolate needs; `scenarioDir` resolves the step's paths. */
6212
6378
  function readCalleeConfig(step, scenarioDir) {
6213
6379
  const path = resolve(scenarioDir, step.config);
6214
- const config = readWranglerConfig(path);
6215
- const name = str$1(config["name"]);
6216
- if (!name) throw new Error(`${basename(path)}: the callee's wrangler config has no name, which qualifies its bindings`);
6217
- const notAdded = [];
6218
- const sqlite = /* @__PURE__ */ new Set();
6219
- const strings = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
6220
- for (const m of list$1(config["migrations"])) {
6221
- for (const c of strings(m["new_sqlite_classes"])) sqlite.add(c);
6222
- for (const r of list$1(m["renamed_classes"])) {
6223
- const from = str$1(r["from"]);
6224
- if (sqlite.delete(from)) sqlite.add(str$1(r["to"]));
6225
- }
6226
- for (const c of strings(m["deleted_classes"])) sqlite.delete(c);
6227
- }
6228
- const durableObjects = [];
6229
- const dos = config["durable_objects"];
6230
- for (const b of list$1(dos?.bindings)) {
6231
- const className = str$1(b["class_name"]);
6232
- const scriptName = b["script_name"] === void 0 ? void 0 : str$1(b["script_name"]);
6233
- durableObjects.push({
6234
- binding: str$1(b["name"]),
6235
- className,
6236
- sqlite: sqlite.has(className),
6237
- ...scriptName === void 0 ? {} : { scriptName }
6238
- });
6239
- }
6240
- const queues = config["queues"];
6241
- for (const key of Object.keys(config)) if (!carried.has(key)) notAdded.push(key);
6242
- const vars = {};
6243
- const rawVars = config["vars"];
6244
- if (typeof rawVars === "object" && rawVars !== null) for (const [k, v] of Object.entries(rawVars)) vars[k] = v;
6380
+ const bindings = readBindings(readWranglerConfig(path));
6381
+ if (bindings.name === void 0) throw new Error(`${basename(path)}: the callee's wrangler config has no name, which qualifies its bindings`);
6245
6382
  return {
6246
6383
  binding: step.binding,
6247
- name,
6384
+ name: bindings.name,
6248
6385
  entry: resolve(scenarioDir, step.entry),
6249
- d1: list$1(config["d1_databases"]).map((d) => ({
6250
- binding: str$1(d["binding"]),
6251
- id: str$1(d["database_id"], str$1(d["database_name"], str$1(d["binding"])))
6252
- })),
6253
- r2: list$1(config["r2_buckets"]).map((b) => ({
6254
- binding: str$1(b["binding"]),
6255
- bucket: str$1(b["bucket_name"], str$1(b["binding"]))
6256
- })),
6257
- kv: list$1(config["kv_namespaces"]).map((k) => ({
6258
- binding: str$1(k["binding"]),
6259
- id: str$1(k["id"], str$1(k["binding"]))
6260
- })),
6261
- durableObjects,
6262
- workflows: list$1(config["workflows"]).map((w) => ({
6263
- binding: str$1(w["binding"]),
6264
- className: str$1(w["class_name"]),
6265
- name: str$1(w["name"], str$1(w["binding"]))
6266
- })),
6267
- services: list$1(config["services"]).map((s) => str$1(s["binding"])),
6268
- queues: list$1(queues?.producers).map((p) => ({
6269
- binding: str$1(p["binding"]),
6270
- queue: str$1(p["queue"])
6271
- })),
6272
- vars,
6273
- sqliteClasses: [...sqlite],
6274
- notAdded
6386
+ d1: bindings.d1,
6387
+ r2: bindings.r2,
6388
+ kv: bindings.kv,
6389
+ durableObjects: bindings.durableObjects,
6390
+ workflows: bindings.workflows,
6391
+ services: bindings.services.map((s) => s.binding),
6392
+ queues: bindings.queues,
6393
+ vars: bindings.vars,
6394
+ sqliteClasses: bindings.sqliteClasses,
6395
+ notAdded: bindings.keys.filter((key) => !carried.has(key))
6275
6396
  };
6276
6397
  }
6277
6398
  /** A Worker's name as an identifier prefix (`my-worker` → `my_worker`, `1st` → `_1st`). */
@@ -6391,32 +6512,14 @@ function miniflareOptionsSource(callees, isolate = noIsolate, callerServices = [
6391
6512
  /** The caller's resources from its wrangler config, when the config can be read (JSON or JSONC); none otherwise. */
6392
6513
  function readCallerResources(wranglerPath) {
6393
6514
  try {
6394
- const config = readWranglerConfig(wranglerPath);
6395
- const dos = config["durable_objects"];
6515
+ const bindings = readBindings(readWranglerConfig(wranglerPath));
6396
6516
  return {
6397
- name: str$1(config["name"]) || void 0,
6398
- d1: list$1(config["d1_databases"]).map((d) => ({
6399
- binding: str$1(d["binding"]),
6400
- id: str$1(d["database_id"], str$1(d["database_name"], str$1(d["binding"])))
6401
- })),
6402
- r2: list$1(config["r2_buckets"]).map((b) => ({
6403
- binding: str$1(b["binding"]),
6404
- bucket: str$1(b["bucket_name"], str$1(b["binding"]))
6405
- })),
6406
- kv: list$1(config["kv_namespaces"]).map((k) => ({
6407
- binding: str$1(k["binding"]),
6408
- id: str$1(k["id"], str$1(k["binding"]))
6409
- })),
6410
- durableObjects: list$1(dos?.bindings).map((b) => ({
6411
- binding: str$1(b["name"]),
6412
- className: str$1(b["class_name"]),
6413
- ...b["script_name"] === void 0 ? {} : { scriptName: str$1(b["script_name"]) }
6414
- })),
6415
- services: list$1(config["services"]).map((b) => ({
6416
- binding: str$1(b["binding"]),
6417
- ...typeof b["entrypoint"] === "string" ? { entrypoint: b["entrypoint"] } : {},
6418
- ...typeof b["props"] === "object" && b["props"] !== null ? { props: b["props"] } : {}
6419
- }))
6517
+ name: bindings.name,
6518
+ d1: bindings.d1,
6519
+ r2: bindings.r2,
6520
+ kv: bindings.kv,
6521
+ durableObjects: bindings.durableObjects,
6522
+ services: bindings.services
6420
6523
  };
6421
6524
  } catch {
6422
6525
  return;
@@ -6945,7 +7048,6 @@ function cleanUp(workDir, stamp) {
6945
7048
  * imported or run: the config is read as JSON or JSONC and the module's
6946
7049
  * source (with the modules it imports relatively) is scanned as text.
6947
7050
  */
6948
- const list = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "object" && x) : [];
6949
7051
  const text$1 = (v) => typeof v === "string" ? v : "";
6950
7052
  const record = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : {};
6951
7053
  /** A path relative to `from`, with forward slashes and a leading `./`. */
@@ -6953,11 +7055,6 @@ function ref(from, to) {
6953
7055
  const p = relative(from, to).split("\\").join("/");
6954
7056
  return p.startsWith(".") ? p : `./${p}`;
6955
7057
  }
6956
- /** Read a wrangler config as JSON or JSONC; TOML is not read. */
6957
- function readConfig(path) {
6958
- if (extname(path) !== ".json" && extname(path) !== ".jsonc") throw new Error(`${basename(path)}: eutaxy draft reads a wrangler config as JSON or JSONC; a TOML config is not read`);
6959
- return readWranglerConfig(path);
6960
- }
6961
7058
  /** Binding kinds the simulation does not proxy: a run that touches one is UNSUPPORTED. */
6962
7059
  const unmodelled = {
6963
7060
  kv_namespaces: "KV namespace",
@@ -6974,12 +7071,6 @@ const unmodelled = {
6974
7071
  version_metadata: "version metadata",
6975
7072
  pipelines: "pipeline"
6976
7073
  };
6977
- /** The SQLite-backed classes of a config's migrations (the ones created so, as wrangler applies them). */
6978
- function sqliteClasses(config) {
6979
- const out = /* @__PURE__ */ new Set();
6980
- for (const m of list(config["migrations"])) for (const c of Array.isArray(m["new_sqlite_classes"]) ? m["new_sqlite_classes"] : []) if (typeof c === "string") out.add(c);
6981
- return out;
6982
- }
6983
7074
  /**
6984
7075
  * The schema file of a D1 binding, beside its config: `schema.sql`, else `<database_name>.sql`, else the
6985
7076
  * only `.sql` file there; `found` false when none is, and the step names `schema.sql` to create.
@@ -7037,10 +7128,10 @@ function configsByName(root, depth = 3) {
7037
7128
  const path = join(dir, e.name);
7038
7129
  if (e.isDirectory()) {
7039
7130
  if (left > 0 && e.name !== "node_modules" && !e.name.startsWith(".")) walk(path, left - 1);
7040
- } else if (e.name === "wrangler.jsonc" || e.name === "wrangler.json") try {
7041
- const name = text$1(readConfig(path)["name"]);
7042
- if (name && !out.has(name)) out.set(name, path);
7043
- } catch {}
7131
+ } else if (e.name === "wrangler.jsonc" || e.name === "wrangler.json") {
7132
+ const name = workerName(path);
7133
+ if (name !== void 0 && !out.has(name)) out.set(name, path);
7134
+ }
7044
7135
  }
7045
7136
  };
7046
7137
  walk(root, depth);
@@ -7101,7 +7192,7 @@ function agentSegment(binding) {
7101
7192
  return (kebab.startsWith("-") ? kebab.slice(1) : kebab).replaceAll("_", "-").replace(/-$/, "");
7102
7193
  }
7103
7194
  function draftScenario(input) {
7104
- const config = readConfig(input.config);
7195
+ const config = readWranglerConfig(input.config);
7105
7196
  const configDir = dirname(input.config);
7106
7197
  const scenarioDir = input.scenarioDir ?? configDir;
7107
7198
  const name = text$1(config["name"]) || basename(configDir);
@@ -7120,9 +7211,8 @@ function draftScenario(input) {
7120
7211
  const found = service && service !== name ? others.get(service) : void 0;
7121
7212
  if (found !== void 0) callees.set(service, found);
7122
7213
  }
7123
- const d1Id = (db) => text$1(db["database_id"]) || text$1(db["database_name"]) || text$1(db["binding"]);
7124
7214
  const callerDatabases = new Map(list(config["d1_databases"]).map((db) => [d1Id(db), text$1(db["binding"])]));
7125
- const callerBuckets = new Map(list(config["r2_buckets"]).map((b) => [text$1(b["bucket_name"]) || text$1(b["binding"]), text$1(b["binding"])]));
7215
+ const callerBuckets = new Map(list(config["r2_buckets"]).map((b) => [r2Bucket(b), text$1(b["binding"])]));
7126
7216
  /** Classes of a callee's script the caller binds itself: one namespace, set up under the caller's name. */
7127
7217
  const sharedClasses = new Set(list(record(config["durable_objects"])["bindings"]).filter((b) => callees.has(text$1(b["script_name"]))).map((b) => `${text$1(b["script_name"])}:${text$1(b["class_name"])}`));
7128
7218
  /** The setup steps of one Worker's own resources: the caller's (prefix ""), or a callee's (`<name>/`). */
@@ -7164,7 +7254,7 @@ function draftScenario(input) {
7164
7254
  if (!prefix && callees.has(script)) setup.push({
7165
7255
  kind: "durable_object",
7166
7256
  binding,
7167
- sqlite: sqliteClasses(readConfig(callees.get(script))).has(className)
7257
+ sqlite: sqliteClasses(readWranglerConfig(callees.get(script))).has(className)
7168
7258
  });
7169
7259
  else notes.push(`Durable Object ${prefix}${binding} is ${script}'s class ${className}: name ${script} with callee() to run it`);
7170
7260
  continue;
@@ -7182,7 +7272,7 @@ function draftScenario(input) {
7182
7272
  for (const b of list(cfg["r2_buckets"])) {
7183
7273
  const binding = text$1(b["binding"]);
7184
7274
  if (!binding) continue;
7185
- const shared = prefix ? callerBuckets.get(text$1(b["bucket_name"]) || binding) : void 0;
7275
+ const shared = prefix ? callerBuckets.get(r2Bucket(b)) : void 0;
7186
7276
  if (shared !== void 0) {
7187
7277
  notes.push(`R2 ${prefix}${binding} is the caller's bucket ${shared}: set it up and read it as ${shared}`);
7188
7278
  continue;
@@ -7230,7 +7320,7 @@ function draftScenario(input) {
7230
7320
  notes.push(`service binding ${binding}: no wrangler config named ${service || "(none)"} under the scenario's directory, so its answers are scripted; script them with service(), or run that Worker with callee()`);
7231
7321
  continue;
7232
7322
  }
7233
- const callee = readConfig(calleeConfig);
7323
+ const callee = readWranglerConfig(calleeConfig);
7234
7324
  const calleeDir = dirname(calleeConfig);
7235
7325
  const calleeMain = resolve(calleeDir, text$1(callee["main"]));
7236
7326
  setup.push({
@@ -7917,6 +8007,75 @@ async function runInstall(options) {
7917
8007
  return exitCodes.error;
7918
8008
  }
7919
8009
  }
8010
+ // packages/cli/src/held-output.ts
8011
+ /**
8012
+ * What a module running ahead of its turn writes, held until its turn:
8013
+ * in memory up to a limit, then in a file, so a module that writes a lot
8014
+ * while an earlier one is still running cannot exhaust the report's heap.
8015
+ * Drained, it gives back exactly the text it was given, in order.
8016
+ */
8017
+ var HeldOutput = class {
8018
+ #limit;
8019
+ #readBytes;
8020
+ #chunks = [];
8021
+ #bytes = 0;
8022
+ #dir;
8023
+ #fd;
8024
+ /** `limitBytes` is held in memory; past it, everything goes to a file, read back `readBytes` at a time. */
8025
+ constructor(limitBytes = 1 << 20, readBytes = 65536) {
8026
+ this.#limit = limitBytes;
8027
+ this.#readBytes = readBytes;
8028
+ }
8029
+ /** Whether the text held so far went past the limit into a file. */
8030
+ get spilled() {
8031
+ return this.#fd !== void 0;
8032
+ }
8033
+ push(text) {
8034
+ const bytes = Buffer.byteLength(text);
8035
+ if (this.#fd === void 0 && this.#bytes + bytes <= this.#limit) {
8036
+ this.#chunks.push(text);
8037
+ this.#bytes += bytes;
8038
+ return;
8039
+ }
8040
+ if (this.#fd === void 0) {
8041
+ this.#dir = mkdtempSync(join(tmpdir(), "eutaxy-report-"));
8042
+ this.#fd = openSync(join(this.#dir, "held"), "w+");
8043
+ }
8044
+ writeSync(this.#fd, text);
8045
+ }
8046
+ /** Everything held, in order, to `out`; then nothing is held and the file is gone. */
8047
+ drain(out) {
8048
+ for (const text of this.#chunks) out(text);
8049
+ this.#chunks = [];
8050
+ this.#bytes = 0;
8051
+ if (this.#fd === void 0) return;
8052
+ try {
8053
+ const decoder = new StringDecoder("utf8");
8054
+ const buffer = Buffer.alloc(this.#readBytes);
8055
+ for (let at = 0;;) {
8056
+ const n = readSync(this.#fd, buffer, 0, buffer.length, at);
8057
+ if (n === 0) break;
8058
+ at += n;
8059
+ const text = decoder.write(buffer.subarray(0, n));
8060
+ if (text !== "") out(text);
8061
+ }
8062
+ const rest = decoder.end();
8063
+ if (rest !== "") out(rest);
8064
+ } finally {
8065
+ this.discard();
8066
+ }
8067
+ }
8068
+ /** Drop the file, if any. */
8069
+ discard() {
8070
+ if (this.#fd !== void 0) closeSync(this.#fd);
8071
+ if (this.#dir !== void 0) rmSync(this.#dir, {
8072
+ recursive: true,
8073
+ force: true
8074
+ });
8075
+ this.#fd = void 0;
8076
+ this.#dir = void 0;
8077
+ }
8078
+ };
7920
8079
  // packages/cli/src/report.ts
7921
8080
  /**
7922
8081
  * `eutaxy report [dir]`: every spec file under a directory through the
@@ -8027,6 +8186,36 @@ function testModule(m, seed, budgetMs, stderr) {
8027
8186
  });
8028
8187
  }
8029
8188
  /**
8189
+ * Every module's verdicts, a few modules' processes at a time. The verdicts
8190
+ * come back in module order, and what each module writes reaches `stderr`
8191
+ * in module order too: a module's output is held until every module before
8192
+ * it has finished (in memory up to a limit, then in a file), so the report
8193
+ * reads as if they ran one after another. No module starts eight or more
8194
+ * places past the earliest unfinished one, so at most seven modules' output
8195
+ * is held at once.
8196
+ */
8197
+ async function testModules(modules, seed, budgetMs, stderr) {
8198
+ const held = modules.map(() => new HeldOutput());
8199
+ const finished = modules.map(() => false);
8200
+ let current = 0;
8201
+ try {
8202
+ return await inWindow(modules, Math.min(8, availableParallelism()), async (m, i) => {
8203
+ const verdicts = await testModule(m, seed, budgetMs, (text) => {
8204
+ if (i === current) stderr(text);
8205
+ else held[i]?.push(text);
8206
+ });
8207
+ finished[i] = true;
8208
+ while (finished[current]) {
8209
+ current++;
8210
+ held[current]?.drain(stderr);
8211
+ }
8212
+ return verdicts;
8213
+ });
8214
+ } finally {
8215
+ for (const h of held) h.discard();
8216
+ }
8217
+ }
8218
+ /**
8030
8219
  * Write a module's open Lean goals beside its spec file as
8031
8220
  * `<spec>.goals.lean`, a proof file with every proof open, and list them.
8032
8221
  * No open goal removes a goal file left from an earlier run.
@@ -8090,8 +8279,7 @@ async function runReport(o) {
8090
8279
  for (const e of errors) o.stderr(`${e}\n`);
8091
8280
  return exitCodes.error;
8092
8281
  }
8093
- let specs = [];
8094
- for (const m of modules) specs = [...specs, ...await testModule(m, o.seed ?? "report", o.moduleBudgetMs ?? 6e4, o.stderr)];
8282
+ let specs = (await testModules(modules, o.seed ?? "report", o.moduleBudgetMs ?? 6e4, o.stderr)).flat();
8095
8283
  const goals = [];
8096
8284
  if (engines.length > 0) specs = await proveSpecs(root, modules.map((m) => ({
8097
8285
  module: m.key,
@@ -8115,7 +8303,7 @@ async function runReport(o) {
8115
8303
  }
8116
8304
  // packages/cli/src/version.ts
8117
8305
  /** The published package's version, as the MCP server reports it; the release tooling keeps it in step. */
8118
- const eutaxyVersion = "0.15.0";
8306
+ const eutaxyVersion = "0.16.0";
8119
8307
  // packages/cli/src/mcp.ts
8120
8308
  /**
8121
8309
  * `eutaxy mcp`: a Model Context Protocol server over stdio, so a coding
@@ -8819,6 +9007,28 @@ async function main(argv, io) {
8819
9007
  io.stderr(`check needs a scenario file\n\n${usage}`);
8820
9008
  return exitCodes.error;
8821
9009
  }
9010
+ if (positionals.length > 2) {
9011
+ io.stderr(`check takes one scenario file\n\n${usage}`);
9012
+ return exitCodes.error;
9013
+ }
9014
+ const checkFlags = [
9015
+ "wrangler",
9016
+ "seed",
9017
+ "max-runs",
9018
+ "budget-ms",
9019
+ "exhaustive",
9020
+ "prover",
9021
+ "json",
9022
+ "out",
9023
+ "no-regression",
9024
+ "expect-violation",
9025
+ "keep"
9026
+ ];
9027
+ const unknownFlag = Object.keys(flags).find((k) => !checkFlags.includes(k));
9028
+ if (unknownFlag !== void 0) {
9029
+ io.stderr(`check does not take --${unknownFlag}\n`);
9030
+ return exitCodes.error;
9031
+ }
8822
9032
  const maxRunsText = str("max-runs");
8823
9033
  const maxRuns = maxRunsText === void 0 ? void 0 : Number(maxRunsText);
8824
9034
  if (maxRuns !== void 0 && !(Number.isInteger(maxRuns) && maxRuns > 0)) {
@@ -8851,4 +9061,4 @@ async function main(argv, io) {
8851
9061
  }
8852
9062
  export { main as t };
8853
9063
 
8854
- //# sourceMappingURL=cli-CzGCMudc.mjs.map
9064
+ //# sourceMappingURL=cli-DbLlYHTY.mjs.map