Skip to main content

Module runtime

Module runtime 

Source
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)) with N pages covering RING_BUFFER_REGION_SIZE; the host supplies a dedicated memory whose region starts at offset 0.
  • Export memory; the host appends ceil(RING_BUFFER_REGION_SIZE / 65536) pages at instantiation and martensite.ring_buffer_ptr returns 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§

PluginInstance
A running WebAssembly plugin instance.
PluginRuntime
Preconfigured Wasmtime runtime environment for loading plugins.
PluginState
Per-instance host state shared with the Wasmtime store.

Enums§

PluginError
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.