Skip to content

fix(oracle-gaps): preserve optional call continuations - #308

Closed
KyleAMathews wants to merge 2 commits into
mainfrom
codex/fix-gap-optional-chain
Closed

KyleAMathews wants to merge 2 commits into
mainfrom
codex/fix-gap-optional-chain

Conversation

@KyleAMathews

@KyleAMathews KyleAMathews commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

The gap runner can make a valid unmutated baseline throw when an optional call crosses a TypeScript non-null assertion. This blocked the indexed-snapshot oracle audit in TanStack/db#2502.

For example, this expression skips the continuation when buckets is absent:

group.buckets?.get(exact)!.add(key)

The instrumenter saw the assertion as the call's consumer and inserted a value wrapper. That wrapper ended the optional chain before .add. The fix follows expression wrappers before identifying receiver and callee uses. Parentheses retain their original semantics.

The existing validity owner now varies wrapper kind, wrapper depth and property, element, call and method continuations. It compares authored-source execution with instrumented execution on nullish and present receivers.

The complete validation also exposed quadratic reach indexing. baselineOf now appends to each site's fresh list rather than copying the growing list for every test. The existing classification oracle checks that order, membership and classification stay unchanged.

Evidence

  • Law: reuse inert instrumentation and the existing classification laws. No product policy changes.
  • Reach: both campaigns construct five non-null call continuations, plus 80 generated histories each. A fixed history retains the absent bucket shape.
  • RED: the new oracle rejects unchanged instrumentation at the returned-result comparison. It reports an introduced TypeError on a nullish receiver.
  • GREEN: the new property's 11 tests pass. The combined audit passes 33,688 tests in both baseline runs with zero nondeterminism. All 282 classification tests also pass before the reach refactor.
  • Mutants: the wrapper-context regression and loss of prior reach are each killed on reproducible routes. The final combined audit kills both mutants and reports zero gaps, crashes and unowned warnings.
  • Receiving check: DB's installed patched tool passes both instrumented baselines, with 105 tests. It kills all five review mutants with zero gaps. The normal DB run passes 623 tests.
  • Limits: these are selected authored-mutant audits. The wrapper grammar is synchronous and observes error names and getter reads.

The evidence record includes exact commands, controls, the stopped run and the deterministic reach-index measurement. Source and oracle lint pass. The package build passes.

@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4637fd4

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 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

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.

1 participant