Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughThis change adds durable offline replica behavior across persistence, connection lifecycle, recovery, and component discovery. It adds manual and read-only modes, request-argument capture, awaitable lifecycle methods, serialized writes, durable raw-update storage, and SQLite shutdown transactions. Component snapshots now support publication markers, migration batches, and ordered snapshot/delta streaming. The package now includes pinned, checksummed wa-sqlite assets with browser, native, packed-consumer, and CI validation. Documentation covers the new APIs and migration process. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The previously identified documentation and command-availability concerns are resolved, with no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 28.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 52 functions across 43 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Update the remaining OPFS references and document assetBase. · README.md:367-379
README.md:367-379
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winUpdate the remaining OPFS references and document
assetBase.Line 3 now states that web storage uses IndexedDB-backed SQLite. These sections still describe OPFS.
docs/offline-replicas.mdline 82 states the browser worker uses IDBBatchAtomicVFS (IndexedDB), not OPFS. The same stale claim also appears at line 1069 ("SQLite in OPFS"). TheWebSqliteOptionsblock also omitsassetBase, whichdocs/offline-replicas.mdline 93 andpackages/replicate/test/browser/main.tsline 37 both use.📝 Proposed documentation fix
-| `persistence.web.sqlite.create(options)` | Browser | wa-sqlite in a Web Worker with OPFS storage | +| `persistence.web.sqlite.create(options)` | Browser | wa-sqlite in a Web Worker with IndexedDB storage | @@ interface WebSqliteOptions { - name: string; // Database name in OPFS + name: string; // Database name in IndexedDB + assetBase?: string; // Base path of the copied wa-sqlite runtime assets worker: Worker | (() => Worker | Promise<Worker>); }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: b7a2cf5a-78d2-4c4e-ab1d-1e8ccc396ae1
⛔ Files ignored due to path filters (4)
bun.lockis excluded by!**/*.lockpackages/replicate/assets/wa-sqlite/dist/wa-sqlite-async.mjsis excluded by!**/dist/**packages/replicate/assets/wa-sqlite/dist/wa-sqlite-async.wasmis excluded by!**/dist/**,!**/*.wasmpackages/replicate/src/component/_generated/component.tsis excluded by!**/_generated/**
📒 Files selected for processing (53)
.gitattributes.github/workflows/ci.yml.gitignore.prettierignoreCHANGELOG.mdREADME.mddocs/offline-replicas.mdeslint.config.jspackages/replicate/assets/wa-sqlite/ACKNOWLEDGMENTS.mdpackages/replicate/assets/wa-sqlite/LICENSEpackages/replicate/assets/wa-sqlite/manifest.jsonpackages/replicate/assets/wa-sqlite/src/FacadeVFS.jspackages/replicate/assets/wa-sqlite/src/VFS.jspackages/replicate/assets/wa-sqlite/src/WebLocksMixin.jspackages/replicate/assets/wa-sqlite/src/examples/IDBBatchAtomicVFS.jspackages/replicate/assets/wa-sqlite/src/sqlite-api.jspackages/replicate/assets/wa-sqlite/src/sqlite-constants.jspackages/replicate/package.jsonpackages/replicate/scripts/copy-sqlite-assets.mjspackages/replicate/scripts/test-native-bundle.cjspackages/replicate/scripts/test-offline-browser.mjspackages/replicate/scripts/verify-sqlite-provenance.mjspackages/replicate/src/client/bindings/counter.tspackages/replicate/src/client/bindings/set.tspackages/replicate/src/client/collection.tspackages/replicate/src/client/documents.tspackages/replicate/src/client/persistence/custom.tspackages/replicate/src/client/persistence/encrypted/web.tspackages/replicate/src/client/persistence/memory.tspackages/replicate/src/client/persistence/sqlite/preload.tspackages/replicate/src/client/persistence/sqlite/schema.tspackages/replicate/src/client/persistence/sqlite/web.tspackages/replicate/src/client/persistence/sqlite/worker.tspackages/replicate/src/client/persistence/types.tspackages/replicate/src/client/persistence/writes.tspackages/replicate/src/client/prose.tspackages/replicate/src/client/services/connection.tspackages/replicate/src/client/services/presence.tspackages/replicate/src/component/mutations.tspackages/replicate/src/component/schema.tspackages/replicate/src/server/index.tspackages/replicate/src/shared/index.tspackages/replicate/src/test/assets.test.tspackages/replicate/src/test/component.test.tspackages/replicate/src/test/discovery.test.tspackages/replicate/src/test/offline.test.tspackages/replicate/src/test/persistence-writes.test.tspackages/replicate/src/test/recovery.test.tspackages/replicate/src/test/server-functions.tspackages/replicate/test/browser/index.htmlpackages/replicate/test/browser/main.tspackages/replicate/test/native/index.jspackages/replicate/test/native/package.json
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
|
@coderabbitai review |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 87ed1d80-cb7c-4719-98f0-968a7dcc1265
📒 Files selected for processing (18)
.github/workflows/ci.ymlAGENTS.mdCHANGELOG.mdCLAUDE.mdREADME.mddocs/CDN.mddocs/tests.mdpackages/replicate/scripts/test-offline-browser.mjspackages/replicate/src/client/collection.tspackages/replicate/src/client/persistence/custom.tspackages/replicate/src/client/persistence/encrypted/web.tspackages/replicate/src/client/persistence/memory.tspackages/replicate/src/client/persistence/sqlite/native.tspackages/replicate/src/client/persistence/sqlite/schema.tspackages/replicate/src/client/persistence/sqlite/web.tspackages/replicate/src/client/persistence/sqlite/worker.tspackages/replicate/src/test/offline.test.tspackages/replicate/test/browser/main.ts
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
|
|
@coderabbitai review |
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: fcef9ed7-5982-4a9c-9cd5-8157d054cea2
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (16)
apps/sveltekit/package.jsondocs/CDN.mddocs/offline-replicas.mdpackage.jsonpackages/replicate/assets/wa-sqlite/PROVENANCE.mdpackages/replicate/assets/wa-sqlite/manifest.jsonpackages/replicate/package.jsonpackages/replicate/scripts/copy-sqlite-assets.mjspackages/replicate/scripts/test-native-bundle.cjspackages/replicate/scripts/test-offline-browser.mjspackages/replicate/scripts/test-packed-consumer.mjspackages/replicate/scripts/verify-sqlite-provenance.mjspackages/replicate/src/test/assets.test.tspackages/replicate/test/browser/baseline-wa-sqlite-manifest.jsonpackages/replicate/test/browser/main.tspackages/replicate/tsdown.config.ts
💤 Files with no reviewable changes (2)
- package.json
- apps/sveltekit/package.json
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
|
@coderabbitai review Addressed the three findings: the documentation now distinguishes the worker asset base from the complete service-worker precache graph and gives the hosted manifest path; the packed-consumer harness canonicalizes temporary paths while preserving cleanup. Three independent follow-up reviews also found and verified a local mutation acknowledgement race and the removed Node/SSR preload guard. These are fixed in 82ca43d, with regression tests; all three reviewers passed the new candidate. The PR description records the exact checks and a separately discovered, pre-existing compaction cleanup limitation. |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Restrict the R2 Worker to published assets. · CDN.md:119-120
docs/CDN.md:119-120
🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick winSensitive Data Exposure
Reachability: External
Exploitability: Moderate
CWE: CWE-200 — Exposure of Sensitive Information to an Unauthorized ActorRestrict the R2 Worker to published assets.
The setup creates a versioned prefix, but the Worker does not enforce it. The request pathname becomes the complete R2 key, so a mixed-use
RUNTIME_BUCKETcan expose any addressed non-public object. Require a dedicated public-assets bucket, or enforce and document an immutable published prefix.
🟡 Minor · Invoke the asset CLI through the package manager. · offline-replicas.md:93
docs/offline-replicas.md:93
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winInvoke the asset CLI through the package manager.
This command is shown as a direct shell command, but the package exposes it only as a local binary. Use
npm exec -- replicate-sqlite-assets public/replicate-sqlite,bunx, or a package script so the binary is available onPATH.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: b7876297-c140-4caa-a5f7-d7030faf6ee1
📒 Files selected for processing (7)
docs/CDN.mddocs/offline-replicas.mdpackages/replicate/scripts/test-packed-consumer.mjspackages/replicate/src/client/collection.tspackages/replicate/src/client/persistence/sqlite/preload.tspackages/replicate/src/test/assets.test.tspackages/replicate/src/test/offline.test.ts
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
|
@coderabbitai review Updated to All three independent reviews passed after the fix-and-repeat cycle. Current package suite: 126 tests; 10 real Chromium offline/process-restart checks; build/types/lint/publint and full Android Metro bundle passed. The PR body distinguishes prior evidence and the known upstream delta-cleanup limitation. Please review the new changes. |
|
✅ Action performedReview finished.
|
Closes #8.
Persisted collections could stay unready behind an unresolved recovery query, deleted records could return after reopening storage, and cursors/presence could overtake document persistence. Fresh clients could miss fully compacted records. A rejected writable delete also left its local tombstone in place; simply merging an older Yjs snapshot could not undo it.
This change separates local readiness from transport, makes local data durable before acknowledging progress, and discovers snapshots alongside deltas. Automatic writable behavior remains the default.
Behavior
networkMode: 'manual',readOnly, captured applicationrequestArgs, and awaitableconnect(),disconnect(), andreset(). Protocol fields are reserved, and stale transport completions cannot mutate a later generation.onInsert; legacy unmarked writable creations remain protected when the server has no history of their ID. Full-row updates remove omitted optional fields.assetBase. A checked asset-copy CLI provides the compatible JS/WASM graph and notices for self-hosting and precaching. The R2 example restricts a dedicated public-assets bucket to the declared immutable prefix.Runtime distribution
The exact original-author
rhashimoto/wa-sqlitearchive at07ad48cf2f682d279f9cd69818cc1d39b2ccda86replaces copied runtime source/binaries. The unofficial unscoped npm package has a different VFS API and is not substituted. Installation uses HTTPS without Git/SSH or compiler tooling; there are no additional runtime dependencies or install/build hooks in that archive.The CLI checks fixed per-file SHA-256 hashes and retains
LICENSE,ACKNOWLEDGMENTS.md, and provenance. The WASM reports SQLite 3.53.0. Manifest digests and loader/WASM revisions identify the distributed artifacts; this is not an independent reproduction of their compiler environment. npm records archive integrity; Bun 1.3.6 pins the full commit URL without a separate integrity digest.Installation adds about 15.4 MB of upstream repository files. The eight browser runtime files served total 1,492,236 bytes, about 2.7% above the earlier graph. GitHub access is needed for installation, not offline startup with locally precached assets. The historical CDN remains the default when
assetBaseis omitted. No browser or copied wa-sqlite implementation is added to production code.Compatibility and migration
This targets upstream
mainatf21c275126a51ab425c0223e1bec8a918d76a462and its v2 preview schema. Published 1.1.2 has a different component schema and is not a supported direct migration.Existing v2 collections must run bounded, idempotent
migrateSnapshotsthrough an internal administrative wrapper untildone. Each batch atomically republishes legacy snapshots above retained sequence evidence; interruption is resumable. Streaming pauses while legacy snapshots remain, so plan a synchronization maintenance window. Writes, scheduled compaction, local reads, and per-document recovery can continue.Old v2 clients understand the snapshot/numeric-cursor wire format after migration, although their local durability bugs remain. Legacy component code/compaction and schema rollback are unsupported. Cursors already corrupt above all retained evidence need cache recovery/reset; preserve unsent writable data first.
Direct third-party providers need the documented durable capabilities. Legacy encrypted IDs must be discoverable through the underlying adapter. Encryption protects payloads, while storage metadata, key names, and document-ID indexes remain visible. No application authorization policy is introduced.
See
docs/offline-replicas.md,docs/CDN.md, and the Unreleased changelog for setup and boundaries.Verification
Current code was tested in an isolated public checkout on Windows with Node 24.20.0, Bun 1.3.6, and locked Convex 1.31.6:
bun run test: 126 tests passed in 11 files. Windows sandbox loader restrictions required a source-equivalent ESM runner configuration; test setup, globs and assertions were unchanged, and the explicit Node environment restated the existing file directive. Actual collections and SQLite cover unresolved transport, raw disk close/reopen, deletion/recovery, failed/delayed persistence, cursor ordering/replay, reset/account fencing, read-only/writable behavior, request context and raw missing-dependency updates. Twelve new delete/repair regressions cover rollback persistence, abrupt restart then server-Y.Doc convergence, partial batch acceptance, concurrent fields, authoritative removal, older/newer repair acknowledgement races, and full-bytes/material consistency after an interleaved stream. They include a negative check that completes recovery after restart and verifies zero repair mutations until an explicit update.tsc --noEmit, required repositorylint:fix, and package lint passed. Source/assets and exports were unchanged by the following documentation-only commits.bun run test:browser: 10 real Chromium offline/process-restart checks passed with actual SQLite/WASM assets.node scripts/test-native-bundle.cjs: the full built Android client graph passed Expo Metro bundling, excluding the browser SQLite loader/VFS. This is not native-device execution.5be07ea15a6dc537b29c1fe5454c358464763a2c: cleanliness/maintainability, durability, and compaction/upgrade correctness. The fix-and-repeat cycle found and corrected both the rejected-delete causal-history gap and the content-sync material/bytes race. Reviewers independently inspected pinned source and raw evidence; Sol executed the requested fresh tests in separate worktrees. This was review-only, not an OS-enforced read-only sandbox.Additional preserved evidence has narrower applicability:
Selected regression tests failed as expected on untouched upstream for readiness, durable deletion, and compacted discovery. Browser execution covered Chromium on Windows; no actual Linux/macOS or native-device execution is claimed. No cloud deployment or package publication was performed.
Diff size
At
5be07ea, approximately 2.8k added lines (60% of additions) are tests and verification tooling.Counts are relative to the PR base. Tests include browser/native fixtures and verification scripts; Docs includes configuration, build metadata, and asset provenance.