diff --git a/.changeset/gap-cli-daemon-every-read.md b/.changeset/gap-cli-daemon-every-read.md new file mode 100644 index 00000000..c38c4416 --- /dev/null +++ b/.changeset/gap-cli-daemon-every-read.md @@ -0,0 +1,9 @@ +--- +'@tanstack/oracles': patch +--- + +A check through `--daemon` now treats every read as an input of the runs that made it, so after any of these changes it reports what a cold run reports. Before, the daemon reused a run that read the old input. The new inputs are a file that a test reads through `fs` outside the package or under `node_modules`; an environment variable that a test reads (or the set of variable names, when a test lists them); and a file or variable that Vitest, the Vite config, or one of the config's own plugins reads while it loads or in one of its hooks, such as a sidecar file that a plugin writes into the code it transforms. + +The daemon now runs each check in the environment of the CLI that asked for it. A check from another environment, or after a file that the config or a plugin read has changed, starts a new daemon, which still reuses every stored run whose inputs are unchanged. + +Each check now hashes every file input from its content, so an edit that keeps a file's size and modification time, as `cp -p`, `rsync -t`, or `touch -r` leave it, is no longer missed. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index edf59139..cd5b6e2c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -106,12 +106,12 @@ jobs: env: SHARD: ${{ matrix.shard }} test-oracle-gaps-end-to-end: - name: Gap report end-to-end oracle (fixed seed, ${{ matrix.shard }}/3) + name: Gap report end-to-end oracle (fixed seed, ${{ matrix.shard }}/4) runs-on: ubuntu-latest strategy: fail-fast: false matrix: - shard: [1, 2, 3] + shard: [1, 2, 3, 4] steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -119,7 +119,7 @@ jobs: persist-credentials: false - name: Setup Tools uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 - # The end-to-end oracle's fixed-seed units, in three shards. Its random + # The end-to-end oracle's fixed-seed units, in four shards. Its random # units, calibrations, and determinism units run locally. - run: pnpm exec vitest --run --config oracle-gaps/vitest.config.mjs gap-report-oracle -t "$(node scripts/pr-shards.mjs pattern oracle-gaps-fixed-seed "$SHARD")" working-directory: packages/oracles diff --git a/README.md b/README.md index 192c7c9c..ee15f062 100644 --- a/README.md +++ b/README.md @@ -194,40 +194,42 @@ exited with ` and exits 3; after an out-of-memory crash it with `oracle-gaps --stop-daemon --package `. On Windows, which has no process groups, the run is not supervised. - A check through the daemon reuses a run while its inputs are unchanged: - the modules the run loaded, and the files in the package that its tests - read through `fs` (`readFileSync`, `readFile`, `existsSync`, `statSync`, - and `fs/promises` `readFile` and `stat`), each by the content that the - run read. A run that an edit overlapped, because a file changed after the - run read it, is not reused. A directory that a test stats or tests for is - an input as a directory, not by its content. - - Two kinds of input are not tracked yet. A Vite plugin whose output depends - on anything but a module's text, such as a sidecar file that it reads, can - make the daemon serve a run that read the plugin's old output. And the - daemon's environment is fixed when it starts, so an environment variable - that a later check sets does not reach the daemon's runs. After such a - change, run the check cold (without `--daemon`), or stop the daemon with - `oracle-gaps --stop-daemon --package `. The maintainer decided on - 2026-11-13 that the daemon tracks both and restarts when they change; a - later release does that. - - These reads are no input, so an edit to the file alone does not rerun the - tests that read it: a read outside the package or under `node_modules`; a - read from a worker thread or child process that the test starts; and a - read through any `fs` or `fs/promises` function other than the six above, - or through one of those six given a file descriptor. That catch-all - includes, for example, `readdir`, `opendir`, `glob`, `globSync`, - `createReadStream`, `realpath`, `lstat`, `access`, `open`, `read`, - `readSync`, `readv`, `fstat`, `fstatSync`, `copyFile`, `copyFileSync`, `cp`, - `cpSync`, `openAsBlob`, `statfs`, `readlink`, the callback `stat`, - `exists`, `watch`, and `watchFile`, and the `fs/promises` `readdir`, - `opendir`, `glob`, `lstat`, `realpath`, `readlink`, `access`, `open`, - `copyFile`, `cp`, `statfs`, and `watch`. Run the check cold (without - `--daemon`) after an edit to a file read that way. A later release records - all of them except `watch` and `watchFile`, which wait for future changes - and stay no input (maintainer decision, 2026-11-13, with `watchFile` in the - family of `watch`). + A check through the daemon reuses a run while its inputs are unchanged. + Every read is an input (maintainer decision, 2026-11-16): the modules the + run loaded; the files its tests read through `fs` on any path, inside the + package or outside it, `node_modules` included (`readFileSync`, + `readFile`, `existsSync`, `statSync`, and `fs/promises` `readFile` and + `stat`), each by the content that the run read; the environment variables + its tests read, by value, or all of them when a test lists them; and what + Vitest, the Vite config, and the config's own plugins read in the CLI's + process while it loads them and in each plugin hook. Each check hashes + every file input from its content, so an edit that keeps a file's size and + modification time (`cp -p`, `rsync -t`, `touch -r`) is seen. A run that an + edit overlapped, because a file changed after the run read it, is not + reused. A directory that a test stats or tests for is an input as a + directory, not by its content. + + The daemon runs every check in the environment that the CLI asking for it + has. A check from another environment, or after a file that Vitest, the + config, or a plugin read has changed, stops the daemon and starts a new + one, which reads them again; the runs it stored are still reused where + their inputs are unchanged. + + These reads are no input yet, so an edit to the file alone does not rerun + the tests that read it: a read from a worker thread or child process that + the test starts; and a read through any `fs` or `fs/promises` function + other than the six above, or through one of those six given a file + descriptor. That catch-all includes, for example, `readdir`, `opendir`, + `glob`, `globSync`, `createReadStream`, `realpath`, `lstat`, `access`, + `open`, `read`, `readSync`, `readv`, `fstat`, `fstatSync`, `copyFile`, + `copyFileSync`, `cp`, `cpSync`, `openAsBlob`, `statfs`, `readlink`, the + callback `stat`, `exists`, `watch`, and `watchFile`, and the `fs/promises` + `readdir`, `opendir`, `glob`, `lstat`, `realpath`, `readlink`, `access`, + `open`, `copyFile`, `cp`, `statfs`, and `watch`. Run the check cold + (without `--daemon`) after an edit to a file read that way. A later + release records all of them except `watch` and `watchFile`, which wait for + future changes and stay no input (maintainer decision, 2026-11-13, with + `watchFile` in the family of `watch`). - `packages/eslint-plugin-oracles` (`@tanstack/eslint-plugin-oracles`): the `oracle/*` lint rules. The rules recognize the framework by its package diff --git a/packages/oracles/oracle-gaps/capture-setup.mjs b/packages/oracles/oracle-gaps/capture-setup.mjs index ce43e66f..c31dd561 100644 --- a/packages/oracles/oracle-gaps/capture-setup.mjs +++ b/packages/oracles/oracle-gaps/capture-setup.mjs @@ -24,12 +24,12 @@ // In a mutant run, fast-check stops a property at its first failure instead // of shrinking it: a kill needs one failing history, not the smallest one. import { createHash } from 'node:crypto' -import fs, { appendFileSync, readFileSync } from 'node:fs' +import { appendFileSync, readFileSync } from 'node:fs' import { createRequire, syncBuiltinESMExports } from 'node:module' -import { dirname, isAbsolute, join, resolve as resolvePath } from 'node:path' -import { fileURLToPath } from 'node:url' +import { dirname, isAbsolute, join } from 'node:path' import { afterAll, beforeEach, chai, expect, inject, vi } from 'vitest' -import { posix, writeWhole } from './paths.mjs' +import { fileHash, keepProperties, watchReads } from './inputs.mjs' +import { writeWhole } from './paths.mjs' const run = inject(`oracleGaps`) ?? @@ -68,14 +68,7 @@ const realUse = real.use // A wrapper keeps every own property of the function it wraps, such as // `util.promisify.custom`, so `util.promisify(setTimeout)` still resolves -// with its value under the capture (law 3: a test that passes alone passes -// under the CLI). -function keepProperties(from, to) { - for (const key of Reflect.ownKeys(from)) - if (key !== `prototype`) - Object.defineProperty(to, key, Object.getOwnPropertyDescriptor(from, key)) - return to -} +// with its value under the capture (inputs.mjs, keepProperties). // The timers that code in this worker has pending, counted where they are // made, each with when it is next due: Node's resource list does not @@ -274,70 +267,26 @@ function appendClosingRow(row) { writeWhole(`${hold}.${marker}`, ``) appendFileSync(state.capture, row.slice(half)) } -// The files this copy reads through fs inside the package: by a sync, a -// promise, or a callback read, or a check of whether a file exists or what -// it is. The daemon stores the run under them as it does the modules the -// copy evaluated (the closing row's `loaded`), so an edit of only such a -// file runs it again, as a cold run sees the edit (law 9). Reads under -// node_modules and of the runner's own files are left out. Each path keeps -// its hash from the copy's first read of it, taken as the runner hashes an -// input (check.mjs, fileHashes), so the run is stored under the text it -// read and not under an edit that lands later in the run (review of #55, -// F1). +// What this copy reads: each file through fs, on any path, node_modules +// included, by a sync, a promise, or a callback read, or a check of whether +// a file exists or what it is; and each environment variable, or the set of +// names when the copy lists them (inputs.mjs). Every read is a daemon input +// (maintainer decision, 2026-11-16): the daemon stores the run under them as +// it does the modules the copy evaluated (the closing row's `loaded`), so an +// edit of only such an input runs it again, as a cold run sees the edit +// (law 9). A file keeps its hash from the copy's first read of it, so the +// run is stored under the text it read and not under an edit that lands +// later in the run (review of #55, F1). A variable's hash is the runner's, +// from the environment it gives the check (check.mjs, servedHash). A file +// the copy wrote before it read it is its own output, no input. globalThis.__oracleGapsReads = new Map() -if (!globalThis.__oracleGapsReading) { - globalThis.__oracleGapsReading = true - // A read's key follows the gap CLI's path rule (paths.mjs, copied beside - // this file with it). The file system gets the native path. - const root = `${posix(process.cwd()).replace(/\/+$/, ``)}/` - const { readFileSync: readNow, statSync: statNow } = fs - const hashNow = (path) => { - try { - return statNow(path).isFile() - ? createHash(`sha1`).update(readNow(path)).digest(`hex`) - : `not a file` - } catch { - return `missing` - } - } - const record = (target) => { - let path - try { - if (target instanceof URL) path = fileURLToPath(target) - else if (typeof target === `string`) path = resolvePath(target) - else if (Buffer.isBuffer(target)) path = resolvePath(target.toString()) - } catch { - return - } - if (path === undefined) return - const key = posix(path) - const reads = globalThis.__oracleGapsReads - if ( - key.startsWith(root) && - !key.includes(`/node_modules/`) && - !key.includes(`/.oracle-gaps`) && - !reads.has(key) - ) - reads.set(key, hashNow(path)) - } - // A wrapper keeps the function's own properties (its name and length, - // which code that dispatches on arity reads), so a test that passes alone - // passes under the capture (law 3; review of #55). - for (const [owner, names] of [ - [fs, [`readFileSync`, `readFile`, `existsSync`, `statSync`]], - [fs.promises, [`readFile`, `stat`]], - ]) - for (const name of names) { - const original = owner[name] - owner[name] = keepProperties(original, function (target, ...rest) { - record(target) - return original.call(this, target, ...rest) - }) - } - // An ES module's `import { readFileSync } from 'node:fs'` (and from - // 'node:fs/promises') reads these from now on. - syncBuiltinESMExports() -} +const wrote = new Set() +watchReads((key, write) => { + const reads = globalThis.__oracleGapsReads + if (write) wrote.add(key) + else if (!reads.has(key) && !wrote.has(key)) + reads.set(key, key.startsWith(`fs:`) ? fileHash(key.slice(3)) : null) +}) // A test's own writes to the process's stdout and stderr (a debugging // `process.stdout.write`) go to the run's test-output.log, beside its // capture, not to the CLI's streams, whose every line is a line of the @@ -1122,13 +1071,9 @@ afterAll(() => { // The hash of each file the copy read, from its first read, under its own // key (`fs:`): a test's read of a file is another input than the // module that its context serves from that file, which can differ from - // the file's text (fourth review of #55, F-A2). - const readAt = Object.fromEntries( - [...globalThis.__oracleGapsReads].map(([path, hash]) => [ - `fs:${path}`, - hash, - ]), - ) + // the file's text (fourth review of #55, F-A2). A variable it read has no + // hash here (`env:`, null). + const readAt = Object.fromEntries(globalThis.__oracleGapsReads) appendClosingRow( `${JSON.stringify({ file: thisFile, closed: true, loaded, readAt, ...(skippedCopy ? { skipped: true } : {}) })}\n`, ) diff --git a/packages/oracles/oracle-gaps/check.mjs b/packages/oracles/oracle-gaps/check.mjs index 631b5e8a..8757bb23 100644 --- a/packages/oracles/oracle-gaps/check.mjs +++ b/packages/oracles/oracle-gaps/check.mjs @@ -9,16 +9,21 @@ // units, the ownership, and the options. A cold run computes every unit. The // daemon keeps each unit in its evidence store with the hash of every module // the run imported, as Vitest reports them, and of what was served for each -// instrumented or patched source; a stored unit is reused only while every -// one of those hashes is unchanged. So a check through the daemon reports -// what a cold run reports (the CLI oracle's law 9). Not covered: a file a -// test reads through `fs`, an environment variable other than the seed, and -// a new file that changes how an unchanged import resolves. +// instrumented or patched source, and of every other read the run made: a +// file its tests read through `fs` on any path, a variable they read, and +// what the config and its plugins read in this process (inputs.mjs; every +// read is a daemon input, maintainer decision, 2026-11-16). A stored unit is +// reused only while every one of those hashes is unchanged. So a check +// through the daemon reports what a cold run reports (the CLI oracle's law +// 9). Not covered: a read through another fs API than those inputs.mjs +// watches, one from a worker thread or a child process that a test starts, +// and a new file that changes how an unchanged import resolves. // // A unit's identity also carries the global inputs: this CLI's own files, // the harness, the Vite config and the files it loads, the package's // manifest and the lockfile, the Node version, and the options that change a // run (the seed, the test timeout, and bail). +import { AsyncLocalStorage } from 'node:async_hooks' import { spawn, spawnSync } from 'node:child_process' import { createHash } from 'node:crypto' import { @@ -74,6 +79,7 @@ import { specifierOf, } from './paths.mjs' import { stateDirOf } from './evidence.mjs' +import { envHash, fileHash, watchReads } from './inputs.mjs' import { baselineOf, blockedOr, @@ -162,6 +168,7 @@ const ownFiles = [ `stream.mjs`, `authored.mjs`, `capture-setup.mjs`, + `inputs.mjs`, `paths.mjs`, `evidence.mjs`, `daemon.mjs`, @@ -215,10 +222,53 @@ class KeepOrder { } } -/** Hashes of files by content, memoized by size and modification time. */ +/** + * The config's own plugins, with each hook run under `reading` (openSession), + * so what a hook reads is a session input. A `load` or `transform` hook + * names the module it serves. A plugin is wrapped once; a hook is a function + * or an object with a `handler`, as Vite takes it. + */ +const hooked = new WeakSet() +function pluginHooks(option, reading) { + if (Array.isArray(option)) + return option.map((plugin) => pluginHooks(plugin, reading)) + if (typeof option?.then === `function`) + return option.then((plugin) => pluginHooks(plugin, reading)) + if (option === null || typeof option !== `object` || hooked.has(option)) + return option + hooked.add(option) + for (const [name, hook] of Object.entries(option)) { + const handler = typeof hook === `function` ? hook : hook?.handler + if (typeof handler !== `function`) continue + const at = { load: 0, transform: 1 }[name] + const watched = function (...args) { + const id = at === undefined ? undefined : args[at] + return reading.run( + { + hook: true, + module: + typeof id === `string` + ? `fs:${posix(id.split(`?`)[0])}` + : undefined, + }, + () => handler.apply(this, args), + ) + } + option[name] = + typeof hook === `function` ? watched : { ...hook, handler: watched } + } + return option +} + +/** + * Hashes of files by content, memoized by size and modification time for + * one check (`forget`, which each check calls first): an edit between two + * checks that keeps a file's size and modification time, as `cp -p` leaves + * it, is still seen (D10; the TLA model's weakened-stamp run). + */ function fileHashes() { const memo = new Map() - return (path) => { + const hashOf = (path) => { let stat try { stat = statSync(path) @@ -241,6 +291,8 @@ function fileHashes() { memo.set(path, { stamp, hash }) return hash } + hashOf.forget = () => memo.clear() + return hashOf } /** The lockfile that pins the package's dependencies, if any. */ @@ -439,11 +491,52 @@ export async function openSession(pkg) { `the TypeScript this CLI depends on (${ts.version}) has no compiler API`, `Reinstall @tanstack/oracles, which depends on TypeScript 5.`, ) + // What Vitest, the config, and the config's own plugins read in this + // process (`reading`): every plugin input is a daemon input (maintainer + // decision, 2026-11-16, "All of them"). What Vitest and Vite read while + // Vitest loads and while a context warms (`warmReads`, some hundred files + // and variables) is a global input of every unit (globalKey). What a hook + // of the config's own plugins reads (`hookReads`, pluginHooks), at any + // time, is an input of every unit that settles after it, with its hash + // from that read (settleIn). A daemon whose session read a file that has + // changed since is replaced (inputsChanged, daemon.mjs), since a plugin or + // a module may keep what it read. A load or transform hook's read of the + // module it serves is that module's own text, the module's input already. + // A file that the session wrote there before it read it, such as the + // config Vite bundles into a temporary file, is the session's own output. + // So is a variable that the CLI set (ORACLE_GAPS_STATE, which names each + // check's output). A read that comes after its warm ended, from work the + // warm left behind, is a hook's read, so the global inputs stay those of + // the warm itself. + const warmReads = new Map() + const hookReads = new Map() + const wrote = new Set() + const reading = new AsyncLocalStorage() + watchReads((key, write) => { + const at = reading.getStore() + if (write && key.startsWith(`env:`)) wrote.add(key) + const reads = at?.hook || at?.done ? hookReads : warmReads + if (at === undefined || key === at.module || reads.has(key)) return + if (write) wrote.add(key) + else if (!wrote.has(key)) + reads.set(key, key.startsWith(`fs:`) ? fileHash(key.slice(3)) : null) + }) + // Runs `work` as a warm under `reading`. + const warming = async (work) => { + const at = {} + try { + return await reading.run(at, work) + } finally { + at.done = true + } + } + globalThis.__oracleGapsPluginHooks = (plugins) => + pluginHooks(plugins, reading) const requireTarget = createRequire(join(pkg, `package.json`)) let createVitest try { - ;({ createVitest } = await import( - pathToFileURL(requireTarget.resolve(`vitest/node`)).href + ;({ createVitest } = await warming( + () => import(pathToFileURL(requireTarget.resolve(`vitest/node`)).href), )) } catch (error) { throw new Refusal( @@ -481,7 +574,9 @@ export async function openSession(pkg) { writeFileSync(join(home, `host`), hostname()) const harness = join(home, `capture-setup.mjs`) copyFileSync(join(here, `capture-setup.mjs`), harness) - // The harness imports the path rule beside it (capture-setup.mjs). + // The harness imports the input rule and the path rule beside it + // (capture-setup.mjs). + copyFileSync(join(here, `inputs.mjs`), join(home, `inputs.mjs`)) copyFileSync(join(here, `paths.mjs`), join(home, `paths.mjs`)) // One wrapper config per context, over the package's own config (a path // relative to the package, or undefined for none). Each serves its own @@ -521,6 +616,8 @@ export default async (env) => { const loaded = typeof base === 'function' ? await base(env) : await base if (loaded === null || typeof loaded !== 'object') throw new Error(${JSON.stringify(`${config ?? `the config`}: config must export or return an object.`)}) + // The config's own plugins, whose hooks' reads are inputs (check.mjs, pluginHooks). + if (loaded.plugins !== undefined) loaded.plugins = globalThis.__oracleGapsPluginHooks(loaded.plugins) const merged = mergeConfig(loaded, { plugins: [{ name: 'oracle-gaps-schemata', @@ -586,6 +683,8 @@ export default async (env) => { // module by the text that its context serves. const servedHash = (path, index) => { if (path.startsWith(`fs:`)) return hashOf(path.slice(3)) + // A variable by its value in the environment this check runs under. + if (path.startsWith(`env:`)) return envHash(path.slice(4)) const text = globalThis.__oracleGapsServe[index]?.get(path) ?? globalThis.__oracleGapsSchemata.get(path) @@ -726,7 +825,12 @@ export default async (env) => { await new Promise((resolve) => service.on(`exit`, resolve)) throw new Error(`The service was stopped`) } - async function warmContext(settings, index) { + // A context warms under `reading` (see warmReads): what its config, Vite, + // and Vitest read while it warms is a global input. + function warmContext(settings, index) { + return warming(() => warmIn(settings, index)) + } + async function warmIn(settings, index) { await fromConfig(index, settings.config, warmProbe()) writeWrapper(index, settings.config) // A context that fails to open gives its listener allowance back: one @@ -751,6 +855,10 @@ export default async (env) => { teardownTimeout: settings.testTimeout, typecheck: { enabled: false }, coverage: { enabled: false }, + // The runner orders the files itself (KeepOrder), so Vitest's + // results cache, which it reads when a context warms and writes + // after each run, would only be an input that every run changes. + cache: false, // Vitest 5 caches transformed modules on disk by default, keyed by // the file, not by what this runner's plugin serves for it, so a // patched or instrumented source could come back as an earlier text. @@ -1493,6 +1601,8 @@ export default async (env) => { } async function check(options, store, log = console.error) { + // Each check hashes every input from its text (fileHashes). + hashOf.forget() const authored = options.mutants ? loadAuthored(options.mutants) : [] seedVariable = `${options.envPrefix}_SEED` if (options.hangLimit > options.mutantLimit) @@ -1612,6 +1722,9 @@ export default async (env) => { ] .sort() .map((file) => [file, hashOf(file)]), + // What Vitest, Vite, and the config read while Vitest loaded and the + // contexts warmed (warmReads), each by its value now. + [...warmReads.keys()].sort().map((key) => [key, servedHash(key)]), process.version, options.seed ?? null, settings, @@ -1671,11 +1784,19 @@ export default async (env) => { // its context's transform of it, or else its hash at the start, or now. // A path that changed while the run ran is invalidated, and the run is // not stored (undefined); nor is a run with no known input. - function settleIn(context, started, paths, readAt = {}) { + function settleIn(context, started, runPaths, runReadAt = {}) { const index = indexOf.get(context) const served = servedBy(index) const loads = globalThis.__oracleGapsLoads[index] - let stable = paths.length > 0 + let stable = runPaths.length > 0 + // What the config's plugins have read so far, each with its hash from + // its read: the run may have read through any of it (see hookReads). + // A variable that the CLI set (`wrote`) is its own output, which a + // copy may read too (the harness's fallback read of ORACLE_GAPS_STATE). + const paths = [...new Set([...runPaths, ...hookReads.keys()])].filter( + (path) => !wrote.has(path), + ) + const readAt = { ...Object.fromEntries(hookReads), ...runReadAt } const inputs = paths.map((path) => { const now = servedHash(path, index) const hash = @@ -2638,7 +2759,16 @@ export default async (env) => { rmSync(home, { recursive: true, force: true }) } - return { check, close } + /** + * Whether a file the session read (warmReads, hookReads) holds other text now: a + * daemon then serves no more checks, since a plugin or a module may keep + * what it read (daemon.mjs). + */ + const inputsChanged = () => + [...warmReads, ...hookReads].some( + ([key, hash]) => key.startsWith(`fs:`) && fileHash(key.slice(3)) !== hash, + ) + return { check, close, inputsChanged } } /** diff --git a/packages/oracles/oracle-gaps/daemon.mjs b/packages/oracles/oracle-gaps/daemon.mjs index 71837dba..3bcfdda7 100644 --- a/packages/oracles/oracle-gaps/daemon.mjs +++ b/packages/oracles/oracle-gaps/daemon.mjs @@ -182,7 +182,13 @@ export async function requestDaemon(pkg, argv, code) { let reply const sent = Date.now() try { - reply = await send(pkg, { argv, cwd: process.cwd(), code }) + // The CLI's environment, which the daemon must run the check under. + reply = await send(pkg, { + argv, + cwd: process.cwd(), + code, + env: process.env, + }) held += Date.now() - sent } catch (error) { if (!absent(error)) throw error @@ -311,7 +317,13 @@ async function takeLock(lock, socket) { } } +// An environment as one value: its names and values, in name order. +const envKey = (env) => JSON.stringify(Object.entries(env ?? {}).sort()) + async function serve(pkg) { + // The environment this daemon runs its checks under, which the CLI that + // started it gave it, taken before the session sets anything in it. + const ownEnv = envKey(process.env) mkdirSync(stateDirOf(pkg), { recursive: true }) const lock = join(stateDirOf(pkg), `daemon.lock`) const socket = socketOf(pkg) @@ -396,8 +408,18 @@ async function serve(pkg) { // A daemon whose code changed, or that a CLI of other code asks (a // second install), declines this check and closes after the // requests already queued, each of which hears `closing`; the CLI - // then starts a daemon of its own code. - if (codeIdentity() !== code || message.code !== code) { + // then starts a daemon of its own code. So does a daemon asked from + // another environment than its own, or whose session read a file + // that changed since (check.mjs, inputsChanged): every read is a + // daemon input (maintainer decision, 2026-11-16), and a module or a + // plugin may keep what it read, so the CLI starts a daemon in its own + // environment, which reads them again. + if ( + codeIdentity() !== code || + message.code !== code || + envKey(message.env) !== ownEnv || + session.inputsChanged() + ) { closing = true queue = queue.then(() => shutdown(connection, { restart: true })) return diff --git a/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs b/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs index 8837915b..6196ed39 100644 --- a/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs +++ b/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs @@ -13,10 +13,11 @@ import { rmSync, symlinkSync, unlinkSync, + utimesSync, writeFileSync, } from 'node:fs' import { createRequire } from 'node:module' -import { dirname, join } from 'node:path' +import { dirname, join, posix as posixPath } from 'node:path' import { fileURLToPath } from 'node:url' import fc from 'fast-check' @@ -488,6 +489,11 @@ const edits = [ // `laterSteps` (the generator rule: new draws go last). const laterEdits = [`fsData`, `midrun`] const earlierEdits = edits.filter((edit) => !laterEdits.includes(edit)) +// The edit of the gate input that file b's verdict reads (`inputRead`), +// which flips it between `open` and `shut`. It is drawn in its own field +// (`inputSteps`), after `laterSteps`, so the fields before it draw as they +// did (the generator rule: new draws go last). +const inputEdits = [`inputGate`] // A history's no later edits, one value, so `histories` can take it back // (fc.constant takes back only its own reference). const NO_LATER_STEPS = Object.freeze([]) @@ -497,6 +503,12 @@ const laterStepsOf = (history) => history.witness === false && history.steps != null ? (history.laterSteps ?? []) : [] +// The input edits a history takes after its later edits, by the same rule. +const NO_INPUT_STEPS = Object.freeze([]) +const inputStepsOf = (history) => + history.witness === false && history.steps != null + ? (history.inputSteps ?? []) + : [] // The steps that act on the daemon and change no file. const daemonEvents = new Set([ `restart`, @@ -860,6 +872,46 @@ const drawn = fc.record({ // The batch whose run rejects: a constructed-only field (0 is no fault). Only the constructed history at // the end of the campaign sets it; the take-back below returns it to 0 (the generator rule, extended). rejectBatch: fc.constant(0), + // Every read is a daemon input (maintainer decision, 2026-11-16, "All of + // them"): a file a test reads through fs on any path, node_modules + // included; an environment variable a test reads; and what the config's + // own plugin reads. File b's verdicts also wait on one such gate input, + // which the `inputGate` edit flips between `open` and `shut` (law 9). The + // gate is a JSON file that the test reads with a sync read: in the + // package's tests (`inside`), beside the package and outside it + // (`outside`), or in a package under its node_modules (`module`); or the + // variable GAP_INPUT_GATE (`env`); or a file the config's own plugin + // reads, once when the config resolves (`pluginConfig`) or each time it + // transforms a test file (`pluginTransform`), and writes into the test's + // text. These fields change what a history runs, so they are drawn + // (maintainer decision, 2026-11-16, "Randomness wins"), and last. + inputRead: fc.constantFrom( + `none`, + `none`, + `none`, + `inside`, + `outside`, + `module`, + `env`, + `pluginConfig`, + `pluginTransform`, + ), + // Each write of a gate file keeps its size (`open` and `shut` have one + // length) and gets back one fixed modification time, as `cp -p`, `rsync + // -t`, or `touch -r` leave a file: a cache keyed by size and time cannot + // tell the two texts apart (D10; the TLA model's weakened-stamp run). + keepStamp: fc.constantFrom(false, false, false, true), + // The input edits, which follow a history's steps and later edits. + inputSteps: fc.oneof( + { weight: 3, arbitrary: fc.constant(NO_INPUT_STEPS) }, + { + weight: 1, + arbitrary: fc.array(fc.constantFrom(...inputEdits), { + minLength: 1, + maxLength: 2, + }), + }, + ), }) // The edit sequence over the witness module, the one list of steps that a @@ -926,21 +978,28 @@ const histories = drawn.map( const later = (history.steps ?? []).filter((step) => laterEdits.includes(step), ) - if (later.length === 0) + // An input edit in `steps` moves to `inputSteps` in the same way. + const inputs = (history.steps ?? []).filter((step) => + inputEdits.includes(step), + ) + if (later.length === 0 && inputs.length === 0) return { ...taken, pauseEngages: true, warmReplaced: false, rejectBatch: 0, } - const earlier = history.steps.filter((step) => !laterEdits.includes(step)) + const earlier = history.steps.filter( + (step) => !laterEdits.includes(step) && !inputEdits.includes(step), + ) return { ...taken, pauseEngages: true, warmReplaced: false, rejectBatch: 0, steps: earlier.length > 0 ? earlier : null, - laterSteps: later, + ...(later.length > 0 ? { laterSteps: later } : {}), + ...(inputs.length > 0 ? { inputSteps: inputs } : {}), } }, ) @@ -2944,11 +3003,25 @@ function resolveHistory(history) { template: history.template, fault: history.fault, stability: history.stability, - steps: [...(history.steps ?? []), ...laterStepsOf(history)], + steps: [ + ...(history.steps ?? []), + ...laterStepsOf(history), + ...inputStepsOf(history), + ], pauseEngages: history.pauseEngages !== false, warmReplaced: history.warmReplaced === true, lazyGate: history.lazyGate === true, fsRead: history.fsRead ?? `none`, + // The gate input that file b's verdicts also wait on (`inputRead`), and + // whether each write of a gate file keeps its size and modification time + // (`keepStamp`). + // A plugin's gate needs a config to hold the plugin: with none, file b + // reads no gate. + inputRead: + pluginGated(history) && configOf(history).configPath === undefined + ? `none` + : (history.inputRead ?? `none`), + keepStamp: history.keepStamp === true, // Whether a step edits file b's helper during a check (`midrun`): then // file a loads the helper and holds the test that edits it. midrun: [...(history.steps ?? []), ...laterStepsOf(history)].includes( @@ -4703,6 +4776,77 @@ const dataReads = { ], } +// The gate input of file b's verdicts (`inputRead`): the variable that +// `env` reads, and the file each other kind reads. A gate file holds +// `open` or `shut`, two words of one length, so an edit keeps its size. +const INPUT_GATE_VAR = `GAP_INPUT_GATE` +const gateText = (open) => + `${JSON.stringify({ gate: open ? `open` : `shut` })}\n` +// The modification time, in seconds, that every write of a gate file gets +// back under `keepStamp`. +const GATE_STAMP = 1_700_000_000 +// A fixture path under the directory beside the package (`outsideOf`), +// which is outside it; writeFixture places it there. +const BESIDE = `/` +/** The directory beside the package `dir` that holds its outside files. */ +const outsideOf = (dir) => `${dir}.outside` +const gateFiles = { + inside: `tests/gate.json`, + outside: `${BESIDE}gate.json`, + module: `node_modules/gap-gate/gate.json`, + pluginConfig: `tests/plugin-gate.json`, + pluginTransform: `tests/plugin-gate.json`, +} +/** Whether the gate input is one that the config's own plugin reads. */ +const pluginGated = (history) => + history.inputRead === `pluginConfig` || + history.inputRead === `pluginTransform` +// Whether a test's verdict waits on the gate input. +const inputGated = (plan, file, t) => + plan.inputRead !== `none` && + file === `b` && + t.judges && + t.judgeBy === `verdict` +// How file b reads its gate input, by each kind (`inputRead`). The outside +// file lies in the directory beside the package, named by the package's +// own directory with `.outside` after it. The plugin kinds read the text +// that the config's plugin wrote in place of `__GAP_INPUT_GATE__`. +const readGateFile = (path) => + `const readInput = async () => ({ open: JSON.parse(readGate(${path}, 'utf8')).gate === 'open' })` +const inputReads = { + inside: [ + `import { readFileSync as readGate } from 'node:fs'`, + readGateFile(`new URL('./gate.json', import.meta.url)`), + ], + outside: [ + `import { readFileSync as readGate } from 'node:fs'`, + `import { fileURLToPath as gatePackage } from 'node:url'`, + readGateFile( + `gatePackage(new URL('..', import.meta.url)).replace(/[\\\\/]+$/, '') + '.outside/gate.json'`, + ), + ], + module: [ + `import { readFileSync as readGate } from 'node:fs'`, + readGateFile( + `new URL('../node_modules/gap-gate/gate.json', import.meta.url)`, + ), + ], + env: [ + `const readInput = async () => ({ open: process.env.${INPUT_GATE_VAR} !== 'shut' })`, + ], + pluginConfig: [ + `const readInput = async () => ({ open: __GAP_INPUT_GATE__ === 'open' })`, + ], + pluginTransform: [ + `const readInput = async () => ({ open: __GAP_INPUT_GATE__ === 'open' })`, + ], +} +/** The variables a check of `state` runs with: the gate's, under `env`. */ +const inputEnv = (plan, state) => + plan.inputRead === `env` + ? { [INPUT_GATE_VAR]: state.inputOpen ? `open` : `shut` } + : {} + function oracleTestFile(plan, file) { const sites = sitesOf(plan) const entries = [ @@ -4800,6 +4944,9 @@ function oracleTestFile(plan, file) { `import * as sut from '../src/sut'`, ...(file === `b` ? [`import { strict } from './strict'`] : []), ...(file === `b` && plan.fsRead !== `none` ? dataReads[plan.fsRead] : []), + ...(file === `b` && plan.inputRead !== `none` + ? inputReads[plan.inputRead] + : []), ...stubs, // State that tests of this file share (the `w_shared` witness). `const shared = { value: 0 }`, @@ -4958,7 +5105,7 @@ function oracleTestFile(plan, file) { // A lazy gate is imported only where the output differs, so // the unmutated run never loads it. It is open before any // edit, so the model need not read it. - ` if (${when} && JSON.stringify(${out}) !== ${JSON.stringify(expected)}${lazyGated(plan, file, t) ? ` && (await import('./lazy')).open` : ``}${fsGated(plan, file, t) ? ` && (await readData()).open` : ``}) {`, + ` if (${when} && JSON.stringify(${out}) !== ${JSON.stringify(expected)}${lazyGated(plan, file, t) ? ` && (await import('./lazy')).open` : ``}${fsGated(plan, file, t) ? ` && (await readData()).open` : ``}${inputGated(plan, file, t) ? ` && (await readInput()).open` : ``}) {`, ` g.__oracleVerdict?.({ property: 'fixture-${file}', law: '${t.law}', checkpoint: 'trace' })`, ` throw new Error('violation')`, ` }`, @@ -4976,7 +5123,7 @@ function oracleTestFile(plan, file) { : []), t.asProp ? ` fcTest.prop([fcv.integer({ min: 0, max: 10 })], { numRuns: 20, seed: 1 })('${testName(t, index)}', async (n) => {` - : ` test('${testName(t, index)}', ${(t.hangs && !t.flaky) || t.slow || t.ioWait || t.timed || lazyGated(plan, file, t) || fsGated(plan, file, t) ? `async ` : ``}() => {`, + : ` test('${testName(t, index)}', ${(t.hangs && !t.flaky) || t.slow || t.ioWait || t.timed || lazyGated(plan, file, t) || fsGated(plan, file, t) || inputGated(plan, file, t) ? `async ` : ``}() => {`, ...partsOf(t).flatMap(campaign), ` })`, `})`, @@ -5200,6 +5347,8 @@ const initialState = (plan) => ({ lazyOpen: true, // What `tests/data.json` holds: whether file b's data gate is open. dataOpen: true, + // Whether file b's gate input reads `open` (`inputRead`). + inputOpen: true, // How many mid-run edits have landed (`midrun`). midruns: 0, seed: 1, @@ -5230,16 +5379,34 @@ const PRE_PLUGIN = `{ name: 'gap-pre-rewrite', enforce: 'pre', transform(code, i // memory, so only the runner's own \`load\` can answer for it (review of #103). const LOAD_PLUGIN = `{ name: 'gap-own-load', load(id) { const path = id.split('?')[0]; return path.endsWith('.test.ts') ? readFileSync(path, 'utf8') : undefined } }` +// The config's own plugin that reads the gate file (`inputRead` +// `pluginConfig` or `pluginTransform`) and writes its word in place of +// `__GAP_INPUT_GATE__` in each test file it transforms. It finds the file +// from the config's own location (`gatePath`), not from a root, which a +// config's test root moves. `pluginConfig` reads it once, when the config +// resolves; `pluginTransform` reads it in each transform. +const GATE_READ = `JSON.parse(readGate(gatePath, 'utf8')).gate` +const gatePlugin = (plan) => + `(() => { let gate; return { name: 'gap-input-gate', configResolved() { ${plan.inputRead === `pluginConfig` ? `gate = ${GATE_READ}` : ``} }, transform(code, id) { return id.split('?')[0].endsWith('.test.ts') ? code.replaceAll('__GAP_INPUT_GATE__', JSON.stringify(${plan.inputRead === `pluginConfig` ? `gate` : GATE_READ})) : undefined } } })()` +// The gate file's path from a config at `configPath` (in the package, or in +// its parent, where the package is the directory `pkg`). +const gateFromConfig = (configPath) => + posixPath.relative( + posixPath.dirname(posixPath.join(`/pkg`, configPath)), + `/pkg/tests/plugin-gate.json`, + ) + /** * The text of the package's config, in its syntax (`configOf`), with the * fault, the top-level await, or the `require` calls the plan holds. `test` * is the config's `test` object. */ -function configText(plan, test) { +function configText(plan, test, configPath = plan.configPath) { const commonjs = plan.configSyntax === `cjs` const plugins = [ ...(plan.prePlugin ? [PRE_PLUGIN] : []), ...(plan.loadPlugin ? [LOAD_PLUGIN] : []), + ...(pluginGated(plan) ? [gatePlugin(plan)] : []), ] const config = `defineConfig(${ { object: ``, function: `() => (`, async: `async () => (`, promise: `` }[ @@ -5268,6 +5435,17 @@ function configText(plan, test) { : [`import { fileURLToPath } from 'node:url'`]), // Only an ES module config has the load plugin (its constructed history). ...(plan.loadPlugin ? [`import { readFileSync } from 'node:fs'`] : []), + ...(pluginGated(plan) + ? commonjs + ? [ + `const { readFileSync: readGate } = require('node:fs')`, + `const gatePath = require('node:path').join(__dirname, '${gateFromConfig(configPath)}')`, + ] + : [ + `import { readFileSync as readGate } from 'node:fs'`, + `const gatePath = new URL('${gateFromConfig(configPath)}', import.meta.url)`, + ] + : []), ...(plan.fault === `configThrows` ? [`throw new Error('the fixture config broke')`] : []), @@ -5452,6 +5630,7 @@ function fixtureFiles(plan, state = initialState(plan)) { [altConfigPath(plan)]: configText( plan, test.replace(`'tests/**/*.test.ts'`, `'tests/a.test.ts'`), + altConfigPath(plan), ), } : {}), @@ -5475,6 +5654,15 @@ function fixtureFiles(plan, state = initialState(plan)) { ...(plan.fsRead !== `none` ? { 'tests/data.json': `${JSON.stringify({ open: state.dataOpen })}\n` } : {}), + // The gate file, which under `keepStamp` gets back one modification + // time each time it is written. + ...(gateFiles[plan.inputRead] === undefined + ? {} + : { + [gateFiles[plan.inputRead]]: plan.keepStamp + ? { text: gateText(state.inputOpen), mtime: GATE_STAMP } + : gateText(state.inputOpen), + }), // A workspace dependency with module state, linked through node_modules. 'deps/state-dep/package.json': manifest({ name: `state-dep`, @@ -5669,6 +5857,11 @@ function removePath(path) { // The paths each fixture directory holds, so a state that lacks a file of // the state before it removes that file. const written = new Map() +// Where a fixture path lies: in the package, or beside it (`BESIDE`). +const placeOf = (dir, path) => + path.startsWith(BESIDE) + ? join(outsideOf(dir), path.slice(BESIDE.length)) + : join(dir, path) function writeFixture(dir, files) { for (const sub of [ `src`, @@ -5682,14 +5875,17 @@ function writeFixture(dir, files) { if (!existsSync(join(dir, `node_modules/state-dep`))) symlinkSync(`../deps/state-dep`, join(dir, `node_modules/state-dep`), `dir`) for (const path of written.get(dir) ?? []) - if (!(path in files)) removePath(join(dir, path)) - for (const [path, text] of Object.entries(files)) { - const at = join(dir, path) + if (!(path in files)) removePath(placeOf(dir, path)) + for (const [path, value] of Object.entries(files)) { + const at = placeOf(dir, path) mkdirSync(dirname(at), { recursive: true }) + // A file may name the modification time it gets back (`keepStamp`). + const text = typeof value?.text === `string` ? value.text : value // An unchanged file keeps its modification time, as in a real package. if (typeof text === `string`) { if (!existsSync(at) || readFileSync(at, `utf8`) !== text) writeFileSync(at, text) + if (value.mtime !== undefined) utimesSync(at, value.mtime, value.mtime) } else if (linkTarget(at) !== text.link) { // A link that a later state points elsewhere is replaced. removePath(at) @@ -5766,6 +5962,7 @@ function applyEdit(state, edit) { : { ...state, strict: !state.strict, midruns: state.midruns + 1 } if (edit === `lazy`) return { ...state, lazyOpen: !state.lazyOpen } if (edit === `fsData`) return { ...state, dataOpen: !state.dataOpen } + if (edit === `inputGate`) return { ...state, inputOpen: !state.inputOpen } if (edit === `seed`) return { ...state, seed: state.seed === 1 ? 2 : 1 } if (edit === `config`) return { ...state, altConfig: !state.altConfig } // A seed no other step uses, so the check has fresh work to be killed in. @@ -5994,6 +6191,10 @@ function readSummary(summary) { export { drawn, NO_LATER_STEPS, + NO_INPUT_STEPS, + inputEdits, + inputEnv, + outsideOf, MIDRUN_EDITORS, captureWitness, outsideRepository, diff --git a/packages/oracles/oracle-gaps/gap-report-oracle.property.test.mjs b/packages/oracles/oracle-gaps/gap-report-oracle.property.test.mjs index 9f0e38dd..85b7ea04 100644 --- a/packages/oracles/oracle-gaps/gap-report-oracle.property.test.mjs +++ b/packages/oracles/oracle-gaps/gap-report-oracle.property.test.mjs @@ -446,8 +446,12 @@ * the check it overlaps must report, for each mutant, what a cold run of * the state before or after the edit reports, and the runner must store no * run under a text it did not read (see the limits). An edit can change a - * file that a test reads through `fs` (`fsData`). Law 9's edits do not - * include an environment variable other than the seed, a new file that changes how an + * file that a test reads through `fs` (`fsData`), and the gate input that + * file b's verdict reads (`inputGate`): a file in the package, outside it, + * or under node_modules, the variable GAP_INPUT_GATE, or a file the config's + * own plugin reads, since every read is a daemon input (maintainer decision, + * 2026-11-16). Law 9's edits do not include another environment variable + * than the seed and the gate's, a new file that changes how an * unchanged import resolves, a change to the Vite config or the installed * packages, or checks at once other than the two that start the daemon. * The harness keeps every global a copy defines configurable, by wrapping @@ -565,6 +569,9 @@ import { HEARTBEAT_MS, FULL_LIMIT_MS, NO_LATER_STEPS, + NO_INPUT_STEPS, + inputEnv, + outsideOf, } from './gap-report-model-oracle.mjs' const here = dirname(fileURLToPath(import.meta.url)) @@ -1578,8 +1585,15 @@ async function incremental(dir, plan, cli, copy, observe, states) { if (!reportText.includes(RUN_LINE)) throw new Error(`the cli edit no longer finds the summary's run line`) const cold = new Map() + // A state is its files, its seed, its CLI, and the variables it sets. const fingerprint = (files, state, other = false) => - JSON.stringify([files, state.seed, state.cliEdited, other]) + JSON.stringify([ + files, + state.seed, + state.cliEdited, + other, + inputEnv(plan, state), + ]) cold.set(fingerprint(fixtureFiles(plan), initialState(plan)), cli) // A cold result without the run identity, which every edit changes, so // that two states compare by what they report. @@ -1651,6 +1665,8 @@ async function incremental(dir, plan, cli, copy, observe, states) { ...configArgs(plan), // After the `config` edit, `--config` names the second config. ...(state.altConfig ? { config: altConfigPath(plan) } : {}), + // The gate variable of this state, when file b's verdicts read one. + env: inputEnv(plan, state), } // The first check may be two at once, which must reach one daemon, and // so are the two after a crash. @@ -1854,6 +1870,17 @@ async function incremental(dir, plan, cli, copy, observe, states) { states.add( `an edit to data read through ${plan.fsRead} changed the cold result`, ) + // An edit of only the gate input that file b's verdicts read, by each + // kind, and one that kept the gate file's size and modification time. + if (step === `inputGate`) { + states.add( + `an edit to the ${plan.inputRead} gate input changed the cold result`, + ) + if (plan.keepStamp && plan.inputRead !== `env`) + states.add( + `an edit that kept a file's size and modification time changed the cold result`, + ) + } // The daemon's previous check cut a run off, so the only context, which // ran every file, was replaced. Whether the replacement read the edited // file again is not observed; the constructed history's order makes it @@ -1985,7 +2012,12 @@ async function incremental(dir, plan, cli, copy, observe, states) { let warm if (!mid) { const [warmRun] = await runClisAtOnce(dir, files, [ - { ...how, daemon: true, outName: `out-warm`, env }, + { + ...how, + daemon: true, + outName: `out-warm`, + env: { ...how.env, ...env }, + }, ]) observe( `retention:warm`, @@ -2002,7 +2034,9 @@ async function incremental(dir, plan, cli, copy, observe, states) { writeFileSync(armMark, ``) } let finished = false - const running = runClisAtOnce(dir, files, [{ ...how, daemon: true, env }]) + const running = runClisAtOnce(dir, files, [ + { ...how, daemon: true, env: { ...how.env, ...env } }, + ]) running.then(() => { finished = true }) @@ -2190,15 +2224,18 @@ async function driver(plan, observe) { budget: plan.budget, cli: plan.cliPath === `spaced` ? copy : here, ...configArgs(plan), + env: { + ...inputEnv(plan, initialState(plan)), + ...(plan.rejectBatch > 0 + ? { ORACLE_GAPS_TEST_REJECT_BATCH: String(plan.rejectBatch) } + : {}), + }, // A rejected batch ends through the internal error's ending, the one ending a history reaches that // names its log, so its output directory's name holds a line break where the platform allows one // (not on win32): its error line and done line must escape it (the register's C entry "The // internal-error line"). ...(plan.rejectBatch > 0 - ? { - env: { ORACLE_GAPS_TEST_REJECT_BATCH: String(plan.rejectBatch) }, - outBreak: process.platform !== `win32`, - } + ? { outBreak: process.platform !== `win32` } : {}), foreign: plan.foreign, } @@ -2818,6 +2855,7 @@ async function driver(plan, observe) { } finally { if (copy) rmSync(copy, { recursive: true, force: true }) removePath(`${dir}.link`) + rmSync(outsideOf(dir), { recursive: true, force: true }) written.delete(dir) dropHook(dir) try { @@ -4381,6 +4419,15 @@ const incrementalStates = [ `two checks started the daemon at once`, `the daemon ran from a path with a space and #`, ] +// The kinds of gate input that file b's verdicts may read (`inputRead`). +const inputKinds = [ + `inside`, + `outside`, + `module`, + `env`, + `pluginConfig`, + `pluginTransform`, +] // Law 9's states that a constructed history of their own reaches, not the // edit sequence: the mid-run edit, and an edit to data a test reads through // fs, by each read. @@ -4398,6 +4445,14 @@ const ownedIncrementalStates = [ `an edit to data read through promise changed the cold result`, `an edit to data read through callback changed the cold result`, `an edit to data read through statDir changed the cold result`, + // Every read is a daemon input (maintainer decision, 2026-11-16): an edit + // of only the gate input that file b's verdicts read, by each kind, and an + // edit that kept the gate file's size and modification time (D10). + ...inputKinds.map( + (kind) => `an edit to the ${kind} gate input changed the cold result`, + ), + `edit inputGate changed the cold result`, + `an edit that kept a file's size and modification time changed the cold result`, ] // The static states (probe structure and ownership through the reference // tree) are gap-report-static-oracle's: it reaches each in every campaign, @@ -4771,7 +4826,7 @@ oracleProperty({ law: { statement: `The gap report enumerates the promised operator mutants, leaves out exactly the probe-only code, discovers every oracle that owns a function's call tree and refuses broken ownership, judges each mutant only by its owners' tests on their registered routes and counts only law verdicts on reproducible routes as kills, which outrank a run that never ends, anchors each mutant by its function and normalized statement, lists every gap and unowned mutant once with consistent counts, keeps keys stable under unrelated edits, reports through one daemon per package what a cold run reports at every state of a sequence of edits, and bounds the runs that confirm a mutant's cut-off copies by one budget per mutant and names each busy mutant in a heartbeat while it runs, leaves nothing in the package and writes nothing where Vitest's include could find it while it runs, leaves no process running once it is stopped, runs the package as Vitest does from any install path and any --source spelling: one instance of each workspace dependency, no refusal over an unbuildable devDependency, child processes for a native addon anywhere in the tree, a capture that a test's builtin spies cannot see, and a refusal of test.projects; leads its report with every test file's baseline, blocks only the mutants a failing oracle file owns and judges the rest, prints every line of its stream with the prefix oracle-gaps: and its kind, one decisive baseline line before any mutant, and a done line last, and every run that does not complete ends, cold or through the daemon, with a refusal that exits 2, prints a refused: block and one fix: directive with no stack trace, and writes the refusal to the run's output directory.`, authority: `The maintainer's decisions in design runs v11, v14, and v19 (2026-11-04 and 2026-11-05), not in this package's records, including that a kill by reach agreement alone is a gap and that an incremental run through the daemon equals a cold one (v19.3); the project's oracle guide on quiet exclusions; the oracle rubric's outcome kinds (ORC-006); the CLI's documented operator list in schemata.mjs; the maintainer's dispositions G1, G2, G4, G5, G6, and G13 of the framework papercut ledger (2026-11-11) and the v20 freeze's namespacing, one-loop, and provisional-report decisions (2026-11-10); the maintainer's request for a greppable stream (2026-11-12, relayed by the coordinator with its decisions of that day: the same prefixes on stdout and stderr, a done line for a stopped run, and no --max-gaps).`, - limits: `Law 12 judges refusals. The one internal error a history reaches is the constructed rejected-batch history (rejectBatch, a test-only fault that rejects a batch's run after its copies are in Vitest's and Vite's state). Its run is judged in this order: the output namespace, process warnings, and config lines, as for any run; then bounded retention, which owes the rejected batch's own line with its state after retirement; then the stream law (law 15) on both streams, as for any run, so its error line and its done line carry the prefix, and no other line does not, which the state \`a run ended in an internal error\` declares; then exit 3 with an internal error's done line last on both streams, no stack frame on stderr, and an error.log in its output directory. What the error.log's stack says is not judged. An internal error that no fault constructs is a completion failure, reported before the stream law; an internal error through the daemon is reached by no history, and its ending is the same function's (endRun), by inspection. The internal error's lines follow the register's C entry "The internal-error line" (2026-11-16): the general law (endsBreach) owes every run that ends through endRun one error line on stderr naming the done line's log, the output directory's error.log, and none on stdout, and owes the supervisor's own exit 3 none. The message's escape is witnessed by the fault's message, which holds a line break and a forged done line after it; the log path's escape only on POSIX, where the rejected batch's output directory holds a line break (a name on win32 cannot). Paths in a completed run's lines (the results note, the done line's report, the test-output note) are escaped the same way, by inspection: no completed history names such a directory. P10's exempt lines (v21.2 P10 and I3) are read by their own shapes (exemptBlocks), never by indentation alone: a baseline failure's indented details, a refusal's block, Node's warning with its \`--trace-warnings\` frames and its hint, V8's fatal block, esbuild's message block, and Vite's own \`[vite]\` line. The V8, traced-warning, and esbuild blocks are calibrated beside our own line with no prefix (the stream calibrations put them before the rejected-batch run's done line, and the law must name our line alone); no generated history prints any of them or a Vite line, and a shape of those tools that exemptBlocks does not name is read as a stray. The stdout summary's exemption is unused and not exercised: the CLI prefixes every summary line (its summary, legend, and function kinds). \`--help\` prints its usage text with no prefix and no done line, exempt by the register's M entry "\`--help\` is exempt" (2026-11-16), and the static oracle's Help law owes exactly that text; \`--stop-daemon\` prints nothing and exits 0, read the same way as a command outside the run protocol (C, pending ratification), and this oracle runs it without observing its streams. A syntax error in a module that the config imports lets the esbuild that Vite bundles configs with print its block before the refusal (trace, Vite 7.3.7, esbuild 0.28.2: \`✘ [ERROR] Unexpected end of file\`, an empty line, \` helper.ts:2:0:\`, the code frame, then the refused block): its lines are exempt by the register's M entry "Other tools' output is exempt" (2026-11-16), the refusal and the done line around them keep the prefix, and no history generates it. Bounded retention reads the hook's lines (retention-hook.mjs). Its count of one line per batch (runner law L2) rests on the index the hook takes when a batch starts, so a CLI that skipped a batch's index and its line together, or that omitted only the line of a check's last batch, keeps the indices 0..n-1 and is not seen; a check that ended before its report (the rejected batch, a stopped run) and a daemon the driver killed are judged for at most one line per index, since the batches they were running at their end owe none. A line's process is told by check.pid, which the check writes, and the driver itself knows only the daemon it killed. The cold store's law (held) counts the entries given to the store's put that a full collection leaves reachable, so a store that kept only a part of an entry (its unit without the entry) is not seen; staleOpen reads Vitest's own close state (closingPromise, set when close starts), so a close that starts and never resolves is the runner oracle's (L8); and a context replaced after a check's last batch is observed only by a later check's first batch through the daemon. The run whose process aborts is declared on every platform. Its win32 witness (process.abort through ORACLE_GAPS_TEST_ABORT_AT, under the win32 supervisor) lands in #79; until then the Windows end-to-end job is non-blocking (C entry (c)). On win32 Node cannot deliver SIGTERM (its kill is TerminateProcess, which ends the process with no stopped line), so the stop states that name SIGTERM are required on POSIX only, and a stop there goes through the CLI's test stop hook and is observed as SIGINT; every SIGINT state stays required on win32. Argument refusals are the static oracle's; the check's rejection of a stack trace, a missing fix, and a wrong exit code is calibrated in the static oracle, through the same refusalBreach, and here only a refused run reported as complete is calibrated, because each calibration here runs real CLI histories. Law 15's stdout gap lines are judged against each completed run's own results.json, by id: the cold run, and each check through the daemon (every step's check and the check that a mid-run edit overlaps); a stopped run and a refusal list no gaps and are not judged so. A line's change is read loosely: its code on one line, whole or cut after a kept part and ended with \`...\`; where the printer cuts (60 code points, kept 57) is the classify oracle's law 8 (\`shortened\`), in-process. A line with any text after its change does not read and fails loudly: the \` (cause: )\` suffix that #99 adds to timeout lines is not read yet, so whichever of #99 and #115 lands second extends readGapLine. Hangs only as an owner test that awaits a promise that never settles, under a 1 s first budget and a 20 s full limit, and a slow run only as two witnesses whose tests wait where the output changed, 3 s in one that then judges and 10 s in two one-test owners of one that does not; busy loops only on instrumented code (cut by the call budget), no slow runs past the full limit that would end, hangs in ordinary or nondeterministic tests, setup errors other than a throw at module load, loops, multi-line conditions, two functions on one line, or await, new, and void statements; nested functions, object-literal methods, accessors, and class-field arrows only where no test calls them (their ownership is the static oracle's); two source files of one package, with no re-exports, namespace imports, or calls into another package; --only only in a stopped run and a partial run of one function's mutants, and no --sample or --diff-base; the baseline's failures only as one failing owner test that throws an error and a setup file that throws, so a baseline law violation's law and counterexample lines are the classify oracle's; a derived class's file is instrumented and its sites are judged as unowned, but no test imports or constructs the class, so its no-mutant and super-region behavior is the static oracle's (in-process), not this oracle's; package configs only as vite.config or vitest.config with one of the extensions .ts, .mts, .cts, .js, .mjs, and .cjs (not every pair), as config/gap-vitest with the same extension through --config, or none, as an object or a sync or async function, with no plugins of their own except one enforce: 'pre' transform that appends a comment to each module of the package (prePlugin) and, in one constructed history, a plugin whose load reads each test file with a sync read (loadPlugin); a plugin whose output depends on anything but the module's text (a sidecar file it reads) and an environment variable that changes between checks are not generated, since the runner tracks neither yet and the daemon's environment is fixed when it starts (F-A1: the maintainer decided on 2026-11-13 that the daemon tracks both and restarts when they change, in the next pull request); and test.projects only as a refusal, and only under the package's own package.json; a config's test.root only in four shapes, each in one constructed history of an ES module config that Vitest discovers, with one owner and one context, where the test files' globs and the setup file are relative to the root (issue #101): the directory that holds the tests, the directory above the package, a directory of the package that holds no test file, and the package's tests as a symbolic link to the directory that holds them (required on every platform, since Windows creates the link as the driver's other links); not under --config, a CommonJS config, test.projects, several contexts with different roots, or a root that is the filesystem's root; the runner serves each copy of a test file by its absolute path, through its pre plugin's load (which answers before the config's own plugins) and through its read of the copy's path for Vitest's pragma read (serveCopies), and histories run copies only in Vite's server environments (node and the pragma's ssr environment): jsdom and happy-dom, Vite's client environment, are not generated (the #103 merge-gate review ran jsdom by hand under all five root shapes, and the copies loaded in each); a top-level await only in an ES module config and require only in a CommonJS one, as Vitest itself loads no other; a --config outside the package is refused by design, through the rule for paths outside the package (args.mjs), and no history generates one; contexts only one, four, or eleven, and process warnings judged only as MaxListenersExceededWarning on the CLI's own stderr (a daemon's process warnings go to its log); a context that fails to open gives back its listener allowance, which no observation shows (a kept allowance only raises the limit, so no warning follows), so that accounting is fixed by inspection; no probe-bound states, so reach agreement's killing of probe mutants is not checked; no gap answers or gate; law 9 judges the witness module's outcome classes along one constructed edit sequence only (a test edit, a helper edit, and a revert), and the budget witness's along one constructed second check with nothing changed, because a generated history with the witness module or the budget witness takes no steps (maintainer decision, 2026-11-11, and the runtime review's P1-a, 2026-11-12; this oracle owns the gap); law 9's edits come between checks, except one, midrun, which lands during a check through the daemon: a test of file a, whose context has loaded file b's helper, rewrites the helper in the baseline's first run of file a, before file b's runs read it, in one context or several; or a test of file b rewrites its own helper, or the data file that its verdict read through a sync fs read, after file b's judged tests read them, in the run that judges with the old text (review of #55, F1); that check must report, for each mutant, what a cold run of the state before the edit or of the state after it reports, and exit as one of them does (third review of #55, F-C), compared per mutant result rather than per file; when file b's own test lands the edit, b's baseline reads the old text and b's mutant runs read the new one, so b's own mutants in that check are not judged, since their results legitimately mix the two texts (maintainer decision, 2026-11-13), while every other mutant there is judged against both cold runs, with the check's exit code, its mutants' keys, and its stream; the stronger follow-up compares each run's raw outcome with the cold outcome of the state that run read; and the next check, with nothing changed, must equal a cold run of the state after the edit, compared for equality of results only, not for what the daemon reused or computed (the runner's rule: a run whose input changed after the run read it is invalidated and not stored, settleIn); a check through the daemon of a state that nothing changed must compute no run that was not cut off, judged where no test reads the clock (F-A, F-A2), and a test's fs read of a file and the module that the context serves from it are two inputs, each under its own hash (F-A2); an edit during a mutant run is not generated, and a file is edited mid-run only by the run's own tests, not by another process at an arbitrary time; a file that a test reads through fs is edited only as one JSON file that file b's verdict reads by a sync, a promise, or a callback read, or by a sync read after it stats its own directory and tests that it exists (statDir: the directory is an input as a directory, not by its content, and is not itself edited), each read first checking that its fs function keeps its own name and length (the runner stores a run under the files in the package that its copy reads with readFileSync, readFile, existsSync, or statSync, or the fs/promises readFile or stat, each with its hash at the copy's first read; a read outside the package or under node_modules, from a worker thread or a child process that a test starts, or through any other fs API, which includes readdir, opendir, glob, globSync, createReadStream, realpath, lstat, access, open, a read through a file descriptor (read, readSync, readv, fstat, fstatSync, and readFileSync or readFile given a file descriptor), copyFile and copyFileSync, cp and cpSync, openAsBlob, statfs, readlink, the callback stat, exists, watch, watchFile, and the fs/promises access, open, and glob, is no input, and none is generated: the maintainer decided on 2026-11-13 that every fs read except watch and watchFile is an input, which a follow-up of #55 implements, and until then this oracle owns the gap); a run cut off by its clock writes no closing row, so it is stored under its file's known inputs only, while a run that spun ends and keeps the inputs it named (F-D); no history makes a cut run read a file that its file's unmutated run does not read, so this is fixed by inspection; a test that rewrites a file it read with the same text makes the next check compute that run again (1 run in the self-edit histories), since the edit changes the file's modification time: the daemon is conservative there, nothing goes stale, and content keys (D10) remove it, with a selfWrite dimension in that pull request; the mid-run marker sits in the daemon's session directory, .oracle-gaps-, whose location predates #55; the runner's hash memo knows a file by its size and modification time, so an edit that keeps both is not seen, and no history makes one (D10, planned in phase 2, A5); law 9's edits leave out other environment variables, new files that change how an unchanged import resolves, Vite config and installed-package changes, and concurrent checks other than two that start the daemon; cut-off charging judged only under one budget; native addons only as a binding.gyp or a prebuilt .node file, not as optional platform packages; daemon races (two CLIs reading one error file, a CLI hearing closing from the failing daemon it started, a reset connection on macOS) fixed by inspection; the runner's copies of the test files exist only in memory, and its harness and Vitest configs sit in the package's .oracle-gaps-, which the next run removes once a killed run has left it (judged after two stopped runs, not after a SIGKILL); a default --out is judged by the static oracle, and these runs name --out in the package; the namespace is checked after each run and, in a stopped run, while the run runs; a slow kill in a later owner, after earlier owners' confirmations spent the budget, becomes a timeout (owner order; not generated); the Vitest 5 path of the copies' pragma read and of the runner is verified from Vitest 5's source only, since the Vitest 5 CI job runs no gap oracle; a batch whose run reports an error outside any test reruns each copy alone (unitsBatch, runAlone) with its first budget, and a copy cut there is kept as a timeout with no confirmation, a defect older than this oracle's budget work that no history reaches (no history has an error outside any test beside a slow copy), recorded here with that trace for the maintainer; stale-session removal is scoped to this host's session directories (a host file), and is not judged across pid namespaces; the stop law covers SIGTERM and SIGINT sent to the CLI, not a SIGKILL of the CLI (its group then ends at the next check of its parent, by inspection) or a signal sent to the daemon, and its witness is one test that spins synchronously and starts one child process; the mutant budget is witnessed as two slow owners whose confirmations pass the --mutant-limit floor, not through its multiple of the owners' unmutated time, and authored mutants have no confirmations to budget; the witness w_slowpair is a wall-clock window, since the CLI's budget has no controlled clock and a fixture cannot see the time the CLI measures for its file: with one-test owner files p and q of measured unmutated time t each (a file first in its context pays the instrumented transform too), a wait W of 10 s, a 20 s --hang-limit and a 15 s --mutant-limit, it tells a budget from none only while (a) its first attempt is cut, W > 1 s + 3t, (b) its two confirmations do not fit the budget, 2W > max(15 s, 10 x 2t), and (c) each would fit its own full limit, W < 20 s + 3t; (b) is the binding one, so it holds while the two files' time stays under about 2 s together (about 1 s each, some 20 times the authoring machine's idle and 5 to 10 times its loaded measurements), and under one budget a run's overhead must stay under 10 s + 3t; CI runners measure 1.5 to 2.3 times the idle machine; beyond that w_slowpair would read not-judged; a heartbeat is owed only where a slow test waits 3 s against a 2 s interval, twice the first budget, so that no copy cut at its first budget beats, and each beat is observed as its mutant and file, not how long or how often it beat; a config only in the package's parent directory is generated one level up, in a temporary directory with no package.json (so its .js or .ts name is CommonJS), as a plain config, one that throws, one with no default export, or one that defines test.projects; a config two or more levels up, or a parent config beside a package config, is not generated, and the order in one directory follows Vitest's configFiles list by inspection; a package with no config lives in a temporary directory, where no parent has a config; a counterexample shrinks through at most six histories, so it can be larger than the smallest that fails; module-level data only as four \`const\` declarations of the main source (an object literal, an array that holds a function, a boolean, and an object of two methods), read in place, with no data imported from another file, destructured, reassigned, or declared as an enum or a default export; the work law only through shortcut witnesses (an early return before a counting loop with a bound twin of ratio 2, and a push beside one that calls String with a bound twin of ratio 1), the early return in tests that reach the clock by each watched path and in tests that wait a turn, a generated test's bound of 1 derived from its plan; probe code is never work (maintainer decision, 2026-11-16), so the model and the capture count no probe-only site, and only a constructed history (a probe branch under a generated test's work bound) reaches a probe branch beside a bound: the fixed seeds' generated histories reach neither that state nor \`killed by a work bound in a generated function\`, which stays measured; work counts are observed only through a bound's ratio and a rise, never as numbers (v21.2 O1), so a counter that skips every site on a probe's line, which drops only the condition sites of an elseIf that run once on both sides, survives (mutant M6, equivalent under these observations), while one that skips every site of a function that holds probe code is killed (M7), and one warm-cache witness whose selection reproduces observations but not work; work is the capture's count of site evaluations per test, so code with no site (a plain assignment, a for...of pass, a builtin's own work) counts nothing and a test's histories are summed, and a test whose work varies between the unmutated runs while its observations agree is not generated. Open Limits, owned by the in-process runner oracle (L1, state \"torn tail at a cut-off read\"; RED: captureLines without the guard): (a) the batch's cut-off read (runBatch's rowsOf after the cut-off) drops a partial last row, and no witness reaches that drop yet, because a copy held half written across the cut-off did not observe its release in the harness; (b) a short fragment on the strict path, which the no-newline mutant does not reach. The strict read after a finished run (a fragment is an internal error) is witnessed by the no-newline mutant. Windows idle gap (recorded, not witnessed): the state \`a hang cut off for idleness\` is required on every platform, and win32 reaches it (run 43683794816, job 132719872988), so it is not platform-scoped. The sampler (capture-setup.mjs) counts a copy idle only after 500 ms with no late tick, no non-quiet handle, utilization at most 5%, and no timer due, so \`every outcome class\` reaches the state only when the sampler sees that window. On win32 the check missed it once (run 43683794816, job 132719872940); the cause is not confirmed (a late tick on a shared runner, or a stdio handle outside \`quiet\` for this file's console output, are the candidates). Its witness, a test-only hold at the hang until the window is seen, is owed, and that is a timing dependency the determinism-under-load rule forbids; the maintainer decides whether it lands before the Windows job becomes blocking.`, + limits: `Law 12 judges refusals. The one internal error a history reaches is the constructed rejected-batch history (rejectBatch, a test-only fault that rejects a batch's run after its copies are in Vitest's and Vite's state). Its run is judged in this order: the output namespace, process warnings, and config lines, as for any run; then bounded retention, which owes the rejected batch's own line with its state after retirement; then the stream law (law 15) on both streams, as for any run, so its error line and its done line carry the prefix, and no other line does not, which the state \`a run ended in an internal error\` declares; then exit 3 with an internal error's done line last on both streams, no stack frame on stderr, and an error.log in its output directory. What the error.log's stack says is not judged. An internal error that no fault constructs is a completion failure, reported before the stream law; an internal error through the daemon is reached by no history, and its ending is the same function's (endRun), by inspection. The internal error's lines follow the register's C entry "The internal-error line" (2026-11-16): the general law (endsBreach) owes every run that ends through endRun one error line on stderr naming the done line's log, the output directory's error.log, and none on stdout, and owes the supervisor's own exit 3 none. The message's escape is witnessed by the fault's message, which holds a line break and a forged done line after it; the log path's escape only on POSIX, where the rejected batch's output directory holds a line break (a name on win32 cannot). Paths in a completed run's lines (the results note, the done line's report, the test-output note) are escaped the same way, by inspection: no completed history names such a directory. P10's exempt lines (v21.2 P10 and I3) are read by their own shapes (exemptBlocks), never by indentation alone: a baseline failure's indented details, a refusal's block, Node's warning with its \`--trace-warnings\` frames and its hint, V8's fatal block, esbuild's message block, and Vite's own \`[vite]\` line. The V8, traced-warning, and esbuild blocks are calibrated beside our own line with no prefix (the stream calibrations put them before the rejected-batch run's done line, and the law must name our line alone); no generated history prints any of them or a Vite line, and a shape of those tools that exemptBlocks does not name is read as a stray. The stdout summary's exemption is unused and not exercised: the CLI prefixes every summary line (its summary, legend, and function kinds). \`--help\` prints its usage text with no prefix and no done line, exempt by the register's M entry "\`--help\` is exempt" (2026-11-16), and the static oracle's Help law owes exactly that text; \`--stop-daemon\` prints nothing and exits 0, read the same way as a command outside the run protocol (C, pending ratification), and this oracle runs it without observing its streams. A syntax error in a module that the config imports lets the esbuild that Vite bundles configs with print its block before the refusal (trace, Vite 7.3.7, esbuild 0.28.2: \`✘ [ERROR] Unexpected end of file\`, an empty line, \` helper.ts:2:0:\`, the code frame, then the refused block): its lines are exempt by the register's M entry "Other tools' output is exempt" (2026-11-16), the refusal and the done line around them keep the prefix, and no history generates it. Bounded retention reads the hook's lines (retention-hook.mjs). Its count of one line per batch (runner law L2) rests on the index the hook takes when a batch starts, so a CLI that skipped a batch's index and its line together, or that omitted only the line of a check's last batch, keeps the indices 0..n-1 and is not seen; a check that ended before its report (the rejected batch, a stopped run) and a daemon the driver killed are judged for at most one line per index, since the batches they were running at their end owe none. A line's process is told by check.pid, which the check writes, and the driver itself knows only the daemon it killed. The cold store's law (held) counts the entries given to the store's put that a full collection leaves reachable, so a store that kept only a part of an entry (its unit without the entry) is not seen; staleOpen reads Vitest's own close state (closingPromise, set when close starts), so a close that starts and never resolves is the runner oracle's (L8); and a context replaced after a check's last batch is observed only by a later check's first batch through the daemon. The run whose process aborts is declared on every platform. Its win32 witness (process.abort through ORACLE_GAPS_TEST_ABORT_AT, under the win32 supervisor) lands in #79; until then the Windows end-to-end job is non-blocking (C entry (c)). On win32 Node cannot deliver SIGTERM (its kill is TerminateProcess, which ends the process with no stopped line), so the stop states that name SIGTERM are required on POSIX only, and a stop there goes through the CLI's test stop hook and is observed as SIGINT; every SIGINT state stays required on win32. Argument refusals are the static oracle's; the check's rejection of a stack trace, a missing fix, and a wrong exit code is calibrated in the static oracle, through the same refusalBreach, and here only a refused run reported as complete is calibrated, because each calibration here runs real CLI histories. Law 15's stdout gap lines are judged against each completed run's own results.json, by id: the cold run, and each check through the daemon (every step's check and the check that a mid-run edit overlaps); a stopped run and a refusal list no gaps and are not judged so. A line's change is read loosely: its code on one line, whole or cut after a kept part and ended with \`...\`; where the printer cuts (60 code points, kept 57) is the classify oracle's law 8 (\`shortened\`), in-process. A line with any text after its change does not read and fails loudly: the \` (cause: )\` suffix that #99 adds to timeout lines is not read yet, so whichever of #99 and #115 lands second extends readGapLine. Hangs only as an owner test that awaits a promise that never settles, under a 1 s first budget and a 20 s full limit, and a slow run only as two witnesses whose tests wait where the output changed, 3 s in one that then judges and 10 s in two one-test owners of one that does not; busy loops only on instrumented code (cut by the call budget), no slow runs past the full limit that would end, hangs in ordinary or nondeterministic tests, setup errors other than a throw at module load, loops, multi-line conditions, two functions on one line, or await, new, and void statements; nested functions, object-literal methods, accessors, and class-field arrows only where no test calls them (their ownership is the static oracle's); two source files of one package, with no re-exports, namespace imports, or calls into another package; --only only in a stopped run and a partial run of one function's mutants, and no --sample or --diff-base; the baseline's failures only as one failing owner test that throws an error and a setup file that throws, so a baseline law violation's law and counterexample lines are the classify oracle's; a derived class's file is instrumented and its sites are judged as unowned, but no test imports or constructs the class, so its no-mutant and super-region behavior is the static oracle's (in-process), not this oracle's; package configs only as vite.config or vitest.config with one of the extensions .ts, .mts, .cts, .js, .mjs, and .cjs (not every pair), as config/gap-vitest with the same extension through --config, or none, as an object or a sync or async function, with no plugins of their own except one enforce: 'pre' transform that appends a comment to each module of the package (prePlugin) and, in one constructed history, a plugin whose load reads each test file with a sync read (loadPlugin); and the gate plugin (inputRead pluginConfig or pluginTransform), which reads a sidecar file of the package once when the config resolves or in each transform of a test file, and writes its word into the test's text (maintainer decision, 2026-11-16, "Every read is a daemon input": every plugin input is a daemon input); a plugin that reads an environment variable, enumerates the environment, or reads through another fs API than the six below is not generated; and test.projects only as a refusal, and only under the package's own package.json; a config's test.root only in four shapes, each in one constructed history of an ES module config that Vitest discovers, with one owner and one context, where the test files' globs and the setup file are relative to the root (issue #101): the directory that holds the tests, the directory above the package, a directory of the package that holds no test file, and the package's tests as a symbolic link to the directory that holds them (required on every platform, since Windows creates the link as the driver's other links); not under --config, a CommonJS config, test.projects, several contexts with different roots, or a root that is the filesystem's root; the runner serves each copy of a test file by its absolute path, through its pre plugin's load (which answers before the config's own plugins) and through its read of the copy's path for Vitest's pragma read (serveCopies), and histories run copies only in Vite's server environments (node and the pragma's ssr environment): jsdom and happy-dom, Vite's client environment, are not generated (the #103 merge-gate review ran jsdom by hand under all five root shapes, and the copies loaded in each); a top-level await only in an ES module config and require only in a CommonJS one, as Vitest itself loads no other; a --config outside the package is refused by design, through the rule for paths outside the package (args.mjs), and no history generates one; contexts only one, four, or eleven, and process warnings judged only as MaxListenersExceededWarning on the CLI's own stderr (a daemon's process warnings go to its log); a context that fails to open gives back its listener allowance, which no observation shows (a kept allowance only raises the limit, so no warning follows), so that accounting is fixed by inspection; no probe-bound states, so reach agreement's killing of probe mutants is not checked; no gap answers or gate; law 9 judges the witness module's outcome classes along one constructed edit sequence only (a test edit, a helper edit, and a revert), and the budget witness's along one constructed second check with nothing changed, because a generated history with the witness module or the budget witness takes no steps (maintainer decision, 2026-11-11, and the runtime review's P1-a, 2026-11-12; this oracle owns the gap); law 9's edits come between checks, except one, midrun, which lands during a check through the daemon: a test of file a, whose context has loaded file b's helper, rewrites the helper in the baseline's first run of file a, before file b's runs read it, in one context or several; or a test of file b rewrites its own helper, or the data file that its verdict read through a sync fs read, after file b's judged tests read them, in the run that judges with the old text (review of #55, F1); that check must report, for each mutant, what a cold run of the state before the edit or of the state after it reports, and exit as one of them does (third review of #55, F-C), compared per mutant result rather than per file; when file b's own test lands the edit, b's baseline reads the old text and b's mutant runs read the new one, so b's own mutants in that check are not judged, since their results legitimately mix the two texts (maintainer decision, 2026-11-13), while every other mutant there is judged against both cold runs, with the check's exit code, its mutants' keys, and its stream; the stronger follow-up compares each run's raw outcome with the cold outcome of the state that run read; and the next check, with nothing changed, must equal a cold run of the state after the edit, compared for equality of results only, not for what the daemon reused or computed (the runner's rule: a run whose input changed after the run read it is invalidated and not stored, settleIn); a check through the daemon of a state that nothing changed must compute no run that was not cut off, judged where no test reads the clock (F-A, F-A2), and a test's fs read of a file and the module that the context serves from it are two inputs, each under its own hash (F-A2); an edit during a mutant run is not generated, and a file is edited mid-run only by the run's own tests, not by another process at an arbitrary time; a file that a test reads through fs is edited only as one JSON file that file b's verdict reads by a sync, a promise, or a callback read, or by a sync read after it stats its own directory and tests that it exists (statDir: the directory is an input as a directory, not by its content, and is not itself edited), each read first checking that its fs function keeps its own name and length (the runner stores a run under the files in the package that its copy reads with readFileSync, readFile, existsSync, or statSync, or the fs/promises readFile or stat, each with its hash at the copy's first read; every read is a daemon input (maintainer decision, 2026-11-16, "All of them"), on any path and under node_modules too, with no package-boundary exception: the gate input (inputRead) is a JSON file that file b's verdict reads with a sync read in the package's tests, beside the package and outside it, or in a package under its node_modules, or the variable GAP_INPUT_GATE, or the gate plugin's sidecar file, and the inputGate edit flips only that input, drawn (maintainer decision, 2026-11-16, "Randomness wins") and in one constructed history per kind; a read from a worker thread or a child process that a test starts, an enumeration of the environment by a test (it is an input as the set of names, and not generated), or a read through any other fs API, which includes readdir, opendir, glob, globSync, createReadStream, realpath, lstat, access, open, a read through a file descriptor (read, readSync, readv, fstat, fstatSync, and readFileSync or readFile given a file descriptor), copyFile and copyFileSync, cp and cpSync, openAsBlob, statfs, readlink, the callback stat, exists, watch, watchFile, and the fs/promises access, open, and glob, is no input, and none is generated: the maintainer decided on 2026-11-13 that every fs read except watch and watchFile is an input, which a follow-up of #55 implements, and until then this oracle owns the gap); a run cut off by its clock writes no closing row, so it is stored under its file's known inputs only, while a run that spun ends and keeps the inputs it named (F-D); no history makes a cut run read a file that its file's unmutated run does not read, so this is fixed by inspection; a test that rewrites a file it read with the same text makes the next check compute that run again (1 run in the self-edit histories), since the edit changes the file's modification time: the daemon is conservative there, nothing goes stale, and content keys (D10) remove it, with a selfWrite dimension in that pull request; the mid-run marker sits in the daemon's session directory, .oracle-gaps-, whose location predates #55; a gate file's edits may keep its size and get back one fixed modification time (keepStamp), as cp -p, rsync -t, or touch -r leave a file, in generated histories and in two constructed ones (the package's file and the plugin's sidecar), so a reuse decided by a file's size and modification time across checks is seen (D10); an edit that keeps both during a check is not generated; law 9's edits leave out environment variables other than the seed and the gate's, new files that change how an unchanged import resolves, Vite config and installed-package changes, and concurrent checks other than two that start the daemon; cut-off charging judged only under one budget; native addons only as a binding.gyp or a prebuilt .node file, not as optional platform packages; daemon races (two CLIs reading one error file, a CLI hearing closing from the failing daemon it started, a reset connection on macOS) fixed by inspection; the runner's copies of the test files exist only in memory, and its harness and Vitest configs sit in the package's .oracle-gaps-, which the next run removes once a killed run has left it (judged after two stopped runs, not after a SIGKILL); a default --out is judged by the static oracle, and these runs name --out in the package; the namespace is checked after each run and, in a stopped run, while the run runs; a slow kill in a later owner, after earlier owners' confirmations spent the budget, becomes a timeout (owner order; not generated); the Vitest 5 path of the copies' pragma read and of the runner is verified from Vitest 5's source only, since the Vitest 5 CI job runs no gap oracle; a batch whose run reports an error outside any test reruns each copy alone (unitsBatch, runAlone) with its first budget, and a copy cut there is kept as a timeout with no confirmation, a defect older than this oracle's budget work that no history reaches (no history has an error outside any test beside a slow copy), recorded here with that trace for the maintainer; stale-session removal is scoped to this host's session directories (a host file), and is not judged across pid namespaces; the stop law covers SIGTERM and SIGINT sent to the CLI, not a SIGKILL of the CLI (its group then ends at the next check of its parent, by inspection) or a signal sent to the daemon, and its witness is one test that spins synchronously and starts one child process; the mutant budget is witnessed as two slow owners whose confirmations pass the --mutant-limit floor, not through its multiple of the owners' unmutated time, and authored mutants have no confirmations to budget; the witness w_slowpair is a wall-clock window, since the CLI's budget has no controlled clock and a fixture cannot see the time the CLI measures for its file: with one-test owner files p and q of measured unmutated time t each (a file first in its context pays the instrumented transform too), a wait W of 10 s, a 20 s --hang-limit and a 15 s --mutant-limit, it tells a budget from none only while (a) its first attempt is cut, W > 1 s + 3t, (b) its two confirmations do not fit the budget, 2W > max(15 s, 10 x 2t), and (c) each would fit its own full limit, W < 20 s + 3t; (b) is the binding one, so it holds while the two files' time stays under about 2 s together (about 1 s each, some 20 times the authoring machine's idle and 5 to 10 times its loaded measurements), and under one budget a run's overhead must stay under 10 s + 3t; CI runners measure 1.5 to 2.3 times the idle machine; beyond that w_slowpair would read not-judged; a heartbeat is owed only where a slow test waits 3 s against a 2 s interval, twice the first budget, so that no copy cut at its first budget beats, and each beat is observed as its mutant and file, not how long or how often it beat; a config only in the package's parent directory is generated one level up, in a temporary directory with no package.json (so its .js or .ts name is CommonJS), as a plain config, one that throws, one with no default export, or one that defines test.projects; a config two or more levels up, or a parent config beside a package config, is not generated, and the order in one directory follows Vitest's configFiles list by inspection; a package with no config lives in a temporary directory, where no parent has a config; a counterexample shrinks through at most six histories, so it can be larger than the smallest that fails; module-level data only as four \`const\` declarations of the main source (an object literal, an array that holds a function, a boolean, and an object of two methods), read in place, with no data imported from another file, destructured, reassigned, or declared as an enum or a default export; the work law only through shortcut witnesses (an early return before a counting loop with a bound twin of ratio 2, and a push beside one that calls String with a bound twin of ratio 1), the early return in tests that reach the clock by each watched path and in tests that wait a turn, a generated test's bound of 1 derived from its plan; probe code is never work (maintainer decision, 2026-11-16), so the model and the capture count no probe-only site, and only a constructed history (a probe branch under a generated test's work bound) reaches a probe branch beside a bound: the fixed seeds' generated histories reach neither that state nor \`killed by a work bound in a generated function\`, which stays measured; work counts are observed only through a bound's ratio and a rise, never as numbers (v21.2 O1), so a counter that skips every site on a probe's line, which drops only the condition sites of an elseIf that run once on both sides, survives (mutant M6, equivalent under these observations), while one that skips every site of a function that holds probe code is killed (M7), and one warm-cache witness whose selection reproduces observations but not work; work is the capture's count of site evaluations per test, so code with no site (a plain assignment, a for...of pass, a builtin's own work) counts nothing and a test's histories are summed, and a test whose work varies between the unmutated runs while its observations agree is not generated. Open Limits, owned by the in-process runner oracle (L1, state \"torn tail at a cut-off read\"; RED: captureLines without the guard): (a) the batch's cut-off read (runBatch's rowsOf after the cut-off) drops a partial last row, and no witness reaches that drop yet, because a copy held half written across the cut-off did not observe its release in the harness; (b) a short fragment on the strict path, which the no-newline mutant does not reach. The strict read after a finished run (a fragment is an internal error) is witnessed by the no-newline mutant. Windows idle gap (recorded, not witnessed): the state \`a hang cut off for idleness\` is required on every platform, and win32 reaches it (run 43683794816, job 132719872988), so it is not platform-scoped. The sampler (capture-setup.mjs) counts a copy idle only after 500 ms with no late tick, no non-quiet handle, utilization at most 5%, and no timer due, so \`every outcome class\` reaches the state only when the sampler sees that window. On win32 the check missed it once (run 43683794816, job 132719872940); the cause is not confirmed (a late tick on a shared runner, or a stdio handle outside \`quiet\` for this file's console output, are the candidates). Its witness, a test-only hold at the hang until the window is seen, is owed, and that is a timing dependency the determinism-under-load rule forbids; the maintainer decides whether it lands before the Windows job becomes blocking.`, }, histories: { // A failing history shrinks through at most six smaller ones. Each runs @@ -6235,6 +6290,97 @@ oracleProperty({ ], }), }, + // Every read is a daemon input (maintainer decision, 2026-11-16, "All + // of them"). File b's verdict also waits on one gate input, and the + // one edit flips only that input from `open` to `shut`: the cold run + // then reports b's mutant as a survivor, and the daemon must not + // reuse a kill that read the open gate (law 9). A second check with + // nothing changed then computes nothing (the `unchanged reuse` law), so + // a daemon that never reuses, which equals a cold run trivially, fails + // too. One history per kind of input, appended last, so the histories + // before them keep their seeds' samples. + ...[ + // A file in the package that the test reads, written back with its + // size and modification time, as `cp -p` leaves it: the daemon must + // see the new text all the same (D10). + [ + `an edit to a file in the package that keeps its size and modification time`, + `inside`, + true, + ], + [ + `an edit to a file outside the package that a test reads`, + `outside`, + false, + ], + [ + `an edit to a file under node_modules that a test reads`, + `module`, + false, + ], + [`an edit to an environment variable that a test reads`, `env`, false], + [ + `an edit to a file the config's plugin reads when the config resolves`, + `pluginConfig`, + false, + ], + // Written back with its size and modification time, too. + [ + `an edit to a file the config's plugin reads when it transforms a test`, + `pluginTransform`, + true, + ], + ].map(([name, inputRead, keepStamp]) => ({ + name, + enters: [ + `edit inputGate changed the cold result`, + `an edit to the ${inputRead} gate input changed the cold result`, + `an unchanged check through the daemon computed nothing`, + ...(keepStamp + ? [ + `an edit that kept a file's size and modification time changed the cold result`, + ] + : []), + ], + build: (generated) => ({ + ...generated, + functions: [[{ kind: `push`, quote: `'` }]], + containers: [], + overloads: [], + owners: [`b`], + library: [], + libraryOwners: [], + runes: [], + derived: null, + dotGen: false, + dataOwners: [], + exportOwners: [], + importer: `none`, + wholeFile: `none`, + template: false, + tests: [{ ...judging(`b`, `fixed seed`, 1), fn: 0 }], + witness: false, + authored: null, + secondAuthored: false, + fault: `none`, + stability: `none`, + ordinary: false, + native: `none`, + boot: false, + cliPath: `plain`, + concurrentStart: false, + lazyGate: false, + fsRead: `none`, + prePlugin: false, + // A config the plugin can sit in, which Vitest discovers. + configPlace: `discovered`, + inputRead, + keepStamp, + laterSteps: NO_LATER_STEPS, + inputSteps: NO_INPUT_STEPS, + steps: [`inputGate`, `recheck`], + }), + })), ]), }, resolve: resolveHistory, diff --git a/packages/oracles/oracle-gaps/gap-report-static-oracle.property.test.mjs b/packages/oracles/oracle-gaps/gap-report-static-oracle.property.test.mjs index e8d30d9f..fd4d79bc 100644 --- a/packages/oracles/oracle-gaps/gap-report-static-oracle.property.test.mjs +++ b/packages/oracles/oracle-gaps/gap-report-static-oracle.property.test.mjs @@ -132,6 +132,7 @@ import { refusalBreach, resolveHistory, removePath, + outsideOf, sourceArgument, caseless, writeFixture, @@ -254,6 +255,7 @@ function defaultOutputsOf(dir, sources) { same: [outs[0] === outs[1], outs[0] === outs[2], outs[1] === outs[2]], } } finally { + rmSync(outsideOf(other), { recursive: true, force: true }) rmSync(other, { recursive: true, force: true }) } } @@ -980,6 +982,7 @@ async function driver(plan, observe) { } finally { written.delete(dir) removePath(`${dir}.link`) + rmSync(outsideOf(dir), { recursive: true, force: true }) rmSync(scratch, { recursive: true, force: true }) } } diff --git a/packages/oracles/oracle-gaps/history-fingerprint.json b/packages/oracles/oracle-gaps/history-fingerprint.json index 20fef659..1dca6243 100644 --- a/packages/oracles/oracle-gaps/history-fingerprint.json +++ b/packages/oracles/oracle-gaps/history-fingerprint.json @@ -57,7 +57,10 @@ ["warmReplaced", "ed6866229ecc4969"], ["testRoot", "e18db063421a75f1"], ["loadPlugin", "ed6866229ecc4969"], - ["rejectBatch", "e5386ea9402dd268"] + ["rejectBatch", "e5386ea9402dd268"], + ["inputRead", "a90da00463cd4e9a"], + ["keepStamp", "45ab5c81233b3182"], + ["inputSteps", "655fde9118d2e219"] ], "histories": [ ["functions", "66c0e9c56951c377"], @@ -117,6 +120,9 @@ ["warmReplaced", "ed6866229ecc4969"], ["testRoot", "e18db063421a75f1"], ["loadPlugin", "ed6866229ecc4969"], - ["rejectBatch", "e5386ea9402dd268"] + ["rejectBatch", "e5386ea9402dd268"], + ["inputRead", "a90da00463cd4e9a"], + ["keepStamp", "45ab5c81233b3182"], + ["inputSteps", "655fde9118d2e219"] ] } diff --git a/packages/oracles/oracle-gaps/inputs.mjs b/packages/oracles/oracle-gaps/inputs.mjs new file mode 100644 index 00000000..bd3f8f03 --- /dev/null +++ b/packages/oracles/oracle-gaps/inputs.mjs @@ -0,0 +1,158 @@ +// What a run reads, as the daemon keys it. Every read is a daemon input +// (maintainer decision, 2026-11-16, "All of them"): a file read through fs +// on any path, node_modules included, an environment variable, and what +// the config's own plugins read. So when one changes between two checks, +// the next check through the daemon reports what a cold run reports (the +// CLI oracle's law 9). +// +// An input's key is `fs:` for a file, hashed by its text (or as +// `not a file`, or `missing`), `env:` for a variable, hashed by its +// value, or `env:*` for the set of names, which code reads when it lists +// the environment. The harness (capture-setup.mjs) watches a test's reads in +// its worker, and the session (check.mjs) watches what the config and its +// plugins read in the CLI's process. Both files are copied beside the +// harness with this one. +import { createHash } from 'node:crypto' +import fs from 'node:fs' +import { syncBuiltinESMExports } from 'node:module' +import { basename, dirname, join, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import { posix } from './paths.mjs' + +// The calls that read a file, and those that test whether it exists and +// what it is. Each is taken once per process, before a wrapper replaces it, +// so hashing a file is not itself a read. +const reads = [ + [fs, [`readFileSync`, `readFile`, `existsSync`, `statSync`]], + [fs.promises, [`readFile`, `stat`]], +] +// The calls that write a file's text. A file that a reader wrote before it +// reads it holds the reader's own output, which follows from the reader's +// other inputs, so that read is no input: a test's temporary file, or the +// config that Vite bundles into a temporary file and then imports. +const writes = [ + [fs, [`writeFileSync`, `writeFile`, `appendFileSync`, `appendFile`]], + [fs.promises, [`writeFile`, `appendFile`]], +] +const original = (globalThis.__oracleGapsOriginalFs ??= { + readFileSync: fs.readFileSync, + statSync: fs.statSync, + realpathSync: fs.realpathSync.native, +}) +const sha1 = (data) => createHash(`sha1`).update(data).digest(`hex`) + +/** + * A file's input hash now, never from a cache: the hash of its text, or + * `not a file` (a test can stat a directory, whose input is that a + * directory is there), or `missing`. + */ +export function fileHash(path) { + try { + return original.statSync(path).isFile() + ? sha1(original.readFileSync(path)) + : `not a file` + } catch { + return `missing` + } +} + +/** A variable's input hash under `env`, or for `*`, that of its names. */ +export const envHash = (name, env = process.env) => + sha1( + name === `*` + ? Object.keys(env).sort().join(`\0`) + : `${env[name] === undefined ? `unset` : `=${env[name]}`}`, + ) + +// The runner's own files: a session directory (`.oracle-gaps-/`, which +// holds this file) and the copies of test files +// (`.oracle-gaps---`). A user's path that only contains +// `.oracle-gaps` is an input like any other. +const isRunnerFile = (path) => /\/\.oracle-gaps-\d+[-/]/.test(path) + +/** + * A wrapper keeps every own property of the function it wraps (its name + * and length, which code that dispatches on arity reads, or + * `util.promisify.custom`), so a test that passes alone passes under the + * capture (law 3; review of #55). + */ +export function keepProperties(from, to) { + for (const key of Reflect.ownKeys(from)) + if (key !== `prototype`) + Object.defineProperty(to, key, Object.getOwnPropertyDescriptor(from, key)) + return to +} + +/** + * Watches this process's reads from now on: each read calls `record(key)` + * with the input's key, and each write of a file or a variable + * `record(key, true)`, the + * `record` of the latest call. The wrappers are + * installed once per process. A file's path is the path rule's (paths.mjs), + * and the runner's own files are left out. An ES module's + * `import { readFileSync } from 'node:fs'` reads the wrappers too. + */ +export function watchReads(record) { + globalThis.__oracleGapsRecord = record + if (globalThis.__oracleGapsWatching) return + globalThis.__oracleGapsWatching = true + record = (key, write) => globalThis.__oracleGapsRecord(key, write) + const watched = (target, write) => { + let path + try { + if (target instanceof URL) path = fileURLToPath(target) + else if (typeof target === `string`) path = resolve(target) + else if (Buffer.isBuffer(target)) path = resolve(target.toString()) + } catch { + return + } + if (path === undefined || isRunnerFile(posix(path))) return + record(`fs:${posix(path)}`, write) + // A written file is also known by its directory's real path, which a + // later read through a link, or an import by its real URL, names. + if (write) + try { + record( + `fs:${posix(join(original.realpathSync(dirname(path)), basename(path)))}`, + write, + ) + } catch { + // No directory to write in: the write fails as it would. + } + } + for (const [calls, write] of [ + [reads, false], + [writes, true], + ]) + for (const [owner, names] of calls) + for (const name of names) { + const call = owner[name] + owner[name] = keepProperties(call, function (target, ...rest) { + watched(target, write) + return call.call(this, target, ...rest) + }) + } + syncBuiltinESMExports() + // A variable read by name, a test of whether it is set, and a listing of + // the names, which reads the set of names. + process.env = new Proxy(process.env, { + get(env, name) { + if (typeof name === `string`) record(`env:${name}`) + return Reflect.get(env, name) + }, + has(env, name) { + if (typeof name === `string`) record(`env:${name}`) + return Reflect.has(env, name) + }, + ownKeys(env) { + record(`env:*`) + return Reflect.ownKeys(env) + }, + // A write goes to the environment itself, which keeps its own rules + // (a value is a string). A variable the reader set is its own output. + set(env, name, value) { + if (typeof name === `string`) record(`env:${name}`, true) + return Reflect.set(env, name, value) + }, + }) +} diff --git a/packages/oracles/scripts/e2e-shards.mjs b/packages/oracles/scripts/e2e-shards.mjs index 30f2d967..a4718c35 100644 --- a/packages/oracles/scripts/e2e-shards.mjs +++ b/packages/oracles/scripts/e2e-shards.mjs @@ -104,6 +104,26 @@ export const shards = { `fixed seed 20261105: an edit to data a test reads through fs (statDir)`, `random seed: an edit to data a test reads through fs (statDir)`, `determinism: constructed history: an edit to data a test reads through fs (statDir)`, + // The daemon-input histories (law 9, every read is a daemon input): about + // 25 s each on the Arca pool, fixed seed. + `fixed seed 20261105: an edit to a file in the package that keeps its size and modification time`, + `random seed: an edit to a file in the package that keeps its size and modification time`, + `determinism: constructed history: an edit to a file in the package that keeps its size and modification time`, + `fixed seed 20261105: an edit to a file outside the package that a test reads`, + `random seed: an edit to a file outside the package that a test reads`, + `determinism: constructed history: an edit to a file outside the package that a test reads`, + `fixed seed 20261105: an edit to a file under node_modules that a test reads`, + `random seed: an edit to a file under node_modules that a test reads`, + `determinism: constructed history: an edit to a file under node_modules that a test reads`, + `fixed seed 20261105: an edit to an environment variable that a test reads`, + `random seed: an edit to an environment variable that a test reads`, + `determinism: constructed history: an edit to an environment variable that a test reads`, + `fixed seed 20261105: an edit to a file the config's plugin reads when the config resolves`, + `random seed: an edit to a file the config's plugin reads when the config resolves`, + `determinism: constructed history: an edit to a file the config's plugin reads when the config resolves`, + `fixed seed 20261105: an edit to a file the config's plugin reads when it transforms a test`, + `random seed: an edit to a file the config's plugin reads when it transforms a test`, + `determinism: constructed history: an edit to a file the config's plugin reads when it transforms a test`, // Added with the CLI's parent-config discovery (not yet measured). `fixed seed 20261105: a package whose parent directory has its config`, `random seed: test.projects in a parent's config`, diff --git a/packages/oracles/scripts/pr-shards.mjs b/packages/oracles/scripts/pr-shards.mjs index a2b88dcb..89007eca 100644 --- a/packages/oracles/scripts/pr-shards.mjs +++ b/packages/oracles/scripts/pr-shards.mjs @@ -26,6 +26,16 @@ import { tmpdir } from 'node:os' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' +// The constructed histories of the edits of each kind of daemon input +// (gap-report-oracle.property.test.mjs). +const daemonInputUnits = [ + 'an edit to a file in the package that keeps its size and modification time', + 'an edit to a file outside the package that a test reads', + 'an edit to a file under node_modules that a test reads', + 'an edit to an environment variable that a test reads', + "an edit to a file the config's plugin reads when the config resolves", + "an edit to a file the config's plugin reads when it transforms a test", +] const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, `\\$&`) const anyOf = (names) => `(?:${names.map(escape).join(`|`)})` const rest = Symbol(`rest`) @@ -318,6 +328,10 @@ export const partitions = { // through the daemon (94 s), brokenOwner (83 s), generated (23 s), the // lazy module (12 s), and small units. 3: rest, + // The edits of a daemon input that every read makes one (maintainer + // decision, 2026-11-16, "Every read is a daemon input"), one unit per + // kind of input. + 4: anyOf(daemonInputUnits), }, }, 'oracle-gaps-static-windows': { @@ -543,6 +557,8 @@ export const partitions = { 'a config whose test root holds no test file', 'a config whose test root is a symbolic link', 'a config whose plugin loads test files with a sync read', + daemonInputUnits[0], + daemonInputUnits[1], ]), 7: anyOf([ 'a daemon pause that cannot engage', @@ -567,6 +583,8 @@ export const partitions = { 'an awaiting config in a package with no module type', 'a declaration fault: configNoDefault', 'a declaration fault: badEntry', + daemonInputUnits[2], + daemonInputUnits[3], ]), 9: anyOf([ 'a lazy module loaded before a hang in the same batch', @@ -579,6 +597,8 @@ export const partitions = { 'a .ts config in a package with no module type that calls require', 'ordinary tests left out by default', 'a declaration fault: configNull', + daemonInputUnits[4], + daemonInputUnits[5], ]), 10: anyOf([ 'an edit that changed the cold result after a hang replaced the only context',