Repository navigation
feat(wasm): [Add WebAssembly browser support for ExtendDB - #1009
Conversation
There was a problem hiding this comment.
I reviewed this with the branch built for wasm32 and merged onto current main (c2e9a32, 1.0.0).
The native side holds up. On the merged tree, cargo fmt --check, cargo check --workspace --all-targets, CI's clippy command and the unit tests of every changed crate pass. The exceptions are the migration checksum test in item 1 and two write-lock tests. Those two fail on main as well on my host, because of how it maps file ownership.
The wasm side mostly matches. On a release build of the module under Node 22, the headless runner passes its 26 checks, and the corpus passes natively. I also sent 32 extra sets of requests to the wasm module and to the native adapter. 30 of them match. They cover GSIs, streams, transactions, batches, paging, the item size limit, the condition and update expression depth limits, and CreateTable with vector indexes.
Below is the complete list of what needs to change before this can land.
Required before merge
-
The branch needs a rebase onto 1.0.0, and three things break when I merge it.
- Version changes. Twelve commits move the workspace from 0.1.14 to 0.1.26. They change Cargo.toml and its 13 pins, Cargo.lock, packaging/npm/package.json, three docs literals and the four notices files. The npm manifest then names 0.1.26 packages that do not exist on npm. main is 1.0.0 with rust-version 1.91.1, so each of these changes goes. Starting from main's Cargo.lock, cargo adds the same new and changed packages as this PR's lock, so the lock regenerates cleanly.
- Frozen migrations.
the_released_bodies_match_their_checksumsfails for SQLite migrations 1, 3, 4, 6 and 9 with "the body changed after release". Each frozen checksum covers the whole source file (SOURCEisinclude_str!of the file itself), and the PR appends the 6-line alias block to each file. Item 6 removes the need for those lines, and the five files then stay byte-identical to main. Fivereblessentries also make the test pass, if you prefer to keep the edits. - The wasm build fails after the merge, in two crates. In
extenddb-storage, #1003 added two aws-lc-rs calls with no wasm branch:key_ring.rs:121-122(the key id HMAC) andserver_components.rs:136(the constant-time KEK compare). Inextenddb-storage-sqlite, #1003's newmanagement_store/secret_rows.rshas no shim alias. With the alias added, it still fails at line 219, because the shim'sSqlitePool::acquirereturns a bareSqliteConnectionwhere sqlx returnsPoolConnection<Sqlite>.
I fixed both build failures locally to measure the size of the change. It is about 50 lines:
hmacandsubtleon wasm, and aPoolConnectionnewtype in the shim. The wasm build then passes. I'd rather not add more cfg branches at each call site. Instead, one crypto module could hold the only wasm cfg, withsha256,hmac_sha256,constant_time_eq,seal,openand a random fill.secret_cipher,signing_key,verify,canonical,key_ringandserver_componentsthen call it. The call-site pattern broke within a week of this PR's base. -
The demo puts AWS secret keys in the page URL.
?backend=awsreadsaccessKeyId,secretAccessKeyandsessionTokenfrom the query string (rawQueryParamin backend.js), and SMOKE-TEST.md tells the user to open such a URL. The URL then lands in browser history and sync, and in the static server's log: with a fake key,python3 -m http.serverlogged the whole query string. The documented command,python3 -m http.server 8000with no--bind, also listens on every interface. On the remote headless host of SMOKE-TEST section 0a, that exposes the page beyond the SSH tunnel.The same path has two more problems:
- The CORS proxy recipe sends
Access-Control-Allow-Origin: *and forwards to a local dev server. That server's seeded example key is public, so any page the user has open can drive the server through the proxy. The recipe also cannot work as written: the page signshost: localhost:8000and path/ddb, and the proxy sends another host and/. ensureSchema()treatsResourceInUseExceptionas success. On an AWS account, the demo then adopts existing tables named Products, Account, Cart and Orders, and "Populate initial catalog" overwrites items in them.
Please remove the
awsbackend from the sample. If it stays:- take the credentials from a password field, held in memory only, and recommend short-lived credentials
- prefix the table names, and refuse a table the demo did not create
- document the cost and the DeleteTable cleanup
Use
--bind 127.0.0.1in every server command, and remove the proxy recipe. - The CORS proxy recipe sends
-
No CI job builds, lints or runs the wasm target.
The PR changes nothing under
.github/. Item 1 shows the cost: one week of main broke the wasm build twice, and no check went red. Open #1087 would break it again. It registers a SQLite function throughlibsqlite3_sysinsqlite_util.rs, which is one of the shim files, and it conflicts with this branch only in a notices file.The shim has no tests of its own. Every storage-sqlite test runs natively against sqlx, so none of them executes the shim.
Please add a job that:
- installs clang and the wasm32 target
- runs the reachability lint
- builds
-p extenddb-wasm-adapter --target wasm32-unknown-unknown --locked - generates the module with wasm-bindgen and runs the headless runner over the corpus
- runs clippy for wasm32 with
-D warnings
Add a table-driven test of the shim's decode, bind and transaction rules that runs on wasm in that job, with wasm-bindgen-test under Node.
-
Two requests crash the wasm module, and the instance stays broken. I measured both on a release build under Node.
- UpdateTable with
VectorIndexUpdates[].Createpanics with "time not implemented on this platform".update_table.rs:911callstokio::time::Instant::now()and:942callstokio::spawn, with no wasm cfg. Thesubmitpromise never settles. Afterwards the instance still answers reads, but every PutItem, UpdateItem, CreateTable and DeleteTable hangs. CreateTable withVectorIndexesworks. - A PartiQL statement with 1,000 nested parentheses around a 100-deep nested call (2,631 characters) traps the module with
RuntimeError: memory access out of bounds, and its promise never settles. So does one with 1,000 nested parentheses around a 1,000-deep list literal (4,031 characters). In both cases, the next request on the instance fails with the same error. Each kind of nesting alone stays within the 1 MiB stack. The caps hold for one kind at a time, but not for two kinds combined. Natively, the parser moves a deep parse to a thread with a large stack (limits.rs). The wasm branch keeps the full caps on the module's own stack.
Please refuse vector index creation through UpdateTable on wasm, with a ValidationException, before the catalog write. For PartiQL, either lower the three caps on wasm to a budget that fits, or set a larger stack (
-C link-arg=-zstack-size=...next to the getrandom flag in.cargo/config.toml). Addtokio::timeandtokio::spawnto the lint's patterns, and add both cases to the corpus.wasm.rs says the promise "rejects only on an adapter fault". With
panic = "abort", a trap leaves the promise pending, so please document that a trap needs a page reload. - UpdateTable with
-
The shim decodes differently from sqlx-sqlite 0.8.6, so passing native tests do not cover the wasm path.
These differences come from comparing the shim with the sqlx sources:
- Type checks. sqlx refuses a value whose storage class does not match: String takes only TEXT, i64 and i32 only INTEGER, and f64 only REAL. The shim accepts INTEGER, REAL and BLOB into String, truncates REAL into integers, parses TEXT into integers and bool, and accepts INTEGER into f64 (
wasm_sqlx.rs:778-844). - NULL into a non-Option type. sqlx decodes
"", 0, false, 0.0 or an empty Vec, and the shim returns an error. A NaN f64 binds as NULL on both, so a metrics row that holds NaN reads 0.0 natively and fails on wasm (catalog_store.rs:146-149). - Invalid UTF-8 in TEXT fails in sqlx, and the shim turns it into U+FFFD. For duplicate column names, sqlx keeps the last one and the shim keeps the first.
- SQL with several statements. sqlx runs all of them. The shim passes no tail pointer to
sqlite3_prepare_v2(:924), so it runs the first statement and reports success. - More arguments than placeholders fail with SQLITE_RANGE in the shim. A nested
begin()sends a secondBEGIN, where sqlx creates a SAVEPOINT. fetchandfetch_optionalread every row before they return, so on wasm the shim loads the whole partition thatvector_search.rsstreams.- The pool hands the same
Arc<RawConn>to every caller, so a pool statement issued during an open transaction runs inside that transaction. Nothing reaches that today, because no shim call returns Pending. A flag for an open transaction that makes such a statement fail would enforce it. unsafe impl SendandSyncforRawConnrely on wasm having no threads. Please gate them onnot(target_feature = "atomics").- The two SQLite builds differ too: 3.54.1 in sqlite-wasm-rs and 3.46.0 in libsqlite3-sys, with different compile flags. Results whose order comes from the query planner can differ.
Please match sqlx's rules, or list each remaining difference in the shim's module doc. Then cover them in the test from item 3.
- Type checks. sqlx refuses a value whose storage class does not match: String takes only TEXT, i64 and i32 only INTEGER, and f64 only REAL. The shim accepts INTEGER, REAL and BLOB into String, truncates REAL into integers, parses TEXT into integers and bool, and accepts INTEGER into f64 (
-
The PR adds several second copies of existing code. Please remove each one, or give its reason in the description.
- The same 6-line alias block is in 44 files. Cargo refuses one dependency key that names a different package per target ("Dependency 'sqlx' has different source paths depending on the build target"). It accepts the shim as its own
publish = falsecrate under[target.'cfg(target_arch = "wasm32")'.dependencies], with one line in lib.rs:#[cfg(target_arch = "wasm32")] extern crate <shim> as sqlx;. I checked both forms in a scratch workspace, natively and for wasm32. The second form removes about 260 lines and the five frozen-file edits. - Five structs keep their field lists twice: once in the derive and once in a hand-written wasm
FromRow(table_helpers.rs,catalog_store.rs,backup_catalog.rs). A new column then compiles natively and breaks only the wasm build. wasm_support::database_fileis a second parser besideserve_lock::database_file, andnew_in_memoryrepeats the INSERT ofbootstrap_dev_rowsand the steps of the migration helper.backup_wasm.rscopies ten handler signatures andBackupRuntime::new.- The adapter copies the server's error body and its SerializationException parse (
response.rs,handler.rs).POC_MAX_ITEM_SIZE_BYTESisDEFAULT_MAX_ITEM_SIZE_BYTESunder another name. - 13 of the 16 tests in
runtime.rsrepeat corpus cases. Please keep those cases only in the corpus table. - The JS SigV4 signer is a second signer beside
packaging/npm/test/launcher.test.js. Web Crypto is a reason, so please say so in the description.
- The same 6-line alias block is in 44 files. Cargo refuses one dependency key that names a different package per target ("Dependency 'sqlx' has different source paths depending on the build target"). It accepts the shim as its own
-
Two groups of requests get the wrong error in the browser build.
-
Backup, PITR, ImportTable and ExportTableToPointInTime answer
InternalServerError. That is an HTTP 500, which AWS SDKs retry. Natively, with no backup store:- CreateBackup writes an in-catalog backup
- ListBackups answers an empty list
- DescribeContinuousBackups reports point-in-time recovery as DISABLED
- UpdateContinuousBackups answers ContinuousBackupsUnavailableException
- ImportTable and ExportTableToPointInTime answer a ValidationException that says import or export is disabled
Please remove
backup_wasm.rsand gate the ten dispatch arms. Return the existing answers above, and a ValidationException that names the WebAssembly build for the backup operations. -
ExecuteStatement, BatchExecuteStatement and ExecuteTransaction answer AccessDeniedException ("Not authorized to perform this action"), because
item_authorizeris None. Please either install the developer-mode item authorizer, or refuse them with a ValidationException that names the reason.
-
-
The docs say nothing about the browser build.
README.md, docs/versioning.md and AGENTS.md do not mention the browser build or the new crate. AGENTS.md still calls
samples/"Example Python applications".Please add a README section that names the browser build Experimental and outside the versioning policy and support. List:
- What it does not do: authentication and authorization (every request runs as account 000000000000), storage beyond memory, and background work. Without background workers:
- TTL never removes an expired item (an item three days past its TTL is still returned)
- ItemCount and TableSizeBytes stay 0, also after 5,000 puts
- stream records are never trimmed
- What it refuses, with each error: the operations in item 7, and vector index creation through UpdateTable.
- The build prerequisites. sqlite-wasm-rs compiles SQLite with clang, so the build needs a clang that targets wasm32. Without one, the build stops in that crate's build script.
Add the crate to the project trees in README.md, AGENTS.md and the architecture guide. Add the WebAssembly build and
extenddb-wasm-adapterunder "Not covered" in docs/versioning.md. - What it does not do: authentication and authorization (every request runs as account 000000000000), storage beyond memory, and background work. Without background workers:
-
Several statements in the description and the comments do not match the code.
-
"the SigV4 auth model is unchanged": the browser build verifies no signature and runs no authorization. A runtime.rs comment says the POC runs "in developer mode with authentication skipped", but the server's developer mode still verifies SigV4 (
request_helpers.rs:291-304). -
"No engine behavior is reimplemented" and "The SQL and all crate logic are verbatim": the PR reimplements the sqlx surface. It also stubs backup, import and the snapshot engine.
-
"5144 passed": the head's
run-tests (stable)log sums to 5,213 passed and 98 ignored. -
"responses match case-for-case": the corpus has 24 cases. 12 of them carry 15 checks, 7 check only the error name, and 5 check nothing. It has no index, stream, transaction, batch, paging, TTL, PartiQL or UpdateTable case.
-
"no C sysroot" is true, but the build needs a C compiler (item 8).
-
The clippy box is not ticked, and its comment asks reviewers to look. With
-W clippy::pedantic, the adapter has 29 warnings on wasm32 and 46doc_markdownwarnings natively. For wasm32,--all-targetsdoes not build, because the tokio dev-dependency inherits the workspace'sfullfeatures and pulls in mio. Scoping that dev-dependency to native fixes the build. -
The code comments cite records that are not in the repository:
discussions/2026-11-15-P2-02-sqlite-in-wasm-2b.md, in 47 places (discussions/is git-ignored)project-overview.md,platform-facts.mdandtesting.md- plan labels such as B2′, D-DIV-1, P3-D1, D-P3-12 and Assumption A1
Please keep the technical sentence of each comment and drop the reference.
-
The doc comment of
create_table_with_taken_name_is_resource_in_usesays the case flows through the shim'sis_unique_violation. That function is insqlite_util.rs, and the test runs only natively. -
The lib.rs comment for
wasm_supportmentions "the backup pool-sizing formulae", which the module does not contain. -
The crate description still says "with an in-memory storage stub".
-
-
The next release would publish
extenddb-wasm-adapteras a 15th crate.The crate has no
publish = false, anddevtools/publish-crates --list-packageslists it. ADR 0029 says every release publishes the 14 crates. A new crate stops the crates.io run until a maintainer publishes it with an API token and sets its owners and its trusted publisher. Please addpublish = false, unless you want the crate on crates.io and amend ADR 0029.
Smaller fixes
- Cargo unifies the adapter's
features = ["memory"]on storage-sqlite into every workspace-wide build, where it changesSqliteConfig::default().pathto:memory:.new_in_memorypasses:memory:itself, so the adapter does not need the feature. new_in_memoryis a new public API, compiled on native, in a crate that is on crates.io. Please mark it#[doc(hidden)]or put it behind a feature.- The wasm crypto branches run in no test, and secret_cipher.rs says that its native fixtures "are the proof". The
zeroizefeature ofaes-gcmis off, so on wasm nothing wipes the expanded AES key. Please enable it. devtools/run-tests: a failed--wasmbuild does not fail a run that also requests other suites, and line 452 overwrites the--headlessresult.- The lint matches text. Because of it, the PR changed
std::timetoweb_timein 10 files that never compile for wasm. Please revert those changes. The lint also missestokio::timeandtokio::spawn, and after the rebase it will flag main'scredential_cache/entry.rs:8.disallowed-methodsin a clippy.toml does the same check with type resolution. - On wasm,
last_errnofrom #1003 (secmem/platform.rs:70) is dead code, which fails a-D warningsbuild. Gate it onany(unix, windows). - The JS signer:
- nothing runs
sigv4SelfTest(), and the headless runner could call it - the canonical query string is always empty, and the path is not URI-encoded
- the secret stays reachable at
window.extenddb.backend._inner._cfg
- nothing runs
- With an empty or comment-only SQL string, the shim returns the connection's last error instead of an empty result.
- The sample's docs describe the author's setup. README.md:112, SMOKE-TEST.md:39 and :220, and sigv4.js:25 say that "the dev host" has no browser or no JS runtime. SMOKE-TEST.md:43 names the root
extenddb-webasm, and :81 adds anmwinitstep. Please write these steps for any reader's host. samples/webasm-storefront/pkg/is not git-ignored.
Optional
- A
RUSTFLAGSvariable in the environment replaces the wasm32 rustflags in.cargo/config.toml, and getrandom then stops the build.run-tests --wasmcould pass the flags with--config. - The regenerated lock moves four Windows-only edges (errno, rustix, tempfile, winapi-util) from main's windows-sys versions to 0.61.2. If #1088 set them on purpose, keep main's.
- The README's module sizes assume wasm-opt. Without wasm-opt, the release module is 8.5 MB from cargo and 7.8 MB after wasm-bindgen.
- A published module would need its own notices file. about.toml lists only the two Linux targets. sqlite-wasm-rs also compiles a musl libc subset and an MIT printf into the module, and its LICENSE file covers neither.
This branch shares files with 71 other open PRs, and 9 of them conflict with it in files that carry the alias block.
|
Thanks for the thorough review — it was built onto 1.0.0 and fuzzed against the Required1. Rebase onto 1.0.0; the three merge breakages.
2. The demo put AWS keys in the page URL. The storefront sample is removed 3. No CI job for wasm; the shim has no tests. Added 4. Two requests crash the module.
5. The shim decodes differently from sqlx-sqlite 0.8.6. The shim now matches
6. Second copies. Removed, or the reason given:
7. Wrong errors in the browser build. The adapter now answers these, the
8. Docs. A new README "Experimental: WebAssembly build" section marks the 9. Statements that did not match the code. The description and comments are
10. The 15th crate. Smaller fixes
Optional
|
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks for the rework. I reviewed 114d444 for wasm32 and natively, alone and merged onto main (ca768ed). All 62 checks on the head are green.
The native side holds up. On the merged tree, cargo fmt --check, both of CI's clippy commands and the migration checksum test pass. The unit tests of the eight changed crates pass, except 9 tests. Those 9 fail on main as well on my host, because of how it maps file ownership.
Every step of wasm.yml passes locally, at the head and on the merged tree, and the corpus reports "RESULT: PASS (77 cases, 71 checks)". In CI, the wasm job started with no cache and passed in 8 m 35 s. Beyond the corpus, a 23-step sequence with vector search, a GSI created on a table with items, TTL and streams matched the native adapter. 400 requests submitted at once answered with no error, and the two counters they updated read 100.
Items 1 and 2 are resolved, and so is the 15th crate of item 10. The workspace stays at 1.0.0 with rust-version 1.91.1. Starting from main's Cargo.lock, cargo writes the head's lock. SQLite migrations 1, 3, 4, 6 and 9 are byte-identical to main. Of the crates in the wasm build, only crates/core/src/crypto.rs uses aws-lc-rs. The sample is gone. The adapter is publish = false, and devtools/publish-crates --list-packages lists 14 crates.
Both crashes of item 4 are fixed. UpdateTable with VectorIndexUpdates[].Create gets a ValidationException, and PutItem, UpdateItem, CreateTable, DeleteTable and GetItem then answer on the same instance. Both PartiQL statements get a ValidationException before the parser runs, and the next request answers.
The shim's decode rules now match sqlx-sqlite 0.8.6. From item 6, the alias block is one line in lib.rs, and sqlite_row_struct! holds each field list once. The server and the adapter build the error body through extenddb_core::error, and POC_MAX_ITEM_SIZE_BYTES is gone. Of the smaller fixes, the memory feature, #[doc(hidden)] on new_in_memory, the last_errno gate and the empty-SQL result are done.
Below is what still needs to change, under the item numbers of my first review.
Required before merge
-
The
wasmjob lints 2 of the 7 workspace crates it builds, and the shim test is not table-driven.- Both clippy steps use
--no-deps(wasm.yml:125 and :130). With thelast_errnogate removed, the build step only warns, and both clippy steps pass.cargo clippy --locked -p extenddb-wasm-adapter --lib --target wasm32-unknown-unknown -- -D warningslints all seven crates. It fails on that change and passes at the head. Please add it as a step. crates/storage-sqlite/tests/wasm_shim.rshas one function per rule, and it binds only an i64, a&strand a NaN f64. Please make it one table of stored value, Rust type and expected value or error, with one test. It needs rows for REAL into i64 and i32, TEXT into bool, REAL and BLOB into String, and NULL into i32 andVec<u8>. It also needs a row for each bind and transaction rule in item 5. The comment at :136-137 describes a String read that the test does not make.- The workflow comment (wasm.yml:12-15) and your reply call
wasma required check. main requires test, fmt, clippy, integration, mongodb-integration, notices-current and cassandra-integration. Until a maintainer addswasm, please say that it must become a required check.
- Both clippy steps use
-
The lint, the corpus and the trap text still need changes.
- Of
tokio::time, the lint matches onlytokio::time::Instant::now(devtools/wasm-reachability-lint.py:57-65). The wasm build enables tokio'stimefeature, so the othertokio::timecalls compile and trap. I addedtokio::time::sleeptohandle_get_item. The lint printed OK, GetItem then panicked with "time not implemented on this platform", and its promise did not settle within 10 s. - With
tokio::time::as the pattern, the lint finds six calls in wasm-compiled files:crates/storage/src/backup_catalog.rs:984,:1674and:1713, andcrates/storage/src/vector_lifecycle/build.rs:146,:169and:185. The adapter reaches none of them today. - Four allowlist entries (:77-90) exempt files with no hit:
storage-sqlite/src/store.rs,storage-sqlite/src/data/vector_index.rs,storage/src/hooks.rsandcore/src/backup_format/data_file.rs. Withstd::time::Instant::now()added to store.rs, the lint printed OK andExtendDb.create()panicked. - The limits.rs entry says that the wasm build omits the parser.
cargo tree -e featuresshows core'spartiqlfeature on in the wasm build.
Please match the
tokio::time::prefix,use tokio::timeimports andstd::thread::sleep, and remove the four entries.disallowed-methodsin a clippy.toml for the wasm steps resolves paths, so it also catches a clock that an import brings in.The corpus has a PutItem and a GetItem after the UpdateTable refusal. In my first review, UpdateItem, CreateTable and DeleteTable hung after the panic. They answer now, so please add them to the corpus as well. Your reply says the corpus has a DeleteTable case, and it has none.
wasm.rs:60-65 says the promise "rejects only if the module traps", then that it stays pending. wasm.rs and README.md:347-349 both say that every later call traps. After the GetItem panic above, the next PutItem and DescribeTable on the instance answered. In my first review, the next request after the PartiQL trap failed. Please say that the promise stays pending, the instance is then in an undefined state, and the page must be reloaded.
- Of
-
The module doc misstates sqlx's bind rules, and the shim differs from sqlx in ways the doc does not list.
- wasm_sqlx.rs:73-75 and :1081 say that extra arguments fail with a range error "as it does under
sqlx". sqlx-sqlite 0.8.6 binds only placeholders1..=cnt(arguments.rs:84). Under sqlx the query succeeds, and the shim fails it. - In SQL with several statements, sqlx carries an argument offset from one statement to the next (connection/execute.rs:86-87).
bind_allbinds the whole list into each statement that has a placeholder. - sqlx adds up
sqlite3_changesafter each statement. The shim reads it once, after the last statement (query_result, :1229-1240). So two INSERTs in one string report 1. After a write, empty SQL reports the count of that write, where sqlx reports 0. SqlitePool::acquire()(:360-365 and :405-412) returns the shared connection without the open-transaction check. A statement on that connection runs inside the open transaction. Your reply says such a statement fails.
Please bind and count like sqlx: a running offset, placeholders
1..=sqlite3_bind_parameter_countfor each statement, the changes added up per statement, and 0 when no statement runs. Otherwise, list each difference correctly. Please also makeacquire()fail while a transaction is open. - wasm_sqlx.rs:73-75 and :1081 say that extra arguments fail with a range error "as it does under
-
These second copies remain. The adapter's copy of the engine's no-store answers is in item 7.
serve_lock_wasm.rs:32-44is a seconddatabase_fileparser besideserve_lock.rs. Your reply saysserve_lock::database_fileis the only one. The wasm build opens only:memory:, so its version can accept that location and refuse every other.new_in_memory(store.rs:520-566) runs its own copy of the account INSERT ofbootstrap_dev_rows(store.rs:300, again at :541). It also repeats the migration steps of lib.rs:397-405. The description and your reply say it reuses both.- runtime.rs:462-712 holds 8 tests that repeat corpus cases: every test from
create_backup_is_unsupportedon, exceptupdate_table_without_a_vector_create_is_not_refused. Please keep those cases in the corpus only. The malformed-body check ofexecute_statement_is_unsupportedcan become a corpus case withrawBody.
-
Well-formed requests now get the native answers. Malformed requests do not, because
no_store_answer(runtime.rs:296-319) skips the checks of the engine's handlers. Of 100 requests to these operations, 13 got another answer on wasm than natively. Examples:DescribeContinuousBackupswith{}gets the DISABLED description on wasm. Natively it gets "The parameter 'TableName' is required but was not present in the request".ListBackupswith{"Limit":0}gets an empty list on wasm. Natively it gets "1 validation error detected: Value '0' at 'limit' failed to satisfy constraint: Member must have value greater than or equal to 1".UpdateContinuousBackupsthat enables recovery on a missing table gets ContinuousBackupsUnavailableException on wasm, and TableNotFoundException natively. The README covers only the request that disables recovery.
no_store_answerand its helpers are also copies of engine code.point_in_time_recovery_enabledandmember_nullare pitr.rs:224-237 and :127-132.continuous_backups_disabled_documentrestatesdefault_continuous_backups_description(pitr.rs:179-188). The messages arePITR_UNSUPPORTED_MESSAGE(pitr.rs:54) and import_export.rs:48 and :288. A change to one of these engine answers would leave the wasm build on the old one.The description says these operations are not answered "by a copy of the handlers". runtime.rs:33-36 and :276-279 call the answer "identical", and README.md:334-345 says "that same answer".
The continuous-backups handlers (pitr.rs:287-321) read only the request, the limits and the table. The ListBackups argument checks (backup.rs:898-943) and the import and export checks read no store. Please compile that code on both targets and use it on wasm in place of the copies. Then add the requests above to the corpus. If a difference remains, list it in the README and in runtime.rs.
-
The README section, the AGENTS.md tree and docs/versioning.md are in. The architecture guide still says "a Cargo workspace with 13 crates" and has no
wasm-adapter/(docs/manuals/01-architecture-guide.md:17-36). Please add the crate and change the count to 15. README.md:382 says "see below" for the section above it. -
The statements from my first review are fixed. These new ones do not match the code:
- The description says
cargo clippy --target wasm32-unknown-unknown --all-targetsbuilds. It exits 101 witherror[E0433]: cannot find module or crate tokio in this scopein test "parity".#![cfg(not(target_arch = "wasm32"))]at the top of tests/parity.rs makes it pass. - .cargo/config.toml:14-19, wasm.yml:17-21, devtools/run-tests:376-381 and README.md:361-363 say that the build needs the getrandom cfg. getrandom 0.3.4 selects the
wasm_jsbackend from the crate feature that core enables (backends.rs:188-192). With the config section removed and no RUSTFLAGS, the wasm build, the 4 crypto tests and the corpus pass. Please remove the cfg, the six stepRUSTFLAGSandWASM_RUSTFLAGS, or fix the comments. My point about an ambient RUSTFLAGS then no longer applies. - wasm.yml:80-84 says the apt step pins clang and lld. It installs unversioned packages, and rustc links wasm32 with its own rust-lld, so lld is not needed.
- crates/wasm-adapter/src/lib.rs:19-24 says the stream and tagging operations answer end to end. The corpus has no tagging case, and ListStreams is its only stream case.
- tests/parity.rs:11-14 says agreement makes the wasm build "faithful". The two runners check the same assertions, and neither compares the responses of the two builds.
- The checklist ticks the ADR box, and the line under it says "ADR / RFC: n/a".
- The description says
-
The adapter's direct engine dependency (crates/wasm-adapter/Cargo.toml:37) adds a 14th
=1.0.0pin outside the root manifest. ADR 0029:109 and packaging/README.md:108-109 bump only the 13 root pins. After such a bump, every cargo command fails with "failed to select a version for the requirementextenddb-engine = "=1.0.0"".The version cannot go on its own. With a path-only dependency, the
packagejob'scargo package --workspace --no-verify --lockedstops with "all dependencies must have a version requirement specified when packaging". Please keep the pin and add it to the bump step in both documents. The other way is to drop the version and exclude the adapter from eachcargo package --workspacecommand.
Smaller fixes
- core/Cargo.toml:48-52 enables aes-gcm's
zeroize, which wipes only the temporary GHASH key (aes-gcm 0.10.3 lib.rs:239-240). aes 0.8.4 and polyval 0.6.2 wipe the AES round keys and the POLYVAL key only under their ownzeroizefeatures.cargo tree -e featuresshows neither on. Please addaesandpolyvalwithfeatures = ["zeroize"]to core's wasm32 dependencies, or fix the comment at line 48. devtools/run-tests --wasm --headlessand--wasm --wasm-testexit 0 when the--wasmsuite fails. The "only remaining suite" branches (:466-471 and :564-569) exit with their own status and ignore thePASS=falseof an earlier suite. Your reply says a failed--wasmfails the run. Line 546 also puts$CARGO_HOME/binbefore the caller's PATH, so this suite can run another cargo.- The wasm test
opens_native_sealed_value(crypto.rs:398-401) says an AWS-LC backend sealed its value. It is the aes-gcm 0.10.3 vector (crypto.rs:330-332), so no test opens a value sealed by AWS-LC on wasm. The four wasm tests also repeat native tests. Please run one set on both targets withcfg_attr, and add a vector sealed by AWS-LC. - wasm_sqlx.rs:11-13 and :24 allow
unknown_lintsfor the whole module, forclippy::unused_async_trait_impl, which clippy 1.97.0 does not have. That allow also accepts a misspelled lint name anywhere in the module. Please drop both until the pinned toolchain has the lint. - On wasm,
sqlite_row_struct!ignores#[sqlx(...)]field attributes. None of the five structs uses one today. The macro could refuse them, or its doc could say so. - signing_key.rs:21-22 still mentions
hmac::sign, which the file no longer calls.
Your reply says the four Windows-only lock edges keep main's windows-sys versions. The lock moves all four to 0.61.2. That is fine, because #1088 moved them only as a side effect.
These were already in the head of my first review, and I didn't raise them then, so they don't hold this PR:
- DescribeEndpoints answers
localhost:8000(runtime.rs:65), the port of the removed demo. - storage-sqlite's lib.rs:30 allows
dead_codeandunused_importsfor the whole crate on wasm. So the wasm clippy can't report dead code in the shim, which compiles only for wasm. - NULL decodes into
serde_json::Value::Null, where sqlx returns a parse error. SqliteDbErrorprints only the message, and sqlx prints the code as well.- The wasm build adds back to Cargo.lock the eight crates that ADR 0026 removed. An amendment to ADR 0026 could record the wasm32 exception.
|
Thanks for the second review. Each item, with the commit and the test that covers it. Where I 3. wasm job and shim test
4. Lint, corpus and trap text
5. Shim bind and count rules (
6. Second copies
7. Native answers for the no-store operations
8. Docs: the architecture guide lists 9. Statements
10. Engine pin: I took a third way. The root Smaller fixes
The items you said do not hold the PR: DescribeEndpoints is now refused by name Changes you did not ask for
|
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks for the reply and the rework. I reviewed c5f9a66 natively and for wasm32, alone and merged onto main (44cd436). CI is green on all 62 checks.
The native side holds up. fmt, both of CI's clippy commands and the tests of the eight changed crates pass on the merged tree. The exceptions are nine tests that also fail on main on my host, because of how it maps file ownership, and the shim table below. I sent the same 225 requests to release SQLite servers built from main and from this head. They cover unsigned and badly signed requests, unparseable bodies, bad names and ARNs, the point-in-time, import and export requests, and the item 7 set. None of the answers differ once timestamps and ids are masked, and the server logs match line for line. parse_request and admit keep main's order, with authentication before the point-in-time refusal, and the same messages, log line and metrics.
Every step of wasm.yml passes through devtools/run-wasm-step, at the head and on the merged tree. The corpus reports "RESULT: PASS (272 cases, 332 corpus checks, 8 checks of submit's JavaScript boundary)". In CI the wasm job passed from a cold cache in about 8 minutes.
Items 3 to 10 and the smaller fixes are resolved, apart from what's below. A few of the results:
- The clippy step refuses
tokio::time::sleepinhandle_get_itemandstd::time::Instant::now()instore.rs. It also refuses a renameduse tokio::time as t, astd::thread::spawnand a function pointer toInstant::now. The reasons on the 18 allow sites hold. - Of 126 requests to the no-store operations, most of them malformed, 116 answer the same on wasm and natively. The other 10 go to the four store-backed backup operations that the README lists. Signed, an UpdateContinuousBackups that enables recovery on a missing table gets ContinuousBackupsUnavailableException at the head and at main.
- The shim binds, counts and locks as sqlx-sqlite 0.8.6 does, and no path the wasm build reaches acquires the connection while it holds a transaction.
- The moved engine and storage-sqlite code keeps its bodies, and the pitr files are plain renames.
- With the 13 root pins bumped to 1.0.1,
cargo metadata,cargo package --workspace --no-verify --lockedanddevtools/check-crate-packagespass. No native build loses an engine feature. submitanswers a non-stringoperationorbodywith a ValidationException. ALimitabove u32::MAX returns every stream and shard on wasm32, as it does natively.
Before it merges:
-
The corpus rules are written twice.
tests/parity.rsandparity/run.mjseach implement the case schema, the request encoding and the judge.judge,read_case,read_corpus,canonical_json,substitute,request_text,json_equal,check_numbersand the rest each exist in Rust and in JavaScript. run.mjs adds a 150-line JSON parser so that it reads numbers as serde_json does.runner-selftest.json(2,385 lines) exists to keep the two judges giving the same outcomes. Since round 2 the runners grew from 125 and 136 lines to 738 and 779.tests/wasm_shim.rsalready runs one Rust table on both targets, withwasm_bindgen_teston wasm32 andtokio::testnatively. Please runtests/parity.rson wasm32 the same way. run.mjs then needs only what has to be JavaScript:createand the eight checks ofsubmit's boundary.parseJson, the JavaScript copies of the rules andrunner-selftest.jsoncan go. If a second judge has to stay, please say why in the description. -
The shim table fails natively under load.
pool_options(wasm_shim.rs:174-176) gives every row's pool a 50 ms acquire timeout, andconnect_withhas to open its first connection within it. I ran it atnice 19on my host, with the load at 25 to 38 on 16 cores. A full test run failed 1 row at the head and 19 on the merged tree. Each failed with "setup failed: Err[PoolTimedOut]". Run alone, the test passed 0 of 20 times atnice 19and 18 of 20 at normal priority. It runs in the requiredtestjob, so a slow runner would fail an unrelated PR. Please give the rows' pools sqlx's default timeout, and keep 50 ms for the three rows that expectPoolTimedOut(:792, :809 and :855). -
raw_sqlandExecutor::executenow refuse:name,@name,$nameand$0placeholders.bind_all(wasm_sqlx.rs:1179-1236) refuses them before it compares the position with the argument count, andrun_execandRawSql::executepass no arguments. sqlx-core 0.8.6 givesraw_sqland a&strno arguments, and sqlx-sqlite binds only when there are some. So under sqlx,raw_sql("SELECT :x")runs with the placeholder NULL. e3afecb added the refusal, and at 114d444 those calls bound nothing. No backend SQL has such a placeholder today. Please skip the binding when a call has no arguments and add araw_sqlrow. Or list it with the other differences and give it a row.
Optional:
- The
zeroizefeatures of aes and polyval are checked twice, by the assertion incrypto.rs:201-208and by the guard step'scargo treecheck. One would do. - The test at
runtime.rs:308repeats the newparse_requesttest inpre_dispatch.rs:96.
These were already in the head of my last review, and I didn't raise them then, so they don't hold this PR:
- The shim's
fetchreads the whole result before it yields. So SearchVectors, which streams to bound its memory, holds the partition in memory on wasm32. - When a query has a row that doesn't decode and a later database error, the shim's
fetch_allreturns the database error. sqlx returns the decode error.
The wasm32 build cannot run a vector index backfill: it is a detached tokio task timed by tokio's clock, and that build runs no tokio runtime. build_vector_index carried a wasm32 arm that returned StorageError::Internal after the catalog commit. The engine maps Internal to InternalServerError (HTTP 500), and by then the request's other changes had committed: a global secondary index created in the same request stayed, and so did a DeletionProtectionEnabled change. Only the vector index's own catalog row was removed again. update_table_impl now refuses a request that creates a vector index on wasm32 after every check of the request has run and immediately before the catalog commit, with StorageError::Unsupported and the webassembly_unsupported_message wording, which the engine answers as ValidationException. Dropping the transaction rolls back every catalog change of the request. The table lookup and the request's own checks answer first, as natively. build_vector_index is then never called on wasm32, so its wasm32 arm is removed, together with the cfgs that kept the native backfill, the three backfill settings readers and the backfill registry off wasm32. One allow of clippy::disallowed_methods on build_vector_index covers the tokio calls the WebAssembly clippy step disallows, with the reason that its only caller refuses before calling it there. A test in tests/wasm_shim.rs sends the create alone and beside a global secondary index create and a deletion-protection change to an in-memory engine: natively the indexes are created; on wasm32 the answer is the Unsupported refusal and the table's description is unchanged.
BatchWriteItem and BatchExecuteStatement read std::time::Instant::now for the start of their request clock scope. Both handlers are in the WebAssembly build. On wasm32-unknown-unknown std has no clock, so the call panics. The clippy step that main's wasm workflow gained in #1009 refuses the call in batch_write_item.rs, and this branch failed it after the merge of main. The handlers now call web_time::Instant::now, and request_clock holds a web_time::Instant. Elsewhere web_time re-exports std::time. Native builds run the same code.
…rder #1009 moved message_key from crates/server/src/response.rs to crates/core/src/error/mod.rs, where error_document builds the error body. The merge moves error_body to that file too, beside the private message_key, and removes this branch's copy of message_key. error_response calls error_body. In tests/test_error_message_key.py, _error_code_and_keys keeps the keys in the order of the bytes and also returns the HTTP status.
Main at e96a60f (#398 and #428 are the newest commits). Three files conflicted. Each one keeps main's text with this branch's formatting: - docs/cassandra-setup.md: the keyspace_prefix bullet from #1173 (the 27-character limit and the lower-casing rule). A colon after the setting name replaces the em dash. The replication_factor bullet gets the same colon. - docs/manuals/06-developer-test-guide.md: main's "core is sync Rust" wording, with a colon in place of the em dash. - docs/versioning.md: main's two bullets (the experimental backend tier, and the WebAssembly build from #1009). Both README links are GitHub URLs, like every other link outside docs/ on this branch. The relative form of the WebAssembly link does not resolve in the strict site build. Main's new docs/rfcs/0000-credential-encryption-key.md gets an entry in the RFCs sidebar, so the page is reachable from the site and not only by URL. Main's new lines in docs/design/02-high-level-design.md (three) and docs/design/03-component-core.md (one) carry em dashes. They stay as main has them: #530's dash sweep covers those files. The strict site build passes on the merged tree.
#1009 added the wasm32 build of this crate after this branch added the SQL function extenddb_scan_segment. After the merge of main, the wasm32 build does not compile. sqlite_util.rs imports libsqlite3_sys, which the wasm32 build does not have, and the SqliteConnection of the wasm_sqlx shim has no lock_handle method. On wasm32, sqlite_util.rs takes SQLite's C API from sqlite-wasm-rs, which exports the same names and types. Both targets use the same scan_segment_sql. The shim gets lock_handle and as_raw_handle, the names sqlx gives them, so register_scan_segment is the same code on both targets. The Scan SQL calls the function on both targets, so the wasm32 build must register it too. The parity corpus gets a parallel Scan of the Page table, segment 0 of 3. It counts the two keys whose CRC32 modulo 3 is 0, k0 and k2. CI's test job runs the corpus natively, and the corpus step of the WebAssembly workflow runs it on wasm32.
Main is at 14ade59 (#864), ten commits after the last merge. Two files conflicted: - docs/manuals/07-upgrade-manual.md: #398 and this branch each add a v1.1.0 entry at the top of "Behavior Changes by Release". The merge keeps both entries whole, the #398 entry first and this branch's U+0000 entry after it. - crates/storage-postgres/src/data/query.rs: #588 adds string_prefix_upper_bound to the extenddb_storage::util import, and this branch imports parse_sk and pk_to_text from super::key_text. The merge imports sk_info and string_prefix_upper_bound from util and keeps the key_text import. bind_sk_condition computes the begins_with bound of #588 from the value that key_text::parse_sk returns. So a prefix that holds U+0000 still gets the ValidationException of this branch before the statement runs. The other files that both sides change merged without a conflict. In each one the two sides change different lines: - crates/storage-postgres/src/data/query_scan.rs: #588 passes the expression maps to build_sk_sql, and this branch imports from key_text. - crates/storage/src/util/mod.rs: the prefix module of #588 and the control_chars module of this branch. - crates/storage-cassandra/src/migrations/mod.rs and crates/storage-sqlite/src/migrations/mod.rs: #1173 and #1009 change imports and module declarations, and this branch adds the EscapeControlChars arm. - crates/storage/src/backup_catalog.rs: #1009 adds clippy allows, and this branch changes a doc comment. - CONTRIBUTING.md, docs/design/04-component-storage.md and docs/differences-from-dynamodb.md: each side changes its own sections. Main adds no catalog migration, so migration 13 keeps its number.
Main is at 14ade59 (#864). One file conflicted: docs/manuals/07-upgrade-manual.md. #398 and this branch each add a v1.1.0 entry at the top of "Behavior Changes by Release". The merge keeps both entries whole, the #398 entry first and this branch's entry after it. The other files that both sides change merged without a conflict: - crates/server/src/handler.rs: main moves the pre-auth request checks into extenddb_engine::parse_request and the point-in-time refusal into admit (#1009). record_segments drops its table argument and takes the segments by reference (#398). This branch changes only the error arm of the authorization step. That arm still records UserErrors and RequestCount with the two calls that the point-in-time refusal makes. - docs/design/06-component-server.md: #398's segments text and this branch's RequestCount and UserErrors paragraph are in separate places. #398 records segments only for a request that reaches dispatch, so a request refused in the authorization step adds counts and no segments.
Main is at 14ade59. This branch last had main at 018715e, through fix/query-key-value-types. Since then, these eleven commits merged into main: #1280, #1009, #596, #1173, #398, #428, #544, #567, #584, #588 and #864. #544 is the squash of fix/query-key-value-types, which was the base branch of this PR. This branch already holds the last head of that branch, 31c5f3d. Main has the same version of each conflicted file as 31c5f3d. So each conflict hunk has the lines of #544 on one side. The other side has the change of this branch to the same lines. The merge keeps the version of this branch in each file: - crates/engine/src/query_key_values.rs: this branch makes two constants and four functions pub(crate) for the Scan checks, and re-exports three functions of unreadable.rs. It reads a number in Segment and TotalSegments as it reads one in Limit, with the dates in the doc comment of shape_fault_first. It passes validate_no_parameter_mix to unreadable_value_checks. - crates/engine/src/query_key_values/unreadable.rs: this branch makes three functions pub(crate). unreadable_value_checks takes the parameter mix check as a parameter, so this branch deletes the import of validate_no_parameter_mix. - crates/server/src/request_helpers.rs: this branch runs the Scan request checks before the IAM decision, as main does for Query. - tests/test_query_leading_keys_values.py: this branch moves the setup of TestLeadingKeysWithAnInvalidKeyValue to the base class ManagementPrincipals, which tests/test_scan_checks_before_authorization.py imports. Git merged crates/engine/src/lib.rs with no conflict. Main compiles three modules only off wasm32 (backup, import_export_io and private_fs), and adds the modules backup_requests and pre_dispatch. This branch adds the module scan_request and changes the doc comment of validate_enum_fields.
Main is at 14ade59. This branch last had main at 018715e, through fix/query-key-value-types. Since then, these eleven commits merged into main: #1280, #1009, #596, #1173, #398, #428, #544, #567, #584, #588 and #864. #544 is the squash of fix/query-key-value-types, which was the base branch of this PR. This branch already holds the last head of that branch, 31c5f3d. Main has the same version of each conflicted file as 31c5f3d. So each conflict hunk has the lines of #544 on one side. The other side has the change of this branch to the same lines. The merge keeps the version of this branch in each file: - crates/engine/src/query_key_values.rs: the dates and the order in the module and function doc comments, the call of validate_condition_value_numbers, and the two functions validate_condition_value_numbers and refuse_first_fault. - crates/engine/src/query_key_values/request_order_tests.rs: the import of Value and the test legacy_condition_values_get_the_number_check. - tests/test_query_key_value_types.py: the dates in the docstring, the nn_table fixture and the helpers eq, N1, KC_ABC and QF_BOB. The merge also keeps the rows k1 to k16, and nn_table in the tables fixture and the control test. Git merged crates/engine/src/lib.rs with no conflict. This branch changes that file only through the commits of #544, so the merged file is the file of main.
What
Add an experimental WebAssembly build of the engine. A new crate,
extenddb-wasm-adapter(publish = false), compiles towasm32-unknown-unknownwith thecore,cache,auth,storage,storage-sqliteandenginecrates it depends on, and runs in a browserover an in-memory SQLite database, with no server and no network. Built
alone for wasm32,
cacheandenginewith its default features do notcompile; the README's "Building it" says why. The adapter exposes a
wasm-bindgensurface,ExtendDb.create()andsubmit(operation, body),that answers a DynamoDB request by calling
extenddb_engine::dispatchinprocess.
The browser lacks three things the server relies on. The build replaces
them as follows:
#[doc(hidden)]module,extenddb_core::crypto, holds theone
#[cfg(target_arch = "wasm32")]crypto branch:sha256,hmac_sha256,constant_time_eq,seal,openand a random fill. Natively it callsaws-lc-rs, as the callers did before; on wasm32 it calls
sha2,hmac,subtle,aes-gcmandgetrandom, with thezeroizefeatures ofaes-gcm,aes,ghashandpolyvalon.secret_cipher,signing_key,verify,canonical,key_ring,server_componentsandbootstrappercall this module.
extenddb-coretherefore depends on aws-lc-rs natively.sqlxwith the Clibsqlite3-sysdoes not build forthe browser (it runs a dedicated OS thread per connection and needs a C
sysroot). On wasm32,
storage-sqlitealiases itself tosqlxwith one linein
lib.rs(extern crate self as sqlx;) and re-exports an in-cratewasm_sqlxmodule that implements the part of thesqlxsurface the crateuses, over the bundled in-memory
sqlite-wasm-rs0.6.3 (SQLite 3.54.1).The crate's SQL is the one the native build runs. On wasm32 the crate
leaves out its file-backed and server code (the bootstrapper, file
migrations, the catalog-migration and locked-store implementations, the
server's backend factories, lifecycle-command helpers and background
workers, which outside tests only the
extenddbcommand-line tool and theserver it starts use) and its snapshot reader, which uses
sqlxAPI theshim does not provide, and has five items of its own: a
SnapshotEnginethat answers
Unsupported, abefore_first_writemigration step thatreturns no lines for the in-memory database, the vector-index refusal
below, the wasm32 arm of
sqlite_row_struct!, which implementsFromRowfrom the field list that natively derives it, and
wasm_sqlx_for_tests,which gives
tests/wasm_shim.rsthe shim's items under the pathssqlxgives them.
The module documentation lists the rules it takes from
sqlx-sqlite0.8.6and each documented difference. A table test of 102 rows,
crates/storage-sqlite/tests/wasm_shim.rs, runs on both targets: nativelyagainst
sqlxover the C SQLite, on wasm32 against the shim.missing facility is. The adapter refuses the PartiQL operations and
DescribeEndpointsby name, before the engine. On wasm32 the engine'sdispatch refuses the four store-backed backup operations (
CreateBackup,DescribeBackup,DeleteBackup,RestoreTableFromBackup), whose code isnot compiled there; the engine's import and export handlers have a wasm32
stand-in for their file I/O, which refuses; and the SQLite backend refuses
an
UpdateTablethat creates a vector index. Each refusal is aValidationExceptionnaming the build.ListBackups,DescribeContinuousBackups,UpdateContinuousBackups,ImportTableandExportTableToPointInTimerun the engine's own handlers on both targets,as a server does. On this build a request whose body does not parse gets
SerializationException, and one whose body parses gets the handler'sanswer, except that an
UpdateContinuousBackupsthat enables point-in-timerecovery gets the server's refusal before the handler. The adapter configures
no import or export paths, so an
ImportTableorExportTableToPointInTimethat passes the server's checks before dispatchgets the answer of a server with none ("Import is disabled…", "Export is
disabled…"), which comes before the file stand-in; the README's table of
those checks lists the requests a server refuses first, and this build's
answer to each.
The README has a new section that marks the build experimental and outside
the versioning policy. It lists what the build does not do (no
authentication or authorization, every request runs under account
000000000000; memory-only storage; no background tasks; no recovery from atrap), what it refuses and with which error, and the checks the HTTP server
makes before dispatch that this build does not make, with both answers.
docs/versioning.mdlists the build under "Not covered". The architectureguide and AGENTS.md add the crate to their trees, dependency graphs and
crate roles, and describe
core's crypto module; the README adds it to itstree.
A new workflow,
.github/workflows/wasm.yml, builds, lints and tests thewasm32 target on every pull request. Its steps run
devtools/run-wasm-step <step>, which holds each step's commands so they can be run locally:build: the adapter for wasm32;clippy:cargo clippyof the adapter for wasm32 without--no-deps, soit lints the seven workspace crates the build compiles, with
-D warningsand the lists in
devtools/wasm-clippy/clippy.toml(disallowed-methodsand
disallowed-types) of calls that trap or hang on wasm32, such astokio::time::sleep,std::time::Instant::nowandstd::thread::sleep.A listed call left in those crates carries
#[allow(clippy::disallowed_methods, reason = "...")], whose reason sayswhy the wasm build does not reach it; the
clippy.tomlheader says what thestep does not see;
guard: a self-test that the clippy step refuses four planted calls andthat
clippy.tomlis well formed, and a check that the four AES-GCM cratesbuild with
zeroize;pedantic:-W clippy::pedanticfor the adapter's own code, all targets;coreandshim: thewasm-bindgen-tests ofextenddb-coreand of theshim under Node 22;
corpus:crates/wasm-adapter/tests/parity.rs, the test that runs theparity corpus natively, run on wasm32 under Node 22 through
ExtendDb,then
parity/run.mjs, the eight checks ofsubmit's JavaScriptboundary, on the module
wasm-packbuilds.wasmis not a required check onmain; a maintainer has to add it for ared run to block a merge.
Native behaviour of the server does not change. The server's request
handler now calls
extenddb_engine::parse_requestandParsedRequest::admit,which hold the known-operation check, the body parse and the point-in-time
recovery refusal it made inline, so the adapter runs the same code; its
answers, logs and metrics are the same. Its error bodies are built through
extenddb_core::errorhelpers, which produce the same JSON.authimportshttpinstead ofaxum::http(the same types). Clocks in the wasm32-compiledcrates read
web_time, which isstd::timenatively.No version change: the branch stays at 1.0.0 with rust-version 1.91.1. The
adapter takes
extenddb-enginefrom the root[workspace.dependencies]entry, whose
=1.0.0pin is one of the 13 that the release bump in ADR 0029and
packaging/README.mdalready changes. InCargo.lock, the PR addssqlite-wasm-rsandrsqlite-vfs,web-time,console_error_panic_hook,wasm-bindgen-futures,wasm-bindgen-testwithwasm-bindgen-test-macro,wasm-bindgen-test-sharedand thecast,minicovandoorandomitdepends on, and the RustCrypto AEAD crates
aead,aes,aes-gcm,ctr,ghash,opaque-debug,polyvalanduniversal-hash(the eight thatADR 0026 removed, back for wasm32 only). It moves
wasm-bindgen,wasm-bindgen-macro,wasm-bindgen-macro-supportandwasm-bindgen-sharedfrom 0.2.122 to 0.2.130 andjs-sysfrom 0.3.99 to0.3.107, which
wasm-bindgen-test0.3.80 requires exactly;thiserrorandthiserror-implfrom 2.0.18 to 2.0.21 (rsqlite-vfsrequires 2.0.20 orlater, and cargo unifies the one
thiserror2 across the workspace); and the four Windows-onlywindows-sysedges (of
errno,rustix,tempfileandwinapi-util) to 0.61.2.timegains its
js-sysdependency (itswasm-bindgenfeature, on wasm32 only).The four
SOFTWARE-LICENSE-NOTICESfiles are regenerated withcargo-about0.9.0.
Why
To run the engine in a browser over in-memory SQLite, reachable from
JavaScript as a DynamoDB endpoint: a way to try the engine with nothing to
install, and a base for a hosted demo. The engine's handlers, DynamoDB
semantics and SQL are the native ones. The new code is the adapter, the
wasm32 SQLite transport, the crypto module, the request steps the server
and the adapter now share (
extenddb_engine::parse_requestandParsedRequest::admit), the wasm32 refusals and stand-ins listed above,extenddb_core::limits::page_size, theextenddb_core::errorhelpers thatbuild error bodies, the
sqlite_row_struct!macro that declares a catalogrow once for both targets,
SqliteEngine::new_in_memorywith theinsert_default_accountandmigrations::migrate_in_memoryit shares withthe server's paths, and the build and test wiring.
Four new files hold code moved out of existing ones, so that what wasm32
needs compiles there and the rest does not:
crates/storage-sqlite/src/server_backend.rs(the server's backendregistration and factories, from
lib.rs),crates/storage-sqlite/src/migrations/file_database.rs(the migration entrypoints for a database file, from
migrations/mod.rs),crates/engine/src/backup_requests.rs(theListBackupshandler and therequest checks it and the continuous-backups handlers share with the
store-backed backup handlers, from
backup.rs) andcrates/engine/src/import_export/files.rs(the import and export file workthat the two handlers did after their enabled check, from
import_export.rs).backup/pitr.rs, which holds the continuous-backupshandlers, and its
pitr/tests.rsmove with no edit tobackup_requests/pitr.rsandbackup_requests/pitr/tests.rs, a childmodule of
backup_requests. The moved functions keep their bodies, exceptthat the server-components factory migrates an in-memory database through
migrations::migrate_in_memory; the new files add module documentation andimports, and some of the moved items became
pub(crate). The import andexport handlers stay in
import_export.rsand now end infiles::import_tableandfiles::export_table.New public items on the published crates, each
#[doc(hidden)]and notmeant as API:
extenddb_core::crypto, whichauthandstoragecall;extenddb_core::limits::page_size, whichstoragecalls; three functionsand a constant of
extenddb_core::error,error_documentandSERIALIZATION_FAILURE_BODY(which the server and the adapter use),malformed_body_error(the engine) andwebassembly_unsupported_message(the engine,
storage-sqliteand the adapter);extenddb_engine::parse_request,which the server and the adapter call, and the
ParsedRequestit returns, whoseadmitthey call;SqliteEngine::new_in_memory, whichthe adapter calls; the
sqlite_row_struct!macro, exported so thattests/wasm_shim.rsdeclares its rows with it, andsqlite_row_attr!, whichits expansion calls; and, on
wasm32 only,
extenddb_storage_sqlite::wasm_sqlx_for_tests, for the sametest.
Testing done
All counts below are from the CI runs of this head,
8708b7fd; all 62checks passed.
fmt,clippy(both commands ofclippy.yml),notices-current,packageandlauncher-tests: green.run-tests (stable)(rustc 1.100.0): 5442 passed / 0 failed / 99 ignored(5373 in the two
cargo teststeps, 69 in "Filesystem store tests asroot");
run-tests (1.91.1): 5373 passed / 0 failed / 99 ignored.wasm: every step green. The corpus step reports "corpus suite: 1 testspassed, the 1 its list names, and no other test ran" (
tests/parity.rson wasm32) and "RESULT: PASS (8 checks of submit's JavaScript boundary)";
the
corestep 10 tests and theshimstep 3 tests.Parity. One corpus,
crates/wasm-adapter/parity/corpus.json(274 cases),and one test,
crates/wasm-adapter/tests/parity.rs, that runs it on bothtargets: natively through the adapter's
Engine(realsqlxover the CSQLite), and on wasm32 under Node with
wasm-bindgen-testthroughExtendDb, the surface the browser module exports. Each case names theexpected error or success and checks response members by JSON pointer; eight
cases carry a separate expectation for the wasm build (the vector-index
refusal and its
DescribeTable, and six backup cases). Neither run comparesthe full responses of the two builds, so a member a case does not check can
differ. On wasm32,
tests/parity.rscalls the RustExtendDb::submitdirectly, with string arguments, and does not load the emitted module.
parity/run.mjsis the only check of the module thatwasm-pack build --target webemits and of theExtendDbclasswasm-bindgen generates: it calls
ExtendDb.create(), thensubmitwithseven non-string arguments, then a
ListTables.The corpus covers the data plane, GSI and LSI reads, streams, tagging,
transactions, batches, TTL, the limits the engine enforces, the refusals and
the requests to the operations that have no store in this build, cases on
the same instance after each refusal, cases that record this build's answer
where the server checks a request before dispatch, and the control-plane
answers of the synchronous in-memory engine.
Checklist
cargo test --workspace): 5442 passed / 0 failed / 99 ignored inrun-tests (stable)cargo fmt --check)cargo clippy -- -W clippy::pedantic): for the new crate, native and wasm32Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: none. The change does not touch the wire protocol, the
Storagetrait, the auth model, the on-disk format or the CLI, and no ADR was written
for the experimental build. If you want one, for this build or as an
amendment to ADR 0026 recording the RustCrypto crates on wasm32, I will add
it.
What the build reimplements, and its documented differences
sqlxsurfacethe crate uses over
sqlite-wasm-rs. Its module documentation lists therules it takes from
sqlx-sqlite0.8.6 and each difference left(among them: only the location
sqlite::memory:opens, the pool neverwaits and holds one connection, and the two SQLite builds, 3.54.1 and
3.46.0, can order planner-dependent results differently).
SqliteEngine::new_in_memory(#[doc(hidden)]) opens the in-memorydatabase through
migrations::migrate_in_memory, which the server'sin-memory backend also calls, and inserts the default account through
insert_default_account, whichbootstrap_dev_rowsalso calls."Checks the server makes that this build does not", a table of 15 checks
with the requests each refuses and both answers, and under "What it
refuses".
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO).