eutaxy 0.9.1 → 0.10.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 +10 -8
- package/dist/aws.d.mts +2 -2
- package/dist/aws.d.mts.map +1 -1
- package/dist/aws.mjs +20 -36
- package/dist/aws.mjs.map +1 -1
- package/dist/bin.mjs +2 -2
- package/dist/cli-Di86EM3f.mjs +2 -0
- package/dist/cli.mjs +2 -2
- package/dist/cloudflare.d.mts +149 -14
- package/dist/cloudflare.d.mts.map +1 -1
- package/dist/cloudflare.mjs +3 -3
- package/dist/delivery-invariants-Br29H7Rg.mjs +62 -0
- package/dist/delivery-invariants-Br29H7Rg.mjs.map +1 -0
- package/dist/{delivery-invariants-DfPkJL0Q.d.mts → delivery-invariants-DZOBkCMR.d.mts} +2 -2
- package/dist/{delivery-invariants-DfPkJL0Q.d.mts.map → delivery-invariants-DZOBkCMR.d.mts.map} +1 -1
- package/dist/{explore-Rwe1PPqX.d.mts → explore-B7aR_5Hy.d.mts} +2 -2
- package/dist/{explore-Rwe1PPqX.d.mts.map → explore-B7aR_5Hy.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{platform-Bpnav0kn.d.mts → platform-CCz48WF9.d.mts} +30 -30
- package/dist/platform-CCz48WF9.d.mts.map +1 -0
- package/dist/{src-Db2r3ZDr.mjs → src-CWVQEhTr.mjs} +2 -2
- package/dist/{src-Db2r3ZDr.mjs.map → src-CWVQEhTr.mjs.map} +1 -1
- package/dist/{src-BRjmbzMV.mjs → src-DGh7w877.mjs} +365 -246
- package/dist/src-DGh7w877.mjs.map +1 -0
- package/dist/{src-BnTcWa-4.mjs → src-MX90l1IH.mjs} +2747 -1737
- package/dist/src-MX90l1IH.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/cli-CVdHb_gU.mjs +0 -2
- package/dist/delivery-invariants-Cg3eVKSw.mjs +0 -39
- package/dist/delivery-invariants-Cg3eVKSw.mjs.map +0 -1
- package/dist/platform-Bpnav0kn.d.mts.map +0 -1
- package/dist/src-BRjmbzMV.mjs.map +0 -1
- package/dist/src-BnTcWa-4.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src-Db2r3ZDr.mjs","names":["digits"],"sources":["../../core/src/verdict.ts","../../spec/src/ir.ts","../../prover/src/regex-gen.ts","../../prover/src/render.ts","../../prover/src/generate.ts","../../prover/src/checked.ts","../../prover/src/shrink.ts","../../prover/src/tested.ts","../../prover/src/ladder.ts","../../prover/src/provers.ts","../../report/src/regression.ts","../../report/src/render.ts"],"sourcesContent":["/** Simulation verdicts, with what each one rests on. */\n\nimport type { EffectLog } from \"./effect-log.ts\";\nimport type { Schedule } from \"./faults.ts\";\nimport type { Violation } from \"./invariants.ts\";\nimport type { Bounds } from \"./scenario.ts\";\n\nexport interface BoundsReached {\n readonly runs: number;\n readonly effectPoints: number;\n readonly faultsInjected: number;\n readonly elapsedMs: number;\n /**\n * Present when exploration was exhaustive: how many distinct schedules ran\n * (runs that only repeated an order the reduction had covered are not\n * counted), and whether every schedule within the bounds was reached\n * before the budget ran out.\n */\n readonly exhaustive?: {\n readonly complete: boolean;\n readonly schedules: number;\n readonly reduction: boolean;\n };\n}\n\ninterface VerdictBase {\n readonly scenario: string;\n readonly seed: number | string;\n readonly reached: BoundsReached;\n readonly assumptions: readonly string[];\n}\n\nexport interface Shrunk {\n readonly faultsRemoved: number;\n readonly eventsRemoved: number;\n readonly runs: number;\n}\n\nexport interface Violated extends VerdictBase {\n readonly kind: \"VIOLATED\";\n readonly violation: Violation;\n /** The replayed, shrunk trace that breaks the invariant. */\n readonly trace: EffectLog;\n readonly schedule: Schedule;\n /** Ids of the drive's events that remain after shrinking. */\n readonly keptEvents: readonly string[];\n readonly shrunk: Shrunk;\n}\n\nexport interface Bounded extends VerdictBase {\n readonly kind: \"BOUNDED\";\n readonly bounds: Bounds;\n}\n\nexport type UnsupportedCause =\n | \"unsupported_api\"\n | \"not_replayable\"\n | \"module_state_leak\"\n | \"unsupported_bounds\";\n\nexport interface Unsupported extends VerdictBase {\n readonly kind: \"UNSUPPORTED\";\n readonly cause: UnsupportedCause;\n readonly reason: string;\n}\n\nexport type ScenarioVerdict = Violated | Bounded | Unsupported;\n\n/** One line per verdict, for error messages; full rendering lives in `report`. */\nexport function describeVerdict(v: ScenarioVerdict): string {\n switch (v.kind) {\n case \"VIOLATED\":\n return `VIOLATED ${v.scenario}: ${v.violation.message} (seed ${v.schedule.seed}, ${v.reached.runs} run(s))`;\n case \"BOUNDED\":\n return `BOUNDED ${v.scenario}: no violation in ${v.reached.runs} run(s), ${v.reached.effectPoints} effect point(s), ${v.reached.faultsInjected} fault(s)`;\n case \"UNSUPPORTED\":\n return `UNSUPPORTED ${v.scenario}: ${v.cause}: ${v.reason}`;\n }\n}\n","/**\n * SpecIR: function specs as plain data. The surface is TypeScript (a spec\n * file beside the module, `forall(f, { when, ensures })` and `total(f)`\n * from `eutaxy/spec`); the IR is Eutaxy's own, so the simulator's rungs\n * and every engine read one shape. Binder domains are the function's\n * parameter types, read from its declaration; the precondition and the\n * claim are kept as the arrow functions' text, read by each engine into\n * its own tree, and evaluated as code by the simulator's rungs.\n */\n\n/** A TypeScript type as far as the reader can read it; `unknown` carries what it could not. */\nexport type SpecType =\n | { readonly kind: \"number\" }\n | { readonly kind: \"boolean\" }\n | { readonly kind: \"string\" }\n | { readonly kind: \"bigint\" }\n | { readonly kind: \"literal\"; readonly value: string | number | boolean }\n | { readonly kind: \"null\" }\n | { readonly kind: \"undefined\" }\n | {\n readonly kind: \"record\";\n /** The declared name, when the type is an `interface` or a `type` alias rather than inline. */\n readonly name?: string;\n readonly fields: readonly Field[];\n }\n | { readonly kind: \"union\"; readonly members: readonly SpecType[] }\n /** `T[]`, `readonly T[]`, `Array<T>` or `ReadonlyArray<T>`: a JavaScript array, read-only or not. */\n | { readonly kind: \"array\"; readonly element: SpecType }\n | { readonly kind: \"unknown\"; readonly text: string };\n\nexport interface Field {\n readonly name: string;\n readonly type: SpecType;\n}\n\n/** One end of a numeric range: the literal as written (sign included). `[` and `]` include the endpoint. */\nexport interface Endpoint {\n readonly value: string;\n readonly inclusive: boolean;\n}\n\n/**\n * What the precondition says about one binder on its own, read from its\n * conjuncts: `Number.isInteger(n)`, `0 <= n`, `n < 5`, `/^a+$/.test(s)`.\n * Draws are steered by it; the precondition itself still has the last word.\n */\nexport interface Hint {\n readonly integer?: true;\n readonly lower?: Endpoint;\n readonly upper?: Endpoint;\n readonly regex?: { readonly pattern: string; readonly flags: string };\n}\n\n/** A parameter of the function under spec. */\nexport interface Param {\n /** Null for a destructured or rest parameter. */\n readonly name: string | null;\n readonly type: SpecType;\n}\n\n/** A quantified variable: a parameter, under the name the claim gives it. */\nexport interface Binder {\n readonly name: string;\n readonly type: SpecType;\n readonly hint?: Hint;\n}\n\n/** An arrow function from the spec file, as written. */\nexport interface Arrow {\n /** Parameter names in order; null for a destructured one. */\n readonly params: readonly (string | null)[];\n /** The body's source text: an expression, or the statements between the braces when `block`. */\n readonly body: string;\n readonly block: boolean;\n /** 1-based line of the arrow in the spec file. */\n readonly line: number;\n}\n\n/**\n * One exported spec: `forall(f, { when, ensures })`, a universally\n * quantified claim over `f`'s parameters where the precondition holds, or\n * `total(f)`, that `f` terminates on every input.\n */\nexport interface Property {\n /** The export's name in the spec file. */\n readonly name: string;\n readonly kind: \"forall\" | \"total\";\n /** The parameters, named as `ensures` names them (the function's own names past its arity). */\n readonly binders: readonly Binder[];\n /** Where the `TESTED` rung draws inputs; not part of the claim (see `Forall`). */\n readonly sample?: Arrow;\n readonly when?: Arrow;\n readonly ensures?: Arrow;\n /**\n * The module's functions the spec file imports, by the local name the\n * arrows use: a claim's free names resolve here, never in the module.\n */\n readonly imports: readonly { readonly local: string; readonly fn: string }[];\n /** The claim as written, for reports. */\n readonly text: string;\n /** 1-based line of the export in the spec file. */\n readonly line: number;\n}\n\n/** The specs on one exported function. */\nexport interface FunctionSpec {\n readonly name: string;\n readonly params: readonly Param[];\n readonly properties: readonly Property[];\n /** 1-based line of the declaration in the module. */\n readonly line: number;\n /** Offset in the module's source of the `(` opening the parameters: the declaration's identity. */\n readonly offset: number;\n}\n\n/** A problem with a spec, located in the spec file (or the module when `inModule`). */\nexport interface SpecError {\n readonly line: number;\n readonly message: string;\n readonly inModule?: true;\n}\n\n/** Every spec of one module, and what did not read. */\nexport interface ModuleSpecs {\n readonly functions: readonly FunctionSpec[];\n readonly errors: readonly SpecError[];\n}\n\n/** A type, for messages. */\nexport function describeType(t: SpecType): string {\n switch (t.kind) {\n case \"number\":\n case \"boolean\":\n case \"string\":\n case \"bigint\":\n case \"null\":\n case \"undefined\":\n return t.kind;\n case \"literal\":\n return typeof t.value === \"string\" ? JSON.stringify(t.value) : String(t.value);\n case \"record\":\n return (\n t.name ?? `{ ${t.fields.map((f) => `${f.name}: ${describeType(f.type)}`).join(\"; \")} }`\n );\n case \"union\":\n return t.members.map(describeType).join(\" | \");\n case \"array\":\n return t.element.kind === \"union\"\n ? `(${describeType(t.element)})[]`\n : `${describeType(t.element)}[]`;\n case \"unknown\":\n return t.text;\n }\n}\n","/**\n * Strings that match a regular expression, drawn with core's seeded\n * generator: the pattern is parsed into alternatives, sequences, classes\n * and quantified terms, and each draw walks that tree. The subset is what\n * guards use: literals, escapes, classes with ranges and negation, groups,\n * alternation, the usual quantifiers and anchors. Lookaround,\n * backreferences and Unicode property escapes are refused with\n * `UnsupportedRegex`, and the caller falls back to sampling. Every draw is\n * checked against the real `RegExp` by the caller, so a gap here can only\n * cost a draw, never admit a value outside the guard.\n */\n\nimport { nextInt, type PrngState } from \"@eutaxy/core\";\n\nexport class UnsupportedRegex extends Error {}\n\ntype Node =\n | { readonly kind: \"alt\"; readonly options: readonly Node[] }\n | { readonly kind: \"seq\"; readonly items: readonly Node[] }\n | { readonly kind: \"repeat\"; readonly item: Node; readonly min: number; readonly max: number }\n | { readonly kind: \"class\"; readonly pool: readonly string[] }\n | { readonly kind: \"literal\"; readonly text: string }\n | { readonly kind: \"empty\" };\n\nconst digits = [...\"0123456789\"];\nconst word = [...\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_\"];\nconst space = [...\" \\t\\n\\r\\f\\v\"];\n/** What `.` and negated classes draw from: printable ASCII, a few others, no newline. */\nconst anyChar = [\n ...\" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~üß日\",\n];\n\n/** A plentiful count for an unbounded quantifier: keeps drawn strings short. */\nconst unboundedExtra = 4;\n/** The most a counted quantifier may ask for; a guard wanting more is left to sampling. */\nconst maxRepeat = 1000;\n/** The longest string one draw may build before it is given up. */\nconst maxLength = 10_000;\n/** The most nodes one draw may visit: nested repetitions of empty matches multiply work without length. */\nconst maxSteps = 100_000;\n\n/** A class node over the characters it can draw; negation is resolved here, once. */\nfunction classNode(chars: readonly string[], negated: boolean): Node {\n const pool = negated ? anyChar.filter((c) => !chars.includes(c)) : chars;\n if (pool.length === 0) throw new UnsupportedRegex(\"an empty class matches nothing\");\n return { kind: \"class\", pool };\n}\n\nclass Parser {\n private at = 0;\n private readonly src: string;\n private readonly dotAll: boolean;\n private readonly unicode: boolean;\n constructor(src: string, flags: string) {\n this.src = src;\n this.dotAll = flags.includes(\"s\");\n this.unicode = flags.includes(\"u\");\n }\n\n parse(): Node {\n const node = this.alternation();\n if (this.at < this.src.length) throw new UnsupportedRegex(`unexpected ${this.src[this.at]}`);\n return node;\n }\n\n private peek(): string | undefined {\n return this.src[this.at];\n }\n\n private take(): string {\n const c = this.src[this.at++];\n if (c === undefined) throw new UnsupportedRegex(\"pattern ends early\");\n return c;\n }\n\n private alternation(): Node {\n const options = [this.sequence()];\n while (this.peek() === \"|\") {\n this.at++;\n options.push(this.sequence());\n }\n return options.length === 1 ? (options[0] as Node) : { kind: \"alt\", options };\n }\n\n private sequence(): Node {\n const items: Node[] = [];\n while (this.at < this.src.length && this.peek() !== \"|\" && this.peek() !== \")\") {\n const atom = this.atom();\n items.push(this.quantified(atom));\n }\n return items.length === 1 ? (items[0] as Node) : { kind: \"seq\", items };\n }\n\n private quantified(atom: Node): Node {\n const c = this.peek();\n let min: number;\n let max: number;\n if (c === \"*\") [min, max] = [0, unboundedExtra];\n else if (c === \"+\") [min, max] = [1, 1 + unboundedExtra];\n else if (c === \"?\") [min, max] = [0, 1];\n else if (c === \"{\") {\n const m = /^\\{(\\d+)(,(\\d*))?\\}/.exec(this.src.slice(this.at));\n if (!m) return atom; // a literal brace\n min = Number(m[1]);\n max =\n m[2] === undefined\n ? min\n : m[3] === \"\" || m[3] === undefined\n ? min + unboundedExtra\n : Number(m[3]);\n if (max < min) throw new UnsupportedRegex(`quantifier {${min},${max}} is empty`);\n if (max > maxRepeat)\n throw new UnsupportedRegex(`quantifier {${min},${max}} repeats too much to draw`);\n this.at += m[0].length - 1;\n } else return atom;\n this.at++;\n if (this.peek() === \"?\") this.at++; // lazy: same language\n return { kind: \"repeat\", item: atom, min, max };\n }\n\n private atom(): Node {\n const c = this.take();\n switch (c) {\n case \"(\": {\n if (this.src.startsWith(\"?:\", this.at)) this.at += 2;\n else if (\n this.src.startsWith(\"?<\", this.at) &&\n !\"=!\".includes(this.src[this.at + 2] ?? \"\")\n ) {\n const close = this.src.indexOf(\">\", this.at);\n if (close < 0) throw new UnsupportedRegex(\"unterminated group name\");\n this.at = close + 1;\n } else if (this.peek() === \"?\") throw new UnsupportedRegex(\"lookaround or modifier group\");\n const inner = this.alternation();\n if (this.take() !== \")\") throw new UnsupportedRegex(\"unbalanced parenthesis\");\n return inner;\n }\n case \"[\":\n return this.charClass();\n case \".\":\n return classNode(this.dotAll ? [...anyChar, \"\\n\"] : anyChar, false);\n case \"^\":\n case \"$\":\n return { kind: \"empty\" };\n case \"\\\\\":\n return this.escape(false);\n case \")\":\n case \"|\":\n case \"*\":\n case \"+\":\n case \"?\":\n throw new UnsupportedRegex(`unexpected ${c}`);\n default:\n return { kind: \"literal\", text: c };\n }\n }\n\n /** An escape after `\\`; inside a class, `\\b` is a backspace. */\n private escape(inClass: boolean): Node {\n const e = this.take();\n switch (e) {\n case \"d\":\n return classNode(digits, false);\n case \"D\":\n return classNode(digits, true);\n case \"w\":\n return classNode(word, false);\n case \"W\":\n return classNode(word, true);\n case \"s\":\n return classNode(space, false);\n case \"S\":\n return classNode(space, true);\n case \"n\":\n return { kind: \"literal\", text: \"\\n\" };\n case \"t\":\n return { kind: \"literal\", text: \"\\t\" };\n case \"r\":\n return { kind: \"literal\", text: \"\\r\" };\n case \"f\":\n return { kind: \"literal\", text: \"\\f\" };\n case \"v\":\n return { kind: \"literal\", text: \"\\v\" };\n case \"0\":\n return { kind: \"literal\", text: \"\\0\" };\n case \"b\":\n if (inClass) return { kind: \"literal\", text: \"\\b\" };\n return { kind: \"empty\" };\n case \"B\":\n return { kind: \"empty\" };\n case \"x\": {\n const hex = this.src.slice(this.at, this.at + 2);\n if (!/^[0-9a-fA-F]{2}$/.test(hex)) throw new UnsupportedRegex(\"bad \\\\x escape\");\n this.at += 2;\n return { kind: \"literal\", text: String.fromCharCode(Number.parseInt(hex, 16)) };\n }\n case \"u\": {\n if (this.peek() === \"{\") {\n // Without the u flag, \\u{43} is the letter u 43 times.\n if (!this.unicode) throw new UnsupportedRegex(\"\\\\u{} without the u flag\");\n const close = this.src.indexOf(\"}\", this.at);\n const hex = this.src.slice(this.at + 1, close);\n if (close < 0 || !/^[0-9a-fA-F]{1,6}$/.test(hex))\n throw new UnsupportedRegex(\"bad \\\\u escape\");\n this.at = close + 1;\n return { kind: \"literal\", text: String.fromCodePoint(Number.parseInt(hex, 16)) };\n }\n const hex = this.src.slice(this.at, this.at + 4);\n if (!/^[0-9a-fA-F]{4}$/.test(hex)) throw new UnsupportedRegex(\"bad \\\\u escape\");\n this.at += 4;\n return { kind: \"literal\", text: String.fromCharCode(Number.parseInt(hex, 16)) };\n }\n case \"p\":\n case \"P\":\n case \"k\":\n case \"c\":\n throw new UnsupportedRegex(`\\\\${e} escapes`);\n default:\n if (/[1-9]/.test(e)) throw new UnsupportedRegex(\"backreferences\");\n return { kind: \"literal\", text: e };\n }\n }\n\n /** `[...]` after its opening bracket. `[]` is empty and `[]a]` is an empty class then `a]`, as in JavaScript. */\n private charClass(): Node {\n let negated = false;\n if (this.peek() === \"^\") {\n negated = true;\n this.at++;\n }\n const chars = new Set<string>();\n while (this.peek() !== \"]\") {\n const c = this.take();\n let member: string;\n if (c === \"\\\\\") {\n const node = this.escape(true);\n if (node.kind === \"class\") {\n // \\d inside a class adds its members; \\D its complement, already resolved over anyChar.\n for (const x of node.pool) chars.add(x);\n continue;\n }\n if (node.kind !== \"literal\") throw new UnsupportedRegex(\"escape in class\");\n member = node.text;\n } else member = c;\n if (\n this.peek() === \"-\" &&\n this.src[this.at + 1] !== \"]\" &&\n this.src[this.at + 1] !== undefined\n ) {\n this.at++;\n const to =\n this.take() === \"\\\\\"\n ? this.escape(true)\n : { kind: \"literal\" as const, text: this.src[this.at - 1] as string };\n if (to.kind !== \"literal\") throw new UnsupportedRegex(\"range to a class\");\n const lo = member.codePointAt(0) as number;\n const hi = to.text.codePointAt(0) as number;\n if (hi < lo) throw new UnsupportedRegex(\"range out of order\");\n if (hi - lo > 0x2000) throw new UnsupportedRegex(\"range too wide to enumerate\");\n for (let p = lo; p <= hi; p++) chars.add(String.fromCodePoint(p));\n continue;\n }\n chars.add(member);\n }\n this.at++;\n return classNode([...chars], negated);\n }\n}\n\n/** The pattern as a tree, or `UnsupportedRegex`. */\nexport function parseRegex(pattern: string, flags: string): Node {\n if (flags.includes(\"v\")) throw new UnsupportedRegex(\"the v flag\");\n return new Parser(pattern, flags).parse();\n}\n\n/** One string from the tree, with the state that follows. */\nexport function drawRegex(node: Node, state: PrngState): readonly [string, PrngState] {\n let s = state;\n let steps = 0;\n const go = (n: Node): string => {\n if (++steps > maxSteps) throw new UnsupportedRegex(\"a draw visited more than 100000 nodes\");\n switch (n.kind) {\n case \"empty\":\n return \"\";\n case \"literal\":\n return n.text;\n case \"alt\": {\n const [i, next] = nextInt(s, n.options.length);\n s = next;\n return go(n.options[i] as Node);\n }\n case \"seq\":\n return n.items.map(go).join(\"\");\n case \"repeat\": {\n const [extra, next] = nextInt(s, n.max - n.min + 1);\n s = next;\n let out = \"\";\n for (let i = 0; i < n.min + extra; i++) {\n out += go(n.item);\n if (out.length > maxLength)\n throw new UnsupportedRegex(\"a draw grew past 10000 characters\");\n }\n return out;\n }\n case \"class\": {\n const [i, next] = nextInt(s, n.pool.length);\n s = next;\n return n.pool[i] as string;\n }\n }\n };\n return [go(node), s];\n}\n","/**\n * A value as a JavaScript literal: exact for the primitive types (bigints\n * included, `-0` and `NaN` kept), records and arrays spelled as literals,\n * so a counterexample reads back as what it was. Never truncated and never\n * throwing: the rungs key distinct inputs by it, so two values must render\n * alike only when they are alike.\n */\nexport function render(value: unknown): string {\n return renderAt(value, new Set());\n}\n\nfunction renderAt(value: unknown, seen: Set<object>): string {\n switch (typeof value) {\n case \"bigint\":\n return `${value}n`;\n case \"number\":\n return Object.is(value, -0) ? \"-0\" : String(value);\n case \"string\":\n return JSON.stringify(value);\n case \"undefined\":\n return \"undefined\";\n case \"boolean\":\n return String(value);\n case \"function\":\n return \"[function]\";\n case \"symbol\":\n return String(value);\n }\n if (value === null) return \"null\";\n const o = value as object;\n if (seen.has(o)) return \"<cycle>\";\n seen.add(o);\n try {\n if (Array.isArray(o)) return `[${o.map((x) => renderAt(x, seen)).join(\", \")}]`;\n if (o instanceof Date)\n return Number.isNaN(o.getTime()) ? \"Date(NaN)\" : `Date(${JSON.stringify(o.toISOString())})`;\n if (o instanceof Map)\n return `Map([${[...o].map(([k, v]) => `[${renderAt(k, seen)}, ${renderAt(v, seen)}]`).join(\", \")}])`;\n if (o instanceof Set) return `Set([${[...o].map((x) => renderAt(x, seen)).join(\", \")}])`;\n const entries = Object.entries(o).map(\n ([k, v]) =>\n `${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(k) ? k : JSON.stringify(k)}: ${renderAt(v, seen)}`,\n );\n return entries.length === 0 ? \"{}\" : `{ ${entries.join(\", \")} }`;\n } catch {\n // A throwing getter or an exotic object: something, never a throw out of a verdict.\n try {\n return `<${String(o)}>`;\n } catch {\n return \"<unrenderable>\";\n }\n } finally {\n seen.delete(o);\n }\n}\n\n/** Whether two values render alike: structural equality that tells `1n` from `1` and `-0` from `0`. */\nexport function same(a: unknown, b: unknown): boolean {\n return typeof a === typeof b && render(a) === render(b);\n}\n\n/**\n * A deep copy of plain data: arrays and records (plain objects); anything\n * else (a Date the simulator passed, a class instance) is kept as it is.\n * Each evaluation of a property gets its own, so code under test that\n * mutates an input (`xs.sort()`) changes neither the printed counterexample\n * nor the candidates built from it, and no two places in an input share an\n * object, as their printed literals do not.\n */\nexport function copy<T>(v: T): T {\n if (Array.isArray(v)) return v.map(copy) as T;\n if (v !== null && typeof v === \"object\") {\n const proto = Object.getPrototypeOf(v);\n if (proto !== Object.prototype && proto !== null) return v;\n return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, copy(x)])) as T;\n }\n return v;\n}\n","/**\n * Inputs for the `TESTED` rung: values drawn from a binder's type, steered\n * by what the precondition says about it, with core's seeded generator;\n * and the smaller values a shrinker tries in place of one that broke a\n * property. Everything here is pure: the same state draws the same value,\n * so a `TESTED` verdict and its counterexample come out the same on every\n * machine.\n */\n\nimport { nextFloat, nextInt, nextU32, type PrngState } from \"@eutaxy/core\";\nimport { type Binder, describeType, type Endpoint, type Hint, type SpecType } from \"@eutaxy/spec\";\nimport { drawRegex, parseRegex, UnsupportedRegex } from \"./regex-gen.ts\";\nimport { copy, render, same } from \"./render.ts\";\n\n/** A value and the state that follows drawing it. */\nexport type Draw<T> = readonly [T, PrngState];\n\n/** Thrown when no value could be drawn: `unsupported` for a type the rung cannot draw, `gave_up` for a range nothing lies in. */\nexport class CannotGenerate extends Error {\n readonly why: \"unsupported\" | \"gave_up\";\n constructor(why: \"unsupported\" | \"gave_up\", message: string) {\n super(message);\n this.why = why;\n }\n}\n\n/** Integers are drawn as doubles, so they stay exact. */\nconst safe = 2n ** 53n - 1n;\n\n/** How far an unguarded side of a bigint range reaches. */\nconst bigintReach = 1n << 128n;\n\n/** A finite endpoint's value as a double. */\nexport function endpointNumber(value: string): number {\n return Number(value.replace(/_/g, \"\").replace(/n$/, \"\"));\n}\n\n/**\n * The integers a bound admits, as the bound itself: `n < 5` admits up to 4,\n * `n <= 5` up to 5, `n < 4.5` up to 4; `0 < n` from 1, `-0.5 <= n` from 0.\n */\nexport function integerBound(e: Endpoint, side: \"lower\" | \"upper\"): bigint | undefined {\n const text = e.value.replace(/_/g, \"\").replace(/n$/, \"\");\n if (/[.eE]/.test(text)) {\n const n = Number(text);\n // A literal past every double (`1e400`) bounds nothing an integer can reach.\n if (!Number.isFinite(n)) return undefined;\n if (!Number.isInteger(n)) return BigInt(side === \"lower\" ? Math.ceil(n) : Math.floor(n));\n return BigInt(n) + (e.inclusive ? 0n : side === \"lower\" ? 1n : -1n);\n }\n return BigInt(text) + (e.inclusive ? 0n : side === \"lower\" ? 1n : -1n);\n}\n\n/** A finite integral endpoint's value, exact: underscores and the `n` suffix dropped. */\nexport function endpointBigInt(value: string): bigint {\n return BigInt(value.replace(/_/g, \"\").replace(/n$/, \"\"));\n}\n\n/**\n * The closed integer interval a hint admits: within what a double holds\n * exactly for `number`; for `bigint`, the hint's ends, an unhinted side\n * reaching 2^128 past the other. Undefined when no integer lies in it.\n */\nfunction integerRange(\n kind: \"number\" | \"bigint\",\n hint: Hint | undefined,\n): { readonly lo: bigint; readonly hi: bigint } | undefined {\n const guardLo = hint?.lower === undefined ? undefined : integerBound(hint.lower, \"lower\");\n const guardHi = hint?.upper === undefined ? undefined : integerBound(hint.upper, \"upper\");\n let lo: bigint;\n let hi: bigint;\n if (kind === \"bigint\") {\n lo =\n guardLo ?? (guardHi === undefined ? -bigintReach : min(-bigintReach, guardHi - bigintReach));\n hi = guardHi ?? (guardLo === undefined ? bigintReach : max(bigintReach, guardLo + bigintReach));\n } else {\n lo = max(-safe, guardLo ?? -safe);\n hi = min(safe, guardHi ?? safe);\n }\n return lo <= hi ? { lo, hi } : undefined;\n}\n\nconst max = (a: bigint, b: bigint) => (a > b ? a : b);\nconst min = (a: bigint, b: bigint) => (a < b ? a : b);\n\n/** Uniform in [lo, hi], however wide: enough 32-bit words, masked, rejected when past the span. */\nexport function uniformBigInt(lo: bigint, hi: bigint, state: PrngState): Draw<bigint> {\n const span = hi - lo + 1n;\n if (span <= 0n) throw new RangeError(`empty integer interval [${lo}, ${hi}]`);\n if (span === 1n) return [lo, state];\n let bits = 0;\n for (let x = span - 1n; x > 0n; x >>= 1n) bits++;\n const words = Math.ceil(bits / 32);\n const mask = (1n << BigInt(bits)) - 1n;\n let s = state;\n for (;;) {\n let r = 0n;\n for (let i = 0; i < words; i++) {\n const [u, next] = nextU32(s);\n s = next;\n r = (r << 32n) | BigInt(u);\n }\n r &= mask;\n if (r < span) return [lo + r, s];\n }\n}\n\n/** One of a list, uniformly. */\nfunction pick<T>(items: readonly T[], state: PrngState): Draw<T> {\n const [i, s] = nextInt(state, items.length);\n return [items[i] as T, s];\n}\n\n/**\n * An integer from the range, biased: most draws are small, since\n * properties fail at boundaries and small cases far more often than deep in\n * the range, some are medium or large, and a few are the range's edges.\n */\n/** An integer range's edges, as the random draws pick from them (repeats kept, so draws stay as they were). */\nfunction integerEdgeCandidates(lo: bigint, hi: bigint): bigint[] {\n return [lo, hi, 0n, 1n, -1n, lo + 1n, hi - 1n].filter((v) => v >= lo && v <= hi);\n}\n\nfunction drawInteger(\n name: string,\n kind: \"number\" | \"bigint\",\n hint: Hint | undefined,\n state: PrngState,\n): Draw<bigint> {\n const range = integerRange(kind, hint);\n if (!range)\n throw new CannotGenerate(\n \"gave_up\",\n kind === \"bigint\"\n ? `no integer lies inside the precondition's bounds on ${name}`\n : `no integer lies inside the precondition's bounds on ${name} within ±2^53, which is as far as draws of number go`,\n );\n const { lo, hi } = range;\n const [cls, s] = nextInt(state, 100);\n const within = (a: bigint, z: bigint): [bigint, bigint] | undefined => {\n const l = max(lo, a);\n const h = min(hi, z);\n return l <= h ? [l, h] : undefined;\n };\n if (cls < 5) return pick(integerEdgeCandidates(lo, hi), s);\n const bound =\n cls < 55\n ? within(-16n, 16n)\n : cls < 80\n ? within(-(1n << 16n), 1n << 16n)\n : cls < 95\n ? within(-(1n << 31n), 1n << 31n)\n : undefined;\n const [l, h] = bound ?? [lo, hi];\n return uniformBigInt(l, h, s);\n}\n\n/** The double interval a hint admits. */\nfunction numberRange(hint: Hint | undefined): {\n readonly lo: number;\n readonly hi: number;\n readonly guarded: boolean;\n} {\n const lo =\n hint?.lower === undefined ? Number.NEGATIVE_INFINITY : endpointNumber(hint.lower.value);\n const hi =\n hint?.upper === undefined ? Number.POSITIVE_INFINITY : endpointNumber(hint.upper.value);\n return { lo, hi, guarded: hint?.lower !== undefined || hint?.upper !== undefined };\n}\n\n/** Whether a double satisfies the hint's bounds (NaN satisfies none). */\nfunction withinNumberHint(hint: Hint | undefined, v: number): boolean {\n if (!hint) return true;\n if (hint.integer && !Number.isInteger(v)) return false;\n if (hint.lower) {\n const lo = endpointNumber(hint.lower.value);\n if (!(hint.lower.inclusive ? v >= lo : v > lo)) return false;\n }\n if (hint.upper) {\n const hi = endpointNumber(hint.upper.value);\n if (!(hint.upper.inclusive ? v <= hi : v < hi)) return false;\n }\n return true;\n}\n\n/** A double hint's edges, as the random draws pick from them. */\nfunction doubleEdgeCandidates(hint: Hint | undefined): number[] {\n const { lo, hi, guarded } = numberRange(hint);\n return [\n 0,\n -0,\n 1,\n -1,\n 0.5,\n Number.MIN_VALUE,\n Number.EPSILON,\n Number.MAX_VALUE,\n -Number.MAX_VALUE,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ...(guarded ? [lo, hi] : [Number.NaN]),\n ].filter((v) => withinNumberHint(hint, v));\n}\n\nfunction drawNumber(hint: Hint | undefined, state: PrngState): Draw<number> {\n const { lo, hi } = numberRange(hint);\n const [cls, s0] = nextInt(state, 100);\n if (cls < 8) {\n const edges = doubleEdgeCandidates(hint);\n if (edges.length > 0) return pick(edges, s0);\n }\n if (cls < 35) {\n const [k, s1] = nextInt(s0, 33);\n return [k - 16, s1];\n }\n if (cls < 60) {\n const [d, s1] = pick([2, 4, 8, 10, 100], s0);\n const [k, s2] = nextInt(s1, 65);\n return [(k - 32) / d, s2];\n }\n if (cls < 80 && Number.isFinite(lo) && Number.isFinite(hi)) {\n const [f, s1] = nextFloat(s0);\n return [lo + f * (hi - lo), s1];\n }\n // Any magnitude a double holds: a random mantissa at a random binary exponent, either sign.\n const [f, s1] = nextFloat(s0);\n const [e, s2] = nextInt(s1, 2100);\n const [neg, s3] = nextInt(s2, 2);\n return [(neg ? -1 : 1) * (1 + f) * 2 ** (e - 1074), s3];\n}\n\nconst letters = \"abcdefghijklmnopqrstuvwxyz\";\nconst digits = \"0123456789\";\nconst plainAlphabet = [...`${letters}${letters.toUpperCase()}${digits} _-.,:/\\n'\"üß日😀`];\nconst stringEdges = [\"\", \" \", \"a\", \"0\", \"-1\", \"\\n\", \"\\u0000\", \"ü\", \"😀\", \"a\".repeat(100)];\n/** The longest string sampled over a regex's own characters, and the longest edge a regex is tried on. */\nconst regexSampleLength = 12;\n\n/**\n * The characters a regex names: literals, the ranges and escapes of its\n * classes. Strings drawn from them match the pattern far more often than\n * strings drawn from everything, which is what the rejection below needs.\n */\nexport function regexAlphabet(pattern: string): string[] {\n const chars = new Set<string>();\n const add = (s: string) => {\n for (const c of s) chars.add(c);\n };\n for (let i = 0; i < pattern.length; i++) {\n const c = pattern[i] as string;\n if (c === \"\\\\\") {\n const e = pattern[++i];\n if (e === \"d\") add(digits);\n else if (e === \"w\") add(`${letters}${letters.toUpperCase()}${digits}_`);\n else if (e === \"s\") add(\" \");\n else if (e === \"n\") add(\"\\n\");\n else if (e === \"t\") add(\"\\t\");\n else if (e !== undefined && !/[DWSbBuxpP]/.test(e)) add(e);\n continue;\n }\n if (pattern[i + 1] === \"-\" && i + 2 < pattern.length && pattern[i + 2] !== \"]\") {\n const from = c.codePointAt(0) as number;\n const to = (pattern[i + 2] as string).codePointAt(0) as number;\n if (from < to && to - from <= 0x1000)\n for (let p = from; p <= to; p++) chars.add(String.fromCodePoint(p));\n i += 2;\n continue;\n }\n if (!\"^$()[]{}|*+?.-\".includes(c)) chars.add(c);\n }\n return [...chars];\n}\n\n/** A string of `length` characters from `alphabet`. */\nfunction drawChars(alphabet: readonly string[], length: number, state: PrngState): Draw<string> {\n let s = state;\n let out = \"\";\n for (let i = 0; i < length; i++) {\n const [c, next] = pick(alphabet, s);\n s = next;\n out += c;\n }\n return [out, s];\n}\n\n/** Whether a string passes the hint's regex (the real RegExp has the last word). */\nfunction matchesRegex(hint: Hint | undefined, v: string): boolean {\n return hint?.regex === undefined || new RegExp(hint.regex.pattern, hint.regex.flags).test(v);\n}\n\nfunction drawString(hint: Hint | undefined, state: PrngState): Draw<string> {\n const g = hint?.regex;\n if (!g) {\n const [cls, s0] = nextInt(state, 100);\n if (cls < 15) return pick(stringEdges, s0);\n const [length, s1] = nextInt(s0, 25);\n return drawChars(plainAlphabet, length, s1);\n }\n let s = state;\n // Walk the pattern when it is in the understood subset; the real RegExp has the last word.\n let tree: ReturnType<typeof parseRegex> | undefined;\n try {\n tree = parseRegex(g.pattern, g.flags);\n } catch (err) {\n if (!(err instanceof UnsupportedRegex)) throw err;\n }\n for (let attempt = 0; tree && attempt < 16; attempt++) {\n try {\n const [candidate, s1] = drawRegex(tree, s);\n s = s1;\n if (matchesRegex(hint, candidate)) return [candidate, s];\n } catch (err) {\n if (!(err instanceof UnsupportedRegex)) throw err;\n break;\n }\n }\n // Otherwise sample strings over the pattern's own characters and keep what matches.\n const fromPattern = regexAlphabet(g.pattern);\n const alphabet = fromPattern.length > 0 ? fromPattern : plainAlphabet;\n for (let attempt = 0; attempt < 64; attempt++) {\n const [length, s1] = nextInt(s, regexSampleLength + 1);\n const [candidate, s2] = drawChars(alphabet, length, s1);\n s = s2;\n if (matchesRegex(hint, candidate)) return [candidate, s];\n }\n throw new CannotGenerate(\n \"gave_up\",\n `no string matching /${g.pattern}/${g.flags} was found in 64 draws over its characters`,\n );\n}\n\n/** The most shrink candidates one array offers at a step; the shrinker evaluates 500 in all. */\nconst shrinkCandidateLimit = 256;\n\n/** The most edges a record type has; random draws cover its other combinations. */\nconst recordEdgeLimit = 64;\n\n/** Without repeats, in one pass, as `same` compares: 0 and -0 stay apart, two empty arrays do not. */\nfunction distinct<T>(values: readonly T[]): T[] {\n const seen = new Set<string>();\n return values.filter((v) => {\n const key = `${typeof v}:${render(v)}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\nfunction integerEdges(kind: \"number\" | \"bigint\", hint: Hint | undefined): bigint[] {\n const range = integerRange(kind, hint);\n return range ? distinct(integerEdgeCandidates(range.lo, range.hi)) : [];\n}\n\n/**\n * How many combinations of these edge lists to take side by side: the\n * longest list's length, twice over when there are two or more lists,\n * since `combined` walks them once in step (equal edges meet, as\n * `Infinity - Infinity` needs) and once rotated (list `k` starting `k`\n * places in, so lists of one type also differ).\n */\nfunction combinations(lists: readonly (readonly unknown[])[]): number {\n const longest = Math.max(0, ...lists.map((l) => l.length));\n return lists.length > 1 ? 2 * longest : longest;\n}\n\n/** List `k`'s value in the `i`-th combination. */\nfunction combined<T>(lists: readonly (readonly T[])[], k: number, i: number): T {\n const longest = Math.max(...lists.map((l) => l.length));\n const own = lists[k] as readonly T[];\n const offset = i < longest ? 0 : k;\n return own[((i % longest) + offset) % own.length] as T;\n}\n\n/**\n * The values of a type, within the hint, that properties fail on far more\n * often than elsewhere: the bounds, zero and one, the double specials (NaN,\n * the infinities, -0), the empty string, both booleans, every member of a\n * union, and records built field by field from those. The `TESTED` rung\n * tries every one before any random draw, so a claim false on one value\n * is found under every seed; a claim false only on a combination of edges\n * across binders or fields is found where the rotation below pairs them,\n * and otherwise rests on the random draws. A type with none (a string\n * whose regex no edge matches) gives none.\n */\nexport function edgesOf(type: SpecType, hint: Hint | undefined): unknown[] {\n switch (type.kind) {\n case \"boolean\":\n return [false, true];\n case \"number\": {\n // Number.isInteger(-0) holds, so -0 is an integer edge wherever 0 is one.\n if (hint?.integer)\n return integerEdges(\"number\", hint).flatMap((v) => (v === 0n ? [0, -0] : [Number(v)]));\n return distinct(doubleEdgeCandidates(hint));\n }\n case \"bigint\":\n return integerEdges(\"bigint\", hint);\n case \"string\":\n // A regex is tried only on edges as short as the strings sampled over its characters: a\n // backtracking pattern on the 100-character edge could run for longer than the check.\n return stringEdges.filter(\n (v) =>\n hint?.regex === undefined || (v.length <= regexSampleLength && matchesRegex(hint, v)),\n );\n case \"literal\":\n return [type.value];\n case \"null\":\n return [null];\n case \"undefined\":\n return [undefined];\n case \"union\":\n return distinct(type.members.flatMap((m) => edgesOf(m, undefined)));\n case \"record\": {\n // Distinct records only, and at most recordEdgeLimit of them: nested records multiply their\n // fields' edges, and a record's edges must not grow with its depth.\n const lists = type.fields.map((f) => edgesOf(f.type, undefined));\n if (lists.some((l) => l.length === 0)) return [];\n const out: Record<string, unknown>[] = [];\n const seen = new Set<string>();\n for (let i = 0; i < Math.max(1, combinations(lists)) && out.length < recordEdgeLimit; i++) {\n const r = Object.fromEntries(type.fields.map((f, k) => [f.name, combined(lists, k, i)]));\n const key = render(r);\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(r);\n }\n return out;\n }\n case \"array\": {\n // Empty, one of each element edge, and one element twice: claims about arrays break on the\n // empty one and on repeats far more often than elsewhere.\n if (!drawable(type.element)) return [];\n const element = edgesOf(type.element, undefined);\n return [\n [],\n ...element.map((e) => [e]),\n ...(element.length > 0 ? [[element[0], element[0]]] : []),\n ];\n }\n case \"unknown\":\n return [];\n }\n}\n\n/** Each binder's edges, computed once for a property's whole edge phase. */\nexport function edgeLists(binders: readonly Binder[]): unknown[][] {\n return binders.map((b) => edgesOf(b.type, b.hint));\n}\n\n/** How many edge assignments the binders' `edgeLists` give. */\nexport function edgeAssignmentCount(edges: readonly (readonly unknown[])[]): number {\n return combinations(edges);\n}\n\n/**\n * The `i`-th edge assignment from the binders' `edgeLists`: the lists\n * walked once in step and once rotated (binder `j` starting `j` places\n * in), cycling, so each edge of each binder appears, equal edges meet and\n * binders of one type also differ; a binder with no edges is drawn at\n * random. Undefined from `edgeAssignmentCount` on.\n */\nexport function edgeAssignment(\n binders: readonly Binder[],\n edges: readonly (readonly unknown[])[],\n i: number,\n state: PrngState,\n): Draw<unknown[]> | undefined {\n if (i >= combinations(edges)) return undefined;\n const values: unknown[] = [];\n let s = state;\n binders.forEach((b, j) => {\n const own = edges[j] as readonly unknown[];\n if (own.length > 0) {\n values.push(copy(combined(edges, j, i)));\n return;\n }\n const [v, next] = generate(b, s);\n s = next;\n values.push(v);\n });\n return [values, s];\n}\n\n/** Whether every part of the type is one the rung draws (no `unknown` anywhere in it). */\nfunction drawable(type: SpecType): boolean {\n switch (type.kind) {\n case \"unknown\":\n return false;\n case \"array\":\n return drawable(type.element);\n case \"union\":\n return type.members.every(drawable);\n case \"record\":\n return type.fields.every((f) => drawable(f.type));\n default:\n return true;\n }\n}\n\n/** A value of the type, within the hint (which applies to a top-level binder only). */\nexport function generateOf(\n name: string,\n type: SpecType,\n hint: Hint | undefined,\n state: PrngState,\n): Draw<unknown> {\n switch (type.kind) {\n case \"boolean\": {\n const [bit, s] = nextInt(state, 2);\n return [bit === 1, s];\n }\n case \"number\": {\n if (hint?.integer) {\n const [v, s] = drawInteger(name, \"number\", hint, state);\n return [Number(v), s];\n }\n let s = state;\n for (let attempt = 0; attempt < 64; attempt++) {\n const [v, next] = drawNumber(hint, s);\n s = next;\n if (withinNumberHint(hint, v)) return [v, s];\n }\n throw new CannotGenerate(\n \"gave_up\",\n `no number inside the precondition's bounds on ${name} was found in 64 draws`,\n );\n }\n case \"bigint\":\n return drawInteger(name, \"bigint\", hint, state);\n case \"string\":\n return drawString(hint, state);\n case \"literal\":\n return [type.value, state];\n case \"null\":\n return [null, state];\n case \"undefined\":\n return [undefined, state];\n case \"union\": {\n const [member, s] = pick(type.members, state);\n return generateOf(name, member, undefined, s);\n }\n case \"record\": {\n let s = state;\n const out: Record<string, unknown> = {};\n for (const f of type.fields) {\n const [v, next] = generateOf(`${name}.${f.name}`, f.type, undefined, s);\n s = next;\n out[f.name] = v;\n }\n return [out, s];\n }\n case \"array\": {\n // Refused whatever length is drawn, as an unreadable parameter type is: an empty draw must\n // not make an array of something unreadable look testable.\n if (!drawable(type.element))\n throw new CannotGenerate(\n \"unsupported\",\n `${name} has a type the rung cannot draw from: ${describeType(type)}`,\n );\n // Mostly short (up to 4), sometimes up to 16; an element repeats an earlier one a quarter of\n // the time, since a claim keyed on distinct elements breaks on a repeat.\n const [cls, s0] = nextInt(state, 100);\n const [length, s1] = nextInt(s0, cls < 70 ? 5 : 17);\n let s = s1;\n const out: unknown[] = [];\n for (let i = 0; i < length; i++) {\n if (out.length > 0) {\n const [repeat, s2] = nextInt(s, 4);\n s = s2;\n if (repeat === 0) {\n const [v, s3] = pick(out, s);\n s = s3;\n out.push(copy(v));\n continue;\n }\n }\n const [v, next] = generateOf(`${name}[${i}]`, type.element, undefined, s);\n s = next;\n out.push(v);\n }\n return [out, s];\n }\n case \"unknown\":\n throw new CannotGenerate(\n \"unsupported\",\n `${name} has a type the rung cannot draw from: ${describeType(type)}`,\n );\n }\n}\n\n/** A value of the binder's type, within its hint. */\nexport function generate(b: Binder, state: PrngState): Draw<unknown> {\n return generateOf(b.name, b.type, b.hint, state);\n}\n\n/** Whether a binder draws integers (or bigints), which later binders may relate to. */\nfunction integral(b: Binder): boolean {\n return b.type.kind === \"bigint\" || (b.type.kind === \"number\" && b.hint?.integer === true);\n}\n\n/**\n * One assignment to every binder. Each is drawn from its own type and\n * hint; a later integer binder is sometimes made to relate to earlier\n * ones instead, equal to one or the sum or difference of two, since\n * preconditions relate binders (`refunded + amount === captured`) and\n * independent draws would meet such an equation once in thousands. A\n * related value outside the binder's hint is dropped for the draw.\n */\nexport function generateAssignment(binders: readonly Binder[], state: PrngState): Draw<unknown[]> {\n const values: unknown[] = [];\n let s = state;\n for (const b of binders) {\n const [drawn, next] = generate(b, s);\n s = next;\n let v = drawn;\n const earlier = values.filter(\n (x, i) => integral(binders[i] as Binder) && typeof x === typeof drawn,\n );\n if (integral(b) && earlier.length > 0) {\n const [cls, s1] = nextInt(s, 10);\n s = s1;\n if (cls < 3) {\n const [a, s2] = pick(earlier, s1);\n const [c, s3] = pick(earlier, s2);\n s = s3;\n let related: unknown = a;\n if (cls === 1)\n related =\n typeof a === \"bigint\" ? (a as bigint) + (c as bigint) : (a as number) + (c as number);\n if (cls === 2)\n related =\n typeof a === \"bigint\" ? (a as bigint) - (c as bigint) : (a as number) - (c as number);\n if (inDomain(b, related) && (typeof related !== \"number\" || Number.isSafeInteger(related)))\n v = related;\n }\n }\n values.push(v);\n }\n return [values, s];\n}\n\n/** Whether a value is of the type (hints aside). */\nexport function conforms(type: SpecType, v: unknown): boolean {\n switch (type.kind) {\n case \"number\":\n return typeof v === \"number\";\n case \"boolean\":\n return typeof v === \"boolean\";\n case \"string\":\n return typeof v === \"string\";\n case \"bigint\":\n return typeof v === \"bigint\";\n case \"literal\":\n // `===`: -0 is of the literal type 0, as TypeScript has it.\n return v === type.value;\n case \"null\":\n return v === null;\n case \"undefined\":\n return v === undefined;\n case \"union\":\n return type.members.some((m) => conforms(m, v));\n case \"record\":\n return (\n typeof v === \"object\" &&\n v !== null &&\n type.fields.every((f) => conforms(f.type, (v as Record<string, unknown>)[f.name]))\n );\n case \"array\":\n // A sparse array is outside: JavaScript's array methods skip its holes, a list has none.\n if (!Array.isArray(v)) return false;\n for (let i = 0; i < v.length; i++)\n if (!(i in v) || !conforms(type.element, v[i])) return false;\n return true;\n case \"unknown\":\n return true;\n }\n}\n\n/** Whether a top-level value is of the binder's type and within its hint. */\nexport function inDomain(b: Binder, v: unknown): boolean {\n if (!conforms(b.type, v)) return false;\n const h = b.hint;\n if (!h) return true;\n if (typeof v === \"number\") return withinNumberHint(h, v);\n if (typeof v === \"bigint\") {\n const lo = h.lower && integerBound(h.lower, \"lower\");\n const hi = h.upper && integerBound(h.upper, \"upper\");\n if (lo !== undefined && v < lo) return false;\n if (hi !== undefined && v > hi) return false;\n return true;\n }\n if (typeof v === \"string\") return matchesRegex(h, v);\n return true;\n}\n\n/** The integer nearest to zero in [lo, hi]. */\nfunction nearestZero(lo: bigint, hi: bigint): bigint {\n return lo > 0n ? lo : hi < 0n ? hi : 0n;\n}\n\n/** Steps from `v` toward `target`: the target itself, then the halfway points back toward `v`. */\nfunction towards(v: bigint, target: bigint): bigint[] {\n const out: bigint[] = [];\n if (v === target) return out;\n out.push(target);\n let d = (v - target) / 2n;\n while (d !== 0n) {\n out.push(v - d);\n d /= 2n;\n }\n return out;\n}\n\n/**\n * Smaller values to try in place of `v`, simplest first, all of the type\n * and within the hint, none equal to `v`. Numbers move toward zero (or the\n * bound nearest it), strings get shorter and plainer, `true` becomes\n * `false`, a union moves to its simplest member, a record shrinks one\n * field at a time.\n */\nexport function shrinkCandidates(b: Binder, v: unknown): unknown[] {\n return candidatesOf(b.type, b.hint, v).filter((c) => !Object.is(c, v) && inDomain(b, c));\n}\n\nfunction candidatesOf(type: SpecType, hint: Hint | undefined, v: unknown): unknown[] {\n // Keyed as `same` compares, in one pass: nested arrays give thousands of candidates.\n const dedupe = (xs: unknown[]) => {\n const keys = new Set<string>();\n return xs.filter((x) => {\n const key = `${typeof x}:${render(x)}`;\n if (keys.has(key)) return false;\n keys.add(key);\n return true;\n });\n };\n switch (type.kind) {\n case \"boolean\":\n return [false];\n case \"number\": {\n if (typeof v !== \"number\") return [];\n // -0 is as small as 0 to every comparison, so only the sign is left to shrink.\n if (Object.is(v, -0)) return [0];\n if (hint?.integer || Number.isInteger(v)) {\n const range = integerRange(\"number\", hint);\n if (!Number.isInteger(v) || !range) return [];\n return dedupe(towards(BigInt(v), nearestZero(range.lo, range.hi)).map(Number));\n }\n const { lo, hi } = numberRange(hint);\n const target = lo > 0 ? lo : Math.min(hi, 0);\n if (!Number.isFinite(v)) return [target, 1, -1, Number.MAX_VALUE, -Number.MAX_VALUE];\n const out = [target, Math.trunc(v)];\n let d = (v - target) / 2;\n for (let i = 0; i < 24 && d !== 0; i++) {\n out.push(v - d);\n d /= 2;\n }\n return dedupe(out);\n }\n case \"bigint\": {\n const range = integerRange(\"bigint\", hint);\n if (typeof v !== \"bigint\" || !range) return [];\n return towards(v, nearestZero(range.lo, range.hi));\n }\n case \"string\": {\n if (typeof v !== \"string\") return [];\n const chars = [...v];\n const out: string[] = [\"\", chars.slice(0, Math.floor(chars.length / 2)).join(\"\")];\n out.push(chars.slice(Math.ceil(chars.length / 2)).join(\"\"));\n for (const at of [0, chars.length - 1, Math.floor(chars.length / 2)])\n out.push([...chars.slice(0, at), ...chars.slice(at + 1)].join(\"\"));\n const first = chars.findIndex((c) => c !== \"a\");\n if (first >= 0) out.push([...chars.slice(0, first), \"a\", ...chars.slice(first + 1)].join(\"\"));\n return dedupe(out);\n }\n case \"array\": {\n // Shorter first (empty, then one element dropped), then elements smaller: one at a time, and\n // every copy of a value at once, so a repeat that breaks the claim survives the shrink.\n // At most shrinkCandidateLimit, in that order: nested arrays have more candidates than the\n // shrinker will ever evaluate, and building them all costs seconds.\n if (!Array.isArray(v)) return [];\n const out: unknown[] = v.length > 0 ? [[]] : [];\n for (let i = 0; i < v.length; i++) out.push(v.filter((_, j) => j !== i));\n const keys = v.map((x) => `${typeof x}:${render(x)}`);\n for (let i = 0; i < v.length && out.length < shrinkCandidateLimit; i++) {\n const own = keys[i];\n const repeated = keys.some((k, j) => j !== i && k === own);\n for (const c of candidatesOf(type.element, undefined, v[i])) {\n if (out.length >= shrinkCandidateLimit) break;\n if (`${typeof c}:${render(c)}` === own) continue;\n out.push(v.map((x, j) => (j === i ? c : x)));\n if (repeated) out.push(v.map((x, j) => (keys[j] === own ? copy(c) : x)));\n }\n }\n return dedupe(out).slice(0, shrinkCandidateLimit);\n }\n case \"literal\":\n case \"null\":\n case \"undefined\":\n case \"unknown\":\n return [];\n case \"union\": {\n // The simplest value of each member first (null, false, 0, \"\", the first literal), then within v's own member.\n const simplest = type.members.flatMap((m): unknown[] => {\n switch (m.kind) {\n case \"null\":\n return [null];\n case \"undefined\":\n return [undefined];\n case \"boolean\":\n return [false];\n case \"number\":\n return [0];\n case \"bigint\":\n return [0n];\n case \"string\":\n return [\"\"];\n case \"literal\":\n return [m.value];\n default:\n return [];\n }\n });\n const own = type.members.find((m) => conforms(m, v));\n return dedupe([...simplest, ...(own ? candidatesOf(own, undefined, v) : [])]);\n }\n case \"record\": {\n if (typeof v !== \"object\" || v === null) return [];\n const o = v as Record<string, unknown>;\n const out: unknown[] = [];\n for (const f of type.fields)\n for (const c of candidatesOf(f.type, undefined, o[f.name]))\n if (!same(c, o[f.name])) out.push({ ...o, [f.name]: c });\n return out;\n }\n }\n}\n","/**\n * The `CHECKED` rung: a property evaluated on every input the simulator\n * actually passed to its function. Binders are the function's parameters,\n * so each recorded call is one assignment; one failing the precondition is\n * outside the claim and discarded. One assignment where the claim is false\n * refutes the property. Holding on all of them is `CHECKED`, which says\n * nothing about inputs the simulator never passed.\n */\n\nimport type { Counterexample, SpecVerdict } from \"@eutaxy/core\";\nimport type { Fn, Forall, FunctionSpec, Property } from \"@eutaxy/spec\";\nimport { conforms } from \"./generate.ts\";\nimport { copy, render } from \"./render.ts\";\n\nexport { render } from \"./render.ts\";\n\n/** What evaluating a spec on one assignment came to. */\nexport type PredicateOutcome = \"held\" | \"discarded\" | \"refuted\";\n\nexport type Evaluation =\n | { readonly outcome: \"held\" | \"discarded\" }\n | { readonly outcome: \"refuted\"; readonly error?: string }\n /** The property, not the function, is at fault: it cannot be evaluated at any rung. */\n | { readonly malformed: string };\n\n/**\n * One assignment through a spec. The precondition decides whether the\n * assignment is inside the claim; a precondition that throws or does not\n * answer a boolean is a malformed property, since it cannot tell. The\n * claim then holds, or is false, or throws: a throw from the claim, the\n * function's own included, means the claim is not true there. A claim\n * that returns something other than a boolean is malformed.\n */\nexport function evaluate(\n spec: Forall<Fn>,\n values: readonly unknown[],\n /** For generated inputs: each arrow gets its own copy of their plain data (`copy`). */\n copied = false,\n): Evaluation {\n const fresh = (): never[] => (copied ? copy(values) : values) as never[];\n if (spec.when) {\n let inside: unknown;\n try {\n inside = spec.when(...fresh());\n } catch (err) {\n return { malformed: `the precondition threw ${String(err)}` };\n }\n if (typeof inside !== \"boolean\")\n return { malformed: `the precondition returned ${render(inside)}, not a boolean` };\n if (!inside) return { outcome: \"discarded\" };\n }\n let claim: unknown;\n try {\n claim = spec.ensures(...fresh());\n } catch (err) {\n return { outcome: \"refuted\", error: String(err) };\n }\n if (typeof claim !== \"boolean\")\n return { malformed: `the claim returned ${render(claim)}, not a boolean` };\n return { outcome: claim ? \"held\" : \"refuted\" };\n}\n\n/** How every rung words an `UNKNOWN` for a property that cannot be evaluated; the ladder recognizes it. */\nexport const malformedReason = (detail: string): string =>\n `the property could not be evaluated: ${detail}`;\n\nexport interface CheckedInput {\n readonly module: string;\n readonly fn: FunctionSpec;\n readonly property: Property;\n /** The calls the simulator made, with their arguments. */\n readonly calls: readonly { readonly args: readonly unknown[] }[];\n /** The spec file's export, or undefined when it could not be loaded. */\n readonly spec: Forall<Fn> | undefined;\n /** Why the function's calls could not be observed, when they could not. */\n readonly unobservable?: string;\n}\n\nexport function checkedRung(input: CheckedInput): SpecVerdict {\n const { module, fn, property } = input;\n const base = { module, function: fn.name, property: property.name, text: property.text };\n const unknown = (\n cause: \"gave_up\" | \"unsupported\" | \"unavailable\",\n reason: string,\n ): SpecVerdict => ({ ...base, kind: \"UNKNOWN\", cause, reason, assumptions: [] });\n if (property.kind === \"total\")\n return unknown(\n \"unsupported\",\n \"termination is not observable on the inputs the simulator passed; total needs a prover\",\n );\n if (input.unobservable)\n return unknown(\n \"unavailable\",\n `calls to ${fn.name} could not be observed: ${input.unobservable}`,\n );\n const spec = input.spec;\n if (!spec)\n return unknown(\"unavailable\", `the spec file's export ${property.name} was not loaded`);\n const binders = property.binders;\n const seen = new Set<string>();\n let held = 0;\n let discarded = 0;\n for (const call of input.calls) {\n const values = binders.map((_, i) => call.args[i]);\n const key = values.map(render).join(\", \");\n if (seen.has(key)) continue;\n seen.add(key);\n // The claim quantifies over the parameter types; a call with an argument of another type\n // (a shell passing a string where a number is declared) is outside it, not a counterexample.\n if (!binders.every((b, i) => conforms(b.type, values[i]))) {\n discarded++;\n continue;\n }\n const counterexample = (error?: string): Counterexample => ({\n binders: binders.map((b, i) => ({ name: b.name, value: render(values[i]) })),\n call: `${fn.name}(${call.args.map(render).join(\", \")})`,\n ...(error === undefined ? {} : { error }),\n });\n const result = evaluate(spec, values);\n if (\"malformed\" in result) return unknown(\"unsupported\", malformedReason(result.malformed));\n if (result.outcome === \"refuted\")\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"CHECKED\",\n counterexample: counterexample(result.error),\n assumptions: [],\n };\n if (result.outcome === \"discarded\") discarded++;\n else held++;\n }\n if (held === 0)\n return unknown(\n \"gave_up\",\n input.calls.length === 0\n ? `the simulator never called ${fn.name}`\n : `none of the ${seen.size} distinct input(s) the simulator passed is inside the claim (the precondition)`,\n );\n return {\n ...base,\n kind: \"CHECKED\",\n inputs: held,\n discarded,\n assumptions: [\n `held on the ${held} distinct input(s) the simulator passed to ${fn.name}; inputs it never passed are not covered`,\n ],\n };\n}\n","/**\n * A refuting assignment made as small as the candidates allow, one binder\n * at a time, while the property still fails: what the TESTED rung reports,\n * and what an engine reports after replaying a solver's model.\n */\n\nimport type { Binder, Fn, Forall } from \"@eutaxy/spec\";\nimport { type Evaluation, evaluate } from \"./checked.ts\";\nimport { shrinkCandidates } from \"./generate.ts\";\nimport { copy } from \"./render.ts\";\n\n/** How many evaluations shrinking may spend on one counterexample. */\nconst shrinkBudget = 500;\n\nexport function shrinkRefutation(\n spec: Forall<Fn>,\n binders: readonly Binder[],\n start: readonly unknown[],\n startEvaluation: Evaluation,\n): { readonly values: readonly unknown[]; readonly error?: string } {\n let values = [...start];\n let error: { readonly error?: string } = refutes(startEvaluation) ?? {};\n let spent = 0;\n let progress = true;\n while (progress && spent < shrinkBudget) {\n progress = false;\n for (let i = 0; i < binders.length && spent < shrinkBudget; i++) {\n const b = binders[i] as Binder;\n let moved = true;\n while (moved && spent < shrinkBudget) {\n moved = false;\n for (const candidate of shrinkCandidates(b, values[i])) {\n if (spent >= shrinkBudget) break;\n spent++;\n const trial = values.with(i, candidate);\n // Inside the sample only: it bounds what an evaluation may cost, shrinking included.\n if (spec.sample && !inSample(spec, trial)) continue;\n const still = refutes(evaluate(spec, trial, true));\n if (still === undefined) continue;\n values = trial;\n error = still;\n moved = true;\n progress = true;\n break;\n }\n }\n }\n }\n return error.error === undefined ? { values } : { values, error: error.error };\n}\n\n/** Whether an evaluation still refutes: an object (holding the error text, if any), or undefined. */\nexport function refutes(e: Evaluation): { readonly error?: string } | undefined {\n if (\"malformed\" in e || e.outcome !== \"refuted\") return undefined;\n return \"error\" in e && e.error !== undefined ? { error: e.error } : {};\n}\n\n/** Whether the spec's sample holds of the values (a sample that throws or answers other than true does not). */\nfunction inSample(spec: Forall<Fn>, values: readonly unknown[]): boolean {\n try {\n return spec.sample?.(...(copy(values) as never[])) === true;\n } catch {\n return false;\n }\n}\n","/**\n * The `TESTED` rung: a property evaluated on assignments drawn from its\n * binders' types, steered by the precondition's hints, with a seed, so the\n * same seed draws the same assignments everywhere. An assignment where the\n * claim is false is shrunk toward smaller values that still break it and\n * reported as a counterexample. Holding on every drawn assignment is\n * `TESTED`: evidence from sampling, which says nothing about the inputs\n * never drawn.\n */\n\nimport { type Counterexample, type PrngState, type SpecVerdict, seedPrng } from \"@eutaxy/core\";\nimport type { Fn, Forall, FunctionSpec, Property } from \"@eutaxy/spec\";\nimport { evaluate, malformedReason, render } from \"./checked.ts\";\nimport {\n CannotGenerate,\n edgeAssignment,\n edgeAssignmentCount,\n edgeLists,\n generateAssignment,\n} from \"./generate.ts\";\nimport { copy } from \"./render.ts\";\nimport { shrinkRefutation } from \"./shrink.ts\";\n\nexport interface TestedOptions {\n /** The check's seed; each property derives its own stream from it and its name. */\n readonly seed: string;\n /** Distinct assignments the property must hold on; default 100. Drawing stops after 20 times as many draws, whatever they were. */\n readonly inputs?: number;\n}\n\nexport interface TestedInput extends TestedOptions {\n readonly module: string;\n readonly fn: FunctionSpec;\n readonly property: Property;\n /** The spec file's export, or undefined when it could not be loaded. */\n readonly spec: Forall<Fn> | undefined;\n}\n\nexport function testedRung(input: TestedInput): SpecVerdict {\n const { module, fn, property } = input;\n const base = { module, function: fn.name, property: property.name, text: property.text };\n const unknown = (\n cause: \"gave_up\" | \"unsupported\" | \"unavailable\",\n reason: string,\n ): SpecVerdict => ({ ...base, kind: \"UNKNOWN\", cause, reason, assumptions: [] });\n if (property.kind === \"total\")\n return unknown(\n \"unsupported\",\n \"termination is not observable on generated inputs; total needs a prover\",\n );\n const spec = input.spec;\n if (!spec)\n return unknown(\"unavailable\", `the spec file's export ${property.name} was not loaded`);\n const binders = property.binders;\n const wanted = input.inputs ?? 100;\n if (!Number.isInteger(wanted) || wanted < 1)\n throw new RangeError(`inputs must be a positive integer, got ${String(input.inputs)}`);\n const seed = `${input.seed}:${module}:${fn.name}:${property.name}`;\n let state: PrngState = seedPrng(seed);\n let held = 0;\n let discarded = 0;\n let sampledOut = 0;\n // Distinct assignments only, as the CHECKED rung counts them: two booleans are two inputs, not a hundred.\n const seen = new Set<string>();\n const counterexample = (values: readonly unknown[], error?: string): Counterexample => ({\n binders: binders.map((b, i) => ({ name: b.name, value: render(values[i]) })),\n ...(error === undefined ? {} : { error }),\n });\n // Every edge assignment is tried, however many there are (a union of a hundred literals has a\n // hundred); then random draws until the budget is met, and at least half of it random, so many\n // edges never crowd out the values between them.\n const edges = edgeLists(binders);\n const edgeTotal = edgeAssignmentCount(edges);\n const randomWanted = Math.ceil(wanted / 2);\n let randomHeld = 0;\n for (\n let draws = 0;\n draws < edgeTotal ||\n ((held < wanted || randomHeld < randomWanted) && draws < edgeTotal + wanted * 20);\n draws++\n ) {\n let values: unknown[];\n try {\n // The edges first, every one of them, then random draws.\n [values, state] =\n (draws < edgeTotal ? edgeAssignment(binders, edges, draws, state) : undefined) ??\n generateAssignment(binders, state);\n } catch (err) {\n if (err instanceof CannotGenerate) return unknown(err.why, err.message);\n throw err;\n }\n const key = values.map(render).join(\", \");\n if (seen.has(key)) continue;\n seen.add(key);\n // Outside the sample is not drawn at all: neither inside nor outside the claim, just not tried.\n if (spec.sample) {\n let inSample: unknown;\n try {\n inSample = spec.sample(...(copy(values) as never[]));\n } catch (err) {\n return unknown(\"unsupported\", malformedReason(`the sample threw ${String(err)}`));\n }\n if (typeof inSample !== \"boolean\")\n return unknown(\n \"unsupported\",\n malformedReason(`the sample returned ${render(inSample)}, not a boolean`),\n );\n if (!inSample) {\n sampledOut++;\n continue;\n }\n }\n const result = evaluate(spec, values, true);\n if (\"malformed\" in result) return unknown(\"unsupported\", malformedReason(result.malformed));\n if (result.outcome === \"discarded\") {\n discarded++;\n continue;\n }\n if (result.outcome === \"refuted\") {\n const smallest = shrinkRefutation(spec, binders, values, result);\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"TESTED\",\n counterexample: counterexample(smallest.values, smallest.error),\n assumptions: [`found on an input generated with seed ${input.seed}, then shrunk`],\n };\n }\n held++;\n if (draws >= edgeTotal) randomHeld++;\n }\n if (held === 0)\n return unknown(\n \"gave_up\",\n sampledOut > 0 && discarded === 0\n ? `all ${sampledOut} distinct generated inputs were outside the sample: it admits too few of the parameter types to draw`\n : `all ${discarded + sampledOut} distinct generated inputs were outside the claim or the sample: its precondition admits too few of the parameter types to sample`,\n );\n return {\n ...base,\n kind: \"TESTED\",\n inputs: held,\n discarded,\n seed: input.seed,\n assumptions: [\n `held on ${held} distinct input(s) generated from the parameter types with seed ${input.seed}; inputs never drawn are not covered`,\n `${fn.name} was called on generated inputs outside the simulator, so it is assumed pure`,\n ...(spec.sample\n ? [\n `drawn only where the sample holds${property.sample ? ` (${property.sample.body.replace(/\\s+/g, \" \").trim()})` : \"\"}; the claim itself is not limited to it`,\n ]\n : []),\n ],\n };\n}\n","/**\n * The spec ladder, as far as it goes without an engine: `CHECKED` on the\n * inputs the simulator passed, then `TESTED` on generated ones. A\n * counterexample at either rung is `REFUTED`; otherwise the verdict is the\n * highest rung that decided, with the lower one's evidence kept beside it.\n */\n\nimport type { SpecVerdict } from \"@eutaxy/core\";\nimport { type Fn, type Forall, isSpec, type ModuleSpecs } from \"@eutaxy/spec\";\nimport { type CheckedInput, checkedRung, malformedReason } from \"./checked.ts\";\nimport { type TestedOptions, testedRung } from \"./tested.ts\";\n\nexport interface LadderOptions {\n /** Run the `TESTED` rung with these options; `false` stops the ladder at `CHECKED`. */\n readonly tested?: TestedOptions | false;\n /** `false` when no scenario ran (`eutaxy report`): the ladder starts at `TESTED`, which it then needs. */\n readonly checked?: false;\n}\n\n/** One property through the ladder's rungs. */\nexport function specLadder(input: CheckedInput, options: LadderOptions = {}): SpecVerdict {\n if (options.checked === false) {\n if (!options.tested) throw new RangeError(\"a ladder without CHECKED needs the TESTED rung\");\n return testedRung({\n module: input.module,\n fn: input.fn,\n property: input.property,\n spec: input.spec,\n ...options.tested,\n });\n }\n const checked = checkedRung(input);\n if (checked.kind === \"REFUTED\" || options.tested === false || options.tested === undefined)\n return checked;\n if (input.property.kind === \"total\") return checked;\n // A property that could not be evaluated on an input the simulator passed is malformed: sampling\n // that happens to miss the input must not make it look sound.\n if (checked.kind === \"UNKNOWN\" && checked.reason.startsWith(malformedReason(\"\"))) return checked;\n const tested = testedRung({\n module: input.module,\n fn: input.fn,\n property: input.property,\n spec: input.spec,\n ...options.tested,\n });\n if (tested.kind === \"REFUTED\") return tested;\n // The same holds the other way round: a generated input that shows the property malformed outranks CHECKED.\n if (tested.kind === \"UNKNOWN\" && tested.reason.startsWith(malformedReason(\"\"))) return tested;\n if (tested.kind === \"TESTED\") {\n if (checked.kind !== \"CHECKED\")\n // Why there is no `checked` count stays visible: the simulator never called the function, say.\n return { ...tested, assumptions: [...tested.assumptions, reason(checked)] };\n return {\n ...tested,\n checked: checked.inputs,\n assumptions: [...tested.assumptions, ...checked.assumptions],\n };\n }\n if (checked.kind !== \"UNKNOWN\")\n return { ...checked, assumptions: [...checked.assumptions, `not TESTED: ${reason(tested)}`] };\n // Neither rung decided: say why for both, once when it is the same reason.\n if (reason(tested) === checked.reason) return checked;\n return { ...checked, reason: `${checked.reason}; generated inputs: ${reason(tested)}` };\n}\n\nfunction reason(v: SpecVerdict): string {\n return v.kind === \"UNKNOWN\" ? v.reason : v.kind;\n}\n\n/**\n * Every spec verdict for one module: each property through the ladder.\n * `props` is the spec file's namespace, `namespace` the module's (after\n * observation ended, so it holds the functions themselves); a spec whose\n * function is not the module's export of that name is not evaluated.\n */\nexport function checkSpecModule(\n module: string,\n specs: ModuleSpecs,\n props: Readonly<Record<string, unknown>>,\n namespace: Readonly<Record<string, unknown>>,\n observed: {\n readonly calls: readonly { readonly function: string; readonly args: readonly unknown[] }[];\n readonly unobservable: { readonly [fn: string]: string };\n },\n options: LadderOptions = {},\n): SpecVerdict[] {\n return specs.functions.flatMap((fn) => {\n const calls = observed.calls.filter((c) => c.function === fn.name);\n // Own properties only: a function named toString must not find Object.prototype's.\n const unobservable = Object.hasOwn(observed.unobservable, fn.name)\n ? observed.unobservable[fn.name]\n : undefined;\n return fn.properties.map((property) => {\n const exported = Object.hasOwn(props, property.name) ? props[property.name] : undefined;\n let spec: Forall<Fn> | undefined;\n let mismatch: string | undefined;\n if (!isSpec(exported)) mismatch = `the spec file exports no spec named ${property.name}`;\n else if (exported.fn !== namespace[fn.name])\n mismatch = `${property.name} names a function that is not the module's export ${fn.name}`;\n else if (exported.kind === \"forall\") spec = exported;\n if (mismatch !== undefined)\n return {\n module,\n function: fn.name,\n property: property.name,\n text: property.text,\n kind: \"UNKNOWN\",\n cause: \"unavailable\",\n reason: mismatch,\n assumptions: [],\n };\n return specLadder(\n {\n module,\n fn,\n property,\n calls,\n spec,\n ...(unobservable === undefined ? {} : { unobservable }),\n },\n options,\n );\n });\n });\n}\n","/**\n * The `Prover` interface every engine implements, first-party or not, and\n * the aggregation of what engines say into the ladder's verdicts. An\n * engine takes a module's source with its specs and the functions to\n * prove and answers per property: `PROVEN` with its name, version and\n * assumptions, or `UNKNOWN` as `gave_up` (a proof did not close, or timed\n * out), `unsupported` (outside its subset) or `unavailable` (not\n * installed). An engine that refutes gives `REFUTED` with a counterexample\n * when it has one. Engines run over a process boundary; nothing here\n * spawns anything.\n */\n\nimport type { Counterexample, SpecVerdict } from \"@eutaxy/core\";\nimport type { ModuleSpecs, SpecError } from \"@eutaxy/spec\";\n\nexport interface EngineId {\n readonly name: string;\n readonly version: string;\n}\n\nexport type ProofOutcome =\n | { readonly kind: \"PROVEN\"; readonly engine: EngineId; readonly assumptions: readonly string[] }\n | {\n readonly kind: \"REFUTED\";\n readonly engine: EngineId;\n readonly counterexample?: Counterexample;\n readonly assumptions: readonly string[];\n }\n | {\n readonly kind: \"UNKNOWN\";\n readonly cause: \"gave_up\" | \"unsupported\" | \"unavailable\";\n readonly reason: string;\n };\n\nexport interface PropertyProof {\n readonly function: string;\n /** The property's export name in the spec file. */\n readonly property: string;\n readonly outcome: ProofOutcome;\n}\n\nexport interface ModuleProofs {\n readonly results: readonly PropertyProof[];\n /** Specs that did not read: properties asked for and never checked. */\n readonly specErrors: readonly SpecError[];\n}\n\nexport interface ProveInput {\n /** The module's source text. */\n readonly source: string;\n /** The module's specs, read from its spec file. */\n readonly specs: ModuleSpecs;\n /** The functions to prove; every one with specs when omitted. */\n readonly functions?: readonly string[];\n /** The module's path, under which its imports resolve; without it the module stands alone. */\n readonly modulePath?: string;\n /** The spec file's path, for an engine that replays a counterexample through the spec itself. */\n readonly specPath?: string;\n readonly timeoutMs?: number;\n}\n\nexport interface Prover {\n readonly name: string;\n /** Whether the engine can run here, or why not. */\n available(): Promise<{ readonly version: string } | { readonly unavailable: string }>;\n prove(input: ProveInput): Promise<ModuleProofs>;\n}\n\n/** What an engine said about one module, by its name. */\nexport interface EngineReport {\n readonly engine: string;\n readonly proofs: ModuleProofs;\n}\n\n/**\n * The simulator's verdicts for a module (CHECKED, TESTED, REFUTED, UNKNOWN,\n * `total` included) combined with what the engines proved. A simulator\n * counterexample stands. One engine proving is `PROVEN`, the lower rungs'\n * counts kept beside it; an engine refuting where nothing else did is\n * `REFUTED` at the PROVEN rung; one proving and another refuting is\n * `CONFLICT`. An engine that gave up, could not run or does not take the\n * function leaves the verdict as it was, with why among the assumptions.\n */\nexport function aggregate(\n module: string,\n verdicts: readonly SpecVerdict[],\n reports: readonly EngineReport[],\n): SpecVerdict[] {\n return verdicts.map((v) => {\n if (v.module !== module) return v;\n const says = reports\n .map((r) => ({\n engine: r.engine,\n outcome: r.proofs.results.find(\n (p) => p.function === v.function && p.property === v.property,\n )?.outcome,\n }))\n .filter((x): x is { engine: string; outcome: ProofOutcome } => x.outcome !== undefined);\n if (says.length === 0) return v;\n const proven = says.find((x) => x.outcome.kind === \"PROVEN\");\n const refuted = says.find((x) => x.outcome.kind === \"REFUTED\");\n if (v.kind === \"REFUTED\" || v.kind === \"CONFLICT\") {\n // The simulator's counterexample is a fact; an engine proving against it is a conflict too.\n if (v.kind === \"REFUTED\" && proven?.outcome.kind === \"PROVEN\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"CONFLICT\",\n proven: proven.outcome.engine,\n refuted: { name: \"simulator\", version: v.rung, counterexample: v.counterexample },\n assumptions: [...v.assumptions, ...proven.outcome.assumptions],\n };\n return v;\n }\n if (proven?.outcome.kind === \"PROVEN\" && refuted?.outcome.kind === \"REFUTED\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"CONFLICT\",\n proven: proven.outcome.engine,\n refuted: {\n name: refuted.outcome.engine.name,\n version: refuted.outcome.engine.version,\n ...(refuted.outcome.counterexample\n ? { counterexample: refuted.outcome.counterexample }\n : {}),\n },\n assumptions: [...proven.outcome.assumptions, ...refuted.outcome.assumptions],\n };\n if (refuted?.outcome.kind === \"REFUTED\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"REFUTED\",\n rung: \"PROVEN\",\n engine: refuted.outcome.engine,\n counterexample: refuted.outcome.counterexample ?? { binders: [] },\n assumptions: refuted.outcome.assumptions,\n };\n if (proven?.outcome.kind === \"PROVEN\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"PROVEN\",\n engine: proven.outcome.engine,\n ...(v.kind === \"TESTED\" ? { tested: v.inputs } : {}),\n ...(v.kind === \"TESTED\" && v.checked !== undefined\n ? { checked: v.checked }\n : v.kind === \"CHECKED\"\n ? { checked: v.inputs }\n : {}),\n assumptions: [...proven.outcome.assumptions, ...v.assumptions],\n };\n // Every engine fell short: say so beside the verdict that stands.\n const notes = says.map((x) =>\n x.outcome.kind === \"UNKNOWN\"\n ? `not PROVEN by ${x.engine}: ${x.outcome.cause}: ${x.outcome.reason}`\n : `${x.engine}: ${x.outcome.kind}`,\n );\n return { ...v, assumptions: [...v.assumptions, ...notes] };\n });\n}\n","/**\n * The Vitest regression emitter. Given a violation, produce a test file that\n * replays its shrunk schedule on the restricted scenario. By default the\n * test expects the invariants to hold, so it fails while the bug exists and\n * passes once it is fixed. With `expect: \"violates\"` it asserts the recorded\n * violation instead, which is how Eutaxy's own corpus exercises the emitter.\n *\n * The emitter knows nothing about any platform: the caller supplies the\n * import lines and the expression that builds the platform.\n */\n\nimport { canonicalJson, type JsonValue, type Violated } from \"@eutaxy/core\";\n\nexport interface RegressionTestOptions {\n /** Import lines for the scenario, the platform's dependencies, and anything the platform expression needs. */\n readonly imports: readonly string[];\n /** An expression evaluating to the `Platform` (may reference the imports). */\n readonly platform: string;\n /** An expression evaluating to the `ScenarioSpec`. */\n readonly scenario: string;\n /** Module that exports `replay`, `restrictSpec` and `checkInvariants`; the public facade by default. */\n readonly engineModule?: string;\n readonly expect?: \"holds\" | \"violates\";\n /**\n * Core functions to observe during the replay, as `refines` needs their\n * decisions in the log: an expression for each module's namespace (from\n * the imports) and the functions to observe on it.\n */\n readonly observe?: readonly {\n readonly namespace: string;\n readonly functions: readonly string[];\n }[];\n}\n\nexport function emitRegressionTest(verdict: Violated, options: RegressionTestOptions): string {\n const engineModule = options.engineModule ?? \"eutaxy\";\n const mode = options.expect ?? \"holds\";\n const schedule = canonicalJson(verdict.schedule as unknown as JsonValue);\n const kept = canonicalJson([...verdict.keptEvents]);\n const keys = canonicalJson([...verdict.violation.keys]);\n const title =\n mode === \"holds\"\n ? `${verdict.scenario}: ${verdict.violation.invariant} holds on the recorded schedule`\n : `${verdict.scenario}: ${verdict.violation.invariant} is still violated on the recorded schedule`;\n const assertion =\n mode === \"holds\"\n ? ` expect(violations.map((v) => \\`\\${v.invariant}: \\${v.message}\\`)).toEqual([]);`\n : ` expect(violations.map((v) => [v.invariant, v.keys])).toContainEqual([${JSON.stringify(verdict.violation.invariant)}, ${keys}]);`;\n const observe = options.observe ?? [];\n const replayLines =\n observe.length === 0\n ? [\" const log = await replay(spec, platform, schedule);\"]\n : [\n ` const observers = [${observe.map((o) => `observeCore(${o.namespace}, ${JSON.stringify(o.functions)})`).join(\", \")}];`,\n \" const log = await replay(spec, platform, schedule).finally(() => {\",\n \" for (const o of observers) o.restore();\",\n \" });\",\n ];\n const lines = [\n \"// Generated by Eutaxy. Replays a recorded violation; regenerate rather than edit.\",\n `// Scenario ${verdict.scenario}, seed ${String(verdict.seed)}: ${verdict.violation.message}`,\n `import { checkInvariants, ${observe.length > 0 ? \"observeCore, \" : \"\"}replay, restrictSpec } from ${JSON.stringify(engineModule)};`,\n ...options.imports,\n 'import { expect, test } from \"vitest\";',\n \"\",\n `const schedule = ${schedule} as const;`,\n `const keptEvents = ${kept} as const;`,\n \"\",\n `test(${JSON.stringify(title)}, async () => {`,\n ` const platform = ${options.platform};`,\n ` const spec = restrictSpec(platform, ${options.scenario}, keptEvents);`,\n ...replayLines,\n \" const violations = checkInvariants(log, spec.invariants);\",\n assertion,\n \"});\",\n \"\",\n ];\n return lines.join(\"\\n\");\n}\n","/**\n * Rendering verdicts: a text form for people and a versioned JSON form for\n * CI and coding agents. Both are pure functions over the verdict data.\n */\n\nimport {\n canonicalJson,\n type EffectLog,\n type JsonValue,\n type ScenarioVerdict,\n type SpecVerdict,\n} from \"@eutaxy/core\";\n\nexport const reportSchemaVersion = 1;\n\n/**\n * The JSON report: one object, canonical, with a schema version at the top.\n * Spec verdicts, when there are any, sit beside the scenario's, never in it.\n */\nexport function renderJson(verdict: ScenarioVerdict, specs: readonly SpecVerdict[] = []): string {\n return canonicalJson({\n schemaVersion: reportSchemaVersion,\n generator: \"eutaxy\",\n verdict: verdict as unknown as JsonValue,\n ...(specs.length > 0 ? { specs: specs as unknown as JsonValue } : {}),\n });\n}\n\nconst specsHeader =\n \"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)\";\n\n/** Spec verdicts as text: one line each, a counterexample under a refutation. */\nexport function renderSpecs(specs: readonly SpecVerdict[]): string {\n if (specs.length === 0) return \"\";\n return [specsHeader, ...specs.flatMap(specLines)].join(\"\\n\");\n}\n\n/** The order a report counts verdicts in: strongest evidence first, then what needs attention. */\nconst verdictOrder = [\"PROVEN\", \"TESTED\", \"CHECKED\", \"REFUTED\", \"CONFLICT\", \"UNKNOWN\"] as const;\n\n/**\n * `eutaxy report` as text: the spec verdicts grouped by module, in the\n * order given, and one closing line counting them by verdict.\n */\nexport function renderSpecReport(specs: readonly SpecVerdict[]): string {\n if (specs.length === 0) return \"No specs found.\";\n const modules = [...new Set(specs.map((v) => v.module))];\n const out = [\n \"Specs (TESTED means held on inputs generated from the parameter types, which is not a proof; PROVEN is one, by the named engine)\",\n ];\n for (const m of modules) {\n out.push(\"\", m);\n for (const v of specs) if (v.module === m) out.push(...specLines(v));\n }\n const counts = verdictOrder\n .map((k) => [k, specs.filter((v) => v.kind === k).length] as const)\n .filter(([, n]) => n > 0)\n .map(([k, n]) => `${n} ${k}`);\n out.push(\n \"\",\n `${specs.length} propert${specs.length === 1 ? \"y\" : \"ies\"} in ${modules.length} module${modules.length === 1 ? \"\" : \"s\"}: ${counts.join(\", \")}`,\n );\n return out.join(\"\\n\");\n}\n\n/** `eutaxy report --json`: canonical, with the schema version, the spec verdicts and nothing else. */\nexport function renderSpecReportJson(specs: readonly SpecVerdict[]): string {\n return canonicalJson({\n schemaVersion: reportSchemaVersion,\n generator: \"eutaxy\",\n specs: specs as unknown as JsonValue,\n });\n}\n\nfunction specLines(v: SpecVerdict): string[] {\n const out: string[] = [];\n const what = `${v.function} ${v.property}`;\n switch (v.kind) {\n case \"CHECKED\":\n out.push(\n ` CHECKED ${what}: held on ${v.inputs} input(s)${v.discarded > 0 ? `, ${v.discarded} outside the claim` : \"\"}`,\n );\n break;\n case \"TESTED\":\n out.push(\n ` TESTED ${what}: held on ${v.inputs} generated input(s)${v.checked === undefined ? \"\" : ` and ${v.checked} the simulator passed`}${v.discarded > 0 ? `, ${v.discarded} outside the claim` : \"\"}`,\n );\n break;\n case \"PROVEN\": {\n const beside = [\n ...(v.tested === undefined ? [] : [`${v.tested} generated input(s)`]),\n ...(v.checked === undefined ? [] : [`${v.checked} the simulator passed`]),\n ];\n out.push(\n ` PROVEN ${what}: by ${v.engine.name} ${v.engine.version}${beside.length > 0 ? `; also held on ${beside.join(\" and \")}` : \"\"}`,\n );\n break;\n }\n case \"CONFLICT\":\n out.push(\n ` CONFLICT ${what}: ${v.proven.name} ${v.proven.version} proves it, ${v.refuted.name} ${v.refuted.version} refutes it; not resolved automatically`,\n );\n if (v.refuted.counterexample)\n out.push(\n ` ${v.refuted.counterexample.binders.map((b) => `${b.name} = ${b.value}`).join(\", \")}`,\n );\n break;\n case \"REFUTED\": {\n const c = v.counterexample;\n const where =\n v.rung === \"PROVEN\"\n ? `by ${v.engine?.name ?? \"an engine\"}`\n : c.call === undefined\n ? \"on a generated input\"\n : `at ${c.call}`;\n out.push(` REFUTED ${what}: false ${where}${c.error ? `, which threw ${c.error}` : \"\"}`);\n if (c.binders.length > 0)\n out.push(` ${c.binders.map((b) => `${b.name} = ${b.value}`).join(\", \")}`);\n out.push(` ${v.text.replace(/\\s+/g, \" \")}`);\n break;\n }\n case \"UNKNOWN\":\n out.push(` UNKNOWN ${what}: ${v.cause}: ${v.reason}`);\n break;\n }\n // A proof rests on its engine's model of the language: every assumption is shown. Elsewhere, an\n // engine that was asked and fell short says so under the verdict that stands.\n for (const a of v.assumptions)\n if (v.kind === \"PROVEN\" || a.startsWith(\"not PROVEN by \")) out.push(` ${a}`);\n return out;\n}\n\nfunction clip(s: string, max: number): string {\n return s.length <= max ? s : `${s.slice(0, max - 1)}…`;\n}\n\nfunction pad(s: string, width: number): string {\n return s.length >= width ? s : s + \" \".repeat(width - s.length);\n}\n\n/** The trace as a fixed-width table; evidence rows are marked with `*`. */\nexport function renderTrace(log: EffectLog, evidence: readonly number[] = []): string {\n const rows = log.entries.map((e) => [\n evidence.includes(e.seq) ? \"*\" : \" \",\n String(e.seq),\n e.invocation,\n e.kind,\n e.target,\n e.op,\n clip(canonicalJson(e.payload), 72),\n ]);\n const header = [\" \", \"seq\", \"invocation\", \"kind\", \"target\", \"op\", \"payload\"];\n const widths = header.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] as string).length)),\n );\n const line = (cells: readonly string[]) =>\n cells\n .map((c, i) => (i === cells.length - 1 ? c : pad(c, widths[i] as number)))\n .join(\" \")\n .trimEnd();\n return [line(header), ...rows.map(line)].join(\"\\n\");\n}\n\n/** A readable report: verdict, what it rests on, and for a violation the schedule and trace. */\nexport function renderText(verdict: ScenarioVerdict): string {\n const out: string[] = [];\n const r = verdict.reached;\n out.push(`${verdict.kind} ${verdict.scenario} (seed ${String(verdict.seed)})`);\n switch (verdict.kind) {\n case \"VIOLATED\": {\n out.push(\"\");\n out.push(\n `Invariant ${verdict.violation.invariant} is violated: ${verdict.violation.message}`,\n );\n out.push(`Keys: ${verdict.violation.keys.join(\", \")}`);\n out.push(\"\");\n out.push(\n `Schedule (run seed ${verdict.schedule.seed}), events kept: ${verdict.keptEvents.join(\", \")}`,\n );\n if (verdict.schedule.faults.length === 0) out.push(\" no injected faults\");\n for (const f of verdict.schedule.faults) {\n out.push(` ${f.fault} at ${f.invocation} effect #${f.ordinal} (${f.target} ${f.op})`);\n }\n out.push(\n `Shrunk: ${verdict.shrunk.eventsRemoved} event(s) and ${verdict.shrunk.faultsRemoved} fault(s) removed in ${verdict.shrunk.runs} run(s)`,\n );\n out.push(\"\");\n out.push(\"Trace:\");\n out.push(renderTrace(verdict.trace, verdict.violation.evidence));\n break;\n }\n case \"BOUNDED\": {\n const b = verdict.bounds;\n out.push(\"\");\n out.push(\"No violation found within the stated bounds. This is not a proof.\");\n out.push(\n `Bounds: faults per run ≤ ${b.maxFaultsPerRun}, redeliveries ≤ ${b.maxRedeliveries}, concurrent invocations ≤ ${b.maxConcurrentInvocations}, budget ${b.budgetMs} ms`,\n );\n break;\n }\n case \"UNSUPPORTED\": {\n out.push(\"\");\n out.push(`Eutaxy could not decide this scenario (${verdict.cause}): ${verdict.reason}`);\n break;\n }\n }\n out.push(\"\");\n out.push(\n `Explored: ${r.runs} run(s), ${r.effectPoints} effect point(s), ${r.faultsInjected} fault(s) injected, ${r.elapsedMs} ms`,\n );\n const e = r.exhaustive;\n if (e) {\n const stopped = {\n VIOLATED: \"stopped at the first violation\",\n BOUNDED: \"stopped at the budget before every schedule ran\",\n UNSUPPORTED: \"stopped where the scenario could not be decided\",\n }[verdict.kind];\n out.push(\n `Exhaustive: ${e.complete ? \"every schedule within the bounds ran\" : stopped} (${e.schedules} schedules${e.reduction ? \", partial-order reduction\" : \"\"})`,\n );\n }\n out.push(\"Assumptions:\");\n for (const a of verdict.assumptions) out.push(` - ${a}`);\n return out.join(\"\\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QAAQ,CAAC;GAC/D;EAEF,KAAK,WAAW;GACd,MAAM,IAAI,QAAQ;GAClB,IAAI,KAAK,EAAE;GACX,IAAI,KAAK,mEAAmE;GAC5E,IAAI,KACF,4BAA4B,EAAE,gBAAgB,mBAAmB,EAAE,gBAAgB,6BAA6B,EAAE,yBAAyB,WAAW,EAAE,SAAS,IACnK;GACA;EACF;EACA,KAAK;GACH,IAAI,KAAK,EAAE;GACX,IAAI,KAAK,0CAA0C,QAAQ,MAAM,KAAK,QAAQ,QAAQ;CAG1F;CACA,IAAI,KAAK,EAAE;CACX,IAAI,KACF,aAAa,EAAE,KAAK,WAAW,EAAE,aAAa,oBAAoB,EAAE,eAAe,sBAAsB,EAAE,UAAU,IACvH;CACA,MAAM,IAAI,EAAE;CACZ,IAAI,GAAG;EACL,MAAM,UAAU;GACd,UAAU;GACV,SAAS;GACT,aAAa;EACf,EAAE,QAAQ;EACV,IAAI,KACF,eAAe,EAAE,WAAW,yCAAyC,QAAQ,IAAI,EAAE,UAAU,YAAY,EAAE,YAAY,8BAA8B,GAAG,EAC1J;CACF;CACA,IAAI,KAAK,cAAc;CACvB,KAAK,MAAM,KAAK,QAAQ,aAAa,IAAI,KAAK,OAAO,GAAG;CACxD,OAAO,IAAI,KAAK,IAAI;AACtB"}
|
|
1
|
+
{"version":3,"file":"src-CWVQEhTr.mjs","names":["digits"],"sources":["../../core/src/verdict.ts","../../spec/src/ir.ts","../../prover/src/regex-gen.ts","../../prover/src/render.ts","../../prover/src/generate.ts","../../prover/src/checked.ts","../../prover/src/shrink.ts","../../prover/src/tested.ts","../../prover/src/ladder.ts","../../prover/src/provers.ts","../../report/src/regression.ts","../../report/src/render.ts"],"sourcesContent":["/** Simulation verdicts, with what each one rests on. */\n\nimport type { EffectLog } from \"./effect-log.ts\";\nimport type { Schedule } from \"./faults.ts\";\nimport type { Violation } from \"./invariants.ts\";\nimport type { Bounds } from \"./scenario.ts\";\n\nexport interface BoundsReached {\n readonly runs: number;\n readonly effectPoints: number;\n readonly faultsInjected: number;\n readonly elapsedMs: number;\n /**\n * Present when exploration was exhaustive: how many distinct schedules ran\n * (runs that only repeated an order the reduction had covered are not\n * counted), and whether every schedule within the bounds was reached\n * before the budget ran out.\n */\n readonly exhaustive?: {\n readonly complete: boolean;\n readonly schedules: number;\n readonly reduction: boolean;\n };\n}\n\ninterface VerdictBase {\n readonly scenario: string;\n readonly seed: number | string;\n readonly reached: BoundsReached;\n readonly assumptions: readonly string[];\n}\n\nexport interface Shrunk {\n readonly faultsRemoved: number;\n readonly eventsRemoved: number;\n readonly runs: number;\n}\n\nexport interface Violated extends VerdictBase {\n readonly kind: \"VIOLATED\";\n readonly violation: Violation;\n /** The replayed, shrunk trace that breaks the invariant. */\n readonly trace: EffectLog;\n readonly schedule: Schedule;\n /** Ids of the drive's events that remain after shrinking. */\n readonly keptEvents: readonly string[];\n readonly shrunk: Shrunk;\n}\n\nexport interface Bounded extends VerdictBase {\n readonly kind: \"BOUNDED\";\n readonly bounds: Bounds;\n}\n\nexport type UnsupportedCause =\n | \"unsupported_api\"\n | \"not_replayable\"\n | \"module_state_leak\"\n | \"unsupported_bounds\";\n\nexport interface Unsupported extends VerdictBase {\n readonly kind: \"UNSUPPORTED\";\n readonly cause: UnsupportedCause;\n readonly reason: string;\n}\n\nexport type ScenarioVerdict = Violated | Bounded | Unsupported;\n\n/** One line per verdict, for error messages; full rendering lives in `report`. */\nexport function describeVerdict(v: ScenarioVerdict): string {\n switch (v.kind) {\n case \"VIOLATED\":\n return `VIOLATED ${v.scenario}: ${v.violation.message} (seed ${v.schedule.seed}, ${v.reached.runs} run(s))`;\n case \"BOUNDED\":\n return `BOUNDED ${v.scenario}: no violation in ${v.reached.runs} run(s), ${v.reached.effectPoints} effect point(s), ${v.reached.faultsInjected} fault(s)`;\n case \"UNSUPPORTED\":\n return `UNSUPPORTED ${v.scenario}: ${v.cause}: ${v.reason}`;\n }\n}\n","/**\n * SpecIR: function specs as plain data. The surface is TypeScript (a spec\n * file beside the module, `forall(f, { when, ensures })` and `total(f)`\n * from `eutaxy/spec`); the IR is Eutaxy's own, so the simulator's rungs\n * and every engine read one shape. Binder domains are the function's\n * parameter types, read from its declaration; the precondition and the\n * claim are kept as the arrow functions' text, read by each engine into\n * its own tree, and evaluated as code by the simulator's rungs.\n */\n\n/** A TypeScript type as far as the reader can read it; `unknown` carries what it could not. */\nexport type SpecType =\n | { readonly kind: \"number\" }\n | { readonly kind: \"boolean\" }\n | { readonly kind: \"string\" }\n | { readonly kind: \"bigint\" }\n | { readonly kind: \"literal\"; readonly value: string | number | boolean }\n | { readonly kind: \"null\" }\n | { readonly kind: \"undefined\" }\n | {\n readonly kind: \"record\";\n /** The declared name, when the type is an `interface` or a `type` alias rather than inline. */\n readonly name?: string;\n readonly fields: readonly Field[];\n }\n | { readonly kind: \"union\"; readonly members: readonly SpecType[] }\n /** `T[]`, `readonly T[]`, `Array<T>` or `ReadonlyArray<T>`: a JavaScript array, read-only or not. */\n | { readonly kind: \"array\"; readonly element: SpecType }\n | { readonly kind: \"unknown\"; readonly text: string };\n\nexport interface Field {\n readonly name: string;\n readonly type: SpecType;\n}\n\n/** One end of a numeric range: the literal as written (sign included). `[` and `]` include the endpoint. */\nexport interface Endpoint {\n readonly value: string;\n readonly inclusive: boolean;\n}\n\n/**\n * What the precondition says about one binder on its own, read from its\n * conjuncts: `Number.isInteger(n)`, `0 <= n`, `n < 5`, `/^a+$/.test(s)`.\n * Draws are steered by it; the precondition itself still has the last word.\n */\nexport interface Hint {\n readonly integer?: true;\n readonly lower?: Endpoint;\n readonly upper?: Endpoint;\n readonly regex?: { readonly pattern: string; readonly flags: string };\n}\n\n/** A parameter of the function under spec. */\nexport interface Param {\n /** Null for a destructured or rest parameter. */\n readonly name: string | null;\n readonly type: SpecType;\n}\n\n/** A quantified variable: a parameter, under the name the claim gives it. */\nexport interface Binder {\n readonly name: string;\n readonly type: SpecType;\n readonly hint?: Hint;\n}\n\n/** An arrow function from the spec file, as written. */\nexport interface Arrow {\n /** Parameter names in order; null for a destructured one. */\n readonly params: readonly (string | null)[];\n /** The body's source text: an expression, or the statements between the braces when `block`. */\n readonly body: string;\n readonly block: boolean;\n /** 1-based line of the arrow in the spec file. */\n readonly line: number;\n}\n\n/**\n * One exported spec: `forall(f, { when, ensures })`, a universally\n * quantified claim over `f`'s parameters where the precondition holds, or\n * `total(f)`, that `f` terminates on every input.\n */\nexport interface Property {\n /** The export's name in the spec file. */\n readonly name: string;\n readonly kind: \"forall\" | \"total\";\n /** The parameters, named as `ensures` names them (the function's own names past its arity). */\n readonly binders: readonly Binder[];\n /** Where the `TESTED` rung draws inputs; not part of the claim (see `Forall`). */\n readonly sample?: Arrow;\n readonly when?: Arrow;\n readonly ensures?: Arrow;\n /**\n * The module's functions the spec file imports, by the local name the\n * arrows use: a claim's free names resolve here, never in the module.\n */\n readonly imports: readonly { readonly local: string; readonly fn: string }[];\n /** The claim as written, for reports. */\n readonly text: string;\n /** 1-based line of the export in the spec file. */\n readonly line: number;\n}\n\n/** The specs on one exported function. */\nexport interface FunctionSpec {\n readonly name: string;\n readonly params: readonly Param[];\n readonly properties: readonly Property[];\n /** 1-based line of the declaration in the module. */\n readonly line: number;\n /** Offset in the module's source of the `(` opening the parameters: the declaration's identity. */\n readonly offset: number;\n}\n\n/** A problem with a spec, located in the spec file (or the module when `inModule`). */\nexport interface SpecError {\n readonly line: number;\n readonly message: string;\n readonly inModule?: true;\n}\n\n/** Every spec of one module, and what did not read. */\nexport interface ModuleSpecs {\n readonly functions: readonly FunctionSpec[];\n readonly errors: readonly SpecError[];\n}\n\n/** A type, for messages. */\nexport function describeType(t: SpecType): string {\n switch (t.kind) {\n case \"number\":\n case \"boolean\":\n case \"string\":\n case \"bigint\":\n case \"null\":\n case \"undefined\":\n return t.kind;\n case \"literal\":\n return typeof t.value === \"string\" ? JSON.stringify(t.value) : String(t.value);\n case \"record\":\n return (\n t.name ?? `{ ${t.fields.map((f) => `${f.name}: ${describeType(f.type)}`).join(\"; \")} }`\n );\n case \"union\":\n return t.members.map(describeType).join(\" | \");\n case \"array\":\n return t.element.kind === \"union\"\n ? `(${describeType(t.element)})[]`\n : `${describeType(t.element)}[]`;\n case \"unknown\":\n return t.text;\n }\n}\n","/**\n * Strings that match a regular expression, drawn with core's seeded\n * generator: the pattern is parsed into alternatives, sequences, classes\n * and quantified terms, and each draw walks that tree. The subset is what\n * guards use: literals, escapes, classes with ranges and negation, groups,\n * alternation, the usual quantifiers and anchors. Lookaround,\n * backreferences and Unicode property escapes are refused with\n * `UnsupportedRegex`, and the caller falls back to sampling. Every draw is\n * checked against the real `RegExp` by the caller, so a gap here can only\n * cost a draw, never admit a value outside the guard.\n */\n\nimport { nextInt, type PrngState } from \"@eutaxy/core\";\n\nexport class UnsupportedRegex extends Error {}\n\ntype Node =\n | { readonly kind: \"alt\"; readonly options: readonly Node[] }\n | { readonly kind: \"seq\"; readonly items: readonly Node[] }\n | { readonly kind: \"repeat\"; readonly item: Node; readonly min: number; readonly max: number }\n | { readonly kind: \"class\"; readonly pool: readonly string[] }\n | { readonly kind: \"literal\"; readonly text: string }\n | { readonly kind: \"empty\" };\n\nconst digits = [...\"0123456789\"];\nconst word = [...\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_\"];\nconst space = [...\" \\t\\n\\r\\f\\v\"];\n/** What `.` and negated classes draw from: printable ASCII, a few others, no newline. */\nconst anyChar = [\n ...\" !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~üß日\",\n];\n\n/** A plentiful count for an unbounded quantifier: keeps drawn strings short. */\nconst unboundedExtra = 4;\n/** The most a counted quantifier may ask for; a guard wanting more is left to sampling. */\nconst maxRepeat = 1000;\n/** The longest string one draw may build before it is given up. */\nconst maxLength = 10_000;\n/** The most nodes one draw may visit: nested repetitions of empty matches multiply work without length. */\nconst maxSteps = 100_000;\n\n/** A class node over the characters it can draw; negation is resolved here, once. */\nfunction classNode(chars: readonly string[], negated: boolean): Node {\n const pool = negated ? anyChar.filter((c) => !chars.includes(c)) : chars;\n if (pool.length === 0) throw new UnsupportedRegex(\"an empty class matches nothing\");\n return { kind: \"class\", pool };\n}\n\nclass Parser {\n private at = 0;\n private readonly src: string;\n private readonly dotAll: boolean;\n private readonly unicode: boolean;\n constructor(src: string, flags: string) {\n this.src = src;\n this.dotAll = flags.includes(\"s\");\n this.unicode = flags.includes(\"u\");\n }\n\n parse(): Node {\n const node = this.alternation();\n if (this.at < this.src.length) throw new UnsupportedRegex(`unexpected ${this.src[this.at]}`);\n return node;\n }\n\n private peek(): string | undefined {\n return this.src[this.at];\n }\n\n private take(): string {\n const c = this.src[this.at++];\n if (c === undefined) throw new UnsupportedRegex(\"pattern ends early\");\n return c;\n }\n\n private alternation(): Node {\n const options = [this.sequence()];\n while (this.peek() === \"|\") {\n this.at++;\n options.push(this.sequence());\n }\n return options.length === 1 ? (options[0] as Node) : { kind: \"alt\", options };\n }\n\n private sequence(): Node {\n const items: Node[] = [];\n while (this.at < this.src.length && this.peek() !== \"|\" && this.peek() !== \")\") {\n const atom = this.atom();\n items.push(this.quantified(atom));\n }\n return items.length === 1 ? (items[0] as Node) : { kind: \"seq\", items };\n }\n\n private quantified(atom: Node): Node {\n const c = this.peek();\n let min: number;\n let max: number;\n if (c === \"*\") [min, max] = [0, unboundedExtra];\n else if (c === \"+\") [min, max] = [1, 1 + unboundedExtra];\n else if (c === \"?\") [min, max] = [0, 1];\n else if (c === \"{\") {\n const m = /^\\{(\\d+)(,(\\d*))?\\}/.exec(this.src.slice(this.at));\n if (!m) return atom; // a literal brace\n min = Number(m[1]);\n max =\n m[2] === undefined\n ? min\n : m[3] === \"\" || m[3] === undefined\n ? min + unboundedExtra\n : Number(m[3]);\n if (max < min) throw new UnsupportedRegex(`quantifier {${min},${max}} is empty`);\n if (max > maxRepeat)\n throw new UnsupportedRegex(`quantifier {${min},${max}} repeats too much to draw`);\n this.at += m[0].length - 1;\n } else return atom;\n this.at++;\n if (this.peek() === \"?\") this.at++; // lazy: same language\n return { kind: \"repeat\", item: atom, min, max };\n }\n\n private atom(): Node {\n const c = this.take();\n switch (c) {\n case \"(\": {\n if (this.src.startsWith(\"?:\", this.at)) this.at += 2;\n else if (\n this.src.startsWith(\"?<\", this.at) &&\n !\"=!\".includes(this.src[this.at + 2] ?? \"\")\n ) {\n const close = this.src.indexOf(\">\", this.at);\n if (close < 0) throw new UnsupportedRegex(\"unterminated group name\");\n this.at = close + 1;\n } else if (this.peek() === \"?\") throw new UnsupportedRegex(\"lookaround or modifier group\");\n const inner = this.alternation();\n if (this.take() !== \")\") throw new UnsupportedRegex(\"unbalanced parenthesis\");\n return inner;\n }\n case \"[\":\n return this.charClass();\n case \".\":\n return classNode(this.dotAll ? [...anyChar, \"\\n\"] : anyChar, false);\n case \"^\":\n case \"$\":\n return { kind: \"empty\" };\n case \"\\\\\":\n return this.escape(false);\n case \")\":\n case \"|\":\n case \"*\":\n case \"+\":\n case \"?\":\n throw new UnsupportedRegex(`unexpected ${c}`);\n default:\n return { kind: \"literal\", text: c };\n }\n }\n\n /** An escape after `\\`; inside a class, `\\b` is a backspace. */\n private escape(inClass: boolean): Node {\n const e = this.take();\n switch (e) {\n case \"d\":\n return classNode(digits, false);\n case \"D\":\n return classNode(digits, true);\n case \"w\":\n return classNode(word, false);\n case \"W\":\n return classNode(word, true);\n case \"s\":\n return classNode(space, false);\n case \"S\":\n return classNode(space, true);\n case \"n\":\n return { kind: \"literal\", text: \"\\n\" };\n case \"t\":\n return { kind: \"literal\", text: \"\\t\" };\n case \"r\":\n return { kind: \"literal\", text: \"\\r\" };\n case \"f\":\n return { kind: \"literal\", text: \"\\f\" };\n case \"v\":\n return { kind: \"literal\", text: \"\\v\" };\n case \"0\":\n return { kind: \"literal\", text: \"\\0\" };\n case \"b\":\n if (inClass) return { kind: \"literal\", text: \"\\b\" };\n return { kind: \"empty\" };\n case \"B\":\n return { kind: \"empty\" };\n case \"x\": {\n const hex = this.src.slice(this.at, this.at + 2);\n if (!/^[0-9a-fA-F]{2}$/.test(hex)) throw new UnsupportedRegex(\"bad \\\\x escape\");\n this.at += 2;\n return { kind: \"literal\", text: String.fromCharCode(Number.parseInt(hex, 16)) };\n }\n case \"u\": {\n if (this.peek() === \"{\") {\n // Without the u flag, \\u{43} is the letter u 43 times.\n if (!this.unicode) throw new UnsupportedRegex(\"\\\\u{} without the u flag\");\n const close = this.src.indexOf(\"}\", this.at);\n const hex = this.src.slice(this.at + 1, close);\n if (close < 0 || !/^[0-9a-fA-F]{1,6}$/.test(hex))\n throw new UnsupportedRegex(\"bad \\\\u escape\");\n this.at = close + 1;\n return { kind: \"literal\", text: String.fromCodePoint(Number.parseInt(hex, 16)) };\n }\n const hex = this.src.slice(this.at, this.at + 4);\n if (!/^[0-9a-fA-F]{4}$/.test(hex)) throw new UnsupportedRegex(\"bad \\\\u escape\");\n this.at += 4;\n return { kind: \"literal\", text: String.fromCharCode(Number.parseInt(hex, 16)) };\n }\n case \"p\":\n case \"P\":\n case \"k\":\n case \"c\":\n throw new UnsupportedRegex(`\\\\${e} escapes`);\n default:\n if (/[1-9]/.test(e)) throw new UnsupportedRegex(\"backreferences\");\n return { kind: \"literal\", text: e };\n }\n }\n\n /** `[...]` after its opening bracket. `[]` is empty and `[]a]` is an empty class then `a]`, as in JavaScript. */\n private charClass(): Node {\n let negated = false;\n if (this.peek() === \"^\") {\n negated = true;\n this.at++;\n }\n const chars = new Set<string>();\n while (this.peek() !== \"]\") {\n const c = this.take();\n let member: string;\n if (c === \"\\\\\") {\n const node = this.escape(true);\n if (node.kind === \"class\") {\n // \\d inside a class adds its members; \\D its complement, already resolved over anyChar.\n for (const x of node.pool) chars.add(x);\n continue;\n }\n if (node.kind !== \"literal\") throw new UnsupportedRegex(\"escape in class\");\n member = node.text;\n } else member = c;\n if (\n this.peek() === \"-\" &&\n this.src[this.at + 1] !== \"]\" &&\n this.src[this.at + 1] !== undefined\n ) {\n this.at++;\n const to =\n this.take() === \"\\\\\"\n ? this.escape(true)\n : { kind: \"literal\" as const, text: this.src[this.at - 1] as string };\n if (to.kind !== \"literal\") throw new UnsupportedRegex(\"range to a class\");\n const lo = member.codePointAt(0) as number;\n const hi = to.text.codePointAt(0) as number;\n if (hi < lo) throw new UnsupportedRegex(\"range out of order\");\n if (hi - lo > 0x2000) throw new UnsupportedRegex(\"range too wide to enumerate\");\n for (let p = lo; p <= hi; p++) chars.add(String.fromCodePoint(p));\n continue;\n }\n chars.add(member);\n }\n this.at++;\n return classNode([...chars], negated);\n }\n}\n\n/** The pattern as a tree, or `UnsupportedRegex`. */\nexport function parseRegex(pattern: string, flags: string): Node {\n if (flags.includes(\"v\")) throw new UnsupportedRegex(\"the v flag\");\n return new Parser(pattern, flags).parse();\n}\n\n/** One string from the tree, with the state that follows. */\nexport function drawRegex(node: Node, state: PrngState): readonly [string, PrngState] {\n let s = state;\n let steps = 0;\n const go = (n: Node): string => {\n if (++steps > maxSteps) throw new UnsupportedRegex(\"a draw visited more than 100000 nodes\");\n switch (n.kind) {\n case \"empty\":\n return \"\";\n case \"literal\":\n return n.text;\n case \"alt\": {\n const [i, next] = nextInt(s, n.options.length);\n s = next;\n return go(n.options[i] as Node);\n }\n case \"seq\":\n return n.items.map(go).join(\"\");\n case \"repeat\": {\n const [extra, next] = nextInt(s, n.max - n.min + 1);\n s = next;\n let out = \"\";\n for (let i = 0; i < n.min + extra; i++) {\n out += go(n.item);\n if (out.length > maxLength)\n throw new UnsupportedRegex(\"a draw grew past 10000 characters\");\n }\n return out;\n }\n case \"class\": {\n const [i, next] = nextInt(s, n.pool.length);\n s = next;\n return n.pool[i] as string;\n }\n }\n };\n return [go(node), s];\n}\n","/**\n * A value as a JavaScript literal: exact for the primitive types (bigints\n * included, `-0` and `NaN` kept), records and arrays spelled as literals,\n * so a counterexample reads back as what it was. Never truncated and never\n * throwing: the rungs key distinct inputs by it, so two values must render\n * alike only when they are alike.\n */\nexport function render(value: unknown): string {\n return renderAt(value, new Set());\n}\n\nfunction renderAt(value: unknown, seen: Set<object>): string {\n switch (typeof value) {\n case \"bigint\":\n return `${value}n`;\n case \"number\":\n return Object.is(value, -0) ? \"-0\" : String(value);\n case \"string\":\n return JSON.stringify(value);\n case \"undefined\":\n return \"undefined\";\n case \"boolean\":\n return String(value);\n case \"function\":\n return \"[function]\";\n case \"symbol\":\n return String(value);\n }\n if (value === null) return \"null\";\n const o = value as object;\n if (seen.has(o)) return \"<cycle>\";\n seen.add(o);\n try {\n if (Array.isArray(o)) return `[${o.map((x) => renderAt(x, seen)).join(\", \")}]`;\n if (o instanceof Date)\n return Number.isNaN(o.getTime()) ? \"Date(NaN)\" : `Date(${JSON.stringify(o.toISOString())})`;\n if (o instanceof Map)\n return `Map([${[...o].map(([k, v]) => `[${renderAt(k, seen)}, ${renderAt(v, seen)}]`).join(\", \")}])`;\n if (o instanceof Set) return `Set([${[...o].map((x) => renderAt(x, seen)).join(\", \")}])`;\n const entries = Object.entries(o).map(\n ([k, v]) =>\n `${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(k) ? k : JSON.stringify(k)}: ${renderAt(v, seen)}`,\n );\n return entries.length === 0 ? \"{}\" : `{ ${entries.join(\", \")} }`;\n } catch {\n // A throwing getter or an exotic object: something, never a throw out of a verdict.\n try {\n return `<${String(o)}>`;\n } catch {\n return \"<unrenderable>\";\n }\n } finally {\n seen.delete(o);\n }\n}\n\n/** Whether two values render alike: structural equality that tells `1n` from `1` and `-0` from `0`. */\nexport function same(a: unknown, b: unknown): boolean {\n return typeof a === typeof b && render(a) === render(b);\n}\n\n/**\n * A deep copy of plain data: arrays and records (plain objects); anything\n * else (a Date the simulator passed, a class instance) is kept as it is.\n * Each evaluation of a property gets its own, so code under test that\n * mutates an input (`xs.sort()`) changes neither the printed counterexample\n * nor the candidates built from it, and no two places in an input share an\n * object, as their printed literals do not.\n */\nexport function copy<T>(v: T): T {\n if (Array.isArray(v)) return v.map(copy) as T;\n if (v !== null && typeof v === \"object\") {\n const proto = Object.getPrototypeOf(v);\n if (proto !== Object.prototype && proto !== null) return v;\n return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, copy(x)])) as T;\n }\n return v;\n}\n","/**\n * Inputs for the `TESTED` rung: values drawn from a binder's type, steered\n * by what the precondition says about it, with core's seeded generator;\n * and the smaller values a shrinker tries in place of one that broke a\n * property. Everything here is pure: the same state draws the same value,\n * so a `TESTED` verdict and its counterexample come out the same on every\n * machine.\n */\n\nimport { nextFloat, nextInt, nextU32, type PrngState } from \"@eutaxy/core\";\nimport { type Binder, describeType, type Endpoint, type Hint, type SpecType } from \"@eutaxy/spec\";\nimport { drawRegex, parseRegex, UnsupportedRegex } from \"./regex-gen.ts\";\nimport { copy, render, same } from \"./render.ts\";\n\n/** A value and the state that follows drawing it. */\nexport type Draw<T> = readonly [T, PrngState];\n\n/** Thrown when no value could be drawn: `unsupported` for a type the rung cannot draw, `gave_up` for a range nothing lies in. */\nexport class CannotGenerate extends Error {\n readonly why: \"unsupported\" | \"gave_up\";\n constructor(why: \"unsupported\" | \"gave_up\", message: string) {\n super(message);\n this.why = why;\n }\n}\n\n/** Integers are drawn as doubles, so they stay exact. */\nconst safe = 2n ** 53n - 1n;\n\n/** How far an unguarded side of a bigint range reaches. */\nconst bigintReach = 1n << 128n;\n\n/** A finite endpoint's value as a double. */\nexport function endpointNumber(value: string): number {\n return Number(value.replace(/_/g, \"\").replace(/n$/, \"\"));\n}\n\n/**\n * The integers a bound admits, as the bound itself: `n < 5` admits up to 4,\n * `n <= 5` up to 5, `n < 4.5` up to 4; `0 < n` from 1, `-0.5 <= n` from 0.\n */\nexport function integerBound(e: Endpoint, side: \"lower\" | \"upper\"): bigint | undefined {\n const text = e.value.replace(/_/g, \"\").replace(/n$/, \"\");\n if (/[.eE]/.test(text)) {\n const n = Number(text);\n // A literal past every double (`1e400`) bounds nothing an integer can reach.\n if (!Number.isFinite(n)) return undefined;\n if (!Number.isInteger(n)) return BigInt(side === \"lower\" ? Math.ceil(n) : Math.floor(n));\n return BigInt(n) + (e.inclusive ? 0n : side === \"lower\" ? 1n : -1n);\n }\n return BigInt(text) + (e.inclusive ? 0n : side === \"lower\" ? 1n : -1n);\n}\n\n/** A finite integral endpoint's value, exact: underscores and the `n` suffix dropped. */\nexport function endpointBigInt(value: string): bigint {\n return BigInt(value.replace(/_/g, \"\").replace(/n$/, \"\"));\n}\n\n/**\n * The closed integer interval a hint admits: within what a double holds\n * exactly for `number`; for `bigint`, the hint's ends, an unhinted side\n * reaching 2^128 past the other. Undefined when no integer lies in it.\n */\nfunction integerRange(\n kind: \"number\" | \"bigint\",\n hint: Hint | undefined,\n): { readonly lo: bigint; readonly hi: bigint } | undefined {\n const guardLo = hint?.lower === undefined ? undefined : integerBound(hint.lower, \"lower\");\n const guardHi = hint?.upper === undefined ? undefined : integerBound(hint.upper, \"upper\");\n let lo: bigint;\n let hi: bigint;\n if (kind === \"bigint\") {\n lo =\n guardLo ?? (guardHi === undefined ? -bigintReach : min(-bigintReach, guardHi - bigintReach));\n hi = guardHi ?? (guardLo === undefined ? bigintReach : max(bigintReach, guardLo + bigintReach));\n } else {\n lo = max(-safe, guardLo ?? -safe);\n hi = min(safe, guardHi ?? safe);\n }\n return lo <= hi ? { lo, hi } : undefined;\n}\n\nconst max = (a: bigint, b: bigint) => (a > b ? a : b);\nconst min = (a: bigint, b: bigint) => (a < b ? a : b);\n\n/** Uniform in [lo, hi], however wide: enough 32-bit words, masked, rejected when past the span. */\nexport function uniformBigInt(lo: bigint, hi: bigint, state: PrngState): Draw<bigint> {\n const span = hi - lo + 1n;\n if (span <= 0n) throw new RangeError(`empty integer interval [${lo}, ${hi}]`);\n if (span === 1n) return [lo, state];\n let bits = 0;\n for (let x = span - 1n; x > 0n; x >>= 1n) bits++;\n const words = Math.ceil(bits / 32);\n const mask = (1n << BigInt(bits)) - 1n;\n let s = state;\n for (;;) {\n let r = 0n;\n for (let i = 0; i < words; i++) {\n const [u, next] = nextU32(s);\n s = next;\n r = (r << 32n) | BigInt(u);\n }\n r &= mask;\n if (r < span) return [lo + r, s];\n }\n}\n\n/** One of a list, uniformly. */\nfunction pick<T>(items: readonly T[], state: PrngState): Draw<T> {\n const [i, s] = nextInt(state, items.length);\n return [items[i] as T, s];\n}\n\n/**\n * An integer from the range, biased: most draws are small, since\n * properties fail at boundaries and small cases far more often than deep in\n * the range, some are medium or large, and a few are the range's edges.\n */\n/** An integer range's edges, as the random draws pick from them (repeats kept, so draws stay as they were). */\nfunction integerEdgeCandidates(lo: bigint, hi: bigint): bigint[] {\n return [lo, hi, 0n, 1n, -1n, lo + 1n, hi - 1n].filter((v) => v >= lo && v <= hi);\n}\n\nfunction drawInteger(\n name: string,\n kind: \"number\" | \"bigint\",\n hint: Hint | undefined,\n state: PrngState,\n): Draw<bigint> {\n const range = integerRange(kind, hint);\n if (!range)\n throw new CannotGenerate(\n \"gave_up\",\n kind === \"bigint\"\n ? `no integer lies inside the precondition's bounds on ${name}`\n : `no integer lies inside the precondition's bounds on ${name} within ±2^53, which is as far as draws of number go`,\n );\n const { lo, hi } = range;\n const [cls, s] = nextInt(state, 100);\n const within = (a: bigint, z: bigint): [bigint, bigint] | undefined => {\n const l = max(lo, a);\n const h = min(hi, z);\n return l <= h ? [l, h] : undefined;\n };\n if (cls < 5) return pick(integerEdgeCandidates(lo, hi), s);\n const bound =\n cls < 55\n ? within(-16n, 16n)\n : cls < 80\n ? within(-(1n << 16n), 1n << 16n)\n : cls < 95\n ? within(-(1n << 31n), 1n << 31n)\n : undefined;\n const [l, h] = bound ?? [lo, hi];\n return uniformBigInt(l, h, s);\n}\n\n/** The double interval a hint admits. */\nfunction numberRange(hint: Hint | undefined): {\n readonly lo: number;\n readonly hi: number;\n readonly guarded: boolean;\n} {\n const lo =\n hint?.lower === undefined ? Number.NEGATIVE_INFINITY : endpointNumber(hint.lower.value);\n const hi =\n hint?.upper === undefined ? Number.POSITIVE_INFINITY : endpointNumber(hint.upper.value);\n return { lo, hi, guarded: hint?.lower !== undefined || hint?.upper !== undefined };\n}\n\n/** Whether a double satisfies the hint's bounds (NaN satisfies none). */\nfunction withinNumberHint(hint: Hint | undefined, v: number): boolean {\n if (!hint) return true;\n if (hint.integer && !Number.isInteger(v)) return false;\n if (hint.lower) {\n const lo = endpointNumber(hint.lower.value);\n if (!(hint.lower.inclusive ? v >= lo : v > lo)) return false;\n }\n if (hint.upper) {\n const hi = endpointNumber(hint.upper.value);\n if (!(hint.upper.inclusive ? v <= hi : v < hi)) return false;\n }\n return true;\n}\n\n/** A double hint's edges, as the random draws pick from them. */\nfunction doubleEdgeCandidates(hint: Hint | undefined): number[] {\n const { lo, hi, guarded } = numberRange(hint);\n return [\n 0,\n -0,\n 1,\n -1,\n 0.5,\n Number.MIN_VALUE,\n Number.EPSILON,\n Number.MAX_VALUE,\n -Number.MAX_VALUE,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ...(guarded ? [lo, hi] : [Number.NaN]),\n ].filter((v) => withinNumberHint(hint, v));\n}\n\nfunction drawNumber(hint: Hint | undefined, state: PrngState): Draw<number> {\n const { lo, hi } = numberRange(hint);\n const [cls, s0] = nextInt(state, 100);\n if (cls < 8) {\n const edges = doubleEdgeCandidates(hint);\n if (edges.length > 0) return pick(edges, s0);\n }\n if (cls < 35) {\n const [k, s1] = nextInt(s0, 33);\n return [k - 16, s1];\n }\n if (cls < 60) {\n const [d, s1] = pick([2, 4, 8, 10, 100], s0);\n const [k, s2] = nextInt(s1, 65);\n return [(k - 32) / d, s2];\n }\n if (cls < 80 && Number.isFinite(lo) && Number.isFinite(hi)) {\n const [f, s1] = nextFloat(s0);\n return [lo + f * (hi - lo), s1];\n }\n // Any magnitude a double holds: a random mantissa at a random binary exponent, either sign.\n const [f, s1] = nextFloat(s0);\n const [e, s2] = nextInt(s1, 2100);\n const [neg, s3] = nextInt(s2, 2);\n return [(neg ? -1 : 1) * (1 + f) * 2 ** (e - 1074), s3];\n}\n\nconst letters = \"abcdefghijklmnopqrstuvwxyz\";\nconst digits = \"0123456789\";\nconst plainAlphabet = [...`${letters}${letters.toUpperCase()}${digits} _-.,:/\\n'\"üß日😀`];\nconst stringEdges = [\"\", \" \", \"a\", \"0\", \"-1\", \"\\n\", \"\\u0000\", \"ü\", \"😀\", \"a\".repeat(100)];\n/** The longest string sampled over a regex's own characters, and the longest edge a regex is tried on. */\nconst regexSampleLength = 12;\n\n/**\n * The characters a regex names: literals, the ranges and escapes of its\n * classes. Strings drawn from them match the pattern far more often than\n * strings drawn from everything, which is what the rejection below needs.\n */\nexport function regexAlphabet(pattern: string): string[] {\n const chars = new Set<string>();\n const add = (s: string) => {\n for (const c of s) chars.add(c);\n };\n for (let i = 0; i < pattern.length; i++) {\n const c = pattern[i] as string;\n if (c === \"\\\\\") {\n const e = pattern[++i];\n if (e === \"d\") add(digits);\n else if (e === \"w\") add(`${letters}${letters.toUpperCase()}${digits}_`);\n else if (e === \"s\") add(\" \");\n else if (e === \"n\") add(\"\\n\");\n else if (e === \"t\") add(\"\\t\");\n else if (e !== undefined && !/[DWSbBuxpP]/.test(e)) add(e);\n continue;\n }\n if (pattern[i + 1] === \"-\" && i + 2 < pattern.length && pattern[i + 2] !== \"]\") {\n const from = c.codePointAt(0) as number;\n const to = (pattern[i + 2] as string).codePointAt(0) as number;\n if (from < to && to - from <= 0x1000)\n for (let p = from; p <= to; p++) chars.add(String.fromCodePoint(p));\n i += 2;\n continue;\n }\n if (!\"^$()[]{}|*+?.-\".includes(c)) chars.add(c);\n }\n return [...chars];\n}\n\n/** A string of `length` characters from `alphabet`. */\nfunction drawChars(alphabet: readonly string[], length: number, state: PrngState): Draw<string> {\n let s = state;\n let out = \"\";\n for (let i = 0; i < length; i++) {\n const [c, next] = pick(alphabet, s);\n s = next;\n out += c;\n }\n return [out, s];\n}\n\n/** Whether a string passes the hint's regex (the real RegExp has the last word). */\nfunction matchesRegex(hint: Hint | undefined, v: string): boolean {\n return hint?.regex === undefined || new RegExp(hint.regex.pattern, hint.regex.flags).test(v);\n}\n\nfunction drawString(hint: Hint | undefined, state: PrngState): Draw<string> {\n const g = hint?.regex;\n if (!g) {\n const [cls, s0] = nextInt(state, 100);\n if (cls < 15) return pick(stringEdges, s0);\n const [length, s1] = nextInt(s0, 25);\n return drawChars(plainAlphabet, length, s1);\n }\n let s = state;\n // Walk the pattern when it is in the understood subset; the real RegExp has the last word.\n let tree: ReturnType<typeof parseRegex> | undefined;\n try {\n tree = parseRegex(g.pattern, g.flags);\n } catch (err) {\n if (!(err instanceof UnsupportedRegex)) throw err;\n }\n for (let attempt = 0; tree && attempt < 16; attempt++) {\n try {\n const [candidate, s1] = drawRegex(tree, s);\n s = s1;\n if (matchesRegex(hint, candidate)) return [candidate, s];\n } catch (err) {\n if (!(err instanceof UnsupportedRegex)) throw err;\n break;\n }\n }\n // Otherwise sample strings over the pattern's own characters and keep what matches.\n const fromPattern = regexAlphabet(g.pattern);\n const alphabet = fromPattern.length > 0 ? fromPattern : plainAlphabet;\n for (let attempt = 0; attempt < 64; attempt++) {\n const [length, s1] = nextInt(s, regexSampleLength + 1);\n const [candidate, s2] = drawChars(alphabet, length, s1);\n s = s2;\n if (matchesRegex(hint, candidate)) return [candidate, s];\n }\n throw new CannotGenerate(\n \"gave_up\",\n `no string matching /${g.pattern}/${g.flags} was found in 64 draws over its characters`,\n );\n}\n\n/** The most shrink candidates one array offers at a step; the shrinker evaluates 500 in all. */\nconst shrinkCandidateLimit = 256;\n\n/** The most edges a record type has; random draws cover its other combinations. */\nconst recordEdgeLimit = 64;\n\n/** Without repeats, in one pass, as `same` compares: 0 and -0 stay apart, two empty arrays do not. */\nfunction distinct<T>(values: readonly T[]): T[] {\n const seen = new Set<string>();\n return values.filter((v) => {\n const key = `${typeof v}:${render(v)}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\nfunction integerEdges(kind: \"number\" | \"bigint\", hint: Hint | undefined): bigint[] {\n const range = integerRange(kind, hint);\n return range ? distinct(integerEdgeCandidates(range.lo, range.hi)) : [];\n}\n\n/**\n * How many combinations of these edge lists to take side by side: the\n * longest list's length, twice over when there are two or more lists,\n * since `combined` walks them once in step (equal edges meet, as\n * `Infinity - Infinity` needs) and once rotated (list `k` starting `k`\n * places in, so lists of one type also differ).\n */\nfunction combinations(lists: readonly (readonly unknown[])[]): number {\n const longest = Math.max(0, ...lists.map((l) => l.length));\n return lists.length > 1 ? 2 * longest : longest;\n}\n\n/** List `k`'s value in the `i`-th combination. */\nfunction combined<T>(lists: readonly (readonly T[])[], k: number, i: number): T {\n const longest = Math.max(...lists.map((l) => l.length));\n const own = lists[k] as readonly T[];\n const offset = i < longest ? 0 : k;\n return own[((i % longest) + offset) % own.length] as T;\n}\n\n/**\n * The values of a type, within the hint, that properties fail on far more\n * often than elsewhere: the bounds, zero and one, the double specials (NaN,\n * the infinities, -0), the empty string, both booleans, every member of a\n * union, and records built field by field from those. The `TESTED` rung\n * tries every one before any random draw, so a claim false on one value\n * is found under every seed; a claim false only on a combination of edges\n * across binders or fields is found where the rotation below pairs them,\n * and otherwise rests on the random draws. A type with none (a string\n * whose regex no edge matches) gives none.\n */\nexport function edgesOf(type: SpecType, hint: Hint | undefined): unknown[] {\n switch (type.kind) {\n case \"boolean\":\n return [false, true];\n case \"number\": {\n // Number.isInteger(-0) holds, so -0 is an integer edge wherever 0 is one.\n if (hint?.integer)\n return integerEdges(\"number\", hint).flatMap((v) => (v === 0n ? [0, -0] : [Number(v)]));\n return distinct(doubleEdgeCandidates(hint));\n }\n case \"bigint\":\n return integerEdges(\"bigint\", hint);\n case \"string\":\n // A regex is tried only on edges as short as the strings sampled over its characters: a\n // backtracking pattern on the 100-character edge could run for longer than the check.\n return stringEdges.filter(\n (v) =>\n hint?.regex === undefined || (v.length <= regexSampleLength && matchesRegex(hint, v)),\n );\n case \"literal\":\n return [type.value];\n case \"null\":\n return [null];\n case \"undefined\":\n return [undefined];\n case \"union\":\n return distinct(type.members.flatMap((m) => edgesOf(m, undefined)));\n case \"record\": {\n // Distinct records only, and at most recordEdgeLimit of them: nested records multiply their\n // fields' edges, and a record's edges must not grow with its depth.\n const lists = type.fields.map((f) => edgesOf(f.type, undefined));\n if (lists.some((l) => l.length === 0)) return [];\n const out: Record<string, unknown>[] = [];\n const seen = new Set<string>();\n for (let i = 0; i < Math.max(1, combinations(lists)) && out.length < recordEdgeLimit; i++) {\n const r = Object.fromEntries(type.fields.map((f, k) => [f.name, combined(lists, k, i)]));\n const key = render(r);\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(r);\n }\n return out;\n }\n case \"array\": {\n // Empty, one of each element edge, and one element twice: claims about arrays break on the\n // empty one and on repeats far more often than elsewhere.\n if (!drawable(type.element)) return [];\n const element = edgesOf(type.element, undefined);\n return [\n [],\n ...element.map((e) => [e]),\n ...(element.length > 0 ? [[element[0], element[0]]] : []),\n ];\n }\n case \"unknown\":\n return [];\n }\n}\n\n/** Each binder's edges, computed once for a property's whole edge phase. */\nexport function edgeLists(binders: readonly Binder[]): unknown[][] {\n return binders.map((b) => edgesOf(b.type, b.hint));\n}\n\n/** How many edge assignments the binders' `edgeLists` give. */\nexport function edgeAssignmentCount(edges: readonly (readonly unknown[])[]): number {\n return combinations(edges);\n}\n\n/**\n * The `i`-th edge assignment from the binders' `edgeLists`: the lists\n * walked once in step and once rotated (binder `j` starting `j` places\n * in), cycling, so each edge of each binder appears, equal edges meet and\n * binders of one type also differ; a binder with no edges is drawn at\n * random. Undefined from `edgeAssignmentCount` on.\n */\nexport function edgeAssignment(\n binders: readonly Binder[],\n edges: readonly (readonly unknown[])[],\n i: number,\n state: PrngState,\n): Draw<unknown[]> | undefined {\n if (i >= combinations(edges)) return undefined;\n const values: unknown[] = [];\n let s = state;\n binders.forEach((b, j) => {\n const own = edges[j] as readonly unknown[];\n if (own.length > 0) {\n values.push(copy(combined(edges, j, i)));\n return;\n }\n const [v, next] = generate(b, s);\n s = next;\n values.push(v);\n });\n return [values, s];\n}\n\n/** Whether every part of the type is one the rung draws (no `unknown` anywhere in it). */\nfunction drawable(type: SpecType): boolean {\n switch (type.kind) {\n case \"unknown\":\n return false;\n case \"array\":\n return drawable(type.element);\n case \"union\":\n return type.members.every(drawable);\n case \"record\":\n return type.fields.every((f) => drawable(f.type));\n default:\n return true;\n }\n}\n\n/** A value of the type, within the hint (which applies to a top-level binder only). */\nexport function generateOf(\n name: string,\n type: SpecType,\n hint: Hint | undefined,\n state: PrngState,\n): Draw<unknown> {\n switch (type.kind) {\n case \"boolean\": {\n const [bit, s] = nextInt(state, 2);\n return [bit === 1, s];\n }\n case \"number\": {\n if (hint?.integer) {\n const [v, s] = drawInteger(name, \"number\", hint, state);\n return [Number(v), s];\n }\n let s = state;\n for (let attempt = 0; attempt < 64; attempt++) {\n const [v, next] = drawNumber(hint, s);\n s = next;\n if (withinNumberHint(hint, v)) return [v, s];\n }\n throw new CannotGenerate(\n \"gave_up\",\n `no number inside the precondition's bounds on ${name} was found in 64 draws`,\n );\n }\n case \"bigint\":\n return drawInteger(name, \"bigint\", hint, state);\n case \"string\":\n return drawString(hint, state);\n case \"literal\":\n return [type.value, state];\n case \"null\":\n return [null, state];\n case \"undefined\":\n return [undefined, state];\n case \"union\": {\n const [member, s] = pick(type.members, state);\n return generateOf(name, member, undefined, s);\n }\n case \"record\": {\n let s = state;\n const out: Record<string, unknown> = {};\n for (const f of type.fields) {\n const [v, next] = generateOf(`${name}.${f.name}`, f.type, undefined, s);\n s = next;\n out[f.name] = v;\n }\n return [out, s];\n }\n case \"array\": {\n // Refused whatever length is drawn, as an unreadable parameter type is: an empty draw must\n // not make an array of something unreadable look testable.\n if (!drawable(type.element))\n throw new CannotGenerate(\n \"unsupported\",\n `${name} has a type the rung cannot draw from: ${describeType(type)}`,\n );\n // Mostly short (up to 4), sometimes up to 16; an element repeats an earlier one a quarter of\n // the time, since a claim keyed on distinct elements breaks on a repeat.\n const [cls, s0] = nextInt(state, 100);\n const [length, s1] = nextInt(s0, cls < 70 ? 5 : 17);\n let s = s1;\n const out: unknown[] = [];\n for (let i = 0; i < length; i++) {\n if (out.length > 0) {\n const [repeat, s2] = nextInt(s, 4);\n s = s2;\n if (repeat === 0) {\n const [v, s3] = pick(out, s);\n s = s3;\n out.push(copy(v));\n continue;\n }\n }\n const [v, next] = generateOf(`${name}[${i}]`, type.element, undefined, s);\n s = next;\n out.push(v);\n }\n return [out, s];\n }\n case \"unknown\":\n throw new CannotGenerate(\n \"unsupported\",\n `${name} has a type the rung cannot draw from: ${describeType(type)}`,\n );\n }\n}\n\n/** A value of the binder's type, within its hint. */\nexport function generate(b: Binder, state: PrngState): Draw<unknown> {\n return generateOf(b.name, b.type, b.hint, state);\n}\n\n/** Whether a binder draws integers (or bigints), which later binders may relate to. */\nfunction integral(b: Binder): boolean {\n return b.type.kind === \"bigint\" || (b.type.kind === \"number\" && b.hint?.integer === true);\n}\n\n/**\n * One assignment to every binder. Each is drawn from its own type and\n * hint; a later integer binder is sometimes made to relate to earlier\n * ones instead, equal to one or the sum or difference of two, since\n * preconditions relate binders (`refunded + amount === captured`) and\n * independent draws would meet such an equation once in thousands. A\n * related value outside the binder's hint is dropped for the draw.\n */\nexport function generateAssignment(binders: readonly Binder[], state: PrngState): Draw<unknown[]> {\n const values: unknown[] = [];\n let s = state;\n for (const b of binders) {\n const [drawn, next] = generate(b, s);\n s = next;\n let v = drawn;\n const earlier = values.filter(\n (x, i) => integral(binders[i] as Binder) && typeof x === typeof drawn,\n );\n if (integral(b) && earlier.length > 0) {\n const [cls, s1] = nextInt(s, 10);\n s = s1;\n if (cls < 3) {\n const [a, s2] = pick(earlier, s1);\n const [c, s3] = pick(earlier, s2);\n s = s3;\n let related: unknown = a;\n if (cls === 1)\n related =\n typeof a === \"bigint\" ? (a as bigint) + (c as bigint) : (a as number) + (c as number);\n if (cls === 2)\n related =\n typeof a === \"bigint\" ? (a as bigint) - (c as bigint) : (a as number) - (c as number);\n if (inDomain(b, related) && (typeof related !== \"number\" || Number.isSafeInteger(related)))\n v = related;\n }\n }\n values.push(v);\n }\n return [values, s];\n}\n\n/** Whether a value is of the type (hints aside). */\nexport function conforms(type: SpecType, v: unknown): boolean {\n switch (type.kind) {\n case \"number\":\n return typeof v === \"number\";\n case \"boolean\":\n return typeof v === \"boolean\";\n case \"string\":\n return typeof v === \"string\";\n case \"bigint\":\n return typeof v === \"bigint\";\n case \"literal\":\n // `===`: -0 is of the literal type 0, as TypeScript has it.\n return v === type.value;\n case \"null\":\n return v === null;\n case \"undefined\":\n return v === undefined;\n case \"union\":\n return type.members.some((m) => conforms(m, v));\n case \"record\":\n return (\n typeof v === \"object\" &&\n v !== null &&\n type.fields.every((f) => conforms(f.type, (v as Record<string, unknown>)[f.name]))\n );\n case \"array\":\n // A sparse array is outside: JavaScript's array methods skip its holes, a list has none.\n if (!Array.isArray(v)) return false;\n for (let i = 0; i < v.length; i++)\n if (!(i in v) || !conforms(type.element, v[i])) return false;\n return true;\n case \"unknown\":\n return true;\n }\n}\n\n/** Whether a top-level value is of the binder's type and within its hint. */\nexport function inDomain(b: Binder, v: unknown): boolean {\n if (!conforms(b.type, v)) return false;\n const h = b.hint;\n if (!h) return true;\n if (typeof v === \"number\") return withinNumberHint(h, v);\n if (typeof v === \"bigint\") {\n const lo = h.lower && integerBound(h.lower, \"lower\");\n const hi = h.upper && integerBound(h.upper, \"upper\");\n if (lo !== undefined && v < lo) return false;\n if (hi !== undefined && v > hi) return false;\n return true;\n }\n if (typeof v === \"string\") return matchesRegex(h, v);\n return true;\n}\n\n/** The integer nearest to zero in [lo, hi]. */\nfunction nearestZero(lo: bigint, hi: bigint): bigint {\n return lo > 0n ? lo : hi < 0n ? hi : 0n;\n}\n\n/** Steps from `v` toward `target`: the target itself, then the halfway points back toward `v`. */\nfunction towards(v: bigint, target: bigint): bigint[] {\n const out: bigint[] = [];\n if (v === target) return out;\n out.push(target);\n let d = (v - target) / 2n;\n while (d !== 0n) {\n out.push(v - d);\n d /= 2n;\n }\n return out;\n}\n\n/**\n * Smaller values to try in place of `v`, simplest first, all of the type\n * and within the hint, none equal to `v`. Numbers move toward zero (or the\n * bound nearest it), strings get shorter and plainer, `true` becomes\n * `false`, a union moves to its simplest member, a record shrinks one\n * field at a time.\n */\nexport function shrinkCandidates(b: Binder, v: unknown): unknown[] {\n return candidatesOf(b.type, b.hint, v).filter((c) => !Object.is(c, v) && inDomain(b, c));\n}\n\nfunction candidatesOf(type: SpecType, hint: Hint | undefined, v: unknown): unknown[] {\n // Keyed as `same` compares, in one pass: nested arrays give thousands of candidates.\n const dedupe = (xs: unknown[]) => {\n const keys = new Set<string>();\n return xs.filter((x) => {\n const key = `${typeof x}:${render(x)}`;\n if (keys.has(key)) return false;\n keys.add(key);\n return true;\n });\n };\n switch (type.kind) {\n case \"boolean\":\n return [false];\n case \"number\": {\n if (typeof v !== \"number\") return [];\n // -0 is as small as 0 to every comparison, so only the sign is left to shrink.\n if (Object.is(v, -0)) return [0];\n if (hint?.integer || Number.isInteger(v)) {\n const range = integerRange(\"number\", hint);\n if (!Number.isInteger(v) || !range) return [];\n return dedupe(towards(BigInt(v), nearestZero(range.lo, range.hi)).map(Number));\n }\n const { lo, hi } = numberRange(hint);\n const target = lo > 0 ? lo : Math.min(hi, 0);\n if (!Number.isFinite(v)) return [target, 1, -1, Number.MAX_VALUE, -Number.MAX_VALUE];\n const out = [target, Math.trunc(v)];\n let d = (v - target) / 2;\n for (let i = 0; i < 24 && d !== 0; i++) {\n out.push(v - d);\n d /= 2;\n }\n return dedupe(out);\n }\n case \"bigint\": {\n const range = integerRange(\"bigint\", hint);\n if (typeof v !== \"bigint\" || !range) return [];\n return towards(v, nearestZero(range.lo, range.hi));\n }\n case \"string\": {\n if (typeof v !== \"string\") return [];\n const chars = [...v];\n const out: string[] = [\"\", chars.slice(0, Math.floor(chars.length / 2)).join(\"\")];\n out.push(chars.slice(Math.ceil(chars.length / 2)).join(\"\"));\n for (const at of [0, chars.length - 1, Math.floor(chars.length / 2)])\n out.push([...chars.slice(0, at), ...chars.slice(at + 1)].join(\"\"));\n const first = chars.findIndex((c) => c !== \"a\");\n if (first >= 0) out.push([...chars.slice(0, first), \"a\", ...chars.slice(first + 1)].join(\"\"));\n return dedupe(out);\n }\n case \"array\": {\n // Shorter first (empty, then one element dropped), then elements smaller: one at a time, and\n // every copy of a value at once, so a repeat that breaks the claim survives the shrink.\n // At most shrinkCandidateLimit, in that order: nested arrays have more candidates than the\n // shrinker will ever evaluate, and building them all costs seconds.\n if (!Array.isArray(v)) return [];\n const out: unknown[] = v.length > 0 ? [[]] : [];\n for (let i = 0; i < v.length; i++) out.push(v.filter((_, j) => j !== i));\n const keys = v.map((x) => `${typeof x}:${render(x)}`);\n for (let i = 0; i < v.length && out.length < shrinkCandidateLimit; i++) {\n const own = keys[i];\n const repeated = keys.some((k, j) => j !== i && k === own);\n for (const c of candidatesOf(type.element, undefined, v[i])) {\n if (out.length >= shrinkCandidateLimit) break;\n if (`${typeof c}:${render(c)}` === own) continue;\n out.push(v.map((x, j) => (j === i ? c : x)));\n if (repeated) out.push(v.map((x, j) => (keys[j] === own ? copy(c) : x)));\n }\n }\n return dedupe(out).slice(0, shrinkCandidateLimit);\n }\n case \"literal\":\n case \"null\":\n case \"undefined\":\n case \"unknown\":\n return [];\n case \"union\": {\n // The simplest value of each member first (null, false, 0, \"\", the first literal), then within v's own member.\n const simplest = type.members.flatMap((m): unknown[] => {\n switch (m.kind) {\n case \"null\":\n return [null];\n case \"undefined\":\n return [undefined];\n case \"boolean\":\n return [false];\n case \"number\":\n return [0];\n case \"bigint\":\n return [0n];\n case \"string\":\n return [\"\"];\n case \"literal\":\n return [m.value];\n default:\n return [];\n }\n });\n const own = type.members.find((m) => conforms(m, v));\n return dedupe([...simplest, ...(own ? candidatesOf(own, undefined, v) : [])]);\n }\n case \"record\": {\n if (typeof v !== \"object\" || v === null) return [];\n const o = v as Record<string, unknown>;\n const out: unknown[] = [];\n for (const f of type.fields)\n for (const c of candidatesOf(f.type, undefined, o[f.name]))\n if (!same(c, o[f.name])) out.push({ ...o, [f.name]: c });\n return out;\n }\n }\n}\n","/**\n * The `CHECKED` rung: a property evaluated on every input the simulator\n * actually passed to its function. Binders are the function's parameters,\n * so each recorded call is one assignment; one failing the precondition is\n * outside the claim and discarded. One assignment where the claim is false\n * refutes the property. Holding on all of them is `CHECKED`, which says\n * nothing about inputs the simulator never passed.\n */\n\nimport type { Counterexample, SpecVerdict } from \"@eutaxy/core\";\nimport type { Fn, Forall, FunctionSpec, Property } from \"@eutaxy/spec\";\nimport { conforms } from \"./generate.ts\";\nimport { copy, render } from \"./render.ts\";\n\nexport { render } from \"./render.ts\";\n\n/** What evaluating a spec on one assignment came to. */\nexport type PredicateOutcome = \"held\" | \"discarded\" | \"refuted\";\n\nexport type Evaluation =\n | { readonly outcome: \"held\" | \"discarded\" }\n | { readonly outcome: \"refuted\"; readonly error?: string }\n /** The property, not the function, is at fault: it cannot be evaluated at any rung. */\n | { readonly malformed: string };\n\n/**\n * One assignment through a spec. The precondition decides whether the\n * assignment is inside the claim; a precondition that throws or does not\n * answer a boolean is a malformed property, since it cannot tell. The\n * claim then holds, or is false, or throws: a throw from the claim, the\n * function's own included, means the claim is not true there. A claim\n * that returns something other than a boolean is malformed.\n */\nexport function evaluate(\n spec: Forall<Fn>,\n values: readonly unknown[],\n /** For generated inputs: each arrow gets its own copy of their plain data (`copy`). */\n copied = false,\n): Evaluation {\n const fresh = (): never[] => (copied ? copy(values) : values) as never[];\n if (spec.when) {\n let inside: unknown;\n try {\n inside = spec.when(...fresh());\n } catch (err) {\n return { malformed: `the precondition threw ${String(err)}` };\n }\n if (typeof inside !== \"boolean\")\n return { malformed: `the precondition returned ${render(inside)}, not a boolean` };\n if (!inside) return { outcome: \"discarded\" };\n }\n let claim: unknown;\n try {\n claim = spec.ensures(...fresh());\n } catch (err) {\n return { outcome: \"refuted\", error: String(err) };\n }\n if (typeof claim !== \"boolean\")\n return { malformed: `the claim returned ${render(claim)}, not a boolean` };\n return { outcome: claim ? \"held\" : \"refuted\" };\n}\n\n/** How every rung words an `UNKNOWN` for a property that cannot be evaluated; the ladder recognizes it. */\nexport const malformedReason = (detail: string): string =>\n `the property could not be evaluated: ${detail}`;\n\nexport interface CheckedInput {\n readonly module: string;\n readonly fn: FunctionSpec;\n readonly property: Property;\n /** The calls the simulator made, with their arguments. */\n readonly calls: readonly { readonly args: readonly unknown[] }[];\n /** The spec file's export, or undefined when it could not be loaded. */\n readonly spec: Forall<Fn> | undefined;\n /** Why the function's calls could not be observed, when they could not. */\n readonly unobservable?: string;\n}\n\nexport function checkedRung(input: CheckedInput): SpecVerdict {\n const { module, fn, property } = input;\n const base = { module, function: fn.name, property: property.name, text: property.text };\n const unknown = (\n cause: \"gave_up\" | \"unsupported\" | \"unavailable\",\n reason: string,\n ): SpecVerdict => ({ ...base, kind: \"UNKNOWN\", cause, reason, assumptions: [] });\n if (property.kind === \"total\")\n return unknown(\n \"unsupported\",\n \"termination is not observable on the inputs the simulator passed; total needs a prover\",\n );\n if (input.unobservable)\n return unknown(\n \"unavailable\",\n `calls to ${fn.name} could not be observed: ${input.unobservable}`,\n );\n const spec = input.spec;\n if (!spec)\n return unknown(\"unavailable\", `the spec file's export ${property.name} was not loaded`);\n const binders = property.binders;\n const seen = new Set<string>();\n let held = 0;\n let discarded = 0;\n for (const call of input.calls) {\n const values = binders.map((_, i) => call.args[i]);\n const key = values.map(render).join(\", \");\n if (seen.has(key)) continue;\n seen.add(key);\n // The claim quantifies over the parameter types; a call with an argument of another type\n // (a shell passing a string where a number is declared) is outside it, not a counterexample.\n if (!binders.every((b, i) => conforms(b.type, values[i]))) {\n discarded++;\n continue;\n }\n const counterexample = (error?: string): Counterexample => ({\n binders: binders.map((b, i) => ({ name: b.name, value: render(values[i]) })),\n call: `${fn.name}(${call.args.map(render).join(\", \")})`,\n ...(error === undefined ? {} : { error }),\n });\n const result = evaluate(spec, values);\n if (\"malformed\" in result) return unknown(\"unsupported\", malformedReason(result.malformed));\n if (result.outcome === \"refuted\")\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"CHECKED\",\n counterexample: counterexample(result.error),\n assumptions: [],\n };\n if (result.outcome === \"discarded\") discarded++;\n else held++;\n }\n if (held === 0)\n return unknown(\n \"gave_up\",\n input.calls.length === 0\n ? `the simulator never called ${fn.name}`\n : `none of the ${seen.size} distinct input(s) the simulator passed is inside the claim (the precondition)`,\n );\n return {\n ...base,\n kind: \"CHECKED\",\n inputs: held,\n discarded,\n assumptions: [\n `held on the ${held} distinct input(s) the simulator passed to ${fn.name}; inputs it never passed are not covered`,\n ],\n };\n}\n","/**\n * A refuting assignment made as small as the candidates allow, one binder\n * at a time, while the property still fails: what the TESTED rung reports,\n * and what an engine reports after replaying a solver's model.\n */\n\nimport type { Binder, Fn, Forall } from \"@eutaxy/spec\";\nimport { type Evaluation, evaluate } from \"./checked.ts\";\nimport { shrinkCandidates } from \"./generate.ts\";\nimport { copy } from \"./render.ts\";\n\n/** How many evaluations shrinking may spend on one counterexample. */\nconst shrinkBudget = 500;\n\nexport function shrinkRefutation(\n spec: Forall<Fn>,\n binders: readonly Binder[],\n start: readonly unknown[],\n startEvaluation: Evaluation,\n): { readonly values: readonly unknown[]; readonly error?: string } {\n let values = [...start];\n let error: { readonly error?: string } = refutes(startEvaluation) ?? {};\n let spent = 0;\n let progress = true;\n while (progress && spent < shrinkBudget) {\n progress = false;\n for (let i = 0; i < binders.length && spent < shrinkBudget; i++) {\n const b = binders[i] as Binder;\n let moved = true;\n while (moved && spent < shrinkBudget) {\n moved = false;\n for (const candidate of shrinkCandidates(b, values[i])) {\n if (spent >= shrinkBudget) break;\n spent++;\n const trial = values.with(i, candidate);\n // Inside the sample only: it bounds what an evaluation may cost, shrinking included.\n if (spec.sample && !inSample(spec, trial)) continue;\n const still = refutes(evaluate(spec, trial, true));\n if (still === undefined) continue;\n values = trial;\n error = still;\n moved = true;\n progress = true;\n break;\n }\n }\n }\n }\n return error.error === undefined ? { values } : { values, error: error.error };\n}\n\n/** Whether an evaluation still refutes: an object (holding the error text, if any), or undefined. */\nexport function refutes(e: Evaluation): { readonly error?: string } | undefined {\n if (\"malformed\" in e || e.outcome !== \"refuted\") return undefined;\n return \"error\" in e && e.error !== undefined ? { error: e.error } : {};\n}\n\n/** Whether the spec's sample holds of the values (a sample that throws or answers other than true does not). */\nfunction inSample(spec: Forall<Fn>, values: readonly unknown[]): boolean {\n try {\n return spec.sample?.(...(copy(values) as never[])) === true;\n } catch {\n return false;\n }\n}\n","/**\n * The `TESTED` rung: a property evaluated on assignments drawn from its\n * binders' types, steered by the precondition's hints, with a seed, so the\n * same seed draws the same assignments everywhere. An assignment where the\n * claim is false is shrunk toward smaller values that still break it and\n * reported as a counterexample. Holding on every drawn assignment is\n * `TESTED`: evidence from sampling, which says nothing about the inputs\n * never drawn.\n */\n\nimport { type Counterexample, type PrngState, type SpecVerdict, seedPrng } from \"@eutaxy/core\";\nimport type { Fn, Forall, FunctionSpec, Property } from \"@eutaxy/spec\";\nimport { evaluate, malformedReason, render } from \"./checked.ts\";\nimport {\n CannotGenerate,\n edgeAssignment,\n edgeAssignmentCount,\n edgeLists,\n generateAssignment,\n} from \"./generate.ts\";\nimport { copy } from \"./render.ts\";\nimport { shrinkRefutation } from \"./shrink.ts\";\n\nexport interface TestedOptions {\n /** The check's seed; each property derives its own stream from it and its name. */\n readonly seed: string;\n /** Distinct assignments the property must hold on; default 100. Drawing stops after 20 times as many draws, whatever they were. */\n readonly inputs?: number;\n}\n\nexport interface TestedInput extends TestedOptions {\n readonly module: string;\n readonly fn: FunctionSpec;\n readonly property: Property;\n /** The spec file's export, or undefined when it could not be loaded. */\n readonly spec: Forall<Fn> | undefined;\n}\n\nexport function testedRung(input: TestedInput): SpecVerdict {\n const { module, fn, property } = input;\n const base = { module, function: fn.name, property: property.name, text: property.text };\n const unknown = (\n cause: \"gave_up\" | \"unsupported\" | \"unavailable\",\n reason: string,\n ): SpecVerdict => ({ ...base, kind: \"UNKNOWN\", cause, reason, assumptions: [] });\n if (property.kind === \"total\")\n return unknown(\n \"unsupported\",\n \"termination is not observable on generated inputs; total needs a prover\",\n );\n const spec = input.spec;\n if (!spec)\n return unknown(\"unavailable\", `the spec file's export ${property.name} was not loaded`);\n const binders = property.binders;\n const wanted = input.inputs ?? 100;\n if (!Number.isInteger(wanted) || wanted < 1)\n throw new RangeError(`inputs must be a positive integer, got ${String(input.inputs)}`);\n const seed = `${input.seed}:${module}:${fn.name}:${property.name}`;\n let state: PrngState = seedPrng(seed);\n let held = 0;\n let discarded = 0;\n let sampledOut = 0;\n // Distinct assignments only, as the CHECKED rung counts them: two booleans are two inputs, not a hundred.\n const seen = new Set<string>();\n const counterexample = (values: readonly unknown[], error?: string): Counterexample => ({\n binders: binders.map((b, i) => ({ name: b.name, value: render(values[i]) })),\n ...(error === undefined ? {} : { error }),\n });\n // Every edge assignment is tried, however many there are (a union of a hundred literals has a\n // hundred); then random draws until the budget is met, and at least half of it random, so many\n // edges never crowd out the values between them.\n const edges = edgeLists(binders);\n const edgeTotal = edgeAssignmentCount(edges);\n const randomWanted = Math.ceil(wanted / 2);\n let randomHeld = 0;\n for (\n let draws = 0;\n draws < edgeTotal ||\n ((held < wanted || randomHeld < randomWanted) && draws < edgeTotal + wanted * 20);\n draws++\n ) {\n let values: unknown[];\n try {\n // The edges first, every one of them, then random draws.\n [values, state] =\n (draws < edgeTotal ? edgeAssignment(binders, edges, draws, state) : undefined) ??\n generateAssignment(binders, state);\n } catch (err) {\n if (err instanceof CannotGenerate) return unknown(err.why, err.message);\n throw err;\n }\n const key = values.map(render).join(\", \");\n if (seen.has(key)) continue;\n seen.add(key);\n // Outside the sample is not drawn at all: neither inside nor outside the claim, just not tried.\n if (spec.sample) {\n let inSample: unknown;\n try {\n inSample = spec.sample(...(copy(values) as never[]));\n } catch (err) {\n return unknown(\"unsupported\", malformedReason(`the sample threw ${String(err)}`));\n }\n if (typeof inSample !== \"boolean\")\n return unknown(\n \"unsupported\",\n malformedReason(`the sample returned ${render(inSample)}, not a boolean`),\n );\n if (!inSample) {\n sampledOut++;\n continue;\n }\n }\n const result = evaluate(spec, values, true);\n if (\"malformed\" in result) return unknown(\"unsupported\", malformedReason(result.malformed));\n if (result.outcome === \"discarded\") {\n discarded++;\n continue;\n }\n if (result.outcome === \"refuted\") {\n const smallest = shrinkRefutation(spec, binders, values, result);\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"TESTED\",\n counterexample: counterexample(smallest.values, smallest.error),\n assumptions: [`found on an input generated with seed ${input.seed}, then shrunk`],\n };\n }\n held++;\n if (draws >= edgeTotal) randomHeld++;\n }\n if (held === 0)\n return unknown(\n \"gave_up\",\n sampledOut > 0 && discarded === 0\n ? `all ${sampledOut} distinct generated inputs were outside the sample: it admits too few of the parameter types to draw`\n : `all ${discarded + sampledOut} distinct generated inputs were outside the claim or the sample: its precondition admits too few of the parameter types to sample`,\n );\n return {\n ...base,\n kind: \"TESTED\",\n inputs: held,\n discarded,\n seed: input.seed,\n assumptions: [\n `held on ${held} distinct input(s) generated from the parameter types with seed ${input.seed}; inputs never drawn are not covered`,\n `${fn.name} was called on generated inputs outside the simulator, so it is assumed pure`,\n ...(spec.sample\n ? [\n `drawn only where the sample holds${property.sample ? ` (${property.sample.body.replace(/\\s+/g, \" \").trim()})` : \"\"}; the claim itself is not limited to it`,\n ]\n : []),\n ],\n };\n}\n","/**\n * The spec ladder, as far as it goes without an engine: `CHECKED` on the\n * inputs the simulator passed, then `TESTED` on generated ones. A\n * counterexample at either rung is `REFUTED`; otherwise the verdict is the\n * highest rung that decided, with the lower one's evidence kept beside it.\n */\n\nimport type { SpecVerdict } from \"@eutaxy/core\";\nimport { type Fn, type Forall, isSpec, type ModuleSpecs } from \"@eutaxy/spec\";\nimport { type CheckedInput, checkedRung, malformedReason } from \"./checked.ts\";\nimport { type TestedOptions, testedRung } from \"./tested.ts\";\n\nexport interface LadderOptions {\n /** Run the `TESTED` rung with these options; `false` stops the ladder at `CHECKED`. */\n readonly tested?: TestedOptions | false;\n /** `false` when no scenario ran (`eutaxy report`): the ladder starts at `TESTED`, which it then needs. */\n readonly checked?: false;\n}\n\n/** One property through the ladder's rungs. */\nexport function specLadder(input: CheckedInput, options: LadderOptions = {}): SpecVerdict {\n if (options.checked === false) {\n if (!options.tested) throw new RangeError(\"a ladder without CHECKED needs the TESTED rung\");\n return testedRung({\n module: input.module,\n fn: input.fn,\n property: input.property,\n spec: input.spec,\n ...options.tested,\n });\n }\n const checked = checkedRung(input);\n if (checked.kind === \"REFUTED\" || options.tested === false || options.tested === undefined)\n return checked;\n if (input.property.kind === \"total\") return checked;\n // A property that could not be evaluated on an input the simulator passed is malformed: sampling\n // that happens to miss the input must not make it look sound.\n if (checked.kind === \"UNKNOWN\" && checked.reason.startsWith(malformedReason(\"\"))) return checked;\n const tested = testedRung({\n module: input.module,\n fn: input.fn,\n property: input.property,\n spec: input.spec,\n ...options.tested,\n });\n if (tested.kind === \"REFUTED\") return tested;\n // The same holds the other way round: a generated input that shows the property malformed outranks CHECKED.\n if (tested.kind === \"UNKNOWN\" && tested.reason.startsWith(malformedReason(\"\"))) return tested;\n if (tested.kind === \"TESTED\") {\n if (checked.kind !== \"CHECKED\")\n // Why there is no `checked` count stays visible: the simulator never called the function, say.\n return { ...tested, assumptions: [...tested.assumptions, reason(checked)] };\n return {\n ...tested,\n checked: checked.inputs,\n assumptions: [...tested.assumptions, ...checked.assumptions],\n };\n }\n if (checked.kind !== \"UNKNOWN\")\n return { ...checked, assumptions: [...checked.assumptions, `not TESTED: ${reason(tested)}`] };\n // Neither rung decided: say why for both, once when it is the same reason.\n if (reason(tested) === checked.reason) return checked;\n return { ...checked, reason: `${checked.reason}; generated inputs: ${reason(tested)}` };\n}\n\nfunction reason(v: SpecVerdict): string {\n return v.kind === \"UNKNOWN\" ? v.reason : v.kind;\n}\n\n/**\n * Every spec verdict for one module: each property through the ladder.\n * `props` is the spec file's namespace, `namespace` the module's (after\n * observation ended, so it holds the functions themselves); a spec whose\n * function is not the module's export of that name is not evaluated.\n */\nexport function checkSpecModule(\n module: string,\n specs: ModuleSpecs,\n props: Readonly<Record<string, unknown>>,\n namespace: Readonly<Record<string, unknown>>,\n observed: {\n readonly calls: readonly { readonly function: string; readonly args: readonly unknown[] }[];\n readonly unobservable: { readonly [fn: string]: string };\n },\n options: LadderOptions = {},\n): SpecVerdict[] {\n return specs.functions.flatMap((fn) => {\n const calls = observed.calls.filter((c) => c.function === fn.name);\n // Own properties only: a function named toString must not find Object.prototype's.\n const unobservable = Object.hasOwn(observed.unobservable, fn.name)\n ? observed.unobservable[fn.name]\n : undefined;\n return fn.properties.map((property) => {\n const exported = Object.hasOwn(props, property.name) ? props[property.name] : undefined;\n let spec: Forall<Fn> | undefined;\n let mismatch: string | undefined;\n if (!isSpec(exported)) mismatch = `the spec file exports no spec named ${property.name}`;\n else if (exported.fn !== namespace[fn.name])\n mismatch = `${property.name} names a function that is not the module's export ${fn.name}`;\n else if (exported.kind === \"forall\") spec = exported;\n if (mismatch !== undefined)\n return {\n module,\n function: fn.name,\n property: property.name,\n text: property.text,\n kind: \"UNKNOWN\",\n cause: \"unavailable\",\n reason: mismatch,\n assumptions: [],\n };\n return specLadder(\n {\n module,\n fn,\n property,\n calls,\n spec,\n ...(unobservable === undefined ? {} : { unobservable }),\n },\n options,\n );\n });\n });\n}\n","/**\n * The `Prover` interface every engine implements, first-party or not, and\n * the aggregation of what engines say into the ladder's verdicts. An\n * engine takes a module's source with its specs and the functions to\n * prove and answers per property: `PROVEN` with its name, version and\n * assumptions, or `UNKNOWN` as `gave_up` (a proof did not close, or timed\n * out), `unsupported` (outside its subset) or `unavailable` (not\n * installed). An engine that refutes gives `REFUTED` with a counterexample\n * when it has one. Engines run over a process boundary; nothing here\n * spawns anything.\n */\n\nimport type { Counterexample, SpecVerdict } from \"@eutaxy/core\";\nimport type { ModuleSpecs, SpecError } from \"@eutaxy/spec\";\n\nexport interface EngineId {\n readonly name: string;\n readonly version: string;\n}\n\nexport type ProofOutcome =\n | { readonly kind: \"PROVEN\"; readonly engine: EngineId; readonly assumptions: readonly string[] }\n | {\n readonly kind: \"REFUTED\";\n readonly engine: EngineId;\n readonly counterexample?: Counterexample;\n readonly assumptions: readonly string[];\n }\n | {\n readonly kind: \"UNKNOWN\";\n readonly cause: \"gave_up\" | \"unsupported\" | \"unavailable\";\n readonly reason: string;\n };\n\nexport interface PropertyProof {\n readonly function: string;\n /** The property's export name in the spec file. */\n readonly property: string;\n readonly outcome: ProofOutcome;\n}\n\nexport interface ModuleProofs {\n readonly results: readonly PropertyProof[];\n /** Specs that did not read: properties asked for and never checked. */\n readonly specErrors: readonly SpecError[];\n}\n\nexport interface ProveInput {\n /** The module's source text. */\n readonly source: string;\n /** The module's specs, read from its spec file. */\n readonly specs: ModuleSpecs;\n /** The functions to prove; every one with specs when omitted. */\n readonly functions?: readonly string[];\n /** The module's path, under which its imports resolve; without it the module stands alone. */\n readonly modulePath?: string;\n /** The spec file's path, for an engine that replays a counterexample through the spec itself. */\n readonly specPath?: string;\n readonly timeoutMs?: number;\n}\n\nexport interface Prover {\n readonly name: string;\n /** Whether the engine can run here, or why not. */\n available(): Promise<{ readonly version: string } | { readonly unavailable: string }>;\n prove(input: ProveInput): Promise<ModuleProofs>;\n}\n\n/** What an engine said about one module, by its name. */\nexport interface EngineReport {\n readonly engine: string;\n readonly proofs: ModuleProofs;\n}\n\n/**\n * The simulator's verdicts for a module (CHECKED, TESTED, REFUTED, UNKNOWN,\n * `total` included) combined with what the engines proved. A simulator\n * counterexample stands. One engine proving is `PROVEN`, the lower rungs'\n * counts kept beside it; an engine refuting where nothing else did is\n * `REFUTED` at the PROVEN rung; one proving and another refuting is\n * `CONFLICT`. An engine that gave up, could not run or does not take the\n * function leaves the verdict as it was, with why among the assumptions.\n */\nexport function aggregate(\n module: string,\n verdicts: readonly SpecVerdict[],\n reports: readonly EngineReport[],\n): SpecVerdict[] {\n return verdicts.map((v) => {\n if (v.module !== module) return v;\n const says = reports\n .map((r) => ({\n engine: r.engine,\n outcome: r.proofs.results.find(\n (p) => p.function === v.function && p.property === v.property,\n )?.outcome,\n }))\n .filter((x): x is { engine: string; outcome: ProofOutcome } => x.outcome !== undefined);\n if (says.length === 0) return v;\n const proven = says.find((x) => x.outcome.kind === \"PROVEN\");\n const refuted = says.find((x) => x.outcome.kind === \"REFUTED\");\n if (v.kind === \"REFUTED\" || v.kind === \"CONFLICT\") {\n // The simulator's counterexample is a fact; an engine proving against it is a conflict too.\n if (v.kind === \"REFUTED\" && proven?.outcome.kind === \"PROVEN\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"CONFLICT\",\n proven: proven.outcome.engine,\n refuted: { name: \"simulator\", version: v.rung, counterexample: v.counterexample },\n assumptions: [...v.assumptions, ...proven.outcome.assumptions],\n };\n return v;\n }\n if (proven?.outcome.kind === \"PROVEN\" && refuted?.outcome.kind === \"REFUTED\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"CONFLICT\",\n proven: proven.outcome.engine,\n refuted: {\n name: refuted.outcome.engine.name,\n version: refuted.outcome.engine.version,\n ...(refuted.outcome.counterexample\n ? { counterexample: refuted.outcome.counterexample }\n : {}),\n },\n assumptions: [...proven.outcome.assumptions, ...refuted.outcome.assumptions],\n };\n if (refuted?.outcome.kind === \"REFUTED\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"REFUTED\",\n rung: \"PROVEN\",\n engine: refuted.outcome.engine,\n counterexample: refuted.outcome.counterexample ?? { binders: [] },\n assumptions: refuted.outcome.assumptions,\n };\n if (proven?.outcome.kind === \"PROVEN\")\n return {\n module: v.module,\n function: v.function,\n property: v.property,\n text: v.text,\n kind: \"PROVEN\",\n engine: proven.outcome.engine,\n ...(v.kind === \"TESTED\" ? { tested: v.inputs } : {}),\n ...(v.kind === \"TESTED\" && v.checked !== undefined\n ? { checked: v.checked }\n : v.kind === \"CHECKED\"\n ? { checked: v.inputs }\n : {}),\n assumptions: [...proven.outcome.assumptions, ...v.assumptions],\n };\n // Every engine fell short: say so beside the verdict that stands.\n const notes = says.map((x) =>\n x.outcome.kind === \"UNKNOWN\"\n ? `not PROVEN by ${x.engine}: ${x.outcome.cause}: ${x.outcome.reason}`\n : `${x.engine}: ${x.outcome.kind}`,\n );\n return { ...v, assumptions: [...v.assumptions, ...notes] };\n });\n}\n","/**\n * The Vitest regression emitter. Given a violation, produce a test file that\n * replays its shrunk schedule on the restricted scenario. By default the\n * test expects the invariants to hold, so it fails while the bug exists and\n * passes once it is fixed. With `expect: \"violates\"` it asserts the recorded\n * violation instead, which is how Eutaxy's own corpus exercises the emitter.\n *\n * The emitter knows nothing about any platform: the caller supplies the\n * import lines and the expression that builds the platform.\n */\n\nimport { canonicalJson, type JsonValue, type Violated } from \"@eutaxy/core\";\n\nexport interface RegressionTestOptions {\n /** Import lines for the scenario, the platform's dependencies, and anything the platform expression needs. */\n readonly imports: readonly string[];\n /** An expression evaluating to the `Platform` (may reference the imports). */\n readonly platform: string;\n /** An expression evaluating to the `ScenarioSpec`. */\n readonly scenario: string;\n /** Module that exports `replay`, `restrictSpec` and `checkInvariants`; the public facade by default. */\n readonly engineModule?: string;\n readonly expect?: \"holds\" | \"violates\";\n /**\n * Core functions to observe during the replay, as `refines` needs their\n * decisions in the log: an expression for each module's namespace (from\n * the imports) and the functions to observe on it.\n */\n readonly observe?: readonly {\n readonly namespace: string;\n readonly functions: readonly string[];\n }[];\n}\n\nexport function emitRegressionTest(verdict: Violated, options: RegressionTestOptions): string {\n const engineModule = options.engineModule ?? \"eutaxy\";\n const mode = options.expect ?? \"holds\";\n const schedule = canonicalJson(verdict.schedule as unknown as JsonValue);\n const kept = canonicalJson([...verdict.keptEvents]);\n const keys = canonicalJson([...verdict.violation.keys]);\n const title =\n mode === \"holds\"\n ? `${verdict.scenario}: ${verdict.violation.invariant} holds on the recorded schedule`\n : `${verdict.scenario}: ${verdict.violation.invariant} is still violated on the recorded schedule`;\n const assertion =\n mode === \"holds\"\n ? ` expect(violations.map((v) => \\`\\${v.invariant}: \\${v.message}\\`)).toEqual([]);`\n : ` expect(violations.map((v) => [v.invariant, v.keys])).toContainEqual([${JSON.stringify(verdict.violation.invariant)}, ${keys}]);`;\n const observe = options.observe ?? [];\n const replayLines =\n observe.length === 0\n ? [\" const log = await replay(spec, platform, schedule);\"]\n : [\n ` const observers = [${observe.map((o) => `observeCore(${o.namespace}, ${JSON.stringify(o.functions)})`).join(\", \")}];`,\n \" const log = await replay(spec, platform, schedule).finally(() => {\",\n \" for (const o of observers) o.restore();\",\n \" });\",\n ];\n const lines = [\n \"// Generated by Eutaxy. Replays a recorded violation; regenerate rather than edit.\",\n `// Scenario ${verdict.scenario}, seed ${String(verdict.seed)}: ${verdict.violation.message}`,\n `import { checkInvariants, ${observe.length > 0 ? \"observeCore, \" : \"\"}replay, restrictSpec } from ${JSON.stringify(engineModule)};`,\n ...options.imports,\n 'import { expect, test } from \"vitest\";',\n \"\",\n `const schedule = ${schedule} as const;`,\n `const keptEvents = ${kept} as const;`,\n \"\",\n `test(${JSON.stringify(title)}, async () => {`,\n ` const platform = ${options.platform};`,\n ` const spec = restrictSpec(platform, ${options.scenario}, keptEvents);`,\n ...replayLines,\n \" const violations = checkInvariants(log, spec.invariants);\",\n assertion,\n \"});\",\n \"\",\n ];\n return lines.join(\"\\n\");\n}\n","/**\n * Rendering verdicts: a text form for people and a versioned JSON form for\n * CI and coding agents. Both are pure functions over the verdict data.\n */\n\nimport {\n canonicalJson,\n type EffectLog,\n type JsonValue,\n type ScenarioVerdict,\n type SpecVerdict,\n} from \"@eutaxy/core\";\n\nexport const reportSchemaVersion = 1;\n\n/**\n * The JSON report: one object, canonical, with a schema version at the top.\n * Spec verdicts, when there are any, sit beside the scenario's, never in it.\n */\nexport function renderJson(verdict: ScenarioVerdict, specs: readonly SpecVerdict[] = []): string {\n return canonicalJson({\n schemaVersion: reportSchemaVersion,\n generator: \"eutaxy\",\n verdict: verdict as unknown as JsonValue,\n ...(specs.length > 0 ? { specs: specs as unknown as JsonValue } : {}),\n });\n}\n\nconst specsHeader =\n \"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)\";\n\n/** Spec verdicts as text: one line each, a counterexample under a refutation. */\nexport function renderSpecs(specs: readonly SpecVerdict[]): string {\n if (specs.length === 0) return \"\";\n return [specsHeader, ...specs.flatMap(specLines)].join(\"\\n\");\n}\n\n/** The order a report counts verdicts in: strongest evidence first, then what needs attention. */\nconst verdictOrder = [\"PROVEN\", \"TESTED\", \"CHECKED\", \"REFUTED\", \"CONFLICT\", \"UNKNOWN\"] as const;\n\n/**\n * `eutaxy report` as text: the spec verdicts grouped by module, in the\n * order given, and one closing line counting them by verdict.\n */\nexport function renderSpecReport(specs: readonly SpecVerdict[]): string {\n if (specs.length === 0) return \"No specs found.\";\n const modules = [...new Set(specs.map((v) => v.module))];\n const out = [\n \"Specs (TESTED means held on inputs generated from the parameter types, which is not a proof; PROVEN is one, by the named engine)\",\n ];\n for (const m of modules) {\n out.push(\"\", m);\n for (const v of specs) if (v.module === m) out.push(...specLines(v));\n }\n const counts = verdictOrder\n .map((k) => [k, specs.filter((v) => v.kind === k).length] as const)\n .filter(([, n]) => n > 0)\n .map(([k, n]) => `${n} ${k}`);\n out.push(\n \"\",\n `${specs.length} propert${specs.length === 1 ? \"y\" : \"ies\"} in ${modules.length} module${modules.length === 1 ? \"\" : \"s\"}: ${counts.join(\", \")}`,\n );\n return out.join(\"\\n\");\n}\n\n/** `eutaxy report --json`: canonical, with the schema version, the spec verdicts and nothing else. */\nexport function renderSpecReportJson(specs: readonly SpecVerdict[]): string {\n return canonicalJson({\n schemaVersion: reportSchemaVersion,\n generator: \"eutaxy\",\n specs: specs as unknown as JsonValue,\n });\n}\n\nfunction specLines(v: SpecVerdict): string[] {\n const out: string[] = [];\n const what = `${v.function} ${v.property}`;\n switch (v.kind) {\n case \"CHECKED\":\n out.push(\n ` CHECKED ${what}: held on ${v.inputs} input(s)${v.discarded > 0 ? `, ${v.discarded} outside the claim` : \"\"}`,\n );\n break;\n case \"TESTED\":\n out.push(\n ` TESTED ${what}: held on ${v.inputs} generated input(s)${v.checked === undefined ? \"\" : ` and ${v.checked} the simulator passed`}${v.discarded > 0 ? `, ${v.discarded} outside the claim` : \"\"}`,\n );\n break;\n case \"PROVEN\": {\n const beside = [\n ...(v.tested === undefined ? [] : [`${v.tested} generated input(s)`]),\n ...(v.checked === undefined ? [] : [`${v.checked} the simulator passed`]),\n ];\n out.push(\n ` PROVEN ${what}: by ${v.engine.name} ${v.engine.version}${beside.length > 0 ? `; also held on ${beside.join(\" and \")}` : \"\"}`,\n );\n break;\n }\n case \"CONFLICT\":\n out.push(\n ` CONFLICT ${what}: ${v.proven.name} ${v.proven.version} proves it, ${v.refuted.name} ${v.refuted.version} refutes it; not resolved automatically`,\n );\n if (v.refuted.counterexample)\n out.push(\n ` ${v.refuted.counterexample.binders.map((b) => `${b.name} = ${b.value}`).join(\", \")}`,\n );\n break;\n case \"REFUTED\": {\n const c = v.counterexample;\n const where =\n v.rung === \"PROVEN\"\n ? `by ${v.engine?.name ?? \"an engine\"}`\n : c.call === undefined\n ? \"on a generated input\"\n : `at ${c.call}`;\n out.push(` REFUTED ${what}: false ${where}${c.error ? `, which threw ${c.error}` : \"\"}`);\n if (c.binders.length > 0)\n out.push(` ${c.binders.map((b) => `${b.name} = ${b.value}`).join(\", \")}`);\n out.push(` ${v.text.replace(/\\s+/g, \" \")}`);\n break;\n }\n case \"UNKNOWN\":\n out.push(` UNKNOWN ${what}: ${v.cause}: ${v.reason}`);\n break;\n }\n // A proof rests on its engine's model of the language: every assumption is shown. Elsewhere, an\n // engine that was asked and fell short says so under the verdict that stands.\n for (const a of v.assumptions)\n if (v.kind === \"PROVEN\" || a.startsWith(\"not PROVEN by \")) out.push(` ${a}`);\n return out;\n}\n\nfunction clip(s: string, max: number): string {\n return s.length <= max ? s : `${s.slice(0, max - 1)}…`;\n}\n\nfunction pad(s: string, width: number): string {\n return s.length >= width ? s : s + \" \".repeat(width - s.length);\n}\n\n/** The trace as a fixed-width table; evidence rows are marked with `*`. */\nexport function renderTrace(log: EffectLog, evidence: readonly number[] = []): string {\n const rows = log.entries.map((e) => [\n evidence.includes(e.seq) ? \"*\" : \" \",\n String(e.seq),\n e.invocation,\n e.kind,\n e.target,\n e.op,\n clip(canonicalJson(e.payload), 72),\n ]);\n const header = [\" \", \"seq\", \"invocation\", \"kind\", \"target\", \"op\", \"payload\"];\n const widths = header.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] as string).length)),\n );\n const line = (cells: readonly string[]) =>\n cells\n .map((c, i) => (i === cells.length - 1 ? c : pad(c, widths[i] as number)))\n .join(\" \")\n .trimEnd();\n return [line(header), ...rows.map(line)].join(\"\\n\");\n}\n\n/** A readable report: verdict, what it rests on, and for a violation the schedule and trace. */\nexport function renderText(verdict: ScenarioVerdict): string {\n const out: string[] = [];\n const r = verdict.reached;\n out.push(`${verdict.kind} ${verdict.scenario} (seed ${String(verdict.seed)})`);\n switch (verdict.kind) {\n case \"VIOLATED\": {\n out.push(\"\");\n out.push(\n `Invariant ${verdict.violation.invariant} is violated: ${verdict.violation.message}`,\n );\n out.push(`Keys: ${verdict.violation.keys.join(\", \")}`);\n out.push(\"\");\n out.push(\n `Schedule (run seed ${verdict.schedule.seed}), events kept: ${verdict.keptEvents.join(\", \")}`,\n );\n if (verdict.schedule.faults.length === 0) out.push(\" no injected faults\");\n for (const f of verdict.schedule.faults) {\n out.push(` ${f.fault} at ${f.invocation} effect #${f.ordinal} (${f.target} ${f.op})`);\n }\n out.push(\n `Shrunk: ${verdict.shrunk.eventsRemoved} event(s) and ${verdict.shrunk.faultsRemoved} fault(s) removed in ${verdict.shrunk.runs} run(s)`,\n );\n out.push(\"\");\n out.push(\"Trace:\");\n out.push(renderTrace(verdict.trace, verdict.violation.evidence));\n break;\n }\n case \"BOUNDED\": {\n const b = verdict.bounds;\n out.push(\"\");\n out.push(\"No violation found within the stated bounds. This is not a proof.\");\n out.push(\n `Bounds: faults per run ≤ ${b.maxFaultsPerRun}, redeliveries ≤ ${b.maxRedeliveries}, concurrent invocations ≤ ${b.maxConcurrentInvocations}, budget ${b.budgetMs} ms`,\n );\n break;\n }\n case \"UNSUPPORTED\": {\n out.push(\"\");\n out.push(`Eutaxy could not decide this scenario (${verdict.cause}): ${verdict.reason}`);\n break;\n }\n }\n out.push(\"\");\n out.push(\n `Explored: ${r.runs} run(s), ${r.effectPoints} effect point(s), ${r.faultsInjected} fault(s) injected, ${r.elapsedMs} ms`,\n );\n const e = r.exhaustive;\n if (e) {\n const stopped = {\n VIOLATED: \"stopped at the first violation\",\n BOUNDED: \"stopped at the budget before every schedule ran\",\n UNSUPPORTED: \"stopped where the scenario could not be decided\",\n }[verdict.kind];\n out.push(\n `Exhaustive: ${e.complete ? \"every schedule within the bounds ran\" : stopped} (${e.schedules} schedules${e.reduction ? \", partial-order reduction\" : \"\"})`,\n );\n }\n out.push(\"Assumptions:\");\n for (const a of verdict.assumptions) out.push(` - ${a}`);\n return out.join(\"\\n\");\n}\n"],"mappings":";;;;AAqEA,SAAgB,gBAAgB,GAA4B;CAC1D,QAAQ,EAAE,MAAV;EACE,KAAK,YACH,OAAO,YAAY,EAAE,SAAS,IAAI,EAAE,UAAU,QAAQ,SAAS,EAAE,SAAS,KAAK,IAAI,EAAE,QAAQ,KAAK;EACpG,KAAK,WACH,OAAO,WAAW,EAAE,SAAS,oBAAoB,EAAE,QAAQ,KAAK,WAAW,EAAE,QAAQ,aAAa,oBAAoB,EAAE,QAAQ,eAAe;EACjJ,KAAK,eACH,OAAO,eAAe,EAAE,SAAS,IAAI,EAAE,MAAM,IAAI,EAAE;CACvD;AACF;;;ACmDA,SAAgB,aAAa,GAAqB;CAChD,QAAQ,EAAE,MAAV;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,aACH,OAAO,EAAE;EACX,KAAK,WACH,OAAO,OAAO,EAAE,UAAU,WAAW,K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