Skip to content

fix(oracle-gaps): scope mutant anchors to declarations outside statement range - #196

Open
schiller-manuel wants to merge 2 commits into
mainfrom
fix/oracle-gaps-anchor-params
Open

schiller-manuel wants to merge 2 commits into
mainfrom
fix/oracle-gaps-anchor-params

Conversation

@schiller-manuel

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

Copy link
Copy Markdown
Contributor

Summary

  • Fixes anchorOf in packages/oracles/oracle-gaps/schemata.mjs so mutants outside TypeScript's FirstStatement..LastStatement range no longer walk up to SourceFile and dump the entire file's tokens into mutant.anchor and mutant.key.
  • Stops at ts.isStatement (covering ExportAssignment alongside ordinary statements) and tight enclosing declarations: Parameter, PropertyDeclaration (including auto-accessors), EnumMember, Decorator, HeritageClause, ClassStaticBlockDeclaration, Accessor, and computed member names on class elements / methods / accessors.
  • Adds focused regression coverage in packages/oracles/tests/oracle-gaps-anchor.test.ts verifying tight, stable anchors for default parameters, class fields, decorators, heritage clauses, computed member names, enum members, and export default.

Validation

  • pnpm run build — passed
  • pnpm run typecheck — passed
  • pnpm run lint:check — passed
  • pnpm run format:check — passed
  • pnpm --filter @tanstack/oracles run test — 9 files, 120 tests passed
  • 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 partitioned
  • pnpm --filter @tanstack/oracles run test:pr-shards — 7 partitions verified

Oracle evidence and key change (added on this branch)

Key change, disclosed. The anchor is part of each mutant's key, so this one-time change re-keys mutants whose anchor was the whole file's tokens. Measured over the gap CLI's own sources (packages/oracles/oracle-gaps/*.mjs, excluding the property tests, the model oracle, and the Vitest config; 7,158 mutants): 17 mutants in 5 files get a new key (check.mjs 5, classify.mjs 8, daemon.mjs 2, args.mjs 1, ending.mjs 1). Each was a whole-file anchor on main, and each now anchors to its declaration, for example check.mjs:182 now anchors to { partial = false } = { }. A gap recorded under an old key shows as new once. (The review's count, 11 of 4,315 on 8 files, used a different file set.)

Law. oracle-gaps.report-anchor-scope, a property of the static gap oracle (packages/oracles/oracle-gaps/gap-report-static-oracle.property.test.mjs, appended at the end of the file). No mutant outside a top-level statement anchors to the whole file. A default parameter, a property declaration, an enum member, a decorator, or a heritage clause anchors to its own declaration, and a statement's mutant anchors to that statement. Authority: the maintainers' decision on this PR (2026-11-23): a mutant outside a statement anchors to its nearest declaration, never the whole file, and the one-time key change is accepted and disclosed.

Reach. Six declared states, anchor parameter, anchor property, anchor enumMember, anchor decorator, anchor heritage, anchor statement. Each has a constructed history that enters it (one per kind, plus one with every kind in one file). The framework rejects a constructed history that misses a state it names. The campaigns run one fixed seed (20261123) and a random seed, 30 histories each, beside the constructed histories.

RED (main's schemata.mjs). git show origin/main:packages/oracles/oracle-gaps/schemata.mjs swapped in, then vitest --run --config oracle-gaps/vitest.config.mjs gap-report-static-oracle -t anchor-scope: 16 tests fail (7 fixed-seed and 7 random-seed campaigns, plus the 2 calibrations, whose clean run already fails). The violation reads, for example, line 1: a binary-swap mutant anchors to the whole file (law anchor scope). A probe on main also shows the whole-file anchor for a default parameter, a class field, an enum member, a decorator, and a heritage clause.

GREEN (this head). The same command: 28 of 28 pass (both campaigns, all states, both calibrations). The whole static oracle file passes 200 of 200. The pinned regression file packages/oracles/tests/oracle-gaps-anchor.test.ts (3 tests) is kept as a supplementary test in its own file and does not discharge the law.

Mutant. The old statement-range walk restored in this head's anchorOf (the while loop checks FirstStatement..LastStatement only, as on main). The same command fails the same 16 tests with the same whole-file violation, so the oracle rejects the original defect.

Limits. One declaration per line, with no nested declarations, and only > comparisons as operators. The ~n suffix of a repeated anchor, the function part of a key, and ownership are not judged here. The anchor of a declaration that spans several lines is not generated. The gap check (node packages/oracles/oracle-gaps/index.mjs --package packages/oracles --source oracle-gaps/schemata.mjs --source oracle-gaps/report.mjs) refuses with "no file owns any selected source": no oracle in the package declares an owns entry over the gap CLI's sources. This is a property of the owner configuration, not of this change, and it is not closed here.

Expected conflicts. #99 and #133 also change gap-report-static-oracle.property.test.mjs. This change only appends one oracleProperty block after the file's last line, plus an import-free helper section above it, so a conflict is expected only where their edits reach the file's end.

This pull request and its description were written by Isaac.

…ent range

anchorOf() previously checked only FirstStatement..LastStatement, which
excludes Parameter, PropertyDeclaration, EnumMember, Decorator,
HeritageClause, ComputedPropertyName, and ExportAssignment. Mutants inside
default parameter initializers or class field initializers walked all the way
to SourceFile, dumping the entire file into mutant.anchor and mutant.key.

Stop at statements (via ts.isStatement) and small enclosing declarations
(parameters, property declarations, enum members, decorators, heritage
clauses, class static blocks, accessors, and computed member names), and add
regression tests covering tight anchors and edit stability.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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 31 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: 62cac188-972e-4baa-acc0-773e1dcfa649
Commits

Reviewing files that changed from the base of the PR and between 7b6bae1 and 2ab382c.

Files selected for processing: 5

  • .changeset/scope-anchors-to-declarations.md
  • packages/oracles/oracle-gaps/gap-report-static-oracle.property.test.mjs
  • packages/oracles/oracle-gaps/report.mjs
  • packages/oracles/oracle-gaps/schemata.mjs
  • packages/oracles/tests/oracle-gaps-anchor.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

@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2ab382c

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

A mutant outside TypeScript's statement range (a default parameter, a
property declaration, an enum member, a decorator, or a heritage clause)
walked up to the source file, so its anchor was the whole file's tokens
and its gap key changed on every edit. The anchor is now the innermost
statement or declaration that holds the site.

Law: oracle-gaps.report-anchor-scope, a property of the static gap
oracle (gap-report-static-oracle.property.test.mjs). Each generated
source declares the tokens of each declaration, and the check compares
every mutant's anchor with them and rejects a whole-file anchor.

RED on main's schemata.mjs: 16 tests fail (7 fixed-seed and 7
random-seed campaigns, plus 2 calibrations whose clean run fails).
GREEN: the static oracle file passes 200 of 200 tests, including 28
for the new property. Mutant: the old statement-range walk restored in
this head's anchorOf fails the same 16 tests.

One-time key change: on the gap CLI's own sources, 17 of 7,158 mutants
get new keys (5 files), each one a whole-file anchor before.

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