forge_host/lib.rs
1//! WASM plugin runtime.
2//!
3//! Loads sandboxed WASM components, enforces fuel / memory / epoch limits,
4//! provides the `host-api` imports declared in `wit/host.wit`, and invokes
5//! plugin exports.
6//!
7//! # Sandbox
8//!
9//! Plugins receive **no** filesystem, network, clock, RNG, environment, or
10//! process state. The only host imports are `log` and `case-convert`. WASI
11//! imports are not linked. See ADR-0001 and ADR-0008.
12//!
13//! # Resource limits
14//!
15//! Every plugin invocation has its own `Store` / `StoreLimits` / `wasmtime`
16//! resource budget:
17//!
18//! * **Fuel** — instructions executed. `consume_fuel = true` on the engine.
19//! * **Memory** — bytes allocated by guest linear memory. Enforced via
20//! `wasmtime::ResourceLimiter`.
21//! * **Wall-clock time** — enforced via epoch interruption. The engine has a
22//! shared epoch counter ticked by a background thread on a fixed cadence;
23//! each store sets `epoch_deadline_trap()` at the appropriate count.
24
25#![forbid(unsafe_code)]
26
27pub mod filesystem;
28mod runtime;
29
30pub use runtime::{
31 Engine, EngineError, FileMode, GenerationOutput, HostState, Limits, LoadError, OutputFile,
32 Plugin, PluginKind, ResourceKind, StageError, TransformOutput,
33};