Rotifer IR Specification
Version: 0.1 (Draft)
Full Document: View on GitHub
Abstract
Section titled “Abstract”Rotifer IR (Rotifer Intermediate Representation) is the cross-binding gene portability layer of the Rotifer Protocol. It enables genes born in one binding environment (e.g., Web3) to be compiled and executed in an entirely different environment (e.g., Cloud, Edge, TEE) — without manual rewriting.
Rotifer IR is to genes what LLVM IR is to programs, or JVM bytecode is to Java classes: an abstract, verifiable, cross-platform compilable logic representation layer. However, unlike general-purpose compiler IRs, Rotifer IR is Gene-Aware — its type system natively understands gene input/output patterns, resource constraints, and security boundaries.
Technical Decision: WASM + Rotifer Constraint Layer
Section titled “Technical Decision: WASM + Rotifer Constraint Layer”The IR adopts a dual-layer design:
| Layer | Responsibility | Technology |
|---|---|---|
| Execution Layer | Computation logic, control flow, data manipulation | WebAssembly (WASM) |
| Constraint Layer | Resource limits, security invariants, type constraints | Rotifer-native custom annotations |
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
Key Chapters
Section titled “Key Chapters”| Chapter | Description |
|---|---|
| Type System | 9 core types with gene-aware extensions (GeneInput, GeneOutput, FitnessScore, SecurityLabel) |
| Instruction Set Constraints | WASM instruction allowlist, prohibited instructions, determinism enforcement |
| Host Functions | 14 standard host functions across 4 categories (Gene lifecycle, I/O, Logging, Resource) |
| Security Model | 4-layer defense (Static → Dynamic → Cryptographic → Constitutional), malicious IR detection |
| Serialization Format | RotiferModule binary format with embedded constraint proofs |
| Compilation Pipeline | Source → AST → Rotifer-WASM → Constraint Verification → Signed Module |
| Cross-Binding Interop | Semantic adapter protocol for type mapping across binding environments |
| Versioning | Semantic versioning with backward compatibility guarantees |
Constitutional Unity Invariant
Section titled “Constitutional Unity Invariant”The most critical property of Rotifer IR:
Any constraint declared at L0 in any binding MUST be preserved through IR compilation, transmission, and re-compilation. No binding may weaken a constitutional constraint.
This is what makes Rotifer IR fundamentally different from general-purpose IRs — it carries safety guarantees, not just computation logic.
For the complete specification (913 lines, 11 chapters), see the full document on GitHub.