Skip to content

SNIFs verisim WASM bridge — single boundary for BEAM-side cross-language access #86

Description

@hyperpolymath

Background

Architectural plan agreed 2026-06-01: BEAM-side cross-language access to VeriSimDB (Gleam, Erlang, future LFE / Hamler / Akula) flows through the SNIFs WASM bridge rather than per-language SDKs. Closes the "do we ship a Gleam SDK?" question with a single principled answer: no, ship a SNIF-compatible WASM module that any BEAM language can call via wasmex.

Context: SNIFs = hyperpolymath/snifs — Safe NIFs via WebAssembly Sandboxing. WASM guest faults become BEAM error tuples instead of killing the whole VM. Native code (Zig today; the verisim core conceptually) compiles to WASM and loads through wasmex. Crash-isolated NIF semantics for free.

Shape of the bridge

Two delivery options, pick when ready:

Option A — verisim-core compiled to WASM directly.

  • Carve out the rust-core API surface that doesn't need tokio (or replace tokio with tokio::runtime::Runtime::new() in the host-driver), compile to wasm32-unknown-unknown or wasm32-wasi.
  • Publish a verisim.wasm artefact per release.
  • SNIF wrapper exposes the typed API as BEAM NIFs; any BEAM language (Elixir, Gleam, Erlang, LFE) calls them.

Option B — verisim-api as the WASM target.

  • Compile the HTTP/JSON API gateway to WASM; SNIF wraps that and serves it locally.
  • Less invasive (no need to refactor for async-WASM), but adds JSON encode/decode hop per call.

Recommendation: Option A long-term, B as the v0 if it ships faster.

What this unblocks / replaces

  • Gleam SDK (now removed in PR chore(rot): flush silent failures + drop Gleam SDK #85) — replaced by Gleam ↔ wasmex ↔ verisim.wasm
  • Future Erlang / LFE / Hamler / Akula support — free once the WASM module ships
  • Reduces SDK matrix tracking burden from 6 → 5 (Rust, Elixir, ReScript, Julia, Zig stay first-class)
  • Aligns with the vcl-ut Tier-1 recompute-PCC pattern (fail-closed WASM module the consumer re-runs)

Dependencies / sequence

  1. Decide between Option A and Option B above (owner)
  2. Spike: minimal SNIF integration with a stub verisim WASM (1-2 days)
  3. Define which rust-core API surface goes through WASM vs stays Rust-native (architectural — likely OctadStore, DriftCalculator, Normalizer, but NOT planner/optimizer or async federation)
  4. Wire vcl-ut wire-codec into the WASM boundary for query-shaped calls
  5. Ship a single verisim.wasm per release; publish SNIF wrapper as a hex package
  6. Document in docs/architecture/snifs-bridge.adoc (currently a planned doc)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions