Skip to content

move TS protobuf logic to Rust using wasi p2 - #658

Draft
davidhewitt wants to merge 4 commits into
mainfrom
dh/wasi-shim
Draft

move TS protobuf logic to Rust using wasi p2 #658
davidhewitt wants to merge 4 commits into
mainfrom
dh/wasi-shim

Conversation

@davidhewitt

@davidhewitt davidhewitt commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

I have a theory that we should be able to migrate some of the typescript components to Rust for the WASM/browser pathway, and that might help with tracing the WASM module in #629

This is somewhat vibe coded, pushing to get feedback and also to review it myself.


Summary by cubic

Move protobuf decoding and dispatch from TypeScript to Rust and ship a WIT-defined WASI 0.2 component with generated JS bindings. Workers now instantiate precompiled component modules and exchange typed requests/events, removing JS-side framing.

  • Refactors

    • Replaced the wasip1 reactor/stdio RPC with a component export worker.dispatch defined in wit/runtime.wit; Rust returns {status, events}.
    • Added wit-bindgen in Rust and @bytecodealliance/jco to wrap the core Wasm and emit JS bindings; split core modules under dist/worker/component/* with checked-in .d.ts.
    • Swapped @bjorn3/browser_wasi_shim for @bytecodealliance/preview2-shim; no host FS/env/network; process exit is denied.
    • Moved ChildEvent decoding and value conversion to Rust using a flat value arena; removed TS wire codec (proto.ts) and JS deframing.
    • Worker hosts/entries instantiate ComponentModules (4 core WebAssembly.Modules) and serve typed dispatch; Node entry runs from .js.
  • Migration

    • Build/CI: npm run build:wasm builds the component; make check-wasm-types verifies generated declarations; artifacts live under dist/worker/component (monty.component.js + 4 core .wasm).
    • Loading/API: loadModule() now returns a modules map; use createWorkerPool(modules) (was createWorkerPool(module)).
    • Tests: make test-browser runs the wasm path in headless Chromium.

Written for commit cbe8da6. Summary will update on new commits.

Review in cubic

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 9308 uncovered lines.
❌ Project coverage is 83.38%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    83.39%    83.38%    -0.01%
==========================================
  Files          235       235         —
  Lines        56018     56018         —
  Branches    118536    118536         —
==========================================
+ Hits         46713     46710        -3
- Misses        9305      9308        +3
- Partials      3577      3575        -2

Generated by Codecov Action

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 33 untouched benchmarks
⏩ 16 skipped benchmarks1


Comparing dh/wasi-shim (cbe8da6) with main (ce8949f)

Open in CodSpeed

Footnotes

  1. 16 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

1 participant