Skip to content

feat(oracle-gaps): check tsconfig coverage and TypeScript errors in oracle files - #198

Open
schiller-manuel wants to merge 3 commits into
mainfrom
feat/oracle-gaps-typecheck
Open

schiller-manuel wants to merge 3 commits into
mainfrom
feat/oracle-gaps-typecheck

Conversation

@schiller-manuel

@schiller-manuel schiller-manuel commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

oracle-gaps runs Vitest with typecheck: { enabled: false }, which strips TypeScript types without checking them. As a result, a package whose TypeScript oracle files (*.oracle*.test.ts) have TypeScript type errors — or are not even included in tsconfig.json — previously reported all oracle files pass, 0 gaps while tsc --noEmit failed.

Solution

Add packages/oracles/oracle-gaps/typecheck.mjs and wire it into check.mjs, args.mjs, report.mjs, and index.mjs:

  • Bundled TS 5.9 only: Uses typescript-for-tanstack-oracles (never loading the target package's typescript), preserving compatibility with JS repos, packages without TypeScript, and TypeScript 7 packages.
  • No-op without tsconfig.json by default: Packages without a tsconfig.json in --package (such as JS repos and synthetic fixture packages) incur zero notes or refusals unless --typecheck is explicitly passed.
  • Coverage across projectReferences: Parses tsconfig.json (or --tsconfig <file>) and follows solution-style projectReferences (file or directory targets, cycle-safe) to detect any .ts/.tsx/.mts/.cts oracle file excluded from typechecking.
  • Graceful TS 7 / incompatible config handling: When a covering tsconfig contains options unsupported by bundled TS 5.9 (e.g. TypeScript 7's contentMappers) or invalid JSON, coverage is still checked where parseable and semantic checking is skipped cleanly with an oracle-gaps: note typecheck: skipped ... line rather than false-positive errors.
  • Scoped diagnostics: Runs getSyntacticDiagnostics + getSemanticDiagnostics only on the covered TypeScript oracle files (with noEmit: true, incremental: false, composite: false, emitDeclarationOnly: false, skipLibCheck: true), so pre-existing type errors in unrelated files are ignored and no build artifacts are written. Uses a stat-stamped /node_modules/ SourceFile cache for fast --daemon parity.
  • Greppable notes by default + strict --typecheck opt-in:
    • Default runs emit single-line oracle-gaps: note typecheck: ... lines to stderr, stream.log, stdout summary, summary.md (## Typecheck notes), and structured typecheck data in results.json.
    • Passing --typecheck (and optionally --tsconfig <file>) refuses the run (exit 2, report-shaped refusal) before baseline tests run if the tsconfig is missing/incompatible, any TypeScript oracle file is excluded, or any oracle file has TypeScript errors.

Validation

  • pnpm run build — passed
  • pnpm run typecheck — passed
  • pnpm run lint:check — passed
  • pnpm run format:check — passed
  • pnpm run test:publint — passed
  • pnpm run test:sherif — passed
  • pnpm --filter @tanstack/oracles run test — 9 files, 125 tests passed (including 8 new unit + CLI/daemon tests in tests/oracle-gaps-typecheck.test.ts)
  • pnpm --filter @tanstack/oracles run test:oracle-gaps:fast — 5 files, 33,899 tests passed
  • pnpm --filter @tanstack/oracles run test:oracle-gaps:shards — 5 shards partition the e2e tests
  • pnpm --filter @tanstack/oracles run test:pr-shards — 7 partitions split their tests exactly
  • Targeted gap-report-oracle e2e checks (every outcome class, apiLessTypescript, noTypescript) — 3/3 passed

Update: TypeScript findings are reported, never blocking (head 330cf22)

Per the maintainer's decision of 2026-11-23 ("type errors shouldn't block a run but we can just put them in the output"), the refusal mode is removed. TypeScript findings in oracle files are reported as output only. The sections above describe the first head (85f3a8e); where they say --typecheck refuses, this update supersedes them.

What changed

  • Coverage problems and TypeScript errors are reported in the stream notes (oracle-gaps: note typecheck: ..., on stderr and stdout, and stream.log), in summary.md (## Typecheck notes), and in results.json (typecheck). They never refuse or fail a run; the exit status and the done line are the same either way.
  • --typecheck and its exit-2 path are removed. The flag is now an unknown option, refused before any check starts. --tsconfig <file> stays, since it names a config rather than a mode.
  • typecheck.mjs no longer caches node_modules source files across daemon checks (the stat-stamped cache). Nothing is kept across checks, so no read needs to be a daemon input (R46). The cost is in the Cost section below.
  • Changeset: .changeset/oracle-gaps-report-typescript.md.

Commits

  • bbe933dc (oracle first): the new law, its shard partition, and its CI job. Run on the parent, it fails, as the RED result below shows.
  • 330cf22b (the change): the removal, the cache removal, the unit tests moved to report-only semantics, and the changeset.

Evidence

  • Law: the maintainer's decision of 2026-11-23 (decisions-register.md, "Type errors are reported, never blocking"). Frozen P10 (one diagnostic per failure from a run with an identity; the done line last, matching the exit code; an argument refusal owes the done line alone) and P12 (CI cost is a budget). The law itself is in the header of packages/oracles/oracle-gaps/gap-report-typecheck-oracle.property.test.mjs.
  • Reach: 26 test units: each campaign (one fixed seed, one random seed) draws 16 generated histories, and each of the 6 declared states also has a constructed history (no tsconfig.json; uncovered oracle files; a referenced tsconfig covers the oracle files; type error in a covered oracle file; daemon run with type errors; --typecheck refused as an unknown option). In the two generated campaigns, every state was entered by at least one generated history except daemon run with type errors in one campaign, which the constructed history covers.
  • RED (parent 85f3a8e): pnpm exec vitest --run --config oracle-gaps/vitest.config.mjs gap-report-typecheck → 5 failed, 21 passed. The failures are the refusal law only: fixed seed 20261123: --typecheck refused as an unknown option, random seed: --typecheck refused as an unknown option, fixed seed 20261123: generated, random seed: generated, and calibration: the removed --typecheck flag still refuses a clean package. Concretely, --typecheck on a clean package exits 0, and on a package with a type error it exits 2 with a TS2322 refusal, not unknown option --typecheck.
  • GREEN (330cf22): the same command → 26 passed. Unit file tests/oracle-gaps-typecheck.test.ts → 8 passed. Static gap oracle gap-report-static → 172 passed. pnpm --filter @tanstack/oracles run typecheck, lint, and prettier on the changed files → clean. node scripts/pr-shards.mjs check → 8 partitions split their tests exactly. node scripts/e2e-shards.mjs check → 5 shards partition the e2e tests.
  • Mutants (each applied alone, run with the oracle, and reverted; all rejected):
    • M1, TypeScript diagnostics not reported (fileDiagnostics = []): 8 of 26 fail, law typecheck report.
    • M2, reported but blocking (a throw on any diagnostic in check.mjs): 8 of 26 fail, law typecheck exit.
    • M3, summary section dropped (report.mjs): 10 of 26 fail, law typecheck report.
    • M4, projectReferences not followed: 4 of 26 fail, law typecheck report.
    • M5, typecheck field dropped from results.json: 12 of 26 fail, law typecheck report.
  • Limits: see the Limits section below.

Why the law is a new property file

The gap e2e oracle (gap-report-oracle.property.test.mjs) is unchanged. Its fixtures write no tsconfig, so none of its histories reaches a TypeScript path, and drawing a new field into its generator would shift every seed of its campaigns (R54) and cost about 30 CLI runs per history. The TypeScript law is a separate, small oracle over the same CLI, named in the gap-report- family and run in its own CI job, so the gap e2e campaign and its seeds are unchanged. This is a judgment call. If you want the dimension in the gap e2e oracle itself, say so, and I will move it.

Cost (P12)

Measured wall time of typecheckOracleFiles in a fresh process (one check = one CLI run):

Case Time per check
No tsconfig.json in the package 0 s (returns before any program is built)
The e2e-style fixture (2 oracle files, includes tests, one error) 0.52 to 0.62 s
This repo's packages/oracles (7 oracle files, 322 source files in the program) 1.5 to 1.8 s

Of the repo's time, about 0.6 s is creating the program (289 node_modules files, mostly the Vitest types) and about 0.9 s is the semantic check. Narrowing the program's roots to the oracle files did not help (1.5 s against 1.5 s), so it is not used.

Cache removal (warm daemon, two checks in one process on this repo): the head's cache gives 0.83 to 0.92 s per warm check; the uncached code gives 1.15 to 1.33 s. So a warm daemon check is about 0.3 to 0.4 s slower on a package with a tsconfig. A cold run is unchanged. A cheaper alternative needs the cache back under R46, with its keys as daemon inputs. That is a follow-up, not in this PR.

The new CI job runs the new oracle, about 2 min locally (122 s under load), in its own job with a 20-minute backstop.

Weight (shipped oracle-gaps CLI, minified and compressed; packages/oracles/oracle-gaps/*.mjs minus property tests)

Ref Files Minified gzip brotli
origin/main 17 128,790 B 52,629 B 47,590 B
85f3a8e (the first head) 18 135,950 B 55,496 B 50,218 B
330cf22 (this head) 18 134,030 B 54,786 B 49,587 B

Against main: +5,240 B minified (+4.1%), +2,157 B gzip (+4.1%), +1,997 B brotli. This head is smaller than the first head by 1,920 B minified. The dist bundle is built from src/, which this PR does not touch.

Conflict with #99

args.mjs conflicts with #99 (fix/gap-cli-deterministic-cuts, 6ccca9d) in git merge-tree: both edit the usage text and the valued options. check.mjs, index.mjs, and scripts/pr-shards.mjs merge cleanly. The args.mjs change here is minimal (one flag removed, the usage text re-wrapped, one option removed). I did not rebase onto #99, per the instruction that #99 merges first.

Limits

  • TypeScript 7 configs (contentMappers) are skipped with a note and are not drawn by the new oracle. The skip is not recorded in a coverage map or the README, since neither exists in this repo.
  • Not drawn: a node_modules edit between two daemon checks; more than one reference level; a config with files and include together.
  • Windows: the new oracle runs only in the Linux job.
  • The cost above is measured on this machine under other load, not on CI runners.
  • The cache removal is a cost, not a correctness change: the daemon's warm check reads the TypeScript inputs again each time, so incremental equals cold for the typecheck.

CI

See the CI line below, which is updated when the run for this head finishes.

This pull request and its description were written by Isaac.

…racle files

Vitest strips TypeScript without typechecking, so oracle files with type errors
or excluded from tsconfig.json previously passed oracle-gaps silently.

- Add oracle-gaps/typecheck.mjs using bundled typescript-for-tanstack-oracles
  (never loading the package's own TypeScript), checking tsconfig.json coverage
  across solution-style projectReferences and running syntactic/semantic
  diagnostics on covered TypeScript oracle files.
- Leave packages without tsconfig.json (JS repos and synthetic fixtures)
  unaffected by default; gracefully skip semantic checking (while still checking
  coverage) when a tsconfig uses options unsupported by bundled TS 5.9 (such as
  TypeScript 7's contentMappers).
- Emit greppable `oracle-gaps: note typecheck: ...` lines (stderr, stream.log,
  stdout summary, summary.md, and results.json) by default, and add `--typecheck`
  and `--tsconfig <file>` to enforce typechecking as a refusal (exit 2).
- Add unit and CLI/daemon integration tests in tests/oracle-gaps-typecheck.test.ts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 330cf22

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/oracles Patch

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

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9c608fe1-613d-43e9-9530-124f0397015c
Commits

Reviewing files that changed from the base of the PR and between 7b6bae1 and 330cf22.

Files selected for processing: 10

  • .changeset/oracle-gaps-report-typescript.md
  • .github/workflows/pr.yml
  • packages/oracles/oracle-gaps/args.mjs
  • packages/oracles/oracle-gaps/check.mjs
  • packages/oracles/oracle-gaps/gap-report-typecheck-oracle.property.test.mjs
  • packages/oracles/oracle-gaps/index.mjs
  • packages/oracles/oracle-gaps/report.mjs
  • packages/oracles/oracle-gaps/typecheck.mjs
  • packages/oracles/scripts/pr-shards.mjs
  • packages/oracles/tests/oracle-gaps-typecheck.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/TanStack/oracles/@tanstack/eslint-plugin-oracles@198
npm i https://pkg.pr.new/TanStack/oracles/@tanstack/oracles@198

commit: 85f3a8e

KyleAMathews and others added 2 commits November 23, 2026 14:03
The gap report owes its TypeScript findings to the output, and never a
refusal (maintainer decision of 2026-11-23, "Type errors are reported,
never blocking"). A property draws the package layout (no tsconfig, a
tsconfig that includes the tests, one that excludes them, a solution
whose reference covers them), a type error in an oracle file, the
removed --typecheck flag, and the daemon. The model states the notes,
the summary section, results.json, and an exit status that the findings
do not change, and the removed flag refused as an unknown option.

RED on the parent (85f3a8e): 5 of 26 units fail, all on the refusal
law: a run with --typecheck completes (exit 0) on a clean package and
refuses (exit 2, a TS2322 refusal, no unknown-option block) on a
package with a type error. The reporting, exit, summary and results
laws hold on the parent.

Adds the pr-shards partition and its CI job, which gates the preview.

Co-authored-by: Isaac <no-reply@databricks.com>
Per the maintainer's decision of 2026-11-23 ("Type errors are reported,
never blocking"), TypeScript findings in oracle files are reported as
output only: the stream notes, the summary's Typecheck notes section,
and results.json. A run's exit status and done line do not depend on
them.

- Remove the --typecheck refusal mode, its exit-2 path and its flag.
  The flag is now an unknown option, which refuses before any check.
  --tsconfig stays: it names the config, not a mode.
- Drop the cross-check cache of node_modules source files in
  typecheck.mjs. Nothing is kept across daemon checks, so no read needs
  to be a daemon input (R46). A warm daemon check on this repo is about
  0.3 to 0.4 s slower; a cold run is unchanged.
- Changeset for the new output.

Co-authored-by: Isaac <no-reply@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants