eutaxy 0.19.0 → 0.19.1
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 +1 -1
- package/dist/aws.d.mts.map +1 -1
- package/dist/aws.mjs +12 -4
- package/dist/aws.mjs.map +1 -1
- package/dist/bin.mjs +1 -1
- package/dist/{cli-CNAKqV9R.mjs → cli-Bxjvq4p9.mjs} +2 -2
- package/dist/{cli-CNAKqV9R.mjs.map → cli-Bxjvq4p9.mjs.map} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cloudflare.d.mts +1 -1
- package/dist/cloudflare.mjs +83 -34
- package/dist/cloudflare.mjs.map +1 -1
- package/dist/{delivery-invariants-BJDck0K8.mjs → delivery-invariants-DsBHpT1n.mjs} +2 -2
- package/dist/{delivery-invariants-BJDck0K8.mjs.map → delivery-invariants-DsBHpT1n.mjs.map} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{mcp-B64Ko6y7.mjs → mcp-DEn3HnLz.mjs} +2 -2
- package/dist/{mcp-B64Ko6y7.mjs.map → mcp-DEn3HnLz.mjs.map} +1 -1
- package/dist/{src-Dx4QvrQb.mjs → src-D-MeEFn3.mjs} +36 -6
- package/dist/src-D-MeEFn3.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/src-Dx4QvrQb.mjs.map +0 -1
package/dist/bin.mjs
CHANGED
|
@@ -139,7 +139,7 @@ async function main(argv, io) {
|
|
|
139
139
|
io.stderr(`mcp takes no arguments\n\n${usage}`);
|
|
140
140
|
return exitCodes.error;
|
|
141
141
|
}
|
|
142
|
-
const { serveStdio } = await import("./mcp-
|
|
142
|
+
const { serveStdio } = await import("./mcp-DEn3HnLz.mjs");
|
|
143
143
|
return serveStdio({
|
|
144
144
|
cwd: io.cwd,
|
|
145
145
|
log: io.stderr
|
|
@@ -294,4 +294,4 @@ async function main(argv, io) {
|
|
|
294
294
|
}
|
|
295
295
|
export { main as t };
|
|
296
296
|
|
|
297
|
-
//# sourceMappingURL=cli-
|
|
297
|
+
//# sourceMappingURL=cli-Bxjvq4p9.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-CNAKqV9R.mjs","names":[],"sources":["../../cli/src/args.ts","../../cli/src/main.ts"],"sourcesContent":["/** A small argument parser: positionals, `--flag value`, `--flag=value` and boolean `--flag`. */\n\nexport interface ParsedArgs {\n readonly positionals: readonly string[];\n readonly flags: Readonly<Record<string, string | true>>;\n}\n\nexport function parseArgs(argv: readonly string[], booleans: readonly string[] = []): ParsedArgs {\n const positionals: string[] = [];\n const flags: Record<string, string | true> = {};\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i] as string;\n if (!a.startsWith(\"--\")) {\n positionals.push(a);\n continue;\n }\n const eq = a.indexOf(\"=\");\n if (eq !== -1) {\n flags[a.slice(2, eq)] = a.slice(eq + 1);\n continue;\n }\n const name = a.slice(2);\n const next = argv[i + 1];\n if (booleans.includes(name) || next === undefined || next.startsWith(\"--\")) {\n flags[name] = true;\n } else {\n flags[name] = next;\n i++;\n }\n }\n return { positionals, flags };\n}\n","import { parseArgs } from \"./args.ts\";\nimport { exitCodes, proverNames, runCheck } from \"./check.ts\";\nimport { runDraft } from \"./draft.ts\";\nimport type { Engine } from \"./install.ts\";\nimport { typescriptMissing, typescriptNeeded } from \"./specs.ts\";\n\nconst usage = `eutaxy — deterministic simulation checks and spec verdicts for Cloudflare Workers\n\nUsage:\n eutaxy check <scenario.sim.ts> [options]\n eutaxy draft [wrangler config] [--worker <module>] [--out <file>] [--json]\n eutaxy report [dir] [--prover <names>] [--seed <seed>] [--json]\n eutaxy prover install <lean|smt> [--from <url or directory>] [--json]\n eutaxy mcp\n\ncheck options:\n --wrangler <path> wrangler config (default: the one the scenario names, else\n wrangler.jsonc/json/toml beside the scenario)\n --seed <seed> exploration seed (default: the scenario file name)\n --max-runs <n> cap on exploration runs in addition to the scenario's time budget\n --budget-ms <n> replace the scenario's time budget (with --max-runs, the run cap decides)\n --exhaustive run every schedule within the bounds once (with partial-order reduction)\n --prover <names> also run the PROVEN rung with these engines on the scenario's specs\n (comma-separated; known: lean, smt)\n --json print the versioned JSON report instead of text\n --out <path> where to write the regression test on a violation, or the\n test replaying the run that met something outside the model\n --no-regression do not write either test\n --expect-violation write a regression test that asserts the violation (for corpora)\n --keep keep the generated .eutaxy/ files\n --console show what the Workers wrote to the console during the check,\n on stderr\n\ndraft writes a scenario skeleton from a wrangler config (JSON or JSONC; default:\nwrangler.jsonc or wrangler.json in the current directory) and the Worker module it names\n(--worker to name another): the bindings become setup steps (a service binding whose\nWorker's config is found under the directory becomes a callee), the handlers the drive,\nthe hosts the code fetches the externals; the invariants and the events are left as holes\nmarked TODO. It prints the scenario, or writes it to --out (never over an existing file);\nnothing is imported or run.\n\nreport runs every spec file (*.props.ts) under dir (default: the current directory)\nthrough the TESTED rung, on inputs drawn from the parameter types with the seed\n(default: report), and the PROVEN rung with --prover. No scenario runs, so nothing\nis CHECKED.\n\nprover install smt puts the pinned Z3 for this platform in Eutaxy's cache\n(EUTAXY_CACHE_DIR, else the platform's user cache), where --prover finds it first:\ndownloaded from the upstream GitHub release, or from a mirror or offline directory\nholding the same file (--from), and checked against its SHA-256 before the solver is\ntaken from it. prover install lean installs the pinned Lean through elan: the machine's\nelan, else elan put in Eutaxy's cache from its pinned installer (the PATH and the\nshell's profile untouched); the toolchain's files are checked against the pinned\ndigest. Nothing is downloaded at any other time.\n\nreport options: --goals writes each module's open Lean goals beside its spec file as\n<spec>.goals.lean (a proof file with every proof open) and lists them; needs --prover lean.\n\nmcp serves the Model Context Protocol over stdio (one JSON-RPC message per line, logs on\nstderr) for a coding agent: tools check, report, goals, prove and prover_status, each\nreturning the JSON report, and draft, returning the drafted scenario. Point the agent's\nMCP configuration at \"eutaxy mcp\".\n\nExit codes: 0 BOUNDED, 1 VIOLATED or a REFUTED or CONFLICT spec, 2 UNSUPPORTED, 3 error.\nreport: 0, or 1 for a REFUTED or CONFLICT spec, 3 error. prover install: 0, or 3.\n`;\n\nexport interface Io {\n readonly cwd: string;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n}\n\n/**\n * A part of the command that reads specs or runs an engine, loaded when its command is given: it\n * loads the TypeScript compiler, which a project that only checks scenarios need not have\n * installed. Undefined, with why on stderr, when the compiler is not there.\n */\nasync function needingTypescript<T>(\n what: string,\n load: () => Promise<T>,\n io: Io,\n): Promise<T | undefined> {\n try {\n return await load();\n } catch (err) {\n if (!typescriptMissing(err)) throw err;\n io.stderr(`${what} needs ${typescriptNeeded}\\n`);\n return undefined;\n }\n}\n\nexport async function main(argv: readonly string[], io: Io): Promise<number> {\n const { positionals, flags } = parseArgs(argv, [\n \"json\",\n \"no-regression\",\n \"expect-violation\",\n \"keep\",\n \"console\",\n \"help\",\n \"exhaustive\",\n \"goals\",\n ]);\n const command = positionals[0];\n if (!command || command === \"help\" || flags[\"help\"] === true) {\n io.stdout(usage);\n return command ? exitCodes.BOUNDED : exitCodes.error;\n }\n // A value flag given without one would otherwise read as absent: `--prover` alone must not quietly\n // skip the PROVEN rung.\n for (const k of [\"wrangler\", \"seed\", \"max-runs\", \"budget-ms\", \"prover\", \"out\", \"from\", \"worker\"])\n if (flags[k] === true) {\n io.stderr(`--${k} needs a value\\n`);\n return exitCodes.error;\n }\n const str = (k: string): string | undefined =>\n typeof flags[k] === \"string\" ? (flags[k] as string) : undefined;\n const provers = (str(\"prover\") ?? \"\")\n .split(\",\")\n .map((n) => n.trim())\n .filter((n) => n.length > 0);\n if (command === \"mcp\") {\n if (positionals.length !== 1 || Object.keys(flags).length > 0) {\n io.stderr(`mcp takes no arguments\\n\\n${usage}`);\n return exitCodes.error;\n }\n // The server, the installer and the report are loaded where a command needs them: the last two\n // load the engines and the spec reader, and with them the TypeScript compiler, which a project\n // that only checks scenarios need not have installed.\n const { serveStdio } = await import(\"./mcp.ts\");\n return serveStdio({ cwd: io.cwd, log: io.stderr });\n }\n if (command === \"prover\") {\n // The usage is checked first, from the engines' names alone; the installer is loaded once there\n // is something to install.\n const engines: readonly string[] = proverNames;\n const names = engines.join(\"|\");\n if (positionals[1] !== \"install\" || positionals.length !== 3) {\n io.stderr(`prover takes: install <${names}>\\n\\n${usage}`);\n return exitCodes.error;\n }\n const other = Object.keys(flags).find((k) => ![\"from\", \"json\"].includes(k));\n if (other !== undefined) {\n io.stderr(`prover install does not take --${other}\\n`);\n return exitCodes.error;\n }\n const engine = positionals[2] as Engine;\n if (!engines.includes(engine)) {\n io.stderr(\n `unknown engine ${positionals[2]}; the engines are ${names.replaceAll(\"|\", \", \")}\\n`,\n );\n return exitCodes.error;\n }\n const installer = await needingTypescript(\n \"eutaxy prover install\",\n () => import(\"./install.ts\"),\n io,\n );\n if (installer === undefined) return exitCodes.error;\n return installer.runInstall({\n engine,\n from: str(\"from\"),\n json: flags[\"json\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n }\n if (command === \"report\") {\n if (positionals.length > 2) {\n io.stderr(`report takes one directory\\n\\n${usage}`);\n return exitCodes.error;\n }\n const other = Object.keys(flags).find((k) => ![\"prover\", \"seed\", \"json\", \"goals\"].includes(k));\n if (other !== undefined) {\n io.stderr(`report does not take --${other}\\n`);\n return exitCodes.error;\n }\n const dir = positionals[1];\n const report = await needingTypescript(\"eutaxy report\", () => import(\"./report.ts\"), io);\n if (report === undefined) return exitCodes.error;\n const { runReport } = report;\n return runReport({\n cwd: io.cwd,\n ...(dir === undefined ? {} : { dir }),\n ...(provers.length > 0 ? { provers } : {}),\n ...(str(\"seed\") ? { seed: str(\"seed\") as string } : {}),\n ...(flags[\"goals\"] === true ? { goals: true } : {}),\n json: flags[\"json\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n }\n if (command === \"draft\") {\n if (positionals.length > 2) {\n io.stderr(`draft takes one wrangler config\\n\\n${usage}`);\n return exitCodes.error;\n }\n const other = Object.keys(flags).find((k) => ![\"worker\", \"out\", \"json\"].includes(k));\n if (other !== undefined) {\n io.stderr(`draft does not take --${other}\\n`);\n return exitCodes.error;\n }\n const config = positionals[1];\n const worker = str(\"worker\");\n const out = str(\"out\");\n return runDraft({\n cwd: io.cwd,\n ...(config === undefined ? {} : { config }),\n ...(worker === undefined ? {} : { worker }),\n ...(out === undefined ? {} : { out }),\n json: flags[\"json\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n }\n if (command !== \"check\") {\n io.stderr(`unknown command ${command}\\n\\n${usage}`);\n return exitCodes.error;\n }\n const scenario = positionals[1];\n if (!scenario) {\n io.stderr(`check needs a scenario file\\n\\n${usage}`);\n return exitCodes.error;\n }\n if (positionals.length > 2) {\n io.stderr(`check takes one scenario file\\n\\n${usage}`);\n return exitCodes.error;\n }\n const checkFlags = [\n \"wrangler\",\n \"seed\",\n \"max-runs\",\n \"budget-ms\",\n \"exhaustive\",\n \"prover\",\n \"json\",\n \"out\",\n \"no-regression\",\n \"expect-violation\",\n \"keep\",\n \"console\",\n ];\n const unknownFlag = Object.keys(flags).find((k) => !checkFlags.includes(k));\n if (unknownFlag !== undefined) {\n io.stderr(`check does not take --${unknownFlag}\\n`);\n return exitCodes.error;\n }\n const maxRunsText = str(\"max-runs\");\n const maxRuns = maxRunsText === undefined ? undefined : Number(maxRunsText);\n if (maxRuns !== undefined && !(Number.isInteger(maxRuns) && maxRuns > 0)) {\n io.stderr(`--max-runs must be a positive integer, got ${JSON.stringify(maxRunsText)}\\n`);\n return exitCodes.error;\n }\n const budgetText = str(\"budget-ms\");\n const budgetMs = budgetText === undefined ? undefined : Number(budgetText);\n if (budgetMs !== undefined && !(Number.isInteger(budgetMs) && budgetMs > 0)) {\n io.stderr(`--budget-ms must be a positive integer, got ${JSON.stringify(budgetText)}\\n`);\n return exitCodes.error;\n }\n return runCheck({\n scenario,\n cwd: io.cwd,\n ...(provers.length > 0 ? { provers } : {}),\n ...(str(\"wrangler\") ? { wrangler: str(\"wrangler\") as string } : {}),\n ...(str(\"seed\") ? { seed: str(\"seed\") as string } : {}),\n ...(maxRuns === undefined ? {} : { maxRuns }),\n ...(budgetMs === undefined ? {} : { budgetMs }),\n exhaustive: flags[\"exhaustive\"] === true,\n json: flags[\"json\"] === true,\n ...(str(\"out\") ? { out: str(\"out\") as string } : {}),\n noRegression: flags[\"no-regression\"] === true,\n expectViolation: flags[\"expect-violation\"] === true,\n keep: flags[\"keep\"] === true,\n console: flags[\"console\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n}\n"],"mappings":";;;AAOA,SAAgB,UAAU,MAAyB,WAA8B,CAAC,GAAe;CAC/F,MAAM,cAAwB,CAAC;CAC/B,MAAM,QAAuC,CAAC;CAC9C,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,IAAI,KAAK;EACf,IAAI,CAAC,EAAE,WAAW,IAAI,GAAG;GACvB,YAAY,KAAK,CAAC;GAClB;EACF;EACA,MAAM,KAAK,EAAE,QAAQ,GAAG;EACxB,IAAI,OAAO,IAAI;GACb,MAAM,EAAE,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;GACtC;EACF;EACA,MAAM,OAAO,EAAE,MAAM,CAAC;EACtB,MAAM,OAAO,KAAK,IAAI;EACtB,IAAI,SAAS,SAAS,IAAI,KAAK,SAAS,KAAA,KAAa,KAAK,WAAW,IAAI,GACvE,MAAM,QAAQ;OACT;GACL,MAAM,QAAQ;GACd;EACF;CACF;CACA,OAAO;EAAE;EAAa;CAAM;AAC9B;;ACzBA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEd,eAAe,kBACb,MACA,MACA,IACwB;CACxB,IAAI;EACF,OAAO,MAAM,KAAK;CACpB,SAAS,KAAK;EACZ,IAAI,CAAC,kBAAkB,GAAG,GAAG,MAAM;EACnC,GAAG,OAAO,GAAG,KAAK,SAAS,iBAAiB,GAAG;EAC/C;CACF;AACF;AA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H"}
|
|
1
|
+
{"version":3,"file":"cli-Bxjvq4p9.mjs","names":[],"sources":["../../cli/src/args.ts","../../cli/src/main.ts"],"sourcesContent":["/** A small argument parser: positionals, `--flag value`, `--flag=value` and boolean `--flag`. */\n\nexport interface ParsedArgs {\n readonly positionals: readonly string[];\n readonly flags: Readonly<Record<string, string | true>>;\n}\n\nexport function parseArgs(argv: readonly string[], booleans: readonly string[] = []): ParsedArgs {\n const positionals: string[] = [];\n const flags: Record<string, string | true> = {};\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i] as string;\n if (!a.startsWith(\"--\")) {\n positionals.push(a);\n continue;\n }\n const eq = a.indexOf(\"=\");\n if (eq !== -1) {\n flags[a.slice(2, eq)] = a.slice(eq + 1);\n continue;\n }\n const name = a.slice(2);\n const next = argv[i + 1];\n if (booleans.includes(name) || next === undefined || next.startsWith(\"--\")) {\n flags[name] = true;\n } else {\n flags[name] = next;\n i++;\n }\n }\n return { positionals, flags };\n}\n","import { parseArgs } from \"./args.ts\";\nimport { exitCodes, proverNames, runCheck } from \"./check.ts\";\nimport { runDraft } from \"./draft.ts\";\nimport type { Engine } from \"./install.ts\";\nimport { typescriptMissing, typescriptNeeded } from \"./specs.ts\";\n\nconst usage = `eutaxy — deterministic simulation checks and spec verdicts for Cloudflare Workers\n\nUsage:\n eutaxy check <scenario.sim.ts> [options]\n eutaxy draft [wrangler config] [--worker <module>] [--out <file>] [--json]\n eutaxy report [dir] [--prover <names>] [--seed <seed>] [--json]\n eutaxy prover install <lean|smt> [--from <url or directory>] [--json]\n eutaxy mcp\n\ncheck options:\n --wrangler <path> wrangler config (default: the one the scenario names, else\n wrangler.jsonc/json/toml beside the scenario)\n --seed <seed> exploration seed (default: the scenario file name)\n --max-runs <n> cap on exploration runs in addition to the scenario's time budget\n --budget-ms <n> replace the scenario's time budget (with --max-runs, the run cap decides)\n --exhaustive run every schedule within the bounds once (with partial-order reduction)\n --prover <names> also run the PROVEN rung with these engines on the scenario's specs\n (comma-separated; known: lean, smt)\n --json print the versioned JSON report instead of text\n --out <path> where to write the regression test on a violation, or the\n test replaying the run that met something outside the model\n --no-regression do not write either test\n --expect-violation write a regression test that asserts the violation (for corpora)\n --keep keep the generated .eutaxy/ files\n --console show what the Workers wrote to the console during the check,\n on stderr\n\ndraft writes a scenario skeleton from a wrangler config (JSON or JSONC; default:\nwrangler.jsonc or wrangler.json in the current directory) and the Worker module it names\n(--worker to name another): the bindings become setup steps (a service binding whose\nWorker's config is found under the directory becomes a callee), the handlers the drive,\nthe hosts the code fetches the externals; the invariants and the events are left as holes\nmarked TODO. It prints the scenario, or writes it to --out (never over an existing file);\nnothing is imported or run.\n\nreport runs every spec file (*.props.ts) under dir (default: the current directory)\nthrough the TESTED rung, on inputs drawn from the parameter types with the seed\n(default: report), and the PROVEN rung with --prover. No scenario runs, so nothing\nis CHECKED.\n\nprover install smt puts the pinned Z3 for this platform in Eutaxy's cache\n(EUTAXY_CACHE_DIR, else the platform's user cache), where --prover finds it first:\ndownloaded from the upstream GitHub release, or from a mirror or offline directory\nholding the same file (--from), and checked against its SHA-256 before the solver is\ntaken from it. prover install lean installs the pinned Lean through elan: the machine's\nelan, else elan put in Eutaxy's cache from its pinned installer (the PATH and the\nshell's profile untouched); the toolchain's files are checked against the pinned\ndigest. Nothing is downloaded at any other time.\n\nreport options: --goals writes each module's open Lean goals beside its spec file as\n<spec>.goals.lean (a proof file with every proof open) and lists them; needs --prover lean.\n\nmcp serves the Model Context Protocol over stdio (one JSON-RPC message per line, logs on\nstderr) for a coding agent: tools check, report, goals, prove and prover_status, each\nreturning the JSON report, and draft, returning the drafted scenario. Point the agent's\nMCP configuration at \"eutaxy mcp\".\n\nExit codes: 0 BOUNDED, 1 VIOLATED or a REFUTED or CONFLICT spec, 2 UNSUPPORTED, 3 error.\nreport: 0, or 1 for a REFUTED or CONFLICT spec, 3 error. prover install: 0, or 3.\n`;\n\nexport interface Io {\n readonly cwd: string;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n}\n\n/**\n * A part of the command that reads specs or runs an engine, loaded when its command is given: it\n * loads the TypeScript compiler, which a project that only checks scenarios need not have\n * installed. Undefined, with why on stderr, when the compiler is not there.\n */\nasync function needingTypescript<T>(\n what: string,\n load: () => Promise<T>,\n io: Io,\n): Promise<T | undefined> {\n try {\n return await load();\n } catch (err) {\n if (!typescriptMissing(err)) throw err;\n io.stderr(`${what} needs ${typescriptNeeded}\\n`);\n return undefined;\n }\n}\n\nexport async function main(argv: readonly string[], io: Io): Promise<number> {\n const { positionals, flags } = parseArgs(argv, [\n \"json\",\n \"no-regression\",\n \"expect-violation\",\n \"keep\",\n \"console\",\n \"help\",\n \"exhaustive\",\n \"goals\",\n ]);\n const command = positionals[0];\n if (!command || command === \"help\" || flags[\"help\"] === true) {\n io.stdout(usage);\n return command ? exitCodes.BOUNDED : exitCodes.error;\n }\n // A value flag given without one would otherwise read as absent: `--prover` alone must not quietly\n // skip the PROVEN rung.\n for (const k of [\"wrangler\", \"seed\", \"max-runs\", \"budget-ms\", \"prover\", \"out\", \"from\", \"worker\"])\n if (flags[k] === true) {\n io.stderr(`--${k} needs a value\\n`);\n return exitCodes.error;\n }\n const str = (k: string): string | undefined =>\n typeof flags[k] === \"string\" ? (flags[k] as string) : undefined;\n const provers = (str(\"prover\") ?? \"\")\n .split(\",\")\n .map((n) => n.trim())\n .filter((n) => n.length > 0);\n if (command === \"mcp\") {\n if (positionals.length !== 1 || Object.keys(flags).length > 0) {\n io.stderr(`mcp takes no arguments\\n\\n${usage}`);\n return exitCodes.error;\n }\n // The server, the installer and the report are loaded where a command needs them: the last two\n // load the engines and the spec reader, and with them the TypeScript compiler, which a project\n // that only checks scenarios need not have installed.\n const { serveStdio } = await import(\"./mcp.ts\");\n return serveStdio({ cwd: io.cwd, log: io.stderr });\n }\n if (command === \"prover\") {\n // The usage is checked first, from the engines' names alone; the installer is loaded once there\n // is something to install.\n const engines: readonly string[] = proverNames;\n const names = engines.join(\"|\");\n if (positionals[1] !== \"install\" || positionals.length !== 3) {\n io.stderr(`prover takes: install <${names}>\\n\\n${usage}`);\n return exitCodes.error;\n }\n const other = Object.keys(flags).find((k) => ![\"from\", \"json\"].includes(k));\n if (other !== undefined) {\n io.stderr(`prover install does not take --${other}\\n`);\n return exitCodes.error;\n }\n const engine = positionals[2] as Engine;\n if (!engines.includes(engine)) {\n io.stderr(\n `unknown engine ${positionals[2]}; the engines are ${names.replaceAll(\"|\", \", \")}\\n`,\n );\n return exitCodes.error;\n }\n const installer = await needingTypescript(\n \"eutaxy prover install\",\n () => import(\"./install.ts\"),\n io,\n );\n if (installer === undefined) return exitCodes.error;\n return installer.runInstall({\n engine,\n from: str(\"from\"),\n json: flags[\"json\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n }\n if (command === \"report\") {\n if (positionals.length > 2) {\n io.stderr(`report takes one directory\\n\\n${usage}`);\n return exitCodes.error;\n }\n const other = Object.keys(flags).find((k) => ![\"prover\", \"seed\", \"json\", \"goals\"].includes(k));\n if (other !== undefined) {\n io.stderr(`report does not take --${other}\\n`);\n return exitCodes.error;\n }\n const dir = positionals[1];\n const report = await needingTypescript(\"eutaxy report\", () => import(\"./report.ts\"), io);\n if (report === undefined) return exitCodes.error;\n const { runReport } = report;\n return runReport({\n cwd: io.cwd,\n ...(dir === undefined ? {} : { dir }),\n ...(provers.length > 0 ? { provers } : {}),\n ...(str(\"seed\") ? { seed: str(\"seed\") as string } : {}),\n ...(flags[\"goals\"] === true ? { goals: true } : {}),\n json: flags[\"json\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n }\n if (command === \"draft\") {\n if (positionals.length > 2) {\n io.stderr(`draft takes one wrangler config\\n\\n${usage}`);\n return exitCodes.error;\n }\n const other = Object.keys(flags).find((k) => ![\"worker\", \"out\", \"json\"].includes(k));\n if (other !== undefined) {\n io.stderr(`draft does not take --${other}\\n`);\n return exitCodes.error;\n }\n const config = positionals[1];\n const worker = str(\"worker\");\n const out = str(\"out\");\n return runDraft({\n cwd: io.cwd,\n ...(config === undefined ? {} : { config }),\n ...(worker === undefined ? {} : { worker }),\n ...(out === undefined ? {} : { out }),\n json: flags[\"json\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n }\n if (command !== \"check\") {\n io.stderr(`unknown command ${command}\\n\\n${usage}`);\n return exitCodes.error;\n }\n const scenario = positionals[1];\n if (!scenario) {\n io.stderr(`check needs a scenario file\\n\\n${usage}`);\n return exitCodes.error;\n }\n if (positionals.length > 2) {\n io.stderr(`check takes one scenario file\\n\\n${usage}`);\n return exitCodes.error;\n }\n const checkFlags = [\n \"wrangler\",\n \"seed\",\n \"max-runs\",\n \"budget-ms\",\n \"exhaustive\",\n \"prover\",\n \"json\",\n \"out\",\n \"no-regression\",\n \"expect-violation\",\n \"keep\",\n \"console\",\n ];\n const unknownFlag = Object.keys(flags).find((k) => !checkFlags.includes(k));\n if (unknownFlag !== undefined) {\n io.stderr(`check does not take --${unknownFlag}\\n`);\n return exitCodes.error;\n }\n const maxRunsText = str(\"max-runs\");\n const maxRuns = maxRunsText === undefined ? undefined : Number(maxRunsText);\n if (maxRuns !== undefined && !(Number.isInteger(maxRuns) && maxRuns > 0)) {\n io.stderr(`--max-runs must be a positive integer, got ${JSON.stringify(maxRunsText)}\\n`);\n return exitCodes.error;\n }\n const budgetText = str(\"budget-ms\");\n const budgetMs = budgetText === undefined ? undefined : Number(budgetText);\n if (budgetMs !== undefined && !(Number.isInteger(budgetMs) && budgetMs > 0)) {\n io.stderr(`--budget-ms must be a positive integer, got ${JSON.stringify(budgetText)}\\n`);\n return exitCodes.error;\n }\n return runCheck({\n scenario,\n cwd: io.cwd,\n ...(provers.length > 0 ? { provers } : {}),\n ...(str(\"wrangler\") ? { wrangler: str(\"wrangler\") as string } : {}),\n ...(str(\"seed\") ? { seed: str(\"seed\") as string } : {}),\n ...(maxRuns === undefined ? {} : { maxRuns }),\n ...(budgetMs === undefined ? {} : { budgetMs }),\n exhaustive: flags[\"exhaustive\"] === true,\n json: flags[\"json\"] === true,\n ...(str(\"out\") ? { out: str(\"out\") as string } : {}),\n noRegression: flags[\"no-regression\"] === true,\n expectViolation: flags[\"expect-violation\"] === true,\n keep: flags[\"keep\"] === true,\n console: flags[\"console\"] === true,\n stdout: io.stdout,\n stderr: io.stderr,\n });\n}\n"],"mappings":";;;AAOA,SAAgB,UAAU,MAAyB,WAA8B,CAAC,GAAe;CAC/F,MAAM,cAAwB,CAAC;CAC/B,MAAM,QAAuC,CAAC;CAC9C,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,IAAI,KAAK;EACf,IAAI,CAAC,EAAE,WAAW,IAAI,GAAG;GACvB,YAAY,KAAK,CAAC;GAClB;EACF;EACA,MAAM,KAAK,EAAE,QAAQ,GAAG;EACxB,IAAI,OAAO,IAAI;GACb,MAAM,EAAE,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;GACtC;EACF;EACA,MAAM,OAAO,EAAE,MAAM,CAAC;EACtB,MAAM,OAAO,KAAK,IAAI;EACtB,IAAI,SAAS,SAAS,IAAI,KAAK,SAAS,KAAA,KAAa,KAAK,WAAW,IAAI,GACvE,MAAM,QAAQ;OACT;GACL,MAAM,QAAQ;GACd;EACF;CACF;CACA,OAAO;EAAE;EAAa;CAAM;AAC9B;;ACzBA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEd,eAAe,kBACb,MACA,MACA,IACwB;CACxB,IAAI;EACF,OAAO,MAAM,KAAK;CACpB,SAAS,KAAK;EACZ,IAAI,CAAC,kBAAkB,GAAG,GAAG,MAAM;EACnC,GAAG,OAAO,GAAG,KAAK,SAAS,iBAAiB,GAAG;EAC/C;CACF;AACF;AAEA,eAAsB,KAAK,MAAyB,IAAyB;CAC3E,MAAM,EAAE,aAAa,UAAU,UAAU,MAAM;EAC7C;EACA;EACA;EACA;EACA;EACA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xjvq4p9.mjs";
|
package/dist/cloudflare.d.mts
CHANGED
|
@@ -690,7 +690,7 @@ interface CloudflarePlatformOptions {
|
|
|
690
690
|
readonly handler: WorkerHandler | WorkerEntrypointClass;
|
|
691
691
|
/** Schema SQL per D1 binding named in the scenario's setup. */
|
|
692
692
|
readonly schemas: Readonly<Record<string, string>>;
|
|
693
|
-
/**
|
|
693
|
+
/** The consumer's max_retries, a whole number that is not negative; Cloudflare's default, 3, when it sets none. */
|
|
694
694
|
readonly maxRetries?: number;
|
|
695
695
|
/**
|
|
696
696
|
* The Cloudflare Vitest plugin's test helpers (`import * as helpers from
|
package/dist/cloudflare.mjs
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
import { o as canonicalJson } from "./src-BtLZPRyG.mjs";
|
|
2
|
-
import { A as readFaults, E as validateScenario, F as redelivery, M as getPath, N as jsonEqual, P as invocationOf, S as virtualEpoch, T as defaultBounds, _ as parseBody, b as withoutNetwork, c as rawRun, d as note, f as runInvocation, g as isRedirect, h as findResponse, j as writeFaults, k as decisionFaults, l as decide, m as InjectedEffectError, n as explore, o as compareSides, p as CrashSignal, s as proxiedSide, t as observeCore, u as hostInvocation, v as replyOf, w as toJson, x as realTick, y as toResponse } from "./src-
|
|
3
|
-
import { n as atLeastOncePerMessage$1, r as atMostOncePerKey, t as atLeastOnce } from "./delivery-invariants-
|
|
2
|
+
import { A as readFaults, E as validateScenario, F as redelivery, M as getPath, N as jsonEqual, P as invocationOf, S as virtualEpoch, T as defaultBounds, _ as parseBody, b as withoutNetwork, c as rawRun, d as note, f as runInvocation, g as isRedirect, h as findResponse, j as writeFaults, k as decisionFaults, l as decide, m as InjectedEffectError, n as explore, o as compareSides, p as CrashSignal, s as proxiedSide, t as observeCore, u as hostInvocation, v as replyOf, w as toJson, x as realTick, y as toResponse } from "./src-D-MeEFn3.mjs";
|
|
3
|
+
import { n as atLeastOncePerMessage$1, r as atMostOncePerKey, t as atLeastOnce } from "./delivery-invariants-DsBHpT1n.mjs";
|
|
4
4
|
import { t as describeVerdict } from "./verdict-evEM5Gxx.mjs";
|
|
5
5
|
import { t as checkSpecModule } from "./src-DwYD3QQJ.mjs";
|
|
6
6
|
import { t as renderJson } from "./src-COuquJvI.mjs";
|
|
7
7
|
import { i as cloudflareUnsupportedTest, n as specKey, r as cloudflareRegressionTest, t as globKey } from "./keys-xtanNmuR.mjs";
|
|
8
|
+
// packages/cloudflare/src/alarm-rules.ts
|
|
9
|
+
/** The delay before the first retry. */
|
|
10
|
+
const firstRetryMs = 2e3;
|
|
11
|
+
/**
|
|
12
|
+
* How long after a run that failed its retry starts, `retryCount` being
|
|
13
|
+
* the retries made before that run: two seconds, doubled for each.
|
|
14
|
+
*/
|
|
15
|
+
function retryDelayMs$2(retryCount) {
|
|
16
|
+
return firstRetryMs * doublings(retryCount);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Two to the power of `count`, written out for the counts a retry
|
|
20
|
+
* follows, since `**` is outside the subset: no retry follows the sixth,
|
|
21
|
+
* so nothing reads past the last line.
|
|
22
|
+
*/
|
|
23
|
+
function doublings(count) {
|
|
24
|
+
if (count <= 0) return 1;
|
|
25
|
+
if (count === 1) return 2;
|
|
26
|
+
if (count === 2) return 4;
|
|
27
|
+
if (count === 3) return 8;
|
|
28
|
+
if (count === 4) return 16;
|
|
29
|
+
return 32;
|
|
30
|
+
}
|
|
31
|
+
/** The generation a `setAlarm` or `deleteAlarm` starts: one no alarm of the object had before. */
|
|
32
|
+
function nextGeneration(generation) {
|
|
33
|
+
return generation + 1;
|
|
34
|
+
}
|
|
35
|
+
/** Whether an alarm event or a retry of it is superseded: the object's alarm is of another generation, set again or deleted since. */
|
|
36
|
+
function superseded(generation, current) {
|
|
37
|
+
return generation !== current;
|
|
38
|
+
}
|
|
8
39
|
// packages/cloudflare/src/background.ts
|
|
9
40
|
const CUT_OFF = ["cut_off"];
|
|
10
41
|
/**
|
|
@@ -2031,13 +2062,14 @@ async function hostedInObject(hooks, inv, objects, binding, id, object, point, p
|
|
|
2031
2062
|
* `setAlarm` replaces it, execution is at least once, and a handler that
|
|
2032
2063
|
* throws is retried with exponential backoff starting at two seconds, up to
|
|
2033
2064
|
* six retries, with `{ retryCount, isRetry }`. `setAlarm` inside a
|
|
2034
|
-
* transaction takes effect only if the transaction commits.
|
|
2065
|
+
* transaction takes effect only if the transaction commits. How many
|
|
2066
|
+
* retries, how long before each and which alarm is superseded are the
|
|
2067
|
+
* rules of alarm-rules.ts, whose claims are proved; this file decides
|
|
2068
|
+
* none of the three itself, and counts an alarm's retries as its event's
|
|
2069
|
+
* attempts less one, by which `redelivery` applies the limit.
|
|
2035
2070
|
*/
|
|
2036
2071
|
/** `EventRef.source` of an alarm event. */
|
|
2037
2072
|
const alarmSource = "durable_object_alarm";
|
|
2038
|
-
/** Cloudflare retries a failed alarm handler up to six times, after 2 s, 4 s, 8 s, ... */
|
|
2039
|
-
const maxRetries = 6;
|
|
2040
|
-
const firstRetryMs = 2e3;
|
|
2041
2073
|
/** The alarms of one namespace's objects; the platform clears it before each run. */
|
|
2042
2074
|
var AlarmBook = class {
|
|
2043
2075
|
entries = /* @__PURE__ */ new Map();
|
|
@@ -2049,7 +2081,6 @@ var AlarmBook = class {
|
|
|
2049
2081
|
if (!e) {
|
|
2050
2082
|
e = {
|
|
2051
2083
|
time: null,
|
|
2052
|
-
seq: 0,
|
|
2053
2084
|
gen: 0,
|
|
2054
2085
|
firings: 0
|
|
2055
2086
|
};
|
|
@@ -2065,19 +2096,17 @@ function alarmControl(book, binding, id, object, hooks) {
|
|
|
2065
2096
|
get: () => entry.time,
|
|
2066
2097
|
set: (time) => {
|
|
2067
2098
|
entry.time = time;
|
|
2068
|
-
entry.
|
|
2069
|
-
entry.gen = entry.seq;
|
|
2099
|
+
entry.gen = nextGeneration(entry.gen);
|
|
2070
2100
|
const data = {
|
|
2071
2101
|
binding,
|
|
2072
2102
|
gen: entry.gen,
|
|
2073
2103
|
id,
|
|
2074
2104
|
object,
|
|
2075
|
-
time,
|
|
2076
2105
|
retryCount: 0
|
|
2077
2106
|
};
|
|
2078
2107
|
const now = Date.now();
|
|
2079
2108
|
hooks().enqueue({
|
|
2080
|
-
id: `alarm:${binding}:${object}:${entry.
|
|
2109
|
+
id: `alarm:${binding}:${object}:${entry.gen}`,
|
|
2081
2110
|
attempt: 1,
|
|
2082
2111
|
source: alarmSource,
|
|
2083
2112
|
data,
|
|
@@ -2086,8 +2115,7 @@ function alarmControl(book, binding, id, object, hooks) {
|
|
|
2086
2115
|
},
|
|
2087
2116
|
delete: () => {
|
|
2088
2117
|
entry.time = null;
|
|
2089
|
-
entry.
|
|
2090
|
-
entry.gen = entry.seq;
|
|
2118
|
+
entry.gen = nextGeneration(entry.gen);
|
|
2091
2119
|
},
|
|
2092
2120
|
unsupported: (reason) => hooks().unsupported(`Durable Object ${binding} ${object}: ${reason}`)
|
|
2093
2121
|
};
|
|
@@ -2199,7 +2227,7 @@ async function takeOverAlarms(storage, alarm) {
|
|
|
2199
2227
|
async function runAlarm(hooks, d, id, object, info, gen) {
|
|
2200
2228
|
await d.objects.run(d.binding, id, object, async (instance) => {
|
|
2201
2229
|
const entry = d.book.entry(id);
|
|
2202
|
-
if (entry.gen
|
|
2230
|
+
if (superseded(gen, entry.gen)) return;
|
|
2203
2231
|
entry.time = null;
|
|
2204
2232
|
const handler = instance.alarm;
|
|
2205
2233
|
if (typeof handler !== "function") {
|
|
@@ -2210,22 +2238,19 @@ async function runAlarm(hooks, d, id, object, info, gen) {
|
|
|
2210
2238
|
});
|
|
2211
2239
|
}
|
|
2212
2240
|
/**
|
|
2213
|
-
* Fire an alarm event: skip it when the object's alarm has since
|
|
2214
|
-
*
|
|
2215
|
-
* with backoff when the handler fails, crashes, or a fault says it
|
|
2241
|
+
* Fire an alarm event: skip it when the object's alarm has since been set
|
|
2242
|
+
* again or deleted, run `alarm()` as one effect otherwise, and schedule a
|
|
2243
|
+
* retry with backoff when the handler fails, crashes, or a fault says it
|
|
2244
|
+
* did.
|
|
2216
2245
|
*/
|
|
2217
2246
|
async function deliverAlarm(event, hooks, maxRedeliveries, d) {
|
|
2218
2247
|
const a = event.data;
|
|
2219
2248
|
const entry = d.book.entry(a.id);
|
|
2220
|
-
if (
|
|
2249
|
+
if (superseded(a.gen, entry.gen)) return {
|
|
2221
2250
|
status: "completed",
|
|
2222
2251
|
followUps: []
|
|
2223
2252
|
};
|
|
2224
2253
|
if (a.retryCount === 0) {
|
|
2225
|
-
if (entry.time !== a.time) return {
|
|
2226
|
-
status: "completed",
|
|
2227
|
-
followUps: []
|
|
2228
|
-
};
|
|
2229
2254
|
if (entry.firings >= d.limit) {
|
|
2230
2255
|
entry.time = null;
|
|
2231
2256
|
d.bookkeep("alarm_not_fired", {
|
|
@@ -2259,21 +2284,21 @@ async function deliverAlarm(event, hooks, maxRedeliveries, d) {
|
|
|
2259
2284
|
return null;
|
|
2260
2285
|
}, () => null);
|
|
2261
2286
|
if (status !== "completed") {
|
|
2262
|
-
const next = redelivery(event,
|
|
2287
|
+
const next = redelivery(event, 6, { maxRedeliveries });
|
|
2263
2288
|
if (next) {
|
|
2264
|
-
const retryAt = Date.now() +
|
|
2289
|
+
const retryAt = Date.now() + retryDelayMs$2(a.retryCount);
|
|
2265
2290
|
const data = {
|
|
2266
2291
|
...a,
|
|
2267
2292
|
retryCount: a.retryCount + 1
|
|
2268
2293
|
};
|
|
2269
|
-
if (
|
|
2294
|
+
if (!superseded(a.gen, entry.gen)) entry.time = retryAt;
|
|
2270
2295
|
hooks.enqueue({
|
|
2271
2296
|
...next,
|
|
2272
2297
|
data,
|
|
2273
2298
|
at: retryAt
|
|
2274
2299
|
});
|
|
2275
2300
|
} else {
|
|
2276
|
-
if (
|
|
2301
|
+
if (!superseded(a.gen, entry.gen)) entry.time = null;
|
|
2277
2302
|
d.bookkeep("alarm_gave_up", {
|
|
2278
2303
|
object: a.object,
|
|
2279
2304
|
retries: a.retryCount
|
|
@@ -4925,8 +4950,31 @@ async function deliverRequest(event, hooks, spec, drive, invocation, worker) {
|
|
|
4925
4950
|
followUps: []
|
|
4926
4951
|
};
|
|
4927
4952
|
}
|
|
4953
|
+
// packages/cloudflare/src/queue-decision.ts
|
|
4954
|
+
/** The decision that stands after a call: the first made, which no later call replaces. */
|
|
4955
|
+
function standsAfter(standing, call) {
|
|
4956
|
+
return standing === "none" ? call : standing;
|
|
4957
|
+
}
|
|
4958
|
+
/** Whether a call takes effect: only one made while no decision stands. */
|
|
4959
|
+
function takesEffect(standing) {
|
|
4960
|
+
return standing === "none";
|
|
4961
|
+
}
|
|
4962
|
+
/** Whether the platform acknowledges the message itself: its handler completed without deciding. */
|
|
4963
|
+
function acknowledgedImplicitly(completed, standing) {
|
|
4964
|
+
return completed && standing === "none";
|
|
4965
|
+
}
|
|
4966
|
+
/** Whether the delivery was handled, so that the message is not delivered again: its decision is an acknowledgement. */
|
|
4967
|
+
function handled(standing) {
|
|
4968
|
+
return standing === "ack";
|
|
4969
|
+
}
|
|
4928
4970
|
// packages/cloudflare/src/queues.ts
|
|
4929
|
-
/**
|
|
4971
|
+
/**
|
|
4972
|
+
* Queue delivery: one invocation per delivery of a message, redelivered
|
|
4973
|
+
* until acked or dead-lettered. Which call takes effect, when the
|
|
4974
|
+
* platform acknowledges for the handler and whether the delivery was
|
|
4975
|
+
* handled are the rule of queue-decision.ts, whose claims are proved;
|
|
4976
|
+
* this file decides none of them itself.
|
|
4977
|
+
*/
|
|
4930
4978
|
/** Deep-copy JSON data so a handler that mutates its message cannot leak into other runs. */
|
|
4931
4979
|
function cloneJson(value) {
|
|
4932
4980
|
return JSON.parse(JSON.stringify(value));
|
|
@@ -4935,8 +4983,8 @@ function cloneJson(value) {
|
|
|
4935
4983
|
async function deliverMessage$1(event, hooks, spec, drive, invocation, worker, maxRetries) {
|
|
4936
4984
|
const queueTarget = `Queue:${drive.queue}`;
|
|
4937
4985
|
const inv = hooks.startInvocation(invocation);
|
|
4938
|
-
/**
|
|
4939
|
-
const state = {
|
|
4986
|
+
/** The decision that stands for the message: Cloudflare honours the first, and later ones are ignored. */
|
|
4987
|
+
const state = { standing: "none" };
|
|
4940
4988
|
const background = [];
|
|
4941
4989
|
const decisionPoint = (op, args) => ({
|
|
4942
4990
|
invocation,
|
|
@@ -4947,9 +4995,9 @@ async function deliverMessage$1(event, hooks, spec, drive, invocation, worker, m
|
|
|
4947
4995
|
});
|
|
4948
4996
|
/** The first decision wins; a later one is recorded as not effective. */
|
|
4949
4997
|
const take = (op) => () => {
|
|
4950
|
-
|
|
4951
|
-
state.
|
|
4952
|
-
return
|
|
4998
|
+
const effective = takesEffect(state.standing);
|
|
4999
|
+
state.standing = standsAfter(state.standing, op);
|
|
5000
|
+
return effective;
|
|
4953
5001
|
};
|
|
4954
5002
|
const effective = (e) => ({ effective: e });
|
|
4955
5003
|
/** Records the handler's call; the result says whether it took effect. */
|
|
@@ -4985,7 +5033,7 @@ async function deliverMessage$1(event, hooks, spec, drive, invocation, worker, m
|
|
|
4985
5033
|
const handler = worker.handler.queue;
|
|
4986
5034
|
if (!handler) throw new Error("the Worker has no queue() handler");
|
|
4987
5035
|
let status = (await runInvocation(hooks, inv, () => handler.call(worker.handler, batch, worker.env, execution))).status;
|
|
4988
|
-
if (status === "completed"
|
|
5036
|
+
if (acknowledgedImplicitly(status === "completed", state.standing)) {
|
|
4989
5037
|
const implicit = decisionPoint("ack", {
|
|
4990
5038
|
messageId: event.id,
|
|
4991
5039
|
implicit: true,
|
|
@@ -4995,7 +5043,7 @@ async function deliverMessage$1(event, hooks, spec, drive, invocation, worker, m
|
|
|
4995
5043
|
}
|
|
4996
5044
|
if (await drainBackground(hooks, inv, invocation, queueTarget, background)) status = "crashed";
|
|
4997
5045
|
const followUps = [];
|
|
4998
|
-
if (state.
|
|
5046
|
+
if (!handled(state.standing)) {
|
|
4999
5047
|
const next = redelivery(event, maxRetries, spec.bounds);
|
|
5000
5048
|
if (next) followUps.push(next);
|
|
5001
5049
|
else note(hooks, {
|
|
@@ -5701,6 +5749,7 @@ function createCloudflarePlatform(options) {
|
|
|
5701
5749
|
/** The name a binding is known by: itself, or the name it is an alias of. */
|
|
5702
5750
|
const canonical = (name) => aliases[name] ?? name;
|
|
5703
5751
|
const maxRetries = options.maxRetries ?? 3;
|
|
5752
|
+
if (!(Number.isInteger(maxRetries) && maxRetries >= 0)) throw new Error("maxRetries must be a non-negative integer");
|
|
5704
5753
|
let hooksRef = null;
|
|
5705
5754
|
const connections = new Connections();
|
|
5706
5755
|
const ctx = {
|