fix(db): unify ordered window semantics #1778
codex/loadsubset-coverage-registry fromcodex/loadsubset-total-order·opened Summary#
- define one
TotalOrderfor query execution, cursor boundaries, source refinement, and public-key ties - retain applied row provenance in
WindowStateso offset/limit changes and SSE updates cannot widen from unproven rows - fetch and refine the full filtered region when locale, reference, or invalid-Date order cannot be expressed safely as a cursor
- align DB-IVM, BTree, and live-query ordering for NaN keys and descending-index ties
Why#
Lazy ordered queries previously used different order and coverage rules at each layer. A source page could look complete to one layer while the live query still lacked a tied row, or a later window could reuse a boundary that did not prove its prefix. This made results depend on request shape, event timing, and index direction.
This PR makes the applied row receipt the source of boundary provenance and uses the same total order from acquisition through publication.
Validation#
- DB: 135 files, 3,450 passed, 6 skipped, no type errors
- Query DB: 8 files, 334 passed, no type errors
- focused TotalOrder/coverage suites: 417 passed
- 100x pagination and replay oracles: 130 passed
- DB, DB-IVM, and Query DB builds and lints
- independent adversarial runtime review: approved
Stacked on #1774. Advances the TotalOrder/window-state step of #1657.
- 1
More templates
- todos
- offline-transactions-react-native
- shopping-list-react-native
- @tanstack/db-example-react-next-ssr-e2e
- tanstack-start-example-basic
- @tanstack/db-example-paced-mutations-demo
- tanstack-start-db-projects-example
- @tanstack/db-example-react-start-ssr-e2e
- @tanstack/db-example-react-todo
- @tanstack/db-example-solid-todo
- offline-first-electron
@tanstack/angular-db
npm i https://pkg.pr.new/@tanstack/angular-db@1778@tanstack/browser-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/browser-db-sqlite-persistence@1778@tanstack/capacitor-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/capacitor-db-sqlite-persistence@1778@tanstack/cloudflare-durable-objects-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/cloudflare-durable-objects-db-sqlite-persistence@1778@tanstack/db
npm i https://pkg.pr.new/@tanstack/db@1778@tanstack/db-ivm
npm i https://pkg.pr.new/@tanstack/db-ivm@1778@tanstack/db-sqlite-persistence-core
npm i https://pkg.pr.new/@tanstack/db-sqlite-persistence-core@1778@tanstack/electric-db-collection
npm i https://pkg.pr.new/@tanstack/electric-db-collection@1778@tanstack/electron-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/electron-db-sqlite-persistence@1778@tanstack/expo-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/expo-db-sqlite-persistence@1778@tanstack/node-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/node-db-sqlite-persistence@1778@tanstack/offline-transactions
npm i https://pkg.pr.new/@tanstack/offline-transactions@1778@tanstack/powersync-db-collection
npm i https://pkg.pr.new/@tanstack/powersync-db-collection@1778@tanstack/query-db-collection
npm i https://pkg.pr.new/@tanstack/query-db-collection@1778@tanstack/react-db
npm i https://pkg.pr.new/@tanstack/react-db@1778@tanstack/react-native-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/react-native-db-sqlite-persistence@1778@tanstack/react-router-with-db
npm i https://pkg.pr.new/@tanstack/react-router-with-db@1778@tanstack/rxdb-db-collection
npm i https://pkg.pr.new/@tanstack/rxdb-db-collection@1778@tanstack/solid-db
npm i https://pkg.pr.new/@tanstack/solid-db@1778@tanstack/svelte-db
npm i https://pkg.pr.new/@tanstack/svelte-db@1778@tanstack/tauri-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/tauri-db-sqlite-persistence@1778@tanstack/trailbase-db-collection
npm i https://pkg.pr.new/@tanstack/trailbase-db-collection@1778@tanstack/vue-db
npm i https://pkg.pr.new/@tanstack/vue-db@1778commit:
fed6992Size Change: +11 kB (+6.45%) 🔍
Total Size: 182 kB
📦 View Changed
Filename Size Change packages/db/dist/esm/collection/change-events.js1.47 kB +37 B (+2.57%) packages/db/dist/esm/collection/state.js6.51 kB +315 B (+5.09%) 🔍 packages/db/dist/esm/collection/subscription.js12.5 kB +6.22 kB (+98.51%) 🆘 packages/db/dist/esm/collection/sync.js7.49 kB +10 B (+0.13%) packages/db/dist/esm/errors.js5.39 kB +88 B (+1.66%) packages/db/dist/esm/event-emitter.js1.08 kB +335 B (+44.79%) 🚨 packages/db/dist/esm/index.js3.81 kB +24 B (+0.63%) packages/db/dist/esm/load-subset-request-provenance.js412 B +412 B (new file) 🆕 packages/db/dist/esm/query/compiler/order-by.js1.81 kB +6 B (+0.33%) packages/db/dist/esm/query/effect.js5.47 kB +279 B (+5.38%) 🔍 packages/db/dist/esm/query/live/collection-subscriber.js2.64 kB +156 B (+6.29%) 🔍 packages/db/dist/esm/query/live/subset-demand-controller.js1.24 kB +10 B (+0.82%) packages/db/dist/esm/query/live/utils.js1.39 kB +27 B (+1.99%) packages/db/dist/esm/query/live/window-state.js2.16 kB +2.16 kB (new file) 🆕 packages/db/dist/esm/query/subset-dedupe.js1.58 kB +39 B (+2.53%) packages/db/dist/esm/query/total-order.js604 B +604 B (new file) 🆕 packages/db/dist/esm/utils/comparison.js1.39 kB +57 B (+4.27%) packages/db/dist/esm/utils/cursor.js699 B +242 B (+52.95%) 🆘 compressed-size-action::db-package-sizeℹ️ View Unchanged
Filename Size packages/db/dist/esm/client.js3.66 kB packages/db/dist/esm/collection-options.js236 B packages/db/dist/esm/collection/changes.js1.95 kB packages/db/dist/esm/collection/cleanup-queue.js810 B packages/db/dist/esm/collection/events.js434 B packages/db/dist/esm/collection/index.js3.99 kB packages/db/dist/esm/collection/indexes.js1.99 kB packages/db/dist/esm/collection/lifecycle.js1.86 kB packages/db/dist/esm/collection/mutations.js2.54 kB packages/db/dist/esm/collection/transaction-metadata.js144 B packages/db/dist/esm/deferred.js207 B packages/db/dist/esm/indexes/auto-index.js829 B packages/db/dist/esm/indexes/base-index.js784 B packages/db/dist/esm/indexes/basic-index.js2.17 kB packages/db/dist/esm/indexes/btree-index.js2.29 kB packages/db/dist/esm/indexes/index-registry.js820 B packages/db/dist/esm/indexes/reverse-index.js557 B packages/db/dist/esm/live-query-adapter.js318 B packages/db/dist/esm/live-query-observer.js3.65 kB packages/db/dist/esm/live-query-options.js702 B packages/db/dist/esm/live-query-window-controller.js4.43 kB packages/db/dist/esm/local-only.js975 B packages/db/dist/esm/local-storage.js2.18 kB packages/db/dist/esm/optimistic-action.js359 B packages/db/dist/esm/paced-mutations.js496 B packages/db/dist/esm/proxy.js3.75 kB packages/db/dist/esm/query/builder/functions.js1.47 kB packages/db/dist/esm/query/builder/get-query-ir.js121 B packages/db/dist/esm/query/builder/index.js6.6 kB packages/db/dist/esm/query/builder/ref-proxy.js1.24 kB packages/db/dist/esm/query/compiler/evaluators.js1.9 kB packages/db/dist/esm/query/compiler/expressions.js430 B packages/db/dist/esm/query/compiler/group-by.js3.69 kB packages/db/dist/esm/query/compiler/index.js8.71 kB packages/db/dist/esm/query/compiler/joins.js2.95 kB packages/db/dist/esm/query/compiler/lazy-targets.js1.11 kB packages/db/dist/esm/query/compiler/parent-routes.js319 B packages/db/dist/esm/query/compiler/route-metadata.js419 B packages/db/dist/esm/query/compiler/select.js1.58 kB packages/db/dist/esm/query/coverage-registry.js4.75 kB packages/db/dist/esm/query/expression-helpers.js1.43 kB packages/db/dist/esm/query/ir-stable-identity.js4.17 kB packages/db/dist/esm/query/ir.js1.59 kB packages/db/dist/esm/query/live-query-collection.js391 B packages/db/dist/esm/query/live/bucket-facade-adapter.js2.76 kB packages/db/dist/esm/query/live/collection-config-builder.js7.32 kB packages/db/dist/esm/query/live/collection-registry.js264 B packages/db/dist/esm/query/live/internal.js145 B packages/db/dist/esm/query/live/materialized-pipeline.js2.47 kB packages/db/dist/esm/query/load-subset-options.js1.08 kB packages/db/dist/esm/query/load-subset-outcome.js557 B packages/db/dist/esm/query/optimizer.js2.92 kB packages/db/dist/esm/query/predicate-utils.js3.38 kB packages/db/dist/esm/query/query-once.js359 B packages/db/dist/esm/query/runtime-reference-identity.js463 B packages/db/dist/esm/scheduler.js1.43 kB packages/db/dist/esm/SortedMap.js1.3 kB packages/db/dist/esm/strategies/debounceStrategy.js247 B packages/db/dist/esm/strategies/queueStrategy.js428 B packages/db/dist/esm/strategies/throttleStrategy.js246 B packages/db/dist/esm/transactions.js3.5 kB packages/db/dist/esm/utils.js927 B packages/db/dist/esm/utils/array-utils.js273 B packages/db/dist/esm/utils/browser-polyfills.js304 B packages/db/dist/esm/utils/btree.js5.61 kB packages/db/dist/esm/utils/index-optimization.js2.39 kB packages/db/dist/esm/utils/type-guards.js157 B packages/db/dist/esm/utils/uuid.js449 B packages/db/dist/esm/virtual-props.js360 B Size Change: 0 B
Total Size: 7.25 kB
compressed-size-action::react-db-package-sizeℹ️ View Unchanged
Filename Size packages/react-db/dist/esm/DbProvider.js317 B packages/react-db/dist/esm/HydrationBoundary.js263 B packages/react-db/dist/esm/index.js330 B packages/react-db/dist/esm/live-query-internals.js282 B packages/react-db/dist/esm/useLiveInfiniteQuery.js1.81 kB packages/react-db/dist/esm/useLiveQuery.js2.68 kB packages/react-db/dist/esm/useLiveQueryEffect.js355 B packages/react-db/dist/esm/useLiveSuspenseQuery.js812 B packages/react-db/dist/esm/usePacedMutations.js401 B KyleAMathews(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
786a66d9-87a4-4005-b13e-ee3d43e740c3You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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