Hot-reloadable adaptive planner with evolutionary learning for self-evolving agent systems.
Singularity Genesis is an adaptive planning and evolutionary improvement system that sits on top of Singularity Workflow to automatically optimize how task DAGs are generated and executed.
Key Features:
- π§ Adaptive Planning - Goals β Task DAGs using learned patterns or LLM
- π Evolutionary Learning - Continuously improves planner variants via fitness-driven evolution
- π₯ Hot Reload - Live code updates without stopping running workflows
- π Measurable Fitness - Success Γ Speed Γ Cost Γ Determinism scoring
- π― Deterministic Replay - Verify and improve reproducibility
βββββββββββββββββββββββββββββββββββββββ
β singularity.genesis (THIS) β
β ββ AdaptivePlanner β β LLM/Pattern-based planning
β ββ EvolutionEngine β β Fitness, mutation, selection
β ββ HotReloadManager β β Live code updates
ββββββββββββββββ¬βββββββββββββββββββββββ
β emits task graphs
β
βββββββββββββββββββββββββββββββββββββββ
β singularity_workflow (SPINE) β β Stable runtime
β ββ Orchestrator (HT-DAG) β
β ββ DAG Execution β
β ββ Lineage Tracking β
βββββββββββββββββββββββββββββββββββββββ
Converts goals into task DAGs using:
- Pattern Cache - Fast lookup of successful patterns (ETS)
- LLM Integration - Claude, OpenAI, or local models for novel goals
- Automatic Learning - Updates patterns based on execution outcomes
{:ok, task_graph} = AdaptivePlanner.plan(
"Build authentication system",
%{resources: %{workers: 8}}
)Improves planner variants through:
- Fitness Evaluation - Score variants on benchmark suite
- Tournament Selection - Pick best performers
- Genetic Operators - Mutation and crossover for breeding
- Hot Reload - Load improved variants without downtime
{:ok, result} = EvolutionEngine.trigger_evolution(
population_size: 10,
survivors: 3,
mutation_rate: 0.3
)Live code updates via:
- Module Generation - Create new planner from variant parameters
- Safe Reload - Compile, verify, load without affecting running workflows
- Rollback Support - Return to previous version if needed
- History Tracking - Audit trail of all reloads
{:ok, result} = HotReload.reload_planner(variant)
{:ok, _} = HotReload.rollback(steps: 1)- ONE RUNTIME - Never modify singularity_workflow, only emit task graphs
- HOT RELOAD - Planner logic reloads live, workflows continue uninterrupted
- EVOLUTIONARY MEMORY - Every DAG run stored with fitness in lineage
- MEASURABLE FITNESS - Success, speed, cost, determinism tracked per generation
- SAFE MUTATION - Planner mutates policies, not execution semantics
- DETERMINISTIC REPLAY - Use Lineage.replay/2 for exact reproduction
Multi-dimensional fitness from execution metrics:
fitness = 0.5 * success_score +
0.3 * speed_score +
0.1 * cost_score +
0.1 * determinism_score
Where:
- Success - 1.0 if completed, 0.0 if failed
- Speed - 1.0 / (duration_sec + 1)
- Cost - 1.0 / (task_count + 1)
- Determinism - 1.0 if replay matches, 0.0 otherwise
def deps do
[
{:singularity.genesis, git: "https://github.com/Singularity-ng/singularity.genesis.git"}
]
end# Plan with learned patterns or LLM fallback
{:ok, task_graph} = Singularity.Evolution.AdaptivePlanner.plan(
"Build REST API for product catalog",
%{resources: %{workers: 4}}
)# Automatically plan, execute, and improve
{:ok, result} = Singularity.Evolution.AdaptivePlanner.execute_and_learn(
"Build REST API for product catalog",
MyApp.Repo,
learn: true
)# Trigger evolution cycle
{:ok, evolution} = Singularity.Evolution.EvolutionEngine.trigger_evolution(
population_size: 10,
survivors: 3,
mutation_rate: 0.3
)
IO.puts("Best fitness: #{evolution.avg_fitness}")
IO.puts("Generation: #{evolution.generation}")# Live reload improved planner
{:ok, reload} = Singularity.Evolution.HotReload.reload_planner(new_variant)
# Rollback if needed
{:ok, _} = Singularity.Evolution.HotReload.rollback()# config/config.exs
config :singularity.genesis,
evolution: [
enabled: true,
auto_evolve: true,
evolution_interval_hours: 24,
population_size: 20,
survivors: 5
],
llm: [
default_provider: :claude,
claude: [
api_key: System.get_env("ANTHROPIC_API_KEY"),
model: "claude-sonnet-4-5-20250929",
max_tokens: 4096
]
],
pattern_cache: [
max_size: 10_000,
eviction_policy: :lru,
persist_to_db: true
]Singularity Genesis uses the Lineage API from Singularity Workflow:
# Get execution history for learning
{:ok, lineage} = Singularity.Workflow.Lineage.get_lineage(run_id, repo)
# Replay workflow for determinism check
{:ok, replay_run_id} = Singularity.Workflow.Lineage.replay(lineage, step_functions, repo)
# Calculate fitness
fitness = FitnessEvaluator.calculate(lineage)# Setup
mix deps.get
mix ecto.create
# Test
mix test
# Code quality
mix quality # Runs format, credo, dialyzer, sobelow
mix test.coverage
# Docs
mix docs- Unit Tests - Individual functions with mocks
- Integration Tests - Full planning β execution β learning cycles
- Benchmark Tests - Evolution effectiveness on standard problems
- Core module scaffolding
- AdaptivePlanner implementation (Week 1-2)
- LLM client integration (Week 2-3)
- Pattern cache and learning (Week 3-4)
- EvolutionEngine implementation (Week 4-5)
- Hot reload system (Week 5-6)
- Benchmark suite and metrics (Week 6-7)
- Production hardening (Week 7-8)
MIT
- Singularity Workflow - DAG execution and lineage tracking
- Evo.txt - Complete specification document
- Elixir Documentation