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.
How It Works
Section titled “How It Works”TypeScript Gene → rotifer compile → Rotifer IR (.wasm) → any Binding- Write a gene in any supported language (currently TypeScript)
- Compile with
rotifer compile— produces a WASM binary with custom sections - Run on any binding: Local CLI, Cloud (Supabase Edge Functions), Web3 (on-chain), or Edge
Custom Sections
Section titled “Custom Sections”Rotifer IR extends standard WASM with protocol-specific metadata embedded in WASM custom sections:
| Section | Contents |
|---|---|
rotifer:phenotype | Gene identity, domain, input/output schemas, version |
rotifer:constraints | L0 constitutional constraints — permissions, resource limits |
rotifer:metering | Fuel 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.
Why WASM?
Section titled “Why WASM?”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
Constitutional Unity Invariant
Section titled “Constitutional Unity Invariant”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.
Full Specification
Section titled “Full Specification”For the complete IR specification, see the full document on GitHub.