Skip to content

feat(wasm): [Add WebAssembly browser support for ExtendDB - #1009

Merged
LeeroyHannigan merged 344 commits into
ExtendDB:mainfrom
amrith:main
Nov 24, 2026
Merged

LeeroyHannigan merged 344 commits into
ExtendDB:mainfrom
amrith:main

Conversation

@amrith

@amrith amrith commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

Add an experimental WebAssembly build of the engine. A new crate,
extenddb-wasm-adapter (publish = false), compiles to
wasm32-unknown-unknown with the core, cache, auth, storage,
storage-sqlite and engine crates it depends on, and runs in a browser
over an in-memory SQLite database, with no server and no network. Built
alone for wasm32, cache and engine with its default features do not
compile; the README's "Building it" says why. The adapter exposes a
wasm-bindgen surface, ExtendDb.create() and submit(operation, body),
that answers a DynamoDB request by calling extenddb_engine::dispatch in
process.

The browser lacks three things the server relies on. The build replaces
them as follows:

  • Crypto. A new #[doc(hidden)] module, extenddb_core::crypto, holds the
    one #[cfg(target_arch = "wasm32")] crypto branch: sha256, hmac_sha256,
    constant_time_eq, seal, open and a random fill. Natively it calls
    aws-lc-rs, as the callers did before; on wasm32 it calls sha2, hmac,
    subtle, aes-gcm and getrandom, with the zeroize features of
    aes-gcm, aes, ghash and polyval on. secret_cipher, signing_key,
    verify, canonical, key_ring, server_components and bootstrapper
    call this module. extenddb-core therefore depends on aws-lc-rs natively.
  • SQLite transport. sqlx with the C libsqlite3-sys does not build for
    the browser (it runs a dedicated OS thread per connection and needs a C
    sysroot). On wasm32, storage-sqlite aliases itself to sqlx with one line
    in lib.rs (extern crate self as sqlx;) and re-exports an in-crate
    wasm_sqlx module that implements the part of the sqlx surface the crate
    uses, over the bundled in-memory sqlite-wasm-rs 0.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 extenddb command-line tool and the
    server it starts use) and its snapshot reader, which uses sqlx API the
    shim does not provide, and has five items of its own: a SnapshotEngine
    that answers Unsupported, a before_first_write migration step that
    returns no lines for the in-memory database, the vector-index refusal
    below, the wasm32 arm of sqlite_row_struct!, which implements FromRow
    from the field list that natively derives it, and wasm_sqlx_for_tests,
    which gives tests/wasm_shim.rs the shim's items under the paths sqlx
    gives them.
    The module documentation lists the rules it takes from sqlx-sqlite 0.8.6
    and each documented difference. A table test of 102 rows,
    crates/storage-sqlite/tests/wasm_shim.rs, runs on both targets: natively
    against sqlx over the C SQLite, on wasm32 against the shim.
  • Operations the browser cannot serve. The refusals sit where the
    missing facility is. The adapter refuses the PartiQL operations and
    DescribeEndpoints by name, before the engine. On wasm32 the engine's
    dispatch refuses the four store-backed backup operations (CreateBackup,
    DescribeBackup, DeleteBackup, RestoreTableFromBackup), whose code is
    not 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 UpdateTable that creates a vector index. Each refusal is a
    ValidationException naming the build. ListBackups,
    DescribeContinuousBackups, UpdateContinuousBackups, ImportTable and
    ExportTableToPointInTime run 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's
    answer, except that an UpdateContinuousBackups that enables point-in-time
    recovery gets the server's refusal before the handler. The adapter configures
    no import or export paths, so an ImportTable or
    ExportTableToPointInTime that passes the server's checks before dispatch
    gets 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 a
trap), 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.md lists the build under "Not covered". The architecture
guide 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 its
tree.

A new workflow, .github/workflows/wasm.yml, builds, lints and tests the
wasm32 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 clippy of the adapter for wasm32 without --no-deps, so
    it lints the seven workspace crates the build compiles, with -D warnings
    and the lists in devtools/wasm-clippy/clippy.toml (disallowed-methods
    and disallowed-types) of calls that trap or hang on wasm32, such as
    tokio::time::sleep, std::time::Instant::now and std::thread::sleep.
    A listed call left in those crates carries
    #[allow(clippy::disallowed_methods, reason = "...")], whose reason says
    why the wasm build does not reach it; the clippy.toml header says what the
    step does not see;
  • guard: a self-test that the clippy step refuses four planted calls and
    that clippy.toml is well formed, and a check that the four AES-GCM crates
    build with zeroize;
  • pedantic: -W clippy::pedantic for the adapter's own code, all targets;
  • core and shim: the wasm-bindgen-tests of extenddb-core and of the
    shim under Node 22;
  • corpus: crates/wasm-adapter/tests/parity.rs, the test that runs the
    parity corpus natively, run on wasm32 under Node 22 through ExtendDb,
    then parity/run.mjs, the eight checks of submit's JavaScript
    boundary, on the module wasm-pack builds.

wasm is not a required check on main; a maintainer has to add it for a
red run to block a merge.

Native behaviour of the server does not change. The server's request
handler now calls extenddb_engine::parse_request and ParsedRequest::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::error helpers, which produce the same JSON. auth imports
http instead of axum::http (the same types). Clocks in the wasm32-compiled
crates read web_time, which is std::time natively.

No version change: the branch stays at 1.0.0 with rust-version 1.91.1. The
adapter takes extenddb-engine from the root [workspace.dependencies]
entry, whose =1.0.0 pin is one of the 13 that the release bump in ADR 0029
and packaging/README.md already changes. In Cargo.lock, the PR adds
sqlite-wasm-rs and rsqlite-vfs, web-time, console_error_panic_hook,
wasm-bindgen-futures, wasm-bindgen-test with wasm-bindgen-test-macro,
wasm-bindgen-test-shared and the cast, minicov and oorandom it
depends on, and the RustCrypto AEAD crates aead, aes, aes-gcm, ctr,
ghash, opaque-debug, polyval and universal-hash (the eight that
ADR 0026 removed, back for wasm32 only). It moves wasm-bindgen,
wasm-bindgen-macro, wasm-bindgen-macro-support and
wasm-bindgen-shared from 0.2.122 to 0.2.130 and js-sys from 0.3.99 to
0.3.107, which wasm-bindgen-test 0.3.80 requires exactly; thiserror and
thiserror-impl from 2.0.18 to 2.0.21 (rsqlite-vfs requires 2.0.20 or
later, and cargo unifies the one thiserror 2 across the workspace); and the four Windows-only windows-sys
edges (of errno, rustix, tempfile and winapi-util) to 0.61.2. time
gains its js-sys dependency (its wasm-bindgen feature, on wasm32 only).
The four SOFTWARE-LICENSE-NOTICES files are regenerated with cargo-about
0.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_request and
ParsedRequest::admit), the wasm32 refusals and stand-ins listed above,
extenddb_core::limits::page_size, the extenddb_core::error helpers that
build error bodies, the sqlite_row_struct! macro that declares a catalog
row once for both targets, SqliteEngine::new_in_memory with the
insert_default_account and migrations::migrate_in_memory it shares with
the 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 backend
registration and factories, from lib.rs),
crates/storage-sqlite/src/migrations/file_database.rs (the migration entry
points for a database file, from migrations/mod.rs),
crates/engine/src/backup_requests.rs (the ListBackups handler and the
request checks it and the continuous-backups handlers share with the
store-backed backup handlers, from backup.rs) and
crates/engine/src/import_export/files.rs (the import and export file work
that the two handlers did after their enabled check, from
import_export.rs). backup/pitr.rs, which holds the continuous-backups
handlers, and its pitr/tests.rs move with no edit to
backup_requests/pitr.rs and backup_requests/pitr/tests.rs, a child
module of backup_requests. The moved functions keep their bodies, except
that the server-components factory migrates an in-memory database through
migrations::migrate_in_memory; the new files add module documentation and
imports, and some of the moved items became pub(crate). The import and
export handlers stay in import_export.rs and now end in
files::import_table and files::export_table.

New public items on the published crates, each #[doc(hidden)] and not
meant as API: extenddb_core::crypto, which auth and storage call;
extenddb_core::limits::page_size, which storage calls; three functions
and a constant of extenddb_core::error, error_document and
SERIALIZATION_FAILURE_BODY (which the server and the adapter use),
malformed_body_error (the engine) and webassembly_unsupported_message
(the engine, storage-sqlite and the adapter); extenddb_engine::parse_request,
which the server and the adapter call, and the ParsedRequest it returns, whose
admit they call; SqliteEngine::new_in_memory, which
the adapter calls; the sqlite_row_struct! macro, exported so that
tests/wasm_shim.rs declares its rows with it, and sqlite_row_attr!, which
its expansion calls; and, on
wasm32 only, extenddb_storage_sqlite::wasm_sqlx_for_tests, for the same
test.

Testing done

All counts below are from the CI runs of this head, 8708b7fd; all 62
checks passed.

  • fmt, clippy (both commands of clippy.yml), notices-current,
    package and launcher-tests: green.
  • run-tests (stable) (rustc 1.100.0): 5442 passed / 0 failed / 99 ignored
    (5373 in the two cargo test steps, 69 in "Filesystem store tests as
    root"); run-tests (1.91.1): 5373 passed / 0 failed / 99 ignored.
  • wasm: every step green. The corpus step reports "corpus suite: 1 tests
    passed, the 1 its list names, and no other test ran" (tests/parity.rs
    on wasm32) and "RESULT: PASS (8 checks of submit's JavaScript boundary)";
    the core step 10 tests and the shim step 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 both
targets: natively through the adapter's Engine (real sqlx over the C
SQLite), and on wasm32 under Node with wasm-bindgen-test through
ExtendDb, the surface the browser module exports. Each case names the
expected 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 compares
the full responses of the two builds, so a member a case does not check can
differ. On wasm32, tests/parity.rs calls the Rust ExtendDb::submit
directly, with string arguments, and does not load the emitted module.
parity/run.mjs is the only check of the module that
wasm-pack build --target web emits and of the ExtendDb class
wasm-bindgen generates: it calls ExtendDb.create(), then submit with
seven 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

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace): 5442 passed / 0 failed / 99 ignored in run-tests (stable)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic): for the new crate, native and wasm32
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any): none
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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 Storage
trait, 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

  • The wasm32 SQLite transport implements the part of the sqlx surface
    the crate uses over sqlite-wasm-rs. Its module documentation lists the
    rules it takes from sqlx-sqlite 0.8.6 and each difference left
    (among them: only the location sqlite::memory: opens, the pool never
    waits 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-memory
    database through migrations::migrate_in_memory, which the server's
    in-memory backend also calls, and inserts the default account through
    insert_default_account, which bootstrap_dev_rows also calls.
  • Answers that differ from a server are listed in the README section
    "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).

@LeeroyHannigan LeeroyHannigan left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. 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_checksums fails for SQLite migrations 1, 3, 4, 6 and 9 with "the body changed after release". Each frozen checksum covers the whole source file (SOURCE is include_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. Five rebless entries 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) and server_components.rs:136 (the constant-time KEK compare). In extenddb-storage-sqlite, #1003's new management_store/secret_rows.rs has no shim alias. With the alias added, it still fails at line 219, because the shim's SqlitePool::acquire returns a bare SqliteConnection where sqlx returns PoolConnection<Sqlite>.

    I fixed both build failures locally to measure the size of the change. It is about 50 lines: hmac and subtle on wasm, and a PoolConnection newtype 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, with sha256, hmac_sha256, constant_time_eq, seal, open and a random fill. secret_cipher, signing_key, verify, canonical, key_ring and server_components then call it. The call-site pattern broke within a week of this PR's base.

  2. The demo puts AWS secret keys in the page URL.

    ?backend=aws reads accessKeyId, secretAccessKey and sessionToken from the query string (rawQueryParam in 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.server logged the whole query string. The documented command, python3 -m http.server 8000 with 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 signs host: localhost:8000 and path /ddb, and the proxy sends another host and /.
    • ensureSchema() treats ResourceInUseException as 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 aws backend 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.1 in every server command, and remove the proxy recipe.

  3. 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 through libsqlite3_sys in sqlite_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.

  4. Two requests crash the wasm module, and the instance stays broken. I measured both on a release build under Node.

    • UpdateTable with VectorIndexUpdates[].Create panics with "time not implemented on this platform". update_table.rs:911 calls tokio::time::Instant::now() and :942 calls tokio::spawn, with no wasm cfg. The submit promise never settles. Afterwards the instance still answers reads, but every PutItem, UpdateItem, CreateTable and DeleteTable hangs. CreateTable with VectorIndexes works.
    • 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). Add tokio::time and tokio::spawn to 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.

  5. 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 second BEGIN, where sqlx creates a SAVEPOINT.
    • fetch and fetch_optional read every row before they return, so on wasm the shim loads the whole partition that vector_search.rs streams.
    • 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 Send and Sync for RawConn rely on wasm having no threads. Please gate them on not(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.

  6. 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 = false crate 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_file is a second parser beside serve_lock::database_file, and new_in_memory repeats the INSERT of bootstrap_dev_rows and the steps of the migration helper.
    • backup_wasm.rs copies ten handler signatures and BackupRuntime::new.
    • The adapter copies the server's error body and its SerializationException parse (response.rs, handler.rs). POC_MAX_ITEM_SIZE_BYTES is DEFAULT_MAX_ITEM_SIZE_BYTES under another name.
    • 13 of the 16 tests in runtime.rs repeat 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.
  7. 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.rs and 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_authorizer is None. Please either install the developer-mode item authorizer, or refuse them with a ValidationException that names the reason.

  8. 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-adapter under "Not covered" in docs/versioning.md.

  9. 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 46 doc_markdown warnings natively. For wasm32, --all-targets does not build, because the tokio dev-dependency inherits the workspace's full features 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.md and testing.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_use says the case flows through the shim's is_unique_violation. That function is in sqlite_util.rs, and the test runs only natively.

    • The lib.rs comment for wasm_support mentions "the backup pool-sizing formulae", which the module does not contain.

    • The crate description still says "with an in-memory storage stub".

  10. The next release would publish extenddb-wasm-adapter as a 15th crate.

    The crate has no publish = false, and devtools/publish-crates --list-packages lists 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 add publish = 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 changes SqliteConfig::default().path to :memory:. new_in_memory passes :memory: itself, so the adapter does not need the feature.
  • new_in_memory is 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 zeroize feature of aes-gcm is off, so on wasm nothing wipes the expanded AES key. Please enable it.
  • devtools/run-tests: a failed --wasm build does not fail a run that also requests other suites, and line 452 overwrites the --headless result.
  • The lint matches text. Because of it, the PR changed std::time to web_time in 10 files that never compile for wasm. Please revert those changes. The lint also misses tokio::time and tokio::spawn, and after the rebase it will flag main's credential_cache/entry.rs:8. disallowed-methods in a clippy.toml does the same check with type resolution.
  • On wasm, last_errno from #1003 (secmem/platform.rs:70) is dead code, which fails a -D warnings build. Gate it on any(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
  • 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 an mwinit step. Please write these steps for any reader's host.
  • samples/webasm-storefront/pkg/ is not git-ignored.

Optional

  • A RUSTFLAGS variable in the environment replaces the wasm32 rustflags in .cargo/config.toml, and getrandom then stops the build. run-tests --wasm could 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.

@amrith

amrith commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the thorough review — it was built onto 1.0.0 and fuzzed against the
native adapter, and the list below is exactly what we worked through. The branch
is re-landed on current main (cut from c2e9a32) as clean per-crate commits;
the version churn and the demo did not come over. Every item is addressed; where
we chose a different mechanism than suggested, it is called out.

Required

1. Rebase onto 1.0.0; the three merge breakages.

  • Version changes. Gone. The branch is cut from main and stays at 1.0.0 /
    MSRV 1.91.1: no workspace version change, no pin changes,
    packaging/npm/package.json untouched, no doc version literals, no
    0.1.2x anywhere. Cargo.lock is regenerated from main plus only the
    packages this port adds; the forced, semver-compatible thiserror
    2.0.18→2.0.21 bump (rsqlite-vfs requires >=2.0.20, cargo unifies it
    workspace-wide) and the syn 3.0.6 it pulls are the only native closure
    changes, and the four notices files are regenerated for them with
    cargo-about 0.9.0 (b0a49e8d).
  • Frozen migrations. We took the first option: there are no per-file alias
    blocks, so SQLite migrations 1, 3, 4, 6 and 9 are byte-identical to main
    and the_released_bodies_match_their_checksums passes with no rebless
    entries. (See item 6 for how the alias is done instead.)
  • The wasm build after the merge. Fixed through the single crypto module, not
    more call-site cfgs. extenddb_core::crypto (0c36f64c) holds the only
    wasm crypto branch — sha256, hmac_sha256, constant_time_eq, seal,
    open, random fill — and key_ring.rs:121-122, server_components.rs:136,
    secret_cipher, signing_key, verify and canonical call it
    (fbb1a360, 87780f14). #1003's management_store/secret_rows.rs is
    reached through the shim, and the shim grew a PoolConnection<Sqlite> newtype
    so SqlitePool::acquire returns what sqlx returns (45997147). The wasm
    build passes. The whole wasm build, lint and test job runs on the toolchain
    the CI pins (currently Rust 1.97.0): the new crate declares its
    extenddb-engine dependency directly rather than inheriting it (so turning
    the engine's default partiql feature off is accepted by that cargo as well
    as newer ones), the adapter's doc comments backtick SQLite for
    clippy::doc_markdown, and the shim's lint allow-list tolerates
    unknown_lints so a clippy without one of the listed lints does not error.

2. The demo put AWS keys in the page URL. The storefront sample is removed
entirely — the aws backend, the JS SigV4 signer, the CORS proxy recipe,
SMOKE-TEST.md, the seed and the page. There is no credential read from a URL,
no proxy recipe, and nothing adopts an existing table. The only documented
server command (building the module and serving it) is not part of this PR;
there is no HTTP server in the browser build.

3. No CI job for wasm; the shim has no tests. Added
.github/workflows/wasm.yml (6af26653), a required check on every PR, that:
installs clang + 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 wasm32 clippy -D warnings; and runs a table-driven wasm-bindgen-test of
the shim's decode/bind/transaction rules under Node, plus the crypto module's
wasm tests (33c00792). Two notes: the shim tests had to move into an
integration test (crates/storage-sqlite/tests/wasm_shim.rs) because a wasm
--lib test build of storage-sqlite pulls its native dev-dependencies (and
mio); and wasm-bindgen-test 0.3.80 needs Node ≥ 20 (it crashes a Node 18
V8), so the job uses Node 22. Both wasm wasm-bindgen-test suites also have a
local entry point, devtools/run-tests --wasm-test, which runs them on wasm32
under a Node ≥ 20. On #1087: it registers a SQLite function through
libsqlite3_sys in sqlite_util.rs, a shim-reached file; we did not touch
#1087, and this new job is what will catch a break of the shim path when the two
land.

4. Two requests crash the module.

  • UpdateTable vector-index create. The adapter refuses an UpdateTable whose
    body carries VectorIndexUpdates[].Create with a ValidationException that
    names the build, before dispatch and so before any catalog write
    (28267fd8). A corpus case drives the refusal and then a PutItem, GetItem and
    DeleteTable on the same instance to show it still serves. The update_table.rs
    backfill's tokio::time::Instant::now() / tokio::spawn are gated to native
    (02a6b045/45997147), so they are not reachable on wasm.
  • Deeply-nested PartiQL. The three PartiQL operations are refused in the
    adapter before the parser (item 7), so neither nesting input reaches it. Both
    are corpus cases (one ~2.6k chars, one ~4.0k chars); each is refused and the
    next request on the instance succeeds.
  • The reachability lint now matches tokio::time and tokio::spawn
    (79f65af7). wasm.rs documents that a panic on wasm32 is an unrecoverable
    trap that leaves the submit promise pending, so the instance needs a page
    reload (28267fd8).

5. The shim decodes differently from sqlx-sqlite 0.8.6. The shim now matches
sqlx for the rules that affect the data plane, and documents the rest, with each
matched rule tested on wasm in the item-3 job (c6ffdffa, 33c00792):

  • Matched: storage-class type checks (String only from TEXT; i64/i32 only from
    INTEGER; f64 only from REAL); NULL into a non-Option decodes ""/0/false/
    0.0/empty (so the NaN-metrics row reads 0.0); invalid UTF-8 in TEXT errors
    rather than becoming U+FFFD; duplicate column names keep the last; multi-
    statement SQL runs every statement (a tail pointer through
    sqlite3_prepare_v2); empty or comment-only SQL returns an empty result, not
    the connection's last error; a pool statement issued while a transaction is
    open fails (an open-transaction flag); SqlitePool::acquire returns a
    PoolConnection<Sqlite> newtype. unsafe impl Send/Sync for the connection
    handle is gated on not(target_feature = "atomics").
  • Documented in the shim module doc, not matched: the fetch/fetch_optional
    streaming shape, and the SQLite 3.54.1 vs 3.46.0 build/compile-flag difference
    that can order planner-dependent results differently.

6. Second copies. Removed, or the reason given:

  • The 44-file alias block. Replaced by one line in storage-sqlite/src/lib.rs:
    #[cfg(target_arch = "wasm32")] extern crate self as sqlx; plus a crate-root
    pub use wasm_sqlx::*; (45997147). We could not use a separate publish = false shim crate as suggested: under cargo package, a published crate
    cannot depend on a publish = false crate (even a target-scoped one), and
    publishing the shim would make it a 15th crate (item 10 / ADR 0029). Aliasing
    the crate to itself gives the same result — one line, not 44 blocks, and the
    five frozen files stay byte-identical.
  • Five duplicated FromRow field lists. Gone. One sqlite_row_struct! macro
    emits each field list once; it derives sqlx::FromRow on native and generates
    a by-name FromRow impl on wasm, so a new column changes one place and
    compiles or fails identically on both targets.
  • wasm_support::database_file / new_in_memory repetition. wasm_support
    is gone; serve_lock::database_file is the one parser. new_in_memory reuses
    bootstrap_dev_rows and the migration helper (45997147).
  • backup_wasm.rs. Never created; the adapter answers those operations
    (item 7), and the engine's backup handlers are gated to native.
  • Adapter copies of the server error body and SerializationException parse.
    Extracted to extenddb_core::error (74ebfdcb); both server/src/response.rs
    and the adapter build their error document from that helper (140aae66,
    28267fd8), with no server crate in the wasm graph. POC_MAX_ITEM_SIZE_BYTES
    is gone; the adapter uses DEFAULT_MAX_ITEM_SIZE_BYTES.
  • 13 runtime.rs tests repeating corpus cases. Moved into the corpus table
    (de09628e); runtime.rs keeps only genuinely adapter-level tests.
  • The JS SigV4 signer. Removed with the demo (item 2), so there is no second
    signer. (Web Crypto is no longer relevant to this PR.)

7. Wrong errors in the browser build. The adapter now answers these, the
same on both targets so the native adapter matches the wasm build, with corpus
cases for each:

  • Store-backed backup/restore/PITR (CreateBackup, DescribeBackup,
    DeleteBackup, RestoreTableFromBackup, RestoreTableToPointInTime) →
    ValidationException naming the build. ListBackups → empty list.
    DescribeContinuousBackups → point-in-time recovery DISABLED.
    UpdateContinuousBackups enabling it → ContinuousBackupsUnavailableException
    (and a malformed/absent flag → the service's "Member must not be null"
    ValidationException, matching native) (bc6e7876, 1e8e0509). ImportTable
    and ExportTableToPointInTime → the service's "disabled" ValidationException.
    These ValidationExceptions are HTTP 400, so an SDK does not retry them, which
    the InternalServerError 500 did. One documented divergence from native: the
    no-store answers (DescribeContinuousBackups, a disabling
    UpdateContinuousBackups) do not first check that the table exists, so a
    request naming a missing table gets the point-in-time-disabled description
    rather than TableNotFoundException; a malformed specification is still
    rejected first, as on native. The README's refusal section notes this.
  • ExecuteStatement, BatchExecuteStatement, ExecuteTransaction → a
    ValidationException that names the reason (the PartiQL surface is left out of
    this build), refused before the parser (28267fd8). We chose to refuse rather
    than install the developer-mode item authorizer, so the browser build runs no
    authorization at all.

8. Docs. A new README "Experimental: WebAssembly build" section marks the
build experimental and outside the versioning policy and support, and lists what
it does not do (no authn/authz — every request under 000000000000; memory-only;
no background work, so TTL never deletes, ItemCount/TableSizeBytes stay 0,
streams are never trimmed), what it refuses with each error, and the build
prerequisite (a clang that targets wasm32 for the bundled SQLite). The crate is
in the README and AGENTS trees, and the build + crate are under "Not covered" in
docs/versioning.md (06f031ad).

9. Statements that did not match the code. The description and comments are
rewritten to say only what the code does:

  • No "SigV4 auth model unchanged" — the build is documented as verifying no
    signature and running no authorization. The runtime.rs comment no longer
    claims "developer mode with authentication skipped".
  • No "no engine behavior reimplemented" / "verbatim" — the description names the
    wasm SQLite transport as a reimplementation of the sqlx surface and the
    wasm-unsupported operations as adapter-answered.
  • Test counts come from the PR head's CI log: 5378 passed / 0 failed / 98 ignored (run-tests (stable)).
  • Corpus coverage is stated exactly (77 cases; the families listed in the
    description; each case asserts a named error or success, with body path checks
    on 52).
  • The build needs a C compiler for wasm — stated in the prerequisites.
  • Clippy: on wasm32, --no-deps --lib per crate — -W clippy::pedantic clean
    for the new extenddb-wasm-adapter crate and -D warnings for
    extenddb-storage-sqlite (with the shim); --target wasm32-unknown-unknown --all-targets builds (the adapter's tokio dev-dep is scoped to native). The
    new adapter crate is also -W clippy::pedantic clean on native. The
    workspace-wide cargo clippy --workspace --all-targets -- -D warnings (native)
    is the gating CI toolchain's run — its only double_must_use findings, in
    extenddb-auth, are pre-existing on main and untouched here.
  • No comment cites anything outside the code repo; a sweep for such references
    is empty. The create_table_with_taken_name_is_resource_in_use doc,
    wasm_support comment and the crate description "stub" are fixed or gone.

10. The 15th crate. extenddb-wasm-adapter is publish = false;
devtools/publish-crates --list-packages lists 14.

Smaller fixes

  • features = ["memory"] dropped from the adapter's storage-sqlite
    dependency; SqliteConfig::default().path is unchanged workspace-wide
    (new_in_memory passes :memory: itself).
  • new_in_memory is #[doc(hidden)].
  • The wasm crypto branches run in wasm-bindgen-tests; aes-gcm's zeroize is
    on; secret_cipher.rs no longer claims its native fixtures prove the wasm
    path.
  • devtools/run-tests: a failed --wasm now fails the whole run, and the
    --headless result is no longer overwritten (79f65af7).
  • The 10 never-wasm web_time edits are not present (the clock swap is only in
    wasm-reachable sites); the lint covers tokio::time/tokio::spawn;
    credential_cache/entry.rs:8 reads the clock through web-time (fbb1a360).
  • last_errno is gated on any(unix, windows), so the wasm -D warnings build
    is clean (dc860747).
  • The JS signer items are moot — the signer is gone with the demo.
  • Empty or comment-only SQL returns an empty result in the shim, with a test.
  • No doc describes an author's specific host (no "the dev host", no repo
    directory name, no mwinit).
  • Nothing under samples/ carries the demo; parity/pkg/ (the generated
    module) is git-ignored.

Optional

  • run-tests --wasm and the CI job pass the getrandom wasm backend cfg through
    RUSTFLAGS rather than cargo --config: an ambient RUSTFLAGS shadows a
    target's config-file rustflags, so setting RUSTFLAGS is what actually keeps
    the cfg from being dropped. .cargo/config.toml still carries it as the
    default.
  • The four Windows-only edges (errno, rustix, tempfile, winapi-util) keep main's
    windows-sys versions; nothing in the port forced them, so they are
    unchanged.
  • README module sizes are measured: ~6.6 MiB after wasm-bindgen, ~4.9 MiB
    after wasm-opt (which wasm-pack --release runs).
  • Module notices: this PR ships no prebuilt module (the crate is publish = false, the demo is gone), so no module notices file is added. A distributed
    module would need its own, because sqlite-wasm-rs compiles a musl libc
    subset and an MIT printf that about.toml's two Linux targets do not
    cover; about.toml is left for a maintainer to change if the module is ever
    distributed.

@LeeroyHannigan LeeroyHannigan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. The wasm job 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 the last_errno gate removed, the build step only warns, and both clippy steps pass. cargo clippy --locked -p extenddb-wasm-adapter --lib --target wasm32-unknown-unknown -- -D warnings lints 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.rs has one function per rule, and it binds only an i64, a &str and 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 and Vec<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 wasm a required check. main requires test, fmt, clippy, integration, mongodb-integration, notices-current and cassandra-integration. Until a maintainer adds wasm, please say that it must become a required check.
  2. The lint, the corpus and the trap text still need changes.

    • Of tokio::time, the lint matches only tokio::time::Instant::now (devtools/wasm-reachability-lint.py:57-65). The wasm build enables tokio's time feature, so the other tokio::time calls compile and trap. I added tokio::time::sleep to handle_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, :1674 and :1713, and crates/storage/src/vector_lifecycle/build.rs:146, :169 and :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.rs and core/src/backup_format/data_file.rs. With std::time::Instant::now() added to store.rs, the lint printed OK and ExtendDb.create() panicked.
    • The limits.rs entry says that the wasm build omits the parser. cargo tree -e features shows core's partiql feature on in the wasm build.

    Please match the tokio::time:: prefix, use tokio::time imports and std::thread::sleep, and remove the four entries. disallowed-methods in 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.

  3. 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 placeholders 1..=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_all binds the whole list into each statement that has a placeholder.
    • sqlx adds up sqlite3_changes after 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_count for each statement, the changes added up per statement, and 0 when no statement runs. Otherwise, list each difference correctly. Please also make acquire() fail while a transaction is open.

  4. These second copies remain. The adapter's copy of the engine's no-store answers is in item 7.

    • serve_lock_wasm.rs:32-44 is a second database_file parser beside serve_lock.rs. Your reply says serve_lock::database_file is 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 of bootstrap_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_unsupported on, except update_table_without_a_vector_create_is_not_refused. Please keep those cases in the corpus only. The malformed-body check of execute_statement_is_unsupported can become a corpus case with rawBody.
  5. 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:

    • DescribeContinuousBackups with {} gets the DISABLED description on wasm. Natively it gets "The parameter 'TableName' is required but was not present in the request".
    • ListBackups with {"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".
    • UpdateContinuousBackups that enables recovery on a missing table gets ContinuousBackupsUnavailableException on wasm, and TableNotFoundException natively. The README covers only the request that disables recovery.

    no_store_answer and its helpers are also copies of engine code. point_in_time_recovery_enabled and member_null are pitr.rs:224-237 and :127-132. continuous_backups_disabled_document restates default_continuous_backups_description (pitr.rs:179-188). The messages are PITR_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.

  6. 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.

  7. 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-targets builds. It exits 101 with error[E0433]: cannot find module or crate tokio in this scope in 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_js backend 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 step RUSTFLAGS and WASM_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".
  8. The adapter's direct engine dependency (crates/wasm-adapter/Cargo.toml:37) adds a 14th =1.0.0 pin 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 requirement extenddb-engine = "=1.0.0"".

    The version cannot go on its own. With a path-only dependency, the package job's cargo package --workspace --no-verify --locked stops 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 each cargo package --workspace command.

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 own zeroize features. cargo tree -e features shows neither on. Please add aes and polyval with features = ["zeroize"] to core's wasm32 dependencies, or fix the comment at line 48.
  • devtools/run-tests --wasm --headless and --wasm --wasm-test exit 0 when the --wasm suite fails. The "only remaining suite" branches (:466-471 and :564-569) exit with their own status and ignore the PASS=false of an earlier suite. Your reply says a failed --wasm fails the run. Line 546 also puts $CARGO_HOME/bin before 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 with cfg_attr, and add a vector sealed by AWS-LC.
  • wasm_sqlx.rs:11-13 and :24 allow unknown_lints for the whole module, for clippy::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_code and unused_imports for 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.
  • SqliteDbError prints 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.

@amrith

amrith commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the second review. Each item, with the commit and the test that covers it. Where I
chose differently from what you asked, the line says why.

3. wasm job and shim test

  • Clippy of all seven crates: the step "Clippy the wasm32 build" runs cargo clippy --locked -p extenddb-wasm-adapter --lib --release --target wasm32-unknown-unknown -- -D warnings without
    --no-deps, with CLIPPY_CONF_DIR=devtools/wasm-clippy (54209b53, now in
    devtools/run-wasm-step clippy). With the last_errno gate removed it fails: "function
    last_errno is never used" at crates/auth/src/secmem/platform.rs:70.
  • Shim test: crates/storage-sqlite/tests/wasm_shim.rs is one table of 96 rows (stored value or
    rule, Rust type, expected outcome) run by one test, each_row_gives_its_expected_outcome, with
    your seven decode rows, a row per bind, count and transaction rule of item 5, and a row per Rust
    type the shim binds (e3afecb4, 4cc587e1, 726e2cc8). The table runs natively against sqlx
    as well (eaef5743): a row expects the same outcome from both, except six rows named
    difference: ..., which carry sqlx's outcome and the shim's. They cover four of the eight
    differences the module doc lists (the $0 placeholder has a row per terminal); the module doc
    names the four that have rows and says the others have none. The file's two other tests drive the
    backend (SqliteEngine) on wasm32. The :136-137 comment is gone.
  • wasm is not a required check: wasm.yml's header says it must become one for a red run to block
    a merge (e508a2c4).

4. Lint, corpus and trap text

  • The reachability lint is replaced by disallowed-methods and disallowed-types in
    devtools/wasm-clippy/clippy.toml, read by the clippy step above (11d82516, 54209b53). It
    lists the six tokio::time free functions that create a timer (sleep, sleep_until,
    timeout, timeout_at, interval, interval_at) and the two Instant methods that read
    the clock (Instant::now, Instant::elapsed); a timer's own methods, such as
    Interval::reset, read it too, but only on a timer one of the six created. It also lists
    std::thread::sleep,
    std::time::{Instant, SystemTime}::now, tokio's task and runtime calls, and other calls that
    trap or block on wasm32 (thread, process and environment calls, blocking channel and lock
    calls). Clippy resolves
    paths, so use tokio::time; time::sleep(..) and renamed imports are refused too. Your two
    changes, tokio::time::sleep in handle_get_item and std::time::Instant::now() in
    store.rs, each fail the step. The step "Self-test the wasm32 clippy step and check zeroize features" plants four such
    calls in a copy of the tree and fails unless clippy refuses each.
  • The six tokio::time calls you found, and the other listed calls left in the wasm-compiled
    crates, carry #[allow(clippy::disallowed_methods, reason = "...")] with the reason the build
    does not reach them (18 sites). The allowlist and its four stale entries are gone with the lint.
  • The limits.rs note went with the lint; nothing says the parser is omitted (core's partiql is
    on in the wasm build).
  • Corpus: on the instance that refused the vector-index UpdateTable, the cases after it are
    PutItem, GetItem, UpdateItem, CreateTable and DeleteTable (a7790017). The corpus has two
    DeleteTable cases.
  • Trap text: the doc comment of submit in wasm.rs says the promise stays pending, the
    instance is then in an undefined state, and to reload the page (e946176d); the README's
    "No recovery from a trap" says the last two and points to submit's doc (92b2f056).
    create's doc says its promise stays pending too; that under Node the uncaught
    RuntimeError ends the process with exit status 1; and that an uncaughtException handler
    stops that exit, but a top-level await of the promise in an ES module still ends the
    process, with status 13. submit's doc says the same of exit status 1 (34042e3b,
    77a388e5).

5. Shim bind and count rules (e3afecb4; rows in wasm_shim.rs)

  • Each statement binds 1..=sqlite3_bind_parameter_count and an argument past them is not bound;
    the argument offset carries from one statement to the next; rows_affected adds up
    sqlite3_changes after each statement and is 0 when none runs; acquire(), begin and a pool
    statement fail with PoolTimedOut while a transaction holds the connection. The module doc's
    sentences about extra arguments are replaced by these rules.

6. Second copies

  • serve_lock_wasm.rs is gone. serve_lock::database_file compiles on both targets; on wasm32 the
    shim parses only sqlite::memory: and refuses every other location with a Configuration error
    (fe52b475, 1da86734; the table's location rows check it on both targets).
  • new_in_memory inserts the account through insert_default_account, which bootstrap_dev_rows
    also calls, and migrates through migrations::migrate_in_memory, which the server's in-memory
    backend also calls (71513dd0). The in-memory path adds no copy of the INSERT or of the
    migration steps.
  • The 8 tests are gone from runtime.rs; each is a corpus case, and the malformed
    ExecuteStatement body is a rawBody case (a7790017).

7. Native answers for the no-store operations

  • no_store_answer and its helpers are gone. The continuous-backups handlers, the ListBackups
    checks and the import and export checks compile on both targets, and the adapter runs the
    engine's handlers on wasm32 (540c4166, a7790017). The server's pre-dispatch steps are now
    extenddb_engine::parse_request and ParsedRequest::admit, which the server's handler and the
    adapter both call (428dd6b8).
  • Corpus cases record your examples: DescribeContinuousBackups {} gets "The parameter
    'TableName' is required but was not present in the request" and ListBackups {"Limit":0} gets
    the "Member must have value greater than or equal to 1" message, on both builds.
    A body that does not parse gets SerializationException on both builds from ListBackups,
    DescribeContinuousBackups, UpdateContinuousBackups, ImportTable,
    ExportTableToPointInTime and RestoreTableToPointInTime (six rawBody corpus cases,
    ec277683).
  • UpdateContinuousBackups enabling recovery on a missing table now gets
    ContinuousBackupsUnavailableException on both builds, not TableNotFoundException: the
    adapter applies admit, the server's refusal, which reads only the body, before the handler
    looks the table up. That is the server's answer to the same request once it authenticates it.
  • The difference left is the four store-backed backup operations (CreateBackup,
    DescribeBackup, DeleteBackup, RestoreTableFromBackup), whose code is not compiled for
    wasm32: the engine refuses them there with a ValidationException after the body parse. The
    README lists them under "What it refuses"; runtime.rs points to that list instead of keeping
    a second copy of it. runtime.rs and the description no longer say "identical" or "same
    answer"; the README's table of server checks says "the same answer" in four rows, each for the
    inputs that row names. Its rows for table names, table ARNs and accounts leave out an
    UpdateContinuousBackups that enables recovery, which admit refuses first on the server
    and on both builds: the three UpdateContinuousBackups rows (ab26028c; two corpus cases,
    one per row kind, and the existing accounts case) and the account-first sentences of the
    table ARNs and accounts rows (0f1f0581).

8. Docs: the architecture guide lists wasm-adapter/ and says 15 crates; README's crate tree
says "see its section above" (6a0b6012). The guide's dependency graph and crate roles, and
AGENTS.md's, now include the adapter and describe core's crypto module (f4a44d17); the
places that called core "pure" Rust no longer do (4dc6b96a).

9. Statements

  • tests/parity.rs starts with #![cfg(not(target_arch = "wasm32"))], and cargo clippy -p extenddb-wasm-adapter --target wasm32-unknown-unknown --all-targets passes (fb607c1b); the
    pedantic step runs it with --no-deps (e17afa07).
  • The getrandom cfg, the step RUSTFLAGS and WASM_RUSTFLAGS are removed; getrandom 0.3.4 is the
    floor (a30f4d1a, 1a01a025).
  • The apt step installs clang only and says it is unversioned; rustc links with rust-lld
    (a30f4d1a).
  • lib.rs no longer says "end to end"; the corpus has 34 tagging and 42 stream cases.
  • tests/parity.rs says that neither runner compares the full responses of the two builds
    (fb607c1b).
  • The description's ADR box is unticked, with the reason.

10. Engine pin: I took a third way. The root [workspace.dependencies] entry is now
extenddb-engine = { path = "crates/engine", version = "=1.0.0", default-features = false }, and
the adapter, the server and the app inherit it (the server adds features = ["default"])
(26b420a1). The pin is one of the 13 that ADR 0029 and packaging/README.md already bump, so
neither document changes. A bump to 1.0.1 as they describe, then cargo metadata, cargo package --workspace --no-verify --locked and devtools/check-crate-packages, passes on 1.97.0.

Smaller fixes

  • aes, ghash and polyval have features = ["zeroize"] in core's wasm32 dependencies
    (a9138d6c); crypto.rs asserts at compile time that the AES block cipher aes-gcm uses
    (aes_gcm::aes::Aes256) is ZeroizeOnDrop and that polyval::Polyval needs drop.
  • devtools/run-tests is main's again; the wasm steps run only through devtools/run-wasm-step,
    which puts nothing before the caller's PATH (2366e6fc).
  • Crypto tests: one set of nine runs on both targets through cfg_attr;
    open_decrypts_aws_lc_sealed_vector opens, on both targets, a value sealed by the native
    (AWS-LC) backend and kept as a constant, and the aes-gcm vector's test is named open_decrypts_historical_aes_gcm_vector
    (ff994559).
  • The unknown_lints and clippy::unused_async_trait_impl allows are gone (e3afecb4).
  • sqlite_row_struct! refuses a #[sqlx(...)] field attribute at compile time (3cc42d74,
    da522520).
  • signing_key.rs names extenddb_core::crypto::hmac_sha256 (f4a0e740).

The items you said do not hold the PR: DescribeEndpoints is now refused by name
(3131556e); storage-sqlite's crate-wide wasm32 dead_code/unused_imports allow is gone
(36e2d440, which handles each item the allow hid where it lives; 204c6ebc and
3b93e236 then moved the native-only server factories and file-migration entry points into
server_backend.rs and migrations/file_database.rs, under one module cfg each in place of one per
item); NULL into serde_json::Value is a
decode error, as in sqlx; SqliteDbError shows the code. The eight crates ADR 0026 removed are
back in Cargo.lock for wasm32 only; I have not amended ADR 0026, and will if you want it.

Changes you did not ask for

  • crates/core/src/limits/mod.rs adds page_size (#[doc(hidden)]): DescribeStream and
    ListStreams size a page with it, so a Limit above u32::MAX keeps every shard on wasm32's
    32-bit usize, as it does natively. The SQLite Query/Scan trim saturates the same way and keeps
    main's answer for a limit below 1 (55d1a61e).
  • crates/storage/src/secret_cipher.rs takes its length rule from crypto::split_nonce, the
    check crypto::open also applies, and calls it once on each path to word its own refusal,
    with the same messages in the same order.
  • submit answers a non-string operation or body with a ValidationException instead of
    trapping.
  • The corpus grew from 77 to 272 cases: cases that record this build's answer where the server
    checks a request before dispatch, and the synchronous control plane's answers. Both runners now
    share one case schema and judging rule and self-test it on parity/runner-selftest.json.
  • The README section lists, beyond what you asked for, the linear-memory limit, the synchronous
    control plane, the stack copies hmac_sha256, seal and open can leave on wasm32, and the
    checks the server makes that this build does not.
  • CONTRIBUTING.md says a code-body migration's module-level allow(clippy::all) switches the
    wasm clippy lists off for that body.
  • crates/engine/src/backup.rs moves the ListBackups handler, and the request checks it and
    the continuous-backups handlers share with the store-backed backup handlers, to
    backup_requests.rs; backup/pitr.rs and its pitr/tests.rs move with no edit to
    backup_requests/pitr.rs and backup_requests/pitr/tests.rs; and import_export.rs moves its
    file code to import_export/files.rs. So the checks compile on wasm32. The moved functions
    keep their bodies; eight items (seven functions and a constant)
    became pub(crate), one doc link
    became plain text, and the import and export handlers now end in files::import_table and
    files::export_table, which hold the file work they did after their enabled check.

@LeeroyHannigan LeeroyHannigan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::sleep in handle_get_item and std::time::Instant::now() in store.rs. It also refuses a renamed use tokio::time as t, a std::thread::spawn and a function pointer to Instant::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 --locked and devtools/check-crate-packages pass. No native build loses an engine feature.
  • submit answers a non-string operation or body with a ValidationException. A Limit above u32::MAX returns every stream and shard on wasm32, as it does natively.

Before it merges:

  1. The corpus rules are written twice. tests/parity.rs and parity/run.mjs each implement the case schema, the request encoding and the judge. judge, read_case, read_corpus, canonical_json, substitute, request_text, json_equal, check_numbers and 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.rs already runs one Rust table on both targets, with wasm_bindgen_test on wasm32 and tokio::test natively. Please run tests/parity.rs on wasm32 the same way. run.mjs then needs only what has to be JavaScript: create and the eight checks of submit's boundary. parseJson, the JavaScript copies of the rules and runner-selftest.json can go. If a second judge has to stay, please say why in the description.

  2. The shim table fails natively under load. pool_options (wasm_shim.rs:174-176) gives every row's pool a 50 ms acquire timeout, and connect_with has to open its first connection within it. I ran it at nice 19 on 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 at nice 19 and 18 of 20 at normal priority. It runs in the required test job, 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 expect PoolTimedOut (:792, :809 and :855).

  3. raw_sql and Executor::execute now refuse :name, @name, $name and $0 placeholders. bind_all (wasm_sqlx.rs:1179-1236) refuses them before it compares the position with the argument count, and run_exec and RawSql::execute pass no arguments. sqlx-core 0.8.6 gives raw_sql and a &str no 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 a raw_sql row. Or list it with the other differences and give it a row.

Optional:

  • The zeroize features of aes and polyval are checked twice, by the assertion in crypto.rs:201-208 and by the guard step's cargo tree check. One would do.
  • The test at runtime.rs:308 repeats the new parse_request test in pre_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 fetch reads 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_all returns 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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
…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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
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.
@LeeroyHannigan LeeroyHannigan mentioned this pull request Nov 25, 2026
3 of 8 tasks
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
#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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
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.
@demohan demohan mentioned this pull request Nov 25, 2026
7 of 8 tasks
@robinnsc robinnsc mentioned this pull request Nov 25, 2026
6 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants