Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
00389a4
fix: safe randomUUID helper for non-secure browser contexts (#1593)
kevin-dp Jun 17, 2026
3124c9e
Added attachments support.
Chriztiaan Jun 12, 2026
d18ab19
Types and tests.
Chriztiaan Jun 18, 2026
2147345
Export and document subtract, multiply, divide math functions (#1151)
KyleAMathews Jun 18, 2026
9a5e8e5
ci: Version Packages (#1596)
github-actions[bot] Jun 18, 2026
91c24c6
Docs.
Chriztiaan Jun 23, 2026
3770d3b
changeset.
Chriztiaan Jun 23, 2026
307fdf8
fix: preload hangs forever after cleanup (#1576) (#1606)
kevin-dp Jun 23, 2026
45617c4
ci: Version Packages (#1612)
github-actions[bot] Jun 23, 2026
38af8c5
Rename saveFileTanStack => save, deleteFIleTanStack => delete.
Chriztiaan Jun 24, 2026
d82ffc2
Made `updateHook` synchronous and updated `AttachmentQueueRow` typing.
Chriztiaan Jun 24, 2026
cd8b191
Merge branch 'main' into feat/powersync-attachments
Chriztiaan Jun 25, 2026
3e59ca5
docs: regenerate API documentation (#1477)
github-actions[bot] Jun 25, 2026
403be75
docs(browser-db-sqlite-persistence): document multi-tab coordinator u…
kevin-dp Jun 25, 2026
267b36b
docs: document materialize() helper for includes subqueries (#1580)
kevin-dp Jun 25, 2026
99d33d5
fix(react-db): defer eager onStoreChange to a microtask in useLiveQue…
kevin-dp Jun 26, 2026
ac09b11
fix(db): prevent prototype pollution via select() alias paths (#1584)…
kevin-dp Jun 26, 2026
36fb29a
fix(query): lazy-join loads through the collection the join key resol…
kevin-dp Jun 26, 2026
d79b0cd
fix: enforce all where conditions when index optimization is partial …
kevin-dp Jun 26, 2026
b05139f
ci: Version Packages (#1621)
github-actions[bot] Jun 26, 2026
e6a8cc2
docs: regenerate API documentation (#1622)
github-actions[bot] Jun 26, 2026
2b27dd1
fix: reconcile duplicate live query child inserts (#1600)
KyleAMathews Jun 26, 2026
928afa4
ci: Version Packages (#1624)
github-actions[bot] Jun 26, 2026
99e9afe
fix(db): preserve discriminated union types through .select() (#1511)…
kevin-dp Jun 29, 2026
816b667
fix(db): nested toArray includes drop children when sibling groups sh…
kevin-dp Jun 29, 2026
7ce457e
Fix unused vars (#1627)
Jaime02 Jun 30, 2026
2b3d5e5
ci: Version Packages (#1628)
github-actions[bot] Jun 30, 2026
f7da776
fix(sqlite-persistence): preserve query owner metadata on insert (clo…
kevin-dp Jul 1, 2026
397e12a
fix(db): avoid full row origin snapshots (#1640)
samwillis Jul 2, 2026
95e25bd
ci: Version Packages (#1632)
github-actions[bot] Jul 2, 2026
3ec3e7a
test: cross-adapter useLiveQuery conformance suite
kevin-dp Jul 7, 2026
18ba740
fix(query-db-collection): keep on-demand query metadata clone-safe (#…
KyleAMathews Jul 7, 2026
a93abf6
ci: Version Packages (#1651)
github-actions[bot] Jul 8, 2026
6d4c096
refactor(db): extract shared live-query adapter helpers (RFC #1623 st…
kevin-dp Jul 9, 2026
b2f305a
fix(svelte-db): disabled useLiveQuery no longer crashes (#1637)
kevin-dp Jul 9, 2026
42fb59c
fix(angular-db): config-object input to injectLiveQuery now syncs (#1…
kevin-dp Jul 9, 2026
f3ade65
test(conformance): parametrize how adapters surface query errors (#1639)
kevin-dp Jul 9, 2026
e147721
test(query-db-collection): cover query invalidation behavior (#1655)
KyleAMathews Jul 9, 2026
b2b8923
docs(query-db-collection): clarify select row extraction (#1654)
KyleAMathews Jul 9, 2026
580f9d0
docs(query-db-collection): document query option compatibility (#1653)
KyleAMathews Jul 9, 2026
eabcea7
Clarify local write status docs and pending sync contract (#1652)
KyleAMathews Jul 9, 2026
aa41c49
fix: use patch bump for adapter helpers (#1668)
KyleAMathews Jul 13, 2026
cbd6081
refactor(query-db-collection): extract query ownership helpers (#1664)
KyleAMathews Jul 13, 2026
d64e1ab
feat(query-db-collection): support more top-level query options (#1665)
KyleAMathews Jul 13, 2026
e51d008
docs(query-db-collection): document runtime QueryClient factory patte…
KyleAMathews Jul 13, 2026
09d7d67
ci: Version Packages (#1661)
github-actions[bot] Jul 13, 2026
6ed8b15
fix(electric-db-collection): preserve persisted rows on progressive r…
pkudinov Jul 13, 2026
286964d
fix(db): preserve explicit gcTime of 0 on live query collections (#1660)
spokodev Jul 13, 2026
73e5b67
test(query-db-collection): characterize cancellation and subset clean…
KyleAMathews Jul 16, 2026
d2a11b1
fix(electric): bound refresh wait for on-demand subsets (#1575)
KyleAMathews Jul 16, 2026
82b90a9
docs: regenerate API documentation (#1629)
github-actions[bot] Jul 16, 2026
4d0b1c0
docs(query-db-collection): document scoped collection factories (#1671)
KyleAMathews Jul 16, 2026
b850340
docs: add contributing guide (#1620)
KyleAMathews Jul 16, 2026
8258d09
fix(db): restore query typechecking for generic collection row types …
obeattie Jul 16, 2026
f89fad1
ci: Version Packages (#1670)
github-actions[bot] Jul 16, 2026
7f0fa36
docs: regenerate API documentation (#1680)
github-actions[bot] Jul 16, 2026
a9e13d5
test: cover late query readiness rejection (#1681)
KyleAMathews Jul 20, 2026
932910d
fix(query-db): clean up empty ownership sets (#1672)
KyleAMathews Jul 20, 2026
f42db5c
feat(query-db): support eager initial data (#1683)
KyleAMathews Jul 20, 2026
2250d35
Merge branch 'main' into feat/powersync-attachments
Chriztiaan Jul 21, 2026
7246c75
ci: Version Packages (#1687)
github-actions[bot] Jul 22, 2026
d70fb2a
docs: regenerate API documentation (#1689)
github-actions[bot] Jul 24, 2026
8ee783d
perf(db): skip unchanged index updates (#1691)
K-Mistele Jul 24, 2026
309a36d
ci: Version Packages (#1693)
github-actions[bot] Jul 24, 2026
38682e4
docs: clarify query cancellation semantics (#1694)
KyleAMathews Jul 24, 2026
67c840f
fix(powersync): applyTransaction hangs forever when a transaction mix…
Chriztiaan Jul 24, 2026
dc7f13e
Minor patch changeset. Updated docs to reflec sync nature of updateHook.
Chriztiaan Jul 28, 2026
6d458a8
Rollback new written attachment on transaction failure.
Chriztiaan Aug 3, 2026
f9f6823
Cleanup import formatting and removed incorrect doc line.
Chriztiaan Aug 3, 2026
2718e1b
Merge branch 'feat/powersync-attachments' of github.com:powersync-ja/…
Chriztiaan Aug 3, 2026
5d3b500
Minor coderabbit feedback.
Chriztiaan Aug 3, 2026
ef0dc8c
fix(powersync): Don't flush records when diff trigger isn't setup yet…
Chriztiaan Aug 10, 2026
fc55bee
Address concurrent save race issue.
Chriztiaan Aug 11, 2026
91649d7
test(db): add includes recompute oracle (#1716)
KyleAMathews Aug 11, 2026
98f3ed0
test(db): tighten includes oracle failure checks (#1717)
KyleAMathews Aug 11, 2026
ad88d07
feat(db): shared live-query observer + migrate all five adapters (RFC…
kevin-dp Aug 11, 2026
7e7abda
feat(db): ordered snapshot / layout-revision contract (RFC #1623 phas…
kevin-dp Aug 12, 2026
2985e0b
docs: use the dynamic README header endpoint (#1710)
AlemTuzlak Aug 12, 2026
e4940a4
test(db): extract reusable trace runner (#1718)
KyleAMathews Aug 12, 2026
9005885
test(db): expand includes oracle state coverage (#1719)
KyleAMathews Aug 12, 2026
0b2a5a0
test(db): add controlled includes oracle drivers (#1720)
KyleAMathews Aug 12, 2026
dc53f0e
feat(db): shared live-query window controller (RFC #1623 phase 5) (#1…
kevin-dp Aug 12, 2026
e19a954
feat(svelte-db): add infinite query binding (#1723)
tannerlinsley Aug 12, 2026
2c35b58
ci: Version Packages (#1697)
github-actions[bot] Aug 12, 2026
424382b
feat(vue-db): add infinite query binding (#1724)
tannerlinsley Aug 13, 2026
e5543bd
docs: regenerate API documentation (#1695)
github-actions[bot] Aug 13, 2026
bf8714c
ci: Version Packages (#1730)
github-actions[bot] Aug 13, 2026
9f3cb6f
docs: regenerate API documentation (#1731)
github-actions[bot] Aug 13, 2026
5f63996
docs: update agent skills for current APIs (#1696)
KyleAMathews Aug 13, 2026
4f991c1
ci: Version Packages (#1732)
github-actions[bot] Aug 13, 2026
1b42802
test(db): fuzz visible includes relationship transitions (#1722)
KyleAMathews Aug 13, 2026
5636eb9
test(db): cover includes query-shape bugs (#1725)
KyleAMathews Aug 13, 2026
c06ecbb
test(db): fuzz includes transition histories (#1733)
KyleAMathews Aug 14, 2026
3ff56cb
test(db): fuzz includes relationship batch shapes (#1739)
KyleAMathews Aug 15, 2026
e9fbc10
test(db): add includes work and shape oracles (#1738)
KyleAMathews Aug 15, 2026
1a9328a
test(db): cover optimistic includes relationships (#1735)
KyleAMathews Aug 15, 2026
cc686f1
test(db): fuzz includes route lifecycles (#1734)
KyleAMathews Aug 15, 2026
6a96669
test(db): cover layered includes publication (#1736)
KyleAMathews Aug 15, 2026
c2a9447
test(query-db): cover ownership lifecycles (#1737)
KyleAMathews Aug 15, 2026
4b9e8cd
Add SSR DbClient and live query identity (#1564)
tannerlinsley Aug 17, 2026
220a1b3
ci: Version Packages (#1742)
github-actions[bot] Aug 18, 2026
a20352a
fix(db): support Temporal values in query comparison operators (#1519)
obeattie Aug 18, 2026
5d9335d
feat(db): rebuild includes materialization as one D2 graph (#1740)
KyleAMathews Aug 20, 2026
a54c8e4
ci: Version Packages (#1749)
github-actions[bot] Aug 20, 2026
aa2ec69
docs: regenerate API documentation (#1755)
github-actions[bot] Aug 21, 2026
aaba924
test(db): add loadSubset and pagination oracles (#1750)
KyleAMathews Aug 21, 2026
c521b5d
fix(db): propagate initial query errors (#1751)
KyleAMathews Aug 21, 2026
bda6f7b
ci: Version Packages (#1758)
github-actions[bot] Aug 21, 2026
32ca264
docs: regenerate API documentation (#1759)
github-actions[bot] Aug 21, 2026
99ba511
fix(db): reject query values from fn.select (#1760)
KyleAMathews Aug 23, 2026
43cc741
fix(react-db): support conditional query configs (#1757)
KyleAMathews Aug 23, 2026
c6f08a9
ci: Version Packages (#1762)
github-actions[bot] Aug 23, 2026
dc903ce
docs: regenerate API documentation (#1763)
github-actions[bot] Aug 24, 2026
8f432ba
fix(db): harden incremental subset recovery (#1756)
KyleAMathews Aug 24, 2026
3131de1
fix(db): preserve correlated include route identity (#1761)
KyleAMathews Aug 24, 2026
afbacf7
ci: Version Packages (#1765)
github-actions[bot] Aug 24, 2026
d8defd2
fix(db): canonicalize loadSubset demand identity (#1768)
KyleAMathews Aug 25, 2026
8c5838d
fix(db): settle subset loads after publication (#1769)
KyleAMathews Aug 25, 2026
9ad882f
fix(db): reuse collection descriptors by id (#1770)
KyleAMathews Aug 25, 2026
5695db9
ci: Version Packages (#1771)
github-actions[bot] Aug 25, 2026
098e1ee
docs: regenerate API documentation (#1766)
github-actions[bot] Aug 25, 2026
ae2fe74
fix(db): lazily initialize runtime reference identities (#1782)
TimFL Aug 27, 2026
bda2303
ci: Version Packages (#1784)
github-actions[bot] Aug 27, 2026
bbc9edf
fix(db): match index collation options semantically (#1788)
KyleAMathews Aug 31, 2026
613807d
ci: Version Packages (#1789)
github-actions[bot] Aug 31, 2026
68366ec
docs: regenerate API documentation (#1790)
github-actions[bot] Aug 31, 2026
cfb01ce
fix: harden subset loading, recovery, and live-query value semantics …
KyleAMathews Sep 10, 2026
c564748
fix: clear release-blocking lint errors (#1801)
KyleAMathews Sep 10, 2026
667d533
ci: Version Packages (#1802)
github-actions[bot] Sep 10, 2026
ad043b7
fix: finish loadSubset review and recovery follow-ups (#1800)
KyleAMathews Sep 10, 2026
bb7cbba
fix(powersync): load attachment IDs before mutations and guard file o…
KyleAMathews Sep 11, 2026
d34d2d4
chore: add changeset for attachment ownership fixes
KyleAMathews Sep 11, 2026
743d11a
docs: regenerate API documentation (#1803)
github-actions[bot] Sep 11, 2026
025a079
fix(db): harden optimistic settlement and queued derived updates (#1807)
KyleAMathews Sep 11, 2026
6e60d30
fix: reject ignored infinite-query page callbacks (#1806)
KyleAMathews Sep 11, 2026
15c4ba0
fix(trailbase): isolate stream lifetimes and add lifecycle oracle (#1…
KyleAMathews Sep 11, 2026
ddc129e
fix(db): reclaim unused sync without aborting preloads (#1810)
KyleAMathews Sep 11, 2026
2645a08
docs: remove duplicate page headings (#1799)
KevinVandy Sep 11, 2026
a378bd3
fix: harden collection lifecycle and resume invariants (#1785)
KyleAMathews Sep 11, 2026
50288a4
Merge pull request #10 from TanStack/codex/powersync-attachment-revie…
Chriztiaan Sep 14, 2026
2b8e76d
Merge branch 'main' into feat/powersync-attachments
Chriztiaan Sep 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 17 additions & 0 deletions .changeset/calm-oracles-check-loss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@tanstack/db': patch
'@tanstack/db-sqlite-persistence-core': patch
'@tanstack/electric-db-collection': patch
---

Harden Electric resume and lifecycle handling so partial updates cannot materialize unknown or moved-out rows, stale async work and waiters cannot cross cleanup or restart—including automatic garbage collection—and valid batches behave the same across callback partitions and persistence hydration.

Preserve hydrated baseline rows during persistence reloads, accept complete-row updates from explicit full-replica resumes, retain committed match evidence until reset, and restart persisted resumes when hydration completion cannot be verified.

Replace stale cached rows atomically when an invalid resume falls back to a fresh snapshot. Keep subset acquisitions from restoring logically removed rows, and isolate utilities and tag visibility when collection options are reused while preserving compatible same-collection resume state.

Accept partial updates to complete rows published independently by persistence, while preserving pending removal and reset boundaries. Avoid copying all applied keys at startup or each subset acquisition; presence checks overlay queued writes and buffered messages once per stream callback. Warn once when an older persistence adapter cannot verify hydration for safe resume.

Keep buffered tag move-outs inside the progressive snapshot's existing transaction so later live updates are not discarded behind an orphaned truncate.

Keep copied materialized configs and reentrant match callbacks scoped to their owning collection session. Cold tagged or legacy persisted state now recovers with a full snapshot behind cached rows, including in on-demand mode. Keep the reset marker through interrupted recovery and publish the replacement only after the full snapshot completes; known untagged and compatible warm resumes retain their saved offset.
6 changes: 6 additions & 0 deletions .changeset/curly-planets-lead.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@tanstack/powersync-db-collection': minor
---

Add attachments support via `TanStackDBAttachmentQueue`. This extends the PowerSync SDK's `AttachmentQueue` and backs it with
a TanStack DB collection, so attachment metadata and related rows commit atomically. Local files and remote uploads/deletes are managed separately.
11 changes: 11 additions & 0 deletions .changeset/finish-review-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@tanstack/db': patch
'@tanstack/db-sqlite-persistence-core': patch
'@tanstack/powersync-db-collection': patch
---

Preserve native values, arbitrary class references, and draft cycles during mutation detachment; keep transaction persistence receipts settled after publication errors and avoid restoring an acknowledged direct insert over its server row. Keep a delete/reinsert visible when the old synced row has not yet been replaced.

Retire replaced ordered prefixes without interrupting successful-load bookkeeping if release throws. Retry automatic ordered repair at most twice while retaining stale results and exposing the error; cleanup cancels retries and explicit window retry remains available.

Keep persisted acquisitions independent, avoid retaining one-shot refreshes as permanent demand, and reject upstream load failures without discarding cached rows. Restore PowerSync readiness only after the recovered baseline also removes rows deleted or moved outside active filters during the tracking outage.
5 changes: 5 additions & 0 deletions .changeset/fix-optimistic-field-reconciliation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/db': patch
---

Preserve whole-row optimistic snapshots through sync and truncate. Fix insert-dependent update settlement, local origin tracking, and rollback publication while sibling requests remain pending. Keep source updates beneath an optimistic live-query delete when queued sync batches apply, without changing sync queue timing.
5 changes: 5 additions & 0 deletions .changeset/fix-trailbase-stream-lifetimes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/trailbase-db-collection': patch
---

Fix unhandled rejections and resource leaks when a TrailBase subscription closes, fails, or is cleaned up. Drain buffered events before releasing the reader and prevent a canceled startup from canceling a replacement sync session.
5 changes: 5 additions & 0 deletions .changeset/lucky-donkeys-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/db': patch
---

Reclaim collections that start syncing without subscribers, releasing unused live-query subscriptions after a minimum 50ms grace period. Keep pending preloads alive until they settle and refresh retention when preloading ready data; `gcTime: 0` continues to disable automatic GC. Keep detached observer snapshots fresh after empty reloads and allow Node processes to exit while background collection cleanup is pending.
5 changes: 5 additions & 0 deletions .changeset/powersync-attachment-startup-ownership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/powersync-db-collection': patch
---

Load attachment IDs before save/delete in eager and on-demand collections. Preserve existing files when a duplicate save is rejected, reject overlapping saves of the same ID across queues sharing a database, and clean up partial local writes.
7 changes: 7 additions & 0 deletions .changeset/reject-ignored-page-callback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/react-db': minor
'@tanstack/vue-db': minor
'@tanstack/svelte-db': minor
---

Remove the ignored `getNextPageParam` option from `useLiveInfiniteQuery` and reject it with a clear error when passed at runtime. Delete this callback from your config; for server pagination, use an on-demand Query Collection whose `queryFn` fulfills `meta.loadSubsetOptions`. Document fixed-server-page loading and clarify that `initialPageParam` labels result pages rather than setting a server cursor.
69 changes: 69 additions & 0 deletions .github/SSR_RELEASE_PLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# TanStack DB SSR Release Plan

## Release Goal

Ship TanStack DB SSR as a single coherent story:

- explicit collection-row hydration and live-query result snapshots through
`DbClient`
- React and Svelte provider and descriptor resolution
- derived live query identity with `queryKey` only when necessary
- backwards-compatible dependency arrays with dev warnings until 1.0
- a working TanStack Start demo and E2E proof

## Pre-release Validation

- Run `pnpm --filter @tanstack/db test`.
- Run `pnpm --filter @tanstack/react-db test`.
- Run `pnpm --filter @tanstack/svelte-db test`.
- Run `pnpm --filter @tanstack/react-router-with-db test` (includes type
tests).
- Run `pnpm --filter @tanstack/query-db-collection test`.
- Run `pnpm --filter @tanstack/db-sqlite-persistence-core test`.
- Run `pnpm --filter @tanstack/db-example-react-start-ssr-e2e test:e2e`.
- Run `pnpm --filter @tanstack/db-example-react-next-ssr-e2e test:e2e`.
- Run `pnpm test:docs`.
- Run `pnpm test:sherif`.
- Run `pnpm build`.

## Demo

- Live URL: https://tanstack-db-ssr-demo.netlify.app/ssr-db
- Deploy `examples/react/start-ssr-e2e` to an SSR-capable host.
- Verify the deployed `/ssr-db` route serves SSR HTML with hydrated rows.
- Verify browser hydration succeeds without console/page errors.
- Verify the streamed collection chunk updates the live query.
- Verify `/ssr-db-stream` streams a projected result, omits source-only data,
and hands off to browser sync.
- Run `PLAYWRIGHT_BASE_URL=https://tanstack-db-ssr-demo.netlify.app pnpm --filter @tanstack/db-example-react-start-ssr-e2e test:e2e:hosted`.
- Add the live URL to the PR description and release notes.

## Docs

- Publish the [SSR and Hydration guide](../docs/guides/ssr.md).
- Link the guide from overview, quick start, live queries, and React overview.
- Regenerate API reference docs in a dedicated docs-maintenance pass if broad
TypeDoc output churn is acceptable.
- Confirm docs explain when `queryKey` is necessary and when it should be
omitted.
- Confirm docs say dependency arrays warn now and are removed in 1.0.

## Migration Messaging

- Lead with: explicit collection preloads transport normalized rows; live-query
preloads transport only their result snapshot.
- Emphasize that existing apps keep working.
- State that `createCollection(...)` remains available, but SSR apps should use
`collectionOptions(...)` plus `DbClient`.
- Explain that React dependency arrays are deprecated with a 1.0 removal path.
- Show `queryKey` only for opaque functional query logic or hot render paths.

## Announcement Checklist

- PR description includes high-level summary, migration cheat sheet, and test
commands.
- Release notes include a "No removals in this release" compatibility section.
- Discord announcement links the SSR guide and live demo.
- Example migration diff is available from the Start SSR demo.
- Follow-up issues are filed for the remaining framework adapters and API
reference generation if they are not part of the shipping PR.
16 changes: 16 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
run: |
pnpm --filter @tanstack/db-ivm build
pnpm --filter @tanstack/db build
pnpm --filter @tanstack/react-db build
pnpm --filter @tanstack/electric-db-collection build
pnpm --filter @tanstack/offline-transactions build
pnpm --filter @tanstack/query-db-collection build
Expand All @@ -68,6 +69,21 @@ jobs:
env:
ELECTRIC_URL: http://localhost:3000

- name: Install Playwright browsers
run: |
cd examples/react/start-ssr-e2e
pnpm exec playwright install --with-deps chromium

- name: Run React Start SSR E2E tests
run: |
cd examples/react/start-ssr-e2e
pnpm test:e2e

- name: Run Next.js SSR E2E tests
run: |
cd examples/react/next-ssr-e2e
pnpm test:e2e

- name: Run Node SQLite persisted collection E2E tests
run: |
cd packages/node-db-sqlite-persistence
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ yarn.lock
build
coverage
dist
playwright-report
test-results

# misc
.DS_Store
Expand All @@ -19,6 +21,7 @@ dist
.env.test.local
.env.production.local
.next
next-env.d.ts

npm-debug.log*
yarn-debug.log*
Expand Down
68 changes: 67 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

This guide provides principles and patterns for AI agents contributing to the TanStack DB codebase. These guidelines are derived from PR review patterns and reflect the quality standards expected in this project.

## Required reading: live-query materialization

Before reading, analyzing, or modifying correlated live-query materialization
code under `packages/db/src/query/live/`, read
`packages/db/src/query/live/ARCHITECTURE.md` in full. Read it before changing
the related includes oracle tests as well.

Treat that document's component boundaries and normative laws as constraints.
If a change intentionally revises an architectural contract, update the
architecture document in the same pull request.

## Table of Contents

1. [Type Safety](#type-safety)
Expand Down Expand Up @@ -351,7 +362,8 @@ const dependentBuilders = [] // Accurately describes dependents

### Always Add Tests for Bugs

**Key Principle:** If you're fixing a bug, add a unit test that reproduces the bug before fixing it. This ensures:
**Key Principle:** Reproduce a bug in a test before fixing it. Prefer extending
an oracle as described below over adding an isolated unit test. This ensures:

- The bug is actually fixed
- The bug doesn't regress in the future
Expand All @@ -368,6 +380,60 @@ test('ignores snapshot that resolves after up-to-date message', async () => {
})
```

### Treat Every Review Bug as a Test Gap

When a reviewer agent confirms a bug, it must also ask why the existing tests
did not catch it. The finding should name the missing test law, state
transition, generator dimension, adapter boundary, or assertion. If a test or
oracle should already have caught the bug, identify the false-green model,
classifier, fixture, or assertion that let it pass. Use that analysis to suggest
the smallest test or oracle improvement that would catch the same class of bug,
not only the reported example.

### Keep Oracles Independent

An oracle is useful only when its expected result comes from a source independent
of the implementation under test. Do not translate production branches, state
machines, classifiers, or helper functions into a second implementation and call
that an oracle. Both copies can encode the same wrong assumption.

- Derive expected behavior from public contracts, documented prior behavior,
mathematical laws, or a separately specified reference model.
- Keep the reference model structurally different from production. Do not import
the production helper or reuse its classifications to compute expected results.
- Preserve existing contract tests unless a product or design decision explicitly
changes the contract. Rewriting a passing expectation to match new production
behavior is a design review, not routine test maintenance.
- When production work suggests an oracle change, compare the old and new
semantics with counterexamples before editing the oracle.
- Use hostile mutants to prove the oracle rejects plausible wrong designs,
including the mistake production currently makes. A green oracle without a
demonstrated kill is weak evidence.
- Use process grammar to explore lifecycle paths, and design grammar to challenge
the oracle's reference semantics. More generated traces cannot repair a wrong
reference model.

### Prefer Oracle Coverage Over Isolated Regressions

An oracle that checks general laws across generated states and histories is a
stronger form of coverage than a unit test for one specific example. Prefer
extending an existing oracle when it can cover the behavior. Add the missing
model rule, generator dimension, state transition, or observable assertion;
adding more pinned examples alone does not generalize the oracle.

Use a focused regression to isolate and shrink a failure, then keep it as a
replay example for the broader oracle where possible. Verify that the expanded
oracle fails without the fix and passes with it. Keep valuable unit tests, but
do not treat them as a substitute for applicable oracle coverage. If an oracle
is not practical for the behavior, explain why a focused test is sufficient.

### Name Tests After Behavior

Test names should state the behavior they prove. Do not put issue or pull
request numbers in test names; those references become stale and make the test
suite harder to read. When an external report contains essential context that
the test cannot express, link it in a nearby comment instead.

### Test Corner Cases

Common corner cases to consider:
Expand Down
Loading
Loading