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.
Operators
Section titled “Operators”| Operator | Semantics | Example |
|---|---|---|
Seq(A, B, C) | Sequential pipeline — output of A feeds into B, then C | Search → Summarize → Translate |
Par(A, B) | Parallel execution — run A and B concurrently, collect all results | Query 3 search providers simultaneously |
Cond(p, T, F) | Conditional — choose gene based on a runtime predicate | Long query → deep research; short → quick search |
Try(P, F) | Fallback — if primary gene fails, run fallback | Premium API → free API |
Transform(inner, mapper) | Post-processing — run inner, then pass its output through a mapper gene | Fetch data → format as Markdown |
Type Safety
Section titled “Type Safety”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 errorFitness Inheritance
Section titled “Fitness Inheritance”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)
Why This Matters
Section titled “Why This Matters”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
Further Reading
Section titled “Further Reading”- Composition Patterns Guide — practical examples and patterns