ReviewOS

home-lang/home

fix(runtime): execute WASI modules passed as entrypoints

#735
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Tracks a focused sub-gap from #66.

Differential behavior

packages/runtime/test/test/js/bun/wasm/wasi.test.js currently reports 1 pass / 1 fail in Home. Executing hello-wasi.wasm exits 0 with empty stdout, while pinned Bun exits 0 and prints hello world\n. The separate WASI preopen security case already passes.

Root cause

Home detects a main .wasm module and stashes its bytes on globalThis.wasmSourceBytes, but returns an empty ESM source. Bun live source returns its embedded src/js/wasi-runner.js, which constructs node:wasi, compiles and instantiates the module, starts it, and exits with the WASI result.

Port

  • Own the exact Bun runner as a runtime asset within Home package boundaries.
  • Return it as static ESM source for main .wasm entrypoints.
  • Preserve existing .file loader behavior for imported WebAssembly assets.
  • Verify the focused WASI corpus test under the memory guard.

A bounded debug build reaches whole-program code generation but is currently stopped by the fixed 3840 MB guard; the ceiling will not be raised.

9 days ago

Port landed on main in 3f4e46bff (fix(runtime): execute WASI entrypoints (#735)).

Validation completed:

  • packages/runtime/src/jsc/wasi-runner.js is byte-identical to live Bun src/js/wasi-runner.js.
  • The loader returns that asset only for the main .wasm module and preserves .file behavior for imported WebAssembly.
  • A 768 MB-capped isolated run through Home using the same hello-wasi.wasm bytes printed hello world\n and exited 0, validating Home node:wasi, compilation, instantiation, and wasi.start.
  • git diff --check passed.

The incremental full debug build reached whole-program code generation but the guard stopped it at 3859 MB against the fixed 3840 MB ceiling (host 35%). The cap was not raised. Keep this issue open until a fresh runtime binary can run wasi.test.js end to end.

9 days ago

Verified end to end on the fresh ReleaseFast runtime at current main (bae99f883):

  • implementation remains in 3f4e46bff;
  • unchanged js/bun/wasm/wasi.test.js: 2 passed, 0 failed;
  • the WASI entrypoint prints hello world\n, while the preopen escape-security case also passes;
  • no test edits, skips, timeout changes, or loader workarounds were used.

Closing this focused checkpoint as complete. Parent parity tracking continues in #66.

Sign in to comment on this issue.