feat(persistence): settle covered on-demand demands from SQLite under network-first #2263
Merged
KyleAMathews(GitHub profile, opens in a new tab)merged 59 commits into
main fromrefs/pull/2263/head·merged by KyleAMathews(GitHub profile, opens in a new tab) Showing 56 changed files with 54 additions and 0 deletions (loading 53).
x
@@ -0,0 +1,11 @@
+---
+'@tanstack/db-sqlite-persistence-core': minor
+---
+
+`initialRender: { strategy: 'network-first' }` now works for on-demand persisted Collections, including Electric's `progressive` mode. Previously the configuration threw `InvalidPersistedCollectionConfigError`.
+
+A subset load that settles online records persisted demand coverage for its exact demand. In a later session, a load of the same demand settles on its rows from SQLite once `networkTimeoutMs` (default 3 seconds) has passed, or at once if the network load fails. The network load keeps running, and its rows publish when they arrive. If it fails after that, the query stays ready. A demand that never settled online still waits for the network. Coverage proves that the rows were complete when they were loaded, not that they are still current. A source truncate, a snapshot transaction, scoped recovery, or a cache-generation rotation clears it. A load that a reset made obsolete, a load that was released before it settled, and a load during the rest of a scoped-recovery sync run record none. Coverage also ends when SQLite holds fewer rows for the demand than when it settled, for example after a source delete or Query DB retention expiry. A `refetch: true` load always waits for the network. An ordered window with a `limit` stays covered only while SQLite holds the same rows for it.
+
+A query that joins eager and on-demand sources becomes ready when every eager source is ready, which network-first allows from its restored rows after the deadline, and every demand the query reaches on an on-demand source has settled. A network failure alone does not settle an on-demand demand that is not covered.
+
+This applies only with the default single-process coordinator. With a multi-tab coordinator, such as `BrowserCollectionCoordinator`, on-demand loads still wait for the network.
@@ -0,0 +1,35 @@
+name: Nightly oracles
+
+# Longer oracle campaigns than PR CI can afford. The generated demand
+# coverage campaign runs with ten times its PR budget, and every hostile
+# mutant in scripts/demand-coverage-mutants.mjs must fail a named test.
+on:
+ schedule:
+ - cron: '17 6 * * *'
+ workflow_dispatch:
+
+concurrency: