WebAssembly Integration#
MuduDB runs user procedures as WebAssembly components inside a WASI sandbox. This provides portability, isolation, and multi-language support while keeping database access under kernel control.
Component model#
A MuduDB procedure is compiled to a WebAssembly component that targets the wasm32-wasip2 platform. The component imports a small set of host-provided syscalls and exports the procedure functions marked with /**mudu-proc**/.
At build time the mtp transpiler generates the component’s import/export surface: the component imports the host syscall interface (mududb:api/system for the sync world, mududb:async-api/system for the async world) and exports one mp2-<name> entry point per procedure, matching the signature the runtime loader expects.
WASI sandbox#
Procedures execute inside a WASI sandbox with the following properties:
Database access is available only through explicit kernel syscalls.
The kernel mediates all network, file, and storage access.
Resource limits (memory, CPU, syscalls) can be enforced per procedure invocation.
Language support#
The runtime hosts six guest languages: Rust (the primary procedure language), AssemblyScript, C#, Python, C, and Go. In principle, any language that can emit WASI components can be supported in the future.
Language |
Target |
Notes |
|---|---|---|
Rust |
|
Primary supported language; bindings via |
AssemblyScript |
WASI component |
Supported via the |
C# |
WASI component |
Built with componentize-dotnet (.NET wasi-wasm target). |
Python |
WASI component |
Built with componentize-py; |
C |
WASI component |
Built with a wasi-sdk clang toolchain. |
Go |
WASI component |
Built with TinyGo. |
Guest bindings#
Guest bindings are generated by mgen from the WIT interface definitions in mudu_binding/wit/, the single source of truth for the guest/host ABI. In-repo Rust procedures reach them through sys_interface and the mududb SDK facade; each guest language vendors its own generated codec.
Runtime limits#
The runtime can enforce per-procedure limits for:
memory usage,
CPU budget (fuel) and wall-clock timeout,
number of host calls (syscalls),
input and output sizes,
concurrent invocations, globally and per app.
These limits help isolate user code from the kernel and from other procedures.
Package format#
Compiled components are packaged into .mpk archives together with DDL, descriptors, and optional initialization data. See Application Packages and the MPK Manifest Contract.
The configuration parser accepts p3, but procedure export-name selection currently returns NotImplemented for P3. Use component_target = "p2" for the documented invocation path.