Repository navigation
fix(oracle-gaps): scope mutant anchors to declarations outside statement range - #196
Open
schiller-manuel wants to merge 2 commits into
Open
schiller-manuel wants to merge 2 commits into
schiller-manuel wants to merge 2 commits into
Conversation
…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>
|
Warning Review limit reachedYou'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. View limit details
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. |
🦋 Changeset detectedLatest commit: 2ab382c 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 |
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>
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.
Summary
anchorOfinpackages/oracles/oracle-gaps/schemata.mjsso mutants outside TypeScript'sFirstStatement..LastStatementrange no longer walk up toSourceFileand dump the entire file's tokens intomutant.anchorandmutant.key.ts.isStatement(coveringExportAssignmentalongside 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.packages/oracles/tests/oracle-gaps-anchor.test.tsverifying tight, stable anchors for default parameters, class fields, decorators, heritage clauses, computed member names, enum members, andexport default.Validation
pnpm run build— passedpnpm run typecheck— passedpnpm run lint:check— passedpnpm run format:check— passedpnpm --filter @tanstack/oracles run test— 9 files, 120 tests passedpnpm --filter @tanstack/oracles run test:oracle-gaps:fast— 5 files, 33,899 tests passedpnpm --filter @tanstack/oracles run test:oracle-gaps:shards— 5 shards partitionedpnpm --filter @tanstack/oracles run test:pr-shards— 7 partitions verifiedOracle 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.mjs5,classify.mjs8,daemon.mjs2,args.mjs1,ending.mjs1). Each was a whole-file anchor on main, and each now anchors to its declaration, for examplecheck.mjs:182now 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.mjsswapped in, thenvitest --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(lawanchor 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(thewhileloop checksFirstStatement..LastStatementonly, 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~nsuffix 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 anownsentry 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 oneoraclePropertyblock 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.