Learn from Cheng Huang's modernization article - #1087
KyleAMathews wants to merge 6 commits into
Conversation
Inspired by Cheng Huang's article on AI-assisted development, this introduces a contract-based testing approach for the live query system. Changes: - Add contracts.ts with precondition/postcondition/invariant utilities - Add D2 multiplicity contracts to CollectionSubscriber.sendChangesToPipeline - Add contract verification test suite (16 tests) The contracts verify: - D2 multiplicity stays at 1 for all visible items - sentToD2Keys accurately tracks keys sent to D2 pipeline - Insert/delete operations maintain consistent tracking state Contracts can be disabled in production via NODE_ENV=production for performance.
🦋 Changeset detectedLatest commit: cabc33d The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
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 |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: +855 B (+0.96%) Total Size: 90.4 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.35 kB ℹ️ View Unchanged
|
Introduces property-based testing to explore edge cases in the live query system. Tests use fast-check to generate random sequences of operations and verify that invariants hold across all inputs. Properties tested: - D2 multiplicity invariant (no duplicate keys) - State consistency (live query matches expected state) - Delete-insert cycles (re-insert always succeeds after delete) - Filtered query correctness (only matching items present) - Batch operation consistency (sequential vs batched produce same result) - Stress testing (100-200 operations maintain invariants) All 9 property-based tests run 100 iterations each (20 for stress tests).
|
Closing as stale/superseded on the exact D2 path. Against pinned origin/main , an independent weighted-multiset model stays at exactly one D2 contribution through insert, duplicate insert, stale-before update, stale-payload delete, and reinsert. The hostile reconciler fails first at duplicate insert (weight 2), and the current 19-test D2 reconciliation oracle suite is GREEN. The production fix lineage is #1054 (), with stronger oracle coverage in #1816 (). Preserving Kyle Mathews/Claude experimental credit and Cheng Huang attribution; reusable runtime-contract ideas remain a future live-query diagnostics cluster. |
🎯 Changes
✅ Checklist
pnpm test:pr.🚀 Release Impact