8000 feat(wasi): Phase 8.1b — wasm32-wasip1 server-side WASM support by adityamukho · Pull Request #152 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

feat(wasi): Phase 8.1b — wasm32-wasip1 server-side WASM support - #152

Merged
adityamukho merged 10 commits into
mainfrom
feat/phase-8-1b
Apr 18, 2026
Merged

adityamukho merged 10 commits into
mainfrom
feat/phase-8-1b

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Closes #130.

What

Compiles Minigraf to wasm32-wasip1 with a working in-memory REPL, tested in CI by both Wasmtime and Wasmer.

Changes

  • Cargo.toml: Narrowed target_arch = "wasm32" dep/dev-dep blocks to all(target_arch = "wasm32", not(target_os = "wasi")) — prevents uuid's js feature (and wasm-bindgen-test) from applying to WASI targets where there is no JavaScript engine.
  • src/main.rs: Added #[cfg(target_os = "wasi")] branch that opens an in-memory database and runs the REPL. File-backed storage is out of scope for WASI (in-memory only per design decision).
  • src/db.rs: Added #[cfg(all(target_os = "wasi", test))] smoke test, run via CARGO_TARGET_WASM32_WASIP1_RUNNER.
  • .github/workflows/wasm-wasi.yml: Rewrote as a single job: build → WASI unit tests (--lib via Wasmtime runner) → Wasmtime smoke (transact + query, output verified) → Wasmer smoke (transact + query, output verified).
  • .wiki/Use-Cases.md: Added Phase 8.1a BrowserDb usage guide and Phase 8.1b WASI section (build/run/constraints/embedding). Pushed to wiki repo separately.
  • README.md: Updated phase status markers to reflect 8.1a/b complete.

Design decisions

  • In-memory only for WASI: File-backed storage under WASI would require threading FileBackend/WAL through new cfg gates across db.rs, lib.rs, storage/ — significant complexity for a use case better served by native binaries. WASI value is as an embeddable library.
  • target_os = "wasi" not target_arch = "wasm32": The broader gate also fires for browser WASM (wasm32-unknown-unknown) where wasm-pack requires #[wasm_bindgen_test] not #[test]. WASI-specific gating keeps targets cleanly separated.
  • cargo test --lib: Integration tests in tests/ include concurrency_test.rs which uses std::thread::spawn — unsupported under WASI Preview 1. --lib scopes the run to in-crate tests only.

Testing sign-off checklist

  • cargo build --target wasm32-wasip1 --release succeeds (CI)
  • cargo test --target wasm32-wasip1 --lib passes via Wasmtime runner (CI)
  • Wasmtime smoke test (transact + query, output verified) passes (CI)
  • Wasmer smoke test (transact + query, output verified) passes (CI)
  • cargo test (native) still passes (CI)
  • cargo build --target wasm32-unknown-unknown --features browser still passes (CI)

🤖 Generated with Claude Code

adityamukho and others added 7 commits April 18, 2026 10:07
…wasm only

wasm32-wasip1 (WASI) has no JavaScript engine. The previous cfg gate
'target_arch = wasm32' applied to WASI too, pulling in wasm-bindgen and
getrandom's JS path. Narrowed to 'all(target_arch = wasm32, not(target_os = wasi))'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous wasm32 branch returned Ok(()) immediately, making the
binary a no-op under WASI. Add a target_os = wasi branch that opens
an in-memory Minigraf database and runs the REPL via stdin/stdout.
File-backed storage is out of scope for WASI (in-memory only).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Uses #[cfg(all(target_os = "wasi", test))] to avoid firing in the browser
WASM environment where wasm-pack requires #[wasm_bindgen_test] instead.
Run via: CARGO_TARGET_WASM32_WASIP1_RUNNER='wasmtime run --dir /tmp'
cargo test --target wasm32-wasip1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…smer

Previous workflow had a fragile two-job split with artifact upload/download
and no Wasmer step. New workflow: build -> WASI unit tests (via
CARGO_TARGET_WASM32_WASIP1_RUNNER) -> Wasmtime smoke -> Wasmer smoke,
all in one job.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
codecov Bot commented Apr 18, 2026 •
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.41%. Comparing base (789d82a) to head (2ca5405).
⚠️ Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (789d82a) and HEAD (2ca5405). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (789d82a) HEAD (2ca5405)
branch-coverage 1 0
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #152      +/-   ##
==========================================
- Coverage   90.44%   83.41%   -7.03%     
==========================================
  Files          26       26              
  Lines       15085     4837   -10248     
  Branches      562        0     -562     
==========================================
- Hits        13644     4035    -9609     
+ Misses       1369      802     -567     
+ Partials       72        0      -72     
Flag Coverage Δ
branch-coverage ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/db.rs 90.03% <ø> (-4.97%) ⬇️
src/main.rs 0.00% <ø> (ø)
src/storage/btree_v6.rs 80.76% <ø> (-9.21%) ⬇️
src/storage/cache.rs 86.53% <ø> (-4.98%) ⬇️

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

adityamukho and others added 3 commits April 18, 2026 15:11
Triple form [:e1 :name "hello"] with keyword :e1 is a valid entity id.
Map form with bare string "e1" is not accepted by edn_to_entity_id.
Under WASI p1, a panic aborts the process (no unwind), so the
expect("transact") on the failing execute() killed the entire test run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WASI p1 has no thread support — thread::spawn panics immediately,
which under WASI p1 (no unwind) aborts the entire test process.

Gate test_concurrent_range_scans_correctness in btree_v6.rs and
test_concurrent_reads in cache.rs so they are excluded from
the wasm32-wasip1 test binary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Map form {:db/id "eid-1" :name "Alice"} is invalid — edn_to_entity_id
only accepts keywords or UUID strings. Triple form [:alice :name "Alice"]
uses a keyword entity id which is always valid.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adityamukho
adityamukho merged commit 7872db2 into main Apr 18, 2026
26 checks passed
@adityamukho
adityamukho deleted the feat/phase-8-1b branch April 18, 2026 09:53
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.

Phase 8.1b: Server-side WASM support (wasm32-wasip1 / WASI)

1 participant

0