Skip to content

Cross-Binding IR

Rotifer IR is the protocol’s portability layer — an intermediate representation built on WASM with protocol-specific custom sections. It is to genes what LLVM IR is to programs.

TypeScript Gene → rotifer compile → Rotifer IR (.wasm) → any Binding
  1. Write a gene in any supported language (currently TypeScript)
  2. Compile with rotifer compile — produces a WASM binary with custom sections
  3. Run on any binding: Local CLI, Cloud (Supabase Edge Functions), Web3 (on-chain), or Edge

Rotifer IR extends standard WASM with protocol-specific metadata embedded in WASM custom sections:

SectionContents
rotifer:phenotypeGene identity, domain, input/output schemas, version
rotifer:constraintsL0 constitutional constraints — permissions, resource limits
rotifer:meteringFuel budget, memory cap, deterministic resource accounting

These sections travel with the binary. When a gene moves from Cloud to Local, its constraints and identity are preserved — no external metadata file needed.

The IR adopts a dual-layer design: WASM for computation, Rotifer-native annotations for constraints.

WASM was selected for the execution layer based on:

  • Formal specification — mathematically defined semantics, small trusted computing base
  • Sandboxed by design — linear memory model, no ambient authority
  • Near-native performance — hardware-agnostic, optimized runtimes (Wasmtime, Wasmer, WAMR)
  • Cross-platform toolchain maturity — compile from Rust, C, Go, AssemblyScript, etc.
  • Deterministic execution support — achievable with constrained instruction set

The critical safety property: any L0 constraint declared in any binding is preserved through compilation, transmission, and re-compilation. No binding can weaken a constitutional constraint.

This is what makes Rotifer IR fundamentally different from general-purpose IRs — it carries safety guarantees, not just computation logic. A gene sandboxed in Cloud remains sandboxed when it runs locally.

For the complete IR specification, see the full document on GitHub.