diff --git a/.gitignore b/.gitignore index e852f34b..b0169425 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ coverage # The gap CLI writes scratch packages and state beside the package it checks, # and its oracle writes scratch packages and CLI copies beside itself. /packages/oracles/oracle-gaps/.scratch-* +/packages/oracles/oracle-gaps-sibling-*/ /packages/oracles/oracle-gaps-mutant*/ .oracle-gaps/ .oracle-gaps-* diff --git a/README.md b/README.md index 192c7c9c..867cf5d6 100644 --- a/README.md +++ b/README.md @@ -146,18 +146,21 @@ agent. `ORACLE_GAPS_TEST_PAUSE_MARK` naming a file the blocked process writes its pid to: `daemon-reply` holds a daemon's reply after the check, and `daemon-read` holds its first connection unread, once `ORACLE_GAPS_TEST_PAUSE_ARM` - names an existing file. The test kills the process by that pid, so no signal + names an existing file (`daemon-reply` too, when `ORACLE_GAPS_TEST_PAUSE_ARM` + is set). `daemon-check` holds a daemon's first armed check before it runs, + until the file `ORACLE_GAPS_TEST_PAUSE_RELEASE` names exists. The test kills the process by that pid, so no signal is needed to pause on win32. Both marks are written whole (a temp file, then a rename), and the test parses the pid as a positive integer before it sends any signal. - - `ORACLE_GAPS_TEST_WAIT_MARK` names a file a request writes when its reply has - not come `ORACLE_GAPS_TEST_WAIT_MS` after it was sent. A request has no - timeout of its own: this timer starts with the request, and is cleared when - the request settles, whether it resolves or rejects. The test acts on the - CLI's wait, not on the clock. + - `ORACLE_GAPS_TEST_WAIT_MARK` names a file a check's request writes when + its daemon has sent nothing for `ORACLE_GAPS_TEST_WAIT_MS`, the point at + which the CLI would run the check cold. With the mark set, the request + writes it there and keeps waiting, so the test acts on the CLI's wait, not + on the clock. - `ORACLE_GAPS_TEST_WAIT_MS` (milliseconds, default 60000) is the CLI's wait - for a daemon to start or to close; a test shortens it to outlast a paused - daemon. It is a test-only knob, not a setting for users. + for a daemon to start or to close, and for a daemon that holds its check + to send anything; a test shortens it to outlast a paused daemon. It is a + test-only knob, not a setting for users. - `ORACLE_GAPS_TEST_SERVED_MARK` names a file the daemon writes its pid to after it answers a check, so a test can tell which daemon served an earlier check (the warm daemon that a later check's pause must match). @@ -191,8 +194,13 @@ exited with ` and exits 3; after an out-of-memory crash of its own (as some browser drivers are). On SIGINT or SIGTERM the CLI signals the whole group, kills what is left 2 s later, and exits 130 or 143. A check through the daemon (`--daemon`) runs in the daemon's process; stop - it with `oracle-gaps --stop-daemon --package `. On Windows, which has - no process groups, the run is not supervised. + it with `oracle-gaps --stop-daemon --package `. While a check waits or + runs there, the daemon tells the CLI each time a check makes progress. A + daemon that sends nothing for 60 s has stopped answering: the CLI ends + it, prints `oracle-gaps: note the package's daemon sent nothing for 60 s; +this check runs cold`, and runs the check in its own process, which + reports what the daemon would have. 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 diff --git a/packages/oracles/oracle-gaps/check.mjs b/packages/oracles/oracle-gaps/check.mjs index 631b5e8a..29ef42c2 100644 --- a/packages/oracles/oracle-gaps/check.mjs +++ b/packages/oracles/oracle-gaps/check.mjs @@ -862,12 +862,15 @@ export default async (env) => { // and for how long, so that a long run never looks frozen. Its label is // its mutant's id, an authored mutant's `authored:`, or `baseline` // for a run with no mutant. The interval is 30 s; the CLI's oracle - // shortens it (ORACLE_GAPS_HEARTBEAT_MS). Each check sets where it logs. - let pulse = { log: () => {}, every: 30_000 } + // shortens it (ORACLE_GAPS_HEARTBEAT_MS). Each check sets where it logs, + // and whom each poll of a running copy tells that the check progresses + // (`alive`: the daemon's beat to the CLIs that wait on it). + let pulse = { log: () => {}, alive: () => {}, every: 30_000 } function heartbeat() { let since let sent = 0 return (label, file, started) => { + pulse.alive() if (started !== since) { since = started sent = 0 @@ -930,6 +933,7 @@ export default async (env) => { context.getRootProject?.().provide(`oracleGaps`, state) writeFileSync(join(out, `state.json`), JSON.stringify(state)) const started = Date.now() + clearErrors(context) const running = context.runTestSpecifications( contextSpecs.get(context).get(file) ?? [], false, @@ -1013,16 +1017,7 @@ export default async (env) => { } rmSync(capture) } - // A run that spun ended, so its closing row names what it read (F-D). - if (spun) - return { - file, - timedOut: true, - spin: true, - seconds, - inputs: importsOf(file, modules, closing), - readAt: closing.readAt, - } + if (spun) return spunRun(file, seconds, modules, closing) const tests = modules.flatMap((module) => [...module.children.allTests()].map((testCase) => { const testResult = testCase.result() @@ -1069,6 +1064,22 @@ export default async (env) => { } } + /** + * The unit of a run that spun past its call budget, alone or in a batch: + * a timeout. It ended, so its closing row names what it read, which it is + * stored under (F-D). + */ + function spunRun(file, seconds, modules, closing = {}) { + return { + file, + timedOut: true, + spin: true, + seconds, + inputs: importsOf(file, modules, closing), + readAt: closing.readAt, + } + } + /** * The modules a run of `file` loaded: those Vitest reports it imported, * and those its copy evaluated (`loaded`, from the capture's closing row), @@ -1173,6 +1184,7 @@ export default async (env) => { writeFileSync(join(out, `state.json`), JSON.stringify(state)) const project = context.getRootProject() const started = Date.now() + clearErrors(context) const run = context.runTestSpecifications( copies.map((copy) => project.createSpecification(copy)), false, @@ -1277,15 +1289,6 @@ export default async (env) => { return rows } const skippedUnit = (item) => ({ file: item.file, skipped: true }) - // A copy that ran past its call budget, even one whose throw ended the - // loop and let it finish, is a timeout as it stands (a count, not a - // clock: no confirming run). - const spunUnit = (item) => ({ - file: item.file, - timedOut: true, - spin: true, - seconds, - }) if (result === undefined) { // Cancelled without waiting; the caller replaces the context (see // runUnit). @@ -1306,7 +1309,11 @@ export default async (env) => { units: items.slice(0, current).map((item, i) => { if (!closed.has(copies[i])) return undefined if (skipped.has(copies[i])) return skippedUnit(item) - if (spun.has(copies[i])) return spunUnit(item) + // A copy that ran past its call budget, even one whose throw + // ended the loop and let it finish, is a timeout as it stands (a + // count, not a clock: no confirming run). + if (spun.has(copies[i])) + return spunRun(item.file, seconds, [], closings.get(copies[i])) const map = keyFor(copies[i], item.file) const own = rows .get(copies[i]) @@ -1350,7 +1357,8 @@ export default async (env) => { units: items.map((item, i) => { const copy = copies[i] if (skipped.has(copy)) return skippedUnit(item) - if (spun.has(copy)) return spunUnit(item) + if (spun.has(copy)) + return spunRun(item.file, seconds, [], closings.get(copy)) const map = keyFor(copy, item.file) const modules = result.testModules.filter((m) => m.moduleId === copy) return { @@ -1427,6 +1435,8 @@ export default async (env) => { throw new Error( `oracle-gaps: this Vitest keeps no filesMap, idMap, or pathsSet in its state, so a check cannot retire its copies`, ) + // The batch's errors outside any test are plain data in its units now. + clearErrors(context) const gone = new Set(copies) for (const [id, task] of idMap) if (gone.has(task.file?.filepath ?? task.filepath)) idMap.delete(id) @@ -1437,6 +1447,20 @@ export default async (env) => { retireModules(context.getRootProject().vite, gone) } + /** + * Drops the errors outside any test that Vitest's state holds. Vitest keeps + * them across runs (its own CLI clears them per run), so a run that does + * not start without them reads an earlier run's errors as its own (its + * batch then runs alone), and a batch that keeps them retains them. + */ + function clearErrors(context) { + if (typeof context.state?.clearErrors !== `function`) + throw new Error( + `oracle-gaps: this Vitest's state has no clearErrors, so a run cannot tell its own errors outside any test`, + ) + context.state.clearErrors() + } + /** * Removes the copies' module nodes from every environment's Vite graph. * Each node is invalidated through Vite's API (which drops its transform), @@ -1492,7 +1516,7 @@ export default async (env) => { return environments } - async function check(options, store, log = console.error) { + async function check(options, store, log = console.error, alive = () => {}) { const authored = options.mutants ? loadAuthored(options.mutants) : [] seedVariable = `${options.envPrefix}_SEED` if (options.hangLimit > options.mutantLimit) @@ -1501,6 +1525,7 @@ export default async (env) => { ) pulse = { log, + alive, every: Number(process.env.ORACLE_GAPS_HEARTBEAT_MS ?? 30_000), } mkdirSync(options.out, { recursive: true }) diff --git a/packages/oracles/oracle-gaps/daemon.mjs b/packages/oracles/oracle-gaps/daemon.mjs index 71837dba..9160419b 100644 --- a/packages/oracles/oracle-gaps/daemon.mjs +++ b/packages/oracles/oracle-gaps/daemon.mjs @@ -20,8 +20,10 @@ // code (codeIdentity), which must be the daemon's; the reply is one line of // JSON with the summary a cold run would have printed and its log, or the // error that ended the check, which the CLI ends the run with as a cold run -// does (ending.mjs). One check runs at a time. The daemon exits when asked, -// or after 30 idle minutes. +// does (ending.mjs). Until then, the daemon sends the CLI a beat (an empty +// line) each time one of its checks makes progress; a CLI that hears nothing +// for 60 s runs its check cold (R39). One check runs at a time. The daemon +// exits when asked, or after 30 idle minutes. // // The CLI starts it: node daemon.mjs --package . Each check's evidence is // flushed to disk before the reply, so a daemon that is killed keeps what it @@ -78,36 +80,44 @@ const writeMark = (path, text) => { renameSync(temp, path) } -function send(pkg, message) { +/** + * Sends one request and settles with the daemon's reply. A check's request + * (`bounded`) settles as `{ silent: true }` once its daemon has sent nothing + * for WAIT_MS of wall-clock time (the socket's own idle timeout). A daemon + * sends a beat (a newline) each time one of its checks makes progress, so + * only a daemon that has stopped answering (or one phase of its check, such + * as a session's start, that runs longer than the bound with no progress) + * reaches it. The bound changes the run's path, never its outcome: the CLI + * then checks cold (v21.2 R39, I15). + */ +function send(pkg, message, bounded = false) { return new Promise((settle, reject) => { - // Test-only (ORACLE_GAPS_TEST_WAIT_MARK, a path): this request has no timeout - // of its own. Here a timer starts when the request is sent and, if the reply - // has not come after WAIT_MS, writes the path, so a test acts on the CLI's - // wait rather than on the clock. The timer is cleared on every settle. + // Test-only (ORACLE_GAPS_TEST_WAIT_MARK, a path): the bound is a pause + // point. Once it is reached, the request writes the path and keeps + // waiting, so a test acts on the CLI's wait rather than on the clock. const mark = process.env.ORACLE_GAPS_TEST_WAIT_MARK - const timer = - mark === undefined - ? undefined - : setTimeout(() => writeMark(mark, ``), WAIT_MS) - const resolvePromise = (value) => { - clearTimeout(timer) + const done = (value) => { + socket.destroy() settle(value) } - const fail = (error) => { - clearTimeout(timer) - reject(error) - } + const fail = reject const socket = connect(socketOf(pkg)) let reply = `` socket.on(`connect`, () => socket.write(`${JSON.stringify(message)}\n`)) + if (bounded) { + socket.setTimeout(WAIT_MS) + socket.on(`timeout`, () => + mark === undefined ? done({ silent: true }) : writeMark(mark, ``), + ) + } socket.on(`data`, (chunk) => { reply += chunk }) socket.on(`end`, () => { // A daemon that ends a connection unanswered has died, or is exiting. - if (reply === ``) return resolvePromise({ died: true }) + if (reply.trim() === ``) return done({ died: true }) try { - resolvePromise(JSON.parse(reply)) + done(JSON.parse(reply)) } catch (error) { fail(error) } @@ -115,7 +125,7 @@ function send(pkg, message) { socket.on(`error`, (error) => // A daemon that exits under a request resets its connection. [`ECONNRESET`, `EPIPE`].includes(error.code) - ? resolvePromise({ died: true }) + ? done({ died: true }) : fail(error), ) }) @@ -150,6 +160,18 @@ function daemonLogTail(pkg) { } } +/** Ends the daemon that holds the package's lock (its token starts with its pid). */ +function endDaemon(pkg) { + const pid = Number.parseInt( + readText(join(stateDirOf(pkg), `daemon.lock`)) ?? ``, + ) + try { + if (pid > 0) process.kill(pid, `SIGKILL`) + } catch { + // It ended meanwhile. + } +} + /** Starts a daemon for the package, detached from this process. */ function startDaemon(pkg) { mkdirSync(stateDirOf(pkg), { recursive: true }) @@ -167,7 +189,9 @@ function startDaemon(pkg) { * `failed`), or a fresh daemon in place of one that died; a closing daemon * is waited for. It waits at most 60 s for a daemon to answer or start; the * time a daemon holds the request, queued or checking, is the check's and is - * not counted. + * not counted while the daemon's checks make progress. A daemon that holds + * it and sends nothing for that long has stopped answering: the CLI ends it + * and gets `{ silent }`, the seconds it waited, to check cold instead. */ export async function requestDaemon(pkg, argv, code) { const began = Date.now() @@ -182,8 +206,15 @@ export async function requestDaemon(pkg, argv, code) { let reply const sent = Date.now() try { - reply = await send(pkg, { argv, cwd: process.cwd(), code }) + reply = await send(pkg, { argv, cwd: process.cwd(), code }, true) held += Date.now() - sent + // A daemon that stopped answering: the CLI ends it, so it writes no + // more into this run's --out, and checks cold (R39). The daemon that + // held the request listens on the socket, so it is the lock's holder. + if (reply.silent) { + endDaemon(pkg) + return { silent: WAIT_MS / 1000 } + } } catch (error) { if (!absent(error)) throw error // A daemon could not load or open its session since this CLI started @@ -247,9 +278,10 @@ export async function stopDaemon(pkg) { } const sleep = (ms) => new Promise((r) => setTimeout(r, ms)) -// How long a CLI waits for a daemon to start or to finish closing. The oracle -// shortens it (ORACLE_GAPS_TEST_WAIT_MS, a test-only knob) to outlast it with a -// paused daemon. +// How long a CLI waits for a daemon to start or to finish closing, and for a +// daemon that holds its check to send anything. The oracle shortens it +// (ORACLE_GAPS_TEST_WAIT_MS, a test-only knob) to outlast it with a paused +// daemon. const WAIT_MS = Number(process.env.ORACLE_GAPS_TEST_WAIT_MS ?? 60_000) // This daemon's lock token, which no other process can hold. const token = `${process.pid}:${randomUUID()}` @@ -348,10 +380,23 @@ async function serve(pkg) { // written over several turns of the event loop. const reply = (connection, value) => new Promise((resolvePromise) => { + waiting.delete(connection) connection.once(`close`, resolvePromise) connection.end(`${JSON.stringify(value)}\n`, resolvePromise) }) + // The connections whose check waits for its reply, queued or checking. Each + // hears a beat (a newline) whenever a check makes progress (a streamed line + // or a poll of a running copy), so its CLI can tell a daemon that works + // from one that stopped answering (requestDaemon). + const waiting = new Set() + const beat = () => { + for (const connection of waiting) + if (connection.writable) connection.write(`\n`) + } const server = createServer((connection) => { + // A CLI that went away hears nothing more; its connection's error (a + // reset under a beat) is no daemon's failure. + connection.on(`error`, () => {}) // Test-only (ORACLE_GAPS_TEST_PAUSE_AT=daemon-read): once the arm file named by // ORACLE_GAPS_TEST_PAUSE_ARM exists, the first connection is accepted and never // read; this daemon's pid goes to ORACLE_GAPS_TEST_PAUSE_MARK for the test, @@ -382,6 +427,7 @@ async function serve(pkg) { queue = queue.then(() => shutdown(connection)) return } + waiting.add(connection) queue = queue.then(async () => { clearTimeout(idle) // A request queued before the session failed hears why. @@ -402,6 +448,23 @@ async function serve(pkg) { queue = queue.then(() => shutdown(connection, { restart: true })) return } + // Test-only (ORACLE_GAPS_TEST_PAUSE_AT=daemon-check): once the arm file + // exists (ORACLE_GAPS_TEST_PAUSE_ARM), the first check waits here, + // before it runs, until the file ORACLE_GAPS_TEST_PAUSE_RELEASE names + // exists, so its CLI hears nothing until the test releases it. This + // daemon's pid goes to ORACLE_GAPS_TEST_PAUSE_MARK. Once. + const pauseMark = process.env.ORACLE_GAPS_TEST_PAUSE_MARK + const release = process.env.ORACLE_GAPS_TEST_PAUSE_RELEASE + if ( + process.env.ORACLE_GAPS_TEST_PAUSE_AT === `daemon-check` && + pauseMark !== undefined && + release !== undefined && + (armMark === undefined || existsSync(armMark)) && + !existsSync(pauseMark) + ) { + writeMark(pauseMark, `${process.pid}`) + while (!existsSync(release)) await sleep(50) + } const stderr = [] let stdout = `` let failed @@ -410,8 +473,14 @@ async function serve(pkg) { const options = parseArgs(message.argv, message.cwd) if (options.pkg !== pkg) throw new Error(`this daemon serves ${pkg}, not ${options.pkg}`) - stdout = await session.check(options, store, (line) => - stderr.push(`${line}\n`), + stdout = await session.check( + options, + store, + (line) => { + stderr.push(`${line}\n`) + beat() + }, + beat, ) await store.flush() // A test-only pause (ORACLE_GAPS_TEST_PAUSE_AT=daemon-reply): the check @@ -420,10 +489,13 @@ async function serve(pkg) { // ORACLE_GAPS_TEST_PAUSE_MARK, for the oracle to kill it by (no signal // pauses a process on win32). Once: a daemon the CLI restarts after this // one died inherits the variable, and must answer. + // With ORACLE_GAPS_TEST_PAUSE_ARM set, it holds only once that file + // exists, so a test can warm the daemon first. const mark = process.env.ORACLE_GAPS_TEST_PAUSE_MARK if ( process.env.ORACLE_GAPS_TEST_PAUSE_AT === `daemon-reply` && mark !== undefined && + (armMark === undefined || existsSync(armMark)) && !existsSync(mark) ) { writeMark(mark, `${process.pid}`) diff --git a/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs b/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs index 8837915b..62df39a6 100644 --- a/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs +++ b/packages/oracles/oracle-gaps/gap-report-model-oracle.mjs @@ -491,6 +491,8 @@ const earlierEdits = edits.filter((edit) => !laterEdits.includes(edit)) // 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([]) +// A history's no stop runs, likewise. +const NO_STOPS = Object.freeze([]) // The later edits a history takes after its steps: only one without the // witness module that has steps. const laterStepsOf = (history) => @@ -689,7 +691,7 @@ const drawn = fc.record({ // spins (`w_stop`), each in a pool: Vitest's workers as child processes or // as threads. Each costs a run of its own, so few histories have one. stopRuns: fc.oneof( - { weight: 9, arbitrary: fc.constant([]) }, + { weight: 9, arbitrary: fc.constant(NO_STOPS) }, { weight: 1, arbitrary: fc.array( @@ -835,31 +837,85 @@ const drawn = fc.record({ }), }, ), + // Randomness wins for new fields (maintainer decision, 2026-11-16): a field + // that changes what a history runs is drawn, and only a field that switches + // a test-only hook on stays a constant that constructed histories set. Of + // the fields below, `tornRows` (ORACLE_GAPS_TEST_TORN_ROWS), `pauseEngages` + // (ORACLE_GAPS_TEST_PAUSE_AT, which the daemon steps arm unless it is false) + // and `rejectBatch` (ORACLE_GAPS_TEST_REJECT_BATCH) switch hooks, so each is + // a constant; `warmReplaced`, `testRoot` and `loadPlugin` choose a scenario + // or a fixture's shape, so each is drawn. Their draws come after every + // earlier field's, so the earlier fields keep their values; the histories + // that draw them run other code, so a fixed seed's histories shift. + // // A batch's closing row written in two halves (issue #83) is constructed // only: the constant draws nothing, so generated histories hold no row, and // `histories` takes a constructed one back as this constant (as // `claimScenario` does). Its neutral value is recorded by the canary. tornRows: fc.constant(false), // Whether the daemon's pause engages in the daemon steps (dieMidCheck and - // resetBeforeRead). Always true in drawn histories, so the seeds' histories are - // unchanged; only the constructed history "a daemon pause that cannot engage" sets - // it false. + // resetBeforeRead): false leaves the pause hook unset. Always true in drawn + // histories; only the constructed history "a daemon pause that cannot engage" + // sets it false. pauseEngages: fc.constant(true), - // Whether the warm daemon is replaced after the warm check (review of #73, B2). - // Only the constructed history of a replaced warm daemon sets it. - warmReplaced: fc.constant(false), + // Whether the warm daemon is stopped after the warm check of a + // `resetBeforeRead` step, so another daemon takes the reset (review of #73, + // B2). It acts only in that step. + warmReplaced: fc.boolean(), // Where the config's `test.root` sits (issue #101, `testRoots`): `none`, the - // package, or a shape that only a constructed history sets. The constant - // draws nothing, so generated histories keep their values; `histories` - // takes a constructed one back as this constant, as `tornRows` does. - testRoot: fc.constant(`none`), + // package, or one of four shapes. Only an ES module config that Vitest + // discovers sets one (`testRootOf`). + testRoot: fc.constantFrom( + `none`, + `none`, + `none`, + `none`, + `tests`, + `parent`, + `outside`, + `link`, + ), // Whether the config has a plugin whose own \`load\` reads each test file - // with a sync read (\`LOAD_PLUGIN\`, review of #103). Only a constructed - // history sets it; \`histories\` takes it back as this constant. - loadPlugin: fc.constant(false), + // with a sync read (\`LOAD_PLUGIN\`, review of #103). Only a config in ES + // module syntax has it (\`loadPluginOf\`). + loadPlugin: fc.constantFrom(false, false, false, true), // 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), + // Whether the daemon of a `dieMidCheck` step holds its reply and lives on + // until the CLI has ended (the cold-fallback witness, R39). It switches the + // test-only `daemon-reply` pause on with no kill, so it is a constant that + // only the constructed history "a check whose daemon stops answering" sets; + // the take-back returns it to false. + replyHeld: fc.constant(false), + // Whether file b's verdict tests that read `tests/data.json` (`fsRead`) + // spin on the function they test, where its output differs and the data + // is open, in place of judging: a mutated copy then reads a file that its + // file's unmutated run never reads, and its call budget cuts it (a spin). + // An edit that closes the data makes those copies end unjudged, so a run + // stored under fewer inputs than it read would be reused stale (F-D of + // #55's third review: a spun run is stored under the inputs it read). + // Drawn: it shapes the fixture's tests and switches no hook. + spinData: fc.constantFrom(false, false, false, true), + // Where a package that lies in this repository is placed: beside the CLI's + // own files (`.scratch-*` in its directory), or in a directory beside the + // CLI's directory whose name extends that directory's name + // (`oracle-gaps-sibling-*`), so a plain prefix test of its path reads it + // as inside the CLI's directory when it is not (#73, fix class 2). Drawn: + // it places the fixture and switches no hook. + siblingDir: fc.constantFrom(false, false, false, true), + // Whether the driver runs this history's stops on win32, where every stop + // goes through the test stop file (ORACLE_GAPS_TEST_STOP): a constant that + // only the halves of `every outcome class` set, so no drawn history + // switches that hook on, and the history is the same on every platform. + hookStops: fc.constant(false), + // Whether a copy that spins on open data (`spinData`) first schedules an + // error that fires after its test has ended: an error outside any test, + // which Vitest cannot give to one copy, so the CLI runs each copy of that + // batch alone (runAlone), and the spun copy's unit comes from a run alone + // (merge gate F4). The outcomes stay the batch's. Drawn: it shapes the + // fixture's tests and switches no hook. + spinThrows: fc.constantFrom(false, false, false, true), }) // The edit sequence over the witness module, the one list of steps that a @@ -900,45 +956,83 @@ const keepsSteps = (history) => { // steps (`laterStepsOf`). Taking a history back returns it unchanged, // except a constructed one whose `steps` hold a later edit, which the // steps grammar cannot draw: its later edits move to `laterSteps`. A -// constructed history may also set `tornRows` (issue #83) or `testRoot` -// (issue #101), which `drawn` cannot produce, so its take-back reads each as -// its drawn constant (as `claimScenario` does): a shrink is torn-row-free and -// runs with the package as the config's root. +// constructed history may also set a hook's field (`tornRows`, issue #83; +// `pauseEngages`; `rejectBatch`; `replyHeld`), which `drawn` cannot +// produce, so its take-back reads each as its drawn constant (as +// `claimScenario` does): a shrink is torn-row-free, keeps the pause armed, +// rejects no batch, and holds no reply. The +// drawn fields (`warmReplaced`, `testRoot`, `loadPlugin`) come back as they +// are. +// A drawn history never switches a test-only hook either (randomness wins, +// 2026-11-16; v21.2 I16). Two steps arm a daemon pause: `dieMidCheck` holds +// the daemon's reply (ORACLE_GAPS_TEST_PAUSE_AT=daemon-reply, with the wait +// and served marks) and `resetBeforeRead` holds its connection unread +// (daemon-read), so a drawn history takes neither; the constructed histories +// that gate their states take them. A stop after the completed line holds the +// run's exit (ORACLE_GAPS_TEST_HOLD_EXIT_MS) and a stop while the config warms +// waits at the warm probe (ORACLE_GAPS_TEST_WARM_PROBE), so a drawn history's +// stops are stops while the witness spins (`after` and `warm` become `run`). +// On win32 every stop goes through the test stop file; the driver runs a +// stop there only for a history that sets `hookStops`, so the histories are +// the same on every platform (v21.2 R4). The maps read the same draws, so no +// field's draws move. Taking a constructed history back reads its hook steps +// and stops the same way, so a shrink keeps none. +const hookSteps = new Set([`dieMidCheck`, `resetBeforeRead`]) +const plainSteps = (steps) => { + if (steps == null || !steps.some((step) => hookSteps.has(step))) return steps + const kept = steps.filter((step) => !hookSteps.has(step)) + return kept.length > 0 ? kept : null +} +const plainStops = (stopRuns) => + stopRuns.some((stop) => stop.when === `after` || stop.when === `warm`) + ? stopRuns.map((stop) => + stop.when === `after` || stop.when === `warm` + ? { ...stop, when: `run` } + : stop, + ) + : stopRuns.length === 0 + ? NO_STOPS + : stopRuns const histories = drawn.map( - (history) => (keepsSteps(history) ? history : { ...history, steps: null }), + (history) => { + const kept = keepsSteps(history) ? history : { ...history, steps: null } + const steps = plainSteps(kept.steps) + const stopRuns = plainStops(kept.stopRuns) + return steps === kept.steps && stopRuns === kept.stopRuns + ? kept + : { ...kept, steps, stopRuns } + }, (value) => { const history = - /** @type {{ witness: unknown, steps: unknown[] | null, tornRows: unknown, testRoot: unknown }} */ ( + /** @type {{ witness: unknown, steps: unknown[] | null, tornRows: unknown, stopRuns: Array<{ when: string }> }} */ ( value ) if (!keepsSteps(history)) throw new Error(`a history with the witness module takes no steps`) - // Take-back into the drawn language: a disarmed pause (pauseEngages false, - // only the constructed history sets it) comes back as engaged, and a - // rejected batch (rejectBatch, likewise) as none, so the arbitrary can - // shrink it. Neither is therefore kept by a shrink. + const stopRuns = plainStops(history.stopRuns ?? NO_STOPS) + const steps = plainSteps(history.steps) const taken = history.tornRows === false && - history.testRoot === `none` && - history.loadPlugin === false + stopRuns === history.stopRuns && + steps === history.steps ? value - : { ...history, tornRows: false, testRoot: `none`, loadPlugin: false } - const later = (history.steps ?? []).filter((step) => - laterEdits.includes(step), - ) + : { ...history, tornRows: false, stopRuns, steps } + const later = (steps ?? []).filter((step) => laterEdits.includes(step)) if (later.length === 0) return { ...taken, pauseEngages: true, - warmReplaced: false, rejectBatch: 0, + replyHeld: false, + hookStops: false, } - const earlier = history.steps.filter((step) => !laterEdits.includes(step)) + const earlier = steps.filter((step) => !laterEdits.includes(step)) return { ...taken, pauseEngages: true, - warmReplaced: false, rejectBatch: 0, + replyHeld: false, + hookStops: false, steps: earlier.length > 0 ? earlier : null, laterSteps: later, } @@ -2418,6 +2512,40 @@ function configOf(history) { } } +/** + * Where a history's config sets `test.root` (`testRoots`): its drawn shape + * where a shape applies, and the package (`none`) elsewhere. A shape's root + * is written from the config's own URL, so only an ES module config sets + * one, and only the config that Vitest discovers in the package: a config + * that `--config` names (and the `config` edit's second config, which it + * names) sits in `config/`, and a parent's config above the package, so the + * shape's paths would name other directories; a `projects` config nests its + * test options in a project. + */ +function testRootOf(history) { + const config = configOf(history) + const steps = [...(history.steps ?? []), ...laterStepsOf(history)] + return config.configFormat === `esm` && + config.configPlace === `discovered` && + history.fault !== `projects` && + !steps.includes(`config`) + ? (history.testRoot ?? `none`) + : `none` +} + +/** + * Whether a history's config has the load plugin (`LOAD_PLUGIN`): where it + * draws one and has a config whose syntax can import `readFileSync`. + */ +function loadPluginOf(history) { + const config = configOf(history) + return ( + history.loadPlugin === true && + config.configPlace !== `none` && + config.configSyntax === `esm` + ) +} + function resolveHistory(history) { let label = 0 const containerOf = (index) => history.containers[index] ?? `free` @@ -2947,8 +3075,13 @@ function resolveHistory(history) { steps: [...(history.steps ?? []), ...laterStepsOf(history)], pauseEngages: history.pauseEngages !== false, warmReplaced: history.warmReplaced === true, + replyHeld: history.replyHeld === true, lazyGate: history.lazyGate === true, fsRead: history.fsRead ?? `none`, + spinData: history.spinData === true, + siblingDir: history.siblingDir === true, + hookStops: history.hookStops === true, + spinThrows: history.spinThrows === 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( @@ -2977,11 +3110,10 @@ function resolveHistory(history) { tornRows: history.tornRows === true, ...configOf(history), configEnv: history.configEnv === true, - // Where the config's `test.root` sits (`testRoots`, issue #101): only a - // constructed history sets it, so a generated one runs with the package - // as the root. - testRoot: history.testRoot ?? `none`, - loadPlugin: history.loadPlugin === true, + // Where the config's `test.root` sits (`testRoots`, issue #101), and + // whether it has the load plugin, where each applies. + testRoot: testRootOf(history), + loadPlugin: loadPluginOf(history), native: history.native ?? `none`, // A prebuilt addon in the workspace dependency's build/Release // (`addRelease`). @@ -4082,6 +4214,11 @@ function runsOf(plan, tests, sites, active) { // A test that hangs where another would judge never ends. if (changed && t.hangs) return { t, route, hang: true, verdicts: found, changed: true } + // A verdict test of file b that reads the data spins there instead, + // while the data is open, which it is before any edit (`spinData`): + // a loop that never ends, as above. + if (changed && plan.spinData && fsGated(plan, t.file, t)) + return { t, route, hang: true, verdicts: found, changed: true } if (changed && t.judges) { found.push({ route, @@ -4948,6 +5085,22 @@ function oracleTestFile(plan, file) { ` if (${when} && JSON.stringify(${out}) !== ${JSON.stringify(expected)}) await new Promise(() => {})`, ] : []), + // Where the output differs and the data is open, a verdict test of + // file b that reads the data spins on the function it tests + // (`spinData`), so the capture's call budget cuts its copy. A flaky + // test does not: the model leaves flaky tests out. + ...(plan.spinData && fsGated(plan, file, t) && !t.flaky + ? [ + ` if (${when} && JSON.stringify(${out}) !== ${JSON.stringify(expected)} && (await readData()).open) {`, + ...(plan.spinThrows + ? [ + ` setTimeout(() => { throw new Error('a spinning copy threw outside its test') })`, + ] + : []), + ` for (;;) ${callFor(t.fn)}(${part.input}, [])`, + ` }`, + ] + : []), ...(!t.judges ? [] : t.judgeBy !== `verdict` @@ -5266,7 +5419,7 @@ function configText(plan, test) { ...(plan.testRoot === `none` ? [] : [`import { fileURLToPath } from 'node:url'`]), - // Only an ES module config has the load plugin (its constructed history). + // Only a config in ES module syntax has the load plugin (`loadPluginOf`). ...(plan.loadPlugin ? [`import { readFileSync } from 'node:fs'`] : []), ...(plan.fault === `configThrows` ? [`throw new Error('the fixture config broke')`] @@ -5334,8 +5487,9 @@ const parentModules = (plan, state) => * init chunk's `vitest-environment-` resolution), so under `parent` that * package lies in the root's node_modules (`environments`); every other shape * finds the package's own. - * Only an ES module config sets a root (it reads its own URL), and only the - * constructed histories set one, each as an ES module config. + * Only an ES module config that Vitest discovers sets a root (it reads its + * own URL; `testRootOf`). Generated histories draw the shape, and each shape + * also has a constructed history of its own. */ const inTests = { root: `./tests`, @@ -5362,6 +5516,14 @@ const testRoots = { // The directory that the package's `tests` links to under the `link` test // root. const linkedTests = `tests-target` +/** + * Where a package path lies in the fixture's files: under the `link` test + * root, the files of `tests` live in `linkedTests`, and `tests` links there. + */ +const fixturePathOf = (plan, path) => + plan.testRoot === `link` && path.startsWith(`tests/`) + ? `${linkedTests}/${path.slice(`tests/`.length)}` + : path function fixtureFiles(plan, state = initialState(plan)) { const manifest = (fields) => @@ -5636,9 +5798,7 @@ function fixtureFiles(plan, state = initialState(plan)) { // `tests` links to it. return Object.fromEntries([ ...Object.entries(files).map(([path, text]) => [ - path.startsWith(`tests/`) - ? `${linkedTests}/${path.slice(`tests/`.length)}` - : path, + fixturePathOf(plan, path), text, ]), [`tests`, link(linkedTests)], @@ -6072,6 +6232,7 @@ export { AUTHORED, initialState, fixtureFiles, + fixturePathOf, written, writeFixture, applyEdit, 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..53351db2 100644 --- a/packages/oracles/oracle-gaps/gap-report-oracle.property.test.mjs +++ b/packages/oracles/oracle-gaps/gap-report-oracle.property.test.mjs @@ -513,7 +513,14 @@ import { writeFileSync, } from 'node:fs' import { tmpdir } from 'node:os' -import { delimiter, dirname, join, relative, resolve } from 'node:path' +import { + delimiter, + dirname, + isAbsolute, + join, + relative, + resolve, +} from 'node:path' import { fileURLToPath, pathToFileURL } from 'node:url' import fc from 'fast-check' import { socketOf, stateDirOf } from './daemon.mjs' @@ -550,6 +557,7 @@ import { altConfigPath, initialState, fixtureFiles, + fixturePathOf, written, writeFixture, applyEdit, @@ -1145,7 +1153,7 @@ async function runClisAtOnce(dir, files, hows, outs = []) { stderr += chunk }) const status = await new Promise((resolvePromise) => { - const timer = setTimeout(() => child.kill(), 300_000) + const timer = setTimeout(() => child.kill(), how.backstopMs ?? 300_000) child.on(`close`, (code) => { clearTimeout(timer) resolvePromise(code) @@ -1187,6 +1195,11 @@ function namedScratch(text, names) { .replaceAll(/session-\d+/g, `session-`) } +// The note a CLI writes when its daemon sent nothing within its bound and the +// check runs cold instead (R39: a cold fallback names its cause). +const coldFallbackNote = + /^oracle-gaps: note the package's daemon sent nothing for \d+ s; this check runs cold/ + /** What one run of the CLI reported, from its exit status and its files. */ // A gap line the CLI streams to stderr as its mutant is judged (stream.mjs): // its class, its line, and its id, after the stream's prefix (law 15). @@ -1605,6 +1618,8 @@ async function incremental(dir, plan, cli, copy, observe, states) { let replacedOnly = false // Whether the daemon's last check cut a batch off. let cutBefore = false + // Whether the daemon's last check stored a run that spun (`spinData`). + let spunBefore = false // Whether the daemon stored a run under the mid-run marker. let markerStored = false // How many runs the daemon computed in a check of a state that nothing @@ -1750,6 +1765,12 @@ async function incremental(dir, plan, cli, copy, observe, states) { // The first line of a failure, for the message; readRun has named // the scratch package and CLI copy in it. stderr: run.stderr?.split(`\n`)[0], + // Whether its daemon held the check's reply and nothing ended it + // while the CLI ran (`heldReply`). + held: run.held === true, + // Whether a daemon wrote into that run's --out after its CLI fell + // back (`heldReply`). + rewritten: run.rewritten === true, }, }) } @@ -1854,6 +1875,21 @@ async function incremental(dir, plan, cli, copy, observe, states) { states.add( `an edit to data read through ${plan.fsRead} changed the cold result`, ) + // The daemon's previous check stored runs of file b's copies that read + // the data and spun (`spinData`), a file that b's unmutated run never + // reads: the runner must store each such run under the inputs it read + // (F-D), so the edit makes the daemon compute it again (law 9). + if (step === `fsData` && plan.spinData && spunBefore) + states.add( + `an edit to data that only a spun copy read changed the cold result`, + ) + // The same, where each spun copy also threw outside its test, so the + // CLI ran its batch's copies alone and stored the spun run from a run + // alone (`spinThrows`; merge gate F4). + if (step === `fsData` && plan.spinData && plan.spinThrows && spunBefore) + states.add( + `an edit to data that only a copy spun alone read 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 @@ -1872,6 +1908,7 @@ async function incremental(dir, plan, cli, copy, observe, states) { ) } cutBefore = (daemon.evidence?.cut ?? 0) > 0 + spunBefore = (daemon.evidence?.spin ?? 0) > 0 replacedOnly = plan.contexts === 1 && cutBefore previous = coldRun } @@ -1881,6 +1918,95 @@ async function incremental(dir, plan, cli, copy, observe, states) { [join(copy, `index.mjs`), `--stop-daemon`, `--package`, dir], { cwd: repo, encoding: `utf8`, timeout: 60_000, env: cleanEnv() }, ) + // A check through a daemon that stops answering: the daemon holds the + // check before it runs (`daemon-check`), so it has written nothing into the + // run's --out, and hears nothing until the driver releases it. A warm check + // starts the daemon with the pause disarmed (ORACLE_GAPS_TEST_PAUSE_ARM), so + // the held check reaches a daemon whose session is open; then the pause is + // armed. The held check's CLI waits 3 s (ORACLE_GAPS_TEST_WAIT_MS), as for + // the other holds, so its bound on a daemon that sends nothing comes early, + // and it writes no wait mark, so nothing pauses it there. Each call's + // backstop (120 s) ends a CLI that never ends, and the incremental check + // reports the stopped run as no cold fallback. Once the CLI has ended, the + // driver poisons the run's results.json, releases the daemon (a file, never + // the clock), and runs one more check through the daemon, which a released + // daemon serves only after the check it held. A results.json that is no + // longer the poison was written by the abandoned check (merge gate F2), so + // the run's printed summary no longer matches its --out; and since the + // daemon wrote nothing before the fallback, only a real cold check gives the + // run its report (F7). The state needs the pause, the CLI's completed run, + // its note that the check runs cold, and the poison kept. + async function heldReply(files, how, marks, pauseMark) { + const armMark = join(marks, `armed`) + const release = join(marks, `release`) + const pause = { + ORACLE_GAPS_TEST_PAUSE_AT: `daemon-check`, + ORACLE_GAPS_TEST_PAUSE_MARK: pauseMark, + ORACLE_GAPS_TEST_PAUSE_ARM: armMark, + ORACLE_GAPS_TEST_PAUSE_RELEASE: release, + } + const [warmRun] = await runClisAtOnce(dir, files, [ + { + ...how, + daemon: true, + outName: `out-warm`, + env: pause, + backstopMs: 120_000, + }, + ]) + observe( + `retention:warm`, + retentionBreaches(warmRun.retention, { + checkPid: warmRun.checkPid, + complete: warmRun.reported, + cold: false, + }), + ) + writeFileSync(armMark, ``) + const outs = [] + const [run] = await runClisAtOnce( + dir, + files, + [ + { + ...how, + daemon: true, + env: { ...pause, ORACLE_GAPS_TEST_WAIT_MS: `3000` }, + backstopMs: 120_000, + }, + ], + outs, + ) + let pid + for (let waited = 0; pid === undefined; waited += 20) { + pid = pidOf(pauseMark) + if (pid !== undefined) break + if (waited >= 60_000) + throw new Error( + `oracle-gaps.report: a held check saw no daemon pause within 60 s`, + ) + await new Promise((r) => setTimeout(r, 20)) + } + // A CLI that never wrote its --out (it waited until the backstop) gets one + // here, so the poison still shows whether the daemon writes into it. + mkdirSync(outs[0], { recursive: true }) + const results = join(outs[0], `results.json`) + const poison = `{"poison":"written by the driver after the CLI ended"}\n` + writeFileSync(results, poison) + writeFileSync(release, ``) + runCli(dir, files, { ...how, daemon: true, outName: `out-released` }) + run.rewritten = readFileSync(results, `utf8`) !== poison + rmSync(marks, { recursive: true, force: true }) + run.held = true + if ( + !run.rewritten && + run.exit === 0 && + run.reported && + run.stream.notes.some((note) => coldFallbackNote.test(note)) + ) + states.add(`a check whose daemon stopped answering ran cold`) + return [run] + } // One check through the daemon, with what the step does to the daemon // meanwhile: paused once the check has begun for longer than the CLI // waits for a daemon, then killed (`dieMidCheck`), or stopped and killed @@ -1900,8 +2026,12 @@ async function incremental(dir, plan, cli, copy, observe, states) { // did not read (settleIn), so the next check, with nothing changed, // equals a cold run of the state after the edit. if (step === `midrun`) { - const target = - plan.midrunTarget === `data` ? `tests/data.json` : `tests/strict.ts` + // The edited file's key in the fixture's files (under the `link` test + // root, the tests' files live where `tests` links to). + const target = fixturePathOf( + plan, + plan.midrunTarget === `data` ? `tests/data.json` : `tests/strict.ts`, + ) const after = files[target] const value = after.includes(`true`) // The marker goes in the running daemon's session directory, where @@ -1960,6 +2090,13 @@ async function incremental(dir, plan, cli, copy, observe, states) { const waitMark = join(marks, `waited`) const servedMark = join(marks, `served`) const mid = step === `dieMidCheck` + // A daemon that stops answering (`replyHeld`, the cold-fallback witness of + // R39): its reply is held at the daemon's `daemon-reply` pause and nothing + // ends it while the CLI runs, so the CLI owes a completed run by a bound of + // its own, a cold run's (law 9). The driver releases the daemon only after + // the CLI has ended, by killing it; a CLI that never ends is ended by the + // call's backstop, which fails loudly as a law-9 violation. + if (mid && plan.replyHeld) return heldReply(files, how, marks, pauseMark) // A plan may disarm the pause (a constructed history): then nothing engages. const pause = plan.pauseEngages === false @@ -1967,7 +2104,9 @@ async function incremental(dir, plan, cli, copy, observe, states) { : { ORACLE_GAPS_TEST_PAUSE_AT: mid ? `daemon-reply` : `daemon-read`, ORACLE_GAPS_TEST_PAUSE_MARK: pauseMark, - ORACLE_GAPS_TEST_PAUSE_ARM: armMark, + // The reset's pause waits for its arm, after the warm check; the + // reply's engages at once. + ...(mid ? {} : { ORACLE_GAPS_TEST_PAUSE_ARM: armMark }), } const env = { ...pause, @@ -2162,7 +2301,9 @@ async function driver(plan, observe) { mkdtempSync( outsideRepository(plan) ? join(realpathSync.native(tmpdir()), `gap-fixture-`) - : join(here, `.scratch-`), + : plan.siblingDir + ? `${here}-sibling-` + : join(here, `.scratch-`), ), ) const dir = @@ -2344,8 +2485,13 @@ async function driver(plan, observe) { // observation holds counts, which no name or order changes: how many // session directories the package has once the run ended, and how many // of them the previous stopped run had left. + // On win32 every stop goes through the CLI's test stop file + // (ORACLE_GAPS_TEST_STOP), so it runs only for a history that sets + // `hookStops`: a drawn history switches no hook on (v21.2 I16). + const stops = + process.platform === `win32` && !plan.hookStops ? [] : plan.stopRuns if (cli.exit === 0 && stopIds.length > 0) - for (const stop of plan.stopRuns) { + for (const stop of stops) { const { retention, checkPid, ...run } = await stoppedRun( dir, files, @@ -2405,9 +2551,30 @@ async function driver(plan, observe) { states.add(`blocked by ${plan.fault}`) // A refused run's output is recorded with its scratch paths named, and // this package lies inside the CLI's directory: the case in which the - // naming order decides whether a random name stays in the trace. + // naming order decides whether a random name stays in the trace. The + // label is judged against the path from the CLI's directory to the + // package (`relative`), so it is never attested for a package that lies + // outside: one in a directory beside the CLI's whose name extends it + // (`siblingDir`) has its own state. + const outsideCli = (() => { + const path = relative(how.cli, dir) + return path.startsWith(`..`) || isAbsolute(path) + })() if (cli.exit !== 0 && dir !== how.cli && isWithin(how.cli, dir)) states.add(`a refused run whose package lies inside the CLI's directory`) + if ( + states.has( + `a refused run whose package lies inside the CLI's directory`, + ) && + outsideCli + ) + throw new Error( + `oracle-gaps.report: recorded a refused run whose package lies inside the CLI's directory, but ${relative(how.cli, dir)} lies outside it`, + ) + if (cli.exit !== 0 && outsideCli && posix(dir).startsWith(posix(how.cli))) + states.add( + `a refused run whose package lies beside the CLI's directory, under a name that extends it`, + ) // A failing owner's replay printed in a package whose config only // `--config` names, beside a discovered config that includes no test. if ( @@ -2914,6 +3081,21 @@ function incrementalCheck(observations) { `after ${step}, the daemon stored a run under the mid-run marker, a file in its own session directory`, `witness guard`, ) + // A check whose daemon stopped answering (`heldReply`) ends as a cold run + // does (R39: a cold fallback is not a failure): the CLI's own bound on a + // daemon that sends nothing ends its wait, and it checks cold. + if (daemon.held && daemon.exit !== cold.exit) + return violation( + `incremental`, + `after ${step}, the daemon held the check and the CLI did not fall back to a cold check: it exited ${daemon.exit}${daemon.exit > 128 ? ` when the driver's backstop stopped it` : ``}, and the cold run exited ${cold.exit}`, + `cold fallback`, + ) + if (daemon.rewritten) + return violation( + `incremental`, + `after ${step}, the daemon ran the check after its CLI had ended, and wrote into that run's --out`, + `cold fallback`, + ) if ( daemon.exit !== cold.exit || daemon.refusal !== cold.refusal || @@ -4429,7 +4611,9 @@ const required = [ `a daemon pause that did not engage`, // Reached by its own constructed history (see there). `a probe branch's work under a generated test's bound judged nothing`, - // Reached only by the constructed history of a replaced warm daemon (see there). + // Gated by the constructed history of a replaced warm daemon (see there); + // a generated history with a reset step reaches it when it draws + // `warmReplaced`. `a warm daemon was replaced before the pause`, `killed by a second owner`, `killed`, @@ -4562,6 +4746,13 @@ const required = [ `a lazy edit changed the cold result after a batch was cut off`, `a rejected batch retired its copies and logged them`, `a run ended in an internal error`, + // Reached only by the constructed history of a held reply (`heldReply`). + `a check whose daemon stopped answering ran cold`, + // Gated by its constructed history; generated histories reach it when + // they draw `spinData` with an fs read and the data's edit. + `an edit to data that only a spun copy read changed the cold result`, + `a refused run whose package lies beside the CLI's directory, under a name that extends it`, + `an edit to data that only a copy spun alone read changed the cold result`, ] // The faults the CLI analyzes anyway: a package's TypeScript is no input. const analyzedFaults = [`noTypescript`, `apiLessTypescript`] @@ -4649,6 +4840,10 @@ const separate = [ `a lazy edit changed the cold result after a batch was cut off`, `a rejected batch retired its copies and logged them`, `a run ended in an internal error`, + `a check whose daemon stopped answering ran cold`, + `an edit to data that only a spun copy read changed the cold result`, + `a refused run whose package lies beside the CLI's directory, under a name that extends it`, + `an edit to data that only a copy spun alone read changed the cold result`, ] // A stop by SIGTERM exists only where Node can deliver it: on win32 kill is // TerminateProcess, so there the stop law is judged by SIGINT (the test stop @@ -4771,7 +4966,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 a plugin whose load reads each test file with a sync read (loadPlugin), drawn for a config in ES module syntax and reached by its own constructed history too; 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, drawn for an ES module config that Vitest discovers in the package (the randomness-wins decision, 2026-11-16) and each reached by its own constructed history of 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 (nor in a history whose config edit names a second config), a CommonJS config, a parent's 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), in a batch as alone; a spun copy that reads a file that its file's unmutated run never reads is generated (spinData: file b's verdict tests that read the data spin on the function they test while it is open), and the data's edit is judged by law 9 for copies that spin in a batch; a copy that spins alone (runAlone, after a batch with an error outside any test) is generated too (spinThrows: each spun copy schedules an error that fires after its test), and its data's edit is judged the same way; an error outside any test only from a copy that spins, so the alone path's other units (a slow copy's confirmation) stay unwitnessed; 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; a scratch package lies in the CLI's directory (.scratch-*), in a directory beside it whose name extends the CLI directory's name (siblingDir, drawn), or in the OS temp directory, so the driver's inside-the-CLI label is judged against a prefix that is not a parent; a CLI path spelled with another drive-letter case or separator than the package's is win32-only and not generated; 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; a daemon that stops answering only as one held check (the daemon-check pause, before the check runs, after a warm check, armed by ORACLE_GAPS_TEST_PAUSE_ARM and released by the driver's file once the CLI has ended): the CLI's bound is the socket's idle timeout on a daemon that sends nothing, a wall-clock bound that changes the run's path and never its outcome (60 s; the hold shortens the wait to 3 s), its cold check must equal a cold run (law 9's cold fallback, R39), and the run's --out must keep only what its CLI wrote, judged by a poison the driver writes before it releases the daemon; a daemon that stops answering while it opens its session, while the request is queued, or within a check is not generated; a CLI whose daemon is closing and hung waits 60 s and fails with an internal error rather than checking cold, and --stop-daemon against a hung daemon has no bound (merge gate F3; owed: a constructed history that closes a held daemon, issue #135); a fallback whose cold check refuses is not generated (law 9's refusal-notes comparison would see the fallback note); 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; a generated history stops only while the witness spins, or aborts, and on win32 not at all, since every other stop switches a test-only hook (the hold after the completed line, the warm probe, and on win32 the test stop file; randomness wins, 2026-11-16), so only the halves of every outcome class stop with one; 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 @@ -4829,6 +5024,8 @@ oracleProperty({ pragma: true, // Stopped while the stop witness spins, once by each signal and // in each pool (law 13). + // Its stops switch hooks: on win32 the test stop file. + hookStops: true, stopRuns: [ { signal: `SIGTERM`, pool: `forks`, when: `run` }, { signal: `SIGINT`, pool: `threads`, when: `run` }, @@ -4985,6 +5182,11 @@ oracleProperty({ concurrentStart: true, cliPath: `spaced`, native: `none`, + // Its reset step's warm label needs the warm daemon kept: with + // `warmReplaced` drawn (randomness wins, 2026-11-16), the fixed + // seed's base drew a replaced one and lost "a warm daemon's + // connection was reset", which this history gates. + warmReplaced: false, laterSteps: NO_LATER_STEPS, steps: [ `helper`, @@ -5271,8 +5473,10 @@ oracleProperty({ build: (generated) => ({ ...generated, fault, + // Its package lies in the CLI's directory, so it is not placed + // beside it (`siblingDir`, drawn). ...(fault === `badEntry` - ? { cliPath: `plain`, configPlace: `discovered` } + ? { cliPath: `plain`, configPlace: `discovered`, siblingDir: false } : {}), ...(fault === `brokenVitest` ? { @@ -5862,6 +6066,11 @@ oracleProperty({ enters: [`edit lazy changed the cold result`], build: (generated) => ({ ...generated, + // Its lazy gate sits in file b's verdict, which a test that spins + // on open data never reaches: with `spinData` drawn (2026-11-16), + // the fixed seed's base drew it and lost "edit lazy changed the + // cold result", which this history gates. + spinData: false, functions: [[{ kind: `push`, quote: `'` }]], containers: [], overloads: [], @@ -5902,6 +6111,11 @@ oracleProperty({ ], build: (generated) => ({ ...generated, + // Its lazy gate sits in file b's verdict, which a test that spins on + // open data never reaches: a random seed's base drew `spinData` + // (2026-11-16) and lost "a lazy edit changed the cold result after + // a batch was cut off", which this history gates (merge gate F6). + spinData: false, functions: [ [{ kind: `push`, quote: `'` }], [{ kind: `if`, op: `>`, k: 4, not: false, quote: `'` }], @@ -6088,6 +6302,8 @@ oracleProperty({ boot: false, budget: `two`, pragma: false, + // Its stops switch hooks: on win32 the test stop file. + hookStops: true, stopRuns: [ { signal: `SIGINT`, pool: `threads`, when: `warm` }, { signal: `SIGINT`, pool: `threads`, when: `abort` }, @@ -6235,6 +6451,137 @@ oracleProperty({ ], }), }, + { + // A daemon that stops answering (R39, the conformance check of #73): the + // daemon of the step's check holds its reply (`replyHeld`, the + // test-only `daemon-reply` pause) and nothing ends it while the CLI + // runs. The CLI owes a completed check, a cold run's, by its own bound + // on a daemon that sends nothing (`heldReply`). + name: `a check whose daemon stops answering`, + enters: [`a check whose daemon stopped answering ran cold`], + build: (generated) => + oneOwnerHistory(generated, { + steps: [`dieMidCheck`], + laterSteps: NO_LATER_STEPS, + replyHeld: true, + }), + }, + { + // F-D of #55's third review, which landed with no RED and no mutant + // (D50): a spun run is stored under the inputs it read. File b's + // verdict test reads the data only where its output differs, and, + // while the data is open, spins there (`spinData`), so each mutated + // copy that changes the output reads a file that b's unmutated run + // never reads, and its call budget cuts it. The edit closes the data: + // the cold run then reports those mutants unjudged, and a daemon that + // stored the spun runs under b's known inputs only would reuse them. + name: `an edit to data that only a spun copy reads`, + enters: [ + `an edit to data that only a spun copy read 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: `sync`, + spinData: true, + // Its spun copies stay in their batch (the batch path's F-D). + spinThrows: false, + laterSteps: NO_LATER_STEPS, + steps: [`fsData`], + }), + }, + { + // #73's fix class 2, which landed with no hostile mutant (D58): the + // driver tells a package inside the CLI's directory by its path from + // that directory (`isWithin`), not by a plain prefix of its name. + // This refused run's package lies in a directory beside the CLI's + // whose name extends it (`siblingDir`), so a prefix test would + // attest the inside state for it, which the driver's check of the + // relative path rejects. + name: `a refused run beside the CLI's directory, under a name that extends it`, + enters: [ + `a refused run whose package lies beside the CLI's directory, under a name that extends it`, + ], + build: (generated) => ({ + ...generated, + fault: `badEntry`, + cliPath: `plain`, + configPlace: `discovered`, + witness: false, + steps: null, + laterSteps: NO_LATER_STEPS, + siblingDir: true, + }), + }, + { + // F-D on the alone path (merge gate F4): the history above, where each + // spun copy also throws outside its test (`spinThrows`), so its batch + // runs alone and the spun run is stored from a run alone (runUnit's + // spunRun). The data's edit must make the daemon compute it again. + name: `an edit to data that only a copy spun alone reads`, + enters: [ + `an edit to data that only a copy spun alone read 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: `sync`, + spinData: true, + spinThrows: true, + laterSteps: NO_LATER_STEPS, + steps: [`fsData`], + }), + }, ]), }, resolve: resolveHistory, diff --git a/packages/oracles/oracle-gaps/history-fingerprint.json b/packages/oracles/oracle-gaps/history-fingerprint.json index 20fef659..cf2c2083 100644 --- a/packages/oracles/oracle-gaps/history-fingerprint.json +++ b/packages/oracles/oracle-gaps/history-fingerprint.json @@ -54,10 +54,15 @@ ["laterSteps", "fb28f2575c00f223"], ["tornRows", "ed6866229ecc4969"], ["pauseEngages", "c93e2e40cd0c4b9f"], - ["warmReplaced", "ed6866229ecc4969"], - ["testRoot", "e18db063421a75f1"], - ["loadPlugin", "ed6866229ecc4969"], - ["rejectBatch", "e5386ea9402dd268"] + ["warmReplaced", "84f62a790b9d0777"], + ["testRoot", "8f4dfb34f4e51863"], + ["loadPlugin", "1b19291d29a6e2b2"], + ["rejectBatch", "e5386ea9402dd268"], + ["replyHeld", "ed6866229ecc4969"], + ["spinData", "ca71b56b0d55db6d"], + ["siblingDir", "efebc6f9d344ecbf"], + ["hookStops", "ed6866229ecc4969"], + ["spinThrows", "a15c94f07e10bd07"] ], "histories": [ ["functions", "66c0e9c56951c377"], @@ -92,7 +97,7 @@ ["unbuiltDep", "ece5968476f7042d"], ["boot", "6fc1fdf2bd90d59e"], ["budget", "d8481d5ff2e964b9"], - ["stopRuns", "826d81299eda30ed"], + ["stopRuns", "d370243f1f4b4a1a"], ["onlyRun", "439d74b1930e4623"], ["pragma", "731664592bd605c0"], ["cliPath", "cba4d240a707ec0b"], @@ -103,7 +108,7 @@ ["configAwait", "cda5d28fd16345ff"], ["configRequire", "79654da1ed474074"], ["contexts", "16320f05c7e90361"], - ["steps", "190290444d7d2340"], + ["steps", "cad4109ec56e04cd"], ["dataOwners", "dddde2f870a331e0"], ["exportOwners", "b63c5a16d33b7d92"], ["importer", "8cf68b28f1e26fa2"], @@ -114,9 +119,14 @@ ["laterSteps", "fb28f2575c00f223"], ["tornRows", "ed6866229ecc4969"], ["pauseEngages", "c93e2e40cd0c4b9f"], - ["warmReplaced", "ed6866229ecc4969"], - ["testRoot", "e18db063421a75f1"], - ["loadPlugin", "ed6866229ecc4969"], - ["rejectBatch", "e5386ea9402dd268"] + ["warmReplaced", "84f62a790b9d0777"], + ["testRoot", "8f4dfb34f4e51863"], + ["loadPlugin", "1b19291d29a6e2b2"], + ["rejectBatch", "e5386ea9402dd268"], + ["replyHeld", "ed6866229ecc4969"], + ["spinData", "ca71b56b0d55db6d"], + ["siblingDir", "efebc6f9d344ecbf"], + ["hookStops", "ed6866229ecc4969"], + ["spinThrows", "a15c94f07e10bd07"] ] } diff --git a/packages/oracles/oracle-gaps/index.mjs b/packages/oracles/oracle-gaps/index.mjs index 4321082e..4e7cc7e4 100755 --- a/packages/oracles/oracle-gaps/index.mjs +++ b/packages/oracles/oracle-gaps/index.mjs @@ -130,6 +130,7 @@ import { codeIdentity, openSession } from './check.mjs' import { received, requestDaemon, stopDaemon } from './daemon.mjs' import { endRun } from './ending.mjs' import { memoryStore } from './evidence.mjs' +import { streamLine } from './stream.mjs' // How long the group has to end after a stop signal before it is killed. const STOP_GRACE_MS = 2000 @@ -296,13 +297,24 @@ async function checkCold(options) { } } -/** The summary of a check run by the package's daemon. */ +/** + * The summary of a check run by the package's daemon, or, when the daemon + * stopped answering, of a cold check, after a note that names why (R39: a + * cold fallback is not a failure). A cold check reports what the daemon's + * would have (incremental equals cold). + */ async function checkThroughDaemon(options) { const reply = await requestDaemon( options.pkg, process.argv.slice(2), codeIdentity(), ) + if (reply.silent) { + process.stderr.write( + `${streamLine(`note`, `the package's daemon sent nothing for ${reply.silent} s; this check runs cold`)}\n`, + ) + return checkCold(options) + } if (reply.stderr) process.stderr.write(reply.stderr) if (reply.failed) throw received(reply.failed) return reply.stdout diff --git a/packages/oracles/scripts/e2e-shards.mjs b/packages/oracles/scripts/e2e-shards.mjs index 30f2d967..4ef9203b 100644 --- a/packages/oracles/scripts/e2e-shards.mjs +++ b/packages/oracles/scripts/e2e-shards.mjs @@ -179,6 +179,18 @@ export const shards = { `calibration: a traced warning's frames beside our own line with no prefix`, `calibration: an esbuild block beside our own line with no prefix`, `calibration: our own indented line with no prefix`, + `fixed seed 20261105: a check whose daemon stops answering`, + `random seed: a check whose daemon stops answering`, + `determinism: constructed history: a check whose daemon stops answering`, + `fixed seed 20261105: an edit to data that only a spun copy reads`, + `random seed: an edit to data that only a spun copy reads`, + `determinism: constructed history: an edit to data that only a spun copy reads`, + `fixed seed 20261105: a refused run beside the CLI's directory, under a name that extends it`, + `random seed: a refused run beside the CLI's directory, under a name that extends it`, + `determinism: constructed history: a refused run beside the CLI's directory, under a name that extends it`, + `fixed seed 20261105: an edit to data that only a copy spun alone reads`, + `random seed: an edit to data that only a copy spun alone reads`, + `determinism: constructed history: an edit to data that only a copy spun alone reads`, `random seed: a .ts config in a package with no module type that calls require`, `random seed: a declaration fault: configThrows`, `random seed: a declaration fault: noTypescript`, diff --git a/packages/oracles/scripts/pr-shards.mjs b/packages/oracles/scripts/pr-shards.mjs index a2b88dcb..fbb6c53b 100644 --- a/packages/oracles/scripts/pr-shards.mjs +++ b/packages/oracles/scripts/pr-shards.mjs @@ -543,6 +543,7 @@ 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', + 'a check whose daemon stops answering', ]), 7: anyOf([ 'a daemon pause that cannot engage', @@ -567,6 +568,9 @@ export const partitions = { 'an awaiting config in a package with no module type', 'a declaration fault: configNoDefault', 'a declaration fault: badEntry', + 'an edit to data that only a spun copy reads', + "a refused run beside the CLI's directory, under a name that extends it", + 'an edit to data that only a copy spun alone reads', ]), 9: anyOf([ 'a lazy module loaded before a hang in the same batch', diff --git a/packages/oracles/tests/gap-report-history-fingerprint.test.ts b/packages/oracles/tests/gap-report-history-fingerprint.test.ts index e7d22ad1..ce998738 100644 --- a/packages/oracles/tests/gap-report-history-fingerprint.test.ts +++ b/packages/oracles/tests/gap-report-history-fingerprint.test.ts @@ -15,10 +15,14 @@ import { drawn, histories } from '../oracle-gaps/gap-report-model-oracle.mjs' // the histories that the oracle takes, after the grammar's own mapping, so // a mapping that folds a new field into an old one shows too. A new field // goes at the end of the grammar and gets its own line at the end of each -// list; no earlier line changes. It guards the fields' draws, not the +// list; no earlier line changes. A constant field that becomes drawn +// (randomness wins for new fields, maintainer decision, 2026-11-16) changes +// its own line and the lines of the fields drawn after it, and no earlier +// one. It guards the fields' draws, not the // resolved plans: a new field may still change what a plan does (the plan // takes `laterSteps` after a history's steps). The default fixed-seed -// campaign draws 2 histories, and those resolve as on main. +// campaign draws 2 histories; since `warmReplaced`, `testRoot` and +// `loadPlugin` are drawn, those resolve with these fields' draws. const FIXED_SEED = 20261105 const DRAWS = 500 @@ -59,4 +63,48 @@ describe(`the gap oracle's history grammar`, () => { ) } }) + + // Randomness wins for new fields (maintainer decision, 2026-11-16; v21.2 + // R54, I16): a field that changes what a history runs is drawn, except that + // no drawn field switches a test-only hook on. The hooks are read off what + // the driver would set for a history, by value, here, not from the model, + // so a model that starts to draw one fails: + // - its constant hook fields hold their neutral values; + // - no step arms a daemon pause: `dieMidCheck` sets ORACLE_GAPS_TEST_PAUSE_AT + // (daemon-reply), _PAUSE_MARK, _SERVED_MARK, _WAIT_MS and _WAIT_MARK, and + // `resetBeforeRead` sets ORACLE_GAPS_TEST_PAUSE_AT (daemon-read), + // _PAUSE_ARM and _SERVED_MARK; `pauseEngages` only disarms those, so it is + // no neutral value of its own; + // - no stop switches a hook: a stop after the completed line holds the run's + // exit (ORACLE_GAPS_TEST_HOLD_EXIT_MS), and a stop while the config warms + // waits at the warm probe (ORACLE_GAPS_TEST_WARM_PROBE); on win32 the + // driver runs a stop through the test stop file (ORACLE_GAPS_TEST_STOP) + // only for a history that sets `hookStops`. + // It reads `histories`, the histories the oracle takes, at three seeds. + test(`draws no value that switches a test-only hook`, () => { + const neutral: Record = { + tornRows: false, // ORACLE_GAPS_TEST_TORN_ROWS + rejectBatch: 0, // ORACLE_GAPS_TEST_REJECT_BATCH + replyHeld: false, // ORACLE_GAPS_TEST_PAUSE_AT=daemon-check, with a release + hookStops: false, // ORACLE_GAPS_TEST_STOP on win32 + } + const hookSteps = [`dieMidCheck`, `resetBeforeRead`] + const hookStops = [`after`, `warm`] + for (const seed of [FIXED_SEED, 1, 2]) { + const samples = fc.sample(histories, { seed, numRuns: DRAWS }) as Array< + Record & { + steps: Array | null + stopRuns: Array<{ when: string }> + } + > + for (const history of samples) { + for (const [field, value] of Object.entries(neutral)) + expect([field, history[field]]).toEqual([field, value]) + for (const step of history.steps ?? []) + expect(hookSteps).not.toContain(step) + for (const stop of history.stopRuns) + expect(hookStops).not.toContain(stop.when) + } + } + }) })