Skip to content

Rotifer IR Specification

Version: 0.1 (Draft)

Full Document: View on GitHub


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:

LayerResponsibilityTechnology
Execution LayerComputation logic, control flow, data manipulationWebAssembly (WASM)
Constraint LayerResource limits, security invariants, type constraintsRotifer-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
ChapterDescription
Type System9 core types with gene-aware extensions (GeneInput, GeneOutput, FitnessScore, SecurityLabel)
Instruction Set ConstraintsWASM instruction allowlist, prohibited instructions, determinism enforcement
Host Functions14 standard host functions across 4 categories (Gene lifecycle, I/O, Logging, Resource)
Security Model4-layer defense (Static → Dynamic → Cryptographic → Constitutional), malicious IR detection
Serialization FormatRotiferModule binary format with embedded constraint proofs
Compilation PipelineSource → AST → Rotifer-WASM → Constraint Verification → Signed Module
Cross-Binding InteropSemantic adapter protocol for type mapping across binding environments
VersioningSemantic versioning with backward compatibility guarantees

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.