1.7 KiB
1.7 KiB
ADR 002: Feature-gated WASM compile hook (ctx.bareOsWasmKernelCompile)
Status
Accepted (2026-04-04)
Context
Operators asked for a bounded path to validate WebAssembly modules in the same runtime that runs the kernel, without pulling Node.js builtins into booter sources or silently loading foreign code.
Decision
- Expose
ctx.bareOsWasmKernelCompile(buf, opts?)only when the host setsBARE_OS_WASM_KERNEL=1(ortrue), copied into sessionshellEnvlike other passthrough keys. - Implementation calls
WebAssembly.compileon a size-cappedUint8Array(default max 512 KiB; override viaopts.maxBytes). No instantiation, no imports, and no execution — compile-only probe suitable for static validation and export-name listing when the engine exposesWebAssembly.Module.exports. - Code lives in
packages/bare-os-booter/lib/bare-os-wasm-kernel.jsand usesglobalThisonly (Bare/V8).
Consequences
- Security: Mis-toggling
BARE_OS_WASM_KERNELonly enables compilation CPU work within caps; it does not grant syscall bridges. Full guest loaders remain out of scope for this ADR. - Optional dep:
bare-vmremains an optional package for future instantiation work; this ADR does not require it on the compile path. - Docs: Environment appendix lists
BARE_OS_WASM_KERNEL; POSIX declared profile remains the normative “honest POSIX” surface.
Related
docs/architecture/POSIX_DECLARED_PROFILE.mddocs/reference/environment-and-posix-appendix.mdpackages/bare-os-booter/CHANGELOG.md(ctx 1.33.0)