Skip to main content

outl_exec/wasm/
mod.rs

1//! WebAssembly sandbox — the **uniform** execution path that every
2//! language can eventually share.
3//!
4//! Today only the [`crate::runtimes::rust`] runtime uses it (because
5//! Rust has no in-process interpreter — we compile to `wasm32-wasip1`
6//! and run via wasmtime). Tomorrow the in-process interpreters
7//! (Steel, Boa, RustPython, mlua) will be swapped for WASM-built
8//! equivalents and route through the same code path.
9//!
10//! Gated behind the `wasm` Cargo feature.
11//!
12//! ## Pieces
13//!
14//! - [`engine`] — builds a `wasmtime::Engine` configured with the
15//!   uniform sandbox: WASI with no preopens / no env / no sockets,
16//!   wall-clock timeout via epoch interruption, optional instruction
17//!   limit via fuel.
18//! - [`module`] — [`WasmModule`], the adapter that takes a WASI module
19//!   binary plus a source string, runs it through wasmtime, and
20//!   produces an [`crate::ExecOutput`]. Implements
21//!   [`crate::Runtime`].
22//! - [`cache`] — `~/.cache/outl/runtimes/` on Linux,
23//!   `~/Library/Caches/outl/runtimes/` on macOS, etc.
24//!   Lazy-generated `.wasm` blobs (today: Rust source → WASM)
25//!   land here keyed by SHA-256 of the source.
26
27pub mod cache;
28pub mod engine;
29pub mod module;
30// `sha2` is now an unconditional dep (used by auto-run hashing too),
31// but cache.rs only needs it under `wasm`; nothing to change here.
32
33pub use cache::{cache_dir, cache_path_for_source};
34pub use engine::{make_engine, SandboxLimits};
35pub use module::WasmModule;