Skip to main content

Module plugins

Module plugins 

Source
Expand description

WASM plugin runtime for Shaperail (M19).

Provides sandboxed execution of WebAssembly plugins as controller hooks. Plugins receive a JSON context and return a modified JSON context.

§Plugin Interface

WASM modules must export:

  • alloc(size: i32) -> i32 — allocate size bytes, return pointer
  • dealloc(ptr: i32, size: i32) — free previously allocated memory
  • before_hook(ptr: i32, len: i32) -> i64 — process context, return (ptr << 32) | len

Optionally:

  • after_hook(ptr: i32, len: i32) -> i64 — same interface, called after DB operation

§Sandboxing

By default, plugins have NO access to:

  • Host filesystem
  • Network
  • Environment variables
  • System clock

This is enforced by creating WASM instances without WASI capabilities.

Structs§

PluginContext
JSON context passed to WASM plugins, matching the controller Context shape.
PluginResult
Result returned from a WASM plugin hook.
PluginUser
Minimal user info passed to WASM plugins.
SandboxConfig
Configuration for plugin sandboxing.
WasmRuntime
Runtime for executing WASM plugins with sandboxing.