docs/book/src/architecture/decisions/ADR-009-wit-wasmtime-plugin-execution.md
This ADR supersedes ADR-003. ADR-003
recorded the initial Extism bridge. The current accepted architecture is
a WIT-defined WASM Component Model surface hosted directly by wasmtime.
Extism was a useful bootstrap for proving that external WASM plugins could appear as ZeroClaw tools. It also gave the project a simple JSON protocol and a permission-gated host-function model.
As the microkernel architecture matured, the plugin surface needed a stronger compatibility boundary:
The WASM Component Model and WIT provide that boundary. Direct
wasmtime integration gives the host enough control to select backends,
attach WASI Preview 2 surfaces, enforce resource limits, and bridge
guest worlds into ZeroClaw's Rust traits.
ZeroClaw's plugin ABI is based on WASM components described by WIT
interfaces under wit/v0. The host uses direct wasmtime component
model plumbing in crates/zeroclaw-plugins, with per-world bridges for
tools, channels, and memory backends.
The execution model is:
wit/v0/tool.wit, channel.wit, and memory.wit define the guest
contracts.crates/zeroclaw-plugins/src/component.rs owns shared component host
plumbing, store state, resource limits, WIT bindings, and WASI wiring.wasm_tool.rs, wasm_channel.rs, and wasm_memory.rs bridge those
worlds back into the Rust Tool, Channel, and Memory traits.manifest.toml declares the plugin name, version,
capability type, permissions, config, and signature material.Execution backend selection is explicit:
plugins-wasm enables the plugin host surface in the main workspace.plugins-wasm-runtime-only enables the smallest runtime-only host.plugins-wasm-cranelift enables Cranelift compilation where supported.plugins-wasm-pulley enables the Pulley interpreter for targets where
Cranelift is unavailable or undesirable.Host surfaces are permission-gated:
HttpClient is the permission that attaches outbound HTTP state and
links WASI HTTP.ConfigRead is required before the host injects a plugin's resolved
config section under __config.Positive:
Negative:
wasmtime component integration is more complex than the
original Extism bridge.Follow-up:
wit/v0/wit/VERSIONING.mdcrates/zeroclaw-plugins/src/component.rscrates/zeroclaw-plugins/src/wasm_tool.rscrates/zeroclaw-plugins/src/wasm_channel.rscrates/zeroclaw-plugins/src/wasm_memory.rscrates/zeroclaw-plugins/src/host.rscrates/zeroclaw-plugins/src/signature.rscrates/zeroclaw-infra/src/net_guard.rs