Repository navigation
feat(browser): add BrowserDb async WASM façade with IndexedDB persistence - #149
Merged
Merged
Conversation
Synchronous in-memory StorageBackend implementation for WASM browser environments. Tracks written page IDs in a dirty set for subsequent flush to IndexedDB via take_dirty(). Includes load_pages/load_pages_all_dirty constructors and 10 passing unit tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds IndexedDbBackend with async open() and load_all_pages() backed by browser IndexedDB, plus the cfg-gates needed to make the whole crate compile cleanly under wasm32-unknown-unknown --features browser. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tructors Replaces the stub src/browser/mod.rs with BrowserDbInner/BrowserDb, open_in_memory() (pure buffer, no IDB), and open() (loads all pages from IndexedDB then wraps in PersistentFactStorage). Imports for DatalogExecutor and QueryResult are included ahead of Task 8. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…USE_TX_TIME pub(crate)
Implements the core execute() async method on BrowserDb, dispatching Datalog commands to query/rule (read) or transact/retract (write) paths, with dirty-page flushing to IndexedDB after writes. Also adds read_page_raw() on BrowserBufferBackend and with_backend/with_backend_mut closure accessors on PersistentFactStorage to safely access the inner Arc<Mutex<B>> without exposing raw lock guards. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add 5 wasm-bindgen-test integration tests in src/browser/mod.rs covering transact/query, empty query, export-import round-trip, page-alignment, and IndexedDB persistence across open/close cycles - Add wasm-bindgen-test = "0.3" as a wasm32-only dev-dependency; move criterion and tempfile to not(wasm32) dev-dependencies to prevent rayon/tempfile link errors when building for WASM - Gate file-backed test modules with #[cfg(all(test, not(target_arch = "wasm32")))] in persistent_facts.rs, wal.rs, db.rs, and backend/file.rs - Gate 5 file-backed integration test files with #![cfg(not(target_arch = "wasm32"))] - Fix tx_id_now() to use js_sys::Date::now() on wasm32+browser targets (std::time::SystemTime::now() panics in the browser WASM runtime) - Fix apply_write() missing pfs.mark_dirty() call before pfs.save(), which caused export_graph() to return empty/unheadered blobs and IDB persistence to silently drop written facts - Fix memory_profile.rs example and Minigraf doc example to compile on wasm32 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lence dead_code lint
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (28.57%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #149 +/- ##
=======================================
Coverage 83.41% 83.41%
=======================================
Files 26 26
Lines 4811 4837 +26
=======================================
+ Hits 4013 4035 +22
- Misses 798 802 +4
🚀 New features to boost your workflow:
|
wasm-pack's bundled wasm-opt does not honour the package.metadata wasm-opt flags, causing bulk-memory validation failure. Disable the bundled wasm-opt (wasm-opt = false) and instead install binaryen via apt in CI, then invoke wasm-opt manually with --enable-bulk-memory. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…imised The standalone binaryen 108 (Ubuntu Noble) rejects the WASM binary because it uses multiple non-MVP features (bulk-memory, mutable-globals, sign-ext, etc.) that all need individual --enable-* flags. Rather than enumerate every feature, skip post-build wasm-opt in CI; the build already succeeds with wasm-opt = false in Cargo.toml metadata, producing a correct if unoptimised binary. The size check is informational only. Correctness is validated by the headless browser test job. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #129
Summary
browsercargo feature compiling Minigraf forwasm32-unknown-unknownwith a newBrowserDbasync façade exposed viawasm-bindgenBrowserBufferBackend(syncHashMap-backedStorageBackend) absorbsPersistentFactStorage::save()writes;IndexedDbBackendflushes dirty pages to IndexedDB in a single batchedreadwritetransaction perexecute()callBrowserDb.open(dbName),BrowserDb.openInMemory(),execute(datalog),checkpoint(),exportGraph(),importGraph(bytes)— all returning Promises.graphblobs (MGRF magic, ascending page order); round-trip verified by integration testwasm-bindgen-testintegration tests run in headless Chrome and Firefox via new.github/workflows/wasm-browser.ymlCI matrixTest plan
cargo test— all 792 native tests passcargo check --target wasm32-unknown-unknown --features browser— cleancargo clippyandcargo clippy --target wasm32-unknown-unknown --features browser— cleancargo fmt --check— clean🤖 Generated with Claude Code