Repository navigation
feat(oracles): extract the oracle framework core from TanStack DB - #1
Merged
Merged
Conversation
Move the oracleProperty framework into @tanstack/oracles: declareOracle, createOracleReach, runOracleCampaign, failure fidelity, the replay witness, the controlled clock, and the replay configuration. The framework's own self-oracle and property tests move with it. The replay configuration is a factory. configureOracles sets the environment prefix, the property registry, and the retired replay variables, so TanStack DB keeps its TANSTACK_DB_ORACLE_* names and its registry unchanged. Without a configuration the prefix is ORACLE and every property id is accepted. Also adds the browser-safe @tanstack/oracles/declaration entry, which loads no Node built-ins, and widens the vitest peer range to ^4.1.0 || ^5.0.0. Co-authored-by: Isaac <[email protected]>
…he seam - vite.config.ts: the default `vitest --run` collected oracle-property-self-oracle.test.ts, which spawns child Vitest runs for about five minutes. The framework config and TanStack DB both assume the default run excludes it; `pnpm test:oracle-framework` still runs it. - oracle-config.ts: drop the two re-exports of recordOracleReplay and declareOracle; index.ts already exports both names. - oracle-config.ts: list REPLAY_WITNESS_MODE among the documented variables. - oracle-reach.ts: remove the TanStack DB issue reference from a comment. - oracle-campaign.ts: use .js specifiers like the rest of src. - oracle-property.ts: attach the __oracleRoute and __oracleVerdict comments to the declarations they describe. No runtime behavior changes. Evidence: `pnpm test` (6 files, 25 tests), `pnpm test:oracle-framework` (37 tests), build, typecheck, publint --strict, and eslint pass. The default run now lists six test files. Co-authored-by: Isaac <[email protected]>
…whole Review fixes for the configuration seam and the package entry. - Nothing is read at import. The replay environment is read by configureOracles, or, in a project that never configures, on first use. Before, the module read and validated `ORACLE_*` at load, so a stray `ORACLE_PATH` (SQL*Plus sets it) made `import '@tanstack/oracles'` throw in a project with its own prefix. - configureOracles checks everything, including the replay environment under the new prefix, before it changes anything, and then replaces the prefix, registry, retired variables, and replay selection together. A rejected call leaves the previous configuration whole; before, it left the new prefix and registry with the old replay selection. - A first configureOracles that changes the defaults after an oracle already read them throws, so a project that configures too late fails loudly instead of running full campaigns under the default prefix. - The main entry is ES modules only: it imports Vitest, which refuses require(), so its CommonJS build could not load. `./declaration` keeps its CommonJS build. - The campaign test that checks reach independence now sets a path replay under the configured prefix; it stubbed a variable nothing read. - Docs: the `ORC-` rule numbers point at TanStack DB's oracle rubric; a fixed history is called one (not an example); the probe hook's install at import is explained; the ordinary configuration test is renamed `config.test.ts`. RED (before this commit): the three new configuration tests failed (stray default variable, rejected replay environment, late configuration), and the export test failed on the previous manifest; a campaign that inherits the global replay mode failed the strengthened campaign test. GREEN: 29 tests in 6 files; the self-oracle 37 tests (198 s); build, typecheck, lint (0 errors), publint. TanStack DB on this build: offline-transactions 396 tests, db-ivm 684, db oracle-replay and SortedMap 107. Co-authored-by: Isaac <[email protected]>
…ange ORACLE_MANIFEST and the ORACLE_SEED and ORACLE_REACH log tags keep fixed names whatever prefix a project configures, because tooling reads them across projects (maintainer decision, 2026-11-08). runOracleCampaign takes its prefix from its caller, so a package's own campaigns stay apart from the project's replay selection. Co-authored-by: Isaac <[email protected]>
…n it Vitest 5 matches `-t` against a test's suite and test names joined by ` > `; Vitest 4 joins them with a space. A failing history printed `-t "^<suite> <test>$"`, so on Vitest 5 its rerun command skipped the test. The pattern now accepts either separator between the suite and the test name, each still escaped and anchored. CI gains a job that runs the package's tests and the self-oracle on Vitest 5, which the peer range claims (maintainer decision, 2026-11-08). The main job now runs the self-oracle too: the default test run leaves it out, so CI did not run it. - Law: rerun — a violation's printed rerun command runs exactly that test (the self-oracle's law). - RED: on Vitest 5.1.0, the self-oracle failed 7 histories under law `rerun`, e.g. "self-oracle.synthetic-0 rerun of "fixed history: fixed-0": "fixed history: fixed-0" did not fail again". A direct probe: Vitest 5 matches `^outer id > fixed history: fixed-0$`, not `^outer id fixed history: fixed-0$`; Vitest 4 the reverse. - GREEN: the self-oracle passes on Vitest 5.1.0 (37 tests, 135 s) and on Vitest 4.1.12 (37 tests, 147 s); the default suite passes (29 tests). - Mutant: the previous pattern is the mutant; it fails on Vitest 5 as quoted under RED. - Limits: a test nested more than one suite deep is not a case the framework prints (its tests sit directly in the property's suite). Co-authored-by: Isaac <[email protected]>
Co-authored-by: Isaac <[email protected]>
…d remove two duplicates - withOracleExamples becomes withOracleFixedHistories (maintainer decision, 2026-11-08): the glossary calls these fixed histories, and fast-check's `examples` option is only the mechanism. TanStack DB does not call it. - runOracleCampaign no longer copies the replay path into a second object. - The replay witness builds and appends a record in one place for both the guarded and the finite replays. Behavior unchanged: default tests 29, self-oracle 37 (146 s), typecheck, lint, build. Co-authored-by: Isaac <[email protected]>
🦋 Changeset detectedLatest commit: cc7afba The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
commit: |
This was referenced Nov 8, 2026
scheduleFrom computed `choices[step] % queues.length` for any number. A negative or fractional choice indexed no queue, findIndex returned -1, and `pending.splice(-1, 1)` released the newest pending task, out of its queue's order (review finding R1-1 on #1). The contract names a queue only for a nonnegative integer and promises no normalization, so such a choice is a caller's breach: scheduleFrom now throws when it is called with one, before it releases anything. - Law: a data schedule releases each queue's tasks in order for every accepted choice list, and rejects a choice that is not a nonnegative integer when called (scheduleFrom contract in oracle-property.ts; fail fast on a contract breach, TanStack DB AGENTS.md). - Reach: the scheduler self-oracle generates negative, fractional, and non-finite choices beside natural ones; declared state `a choice that names no queue` (constructed) reached by 134 of 200 histories in the fixed-seed campaign, 140 in the random one; 67 and 61 histories still check the release order. - RED (parent): `vitest run tests/oracle-property-scheduler-oracle.property.test.ts` failed 4 tests under law `invalid choice`, e.g. fixed history "a negative choice names no queue": "a choice names no queue, but the schedule accepted it". A direct probe released ["storage 2","storage 0", "provider 1"] for choices [-1] and [1.5]. - GREEN: the scheduler oracle passes, 6 tests. - Mutant: a narrow fix that rejects only negative choices fails 3 tests, both campaigns (shrunk to choice 5e-324) and the fractional fixed history; removing the check is the parent's RED. - Limits: a rejected schedule is observed as a throw, not by its message. Co-authored-by: Isaac <[email protected]>
…settled withinTurns(promise, 0) answered false even when the promise had settled before the call: the expiry, an async function with no turn to wait, fulfilled before the promise's own settlement callback ran, and won the race (review finding R1-7 on #1). Its contract says it answers true as soon as the promise settles, and a promise settled before the call settled before any deadline. The expiry now lets settlement callbacks that are already due run, then answers whether the promise settled. The doc no longer claims "the same microtask an await would", which the race never gave. withinTurns had no oracle (the self-oracle listed it as a limit). It gets a small one: when a promise settles (already, in turn 1 to 3, or never), whether it rejects, and the number of turns; the driver counts turns with its own ticker, and the check compares the answer and the turn it arrived in with the rule. - Law: withinTurns resolves true in the turn its promise settles when that is before the deadline, a promise already settled at the call included, and false in the deadline's turn otherwise (withinTurns contract in oracle-property.ts). - Reach: declared state `an already settled promise with no turns` (constructed) reached by 51 of 101 histories (fixed seed) and 54 (random); measured: settled before the deadline 65/68, deadline first 29/27, a tie 7/6. - RED (parent): `vitest run tests/within-turns-oracle.property.test.ts` failed both campaigns under law `deadline`, counterexample {"settles":"already","rejects":false,"turns":0}. - GREEN: 3 tests pass. - Mutants: `return state.settled` without letting due callbacks run fails both campaigns on the same counterexample; a withinTurns that waits every turn before it answers fails both on {"settles":"already","turns":1} under law `turn`. - Limits: settlement in the deadline's own turn may answer either way; settlement in a later microtask of the calling turn is not generated. Co-authored-by: Isaac <[email protected]>
Three review findings on #1 in the configuration seam, one law: every oracle read uses the one configuration in force, the replay environment is read once under it, and a first configureOracles that changes the defaults after any read throws. - R1-5: only a replay-environment read marked the defaults as read. A registry check before configureOracles (an oracleProperty registration, or oracleRandomParameters at file load) passed against the empty default registry, and a later configureOracles({ registry }) was accepted. - R1-6: createOracleReach re-read the live environment through readOracleRunConfig(), while replay selection (oracleReplayRequested, oracleReplayTest) kept the configured read. After the environment changed, tests stood aside while reach still checked, or the reverse. - R1-9: the prefix was stored twice, in oracle-config.ts and oracle-environment.ts, kept in step by hand. oracle-environment.ts now holds the only copy of the configuration (prefix, registry, retired variables) and the read flags. Every read goes through oracleSettings(), which marks the defaults as read before the first configuration, so a registry check and a variable name count as reads. createOracleReach reads oracleReplayRequested(). readOracleRunConfig with an explicit environment also counts as a read now: it reads the prefix, registry, and retired list. The declared-reach oracle's driver set a run kind's environment and relied on createOracleReach reading it live. It now configures under that environment, and configures the process's own afterward; this is valid on both the parent and this commit, and its model and prose say the reach reads the configured selection. - Law: as above (configureOracles contract in oracle-config.ts: the replay environment is read at configuration or first use; configure before oracles read). - Reach: new oracle tests/config-oracle.property.test.ts, fresh modules per history; declared states (all constructed) `a configuration after a registry read` 17/18, `an environment change after configuration` 40/43, `a calibration witness under another prefix` 16/20 histories (fixed / random campaign, 102 each). - RED (parent): `vitest run tests/config-oracle.property.test.ts` failed 4 tests: both campaigns and fixed history "a registry check before configuration" at step 1 under law `configure first` (the configuration was accepted); fixed history "a replay set after configuration" at step 3 under law `one configuration` (reach skipped its check, replay selection saw no replay). - GREEN: the config oracle passes 5 tests; default suite and declared-reach oracle pass. - Mutants: a registry check that does not mark the defaults read fails 3 tests under `configure first`; a reach that reads the live environment fails 3 under `one configuration`; a second prefix copy that configuration does not update (oracleEnvName fixed at ORACLE) fails both campaigns on a calibration witness under ACME. - Limits: one registered id, valid replay selections; retired variables, multipliers, and malformed environments stay with config.test.ts. The calibration variable is read when its witness registers. Co-authored-by: Isaac <[email protected]>
oraclePropertyOptions and oracleRandomParameters registered a route (`random seed`, or `fixed history` under a path replay) as a side effect, and the last registration wins. A fixed-seed campaign that built its options with them and then set its own seed was attributed to `random seed`, and an explicit oracleRoute call made before building the options was overwritten, so the gap report misread such kills (finding F2 on #1, found in TanStack DB's conversion). A route now describes the campaign that runs, whatever order the helpers are called in: building options registers nothing; oracleProperty and runOracleCampaign register their campaigns' routes, and oracleProperty's random campaign registers `fixed history` itself when it runs a path replay; a test that runs its own campaign calls oracleRoute. Public behavior change: the two builders no longer call globalThis.__oracleRoute. A test that runs its own fast-check campaign and relied on that registration now records no route until it calls oracleRoute (`random seed` for a random campaign, `fixed history` under a replay of it). Sites that register their route after building options are unchanged. Signatures are unchanged. - Law: the route registered when a campaign runs describes that campaign: the runner's own, or the last one the test registered; building options registers none (gap-report route contract; coordinator decision for #1, 2026-11-08). - Reach: new oracle tests/route-oracle.property.test.ts; declared states (constructed) `options built after the test registered its route` 33/32 and `options built inside a runner's campaign` 44/49 histories (fixed / random campaign, 102 each). - RED (parent): `vitest run tests/route-oracle.property.test.ts` failed 3 tests under law `route`: both campaigns shrank to a test that only built property options (observed `random seed`, owed none), and fixed history "options built after the test registered fixed seed" observed `random seed`, owed `fixed seed`. - GREEN: 4 tests pass; the self-oracle's new `route` law (next commit) passes, including path replays. - Mutants: restoring the builders' registration fails the 3 tests above; removing the random campaign's `fixed history` registration fails the self-oracle's replay fixed histories ("the replay ran under routes ["random seed", ...], owed "fixed history""). - Limits: a caller's own oracleRoute is taken as its claim; the framework cannot check it. Co-authored-by: Isaac <[email protected]>
…the history holds Four review findings on #1 (R1-2, R1-3, R1-4, R1-8), each extended into the oracleProperty self-oracle before the fix. - R1-2: failure() printed the history with JSON.stringify, which throws on a bigint, so a real law violation surfaced as a TypeError; an unlabelled enumerated history was named by JSON.stringify too, so a bigint history failed registration and Map histories all got the name `{}`. Both now use traceText, the framework's stable text, which keeps bigints, Maps, Sets, undefined, and errors apart. Names of JSON-safe histories do not change. - R1-3: the rerun command was anchored at the property's suite and quoted as JSON, so inside an outer describe it matched nothing, and a name with `$` or a backtick expanded when pasted. It is now built from the test's full suite chain (Vitest's task), each name escaped, joined by `(?: | > )` for Vitest 4 and 5, in POSIX single quotes. Checked on Vitest 4.1.12 here and by hand on Vitest 5.0.5 (the suite chain and the pattern match a nested test the same way). - R1-4: on a controlled-clock spin, a model or check that could not read the cut trace threw, and the history failed as a setup error instead of under `bounded clock`. The spin now decides then, as a driver error does when its cut trace cannot be read. - R1-8: the determinism test ran the driver through recordTrace, a near-copy of recordGuarded that left the probe window open when the driver threw, so a late probe call after that was recorded silently instead of throwing; it also skipped the observation hook. recordTrace is gone: the determinism test records through recordGuarded and compares the trace, the spin, and the probe calls. Determinism runs now also reach globalThis.__oracleObserve, as every other run does. Self-oracle extensions (generator dimensions, each with a fixed history): a history's form (array, bigint-tagged object, Map); enumerated labels (plain, with shell characters, none); a property nested in an outer suite; a strict model that throws on a trace a stop cut short; and the rerun probe now runs the printed command through /bin/sh. The late-probe law now counts one unhandled error per late call, from the log, instead of "at least one"; the synthetic driver starts its late call as it returns or throws (before, a clock spec's call fired inside its own history), and a late spec's file waits 50 ms after its last test so the last call lands. A new `route` law checks the route each history runs under, including a replayed random campaign's `fixed history`. The reporter counts a suite's collection errors as the file's. - Law: verdict (a violation surfaces as that law's failure whatever the history holds), registration (unlabelled histories get distinct names), rerun (the printed command, pasted into a shell, runs exactly that test, nested or not), clock (a spin whose cut trace the model cannot read fails under `bounded clock`), agreement (every late probe call throws, also after a driver that threw), route. Authority: oracle-property.ts header; maintainer decision of 2026-11-06 on the bounded clock; coordinator decision for #1, 2026-11-08, on routes. - Reach: 8 new measured states, each entered by its fixed history on every run (bigint-history-violation, unlabelled-enumerated, map-history, shell-label-rerun, nested-rerun, strict-model-cut-short, late-probe-after-driver-error, replayed-route); the 3-run campaigns reached replayed-route twice and the others rarely. - RED (parent, `pnpm --filter @tanstack/oracles test:oracle-framework`): 7 failed, 37 passed, exactly the new fixed histories: "a violation in a history holding a bigint" failed as {"kind":"other"}, owed law three; "Map histories apart" registered ["determinism","{}","{}"]; "bigint histories loads" failed to load; "survives a shell" and "inside another suite" did not fail again on rerun; "cut at a spin" failed as {"kind":"other"}, owed bounded clock; "after a throwing driver" reported 10 late probe calls, owed 11. - GREEN: self-oracle 44 passed (181 s, 2 workers); default suite passes. - Mutants (each fails exactly its fixed histories): default label back to JSON (registration, 2 tests); failure text back to JSON (verdict); full name but JSON quoting (rerun, shell label); shell quoting but only the property suite and test (rerun, nested); the spin's judge unguarded (verdict, bounded clock); probe window left open after a driver error (agreement, 7 late calls of 11); random campaign without its replay route (route, 3 replay tests). - Limits: unlabelled names are checked for distinctness, not text; a slow spec's late calls and routes are not counted exactly; histories still hold one to three integers. Co-authored-by: Isaac <[email protected]>
The library build emitted every entry in both formats, so the tarball shipped dist/cjs/index.cjs, oracle-property.cjs, and six more CommonJS modules with their .d.cts files (review finding R1-10 on #1). Nothing exported them, and index.cjs and oracle-property.cjs cannot load: they require Vitest, which refuses require(). A small build plugin now keeps only the CommonJS modules that the browser-safe ./declaration entry reaches, and their declaration files. It applies to builds only, so a test run's served config never touches dist. The package test gains a pack check: it builds, lists the tarball with `npm pack --dry-run --json`, loads every runtime module under its own module system in one Node process, requires the `require` export targets alone and lists the CommonJS modules they never reach, and checks that every export target ships and every .d.cts has its module. - Law: the package ships only loadable, reachable entries. - RED (parent): `vitest run tests/package.test.ts` failed: dist/cjs/index.cjs and oracle-property.cjs failed to load ("Vitest cannot be imported in a CommonJS module using require()"), and 8 CommonJS modules were unreached from the require targets. - GREEN: 4 tests pass; dist/cjs holds declaration and oracle-declaration only (.cjs, .map, .d.cts); publint --strict passes. - Mutant: pruning the chunks but keeping every .d.cts fails the declaration-file check, listing dist/cjs/index.d.cts and 7 more. - Limits: ES module reachability is not checked; every ES module is loadable. Co-authored-by: Isaac <[email protected]>
A calibration uses the first candidate whose clean trace passes. Its clean check judged the whole recorded trace and ignored a controlled-clock spin, so a spinning history, which fails under `bounded clock` in its own test, counted as clean, and the calibration could pass on it. Both calibration paths (a corrupted trace and a mutant driver) now skip a candidate whose clock spun, as they skip one whose driver threw. Found by a 4x self-oracle campaign while verifying the review repairs on #1; the code predates them. - Law: calibration — a calibration uses the first candidate whose clean trace passes (maintainer decision of 2026-11-03), and a spin fails its history (maintainer decision of 2026-11-06). - Reach: new fixed history "a calibration skips a candidate whose clock spins" (a clock spec whose first candidate is [7]) enters calibration-skipped-candidate and calibration-applied on every run. - RED (HEAD before this commit): `ORACLE_RUNS_MULTIPLIER=4 pnpm --filter @tanstack/oracles test:oracle-framework` failed the random campaign: "calibration: cal-0" passed, owed {"kind":"calibration-none"} (replay ORACLE_SEED=1625892856 ORACLE_PATH=5:10:10:11:11:11 ORACLE_PROPERTY=self-oracle.framework reproduces it); the new fixed history failed the same way. - GREEN: the replay passes; the self-oracle passes 45 tests at 4x runs (304 s); default suite 44 tests. - Mutant: skipping the spin only on the corrupted-trace path fails the fixed history on its mutant-driver calibration ("cal-1" passed, owed calibration-none). - Limits: as the self-oracle states. Co-authored-by: Isaac <[email protected]>
…s no turns Round-2 review finding R1b-10 on #1: the fail-fast checks were incomplete. scheduleFrom looked for a misfit with `find`, which returns undefined both for "none" and for a hole or an explicit undefined, so `[, 0]` passed. withinTurns took any number of turns: a negative count or NaN acted as 0, 1.5 as 2, and Infinity waited for ever on a promise that never settles. scheduleFrom now uses findIndex; withinTurns throws for a count that is not a nonnegative integer. - Law: a choice names a queue only as a nonnegative integer, and a number of turns counts turns only as one; anything else is a caller's breach, rejected when called (scheduleFrom and withinTurns contracts in oracle-property.ts; fail fast, TanStack DB AGENTS.md). - Reach: the scheduler grammar adds undefined and sparse arrays (fixed history "a hole names no queue"); the withinTurns grammar adds -1, 0.5, 1.5, NaN, and Infinity turns, declared state `a number of turns that counts none` (constructed) reached by 30/27 of 102 histories, plus fixed history "a negative number of turns". - RED (abd445e): the scheduler oracle failed 3 tests on choices `[,]`; the withinTurns oracle failed 3 on `turns: -1`. - GREEN: scheduler 7 tests, withinTurns 4 tests. - Mutants: a check that lets an undefined misfit pass fails 3 tests on `[,]`; rejecting only negative counts fails both withinTurns campaigns on `turns: 1.5`. - Limits: as each oracle states. Co-authored-by: Isaac <[email protected]>
… text Round-2 review findings R1b-2, R1b-3, R1b-4, R1b-6, R1b-7, R1b-8, R1b-9 on #1, and R1b-11 from TanStack DB's conversion review. Each oracle's model now states its law, not either runner's behavior. Routes (R1b-4, R1b-7, R1b-8, R1b-11). One vocabulary, `OracleRoute` in the new oracle-route.ts: `fixed seed` (a seed fixed in code, or a seed-only replay that reseeds a campaign), `fixed history` (one written or recorded history, a path replay included), `case` (an enumerated history), `random seed` (a seed the framework or fast-check draws), and `calibration` (a calibration, a probe calibration, or the determinism test). Before, oracleProperty registered `enumerated`, `determinism`, and `probe calibration`, which oracleRoute's type and docs did not name; it attributed a seed-only replay to `random seed` while runOracleCampaign said `fixed seed`; and runOracleCampaign attributed a path replay to `fixed seed` while oracleProperty said `fixed history`. Now: `enumerated` -> `case`; `determinism` and `probe calibration` -> `calibration`; both runners attribute a seed-only replay to `fixed seed` and a path replay to `fixed history`. - New: `oracleRouteOf(parameters)` names the route of a campaign that runs with given fast-check parameters: `fixed history` with a path; `random seed` without a seed or with the seed an options builder drew; `fixed seed` otherwise, such as a seed the test fixed. The builders record a drawn seed under a registered symbol, which a spread keeps and fast-check ignores. oracleProperty's random campaign uses it. A test that runs its own campaign registers `oracleRoute(oracleRouteOf(parameters))`. - oracle-route.ts imports nothing. `@tanstack/oracles/declaration` now exports `oracleRoute`, `oracleRouteOf`, and the `OracleRoute` type besides `declareOracle`, so a suite bundled into a webview registers its routes without Node built-ins. The main entry still exports oracleRoute and now exports oracleRouteOf and the type. Configuration (R1b-2, R1b-3). `readOracleRunConfig()` without an argument re-read process.env on every call, so `oracleRandomParameters(n, readOracleRunConfig(), id)` could replay a selection that oracleReplayTest and createOracleReach did not see; it now returns the configured read (with an argument it still parses that environment). The calibration variable was read live by oracleCalibrationTest; it is now read with the replay selection. Stable text (R1b-6). The default label, the failure's History line, and the determinism test used traceText, which printed NaN, Infinity, and null alike, -0 as 0, the string "$undefined" as undefined, and dropped symbol keys and prototypes. The determinism test now compares exactly with isDeepStrictEqual, as differs does; the text is a history's JSON when JSON carries it exactly (so JSON-safe names do not change) and Node's inspection otherwise. Build (R1b-9). The CommonJS pruning plugin kept its reached set across builds, so a watch rebuild kept stale modules and dropped new ones; it starts again on each build. - Laws: route (gap-report route contract; coordinator decisions for #1, 2026-11-08); one configuration (configureOracles contract); determinism and registration (oracle-property.ts header); the package ships only loadable, reachable entries and the declaration entry loads no Node built-in. - Reach: route oracle states `a runner's replay` 38/44, `the route of options whose seed the test fixed` 18/22, plus 2 earlier states (fixed / random campaign, 104 histories); config oracle `an environment change after configuration` 47/42; self-oracle new state lossy-history and fixed histories for -0 labels and -0 determinism. - RED (abd445e): route oracle failed 5 tests, including fixed history "a runner's path replay is a fixed history" (observed `fixed seed`) and a missing oracleRouteOf; config oracle failed 4, including "run configuration read after the environment changed" and "a calibration variable set after configuration"; self-oracle failed 39 of 47 (route `enumerated` owed `case`, `random seed` owed `fixed seed` under the children's seed-only replay; labels ["[0]","[0]","[null]"]; -0 vs 0 passed determinism); package test failed the declaration exports and the two-build plugin check. - GREEN: default suite 51 tests; self-oracle 47 tests (193 s); build, typecheck, lint, publint. - Mutants, each rejected: runOracleCampaign path replay back to `fixed seed` (route oracle, 3 tests); oracleRouteOf ignoring the drawn seed (route oracle campaigns); oracleProperty's random campaign always `random seed` (self-oracle, `fixed seed` owed); `enumerated` restored (self-oracle); readOracleRunConfig() live (config oracle, 3 tests); calibration read live (config oracle, 2); determinism by JSON text and default label by JSON (self-oracle, one fixed history each); the plugin without clearing (package test); oracle-route.ts importing node:util (package test names "dist/esm/oracle-route.js: node:util"). - Limits: every self-oracle child sets a seed-only replay, so the self-oracle never sees oracleProperty's `random seed` route; the route oracle covers it through oracleRouteOf. A drawn seed travels with the parameters object; parameters serialized across realms lose it and read as `fixed seed`. Co-authored-by: Isaac <[email protected]>
5030ce3 picked up two untracked packages/oracles/.oracle-gaps/bundle-*.mjs files, local output of the gap report. They stay on disk, untracked. Co-authored-by: Isaac <[email protected]>
… compare as data Round-3 review findings R1c-1..R1c-9 on #1. Routes (R1c-1, R1c-2, R1c-3, R1c-9). A route never claims more reproducibility than its campaign has; where the framework cannot know a seed is fixed it says `random seed` (coordinator decision, 2026-11-08). Before, oracleRouteOf read any seed without the drawn-seed mark as `fixed seed`, so rebuilt options, a JSON round trip, a structured clone, and runOracleCampaign's own random campaign (which never set the mark) over-claimed. The mark is now inverted: only a declared seed is fixed. - New `oracleFixedSeed(seed, parameters?)` (main and ./declaration entries) returns parameters that run with `seed`, declared fixed under the registered symbol `@tanstack/oracles/fixed-seed`. A spread keeps the declaration; a seed set by hand, a field-by-field rebuild, JSON, or structuredClone drops it, and the parameters then read `random seed`. - oracleRouteOf is the one classifier: no seed -> `random seed`; seed and path -> `fixed history`; a seed equal to its declaration -> `fixed seed`; otherwise `random seed`. Options built under a replay declare the replay's seed. runOracleCampaign builds its fixed and replay campaigns with oracleFixedSeed and registers oracleRoute(oracleRouteOf(parameters)) (its nested ternary is gone); oracleProperty's fixed-seed campaigns do the same. The parameters runOracleCampaign passes to its callback now carry the declaration, which the declared-reach model and the campaign test owe. - Route oracle grammar adds: set seed by hand (to a value no declaration uses), declare a fixed seed, rebuild field by field, JSON and structuredClone round trips, and the route of the runner's parameters; the constructed "lost declaration" history takes each losing step in turn. Self-oracle (R1c-4). A suite may add a seedless child run, without ORACLE_SEED, whose random campaigns must run every history under `random seed`. Names (R1c-5). Unlabelled names and History lines printed an Error's stack, with this machine's paths; an Error now prints as its name and message (ErrorText), and the self-oracle's `names` law rejects a test name holding the package path. Determinism (R1c-6). The rule: observations are data. Two runs are compared by their stable text, so -0 and 0, object key order, and Map and Set order count (a check that iterates them can see them), and a function counts by its name, so a fresh closure is the same data. Before, isDeepStrictEqual passed key-order noise and failed fresh closures. Replay environment (R1c-7, R1c-8). The replay witness re-read PROPERTY/SEED/PATH and its channel from process.env; the read replay environment (selection, multiplier, calibration, witness channel and mode) and its parser now live in oracle-environment.ts, and the witness reads the configured read. readOracleRunConfig() returns a frozen copy of the four public fields, not the cached object. - RED (d676cf0): route oracle failed 7 tests (e.g. "the route of a seed the runner drew", "options round-tripped through JSON", "a seed set by hand": observed `fixed seed`, owed `random seed`); config oracle failed 4 ("a replay witness after the environment changed", "a mutated run configuration"); self-oracle failed 5 of 51 (name with the package path; key-order noise passed determinism; a fresh closure failed it; the random campaign and the self-oracle's own determinism on the same two causes). - GREEN: default suite 57 tests; self-oracle 51 tests (219 s); typecheck, lint (0 errors). - Mutants, each rejected: runner declares every seed fixed (route oracle, 3); any declaration counts whatever seed runs (both campaigns and a fixed history); the round-2 rule (unmarked seed is fixed; 6 tests); the reviewer's oracle-property.ts mutant `path ? fixed history : fixed seed` (seedless fixed history: ran under ["fixed seed"]); names keep stacks; determinism by isDeepStrictEqual (2); witness reads the live environment (2); readOracleRunConfig returns the cached object (3). - Limits: a declaration is lost across realms (serialized parameters), which under-claims by design; errors nested inside class instances keep their stacks; a function counts by its name only. Co-authored-by: Isaac <[email protected]>
…ction already read Law adopted by the maintainer (decision, 2026-11-08; finding R1b-1 on #1): once anything has read the replay selection, a configureOracles call that would change it throws and changes nothing. Tests already stood aside, or ran, by the selection they read, so a later selection would leave them wrong. A later call that keeps the selection still replaces the rest of the configuration; the first-call lock on the defaults stays. Before, every configureOracles call re-read the replay environment and replaced the selection, whatever had read it. - Production: oracle-environment.ts records that the replay environment was read; configureOracles compares the selection it would read (seed, path, property) with the one read and throws on a difference. - Config oracle: the model and prose state the new law; new declared state `a configuration that would change a read selection` (constructed), reached by 23/22 of 103 histories; fixed history "a reconfiguration that would change a read selection". - The declared-reach oracle's driver configured under each run kind's environment, which the law now refuses; it imports fresh modules per run kind instead, as a process of that kind would. config.test.ts: the example that reconfigured after a read now shows the refusal, on fresh modules. - RED (1ba5cde): config oracle failed 3 tests at step 2 under law `configure first` (the configuration was accepted); the new config.test.ts example failed. - GREEN: config oracle 10 tests, default suite 59, declared-reach oracle. - Mutant: a reconfiguration that silently changes the selection (check disabled) fails both campaigns and the fixed history. - Limits: the grammar varies the whole selection (replay or none), so a check that compared only one of seed, path, or property would not be told apart from this one. Co-authored-by: Isaac <[email protected]>
… is named Law adopted by the maintainer (decision, 2026-11-08; finding R1b-5 on #1): models must be prefix-total. A driver error or a controlled-clock spin cuts a trace short; a model that throws on the cut trace fails the history with an OracleModelError that names the model, the cut, and the model's error, instead of a setup error or `bounded clock`. With a prefix-total model, a violation recorded before the cut is still reported as that law's failure, as the header's "a later crash cannot hide an earlier wrong observation" promises. Shrinking keeps a model error as its own kind. - Production: judge calls the model on its own; a model error on a cut trace becomes OracleModelError; a spin no longer swallows it; the campaign predicate keeps `model` apart from `setup`. A check error and a model error on a full trace are unchanged. - Self-oracle: verdictOf's strict branch owes `model-not-total`; the classifier reads OracleModelError; fixed histories for a spin and a driver error that cut the trace, and a campaign that reports and replays a model error. - RED (1ba5cde): the spin case failed as `bounded clock` and the driver-error case as `setup`, each owed `model-not-total`. - GREEN: self-oracle 53 tests at 4x runs (254 s); default suite 59. - Mutant: a model error on a cut trace reported as before fails both fixed histories. Equivalent mutant: merging the model and setup shrink kinds survives, because fast-check removes only leading items here, so no shrink of a model error reaches a plain driver error; the self-oracle's limits say so. - Limits: a non-total check on a cut trace still ranks as before. Co-authored-by: Isaac <[email protected]>
… only stacks Round-4 review findings R1d-1, R1d-2, R1d-3, R1d-4, R1d-8, R1d-9, R1d-10 on #1. - R1d-1: an OracleModelError on a trace a driver error cut short carried only the model's error. It now quotes the driver's error in its message and keeps it as `driverError`, beside the model's error as `cause`. - R1d-2, R1d-3, R1d-4: stable text reduced every Error to name and message (losing own properties, cause, `errors`, and class), left an Error inside a class instance with its stack, and could throw while naming. It now copies arrays, Maps, Sets, plain objects, and class instances with their prototypes and own properties (an accessor as an accessor, so no getter runs), and each Error, wherever it is, with its prototype and every own property but `stack`; Node prints that copy as, e.g., `[SyntheticFault [Error]: synthetic] { code: 3 }`. Naming never throws: a value that cannot be copied falls back to its plain inspection, and then to its tag. - R1d-8: a spin after the last observation cuts nothing, so a model or check that throws on that whole trace is the parts' own (setup) error, not an OracleModelError. - R1d-9: OracleModelError is exported beside OracleViolation. - R1d-10: the determinism test compares plain data (primitives, arrays, plain objects, keys in order) directly and builds stable text only when that cannot decide. - Self-oracle: history forms `errors` (Error, a same-named subclass, an Error with a cause, an Error with a code), `boxed` (an Error in a class instance), `trap` (an enumerable getter that throws; enumerated only, because fast-check cannot print it); an Error-data noise driver; a model that throws on any trace holding a 7; verdictOf owes the driver's error in a model error and a setup error for an uncut spin. Also a defect in the self-oracle's own model, older than this round: a slow spec owed `timeout` everywhere, but a history outside the language fails its membership check before the driver runs; the model owes that now. - RED (a4bc942): self-oracle failed 8 of 58: the driver error missing from a model error; an uncut spin reported as a model error; Error histories named alike; a stack in a boxed history's name; a getter that throws failing the load; Error-data noise passing determinism; the random campaign (the membership case above); the self-oracle's own determinism (boxed names differ by run directory). Package test: OracleModelError missing from the exports. - GREEN: self-oracle 58 tests at 1x (222 s) and at 4x (258 s); default suite 63. - Mutants, each rejected: no driver's error in the message; an Error copy that keeps only its message; one that loses its class; class instances kept as they are; the original R1d-4 shape (properties read, outside the guard); every spin treated as a cut; a fast path that ignores key order. Equivalent: removing only one of the two R1d-4 guards (the copy calls no getter, so either guard alone suffices). - Limits: a message that names a path is kept, as data a check can read; dates, typed arrays, and other exotic objects are kept as they are; the fast path has no timing test. Co-authored-by: Isaac <[email protected]>
…nvironment seeds, never throw from a witness Round-4 review findings R1d-5, R1d-6, R1d-7 on #1. - R1d-5: the adopted R1b-1 law covers everything a read decided from. A reconfiguration could change the calibration variable after a calibration witness decided by it; the variable is now part of the selection a reconfiguration may not change. - R1d-6: oracleRandomParameters declared any defined seed fixed, so a caller's number or hand-built configuration (say, a Math.random seed) read `fixed seed`. Only a seed the process's replay environment selected is declared now: readOracleRunConfig() carries the declaration for its seed, and oraclePropertyOptions builds from it. A caller who means a fixed seed declares it with oracleFixedSeed. - R1d-7: recordOracleReplay and recordOracleFiniteReplay promise never to throw, but read the replay environment, which can be malformed; an environment that cannot be read now selects no witness. - RED (a4bc942): config oracle failed 3 ("a reconfiguration that would change a read calibration"); route oracle failed 4 ("random parameters from a caller's number" and "from a hand-built configuration" observed `fixed seed`, owed `random seed`); the new config.test.ts example threw with ORACLE_RUNS_MULTIPLIER=0. - GREEN: config oracle 11, route oracle 12, default suite 63. - Mutants, each rejected: calibration left out of the selection (3 tests); any defined seed declared (3); readOracleRunConfig declaring nothing (the seed-replay campaign); the witness without its guard. - Limits: the never-throws witness rule is an example, because the config oracle generates only valid environments. Co-authored-by: Isaac <[email protected]>
…tness write or a thrown value's text Round-5 review findings R1e-6, R1e-7, R1e-8 on #1 (R1e-1..R1e-5 and R1e-9, all in value rendering, are held for a maintainer decision). - R1e-6: on a controlled-clock spin, a driver error that came after the spin with no later observation was dropped: the trace was judged as whole, so the error and the cut were both lost. A spin now cuts the trace when anything follows it, an observation or a driver error, and a driver error after the spin, which still does not decide, is kept as the cause of what does (a recorded violation or `bounded clock`) and is carried by a model error on that cut trace. - R1e-7: appendWitness wrote unguarded, so an unwritable channel threw from recordOracleReplay and recordOracleFiniteReplay ("never throws") and, in oracleReplayReporter, replaced fast-check's counterexample and cause. An unwritable channel now records no witness. - R1e-8: an OracleModelError formatted a thrown non-Error with String(), which throws for a null-prototype object or a throwing toString, replacing the model error with a TypeError filed as setup. It uses the stable text, which never throws. - Self-oracle: a `throwOnSpin` driver (throws right after a spin, without observing more) and an `oddThrow` driver (a 6 throws a null-prototype object with a message); verdictOf keeps a driver error after a spin as the cause and counts it as a cut; the determinism model owes a setup error for that driver error too. The existing fixed history "a driver error after the clock spins does not decide" now owes that error as the cause. - RED (4bc3636): self-oracle failed 4 targeted fixed histories (driver error dropped after a spin, twice; a model error on a trace cut right after a spin reported as setup; the odd thrown value's text threw, failing as `other`); config.test.ts: ENOENT thrown by recordOracleFiniteReplay with an unwritable channel. - GREEN: self-oracle 61 tests at 4x runs (282 s); default suite 64. - Mutants, each rejected: a driver error does not cut a spin's trace; the driver error after a spin dropped (2 tests); the witness write unguarded; String() for the thrown value. - Limits: the unwritable channel is an example, since the config oracle has no file-system dimension. Co-authored-by: Isaac <[email protected]>
KyleAMathews
added a commit
that referenced
this pull request
Nov 9, 2026
…cal `probing` guard
Maintainer decision of 2026-11-08: a state probe's guard is a constant at
the top of each function that probes,
const probing = typeof process === 'undefined' ? false : process.env.NODE_ENV !== 'production'
probing && globalThis.__oracleProbe?.('package#name', condition)
The bare `process.env.NODE_ENV` guard throws ReferenceError in unbundled
browsers and Deno and reads the environment per record; a module-level
constant is not folded by esbuild in a module that has imports, so its
probes ship. Only the new form is accepted (no transition), as the
maintainer recommended: TanStack DB moves its probes at once.
- CLI (schemata.mjs): probe-only code is the guard declaration (a
`const probing` with exactly that initializer, in a function) and each
`probing && hook(name, condition)` statement whose `probing` resolves,
from the innermost block out, to that declaration without crossing a
function boundary. Every other shape is production code: the former
form, another name, `let`, another initializer, an outer function's
guard, a module-level guard.
- Lint rule `oracle/probe-form`: the same guard, resolved through ESLint's
scope manager (a `const`, one definition, the guard's initializer, bound
in the probe's nearest function scope). The name format, the two
arguments, the receiver, and condition purity are unchanged.
- Law: the probe form above (maintainer decision, 2026-11-08).
- Reach: static oracle: the preamble's helpers and every generated or
witness function that probes declare the guard, and a new witness
`w_near` holds each near-miss (former form, another name, `let`,
another initializer, outer function's guard), reached in both fixed and
random campaigns; the grammar also draws them as `nearProbe`
statements, which the e2e oracle classifies as production survivors.
Lint oracle: new kinds `block-guard` (legal), `former-guard`,
`other-name`, `let-guard`, `bare-init`, `and-init`, `outer-guard`, and
the guard's quote style; the census lints each.
- RED: static oracle "src/sut.ts:report:10:binary-swap#0: probe code is
false, owed true"; lint oracle "production file, production config:
expected [ '3:probeForm' ] to deeply equal []".
- GREEN: static and classify 15/15; e2e fixed seed passes; lint package
4130/4130.
- Mutants: CLI: former form still accepted ("w_near:158: probe code is
true, owed false"); any `probing` binding (":163"); guard declaration
judged as production ("report:10: probe code is false, owed true");
an outer function's guard (":170"). Rule: former guard accepted, any
`probing` binding, an outer function's guard, `let`, any initializer,
any name: each fails the census and both campaigns.
- Limits: a module-level guard, a parameter or function named `probing`,
and a guard declared after its probe (a temporal dead zone at runtime)
are not generated; both the CLI and the rule accept a guard declared
after its probe in the same scope. packages/oracles/src/oracle-property.ts
and the framework's self-oracle fixture still show the former form; they
belong to PR #1.
Co-authored-by: Isaac <[email protected]>
The probe form changed (maintainer decision, 2026-11-08): the function
where production decides a state guards its probe locally,
const probing =
typeof process === 'undefined' ? false : process.env.NODE_ENV !== 'production'
probing && globalThis.__oracleProbe?.('package#name', condition)
so a bundle without `process` (a browser or a native webview) skips the
probe instead of throwing. The header of oracle-property.ts showed the old
bare `process.env.NODE_ENV !== 'production' && ...` form, and the
self-oracle's synthetic driver used it; both use the new form now, the
late probe call as its own probing function.
No framework behavior changes. Default suite 64 tests; self-oracle 61
tests (222 s, 2 workers), every probe fixed history entering its named
states (agreement violation, false condition, never reached, reached and
not entered, forced calibrations, late probe calls).
Co-authored-by: Isaac <[email protected]>
KyleAMathews
added a commit
that referenced
this pull request
Nov 9, 2026
`recordOracleFiniteReplay` wrote with its own `appendFileSync`, because the no-disabled rule accepted a witness's `numRuns: 1` only as a typed `OracleReplayWitness` variable that `JSON.stringify` alone reads. PR #1's `appendWitness` guards the write (an unwritable channel records no witness and never throws), so the finite witness now goes through it, and the rule recognizes the record passed to it. - Law (no-disabled, replay observations): a plain witness literal is an observation when it is the second argument of `appendWitness`, which resolves to a function declaration of the writer module whose record parameter is an `OracleReplayWitness` that it only serializes; any other one-run literal is still reported. Authority: the maintainer's 2026-10-28 decision on serialized witnesses, and the request of 2026-11-08 to route this write through the guard rather than restore the inline write. - Reach: the replay-observation oracle gains 48 writer-call programs (module, writer body, parameter type, a shadowing callback, literal spelling), each a declared state. - RED: the one admissible writer-call program was reported (singleRun). - GREEN: 3898/3898; the repository lint passes on oracle-replay-witness.ts. - Mutants, each rejected: writer body not checked, callee not resolved (a callback named appendWitness), literal shape not checked, parameter type not checked, any module. Co-authored-by: Isaac <[email protected]>
KyleAMathews
added a commit
that referenced
this pull request
Nov 9, 2026
…all to a probe helper is probe code PR #1 names five routes (oracle-route.ts): `fixed seed`, `fixed history`, `case`, `random seed`, `calibration`. The CLI still counted the retired `constructed history` and `enumerated` as reproducible and `probe calibration` and `determinism` as framework checks. They are unknown routes now, in classify.mjs and in the capture's stop-at-first-kill. The model's boot dimension (b20b5a1) marked the module-level call to a booted first function as production even when that function is a probe helper; law 2 makes a call statement to a probe helper probe-only, as the CLI does. A random static campaign found it ("src/sut.ts:<module>:40:delete-call#0: probe code is true, owed false"). - Law: law 4's route kinds in the framework's vocabulary (authority: oracle-route.ts in PR #1); law 2 for the boot call. - Reach: both oracles keep the retired names in their route pools, where they must read as unknown routes. - RED (unchanged classify.mjs): "mutant m0: framework-error, owed crashed"; "mutant m2: crashed, owed unregistered-kill". - GREEN: static and classify 15/15 (static also under four random seeds). - Mutants: retired reproducible names kept ("killed, owed unregistered-kill"); retired framework names kept ("framework-error, owed crashed"). - Limits: the capture's stop-at-first-kill set has no mutant of its own; report.mjs still describes the calibration route's three checks. Co-authored-by: Isaac <[email protected]>
KyleAMathews
added a commit
that referenced
this pull request
Nov 9, 2026
…lls its callback is not guarded The merge of PR #1 brought its self-oracle fixture's `if (spec.nested) describe(outerSuite, register) else register()`, which registers the property's tests on both branches, inside the suite or beside it. no-disabled reported the `describe` as a registration only under a condition. The rule now leaves out such an `if`: the suite is its branch's only statement, its callback is a name, and the other branch only calls that name with no arguments. Every other conditional suite is still reported. - Law: no-disabled reports a registration that can stop running in ordinary runs (AGENTS.md); one that runs on every branch is not one. - Tests (no-disabled has unit tests, no oracle): three admissible forms (bare, braced, reversed) and three near-misses (another call in the other branch, no else, a second statement beside the suite). The pinned count of the replay-observation oracle's programs moves from 3848 to 3896 with its 48 writer-call programs. - RED: the three admissible forms were reported (guarded). - GREEN: lint package 4184/4184; `pnpm lint:check` passes on the merged tree. - Mutants: either branch check alone (`||`): three near-misses accepted; the suite's own branch unchecked: one accepted. Both rejected. Co-authored-by: Isaac <[email protected]>
…a domain
Maintainer decision (2026-11-08): observations (`observe` values) and
enumerated histories are data, and a driver converts anything else. The
domain: primitives (with -0, NaN, the infinities, bigints, and undefined),
dense arrays, plain objects with string keys (Object.prototype or a null
prototype), Maps, Sets, and Errors (name, message, own data properties,
cause, AggregateError errors). Anything else fails the history at once
with an OracleDataError that names the value's path in the trace and its
kind, e.g. `observation 3 ("result") .reason: DOMException is not
observation data`; an enumerated source holding such a history fails to
register, e.g. `history 0 .trap: an accessor is not history data`.
This resolves the held round-5 findings R1e-1..R1e-5 and R1e-9 by design:
there is no renderer for values outside the domain any more.
- One encoder, encodeData, replaces stableText, machineFree, and sameData.
It produces both test names and the determinism comparison: equal
encodings exactly when the values are the same data, with key order and
Map and Set order significant, -0 distinct from 0, an object's prototype
not data, and no stack, so names are the same on every machine. JSON
data encodes as its JSON text, so the names of JSON histories do not
change.
- Every observation is encoded when it is observed; the first that is not
data fails the history at once, also when the driver catches the error
its observe call throws, and shrinking keeps a data error as its own
kind. The determinism test compares the encodings taken at observe time.
- Out of the domain: cycles, sparse arrays and arrays with other
properties, accessors, hidden properties, symbol keys, class instances,
functions, symbols, DOMException, objects from another realm, typed
arrays, and Dates. A Date is left out on purpose: its data is an instant,
which a driver states as a number or an ISO string of its choosing; the
TanStack DB oracles already convert with getTime().
- New export: OracleDataError.
- Self-oracle: an `odd` dimension records, first, a value of each kind the
domain holds and of each kind outside it; the model owes the data error's
path and kind for each outside kind, a registration failure naming the
history's path for enumerated `boxed` and `trap` histories (labelled or
not), and an unchanged run for in-domain data. The `freshClosure`
dimension is retired (functions are not data). Two self-oracle helper
defects that the 4x campaign reached are fixed: a `lossy` counterexample
(`Number.NaN`, `-0`) is read back, and an `errors` counterexample, which
fast-check prints without its items, is skipped by the shrink and replay
checks (a stated limit).
- RED (4580e0e): self-oracle failed 14 of 72: each of the 11 outside kinds
observed was accepted, the two enumerated out-of-domain histories loaded,
and the fixed-seed campaign passed an outside kind.
- GREEN: self-oracle 73 tests at 4x runs (340 s); default suite 64; every
in-repo oracle already observes data.
- Mutants, each rejected: cycles accepted (fails as an unreadable value at
the wrong path); -0 dropped (names collide; determinism passes -0 vs 0);
key order ignored (determinism passes reordered keys); class instances
accepted as objects (4 kinds); an Error keeps its stack (a hidden
property fails); only unlabelled enumerated histories validated.
- Size: oracle-property.js +175 B gzip (6195 -> 6370), index.js +13 B.
The encoder is about the renderer's size; the rest is the new
fail-at-once path (observe-time encoding, the error class, path messages,
registration validation). Tried: one path helper, one text fallback, no
separate sparse loop, no unreadable-value wrapper.
- Limits: an Error's own string data (a message or a `path` naming a
file) is kept as data; a proxy whose trap throws fails as a setup error,
not a data error; generated histories are not checked (fast-check
prints them), and failure text shows why one is not data.
Co-authored-by: Isaac <[email protected]>
…'s code Round-6 review findings R1f-1..R1f-9 on #1, all in the encoder; the domain decision (maintainer, 2026-11-08) stands. The rule implemented: membership and encoding read only own property descriptors, prototypes, and internal slots (Array.isArray, util.types brands, Map and Set iteration through the intrinsic methods, Object.getOwnPropertyDescriptor, Reflect.ownKeys), never [[Get]] through a getter, and a proxy is not data. - R1f-1, R1f-3: an array is data only when its own keys are exactly its indices, each an enumerable data property, and `length`. Before, the check counted keys (`[1,,3]` with one extra key passed) and read elements with [[Get]] (a getter ran; a hidden index passed). - R1f-2: a Map or a Set has no own properties. - R1f-4: an Error's name and message are data properties found on the Error or its prototype chain (a getter there is not data); `new Error()` and `new Error('')` are the same data. - R1f-5: a proxy is not data, and any exception while an exotic object is read becomes an OracleDataError naming the path. - R1f-6: Arrays, Maps, Sets, and Errors are recognized by their brands, and their prototypes as a realm's intrinsics, so data from another realm is data (stated in the header). Rejections name the kind: a class by its constructor's name, "an instance of an anonymous class", "an object with a custom prototype". - R1f-9: a key that is not an identifier is quoted in a path. - R1f-7: a failure report prints a generated history that is not data through Node's inspection, on one line; names and comparisons never use it. A thrown value in a model error is printed the same way. - R1f-8: an observation is checked when it is observed, without building its encoding; only the determinism test builds encodings, and shared subtrees are read once. - Self-oracle `odd` shapes for each finding (array with holes and a key, array with a key, accessor and hidden indices, Map and Set own properties, own name getter, prototype message getter, revoked proxy, custom prototype, anonymous class, dotted key, shared references 23 levels deep under a 5 s timeout), cross-realm data in the `domain` value, an `emptyMessage` driver, and a check that a law's failure prints a generated non-data history. - RED (5e39fcb): 17 targeted fixed histories failed: cross-realm data rejected as "an object from another realm"; the shared value timed out; `new Error()` vs `new Error('')` failed determinism; the report printed "(history: SyntheticBox is not observation data)"; each out-of-domain shape accepted, misnamed, or escaping as a getter's own error. - GREEN: self-oracle 87 tests at 4x (429 s) and three times at 1x (391, 405, and, under load, 468 s); default suite 64. The first verification run caught my own new check recording the report's History text, whose stack names each run's directory, in the self-oracle's trace; it now records only whether the history is shown. - Mutants, each rejected: holes not checked per index; no Map/Set own-key check; elements read through [[Get]]; name or message read through [[Get]]; no proxy check; realm-bound prototype identity; no report fallback; no memo of shared subtrees (timeout); unquoted keys. Equivalent at this size: building encodings at observe time with the memo kept (string building is linear in the output). - Size: oracle-property.js +475 B gzip (6370 -> 6845), for the exact membership checks. - Limits: a DOMException from another realm is read as an Error; a null-prototype object used as a prototype that also holds a `hasOwnProperty` function is taken for Object.prototype; a monkeypatched intrinsic Map or Set iterator would run. Co-authored-by: Isaac <[email protected]>
…d reports in the domain Round-7 review findings R1g-1..R1g-9 on #1. - R1g-1: round 6 moved encoding out of observe calls, so the determinism test encoded stored observations after the driver finished, by reference: a live array or Map observed twice and changed in between compared only its final state, and a value that later gained a Date failed only in determinism. The determinism test now records each observation's encoding inside the observe call; ordinary runs still only check. - R1g-2: `differs` compared with isDeepStrictEqual, which compares prototypes, so data from another realm never equalled the same data built here. Two data values are now equal when they are the same data, whatever order their object keys and Map and Set entries come in (as isDeepStrictEqual treated order before); values outside the domain still compare by isDeepStrictEqual. - R1g-3: a stack or string-length overflow on valid data (a list 20,000 links long) was reported as "an object that cannot be read". It now fails as a framework limit: "the value is deeper or larger than the framework's encoding limit", with the RangeError as its cause. - R1g-4: proxy traps still ran through a proxied prototype (instanceof, the Object.prototype test). The whole prototype chain is checked for a proxy before any walk: "an object with a proxy prototype". - R1g-5: the domain's Error is the native brand only; an old-style Error (an Error prototype without [[ErrorData]], as util.inherits libraries build) is named "an old-style Error without the native brand". The header says so. - R1g-6: a check-only pass builds no strings. - R1g-7: a report of a value that is not data (a thrown DOMException in a model error) printed its whole stack, with machine paths, on one line; report text now drops stack frames and is bounded at 2,000 characters. - R1g-8: the module header states the domain as encodeData does (the array rule, Maps and Sets without own properties, enumerable data properties, the native Error brand, no proxy prototype, the limit). - R1g-9: the array branch checks for an extra key first and reads each index descriptor once. - Self-oracle: drivers that observe a live array and Map at two checkpoints with a first value that alternates between runs (`liveNoise`), observe a live array and then put a Date in it (`liveDate`), observe a list from another realm that the check compares with `differs` (`realmCheck`), and throw a DOMException (`domThrow`); `odd` shapes for a 20,000-deep list (owed a framework limit), an Error and an object with a proxy prototype whose traps throw if they run, and an old-style Error; a check that a model error quotes no machine path. - RED (8fab15e): 8 targeted fixed histories failed: live values passed determinism, and a later Date failed it; differs rejected the cross-realm list; the deep list failed as "an object that cannot be read"; both proxy-prototype shapes as "an object that cannot be read"; the old-style Error as "an object with a custom prototype"; the DOMException model error quoted machine paths. - GREEN: self-oracle 95 tests at 4x (453 s) and three times at 1x (421, 417, and, under load, 429 s); default suite 64; build, typecheck, lint, publint. - Mutants, each rejected: encoding stored observations after the driver; differs by isDeepStrictEqual; a RangeError read as non-data; no proxy check on the chain; the old-style Error unnamed; report text without the stack filter. A separate name-and-message branch for non-data Errors was redundant with the stack filter (its removal survived) and is gone. - Size: oracle-property.js +150 B gzip (6845 -> 6995). - Limits: as before, a DOMException from another realm reads as an Error; the R1g-6 change has no timing test. Co-authored-by: Isaac <[email protected]>
…y and reports exact Round-8 (final) review findings R1h-1..R1h-4 on #1. R1h-5..R1h-9 are follow-ups. - R1h-1: the determinism test compared observe-time encodings, but the model and check judged the live value: `observe('a', s); s.n = 2` passed determinism while the check read the change. The trace now holds a copy of what each observe call saw (observations are data, so a structural copy is well defined): arrays, plain objects, Maps, Sets, and Errors keep their prototypes, brands, and own properties, and a shared reference stays shared. The gap report's observation hook receives the same copy. - R1h-2: data equality in `differs` caught every error and fell back to isDeepStrictEqual, so the framework-limit error became a bare RangeError (two equal 20,000-deep lists) and large cross-realm data compared unequal. Only a value outside the domain falls back; a framework limit propagates as itself. - R1h-3: report text dropped whole stack-frame lines, and with them the ` {` that Node prints after an Error's last frame when the Error has properties. It now strips only the frame text. - R1h-4: a prototype's `constructor` was read without a proxy check, so a proxied constructor ran a trap; it is now "an instance of a proxied class". - Self-oracle: a `snapshotCheck` driver (observes an object, then changes it; the check compares what was observed), a `deepCheck` check (differs on two equal 20,000-deep lists, owed the framework limit), a boxed Error with an own property and a check that the report's braces balance, and an odd shape whose prototype's constructor is a proxy whose traps throw. - RED (5d74897): 4 targeted fixed histories failed: the check read the later change (violation); differs threw a bare RangeError (`other`, owed `limit`); the report's braces did not balance; the proxied constructor failed as "an object that cannot be read". - GREEN: self-oracle 98 tests at 4x (505 s) and three times at 1x (488, 491, and, under load, 503 s); default suite 64; build, typecheck, lint, publint, sherif. - Mutants, each rejected: judging the live reference; falling back on every error; dropping whole frame lines; reading a proxied constructor. - Size: oracle-property.js +288 B gzip (6995 -> 7283), mostly the observe-time copy. Co-authored-by: Isaac <[email protected]>
CI's self-oracle determinism test timed out at 600 s on d93a15d. The time was the self-oracle's child Vitest processes, not the framework's observations: - With an instrumented recordGuarded, every observe call in the whole determinism test (validate, encode, copy) took 43 ms in total, at most 1.3 ms for one call, out of about 300 s. - The 55 fixed histories that 4580e0e and d93a15d share took 78 s and 70 s. Per history, nothing slowed down. - The growth came from new fixed histories (58 to 95, mostly one per out-of-domain kind). Each spawns up to three child Vitest runs, and the determinism test runs each twice more. - In a CPU profile of one child, about half of its startup was loading @microsoft/api-extractor and the other declaration tooling, through @tanstack/vite-config's vite-plugin-dts. Every Vitest run loaded them, and a test run uses none of those plugins (the package has no tsconfig paths). The default config now imports @tanstack/vite-config only when Vite builds. The test settings are exported as testConfig for the self-oracle's config. The build output is byte-identical (diff -r of dist before and after). Self-oracle, ORACLE_SEED=1928265604, 1x, 2 workers, one quiet machine: commit total determinism 4580e0e 244 s 151 s d93a15d 483 s 322 s this 242 s 158 s A single small test file: 1.0 s before, 0.6 s after. Verification: the self-oracle passed at 4x (243 s) and three times at 1x (228 s, 244 s, and 296 s under load from a looping default suite), 98/98 each. Build, typecheck, lint, publint, sherif, format, and the default suite (64/64) passed. Limits: no law, model, history, or check changed, so there is no RED, mutant, or reach. Nothing guards the startup cost. CI time still grows with each fixed history added to the self-oracle (about 0.8 s for its own test, and again for each of its two determinism runs). Co-authored-by: Isaac <[email protected]>
2 of 3 tasks
KyleAMathews
added a commit
that referenced
this pull request
Nov 9, 2026
main's tree equals #1's head cc7afba, which this branch already contains, so every conflict takes this branch's side and the merged tree equals b937148's tree. Co-authored-by: Isaac <[email protected]>
KyleAMathews
added a commit
that referenced
this pull request
Nov 9, 2026
* feat(oracles): extract the oracle framework core from TanStack DB Move the oracleProperty framework into @tanstack/oracles: declareOracle, createOracleReach, runOracleCampaign, failure fidelity, the replay witness, the controlled clock, and the replay configuration. The framework's own self-oracle and property tests move with it. The replay configuration is a factory. configureOracles sets the environment prefix, the property registry, and the retired replay variables, so TanStack DB keeps its TANSTACK_DB_ORACLE_* names and its registry unchanged. Without a configuration the prefix is ORACLE and every property id is accepted. Also adds the browser-safe @tanstack/oracles/declaration entry, which loads no Node built-ins, and widens the vitest peer range to ^4.1.0 || ^5.0.0. Co-authored-by: Isaac <[email protected]> * fix(oracles): exclude the self-oracle from the default run and tidy the seam - vite.config.ts: the default `vitest --run` collected oracle-property-self-oracle.test.ts, which spawns child Vitest runs for about five minutes. The framework config and TanStack DB both assume the default run excludes it; `pnpm test:oracle-framework` still runs it. - oracle-config.ts: drop the two re-exports of recordOracleReplay and declareOracle; index.ts already exports both names. - oracle-config.ts: list REPLAY_WITNESS_MODE among the documented variables. - oracle-reach.ts: remove the TanStack DB issue reference from a comment. - oracle-campaign.ts: use .js specifiers like the rest of src. - oracle-property.ts: attach the __oracleRoute and __oracleVerdict comments to the declarations they describe. No runtime behavior changes. Evidence: `pnpm test` (6 files, 25 tests), `pnpm test:oracle-framework` (37 tests), build, typecheck, publint --strict, and eslint pass. The default run now lists six test files. Co-authored-by: Isaac <[email protected]> * fix(oracles): read the configuration when it is used, and replace it whole Review fixes for the configuration seam and the package entry. - Nothing is read at import. The replay environment is read by configureOracles, or, in a project that never configures, on first use. Before, the module read and validated `ORACLE_*` at load, so a stray `ORACLE_PATH` (SQL*Plus sets it) made `import '@tanstack/oracles'` throw in a project with its own prefix. - configureOracles checks everything, including the replay environment under the new prefix, before it changes anything, and then replaces the prefix, registry, retired variables, and replay selection together. A rejected call leaves the previous configuration whole; before, it left the new prefix and registry with the old replay selection. - A first configureOracles that changes the defaults after an oracle already read them throws, so a project that configures too late fails loudly instead of running full campaigns under the default prefix. - The main entry is ES modules only: it imports Vitest, which refuses require(), so its CommonJS build could not load. `./declaration` keeps its CommonJS build. - The campaign test that checks reach independence now sets a path replay under the configured prefix; it stubbed a variable nothing read. - Docs: the `ORC-` rule numbers point at TanStack DB's oracle rubric; a fixed history is called one (not an example); the probe hook's install at import is explained; the ordinary configuration test is renamed `config.test.ts`. RED (before this commit): the three new configuration tests failed (stray default variable, rejected replay environment, late configuration), and the export test failed on the previous manifest; a campaign that inherits the global replay mode failed the strengthened campaign test. GREEN: 29 tests in 6 files; the self-oracle 37 tests (198 s); build, typecheck, lint (0 errors), publint. TanStack DB on this build: offline-transactions 396 tests, db-ivm 684, db oracle-replay and SortedMap 107. Co-authored-by: Isaac <[email protected]> * docs(oracles): name the environment names that the prefix does not change ORACLE_MANIFEST and the ORACLE_SEED and ORACLE_REACH log tags keep fixed names whatever prefix a project configures, because tooling reads them across projects (maintainer decision, 2026-11-08). runOracleCampaign takes its prefix from its caller, so a package's own campaigns stay apart from the project's replay selection. Co-authored-by: Isaac <[email protected]> * fix(oracles): print rerun commands that match on Vitest 5, and test on it Vitest 5 matches `-t` against a test's suite and test names joined by ` > `; Vitest 4 joins them with a space. A failing history printed `-t "^<suite> <test>$"`, so on Vitest 5 its rerun command skipped the test. The pattern now accepts either separator between the suite and the test name, each still escaped and anchored. CI gains a job that runs the package's tests and the self-oracle on Vitest 5, which the peer range claims (maintainer decision, 2026-11-08). The main job now runs the self-oracle too: the default test run leaves it out, so CI did not run it. - Law: rerun — a violation's printed rerun command runs exactly that test (the self-oracle's law). - RED: on Vitest 5.1.0, the self-oracle failed 7 histories under law `rerun`, e.g. "self-oracle.synthetic-0 rerun of "fixed history: fixed-0": "fixed history: fixed-0" did not fail again". A direct probe: Vitest 5 matches `^outer id > fixed history: fixed-0$`, not `^outer id fixed history: fixed-0$`; Vitest 4 the reverse. - GREEN: the self-oracle passes on Vitest 5.1.0 (37 tests, 135 s) and on Vitest 4.1.12 (37 tests, 147 s); the default suite passes (29 tests). - Mutant: the previous pattern is the mutant; it fails on Vitest 5 as quoted under RED. - Limits: a test nested more than one suite deep is not a case the framework prints (its tests sit directly in the property's suite). Co-authored-by: Isaac <[email protected]> * chore: add a changeset for the oracle framework core Co-authored-by: Isaac <[email protected]> * refactor(oracles): name the fixed-history helper for what it adds, and remove two duplicates - withOracleExamples becomes withOracleFixedHistories (maintainer decision, 2026-11-08): the glossary calls these fixed histories, and fast-check's `examples` option is only the mechanism. TanStack DB does not call it. - runOracleCampaign no longer copies the replay path into a second object. - The replay witness builds and appends a record in one place for both the guarded and the finite replays. Behavior unchanged: default tests 29, self-oracle 37 (146 s), typecheck, lint, build. Co-authored-by: Isaac <[email protected]> * feat(oracles): add the oracle-gaps CLI The gap report moves from TanStack DB into the package as the oracle-gaps bin. It lists the production behaviour that a project's owning oracles leave unexercised or unjudged. - The evidence store is a JSON file, flushed after each check, instead of a TanStack DB collection on SQLite. The daemon's incremental-equals-cold law is unchanged. - The seed variable is ${--env-prefix}_SEED, default ORACLE; the CLI carries it in each run's state. - The framework source is hashed from src/oracle-property.ts, and the three gap oracles import the package's src. - Its tests use the package's own TypeScript, Vitest, and fast-check. Co-authored-by: Isaac <[email protected]> * feat(eslint-plugin-oracles): publish the oracle lint rules as a package The oc/* rules move from TanStack DB's scripts into @tanstack/eslint-plugin-oracles, a separate package so that the framework keeps no parser dependency. The rules recognize the framework by package specifier (@tanstack/oracles, its declaration entry) and by a relative module with the framework's file name. A project's variable prefix and its replay modules are settings under settings.oracles. Messages name neither AGENTS.md nor a fixed variable prefix. Two part-reach paths (the lint CLI and its edit-hook form) stay with the repository that owns the hook script. Co-authored-by: Isaac <[email protected]> * chore: wire the lint plugin into the repository's ESLint config The root config enables the plugin's recommended and production configs. The framework's oracle-* modules are excluded from the production probe rule, since they install the probe receiver. The root tsconfig turns checkJs off, because the config imports the plugin's untyped JavaScript. Co-authored-by: Isaac <[email protected]> * fix(oracle-gaps): load the package's own Vitest config as Vitest does The runner imported `./vite.config.ts` and merged it as an object. A package whose config exports a function (react-db: `defineConfig(async () => ...)`) failed with "Cannot merge config in form of callback", and a package with only `vitest.config.ts` or `vite.config.mjs` did not load. The runner also did not set the variables that Vitest's CLI sets before it loads a config (VITEST, TEST, NODE_ENV ??= test), so svelte-db's config, which picks its resolve conditions under VITEST, resolved the server build and two oracles failed with no mutant active. The runner now finds the config file in Vitest's order, calls a function export with the config environment, and sets those variables first. - Law: the report judges a package whose Vitest config Vitest itself loads, under the environment Vitest's CLI gives that config. - Reach: the fixture's config gains three generated dimensions (export form, file name, a config that finds its tests only under Vitest's environment). The "every outcome class" construction uses an async function in vitest.config.ts that reads that environment; three new required states record a kill under each. - RED: the e2e fixed seed failed on the unchanged runner ("the CLI did not complete (exit 1)", an esbuild load error). - GREEN: static and classify oracles 14/14; e2e fixed seed passes. - Mutants: no VITEST (a kill reported as unowned), only vite.config.ts (CLI did not complete), no function call (CLI did not complete): all rejected. - Limits: configs in vite.config.ts, vitest.config.ts, or vite.config.mjs only; no projects, no --config option. Co-authored-by: Isaac <[email protected]> * fix(oracle-gaps): run a package with a native addon in child processes The runner's default pool is worker threads, which start much faster than child processes. A native addon can crash the whole process from a worker thread. On TanStack DB's node-db-sqlite-persistence (better-sqlite3) the CLI exited 139 with no output, twice in a row; on browser-db-sqlite-persistence a V8 fatal error in a worker thread left the CLI hung until its timeout. Both pass with `--pool forks`. The default pool is now `forks` when a direct dependency or devDependency of the package has a `binding.gyp` beside its manifest, and `threads` otherwise. `--pool` still overrides it. The report's inputs line names the pool. - Law: the report runs a package with a native-addon dependency in child processes, and says which pool it used. - Reach: the fixture's workspace dependency gains a generated `binding.gyp` (1 in 4 histories); the "every outcome class" construction has one, so its whole witness runs on child processes. New required state: "a package with a native addon ran in child processes". - RED: e2e fixed seed on the unchanged runner: "the run did not use the threads pool" (the report named no pool). - GREEN: static and classify oracles 14/14; e2e fixed seed passes. - Mutant: always threads: "the run did not use the forks pool". - Limits: direct dependencies only; an addon that ships no binding.gyp (a prebuilt-only package) is not detected; a crash in a child process is not yet reported as such. Co-authored-by: Isaac <[email protected]> * chore: run the gap report's oracles in CI, and pass the oracle lint rules - CI's Test job runs the gap report's static and classify oracles and the end-to-end oracle's fixed seed. Before this, no CI job ran them. - `oracle-campaign.ts` selects a replay from the configuration, so it is one of the framework's replay-selection modules in the lint settings. - The finite replay witness is a typed record serialized in place again, the shape the no-disabled rule accepts as a witness and not as fast-check options with one run (5f043a0 had passed it through appendWitness). - The package leaves out the gap oracle's scratch directories. - Changesets for the oracle-gaps CLI and @tanstack/eslint-plugin-oracles. Verified: lint:check 0 errors, typecheck, build, format:check, test (29), self-oracle (37), publint --strict, sherif. Co-authored-by: Isaac <[email protected]> * docs(oracle-gaps): state the real --contexts limit and document --pool Co-authored-by: Isaac <[email protected]> * fix(oracle-gaps): give each copy fresh globals when a setup file defines one All copies in a batch share one realm, and each copy starts from the worker's first globals: the harness deletes the globals that an earlier copy added. A setup file that defines a new global without `configurable` defeats that. offline-transactions' tests/setup.ts defines `indexedDB` that way, so every later copy's setup threw "Cannot redefine property: indexedDB" and 25 kills on KeyScheduler became setup-error gaps (10 killed / 31 gaps). Before the config fix the runner had loaded vite.config.ts, which has no setup file, so earlier reports on this package judged its tests under a config that CI does not use. The harness now runs before the package's own setup files, and a new global that a copy defines on globalThis stays configurable, so the reset can remove it. - Law: each copy runs as in a fresh worker, including a setup file that defines a non-configurable global. - Reach: the fixture's config may name a setup file that defines a new global without `configurable` (1 in 4 histories); the "every outcome class" construction has one. New required state: "a setup file that defines a fixed global ran in every copy". - RED: e2e fixed seed: "src/sut.ts:w_kill:32:if-false#0: setup-error, owed killed". - GREEN: static and classify 14/14; e2e fixed seed passes. On TanStack DB, KeyScheduler gives 35 killed / 6 gaps again, now under vitest.config.ts. - Mutants: harness after the package's setup files, and new globals left non-configurable: both rejected with the RED difference. - Limits: a global that existed before the first copy and that a setup file makes non-configurable is not covered. Co-authored-by: Isaac <[email protected]> * fix(oracles): reject a schedule choice that names no queue scheduleFrom computed `choices[step] % queues.length` for any number. A negative or fractional choice indexed no queue, findIndex returned -1, and `pending.splice(-1, 1)` released the newest pending task, out of its queue's order (review finding R1-1 on #1). The contract names a queue only for a nonnegative integer and promises no normalization, so such a choice is a caller's breach: scheduleFrom now throws when it is called with one, before it releases anything. - Law: a data schedule releases each queue's tasks in order for every accepted choice list, and rejects a choice that is not a nonnegative integer when called (scheduleFrom contract in oracle-property.ts; fail fast on a contract breach, TanStack DB AGENTS.md). - Reach: the scheduler self-oracle generates negative, fractional, and non-finite choices beside natural ones; declared state `a choice that names no queue` (constructed) reached by 134 of 200 histories in the fixed-seed campaign, 140 in the random one; 67 and 61 histories still check the release order. - RED (parent): `vitest run tests/oracle-property-scheduler-oracle.property.test.ts` failed 4 tests under law `invalid choice`, e.g. fixed history "a negative choice names no queue": "a choice names no queue, but the schedule accepted it". A direct probe released ["storage 2","storage 0", "provider 1"] for choices [-1] and [1.5]. - GREEN: the scheduler oracle passes, 6 tests. - Mutant: a narrow fix that rejects only negative choices fails 3 tests, both campaigns (shrunk to choice 5e-324) and the fractional fixed history; removing the check is the parent's RED. - Limits: a rejected schedule is observed as a throw, not by its message. Co-authored-by: Isaac <[email protected]> * fix(oracles): let withinTurns answer true for a promise that already settled withinTurns(promise, 0) answered false even when the promise had settled before the call: the expiry, an async function with no turn to wait, fulfilled before the promise's own settlement callback ran, and won the race (review finding R1-7 on #1). Its contract says it answers true as soon as the promise settles, and a promise settled before the call settled before any deadline. The expiry now lets settlement callbacks that are already due run, then answers whether the promise settled. The doc no longer claims "the same microtask an await would", which the race never gave. withinTurns had no oracle (the self-oracle listed it as a limit). It gets a small one: when a promise settles (already, in turn 1 to 3, or never), whether it rejects, and the number of turns; the driver counts turns with its own ticker, and the check compares the answer and the turn it arrived in with the rule. - Law: withinTurns resolves true in the turn its promise settles when that is before the deadline, a promise already settled at the call included, and false in the deadline's turn otherwise (withinTurns contract in oracle-property.ts). - Reach: declared state `an already settled promise with no turns` (constructed) reached by 51 of 101 histories (fixed seed) and 54 (random); measured: settled before the deadline 65/68, deadline first 29/27, a tie 7/6. - RED (parent): `vitest run tests/within-turns-oracle.property.test.ts` failed both campaigns under law `deadline`, counterexample {"settles":"already","rejects":false,"turns":0}. - GREEN: 3 tests pass. - Mutants: `return state.settled` without letting due callbacks run fails both campaigns on the same counterexample; a withinTurns that waits every turn before it answers fails both on {"settles":"already","turns":1} under law `turn`. - Limits: settlement in the deadline's own turn may answer either way; settlement in a later microtask of the calling turn is not generated. Co-authored-by: Isaac <[email protected]> * fix(oracles): read one configuration everywhere Three review findings on #1 in the configuration seam, one law: every oracle read uses the one configuration in force, the replay environment is read once under it, and a first configureOracles that changes the defaults after any read throws. - R1-5: only a replay-environment read marked the defaults as read. A registry check before configureOracles (an oracleProperty registration, or oracleRandomParameters at file load) passed against the empty default registry, and a later configureOracles({ registry }) was accepted. - R1-6: createOracleReach re-read the live environment through readOracleRunConfig(), while replay selection (oracleReplayRequested, oracleReplayTest) kept the configured read. After the environment changed, tests stood aside while reach still checked, or the reverse. - R1-9: the prefix was stored twice, in oracle-config.ts and oracle-environment.ts, kept in step by hand. oracle-environment.ts now holds the only copy of the configuration (prefix, registry, retired variables) and the read flags. Every read goes through oracleSettings(), which marks the defaults as read before the first configuration, so a registry check and a variable name count as reads. createOracleReach reads oracleReplayRequested(). readOracleRunConfig with an explicit environment also counts as a read now: it reads the prefix, registry, and retired list. The declared-reach oracle's driver set a run kind's environment and relied on createOracleReach reading it live. It now configures under that environment, and configures the process's own afterward; this is valid on both the parent and this commit, and its model and prose say the reach reads the configured selection. - Law: as above (configureOracles contract in oracle-config.ts: the replay environment is read at configuration or first use; configure before oracles read). - Reach: new oracle tests/config-oracle.property.test.ts, fresh modules per history; declared states (all constructed) `a configuration after a registry read` 17/18, `an environment change after configuration` 40/43, `a calibration witness under another prefix` 16/20 histories (fixed / random campaign, 102 each). - RED (parent): `vitest run tests/config-oracle.property.test.ts` failed 4 tests: both campaigns and fixed history "a registry check before configuration" at step 1 under law `configure first` (the configuration was accepted); fixed history "a replay set after configuration" at step 3 under law `one configuration` (reach skipped its check, replay selection saw no replay). - GREEN: the config oracle passes 5 tests; default suite and declared-reach oracle pass. - Mutants: a registry check that does not mark the defaults read fails 3 tests under `configure first`; a reach that reads the live environment fails 3 under `one configuration`; a second prefix copy that configuration does not update (oracleEnvName fixed at ORACLE) fails both campaigns on a calibration witness under ACME. - Limits: one registered id, valid replay selections; retired variables, multipliers, and malformed environments stay with config.test.ts. The calibration variable is read when its witness registers. Co-authored-by: Isaac <[email protected]> * fix(oracle-gaps): tell same-named functions apart, read any --source spelling, keep Svelte runes in place Three static defects, each found in review of PR #2 or in TanStack DB's conversion: - R2-1, R2-2: owners.mjs indexed functions in a Map by name, and named an object literal's method after the class around it. A literal method `run` inside `Store.other` replaced `Store.run`, so the owned method's mutants fell to `<module>` (unowned), and a second nested `next` hid the first. Getters, setters, and class-field arrows were no functions at all. Functions are now a list, each with its node; ownership walks nodes, a mutant's owners are its innermost function's, and a class member is `Class.member` only when its parent is the class. - R2-3: `--source ./src/x.ts` was used as spelled, so it matched no owns entry and every mutant was unowned. parseArgs now names each source by its path in the package. - R2-12: in a `.svelte.ts` module, `value-undefined` wrapped `$derived.by(...)` and `delete-call` wrapped `$effect(...)`, which the Svelte compiler refuses (`state_invalid_placement`); every svelte-db oracle failed unmutated. A rune that Svelte allows in one place only is no site in a Svelte module; its arguments are still mutated. - Law: owning an entry owns exactly its static reference tree, and each mutant belongs to its innermost function, whatever names repeat (CLI law 3, law 1's naming); a source is the same file in every spelling; instrumenting a source does not change whether it compiles (Svelte's rune placement rule). - Reach (static oracle, fixed seed 20261105 / random): same-named literal method and nested helpers 10-12 histories each; getter, setter, field arrow 11-12; `./` spelling 9-10, redundant segment 3; Svelte module 15-19; `$`-named call outside Svelte 10-14. The "every static state" construction reaches all but the redundant spelling, which "a whole-file owner" reaches. - RED (unchanged production): rune placement, "the instrumented Svelte module moves a rune from its place: $effect(() => { ... })"; with runes off, enumeration: `src/sut.ts:<module>:311:delete-call` for `W8.run`'s body, `W8.run:316` for the literal's, `w_nest0:152` for `next`, and `<module>` for the getter, setter, and field arrow; with the witness also off, enumeration: every mutant under `./src/sut.ts`. - GREEN: static and classify oracles 15/15; e2e fixed seed passes. - Mutants, each rejected on the fixed seed: literal method named by its enclosing class (enumeration); owners kept by name (ownership, "src/sut.ts:next:158: owned, owed unowned"); accessors not functions, field arrows not functions (enumeration); sources as spelled (enumeration); rune value replaced, `$effect` statement skipped (rune placement); runes in every file (enumeration: the library's `$derived` call lost its mutants). - Limits: same-named functions, accessors, and field arrows are judged for ownership only (no test calls them). The rune judge restates Svelte's rule; the compiler is not installed here, and `$props`, `$bindable`, `$inspect`, class-field runes, and `.svelte` components are not generated. An owns entry that names two same-named functions owns both. An authored mutant's `source` field is used as written. The static driver now reads sources through parseArgs, and reads owners through `owned.at(source, line)`, which replaces `functionAt` and `of`. Co-authored-by: Isaac <[email protected]> * fix(oracles): register no route while building options oraclePropertyOptions and oracleRandomParameters registered a route (`random seed`, or `fixed history` under a path replay) as a side effect, and the last registration wins. A fixed-seed campaign that built its options with them and then set its own seed was attributed to `random seed`, and an explicit oracleRoute call made before building the options was overwritten, so the gap report misread such kills (finding F2 on #1, found in TanStack DB's conversion). A route now describes the campaign that runs, whatever order the helpers are called in: building options registers nothing; oracleProperty and runOracleCampaign register their campaigns' routes, and oracleProperty's random campaign registers `fixed history` itself when it runs a path replay; a test that runs its own campaign calls oracleRoute. Public behavior change: the two builders no longer call globalThis.__oracleRoute. A test that runs its own fast-check campaign and relied on that registration now records no route until it calls oracleRoute (`random seed` for a random campaign, `fixed history` under a replay of it). Sites that register their route after building options are unchanged. Signatures are unchanged. - Law: the route registered when a campaign runs describes that campaign: the runner's own, or the last one the test registered; building options registers none (gap-report route contract; coordinator decision for #1, 2026-11-08). - Reach: new oracle tests/route-oracle.property.test.ts; declared states (constructed) `options built after the test registered its route` 33/32 and `options built inside a runner's campaign` 44/49 histories (fixed / random campaign, 102 each). - RED (parent): `vitest run tests/route-oracle.property.test.ts` failed 3 tests under law `route`: both campaigns shrank to a test that only built property options (observed `random seed`, owed none), and fixed history "options built after the test registered fixed seed" observed `random seed`, owed `fixed seed`. - GREEN: 4 tests pass; the self-oracle's new `route` law (next commit) passes, including path replays. - Mutants: restoring the builders' registration fails the 3 tests above; removing the random campaign's `fixed history` registration fails the self-oracle's replay fixed histories ("the replay ran under routes ["random seed", ...], owed "fixed history""). - Limits: a caller's own oracleRoute is taken as its claim; the framework cannot check it. Co-authored-by: Isaac <[email protected]> * fix(oracles): keep a law's failure, rerun, and probe window whatever the history holds Four review findings on #1 (R1-2, R1-3, R1-4, R1-8), each extended into the oracleProperty self-oracle before the fix. - R1-2: failure() printed the history with JSON.stringify, which throws on a bigint, so a real law violation surfaced as a TypeError; an unlabelled enumerated history was named by JSON.stringify too, so a bigint history failed registration and Map histories all got the name `{}`. Both now use traceText, the framework's stable text, which keeps bigints, Maps, Sets, undefined, and errors apart. Names of JSON-safe histories do not change. - R1-3: the rerun command was anchored at the property's suite and quoted as JSON, so inside an outer describe it matched nothing, and a name with `$` or a backtick expanded when pasted. It is now built from the test's full suite chain (Vitest's task), each name escaped, joined by `(?: | > )` for Vitest 4 and 5, in POSIX single quotes. Checked on Vitest 4.1.12 here and by hand on Vitest 5.0.5 (the suite chain and the pattern match a nested test the same way). - R1-4: on a controlled-clock spin, a model or check that could not read the cut trace threw, and the history failed as a setup error instead of under `bounded clock`. The spin now decides then, as a driver error does when its cut trace cannot be read. - R1-8: the determinism test ran the driver through recordTrace, a near-copy of recordGuarded that left the probe window open when the driver threw, so a late probe call after that was recorded silently instead of throwing; it also skipped the observation hook. recordTrace is gone: the determinism test records through recordGuarded and compares the trace, the spin, and the probe calls. Determinism runs now also reach globalThis.__oracleObserve, as every other run does. Self-oracle extensions (generator dimensions, each with a fixed history): a history's form (array, bigint-tagged object, Map); enumerated labels (plain, with shell characters, none); a property nested in an outer suite; a strict model that throws on a trace a stop cut short; and the rerun probe now runs the printed command through /bin/sh. The late-probe law now counts one unhandled error per late call, from the log, instead of "at least one"; the synthetic driver starts its late call as it returns or throws (before, a clock spec's call fired inside its own history), and a late spec's file waits 50 ms after its last test so the last call lands. A new `route` law checks the route each history runs under, including a replayed random campaign's `fixed history`. The reporter counts a suite's collection errors as the file's. - Law: verdict (a violation surfaces as that law's failure whatever the history holds), registration (unlabelled histories get distinct names), rerun (the printed command, pasted into a shell, runs exactly that test, nested or not), clock (a spin whose cut trace the model cannot read fails under `bounded clock`), agreement (every late probe call throws, also after a driver that threw), route. Authority: oracle-property.ts header; maintainer decision of 2026-11-06 on the bounded clock; coordinator decision for #1, 2026-11-08, on routes. - Reach: 8 new measured states, each entered by its fixed history on every run (bigint-history-violation, unlabelled-enumerated, map-history, shell-label-rerun, nested-rerun, strict-model-cut-short, late-probe-after-driver-error, replayed-route); the 3-run campaigns reached replayed-route twice and the others rarely. - RED (parent, `pnpm --filter @tanstack/oracles test:oracle-framework`): 7 failed, 37 passed, exactly the new fixed histories: "a violation in a history holding a bigint" failed as {"kind":"other"}, owed law three; "Map histories apart" registered ["determinism","{}","{}"]; "bigint histories loads" failed to load; "survives a shell" and "inside another suite" did not fail again on rerun; "cut at a spin" failed as {"kind":"other"}, owed bounded clock; "after a throwing driver" reported 10 late probe calls, owed 11. - GREEN: self-oracle 44 passed (181 s, 2 workers); default suite passes. - Mutants (each fails exactly its fixed histories): default label back to JSON (registration, 2 tests); failure text back to JSON (verdict); full name but JSON quoting (rerun, shell label); shell quoting but only the property suite and test (rerun, nested); the spin's judge unguarded (verdict, bounded clock); probe window left open after a driver error (agreement, 7 late calls of 11); random campaign without its replay route (route, 3 replay tests). - Limits: unlabelled names are checked for distinctness, not text; a slow spec's late calls and routes are not counted exactly; histories still hold one to three integers. Co-authored-by: Isaac <[email protected]> * fix(oracles): build CommonJS only for the declaration entry The library build emitted every entry in both formats, so the tarball shipped dist/cjs/index.cjs, oracle-property.cjs, and six more CommonJS modules with their .d.cts files (review finding R1-10 on #1). Nothing exported them, and index.cjs and oracle-property.cjs cannot load: they require Vitest, which refuses require(). A small build plugin now keeps only the CommonJS modules that the browser-safe ./declaration entry reaches, and their declaration files. It applies to builds only, so a test run's served config never touches dist. The package test gains a pack check: it builds, lists the tarball with `npm pack --dry-run --json`, loads every runtime module under its own module system in one Node process, requires the `require` export targets alone and lists the CommonJS modules they never reach, and checks that every export target ships and every .d.cts has its module. - Law: the package ships only loadable, reachable entries. - RED (parent): `vitest run tests/package.test.ts` failed: dist/cjs/index.cjs and oracle-property.cjs failed to load ("Vitest cannot be imported in a CommonJS module using require()"), and 8 CommonJS modules were unreached from the require targets. - GREEN: 4 tests pass; dist/cjs holds declaration and oracle-declaration only (.cjs, .map, .d.cts); publint --strict passes. - Mutant: pruning the chunks but keeping every .d.cts fails the declaration-file check, listing dist/cjs/index.d.cts and 7 more. - Limits: ES module reachability is not checked; every ES module is loadable. Co-authored-by: Isaac <[email protected]> * fix(oracles): skip a calibration candidate whose clock spins A calibration uses the first candidate whose clean trace passes. Its clean check judged the whole recorded trace and ignored a controlled-clock spin, so a spinning history, which fails under `bounded clock` in its own test, counted as clean, and the calibration could pass on it. Both calibration paths (a corrupted trace and a mutant driver) now skip a candidate whose clock spun, as they skip one whose driver threw. Found by a 4x self-oracle campaign while verifying the review repairs on #1; the code predates them. - Law: calibration — a calibration uses the first candidate whose clean trace passes (maintainer decision of 2026-11-03), and a spin fails its history (maintainer decision of 2026-11-06). - Reach: new fixed history "a calibration skips a candidate whose clock spins" (a clock spec whose first candidate is [7]) enters calibration-skipped-candidate and calibration-applied on every run. - RED (HEAD before this commit): `ORACLE_RUNS_MULTIPLIER=4 pnpm --filter @tanstack/oracles test:oracle-framework` failed the random campaign: "calibration: cal-0" passed, owed {"kind":"calibration-none"} (replay ORACLE_SEED=1625892856 ORACLE_PATH=5:10:10:11:11:11 ORACLE_PROPERTY=self-oracle.framework reproduces it); the new fixed history failed the same way. - GREEN: the replay passes; the self-oracle passes 45 tests at 4x runs (304 s); default suite 44 tests. - Mutant: skipping the spin only on the corrupted-trace path fails the fixed history on its mutant-driver calibration ("cal-1" passed, owed calibration-none). - Limits: as the self-oracle states. Co-authored-by: Isaac <[email protected]> * fix(oracles): reject a hole in a schedule and a turn count that counts no turns Round-2 review finding R1b-10 on #1: the fail-fast checks were incomplete. scheduleFrom looked for a misfit with `find`, which returns undefined both for "none" and for a hole or an explicit undefined, so `[, 0]` passed. withinTurns took any number of turns: a negative count or NaN acted as 0, 1.5 as 2, and Infinity waited for ever on a promise that never settles. scheduleFrom now uses findIndex; withinTurns throws for a count that is not a nonnegative integer. - Law: a choice names a queue only as a nonnegative integer, and a number of turns counts turns only as one; anything else is a caller's breach, rejected when called (scheduleFrom and withinTurns contracts in oracle-property.ts; fail fast, TanStack DB AGENTS.md). - Reach: the scheduler grammar adds undefined and sparse arrays (fixed history "a hole names no queue"); the withinTurns grammar adds -1, 0.5, 1.5, NaN, and Infinity turns, declared state `a number of turns that counts none` (constructed) reached by 30/27 of 102 histories, plus fixed history "a negative number of turns". - RED (abd445e): the scheduler oracle failed 3 tests on choices `[,]`; the withinTurns oracle failed 3 on `turns: -1`. - GREEN: scheduler 7 tests, withinTurns 4 tests. - Mutants: a check that lets an undefined misfit pass fails 3 tests on `[,]`; rejecting only negative counts fails both withinTurns campaigns on `turns: 1.5`. - Limits: as each oracle states. Co-authored-by: Isaac <[email protected]> * fix(oracles): one route vocabulary, one replay read, and exact stable text Round-2 review findings R1b-2, R1b-3, R1b-4, R1b-6, R1b-7, R1b-8, R1b-9 on #1, and R1b-11 from TanStack DB's conversion review. Each oracle's model now states its law, not either runner's behavior. Routes (R1b-4, R1b-7, R1b-8, R1b-11). One vocabulary, `OracleRoute` in the new oracle-route.ts: `fixed seed` (a seed fixed in code, or a seed-only replay that reseeds a campaign), `fixed history` (one written or recorded history, a path replay included), `case` (an enumerated history), `random seed` (a seed the framework or fast-check draws), and `calibration` (a calibration, a probe calibration, or the determinism test). Before, oracleProperty registered `enumerated`, `determinism`, and `probe calibration`, which oracleRoute's type and docs did not name; it attributed a seed-only replay to `random seed` while runOracleCampaign said `fixed seed`; and runOracleCampaign attributed a path replay to `fixed seed` while oracleProperty said `fixed history`. Now: `enumerated` -> `case`; `determinism` and `probe calibration` -> `calibration`; both runners attribute a seed-only replay to `fixed seed` and a path replay to `fixed history`. - New: `oracleRouteOf(parameters)` names the route of a campaign that runs with given fast-check parameters: `fixed history` with a path; `random seed` without a seed or with the seed an options builder drew; `fixed seed` otherwise, such as a seed the test fixed. The builders record a drawn seed under a registered symbol, which a spread keeps and fast-check ignores. oracleProperty's random campaign uses it. A test that runs its own campaign registers `oracleRoute(oracleRouteOf(parameters))`. - oracle-route.ts imports nothing. `@tanstack/oracles/declaration` now exports `oracleRoute`, `oracleRouteOf`, and the `OracleRoute` type besides `declareOracle`, so a suite bundled into a webview registers its routes without Node built-ins. The main entry still exports oracleRoute and now exports oracleRouteOf and the type. Configuration (R1b-2, R1b-3). `readOracleRunConfig()` without an argument re-read process.env on every call, so `oracleRandomParameters(n, readOracleRunConfig(), id)` could replay a selection that oracleReplayTest and createOracleReach did not see; it now returns the configured read (with an argument it still parses that environment). The calibration variable was read live by oracleCalibrationTest; it is now read with the replay selection. Stable text (R1b-6). The default label, the failure's History line, and the determinism test used traceText, which printed NaN, Infinity, and null alike, -0 as 0, the string "$undefined" as undefined, and dropped symbol keys and prototypes. The determinism test now compares exactly with isDeepStrictEqual, as differs does; the text is a history's JSON when JSON carries it exactly (so JSON-safe names do not change) and Node's inspection otherwise. Build (R1b-9). The CommonJS pruning plugin kept its reached set across builds, so a watch rebuild kept stale modules and dropped new ones; it starts again on each build. - Laws: route (gap-report route contract; coordinator decisions for #1, 2026-11-08); one configuration (configureOracles contract); determinism and registration (oracle-property.ts header); the package ships only loadable, reachable entries and the declaration entry loads no Node built-in. - Reach: route oracle states `a runner's replay` 38/44, `the route of options whose seed the test fixed` 18/22, plus 2 earlier states (fixed / random campaign, 104 histories); config oracle `an environment change after configuration` 47/42; self-oracle new state lossy-history and fixed histories for -0 labels and -0 determinism. - RED (abd445e): route oracle failed 5 tests, including fixed history "a runner's path replay is a fixed history" (observed `fixed seed`) and a missing oracleRouteOf; config oracle failed 4, including "run configuration read after the environment changed" and "a calibration variable set after configuration"; self-oracle failed 39 of 47 (route `enumerated` owed `case`, `random seed` owed `fixed seed` under the children's seed-only replay; labels ["[0]","[0]","[null]"]; -0 vs 0 passed determinism); package test failed the declaration exports and the two-build plugin check. - GREEN: default suite 51 tests; self-oracle 47 tests (193 s); build, typecheck, lint, publint. - Mutants, each rejected: runOracleCampaign path replay back to `fixed seed` (route oracle, 3 tests); oracleRouteOf ignoring the drawn seed (route oracle campaigns); oracleProperty's random campaign always `random seed` (self-oracle, `fixed seed` owed); `enumerated` restored (self-oracle); readOracleRunConfig() live (config oracle, 3 tests); calibration read live (config oracle, 2); determinism by JSON text and default label by JSON (self-oracle, one fixed history each); the plugin without clearing (package test); oracle-route.ts importing node:util (package test names "dist/esm/oracle-route.js: node:util"). - Limits: every self-oracle child sets a seed-only replay, so the self-oracle never sees oracleProperty's `random seed` route; the route oracle covers it through oracleRouteOf. A drawn seed travels with the parameters object; parameters serialized across realms lose it and read as `fixed seed`. Co-authored-by: Isaac <[email protected]> * chore: untrack gap-report scratch bundles committed by mistake 5030ce3 picked up two untracked packages/oracles/.oracle-gaps/bundle-*.mjs files, local output of the gap report. They stay on disk, untracked. Co-authored-by: Isaac <[email protected]> * fix(oracles): routes never over-claim, names are machine-free, traces compare as data Round-3 review findings R1c-1..R1c-9 on #1. Routes (R1c-1, R1c-2, R1c-3, R1c-9). A route never claims more reproducibility than its campaign has; where the framework cannot know a seed is fixed it says `random seed` (coordinator decision, 2026-11-08). Before, oracleRouteOf read any seed without the drawn-seed mark as `fixed seed`, so rebuilt options, a JSON round trip, a structured clone, and runOracleCampaign's own random campaign (which never set the mark) over-claimed. The mark is now inverted: only a declared seed is fixed. - New `oracleFixedSeed(seed, parameters?)` (main and ./declaration entries) returns parameters that run with `seed`, declared fixed under the registered symbol `@tanstack/oracles/fixed-seed`. A spread keeps the declaration; a seed set by hand, a field-by-field rebuild, JSON, or structuredClone drops it, and the parameters then read `random seed`. - oracleRouteOf is the one classifier: no seed -> `random seed`; seed and path -> `fixed history`; a seed equal to its declaration -> `fixed seed`; otherwise `random seed`. Options built under a replay declare the replay's seed. runOracleCampaign builds its fixed and replay campaigns with oracleFixedSeed and registers oracleRoute(oracleRouteOf(parameters)) (its nested ternary is gone); oracleProperty's fixed-seed campaigns do the same. The parameters runOracleCampaign passes to its callback now carry the declaration, which the declared-reach model and the campaign test owe. - Route oracle grammar adds: set seed by hand (to a value no declaration uses), declare a fixed seed, rebuild field by field, JSON and structuredClone round trips, and the route of the runner's parameters; the constructed "lost declaration" history takes each losing step in turn. Self-oracle (R1c-4). A suite may add a seedless child run, without ORACLE_SEED, whose random campaigns must run every history under `random seed`. Names (R1c-5). Unlabelled names and History lines printed an Error's stack, with this machine's paths; an Error now prints as its name and message (ErrorText), and the self-oracle's `names` law rejects a test name holding the package path. Determinism (R1c-6). The rule: observations are data. Two runs are compared by their stable text, so -0 and 0, object key order, and Map and Set order count (a check that iterates them can see them), and a function counts by its name, so a fresh closure is the same data. Before, isDeepStrictEqual passed key-order noise and failed fresh closures. Replay environment (R1c-7, R1c-8). The replay witness re-read PROPERTY/SEED/PATH and its channel from process.env; the read replay environment (selection, multiplier, calibration, witness channel and mode) and its parser now live in oracle-environment.ts, and the witness reads the configured read. readOracleRunConfig() returns a frozen copy of the four public fields, not the cached object. - RED (d676cf0): route oracle failed 7 tests (e.g. "the route of a seed the runner drew", "options round-tripped through JSON", "a seed set by hand": observed `fixed seed`, owed `random seed`); config oracle failed 4 ("a replay witness after the environment changed", "a mutated run configuration"); self-oracle failed 5 of 51 (name with the package path; key-order noise passed determinism; a fresh closure failed it; the random campaign and the self-oracle's own determinism on the same two causes). - GREEN: default suite 57 tests; self-oracle 51 tests (219 s); typecheck, lint (0 errors). - Mutants, each rejected: runner declares every seed fixed (route oracle, 3); any declaration counts whatever seed runs (both campaigns and a fixed history); the round-2 rule (unmarked seed is fixed; 6 tests); the reviewer's oracle-property.ts mutant `path ? fixed history : fixed seed` (seedless fixed history: ran under ["fixed seed"]); names keep stacks; determinism by isDeepStrictEqual (2); witness reads the live environment (2); readOracleRunConfig returns the cached object (3). - Limits: a declaration is lost across realms (serialized parameters), which under-claims by design; errors nested inside class instances keep their stacks; a function counts by its name only. Co-authored-by: Isaac <[email protected]> * feat(oracles): refuse a configuration that would change a replay selection already read Law adopted by the maintainer (decision, 2026-11-08; finding R1b-1 on #1): once anything has read the replay selection, a configureOracles call that would change it throws and changes nothing. Tests already stood aside, or ran, by the selection they read, so a later selection would leave them wrong. A later call that keeps the selection still replaces the rest of the configuration; the first-call lock on the defaults stays. Before, every configureOracles call re-read the replay environment and replaced the selection, whatever had read it. - Production: oracle-environment.ts records that the replay environment was read; configureOracles compares the selection it would read (seed, path, property) with the one read and throws on a difference. - Config oracle: the model and prose state the new law; new declared state `a configuration that would change a read selection` (constructed), reached by 23/22 of 103 histories; fixed history "a reconfiguration that would change a read selection". - The declared-reach oracle's driver configured under each run kind's environment, which the law now refuses; it imports fresh modules per run kind instead, as a process of that kind would. config.test.ts: the example that reconfigured after a read now shows the refusal, on fresh modules. - RED (1ba5cde): config oracle failed 3 tests at step 2 under law `configure first` (the configuration was accepted); the new config.test.ts example failed. - GREEN: config oracle 10 tests, default suite 59, declared-reach oracle. - Mutant: a reconfiguration that silently changes the selection (check disabled) fails both campaigns and the fixed history. - Limits: the grammar varies the whole selection (replay or none), so a check that compared only one of seed, path, or property would not be told apart from this one. Co-authored-by: Isaac <[email protected]> * feat(oracles): a model must accept a trace cut short; one that cannot is named Law adopted by the maintainer (decision, 2026-11-08; finding R1b-5 on #1): models must be prefix-total. A driver error or a controlled-clock spin cuts a trace short; a model that throws on the cut trace fails the history with an OracleModelError that names the model, the cut, and the model's error, instead of a setup error or `bounded clock`. With a prefix-total model, a violation recorded before the cut is still reported as that law's failure, as the header's "a later crash cannot hide an earlier wrong observation" promises. Shrinking keeps a model error as its own kind. - Production: judge calls the model on its own; a model error on a cut trace becomes OracleModelError; a spin no longer swallows it; the campaign predicate keeps `model` apart from `setup`. A check error and a model error on a full trace are unchanged. - Self-oracle: verdictOf's strict branch owes `model-not-total`; the classifier reads OracleModelError; fixed histories for a spin and a driver error that cut the trace, and a campaign that reports and replays a model error. - RED (1ba5cde): the spin case failed as `bounded clock` and the driver-error case as `setup`, each owed `model-not-total`. - GREEN: self-oracle 53 tests at 4x runs (254 s); default suite 59. - Mutant: a model error on a cut trace reported as before fails both fixed histories. Equivalent mutant: merging the model and setup shrink kinds survives, because fast-check removes only leading items here, so no shrink of a model error reaches a plain driver error; the self-oracle's limits say so. - Limits: a non-total check on a cut trace still ranks as before. Co-authored-by: Isaac <[email protected]> * fix(oracles): keep what a check reads in names and model errors, drop only stacks Round-4 review findings R1d-1, R1d-2, R1d-3, R1d-4, R1d-8, R1d-9, R1d-10 on #1. - R1d-1: an OracleModelError on a trace a driver error cut short carried only the model's error. It now quotes the driver's error in its message and keeps it as `driverError`, beside the model's error as `cause`. - R1d-2, R1d-3, R1d-4: stable text reduced every Error to name and message (losing own properties, cause, `errors`, and class), left an Error inside a class instance with its stack, and could throw while naming. It now copies arrays, Maps, Sets, plain objects, and class instances with their prototypes and own properties (an accessor as an accessor, so no getter runs), and each Error, wherever it is, with its prototype and every own property but `stack`; Node prints that copy as, e.g., `[SyntheticFault [Error]: synthetic] { code: 3 }`. Naming never throws: a value that cannot be copied falls back to its plain inspection, and then to its tag. - R1d-8: a spin after the last observation cuts nothing, so a model or check that throws on that whole trace is the parts' own (setup) error, not an OracleModelError. - R1d-9: OracleModelError is exported beside OracleViolation. - R1d-10: the determinism test compares plain data (primitives, arrays, plain objects, keys in order) directly and builds stable text only when that cannot decide. - Self-oracle: history forms `errors` (Error, a same-named subclass, an Error with a cause, an Error with a code), `boxed` (an Error in a class instance), `trap` (an enumerable getter that throws; enumerated only, because fast-check cannot print it); an Error-data noise driver; a model that throws on any trace holding a 7; verdictOf owes the driver's error in a model error and a setup error for an uncut spin. Also a defect in the self-oracle's own model, older than this round: a slow spec owed `timeout` everywhere, but a history outside the language fails its membership check before the driver runs; the model owes that now. - RED (a4bc942): self-oracle failed 8 of 58: the driver error missing from a model error; an uncut spin reported as a model error; Error histories named alike; a stack in a boxed history's name; a getter that throws failing the load; Error-data noise passing determinism; the random campaign (the membership case above); the self-oracle's own determinism (boxed names differ by run directory). Package test: OracleModelError missing from the exports. - GREEN: self-oracle 58 tests at 1x (222 s) and at 4x (258 s); default suite 63. - Mutants, each rejected: no driver's error in the message; an Error copy that keeps only its message; one that loses its class; class instances kept as they are; the original R1d-4 shape (properties read, outside the guard); every spin treated as a cut; a fast path that ignores key order. Equivalent: removing only one of the two R1d-4 guards (the copy calls no getter, so either guard alone suffices). - Limits: a message that names a path is kept, as data a check can read; dates, typed arrays, and other exotic objects are kept as they are; the fast path has no timing test. Co-authored-by: Isaac <[email protected]> * fix(oracles): lock the calibration with the selection, declare only environment seeds, never throw from a witness Round-4 review findings R1d-5, R1d-6, R1d-7 on #1. - R1d-5: the adopted R1b-1 law covers everything a read decided from. A reconfiguration could change the calibration variable after a calibration witness decided by it; the variable is now part of the selection a reconfiguration may not change. - R1d-6: oracleRandomParameters declared any defined seed fixed, so a caller's number or hand-built configuration (say, a Math.random seed) read `fixed seed`. Only a seed the process's replay environment selected is declared now: readOracleRunConfig() carries the declaration for its seed, and oraclePropertyOptions builds from it. A caller who means a fixed seed declares it with oracleFixedSeed. - R1d-7: recordOracleReplay and recordOracleFiniteReplay promise never to throw, but read the replay environment, which can be malformed; an environment that cannot be read now selects no witness. - RED (a4bc942): config oracle failed 3 ("a reconfiguration that would change a read calibration"); route oracle failed 4 ("random parameters from a caller's number" and "from a hand-built configuration" observed `fixed seed`, owed `random seed`); the new config.test.ts example threw with ORACLE_RUNS_MULTIPLIER=0. - GREEN: config oracle 11, route oracle 12, default suite 63. - Mutants, each rejected: calibration left out of the selection (3 tests); any defined seed declared (3); readOracleRunConfig declaring nothing (the seed-replay campaign); the witness without its guard. - Limits: the never-throws witness rule is an example, because the config oracle generates only valid environments. Co-authored-by: Isaac <[email protected]> * fix(oracles): keep a driver error after a spin, never throw from a witness write or a thrown value's text Round-5 review findings R1e-6, R1e-7, R1e-8 on #1 (R1e-1..R1e-5 and R1e-9, all in value rendering, are held for a maintainer decision). - R1e-6: on a controlled-clock spin, a driver error that came after the spin with no later observation was dropped: the trace was judged as whole, so the error and the cut were both lost. A spin now cuts the trace when anything follows it, an observation or a driver error, and a driver error after the spin, which still does not decide, is kept as the cause of what does (a recorded violation or `bounded clock`) and is carried by a model error on that cut trace. - R1e-7: appendWitness wrote unguarded, so an unwritable channel threw from recordOracleReplay and recordOracleFiniteReplay ("never throws") and, in oracleReplayReporter, replaced fast-check's counterexample and cause. An unwritable channel now records no witness. - R1e-8: an OracleModelError formatted a thrown non-Error with String(), which throws for a null-prototype object or a throwing toString, replacing the model error with a TypeError filed as setup. It uses the stable text, which never throws. - Self-oracle: a `throwOnSpin` driver (throws right after a spin, without observing more) and an `oddThrow` driver (a 6 throws a null-prototype object with a message); verdictOf keeps a driver error after a spin as the cause and counts it as a cut; the determinism model owes a setup error for that driver error too. The existing fixed history "a driver error after the clock spins does not decide" now owes that error as the cause. - RED (4bc3636): self-oracle failed 4 targeted fixed histories (driver error dropped after a spin, twice; a model error on a trace cut right after a spin reported as setup; the odd thrown value's text threw, failing as `other`); config.test.ts: ENOENT thrown by recordOracleFiniteReplay with an unwritable channel. - GREEN: self-oracle 61 tests at 4x runs (282 s); default suite 64. - Mutants, each rejected: a driver error does not cut a spin's trace; the driver error after a spin dropped (2 tests); the witness write unguarded; String() for the thrown value. - Limits: the unwritable channel is an example, since the config oracle has no file-system dimension. Co-authored-by: Isaac <[email protected]> * fix(oracle-gaps): run the package as Vitest does from any path, with one daemon, and a harness its tests cannot see Review findings R2-4 to R2-11 on PR #2, each generated by the end-to-end oracle first, then fixed: - R2-4: the is-main check compared `import.meta.url` with an unescaped `file://` path, so a CLI installed under a path with a space or `#` exited 0 with no output, and its daemon never listened. Both now compare with `pathToFileURL(...).href`. - R2-5: two CLIs that found no daemon each started one, and one was orphaned. A daemon now takes `.oracle-gaps/daemon.lock` before it listens and exits when a live daemon holds it; a dead holder's lock is taken over. - R2-6: the batch watchdog took the first copy without a closing row as the running one, but a copy whose test file fails to load runs no `afterAll`. Each copy now writes a starting row; the running copy is the last that started. A cut-off batch reruns an earlier copy that never closed. - R2-7, R2-8: a package is bundled only when its `exports` names one entry and that entry builds; any other loads as Vitest loads it. A dependency's devDependencies are not followed. - R2-9: the default pool is `forks` when a `binding.gyp` or a prebuilt `.node` file is anywhere in the dependency tree (dependencies and peers, transitively; the package's own devDependencies), not only beside a direct dependency. Optional dependencies are not followed: on TanStack DB they sent most packages to forks through rollup and fsevents; without them exactly the better-sqlite3 and electron packages use forks, query-db-collection included through a workspace dependency. - R2-10: a config with `test.projects` now refuses the run, naming `test.projects` (the refusal, not project support). - R2-11: the capture called `Object.getOwnPropertyDescriptor` and other builtins on asserted values, so a test that spies on them counted the harness's calls. It now keeps its own references, taken once per worker before any test runs. - Found on the way, by a generated history: an authored mutant killed in two owner files listed its tests and laws in the order the contexts finished, so the daemon's report and the cold run's differed (law 9). Its units now keep their owner files' order. - Law: the runner runs the package as Vitest does (new law 10, from any install path and `--source` spelling, one instance per workspace dependency, no refusal over an unbuildable devDependency, forks for an addon anywhere in the tree); law 3's capture clause (builtin spies) and `test.projects` refusal; law 4's setup error at module load and cut-off charging; law 9's one daemon per package. Authority: the review of PR #2 and TanStack DB's conversion (2026-11-08), and the maintainer's choice to refuse `test.projects`. - Reach (fixed seed 20261105): the "every outcome class" construction now runs from a CLI under `oracle-gaps-mutant cli #...`, with a `./` source spelling, a subpath import of the workspace dependency, an unbuilt devDependency, a native addon, and the builtin-spy witness; "a load failure beside a hang" (new) reaches a setup error and a timeout in one batch under one budget; "two authored mutants" has a prebuilt addon two levels down; the edit sequence starts with two checks at once from a spaced path; a `projects` fault refuses. Each new state is required. - RED (unchanged production, one dimension at a time): spaced path "the CLI did not complete (exit 0): no results"; unbuilt devDependency "TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string"; builtin spy "tests/a.test.ts (t24 > fixed seed 25: Error: the payload was scanned)"; subpath "state-dep loaded twice in one realm" in a and b; load failure "src/sut.ts:f0:30:if-true#0: timeout, owed setup-error"; deep addon "the run did not use the forks pool: ... pool threads"; concurrent start: the campaign timed out at 900 s and left an orphaned daemon (killed by hand); authored order: "after newOracle, the daemon's report differs from the cold run's at src/sut.ts#authored:a2". - GREEN: static and classify 15/15; e2e fixed seed passes in 100 s. - Mutants, each rejected: unescaped file URL (completion); no start lock (campaign timeout, see limits); first unclosed copy runs (classification, timeout owed setup-error); bundle a package with subpaths (completion, loaded twice); unbuildable entry aborts (completion, TypeError); direct dependencies only, and binding.gyp only (completion, threads pool); projects not refused (ownership, "the run completed although test.projects must refuse it"); capture calls the global `Object.keys` (completion, payload scanned). - Limits: the no-lock mutant is rejected by a campaign timeout, not by the one-daemon check; cut-off charging is judged only where it changes an outcome (one budget); addons shipped only as optional platform packages are not detected; `test.projects` only as one project without `extends`; the daemon count is read from the process list; the authored-order fix has no deterministic witness (the order depended on scheduling). Co-authored-by: Isaac <[email protected]> * fix(oracle-gaps): count the outcomes an `if` takes at module load The boot dimension added in b20b5a1 runs a generated function when the module loads. In a generated edit-sequence history, its `if (x > 4)` was false at load and true in a test. The model counts both outcomes as taken, because code that runs at load reaches every test of its file (maintainer decision, 2026-11-06, as law 4 states it), so the `if-true` survivor is `no-observed-difference`. The capture recorded `if` outcomes only inside tests, and the baseline skipped background rows, so the CLI reported a `generator-gap`. The capture now records outcomes taken outside any test in the file's background row, and the baseline counts them for that file. - Law: e2e law 4's generator gap, with load-time code reaching every test of its file (maintainer decision of 2026-11-06). - Reach: the edit-sequence construction with a booted first function (fixed seed 20261105); not reachable before the boot dimension. - RED: "src/sut.ts:f0:31:if-true#0: generator-gap, owed no-observed-difference" (law: classification). - GREEN: static and classify 15/15; e2e fixed seed passes. - Mutant: background rows skipped again: the fixed-seed campaign fails (it times out at 900…
KyleAMathews
pushed a commit
to TanStack/db
that referenced
this pull request
Nov 9, 2026
TanStack/oracles#1 and #2 merged; main is 98a9610. Both packages move from the #2 preview (b937148) to the pkg.pr.new preview of that main commit, which has the same source tree as the preview this branch tested (both are tree 95dbce3). The coverage map's two framework links now point at the main commit, because b937148 was on #2's deleted branch. pnpm-lock.yaml was resolved from the public registry by a temporary CI job (run 42664121157, which also checked a frozen install), because the local registry proxy cannot fetch the new previews. Co-authored-by: Isaac <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR moves the oracle framework core out of TanStack DB and into
@tanstack/oracles. Any project can now write oracles with it: state a law, generate the histories where the law matters, and check production against an independent model. TanStack DB can use the package through re-exports of its old modules. Some behaviors changed during review, and the compatibility section below lists them.Eight review rounds hardened the framework after the first version of this description. Each fix followed the same method. First, extend the framework's self-oracle until it reaches the defect, and record the failing result on the unchanged code. Then fix the code, and show that a hostile mutant fails. Four themes came out of those rounds:
What a project gets
The main entry exports the framework's parts:
oracleProperty,declareOracle,createOracleReach,runOracleCampaign, the controlled clock (useOracleClock), failure fidelity, and replay witnesses. It also exports the route helpersoracleRoute,oracleRouteOf, andoracleFixedSeed. It also exports two failure classes:OracleModelErrorandOracleDataError. A browser or native module importsdeclareOracleand the route helpers from@tanstack/oracles/declaration, which loads no Node built-ins.A project calls
configureOraclesonce, before its oracles run:The prefix names every replay variable:
TANSTACK_DB_ORACLE_SEED,_PATH,_PROPERTY,_RUNS_MULTIPLIER,_CALIBRATION,_REPLAY_WITNESS, and_REPLAY_WITNESS_MODE. Without a registry, the framework accepts every property id. A retired variable that is still set fails the run, so an old command cannot run the full campaigns and appear to pass.The configuration cannot change under a running test
The configuration follows one rule: a project configures once, before its oracles run, and that configuration controls every later call.
configureOraclesor on first use. A later change to the environment changes nothing that a read reports. A strayORACLE_PATH(SQL*Plus sets it) cannot break a project with its own prefix.oraclePropertyregistration makes one), a variable name, and the calibration variable. A firstconfigureOraclescall that changes the defaults after a read throws.configureOraclescall that would change the selection or the calibration variable throws. That call changes nothing (maintainer decision, 2026-11-08). Tests already stood aside, or ran, by the selection that they read.createOracleReach,oracleReplayTest,readOracleRunConfig(), and the calibration witness all read the same configured selection.readOracleRunConfig()returns a frozen copy. Recording a witness never throws, also for a malformed environment or a channel that the process cannot write.ORACLE_MANIFESTand theORACLE_SEEDandORACLE_REACHlog tags keep fixed names for every prefix.runOracleCampaigntakes its prefix from its caller.Routes tell the gap report which kills are reproducible
The gap report counts a mutant's kill only on a reproducible route, and the last registration wins. All runners and
oracleRoutenow use one vocabulary,OracleRoute:fixed seed: a seed declared fixed, byoracleFixedSeed, by a runner's fixed-seed campaign, or by a seed from the replay environment.fixed history: one written or recorded history, including a path replay.case: an enumerated history.random seed: any other campaign.calibration: a calibration, a probe calibration, or the determinism test.A route never claims more reproducibility than its campaign has. The options builders (
oraclePropertyOptions,oracleRandomParameters) register no route. One classifier,oracleRouteOf(parameters), names the route of the parameters that finally run. A declaration of a fixed seed survives a spread. Four changes lose the declaration: a seed set by hand, a field-by-field rebuild, a JSON round trip, and a structured clone. The parameters then read asrandom seed. That loss undercounts kills, but it never counts a kill that cannot be reproduced. A test that runs its own fast-check campaign registers its route like this:Models and failures
OracleModelError, which names the model and carries the driver's error. A violation recorded before the cut is still the failure, with the driver's error as its cause.scheduleFromrejects a choice that is not a nonnegative integer.withinTurnsanswerstruefor a promise that settled before the call, and it rejects a turn count that is not a nonnegative integer.Observations are a closed data domain
Observations and enumerated histories are data (maintainer decision, 2026-11-08). The domain holds these values:
-0,NaN, the infinities, bigints, andundefined.length.errors, never their stack.The framework recognizes arrays, Maps, Sets, and Errors by brand, so data from another realm is data. Reading a value never runs a getter or a proxy trap. A driver converts anything else before it observes it, for example a Date, a class instance, a DOMException, or a function. An observation outside the domain fails its history at once with an
OracleDataErrorthat names the value's path:An enumerated source that holds a history outside the domain fails to register. Data deeper or larger than the encoder can handle fails with a framework-limit error, never as non-data.
One encoder gives test names and the determinism comparison. Two values have equal encodings exactly when they are the same data. Key order and Map and Set order count,
-0is not0, and a prototype is not data. JSON data encodes as its JSON text, so the names of JSON histories did not change. The trace holds a copy of what eachobservecall saw, so a later change to the value cannot change the verdict. The determinism test compares the encodings taken at observe time.differstreats two data values as equal when they are the same data, whatever the order of their keys and entries. A failure report prints a generated history even when it is not data, through Node's inspection, without stack frames, and with at most 2,000 characters.Package shape
The main entry is ES modules only. It imports Vitest, which refuses
require(). Only the./declarationentry has a CommonJS build. The package test packs the tarball and checks four things:requireexport reaches every CommonJS module../declarationgraph imports no Node built-in.Peers are
vitest ^4.1.0 || ^5.0.0andfast-check ^4. A CI job runs the tests and the self-oracle on Vitest 5. The helper that adds fixed histories to fast-check options iswithOracleFixedHistories. In TanStack DB, its name waswithOracleExamples.Compatibility notes for TanStack DB
oraclePropertyOptionsandoracleRandomParametersno longer register a route. A test with its own campaign callsoracleRoute(oracleRouteOf(parameters)). A hand-set seed reads asrandom seedunless it passes throughoracleFixedSeed.enumeratedis nowcase.determinismandprobe calibrationare nowcalibration.undefinedfields and-0outside JSON. Both are in the domain. The result-shape rows may hold symbol keys, which now fail.configureOraclescall that would change a replay selection that a test already read now throws.Verification
At the head of this branch:
pnpm test:oracle-framework): 98 tests atORACLE_RUNS_MULTIPLIER=4(505 s), and three 1x runs (one under load from the default suite). All 98 passed in each run.publint --strict, and sherif.oracle-property.jsgrew from about 5.2 kB to 7.3 kB (minified, gzip), mostly for the data domain. The tarball lost eight unloadable CommonJS modules.Follow-ups
Round 8 was the last review round for this PR. These items stay open:
Object.prototype.Error is not … data.differscall builds and sorts full encodings of both values, with no early exit.hasOwnPropertyfunction forObject.prototype. A monkeypatched intrinsic Map or Set iterator would run.errors-form counterexample back as items, so its shrink and replay checks skip that form.ORACLE_SEED=-978011999). The self-oracle grammar changed since then, so that path replays a different history, which passes. Later 4x runs found two defects in the self-oracle's own helpers, and this PR fixes both. No random campaign failed in the last eleven self-oracle runs.oracleRandomParametersandoracleRuns.Next PRs
oracle-gapsCLI (the gap report) and@tanstack/eslint-plugin-oracles, on branchextract/gap-cli.This pull request and its description were written by Isaac.