Skip to main content

Module wasm_runtime

Module wasm_runtime 

Source
Expand description

WASM-Sandboxed Multi-Tenant Plugin Runtime

This module replaces the unsafe libloading-based dynamic plugin loader with a secure, sandboxed WASM runtime.

§Security Model

  • Memory Isolation: Each plugin runs in its own linear memory
  • Fuel Limits: Instruction counting prevents infinite loops
  • Capability-Based Access: Plugins can only access allowed resources
  • No Syscalls: WASM code cannot directly access filesystem/network

§Performance

  • Target overhead: ~100ns per host function call
  • Memory-mapped WASM modules for fast instantiation
  • Pooled instances for frequently-used plugins

§Architecture

┌─────────────────────────────────────────────────────────────┐
│                    WASM Plugin Runtime                       │
│  ┌─────────────────────────────────────────────────────┐    │
│  │              WasmPluginRegistry                      │    │
│  │   ┌──────────┐ ┌──────────┐ ┌──────────┐            │    │
│  │   │Plugin A  │ │Plugin B  │ │Plugin C  │            │    │
│  │   │(WASM)    │ │(WASM)    │ │(WASM)    │            │    │
│  │   └────┬─────┘ └────┬─────┘ └────┬─────┘            │    │
│  └────────┼────────────┼────────────┼───────────────────┘    │
│           │            │            │                        │
│  ┌────────┴────────────┴────────────┴───────────────────┐    │
│  │              Host Function ABI                        │    │
│  │   soch_read, soch_write, vector_search, emit_metric   │    │
│  └──────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘

Structs§

WasmInstanceConfig
Configuration for a WASM plugin instance
WasmObservabilityPlugin
Wrapper to use a WASM plugin as an ObservabilityExtension
WasmPluginCapabilities
Capabilities granted to a WASM plugin
WasmPluginInstance
A WASM plugin instance
WasmPluginRegistry
Registry for WASM plugins
WasmPluginStats
Statistics for a WASM plugin instance

Enums§

WasmPluginState
State of a WASM plugin instance
WasmValue
WASM value types for function arguments and returns