Skip to content

refactor(db): retire legacy tests with oracle-backed index fixes - #2116

Merged
KyleAMathews merged 51 commits into
mainfrom
codex/oracle-test-retirement-2-blocks
Oct 13, 2026
Merged

KyleAMathews merged 51 commits into
mainfrom
codex/oracle-test-retirement-2-blocks

Conversation

@KyleAMathews

@KyleAMathews KyleAMathews commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Why

This PR retires 31 legacy unit-test blocks after transferring their observable behavior to independent oracles. The transfer exposed index cases where physical storage changed a public query result. These changes preserve source keys and make indexed results agree with the query's declared order.

What changes

An ordered query must return the same bounded result with or without an index. On the previous PR head, orderBy(v).limit(1) chose 5n instead of 3 for rows with values [5n, 10n, 3]. The index now keeps its strict storage order but declines an ordered query plan when that order can disagree with the query. Direct reads and eager live queries pass the same mixed-value oracle. One retained on-demand history compares settled windows after a value-kind change, a finite provider request, and a cursor request.

The index rewrite also preserves exact source-key ownership across mixed values. BasicIndex stores exact keys at admission, so ordered Temporal reads do not repeat toString() for each visited row. BTreeIndex keeps comparator-tie buckets when one exact value leaves, which avoids rebuilding the whole group on a later update. Both index types pass the same normalized Date, Temporal, and byte inputs to a custom comparison callback.

The transfer also covers these independent value rules:

  • A full BasicIndex build keeps undefined in the configured nulls-first position.
  • Duration equality uses all ten public fields. Equal display text does not make two Durations equal.
  • Indexed ZonedDateTimes use instant order. Time-only Durations use elapsed-time order. PlainDates use calendar order, including the tested extended-year pair.
  • Indexed direct reads preserve the required TypeError for the tested mixed or unordered Temporal pairs.
  • Ordinary strings beginning with \0tanstack-db: follow their declared string collation.

The coverage map names each oracle owner and its limits. The review record contains baseline failures and hostile tests. The scope record tracks adjacent questions.

Limits and review outcome

The PR does not add guarantees after callers change standard data objects in place. It does not rebuild a live-query graph when captured inArray entries change. It does not define unsigned byte order or a universal order among unlike JavaScript values.

A high-effort review reproduced the mixed-value regression and found work and callback-input gaps that this follow-up addresses. The reviewer withdrew a claimed wrong live-query result for a reverse manual index. Its scratch test loaded DB IVM from a different checkout. With the matching package, both the previous PR head and origin/main returned the expected rows. The three-rank public oracle remains as a stronger regression test.

Code weight and verification

Against origin/main at bbbf017ef, production TypeScript adds 406 lines and removes 541 lines. This is 135 fewer production lines. Paired minified builds of the same 105 DB ESM files total 206,122 gzip bytes at baseline and 205,973 here. The package-file total is 149 bytes smaller. A single bundled consumer build measures 100,544 gzip bytes at baseline and 100,746 here. The raw consumer bundle is 52 bytes larger, and its gzip result is 202 bytes larger. Bundling changes which modules survive tree shaking and which text gzip can share. On the final pushed head, CI's compressed-size action reports 158 bytes less (-0.07%) across its measured DB and React DB files.

The full DB source suite passed 13,230 tests in 283 files before the final narrow oracle and compiler edits. After those edits, 25 focused mixed-order and custom-index tests passed. The Temporal oracle passed 68 tests, and the focused index-work tests passed. DB TypeScript, changed-file lint, formatting, the minified build, the minified public API test, and mangle-cache validation passed locally.

Checklist

  • I have tested this code locally with pnpm test.

Release impact

  • This change affects published code, and I have generated a changeset.
  • This change is tests and documentation only. No release is needed.

Loading
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