Repository navigation
refactor(db): retire legacy tests with oracle-backed index fixes - #2116
Merged
Merged
Conversation
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.
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)chose5ninstead of3for 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.
BasicIndexstores exact keys at admission, so ordered Temporal reads do not repeattoString()for each visited row.BTreeIndexkeeps 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:
BasicIndexbuild keepsundefinedin the configured nulls-first position.TypeErrorfor the tested mixed or unordered Temporal pairs.\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
inArrayentries 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/mainreturned the expected rows. The three-rank public oracle remains as a stronger regression test.Code weight and verification
Against
origin/mainatbbbf017ef, 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
pnpm test.Release impact