Skip to content

Gene Composition Algebra

Rotifer provides five composition operators that combine simple genes into complex behaviors — with compile-time type checking, structured error propagation, and fitness inheritance.

OperatorSemanticsExample
Seq(A, B, C)Sequential pipeline — output of A feeds into B, then CSearch → Summarize → Translate
Par(A, B)Parallel execution — run A and B concurrently, collect all resultsQuery 3 search providers simultaneously
Cond(p, T, F)Conditional — choose gene based on a runtime predicateLong query → deep research; short → quick search
Try(P, F)Fallback — if primary gene fails, run fallbackPremium API → free API
Transform(inner, mapper)Post-processing — run inner, then pass its output through a mapper geneFetch data → format as Markdown

Compositions are type-checked at compile time. The output schema of gene A must be compatible with the input schema of gene B for Seq(A, B) to compile. Incompatible schemas produce errors before any code runs.

Seq(search, translate)
├─ search.outputSchema: { results: string[] }
└─ translate.inputSchema: { text: string }
✗ Schema mismatch — compile error

Composed genes inherit fitness from their components. The Arena evaluates compositions as a whole:

  • Seq(A, B) — fitness reflects end-to-end performance (latency is additive, correctness is multiplicative)
  • Par(A, B) — fitness reflects aggregate quality (latency is max, results are merged)
  • Try(P, F) — fitness accounts for fallback rate (frequent fallbacks reduce score)

Tool registries let you chain tools in application code. Rotifer makes composition a first-class protocol primitive:

  • The protocol validates compositions, not just individual genes
  • Compositions compete in the Arena alongside atomic genes
  • An agent can discover and adopt a pre-composed pipeline, not just individual tools