eutaxy 0.18.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +15 -12
  2. package/dist/aws.d.mts +3 -3
  3. package/dist/aws.d.mts.map +1 -1
  4. package/dist/aws.mjs +13 -4
  5. package/dist/aws.mjs.map +1 -1
  6. package/dist/bin.mjs +1 -1
  7. package/dist/check-zkHLdWyf.mjs +1281 -0
  8. package/dist/check-zkHLdWyf.mjs.map +1 -0
  9. package/dist/cli-Bxjvq4p9.mjs +297 -0
  10. package/dist/cli-Bxjvq4p9.mjs.map +1 -0
  11. package/dist/cli.d.mts.map +1 -1
  12. package/dist/cli.mjs +1 -1
  13. package/dist/cloudflare.d.mts +38 -6
  14. package/dist/cloudflare.d.mts.map +1 -1
  15. package/dist/cloudflare.mjs +6466 -3
  16. package/dist/cloudflare.mjs.map +1 -0
  17. package/dist/{delivery-invariants-D-_GPOqE.d.mts → delivery-invariants-C3GXJIbg.d.mts} +2 -2
  18. package/dist/{delivery-invariants-D-_GPOqE.d.mts.map → delivery-invariants-C3GXJIbg.d.mts.map} +1 -1
  19. package/dist/{delivery-invariants-BRwfZJrs.mjs → delivery-invariants-DsBHpT1n.mjs} +2 -2
  20. package/dist/{delivery-invariants-BRwfZJrs.mjs.map → delivery-invariants-DsBHpT1n.mjs.map} +1 -1
  21. package/dist/draft-DEUDffHa.mjs +467 -0
  22. package/dist/draft-DEUDffHa.mjs.map +1 -0
  23. package/dist/{src-H1Q8ytEx.mjs → generate-TBJM3-2P.mjs} +3 -618
  24. package/dist/generate-TBJM3-2P.mjs.map +1 -0
  25. package/dist/index.d.mts +36 -36
  26. package/dist/index.d.mts.map +1 -1
  27. package/dist/index.mjs +6 -3
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/install-DkzpGA5D.mjs +611 -0
  30. package/dist/install-DkzpGA5D.mjs.map +1 -0
  31. package/dist/{explore-D33RP9hF.d.mts → ir-KpC2epGn.d.mts} +70 -70
  32. package/dist/ir-KpC2epGn.d.mts.map +1 -0
  33. package/dist/keys-xtanNmuR.mjs +111 -0
  34. package/dist/keys-xtanNmuR.mjs.map +1 -0
  35. package/dist/mcp-DEn3HnLz.mjs +539 -0
  36. package/dist/mcp-DEn3HnLz.mjs.map +1 -0
  37. package/dist/{platform-CawKCUru.d.mts → platform-Cs9V9t2k.d.mts} +25 -11
  38. package/dist/platform-Cs9V9t2k.d.mts.map +1 -0
  39. package/dist/pool-CXN4CwGY.mjs +61 -0
  40. package/dist/pool-CXN4CwGY.mjs.map +1 -0
  41. package/dist/{provers-DS44OeEm.mjs → provers-D8VaY_OM.mjs} +18 -2
  42. package/dist/provers-D8VaY_OM.mjs.map +1 -0
  43. package/dist/reader-B9FSoEYW.mjs +1 -0
  44. package/dist/reader-Cz6_bLf6.mjs +3774 -0
  45. package/dist/reader-Cz6_bLf6.mjs.map +1 -0
  46. package/dist/report-_Vzavqg0.mjs +310 -0
  47. package/dist/report-_Vzavqg0.mjs.map +1 -0
  48. package/dist/src-B2DpVbMN.mjs +2 -0
  49. package/dist/src-BFGTvuA_.mjs +1235 -0
  50. package/dist/src-BFGTvuA_.mjs.map +1 -0
  51. package/dist/src-BtLZPRyG.mjs +120 -0
  52. package/dist/src-BtLZPRyG.mjs.map +1 -0
  53. package/dist/src-CB8DcvsK.mjs +1 -0
  54. package/dist/src-COuquJvI.mjs +269 -0
  55. package/dist/src-COuquJvI.mjs.map +1 -0
  56. package/dist/src-Chn-m_r1.mjs +1082 -0
  57. package/dist/src-Chn-m_r1.mjs.map +1 -0
  58. package/dist/{src-Whn0RMSh.mjs → src-D-MeEFn3.mjs} +589 -517
  59. package/dist/src-D-MeEFn3.mjs.map +1 -0
  60. package/dist/src-DwYD3QQJ.mjs +346 -0
  61. package/dist/src-DwYD3QQJ.mjs.map +1 -0
  62. package/dist/toolchain-DWfymxAJ.mjs +80 -0
  63. package/dist/toolchain-DWfymxAJ.mjs.map +1 -0
  64. package/dist/verdict-evEM5Gxx.mjs +12 -0
  65. package/dist/verdict-evEM5Gxx.mjs.map +1 -0
  66. package/package.json +4 -1
  67. package/dist/cli-DyA7uTBg.mjs +0 -9447
  68. package/dist/cli-DyA7uTBg.mjs.map +0 -1
  69. package/dist/explore-D33RP9hF.d.mts.map +0 -1
  70. package/dist/platform-CawKCUru.d.mts.map +0 -1
  71. package/dist/provers-DS44OeEm.mjs.map +0 -1
  72. package/dist/src-H1Q8ytEx.mjs.map +0 -1
  73. package/dist/src-Whn0RMSh.mjs.map +0 -1
  74. package/dist/workerd-tI8INa6v.mjs +0 -6334
  75. package/dist/workerd-tI8INa6v.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-DkzpGA5D.mjs","names":[],"sources":["../../cli/src/archive.ts","../../cli/src/install.ts"],"sourcesContent":["/**\n * Reading the two archive formats the release files come in, with Node's\n * standard library alone: a zip (Z3; elan's installer on Windows) and a\n * gzip-compressed tar (elan's installer elsewhere). From either, only the\n * files the caller names are taken, each to the path the caller gives: the\n * archive chooses no path and makes no link, so nothing in it can write\n * anywhere else. A named entry that is missing, there twice, a link or a\n * directory, or whose data does not match what its headers say, is refused,\n * and nothing is written until every named entry has been read.\n */\n\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve, sep } from \"node:path\";\nimport { crc32, gunzipSync, inflateRawSync } from \"node:zlib\";\n\nexport class ArchiveError extends Error {}\n\nconst inside = (dest: string, path: string): boolean =>\n path === dest || path.startsWith(dest + sep);\n\n/** Each named entry's place under `dest`, checked before the archive is read. */\nfunction placesOf(entries: Readonly<Record<string, string>>, dest: string): Map<string, string> {\n const root = resolve(dest);\n const places = new Map<string, string>();\n for (const [name, to] of Object.entries(entries)) {\n const place = resolve(root, to);\n if (place === root || !inside(root, place))\n throw new ArchiveError(`${JSON.stringify(to)} is not a path under the toolchain directory`);\n places.set(name, place);\n }\n return places;\n}\n\n/**\n * Write what was read, once every named entry has been: files with mode\n * 0644 (the caller makes its executable runnable). Returns how many.\n */\nfunction writeFound(\n kind: string,\n places: ReadonlyMap<string, string>,\n found: ReadonlyMap<string, Buffer>,\n): number {\n const missing = [...places.keys()].filter((name) => !found.has(name));\n if (missing.length > 0)\n throw new ArchiveError(\n `the ${kind} holds no ${missing.map((m) => JSON.stringify(m)).join(\", \")}`,\n );\n for (const [name, data] of found) {\n const place = places.get(name) as string;\n mkdirSync(dirname(place), { recursive: true });\n writeFileSync(place, data, { mode: 0o644 });\n }\n return found.size;\n}\n\nconst ZIP_EOCD = 0x06054b50;\nconst ZIP64_EOCD = 0x06064b50;\nconst ZIP64_LOCATOR = 0x07064b50;\nconst ZIP_CENTRAL = 0x02014b50;\nconst ZIP_LOCAL = 0x04034b50;\n\n/** The central directory's position and entry count, through the zip64 records when the plain ones overflow. */\nfunction centralDirectory(zip: Buffer): { offset: number; entries: number } {\n const start = Math.max(0, zip.length - 22 - 65_535);\n let eocd = -1;\n for (let i = zip.length - 22; i >= start; i--)\n if (zip.readUInt32LE(i) === ZIP_EOCD) {\n eocd = i;\n break;\n }\n if (eocd < 0) throw new ArchiveError(\"not a zip file: no end-of-central-directory record\");\n let entries: number = zip.readUInt16LE(eocd + 10);\n let offset: number = zip.readUInt32LE(eocd + 16);\n if (entries === 0xffff || offset === 0xffffffff) {\n const locator = eocd - 20;\n if (locator < 0 || zip.readUInt32LE(locator) !== ZIP64_LOCATOR)\n throw new ArchiveError(\"zip64 archive without its locator\");\n const at = Number(zip.readBigUInt64LE(locator + 8));\n if (at + 56 > zip.length || zip.readUInt32LE(at) !== ZIP64_EOCD)\n throw new ArchiveError(\"zip64 archive without its end record\");\n entries = Number(zip.readBigUInt64LE(at + 32));\n offset = Number(zip.readBigUInt64LE(at + 48));\n }\n return { offset, entries };\n}\n\n/** Sizes and offset of one entry, from its zip64 extra field when the plain ones overflow. */\nfunction zip64Fields(\n extra: Buffer,\n plain: { compressed: number; uncompressed: number; offset: number },\n): { compressed: number; uncompressed: number; offset: number } {\n let at = 0;\n while (at + 4 <= extra.length) {\n const id = extra.readUInt16LE(at);\n const size = extra.readUInt16LE(at + 2);\n const end = at + 4 + size;\n if (end > extra.length) throw new ArchiveError(\"an entry's extra field is cut short\");\n if (id === 0x0001) {\n let p = at + 4;\n const next = (): number => {\n if (p + 8 > end) throw new ArchiveError(\"an entry's zip64 field is cut short\");\n const value = Number(extra.readBigUInt64LE(p));\n p += 8;\n return value;\n };\n const out = { ...plain };\n if (out.uncompressed === 0xffffffff) out.uncompressed = next();\n if (out.compressed === 0xffffffff) out.compressed = next();\n if (out.offset === 0xffffffff) out.offset = next();\n return out;\n }\n at += 4 + size;\n }\n return plain;\n}\n\n/**\n * Take the named files of a zip, and nothing else: `entries` maps each\n * file's path in the archive to the path under `dest` it is written to.\n * Every named entry must be there exactly once, must be a plain file\n * (a directory or a link is refused), and must inflate to its declared\n * size and CRC-32; nothing is written until all of them have. Files are\n * written with mode 0644 (the caller makes its executable runnable).\n * Returns how many files were written.\n */\nexport function extractZipEntries(\n file: string,\n entries: Readonly<Record<string, string>>,\n dest: string,\n): number {\n const places = placesOf(entries, dest);\n const zip = readFileSync(file);\n const { offset, entries: count } = centralDirectory(zip);\n const found = new Map<string, Buffer>();\n let at = offset;\n for (let i = 0; i < count; i++) {\n if (at + 46 > zip.length || zip.readUInt32LE(at) !== ZIP_CENTRAL)\n throw new ArchiveError(\"a central directory entry is not where the zip says it is\");\n const madeBy = zip.readUInt16LE(at + 4) >> 8;\n const method = zip.readUInt16LE(at + 10);\n const crc = zip.readUInt32LE(at + 16);\n const nameLength = zip.readUInt16LE(at + 28);\n const extraLength = zip.readUInt16LE(at + 30);\n const commentLength = zip.readUInt16LE(at + 32);\n const externalAttributes = zip.readUInt32LE(at + 38);\n const name = zip.subarray(at + 46, at + 46 + nameLength).toString(\"utf8\");\n const extra = zip.subarray(at + 46 + nameLength, at + 46 + nameLength + extraLength);\n const sizes = zip64Fields(extra, {\n compressed: zip.readUInt32LE(at + 20),\n uncompressed: zip.readUInt32LE(at + 24),\n offset: zip.readUInt32LE(at + 42),\n });\n at += 46 + nameLength + extraLength + commentLength;\n if (!places.has(name)) continue;\n const quoted = JSON.stringify(name);\n if (found.has(name)) throw new ArchiveError(`entry ${quoted} is in the zip twice`);\n const type = (madeBy === 3 ? externalAttributes >>> 16 : 0) & 0o170000;\n if (name.endsWith(\"/\") || type === 0o040000)\n throw new ArchiveError(`entry ${quoted} is a directory, not a file`);\n if (type === 0o120000) throw new ArchiveError(`entry ${quoted} is a link, not a file`);\n const local = sizes.offset;\n if (local + 30 > zip.length || zip.readUInt32LE(local) !== ZIP_LOCAL)\n throw new ArchiveError(`entry ${quoted} has no local header where the zip says`);\n const dataStart = local + 30 + zip.readUInt16LE(local + 26) + zip.readUInt16LE(local + 28);\n const raw = zip.subarray(dataStart, dataStart + sizes.compressed);\n let data: Buffer;\n if (method === 0) data = raw;\n else if (method === 8) {\n try {\n // Never more than the entry declares, so a short entry cannot inflate into a huge one; the\n // declared size itself comes from the zip, whose SHA-256 the install checked first.\n data = inflateRawSync(raw, { maxOutputLength: Math.max(1, sizes.uncompressed) });\n } catch (err) {\n throw new ArchiveError(\n `entry ${quoted} did not inflate within its declared size: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n } else\n throw new ArchiveError(\n `entry ${quoted} uses compression method ${method}; only stored and deflated entries are read`,\n );\n if (data.length !== sizes.uncompressed)\n throw new ArchiveError(`entry ${quoted} did not inflate to its declared size`);\n if (crc32(data) !== crc) throw new ArchiveError(`entry ${quoted} fails its CRC-32 check`);\n found.set(name, data);\n }\n return writeFound(\"zip\", places, found);\n}\n\n/** The largest tar a release's installer comes in, uncompressed; elan's is 6 to 14 MB. */\nconst maxTarBytes = 256 * 1024 * 1024;\n\nconst text = (block: Buffer, start: number, length: number): string => {\n const slice = block.subarray(start, start + length);\n const end = slice.indexOf(0);\n return slice.subarray(0, end < 0 ? slice.length : end).toString(\"utf8\");\n};\n\n/** An octal field, or GNU base-256 when the high bit of the first byte is set. */\nconst numeric = (block: Buffer, start: number, length: number): number => {\n const first = block[start] as number;\n if (first & 0x80) {\n let n = 0;\n for (let i = start + 1; i < start + length; i++) n = n * 256 + (block[i] as number);\n return n;\n }\n const t = text(block, start, length).trim();\n if (t.length === 0) return 0;\n if (!/^[0-7]+$/.test(t))\n throw new ArchiveError(`a tar header holds ${JSON.stringify(t)} where a number goes`);\n return Number.parseInt(t, 8);\n};\n\n/** `length key=value\\n` records of a pax extended header. */\nfunction paxRecords(data: Buffer): Map<string, string> {\n const out = new Map<string, string>();\n let at = 0;\n while (at < data.length) {\n const space = data.indexOf(0x20, at);\n if (space < 0) break;\n const length = Number.parseInt(data.subarray(at, space).toString(\"latin1\"), 10);\n if (!Number.isInteger(length) || length <= 0) break;\n const record = data.subarray(space + 1, at + length - 1).toString(\"utf8\");\n const eq = record.indexOf(\"=\");\n if (eq > 0) out.set(record.slice(0, eq), record.slice(eq + 1));\n at += length;\n }\n return out;\n}\n\n/**\n * Take the named files of a gzip-compressed tar, and nothing else, as\n * `extractZipEntries` does for a zip: `entries` maps each file's path in\n * the archive (after any pax or GNU long name) to its path under `dest`.\n * Every header's checksum is checked; a named entry must be a regular file.\n */\nexport function extractTarGzEntries(\n file: string,\n entries: Readonly<Record<string, string>>,\n dest: string,\n): number {\n const places = placesOf(entries, dest);\n let tar: Buffer;\n try {\n tar = gunzipSync(readFileSync(file), { maxOutputLength: maxTarBytes });\n } catch (err) {\n throw new ArchiveError(\n `not a gzip-compressed tar within ${maxTarBytes} bytes: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n const found = new Map<string, Buffer>();\n let next: { path?: string; size?: number } = {};\n let at = 0;\n while (at + 512 <= tar.length) {\n const block = tar.subarray(at, at + 512);\n if (block.every((b) => b === 0)) break;\n let sum = 0;\n for (let i = 0; i < 512; i++) sum += i >= 148 && i < 156 ? 0x20 : (block[i] as number);\n if (sum !== numeric(block, 148, 8)) throw new ArchiveError(\"a tar header fails its checksum\");\n const type = block[156] === 0 ? \"0\" : String.fromCharCode(block[156] as number);\n const size =\n type === \"x\" || type === \"L\"\n ? numeric(block, 124, 12)\n : (next.size ?? numeric(block, 124, 12));\n const start = at + 512;\n if (start + size > tar.length)\n throw new ArchiveError(\"the tar ends inside an entry; the file is truncated\");\n const data = tar.subarray(start, start + size);\n at = start + Math.ceil(size / 512) * 512;\n if (type === \"x\") {\n const records = paxRecords(data);\n const path = records.get(\"path\");\n const declared = records.get(\"size\");\n if (declared !== undefined && !/^\\d+$/.test(declared))\n throw new ArchiveError(`a pax header gives the size ${JSON.stringify(declared)}`);\n next = {\n ...(path === undefined ? {} : { path }),\n ...(declared === undefined ? {} : { size: Number(declared) }),\n };\n continue;\n }\n if (type === \"L\") {\n next = { ...next, path: text(data, 0, data.length) };\n continue;\n }\n if (type === \"g\") continue;\n // Only a POSIX header (\"ustar\\0\") has a name prefix there; an old GNU one (\"ustar \") keeps times.\n const prefix = text(block, 257, 6) === \"ustar\" ? text(block, 345, 155) : \"\";\n const plain = text(block, 0, 100);\n const name = next.path ?? (prefix.length > 0 ? `${prefix}/${plain}` : plain);\n next = {};\n if (!places.has(name)) continue;\n const quoted = JSON.stringify(name);\n if (found.has(name)) throw new ArchiveError(`entry ${quoted} is in the tar twice`);\n if (type === \"5\") throw new ArchiveError(`entry ${quoted} is a directory, not a file`);\n if (type === \"1\" || type === \"2\")\n throw new ArchiveError(`entry ${quoted} is a link, not a file`);\n if (type !== \"0\" && type !== \"7\")\n throw new ArchiveError(`entry ${quoted} is of tar type ${JSON.stringify(type)}, not a file`);\n found.set(name, Buffer.from(data));\n }\n return writeFound(\"tar\", places, found);\n}\n","/**\n * `eutaxy prover install <lean|smt>`: the pinned toolchain of a prover put\n * on this machine, where the engines look first.\n *\n * `installToolchain` installs a pinned upstream release file into Eutaxy's\n * cache: the file for this platform is downloaded (or copied from a mirror\n * or an offline directory given with `--from`), its SHA-256 checked against\n * the table before anything is unpacked, the files the table names taken\n * from it (a zip or a `tar.gz`) beside a marker written last, and the\n * download deleted. A mismatch or a failed download installs nothing, and\n * nothing is run. Z3 comes this way, and so does elan's installer.\n *\n * `installLean` installs Lean through elan, Lean's toolchain manager: the\n * machine's elan if it has one, else elan installed into Eutaxy's cache\n * from its pinned installer (without touching the PATH or the shell's\n * profile); then `elan toolchain install` of the pinned toolchain, whose\n * files' digest is checked against the pinned one, since elan checks no\n * pinned checksum itself.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { createHash, randomBytes } from \"node:crypto\";\nimport {\n chmodSync,\n closeSync,\n createReadStream,\n existsSync,\n mkdirSync,\n mkdtempSync,\n openSync,\n renameSync,\n rmSync,\n writeFileSync,\n writeSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport {\n cacheDir,\n executableName,\n type Host,\n host,\n type InstallMarker,\n installed,\n markerFile,\n type Platform,\n platformOf,\n platforms,\n type Toolchain,\n toolchainDir,\n} from \"@eutaxy/prover/toolchain\";\nimport {\n type Elan,\n elanCandidates,\n elanDownloads,\n elanHome,\n elanVersion,\n leanDigests,\n leanToolchain,\n leanVersion,\n toolchainDigest,\n} from \"@eutaxy/prover-lean\";\nimport { z3Downloads } from \"@eutaxy/prover-smt\";\nimport { reportSchemaVersion } from \"@eutaxy/report\";\nimport { extractTarGzEntries, extractZipEntries } from \"./archive.ts\";\nimport { exitCodes } from \"./check.ts\";\n\n/** The engines the command installs, by the name it takes. */\nexport const engines = [\"lean\", \"smt\"] as const;\nexport type Engine = (typeof engines)[number];\n\nexport class InstallError extends Error {}\n\nexport interface InstallOptions {\n readonly toolchain: Toolchain;\n readonly host?: Host;\n /** A mirror URL or a directory holding the release file under its upstream name. */\n readonly from?: string;\n /** How to download, for tests; the global `fetch` otherwise. */\n readonly fetch?: typeof fetch;\n /** Progress lines while a download runs. */\n readonly progress?: (text: string) => void;\n}\n\nexport interface InstallResult {\n readonly name: string;\n readonly version: string;\n readonly platform: Platform;\n readonly file: string;\n readonly source: string;\n readonly sha256: string;\n readonly bytes: number;\n readonly dir: string;\n readonly executable: string;\n /** False when the toolchain was already in the cache and nothing was downloaded. */\n readonly downloaded: boolean;\n}\n\nconst isUrl = (s: string): boolean => /^https?:\\/\\//.test(s);\n\n/** Write a byte stream to `path`, hashing it as it goes; the hash and the byte count come back. */\nasync function store(\n bytes: AsyncIterable<Uint8Array>,\n path: string,\n progress: ((written: number) => void) | undefined,\n): Promise<{ sha256: string; bytes: number }> {\n const hash = createHash(\"sha256\");\n const fd = openSync(path, \"w\");\n let written = 0;\n let reported = 0;\n try {\n for await (const chunk of bytes) {\n writeSync(fd, chunk);\n hash.update(chunk);\n written += chunk.byteLength;\n if (progress && written - reported >= 50_000_000) {\n reported = written;\n progress(written);\n }\n }\n } finally {\n closeSync(fd);\n }\n return { sha256: hash.digest(\"hex\"), bytes: written };\n}\n\nexport async function installToolchain(options: InstallOptions): Promise<InstallResult> {\n const { toolchain } = options;\n const h = options.host ?? host();\n const platform = platformOf(h);\n const release = platform === undefined ? undefined : toolchain.files[platform];\n if (platform === undefined || release === undefined)\n throw new InstallError(\n `no ${toolchain.name} ${toolchain.version} release for ${h.platform}-${h.arch}; the platforms are ${platforms.join(\", \")}`,\n );\n const cache = cacheDir(h);\n const dir = toolchainDir(cache, toolchain);\n const already = installed(toolchain, h);\n if (already)\n return {\n name: toolchain.name,\n version: toolchain.version,\n platform,\n file: already.marker.file,\n source: already.marker.source,\n sha256: already.marker.sha256,\n bytes: release.bytes,\n dir,\n executable: already.executable,\n downloaded: false,\n };\n const source =\n options.from === undefined\n ? release.url\n : isUrl(options.from)\n ? `${options.from.replace(/\\/+$/, \"\")}/${release.file}`\n : join(options.from, release.file);\n // Staging paths of this invocation alone, so two installs sharing a cache never touch each other's files.\n const stamp = `${process.pid}-${randomBytes(4).toString(\"hex\")}`;\n const downloads = join(cache, \"downloads\");\n const archive = join(downloads, `${release.file}.${stamp}.part`);\n const mb = (n: number) => `${Math.round(n / 1_000_000)} MB`;\n try {\n mkdirSync(downloads, { recursive: true });\n let bytes: AsyncIterable<Uint8Array>;\n if (isUrl(source)) {\n const fetchImpl = options.fetch ?? fetch;\n let response: Response;\n try {\n response = await fetchImpl(source);\n } catch (err) {\n throw new InstallError(\n `could not download ${source}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n if (!response.ok || response.body === null)\n throw new InstallError(\n `could not download ${source}: HTTP ${response.status} ${response.statusText}`,\n );\n options.progress?.(`downloading ${release.file} (${mb(release.bytes)}) from ${source}`);\n bytes = Readable.fromWeb(response.body as import(\"node:stream/web\").ReadableStream);\n } else {\n if (!existsSync(source)) throw new InstallError(`no ${release.file} in ${options.from}`);\n bytes = createReadStream(source);\n }\n let stored: { sha256: string; bytes: number };\n try {\n stored = await store(bytes, archive, (n) =>\n options.progress?.(`${mb(n)} of ${mb(release.bytes)}`),\n );\n } catch (err) {\n throw new InstallError(\n `could not download ${source}: ${err instanceof Error ? err.message : String(err)}; nothing was installed`,\n );\n }\n if (stored.sha256 !== release.sha256)\n throw new InstallError(\n `checksum mismatch for ${release.file} from ${source}: expected sha256 ${release.sha256}, got ${stored.sha256} (${stored.bytes} bytes, ${release.bytes} expected); nothing was installed`,\n );\n const partial = `${dir}.partial-${stamp}`;\n mkdirSync(partial, { recursive: true });\n try {\n options.progress?.(`unpacking ${release.file}`);\n const extract = release.file.endsWith(\".zip\")\n ? extractZipEntries\n : release.file.endsWith(\".tar.gz\")\n ? extractTarGzEntries\n : undefined;\n if (extract === undefined)\n throw new InstallError(`${release.file} is neither a .zip nor a .tar.gz`);\n if (release.entries === undefined)\n throw new InstallError(\n `the table names no files to take from ${release.file}; nothing was installed`,\n );\n extract(archive, release.entries, partial);\n const executable = executableName(toolchain, h);\n if (!existsSync(join(partial, executable)))\n throw new InstallError(`${release.file} holds no ${executable}; nothing was installed`);\n // The named executable must run whatever mode the archive gave it (a zip made elsewhere carries none).\n if (h.platform !== \"win32\") chmodSync(join(partial, executable), 0o755);\n const marker: InstallMarker = {\n name: toolchain.name,\n version: toolchain.version,\n platform,\n file: release.file,\n sha256: stored.sha256,\n source,\n };\n writeFileSync(join(partial, markerFile), `${JSON.stringify(marker, null, 2)}\\n`);\n rmSync(dir, { recursive: true, force: true });\n renameSync(partial, dir);\n } catch (err) {\n rmSync(partial, { recursive: true, force: true });\n throw err instanceof InstallError\n ? err\n : new InstallError(\n `could not unpack ${release.file}: ${err instanceof Error ? err.message : String(err)}; nothing was installed`,\n );\n }\n return {\n name: toolchain.name,\n version: toolchain.version,\n platform,\n file: release.file,\n source,\n sha256: stored.sha256,\n bytes: stored.bytes,\n dir,\n executable: join(dir, executableName(toolchain, h)),\n downloaded: true,\n };\n } catch (err) {\n // Anything but an install error here is the file system refusing (the cache not writable, say).\n throw err instanceof InstallError\n ? err\n : new InstallError(\n `could not install ${toolchain.name} ${toolchain.version} in ${cache}: ${err instanceof Error ? err.message : String(err)}`,\n );\n } finally {\n try {\n rmSync(archive, { force: true });\n } catch {\n // The download never got there (the cache is not a directory, say); the error above says why.\n }\n }\n}\n\n/** What running a command gave: its exit code (null when it could not start or timed out) and its output. */\nexport interface ExecResult {\n readonly code: number | null;\n readonly stdout: string;\n readonly stderr: string;\n readonly timedOut?: boolean;\n}\nexport interface ExecOptions {\n /** Environment added to the process's own. */\n readonly env?: Readonly<Record<string, string>> | undefined;\n readonly cwd?: string;\n /** Killed after this long; a command that hangs never holds the install forever. */\n readonly timeoutMs?: number;\n}\n/** Run a command to its end; tests hand in another. */\nexport type Exec = (\n command: string,\n args: readonly string[],\n options?: ExecOptions,\n) => Promise<ExecResult>;\n\n/** How long a quick elan command (a version, a list, a path) may take. */\nconst quickMs = 60_000;\n/** How long elan may take to install the toolchain: a 600 MB download and 2.8 GB unpacked. */\nconst toolchainInstallMs = 60 * 60_000;\n\nconst exec: Exec = (command, args, options = {}) =>\n new Promise((resolve) => {\n let child: ReturnType<typeof spawn>;\n try {\n child = spawn(command, args, {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.env === undefined ? {} : { env: { ...process.env, ...options.env } }),\n });\n } catch (err) {\n resolve({ code: null, stdout: \"\", stderr: String(err) });\n return;\n }\n let stdout = \"\";\n let stderr = \"\";\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGKILL\");\n }, options.timeoutMs ?? quickMs);\n child.stdout?.on(\"data\", (d: Buffer) => {\n stdout += d.toString();\n });\n child.stderr?.on(\"data\", (d: Buffer) => {\n stderr += d.toString();\n });\n child.on(\"error\", (err) => {\n clearTimeout(timer);\n resolve({ code: null, stdout, stderr: `${stderr}${String(err)}` });\n });\n child.on(\"close\", (code) => {\n clearTimeout(timer);\n resolve(\n timedOut\n ? { code: null, stdout, stderr: `${stderr}timed out`, timedOut: true }\n : { code, stdout, stderr },\n );\n });\n });\n\n/** The last lines of a command's error output, for a message. */\nconst tail = (text: string): string => text.trim().split(\"\\n\").slice(-5).join(\"\\n\");\n\nexport interface LeanInstallOptions {\n readonly host?: Host;\n /** Refused: Lean comes through elan, from its own host. */\n readonly from?: string;\n /** How to download elan's installer, for tests; the global `fetch` otherwise. */\n readonly fetch?: typeof fetch;\n readonly progress?: (text: string) => void;\n /** How to run elan, for tests. */\n readonly exec?: Exec;\n /** The digests to check against, for tests; `leanDigests` otherwise. */\n readonly digests?: Readonly<Partial<Record<Platform, string>>>;\n /** The elan installer to fetch, for tests; `elanDownloads` otherwise. */\n readonly elanInstaller?: Toolchain;\n}\n\n/**\n * Lean through elan. The result's `file` is the toolchain's name, `source`\n * the elan that installed it, `sha256` the digest of the toolchain's files,\n * `bytes` their size and `dir` the toolchain's directory.\n */\nexport async function installLean(options: LeanInstallOptions = {}): Promise<InstallResult> {\n const h = options.host ?? host();\n const platform = platformOf(h);\n const expected = platform === undefined ? undefined : (options.digests ?? leanDigests)[platform];\n if (platform === undefined || expected === undefined)\n throw new InstallError(\n `no lean ${leanVersion} toolchain for ${h.platform}-${h.arch}; the platforms are ${platforms.join(\", \")}`,\n );\n if (options.from !== undefined)\n throw new InstallError(\n `--from applies to smt only: Lean is installed by elan, which downloads it from releases.lean-lang.org; offline, unpack Lean's release by hand and register it with elan toolchain link`,\n );\n const run = options.exec ?? exec;\n const say = options.progress ?? (() => {});\n let elan: Elan | undefined;\n for (const candidate of elanCandidates(h)) {\n if ((await run(candidate.command, [\"--version\"], { env: candidate.env })).code === 0) {\n elan = candidate;\n break;\n }\n }\n if (elan === undefined) {\n const installer = await installToolchain({\n toolchain: options.elanInstaller ?? elanDownloads,\n host: h,\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n ...(options.progress === undefined ? {} : { progress: options.progress }),\n });\n const home = elanHome(h);\n say(`installing elan ${elanVersion} in ${home}`);\n const made = await run(\n installer.executable,\n [\"-y\", \"--no-modify-path\", \"--default-toolchain\", \"none\"],\n { env: { ELAN_HOME: home }, timeoutMs: 10 * 60_000 },\n );\n elan = elanCandidates(h)[0] as Elan;\n if (made.code !== 0 || (await run(elan.command, [\"--version\"], { env: elan.env })).code !== 0)\n throw new InstallError(\n `elan's installer did not install elan in ${home} (exit ${made.code}): ${tail(made.stderr)}`,\n );\n }\n const list = await run(elan.command, [\"toolchain\", \"list\"], { env: elan.env });\n // Without the list it is unknown whether the toolchain was there, and so whether it is the\n // user's: stop rather than guess, since a mismatch would uninstall what this run installed.\n if (list.code !== 0)\n throw new InstallError(\n `elan (${elan.command}) could not list its toolchains (exit ${list.code}): ${tail(list.stderr)}`,\n );\n const had = list.stdout.split(\"\\n\").some((line) => line.trim().split(\" \")[0] === leanToolchain);\n if (!had) {\n say(\n `installing ${leanToolchain} through ${elan.command} (about 600 MB to download, 2.8 GB unpacked)`,\n );\n const installed = await run(elan.command, [\"toolchain\", \"install\", leanToolchain], {\n env: elan.env,\n timeoutMs: toolchainInstallMs,\n });\n if (installed.code !== 0)\n throw new InstallError(\n `elan could not install ${leanToolchain} (exit ${installed.code}): ${tail(installed.stderr)}`,\n );\n }\n // Where it is, asked of elan without running anything from the toolchain, which is not checked\n // yet: `elan which` in a directory whose lean-toolchain file names it gives its `lean`'s path.\n const pinned = mkdtempSync(join(tmpdir(), \"eutaxy-lean-toolchain-\"));\n let where: ExecResult;\n try {\n writeFileSync(join(pinned, \"lean-toolchain\"), `${leanToolchain}\\n`);\n // ELAN_TOOLCHAIN, if the caller set one, would win over the file: name the pinned one there too.\n where = await run(elan.command, [\"which\", \"lean\"], {\n env: { ...elan.env, ELAN_TOOLCHAIN: leanToolchain },\n cwd: pinned,\n });\n } finally {\n rmSync(pinned, { recursive: true, force: true });\n }\n const leanPath = where.stdout.trim();\n const prefix = dirname(dirname(leanPath));\n if (where.code !== 0 || !/[\\\\/]bin[\\\\/]lean(\\.exe)?$/.test(leanPath) || !existsSync(prefix))\n throw new InstallError(\n `elan has ${leanToolchain} but did not say where (exit ${where.code}): ${tail(where.stderr) || leanPath}`,\n );\n say(`checking the files of ${leanToolchain} in ${prefix}`);\n const found = toolchainDigest(prefix);\n // An elan built for the other architecture of this system (x64 under Rosetta, say) installs the\n // pinned release for its own; that toolchain runs here too, so it is accepted, and said.\n const digests = options.digests ?? leanDigests;\n const sameSystem = Object.entries(digests).find(\n ([p, d]) => d === found.digest && p.startsWith(`${h.platform}-`),\n )?.[0];\n if (sameSystem !== undefined && sameSystem !== platform)\n say(\n `the toolchain is the pinned release for ${sameSystem}, the architecture ${elan.command} installs for, not ${platform}; it runs here too`,\n );\n if (sameSystem === undefined) {\n // Only a toolchain this run installed is removed; one that was already there is the user's.\n let fate = \"it was there before this command, so it was left as it is\";\n if (!had) {\n const removed = await run(elan.command, [\"toolchain\", \"uninstall\", leanToolchain], {\n env: elan.env,\n });\n fate =\n removed.code === 0\n ? \"it was uninstalled\"\n : `uninstalling it failed (exit ${removed.code}): remove it with elan toolchain uninstall ${leanToolchain}`;\n }\n throw new InstallError(\n `the toolchain in ${prefix} is not the pinned ${leanToolchain}: the digest of its files is ${found.digest}, expected ${expected}; ${fate}`,\n );\n }\n return {\n name: \"lean\",\n version: leanVersion,\n platform,\n file: leanToolchain,\n source: elan.command,\n sha256: found.digest,\n bytes: found.bytes,\n dir: prefix,\n executable: join(prefix, \"bin\", h.platform === \"win32\" ? \"lean.exe\" : \"lean\"),\n downloaded: !had,\n };\n}\n\nexport interface RunInstallOptions {\n readonly engine: Engine;\n readonly from?: string | undefined;\n readonly json: boolean;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n readonly host?: Host;\n readonly fetch?: typeof fetch;\n readonly exec?: Exec;\n readonly digests?: Readonly<Partial<Record<Platform, string>>>;\n}\n\n/** The command: the result as text or `--json` on stdout, progress and errors on stderr; exit 0, or 3 on an error. */\nexport async function runInstall(options: RunInstallOptions): Promise<number> {\n try {\n const shared = {\n ...(options.host === undefined ? {} : { host: options.host }),\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n ...(options.from === undefined ? {} : { from: options.from }),\n progress: (text: string) => options.stderr(`${text}\\n`),\n };\n const result =\n options.engine === \"lean\"\n ? await installLean({\n ...shared,\n ...(options.exec === undefined ? {} : { exec: options.exec }),\n ...(options.digests === undefined ? {} : { digests: options.digests }),\n })\n : await installToolchain({ ...shared, toolchain: z3Downloads });\n if (options.json) {\n options.stdout(\n `${JSON.stringify({ schemaVersion: reportSchemaVersion, command: \"prover install\", ...result }, null, 2)}\\n`,\n );\n } else if (options.engine === \"lean\") {\n options.stdout(\n `${result.name} ${result.version} ${result.downloaded ? \"installed\" : \"already installed\"} in ${result.dir}\\n ${result.file} through ${result.source}\\n files checked, digest ${result.sha256}\\n`,\n );\n } else if (result.downloaded) {\n options.stdout(\n `${result.name} ${result.version} installed in ${result.dir}\\n ${result.file} from ${result.source}\\n sha256 ${result.sha256}\\n`,\n );\n } else {\n options.stdout(\n `${result.name} ${result.version} already installed in ${result.dir} (${result.file}, sha256 ${result.sha256})\\n`,\n );\n }\n return exitCodes.BOUNDED;\n } catch (err) {\n if (!(err instanceof InstallError)) throw err;\n options.st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AAG,OAAO,QAAQ,wBAAwB,OAAO,IAAI,IAAI,OAAO,KAAK,WAAW,OAAO,OAAO,IAC/G;EAEF,OAAO,UAAU;CACnB,SAAS,KAAK;EACZ,IAAI,EAAE,eAAe,eAAe,MAAM;EAC1C,QAAQ,OAAO,GAAG,IAAI,QAAQ,GAAG;EACjC,OAAO,UAAU;CACnB;AACF"}
@@ -1,4 +1,4 @@
1
- import { E as EffectLog, d as PinnedSchedule, h as Violation, j as Schedule, n as Platform, o as ScenarioSpec, r as Bounds } from "./platform-CawKCUru.mjs";
1
+ import { E as EffectLog, d as PinnedSchedule, j as Schedule, n as Platform, o as ScenarioSpec, r as Bounds, w as Violation } from "./platform-Cs9V9t2k.mjs";
2
2
  /** How far exploration got: runs, effect points, faults injected and time taken, and coverage when exhaustive. */
3
3
  interface BoundsReached {
4
4
  readonly runs: number;
@@ -80,6 +80,73 @@ interface Unsupported extends VerdictBase {
80
80
  type ScenarioVerdict = Violated | Bounded | Unsupported;
81
81
  /** One line per verdict, for error messages; full rendering lives in `report`. */
82
82
  declare function describeVerdict(v: ScenarioVerdict): string;
83
+ /** How `explore` searches: the seed, a cap on runs, the time budget, the share of runs with faults, and exhaustive mode. */
84
+ interface ExploreOptions {
85
+ readonly seed: number | string;
86
+ /**
87
+ * Hard cap on exploration's runs, in addition to the scenario's time budget. The scenario's pinned
88
+ * schedules run first, each under each of its seeds, uncounted and whatever the budget.
89
+ */
90
+ readonly maxRuns?: number;
91
+ /**
92
+ * Replaces the scenario's `budgetMs` for this exploration: the real time
93
+ * exploring and shrinking may take, and the real time one effect's I/O
94
+ * may take before it counts as hung. With a generous budget and
95
+ * `maxRuns`, the run cap ends exploration, so a seed decides the verdict
96
+ * on any machine.
97
+ */
98
+ readonly budgetMs?: number;
99
+ /**
100
+ * The share of seeded runs after the first (which injects none) that
101
+ * inject faults (see `planFaults`). Default 0.9: the runs without faults
102
+ * also check the scenario as it runs without them, and measure how many
103
+ * eligible points a run without faults has, which can vary with the seed.
104
+ */
105
+ readonly faultProbability?: number;
106
+ /** Clock for the time budget; injectable for tests. */
107
+ readonly now?: () => number;
108
+ /** Hard cap on replay runs spent shrinking a violation. */
109
+ readonly maxShrinkRuns?: number;
110
+ /**
111
+ * How many of the first exploration runs to replay in reverse order
112
+ * before reporting BOUNDED, to detect module-level state leaking between
113
+ * runs. 0 disables the pass.
114
+ */
115
+ readonly leakCheckRuns?: number;
116
+ /**
117
+ * Explore every schedule within the bounds, each once, instead of drawing
118
+ * schedules from the seed: every fault (or none) at every effect point
119
+ * that may still take one, and every order of turns. With `reduction`
120
+ * (the default), turns of different invocations on different targets
121
+ * commute and only one order of them is run.
122
+ */
123
+ readonly exhaustive?: boolean | {
124
+ readonly reduction?: boolean;
125
+ };
126
+ }
127
+ /** What one run of a pinned schedule did. */
128
+ interface PinnedRun {
129
+ readonly log: EffectLog;
130
+ /** The run's schedule as recorded, by invocation and position. */
131
+ readonly schedule: Schedule;
132
+ /** What the run met that the simulation cannot control or replay; empty when nothing. */
133
+ readonly unsupportedReasons: readonly string[];
134
+ /** Each fault of the schedule the run did not place, and why; empty when it placed them all. */
135
+ readonly unplaced: readonly string[];
136
+ }
137
+ /**
138
+ * Run a pinned schedule once, under `seed` (default its first), each fault at the call it names:
139
+ * the replay of an `UNSUPPORTED` verdict's `replay`, or of one of a scenario's pinned schedules.
140
+ */
141
+ declare function runPinned(spec: ScenarioSpec, platform: Platform, pinned: PinnedSchedule, seed?: number): Promise<PinnedRun>;
142
+ /** Re-run a recorded schedule exactly. */
143
+ declare function replay(spec: ScenarioSpec, platform: Platform, schedule: Schedule): Promise<EffectLog>;
144
+ /**
145
+ * Explore a scenario on a platform: run its pinned schedules, then run it under schedules drawn from the
146
+ * seed (or every schedule within the bounds, when exhaustive), shrink the first violation exploration
147
+ * found, and return the verdict. At most 100 runs of exploration unless `maxRuns` says otherwise.
148
+ */
149
+ declare function explore(scenario: ScenarioSpec, platform: Platform, options: ExploreOptions): Promise<ScenarioVerdict>;
83
150
  /**
84
151
  * SpecIR: function specs as plain data. The surface is TypeScript (a spec
85
152
  * file beside the module, `forall(f, { when, ensures })` and `total(f)`
@@ -216,72 +283,5 @@ interface ModuleSpecs {
216
283
  readonly functions: readonly FunctionSpec[];
217
284
  readonly errors: readonly SpecError[];
218
285
  }
219
- /** How `explore` searches: the seed, a cap on runs, the time budget, the share of runs with faults, and exhaustive mode. */
220
- interface ExploreOptions {
221
- readonly seed: number | string;
222
- /**
223
- * Hard cap on exploration's runs, in addition to the scenario's time budget. The scenario's pinned
224
- * schedules run first, each under each of its seeds, uncounted and whatever the budget.
225
- */
226
- readonly maxRuns?: number;
227
- /**
228
- * Replaces the scenario's `budgetMs` for this exploration: the real time
229
- * exploring and shrinking may take, and the real time one effect's I/O
230
- * may take before it counts as hung. With a generous budget and
231
- * `maxRuns`, the run cap ends exploration, so a seed decides the verdict
232
- * on any machine.
233
- */
234
- readonly budgetMs?: number;
235
- /**
236
- * The share of seeded runs after the first (which injects none) that
237
- * inject faults (see `planFaults`). Default 0.9: the runs without faults
238
- * also check the scenario as it runs without them, and measure how many
239
- * eligible points a run without faults has, which can vary with the seed.
240
- */
241
- readonly faultProbability?: number;
242
- /** Clock for the time budget; injectable for tests. */
243
- readonly now?: () => number;
244
- /** Hard cap on replay runs spent shrinking a violation. */
245
- readonly maxShrinkRuns?: number;
246
- /**
247
- * How many of the first exploration runs to replay in reverse order
248
- * before reporting BOUNDED, to detect module-level state leaking between
249
- * runs. 0 disables the pass.
250
- */
251
- readonly leakCheckRuns?: number;
252
- /**
253
- * Explore every schedule within the bounds, each once, instead of drawing
254
- * schedules from the seed: every fault (or none) at every effect point
255
- * that may still take one, and every order of turns. With `reduction`
256
- * (the default), turns of different invocations on different targets
257
- * commute and only one order of them is run.
258
- */
259
- readonly exhaustive?: boolean | {
260
- readonly reduction?: boolean;
261
- };
262
- }
263
- /** What one run of a pinned schedule did. */
264
- interface PinnedRun {
265
- readonly log: EffectLog;
266
- /** The run's schedule as recorded, by invocation and position. */
267
- readonly schedule: Schedule;
268
- /** What the run met that the simulation cannot control or replay; empty when nothing. */
269
- readonly unsupportedReasons: readonly string[];
270
- /** Each fault of the schedule the run did not place, and why; empty when it placed them all. */
271
- readonly unplaced: readonly string[];
272
- }
273
- /**
274
- * Run a pinned schedule once, under `seed` (default its first), each fault at the call it names:
275
- * the replay of an `UNSUPPORTED` verdict's `replay`, or of one of a scenario's pinned schedules.
276
- */
277
- declare function runPinned(spec: ScenarioSpec, platform: Platform, pinned: PinnedSchedule, seed?: number): Promise<PinnedRun>;
278
- /** Re-run a recorded schedule exactly. */
279
- declare function replay(spec: ScenarioSpec, platform: Platform, schedule: Schedule): Promise<EffectLog>;
280
- /**
281
- * Explore a scenario on a platform: run its pinned schedules, then run it under schedules drawn from the
282
- * seed (or every schedule within the bounds, when exhaustive), shrink the first violation exploration
283
- * found, and return the verdict. At most 100 runs of exploration unless `maxRuns` says otherwise.
284
- */
285
- declare function explore(scenario: ScenarioSpec, platform: Platform, options: ExploreOptions): Promise<ScenarioVerdict>;
286
- export { Unsupported as _, runPinned as a, FunctionSpec as c, Property as d, SpecError as f, ScenarioVerdict as g, BoundsReached as h, replay as i, Hint as l, Bounded as m, PinnedRun as n, Arrow as o, SpecType as p, explore as r, Binder as s, ExploreOptions as t, ModuleSpecs as u, Violated as v, describeVerdict as y };
287
- //# sourceMappingURL=explore-D33RP9hF.d.mts.map
286
+ export { Unsupported as _, ModuleSpecs as a, SpecType as c, explore as d, replay as f, ScenarioVerdict as g, BoundsReached as h, Hint as i, ExploreOptions as l, Bounded as m, Binder as n, Property as o, runPinned as p, FunctionSpec as r, SpecError as s, Arrow as t, PinnedRun as u, Violated as v, describeVerdict as y };
287
+ //# sourceMappingURL=ir-KpC2epGn.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir-KpC2epGn.d.mts","names":[],"sources":["../../core/src/verdict.ts","../../engine/src/explore.ts","../../spec/src/ir.ts"],"mappings":";;UASiB;WACN;WACA;WACA;WACA;;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WACA;WACA;;;UAIM;WACN,oBAAoB;WACpB,iBAAiB"}
@@ -0,0 +1,111 @@
1
+ import { c as emitUnsupportedTest, s as emitRegressionTest } from "./src-COuquJvI.mjs";
2
+ // packages/cli/src/regression.ts
3
+ /**
4
+ * Identifiers for binding names: a qualified name (`orders/DB`) becomes
5
+ * `orders_DB`, and a name whose identifier another already took gets a
6
+ * count (`orders_DB_2`), so two imports never share a name.
7
+ */
8
+ function identifiers(names) {
9
+ const taken = /* @__PURE__ */ new Set();
10
+ const out = /* @__PURE__ */ new Map();
11
+ for (const name of names) {
12
+ const base = name.replace(/[^A-Za-z0-9_$]/g, "_");
13
+ let id = base;
14
+ for (let n = 2; taken.has(id); n++) id = `${base}_${n}`;
15
+ taken.add(id);
16
+ out.set(name, id);
17
+ }
18
+ return out;
19
+ }
20
+ /** A binding name as an object key: bare where it is an identifier, quoted otherwise. */
21
+ const key = (binding) => /^[A-Za-z_$][\w$]*$/.test(binding) ? binding : JSON.stringify(binding);
22
+ /** A Vitest regression test for a Cloudflare scenario, to run under the Cloudflare Vitest plugin. */
23
+ function cloudflareRegressionTest(verdict, options) {
24
+ return emitRegressionTest(verdict, {
25
+ ...cloudflareTestParts(options),
26
+ ...options.expect ? { expect: options.expect } : {}
27
+ });
28
+ }
29
+ /**
30
+ * A Vitest test for a Cloudflare scenario that replays the run that made the check `UNSUPPORTED`
31
+ * (see `emitUnsupportedTest`), to run under the Cloudflare Vitest plugin; `expect` is not used.
32
+ */
33
+ function cloudflareUnsupportedTest(verdict, options) {
34
+ return emitUnsupportedTest(verdict, cloudflareTestParts(options));
35
+ }
36
+ /** The imports, the platform and scenario expressions and the observers both kinds of test use. */
37
+ function cloudflareTestParts(options) {
38
+ const bindings = Object.keys(options.schemaPaths).sort();
39
+ const callees = Object.keys(options.callees ?? {}).sort();
40
+ /**
41
+ * Each binding's files, in setup order, each with an identifier of its own: the binding's name for the
42
+ * first, a count after it for the later ones, made unique across all files as `identifiers` does.
43
+ */
44
+ const taken = /* @__PURE__ */ new Set();
45
+ const files = bindings.flatMap((b) => {
46
+ const paths = options.schemaPaths[b] ?? [];
47
+ return (typeof paths === "string" ? [paths] : paths).map((path, i) => {
48
+ const base = (i === 0 ? b : `${b}_${i + 1}`).replace(/[^A-Za-z0-9_$]/g, "_");
49
+ let id = base;
50
+ for (let n = 2; taken.has(id); n++) id = `${base}_${n}`;
51
+ taken.add(id);
52
+ return {
53
+ binding: b,
54
+ path,
55
+ id
56
+ };
57
+ });
58
+ });
59
+ const calleeIds = identifiers(callees);
60
+ const withExports = options.exports === true || options.workflows === true;
61
+ const note = callees.length === 0 || (options.calleeBindings ?? []).length === 0 ? [] : [`// Needs the callees' bindings in this test's isolate under their qualified names: ${(options.calleeBindings ?? []).join(", ")}.`, "// Declare them in the wrangler config, or run this test under the config eutaxy check --keep leaves in .eutaxy/."];
62
+ const envNote = (options.envBindings ?? []).length === 0 ? [] : [
63
+ `// Needs the scenario's vars and secrets in this test's isolate: ${(options.envBindings ?? []).join(", ")}.`,
64
+ "// Give them to the Cloudflare plugin as miniflare: { bindings: { … } } with the values the scenario's setup has,",
65
+ "// or run this test under the config eutaxy check --keep leaves in .eutaxy/."
66
+ ];
67
+ const imports = [
68
+ ...note,
69
+ ...envNote,
70
+ "import { createCloudflarePlatform } from \"eutaxy/cloudflare\";",
71
+ "import { env } from \"cloudflare:workers\";",
72
+ ...options.durableObjects ? ["import * as cloudflareTest from \"cloudflare:test\";"] : [],
73
+ `import scenario from ${JSON.stringify(options.scenarioPath)};`,
74
+ ...files.map((f) => `import schema_${f.id} from ${JSON.stringify(`${f.path}?raw`)};`),
75
+ ...callees.map((b) => `import * as callee_${calleeIds.get(b)} from ${JSON.stringify(options.callees?.[b]?.path)};`),
76
+ withExports ? `import * as worker from ${JSON.stringify(options.workerPath)};` : `import handler from ${JSON.stringify(options.workerPath)};`,
77
+ ...(options.specModules ?? []).map((m, i) => `import * as core_${i} from ${JSON.stringify(m.path)};`)
78
+ ];
79
+ const schemaOf = (b) => {
80
+ const own = files.filter((f) => f.binding === b).map((f) => `schema_${f.id}`);
81
+ return own.length === 1 ? own[0] : `[${own.join(", ")}].join("\\n;\\n")`;
82
+ };
83
+ const schemas = `{ ${bindings.map((b) => `${key(b)}: ${schemaOf(b)}`).join(", ")} }`;
84
+ const calleeOption = callees.length === 0 ? "" : `, callees: { ${callees.map((b) => `${key(b)}: { name: ${JSON.stringify(options.callees?.[b]?.name)}, exports: callee_${calleeIds.get(b)}${options.callees?.[b]?.entrypoint === void 0 ? "" : `, entrypoint: ${JSON.stringify(options.callees?.[b]?.entrypoint)}`}${options.callees?.[b]?.props === void 0 ? "" : `, props: ${JSON.stringify(options.callees?.[b]?.props)}`}${options.callees?.[b]?.self ? ", self: true" : ""} }`).join(", ")} }`;
85
+ const retries = options.maxRetries === void 0 ? "" : `, maxRetries: ${options.maxRetries}`;
86
+ const aliases = options.aliases === void 0 || Object.keys(options.aliases).length === 0 ? "" : `, aliases: ${JSON.stringify(options.aliases)}`;
87
+ const objects = options.durableObjects ? ", durableObjects: cloudflareTest" : "";
88
+ return {
89
+ imports,
90
+ platform: `createCloudflarePlatform({ env, ${withExports ? "handler: worker.default" : "handler"}, schemas: ${schemas}${retries}${objects}${withExports ? ", exports: worker" : ""}${calleeOption}${aliases} })`,
91
+ scenario: options.budgetMs === void 0 ? "scenario" : `{ ...scenario, bounds: { ...scenario.bounds, budgetMs: ${options.budgetMs} } }`,
92
+ ...options.engineModule ? { engineModule: options.engineModule } : {},
93
+ ...options.specModules && options.specModules.length > 0 ? { observe: options.specModules.map((m, i) => ({
94
+ namespace: `core_${i}`,
95
+ functions: m.functions
96
+ })) } : {}
97
+ };
98
+ }
99
+ // packages/cli/src/keys.ts
100
+ /** How the two halves of `eutaxy check` name a module next to the scenario. Imports nothing, so workerd can load it. */
101
+ /** Normalize a module path from a scenario's `specs` to a key: "./domain.ts". */
102
+ function specKey(path) {
103
+ return `./${path.split("\\").join("/").replace(/^(\.\/)+/, "")}`;
104
+ }
105
+ /** The key Vite's `import.meta.glob` gives a path next to the scenario, seen from `.eutaxy/`. */
106
+ function globKey(path) {
107
+ return `.${specKey(path)}`;
108
+ }
109
+ export { cloudflareUnsupportedTest as i, specKey as n, cloudflareRegressionTest as r, globKey as t };
110
+
111
+ //# sourceMappingURL=keys-xtanNmuR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys-xtanNmuR.mjs","names":[],"sources":["../../cli/src/regression.ts","../../cli/src/keys.ts"],"sourcesContent":["import type { Unsupported, Violated } from \"@eutaxy/core\";\nimport {\n emitRegressionTest,\n emitUnsupportedTest,\n type RegressionTestOptions,\n} from \"@eutaxy/report\";\n\n/**\n * What `cloudflareRegressionTest` needs to write the test: import paths of the scenario, the Worker and its\n * schema files, relative to the emitted file, and what the platform was given when the check ran.\n */\nexport interface CloudflareRegressionOptions {\n /** Import path of the scenario module, relative to the emitted file. */\n readonly scenarioPath: string;\n /** Import path of the Worker module. */\n readonly workerPath: string;\n /** D1 binding name to its schema file path, or its files in setup order (joined), imported with `?raw`. */\n readonly schemaPaths: Readonly<Record<string, string | readonly string[]>>;\n /**\n * The time budget the check ran with, when it replaced the scenario's: the\n * replay gets the same, so I/O that finished within it does not time out.\n */\n readonly budgetMs?: number;\n /** The platform's retry limit, when the scenario was checked with a non-default one. */\n readonly maxRetries?: number;\n /** The scenario sets up Durable Objects: pass the Cloudflare test helpers to the platform. */\n readonly durableObjects?: boolean;\n /**\n * Pass the Worker module's exports to the platform: the scenario sets up\n * Workflows (their classes are among them) or drives a named entrypoint.\n */\n readonly exports?: boolean;\n /** @deprecated Use `exports`. */\n readonly workflows?: boolean;\n /**\n * The Workers behind service bindings the scenario names with `callee`, by\n * binding: each one's name from its wrangler config and the import path of\n * its module.\n */\n readonly callees?: Readonly<\n Record<\n string,\n {\n readonly name: string;\n readonly path: string;\n readonly entrypoint?: string;\n readonly props?: Readonly<Record<string, unknown>>;\n /** The callee is the scenario's own Worker, called back by a Worker it called. */\n readonly self?: boolean;\n }\n >\n >;\n /**\n * The qualified names the callees' bindings had in the check's isolate: the\n * replay needs them in its own, so the test says so at its top.\n */\n readonly calleeBindings?: readonly string[];\n /**\n * The vars and secrets the scenario gives a value, by name: the check put them in its isolate, and\n * the replay needs them in its own, so the test says so at its top. Names only: the scenario has\n * the values.\n */\n readonly envBindings?: readonly string[];\n /** Qualified binding names that are aliases of the caller's bindings, passed to the platform. */\n readonly aliases?: Readonly<Record<string, string>>;\n readonly expect?: \"holds\" | \"violates\";\n readonly engineModule?: string;\n /** Core modules to observe during the replay (import path, functions), for `refines`. */\n readonly specModules?: readonly {\n readonly path: string;\n readonly functions: readonly string[];\n }[];\n}\n\n/**\n * Identifiers for binding names: a qualified name (`orders/DB`) becomes\n * `orders_DB`, and a name whose identifier another already took gets a\n * count (`orders_DB_2`), so two imports never share a name.\n */\nfunction identifiers(names: readonly string[]): ReadonlyMap<string, string> {\n const taken = new Set<string>();\n const out = new Map<string, string>();\n for (const name of names) {\n const base = name.replace(/[^A-Za-z0-9_$]/g, \"_\");\n let id = base;\n for (let n = 2; taken.has(id); n++) id = `${base}_${n}`;\n taken.add(id);\n out.set(name, id);\n }\n return out;\n}\n/** A binding name as an object key: bare where it is an identifier, quoted otherwise. */\nconst key = (binding: string): string =>\n /^[A-Za-z_$][\\w$]*$/.test(binding) ? binding : JSON.stringify(binding);\n\n/** A Vitest regression test for a Cloudflare scenario, to run under the Cloudflare Vitest plugin. */\nexport function cloudflareRegressionTest(\n verdict: Violated,\n options: CloudflareRegressionOptions,\n): string {\n return emitRegressionTest(verdict, {\n ...cloudflareTestParts(options),\n ...(options.expect ? { expect: options.expect } : {}),\n });\n}\n\n/**\n * A Vitest test for a Cloudflare scenario that replays the run that made the check `UNSUPPORTED`\n * (see `emitUnsupportedTest`), to run under the Cloudflare Vitest plugin; `expect` is not used.\n */\nexport function cloudflareUnsupportedTest(\n verdict: Unsupported,\n options: CloudflareRegressionOptions,\n): string {\n return emitUnsupportedTest(verdict, cloudflareTestParts(options));\n}\n\n/** The imports, the platform and scenario expressions and the observers both kinds of test use. */\nfunction cloudflareTestParts(\n options: CloudflareRegressionOptions,\n): Omit<RegressionTestOptions, \"expect\"> {\n const bindings = Object.keys(options.schemaPaths).sort();\n const callees = Object.keys(options.callees ?? {}).sort();\n /**\n * Each binding's files, in setup order, each with an identifier of its own: the binding's name for the\n * first, a count after it for the later ones, made unique across all files as `identifiers` does.\n */\n const taken = new Set<string>();\n const files = bindings.flatMap((b) => {\n const paths = options.schemaPaths[b] ?? [];\n return (typeof paths === \"string\" ? [paths] : paths).map((path, i) => {\n const base = (i === 0 ? b : `${b}_${i + 1}`).replace(/[^A-Za-z0-9_$]/g, \"_\");\n let id = base;\n for (let n = 2; taken.has(id); n++) id = `${base}_${n}`;\n taken.add(id);\n return { binding: b, path, id };\n });\n });\n const calleeIds = identifiers(callees);\n const withExports = options.exports === true || options.workflows === true;\n const note =\n callees.length === 0 || (options.calleeBindings ?? []).length === 0\n ? []\n : [\n `// Needs the callees' bindings in this test's isolate under their qualified names: ${(options.calleeBindings ?? []).join(\", \")}.`,\n \"// Declare them in the wrangler config, or run this test under the config eutaxy check --keep leaves in .eutaxy/.\",\n ];\n const envNote =\n (options.envBindings ?? []).length === 0\n ? []\n : [\n `// Needs the scenario's vars and secrets in this test's isolate: ${(options.envBindings ?? []).join(\", \")}.`,\n \"// Give them to the Cloudflare plugin as miniflare: { bindings: { … } } with the values the scenario's setup has,\",\n \"// or run this test under the config eutaxy check --keep leaves in .eutaxy/.\",\n ];\n const imports = [\n ...note,\n ...envNote,\n 'import { createCloudflarePlatform } from \"eutaxy/cloudflare\";',\n 'import { env } from \"cloudflare:workers\";',\n ...(options.durableObjects ? ['import * as cloudflareTest from \"cloudflare:test\";'] : []),\n `import scenario from ${JSON.stringify(options.scenarioPath)};`,\n ...files.map((f) => `import schema_${f.id} from ${JSON.stringify(`${f.path}?raw`)};`),\n ...callees.map(\n (b) =>\n `import * as callee_${calleeIds.get(b)} from ${JSON.stringify(options.callees?.[b]?.path)};`,\n ),\n withExports\n ? `import * as worker from ${JSON.stringify(options.workerPath)};`\n : `import handler from ${JSON.stringify(options.workerPath)};`,\n ...(options.specModules ?? []).map(\n (m, i) => `import * as core_${i} from ${JSON.stringify(m.path)};`,\n ),\n ];\n const schemaOf = (b: string): string => {\n const own = files.filter((f) => f.binding === b).map((f) => `schema_${f.id}`);\n return own.length === 1 ? (own[0] as string) : `[${own.join(\", \")}].join(\"\\\\n;\\\\n\")`;\n };\n const schemas = `{ ${bindings.map((b) => `${key(b)}: ${schemaOf(b)}`).join(\", \")} }`;\n const calleeOption =\n callees.length === 0\n ? \"\"\n : `, callees: { ${callees\n .map(\n (b) =>\n `${key(b)}: { name: ${JSON.stringify(options.callees?.[b]?.name)}, exports: callee_${calleeIds.get(b)}${options.callees?.[b]?.entrypoint === undefined ? \"\" : `, entrypoint: ${JSON.stringify(options.callees?.[b]?.entrypoint)}`}${options.callees?.[b]?.props === undefined ? \"\" : `, props: ${JSON.stringify(options.callees?.[b]?.props)}`}${options.callees?.[b]?.self ? \", self: true\" : \"\"} }`,\n )\n .join(\", \")} }`;\n const retries = options.maxRetries === undefined ? \"\" : `, maxRetries: ${options.maxRetries}`;\n const aliases =\n options.aliases === undefined || Object.keys(options.aliases).length === 0\n ? \"\"\n : `, aliases: ${JSON.stringify(options.aliases)}`;\n const objects = options.durableObjects ? \", durableObjects: cloudflareTest\" : \"\";\n const handler = withExports ? \"handler: worker.default\" : \"handler\";\n const exports = withExports ? \", exports: worker\" : \"\";\n return {\n imports,\n platform: `createCloudflarePlatform({ env, ${handler}, schemas: ${schemas}${retries}${objects}${exports}${calleeOption}${aliases} })`,\n scenario:\n options.budgetMs === undefined\n ? \"scenario\"\n : `{ ...scenario, bounds: { ...scenario.bounds, budgetMs: ${options.budgetMs} } }`,\n ...(options.engineModule ? { engineModule: options.engineModule } : {}),\n ...(options.specModules && options.specModules.length > 0\n ? {\n observe: options.specModules.map((m, i) => ({\n namespace: `core_${i}`,\n functions: m.functions,\n })),\n }\n : {}),\n };\n}\n","/** How the two halves of `eutaxy check` name a module next to the scenario. Imports nothing, so workerd can load it. */\n\n/** Normalize a module path from a scenario's `specs` to a key: \"./domain.ts\". */\nexport function specKey(path: string): string {\n const posix = path\n .split(\"\\\\\")\n .join(\"/\")\n .replace(/^(\\.\\/)+/, \"\");\n return `./${posix}`;\n}\n\n/** The key Vite's `import.meta.glob` gives a path next to the scenario, seen from `.eutaxy/`. */\nexport function globKey(path: string): string {\n return `.${specKey(path)}`;\n}\n"],"mappings":";;;;;;;AA+EA,SAAS,YAAY,OAAuD;CAC1E,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,sBAAM,IAAI,IAAoB;CACpC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,KAAK,QAAQ,mBAAmB,GAAG;EAChD,IAAI,KAAK;EACT,KAAK,IAAI,IAAI,GAAG,MAAM,IAAI,EAAE,GAAG,KAAK,KAAK,GAAG,KAAK,GAAG;EACpD,MAAM,IAAI,EAAE;EACZ,IAAI,IAAI,MAAM,EAAE;CAClB;CACA,OAAO;AACT;;AAEA,MAAM,OAAO,YACX,qBAAqB,KAAK,OAAO,IAAI,UAAU,KAAK,UAAU,OAAO;;AAGvE,SAAgB,yBACd,SACA,SACQ;CACR,OAAO,mBAAmB,SAAS;EACjC,GAAG,oBAAoB,OAAO;EAC9B,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;CACrD,CAAC;AACH;;;;;AAMA,SAAgB,0BACd,SACA,SACQ;CACR,OAAO,oBAAoB,SAAS,oBAAoB,OAAO,CAAC;AAClE;;AAGA,SAAS,oBACP,SACuC;CACvC,MAAM,WAAW,OAAO,KAAK,QAAQ,WAAW,CAAC,CAAC,KAAK;CACvD,MAAM,UAAU,OAAO,KAAK,QAAQ,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK;;;;;CAKxD,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,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