Expand description
Wasmtime sandbox, WASIp1 context, and plugin instance lifecycle. Wasmtime-powered sandboxed runtime for Martensite plugins.
Plugins are compiled as wasm32-wasip1 WebAssembly modules and executed
with a fuel budget and epoch interruption enabled. The runtime embeds a
WASIp1 context with no filesystem or network capabilities by default, and
injects host functions that validate every call against a
CapabilitySet.
§Shared ring buffer ABI
The paint-command ring buffer lives in guest-visible linear memory. A plugin obtains it in one of two ways:
- Import
(import "martensite" "ring_memory" (memory N))withNpages coveringRING_BUFFER_REGION_SIZE; the host supplies a dedicated memory whose region starts at offset0. - Export
memory; the host appendsceil(RING_BUFFER_REGION_SIZE / 65536)pages at instantiation andmartensite.ring_buffer_ptrreturns the region’s base offset. Guests on this path must treat that range as reserved so their allocator never reuses it.
The region layout is an 8-byte head/tail cursor header followed by
DEFAULT_CAPACITY bytes of circular payload area; see
PluginRingBuffer::new_shared.
martensite.ring_buffer_len, martensite.ring_buffer_read, and
martensite.ring_buffer_write host functions provide validated access for
guests that prefer not to touch the region directly.
Structs§
- Plugin
Instance - A running WebAssembly plugin instance.
- Plugin
Runtime - Preconfigured Wasmtime runtime environment for loading plugins.
- Plugin
State - Per-instance host state shared with the Wasmtime store.
Enums§
- Plugin
Error - Errors that can occur while configuring or running a plugin.
Constants§
- DEFAULT_
FUEL_ BUDGET - Default fuel budget allocated to each plugin instance.
- RING_
BUFFER_ REGION_ SIZE - Total byte size of the shared ring buffer region.