# evomap/evolver architecture

> Architecture diagram of the GitHub repository evomap/evolver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/evomap/evolver
- Repository: https://github.com/evomap/evolver

## Overview

1. **What this repo is**
   Evolver is a Node.js 18+ CLI engine for agent self-evolution. Its primary job is not to edit code directly, but to read local history/signals, choose a protocol asset, and emit a structured GEP prompt plus audit events.

2. **Top-level entry and runtime shape**
   `index.js` is the main CLI entrypoint. It supports standalone runs, review mode, and looping/daemon mode. In loop mode it can also emit text directives like `sessions_spawn(...)` that only become executable when consumed by a host runtime such as OpenClaw.

3. **Core orchestration path**
   `src/evolve.js` is the central coordinator. It gathers local signals, selects an evolution strategy, invokes the GEP selector, builds the prompt, and records the resulting evolution event into local memory. This is the main dataflow: local logs/signals in, prompt and audit artifact out.

4. **GEP is the core domain model**
   Most of the architecture lives under `src/gep/`. This subsystem models the protocol objects and operations around **Genes**, **Capsules**, and **Events**. The bundled canonical assets live in `assets/gep/` as `genes.json`, `capsules.json`, and `events.jsonl`, which are the local seed store for evolution decisions.

5. **Selection, mutation, and prompt assembly**
   Within `src/gep/`, modules such as `selector.js`, `mutation.js`, `strategy.js`, `prompt.js`, `candidateEval.js`, and `curriculum.js` shape how the system scores signals and turns them into a GEP-compliant prompt. This is the “decision engine” that picks reusable experience assets instead of generating free-form instructions.

6. **State, memory, and evidence trail**
   Evolver persists local runtime evidence in a memory-oriented layer: `assetStore`, `memoryGraph`, `narrativeMemory`, `executionTrace`, `assetCallLog`, `learningSignals`, and related helpers. The README’s `./memory/` directory is the externalized boundary for logs, signals, and `EvolutionEvent` history.

7. **Security and safety boundary**
   The repo draws a strong line between read-only evolution and the one place that can execute commands: `src/gep/solidify.js` and the validator subsystem. Validation commands are restricted by prefix/syntax checks, timeouts, and repository scoping, and unsafe A2A asset promotions are rejected. Supporting modules like `sanitize`, `policyCheck`, `shield`, `integrityCheck`, and `security`-related tests reinforce this boundary.

8. **Validation subsystem**
   `src/gep/validator/` contains the sandboxed validation pipeline, including the executor and reporter. This is the architecture’s “prove it before trust it” layer: claimed validation steps run in a constrained sandbox, and the result is emitted as a `ValidationReport`.

9. **Optional EvoMap / A2A network integration**
   When configured with `A2A_HUB_URL` and a node ID, Evolver connects to the EvoMap Hub for heartbeat, worker-pool participation, skill sharing, and asset publishing. The related code lives across `src/gep/a2a.js`, `a2aProtocol.js`, `hubSearch`, `hubVerify`, `directoryClient`, `mailboxTransport`, `taskReceiver`, and the ATP modules under `src/atp/`.

10. **Worker and validator network roles**
   The repo supports two network-side roles: worker participation and decentralized validation. Worker mode advertises capabilities and picks up tasks; validator mode periodically pulls validation jobs and submits reports. This makes the node both a local evolution engine and a network participant.

11. **Host runtime and editor integrations**
   `src/adapters/` and `src/proxy/` form the integration boundary for external agent runtimes. Adapters exist for Claude Code, Cursor, Kiro, and Codex, while the proxy layer provides HTTP routes, mailbox storage, sync, lifecycle management, and extension hooks for session events, DMs, and skill updates.

12. **Operations and lifecycle management**
   `src/ops/` contains the daemon-facing operational commands: lifecycle control, health checks, cleanup, self-repair, skill monitoring, and triggers. These modules are separate from the core evolution engine and are responsible for keeping long-running runs healthy and recoverable.

13. **Offline-first, repo-local design**
   Core functionality works without network access. Git is required because Evolver uses repository state for rollback, blast-radius reasoning, and solidification. Network features, issue reporting, and skill exchange are optional overlays rather than core dependencies.

14. **Tooling, scripts, and release pipeline**
   The `scripts/` directory covers import/export, analysis, log extraction, version suggestion, validation, and reporting workflows. Tests span nearly every subsystem, indicating a highly modular architecture with explicit boundaries around protocol logic, adapters, proxy behavior, validator safety, and lifecycle operations.

Main entry points: [`src/evolve.js`](https://github.com/evomap/evolver/blob/main/src/evolve.js) (Evolve), [`src/gep/selector.js`](https://github.com/evomap/evolver/blob/main/src/gep/selector.js) (Selector), [`src/gep/a2a.js`](https://github.com/evomap/evolver/blob/main/src/gep/a2a.js) (A2A), [`src/proxy`](https://github.com/evomap/evolver/tree/main/src/proxy) (Proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_index_js["CLI<br/>entrypoint<br/>[index.js]"]
  node_evolve_js["Evolve<br/>orchestrator<br/>[evolve.js]"]
end

subgraph group_gep["GEP Core"]
  node_assets_gep[("GEP Assets<br/>seed data")]
  node_signals["Signals<br/>signal ingest<br/>[signals.js]"]
  node_selector["Selector<br/>decision engine<br/>[selector.js]"]
  node_strategy["Strategy<br/>scoring<br/>[strategy.js]"]
  node_mutation["Mutation<br/>transform<br/>[mutation.js]"]
  node_prompt["Prompt<br/>assembly<br/>[prompt.js]"]
  node_candidate_eval["Candidate Eval<br/>ranking<br/>[candidateEval.js]"]
  node_curriculum["Curriculum<br/>policy<br/>[curriculum.js]"]
  node_memory[("Memory<br/>persistence<br/>[memoryGraph.js]")]
  node_trace["Trace<br/>audit trail<br/>[executionTrace.js]"]
  node_solidify["Solidify<br/>safety gate<br/>[solidify.js]"]
  node_validator["Validator<br/>sandbox<br/>[index.js]"]
  node_validation_report["Report<br/>result model"]
end

subgraph group_network["Network"]
  node_a2a["A2A<br/>network bridge<br/>[a2a.js]"]
  node_hub_client["Hub Client<br/>[directoryClient.js]"]
  node_task_receiver["Task Receiver<br/>worker role<br/>[taskReceiver.js]"]
  node_atp["ATP<br/>market module<br/>[index.js]"]
end

subgraph group_integrations["Integrations"]
  node_adapters["Adapters"]
  node_proxy["Proxy"]
end

subgraph group_ops["Ops"]
  node_ops_index["Ops<br/>[index.js]"]
end

node_index_js -->|"runs"| node_evolve_js
node_evolve_js -->|"collects"| node_signals
node_evolve_js -->|"selects"| node_selector
node_evolve_js -->|"scores"| node_strategy
node_selector -->|"ranks"| node_candidate_eval
node_strategy -->|"guides"| node_curriculum
node_selector -->|"adapts"| node_mutation
node_mutation -->|"assembles"| node_prompt
node_assets_gep -->|"seeds"| node_selector
node_signals -->|"persists"| node_memory
node_evolve_js -->|"records"| node_trace
node_evolve_js -->|"guards"| node_solidify
node_solidify -->|"verifies"| node_validator
node_validator -->|"emits"| node_validation_report
node_evolve_js -->|"attaches"| node_validation_report
node_a2a -->|"uses"| node_hub_client
node_a2a -->|"feeds"| node_task_receiver
node_a2a -->|"integrates"| node_atp
node_adapters -->|"connects"| node_proxy
node_proxy -->|"triggers"| node_evolve_js
node_ops_index -->|"operates"| node_evolve_js
node_ops_index -->|"manages"| node_proxy

click node_index_js "https://github.com/evomap/evolver/blob/main/index.js"
click node_evolve_js "https://github.com/evomap/evolver/blob/main/src/evolve.js"
click node_assets_gep "https://github.com/evomap/evolver/tree/main/assets/gep"
click node_signals "https://github.com/evomap/evolver/blob/main/src/gep/signals.js"
click node_selector "https://github.com/evomap/evolver/blob/main/src/gep/selector.js"
click node_strategy "https://github.com/evomap/evolver/blob/main/src/gep/strategy.js"
click node_mutation "https://github.com/evomap/evolver/blob/main/src/gep/mutation.js"
click node_prompt "https://github.com/evomap/evolver/blob/main/src/gep/prompt.js"
click node_candidate_eval "https://github.com/evomap/evolver/blob/main/src/gep/candidateEval.js"
click node_curriculum "https://github.com/evomap/evolver/blob/main/src/gep/curriculum.js"
click node_memory "https://github.com/evomap/evolver/blob/main/src/gep/memoryGraph.js"
click node_trace "https://github.com/evomap/evolver/blob/main/src/gep/executionTrace.js"
click node_solidify "https://github.com/evomap/evolver/blob/main/src/gep/solidify.js"
click node_validator "https://github.com/evomap/evolver/blob/main/src/gep/validator/index.js"
click node_validation_report "https://github.com/evomap/evolver/blob/main/src/gep/validationReport.js"
click node_a2a "https://github.com/evomap/evolver/blob/main/src/gep/a2a.js"
click node_hub_client "https://github.com/evomap/evolver/blob/main/src/gep/directoryClient.js"
click node_task_receiver "https://github.com/evomap/evolver/blob/main/src/gep/taskReceiver.js"
click node_atp "https://github.com/evomap/evolver/blob/main/src/atp/index.js"
click node_adapters "https://github.com/evomap/evolver/tree/main/src/adapters"
click node_proxy "https://github.com/evomap/evolver/tree/main/src/proxy"
click node_ops_index "https://github.com/evomap/evolver/blob/main/src/ops/index.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index_js,node_evolve_js toneBlue
class node_assets_gep,node_signals,node_selector,node_strategy,node_mutation,node_prompt,node_candidate_eval,node_curriculum,node_memory,node_trace,node_solidify,node_validator,node_validation_report toneAmber
class node_a2a,node_hub_client,node_task_receiver,node_atp toneMint
class node_adapters,node_proxy toneRose
class node_ops_index toneIndigo
```

## Components

### Runtime

CLI entry and orchestration

- [CLI](https://github.com/evomap/evolver/blob/main/index.js): entrypoint · Main command entry; supports standalone, review, and loop modes · `index.js`
- [Evolve](https://github.com/evomap/evolver/blob/main/src/evolve.js): orchestrator · Coordinates signal gathering, strategy choice, prompt building, and event recording · `src/evolve.js`

### GEP Core

Protocol model, selection, prompt assembly, and safety

- [GEP Assets](https://github.com/evomap/evolver/tree/main/assets/gep): seed data · Canonical genes, capsules, and events used as local evolution seeds · `assets/gep`
- [Signals](https://github.com/evomap/evolver/blob/main/src/gep/signals.js): signal ingest · Collects local history, logs, and environment signals · `src/gep/signals.js`
- [Selector](https://github.com/evomap/evolver/blob/main/src/gep/selector.js): decision engine · Chooses reusable protocol assets from candidates and signals · `src/gep/selector.js`
- [Strategy](https://github.com/evomap/evolver/blob/main/src/gep/strategy.js): scoring · Scores evolution paths and guides selection · `src/gep/strategy.js`
- [Mutation](https://github.com/evomap/evolver/blob/main/src/gep/mutation.js): transform · Adapts genes, capsules, and candidate assets into a fit prompt form · `src/gep/mutation.js`
- [Prompt](https://github.com/evomap/evolver/blob/main/src/gep/prompt.js): assembly · Builds the structured GEP-compliant prompt emitted by the engine · `src/gep/prompt.js`
- [Candidate Eval](https://github.com/evomap/evolver/blob/main/src/gep/candidateEval.js): ranking · Evaluates candidate assets and evidence quality · `src/gep/candidateEval.js`
- [Curriculum](https://github.com/evomap/evolver/blob/main/src/gep/curriculum.js): policy · Shapes staged learning and progression across evolution cycles · `src/gep/curriculum.js`
- [Memory](https://github.com/evomap/evolver/blob/main/src/gep/memoryGraph.js): persistence · Local state and evidence trail for evolution history · `src/gep/memoryGraph.js`
- [Trace](https://github.com/evomap/evolver/blob/main/src/gep/executionTrace.js): audit trail · Execution traces, call logs, and learning signals · `src/gep/executionTrace.js`
- [Solidify](https://github.com/evomap/evolver/blob/main/src/gep/solidify.js): safety gate · Read-to-write boundary that validates and safely promotes changes · `src/gep/solidify.js`
- [Validator](https://github.com/evomap/evolver/blob/main/src/gep/validator/index.js): sandbox · Sandboxed validation pipeline producing validation reports · `src/gep/validator/index.js`
- [Report](https://github.com/evomap/evolver/blob/main/src/gep/validationReport.js): result model · Structured validation result emitted by the validator · `src/gep/validationReport.js`

### Network

Optional EvoMap and validation network roles

- [A2A](https://github.com/evomap/evolver/blob/main/src/gep/a2a.js): network bridge · Optional EvoMap hub integration for worker and asset exchange · `src/gep/a2a.js`
- [Hub Client](https://github.com/evomap/evolver/blob/main/src/gep/directoryClient.js): client · Connects to hub services for search, verify, publish, and mailbox flows · `src/gep/directoryClient.js`
- [Task Receiver](https://github.com/evomap/evolver/blob/main/src/gep/taskReceiver.js): worker role · Consumes network tasks and feeds them into local execution · `src/gep/taskReceiver.js`
- [ATP](https://github.com/evomap/evolver/blob/main/src/atp/index.js): market module · Optional consumer/merchant workflow around hub participation · `src/atp/index.js`

### Integrations

Host runtimes and proxy boundary

- [Adapters](https://github.com/evomap/evolver/tree/main/src/adapters): runtime adapters · Host integrations for Claude Code, Cursor, Kiro, and Codex · `src/adapters`
- [Proxy](https://github.com/evomap/evolver/tree/main/src/proxy): session proxy · HTTP, mailbox, sync, lifecycle, and extension boundary for external runtimes · `src/proxy`

### Ops

Daemon and lifecycle management

- [Ops](https://github.com/evomap/evolver/blob/main/src/ops/index.js): daemon ops · Operational commands for health, cleanup, repair, and triggers · `src/ops/index.js`

## Connections

- CLI → Evolve: runs · CLI dispatches core evolution flow
- Evolve → Signals: collects · Reads local history and environment signals
- Evolve → Selector: selects · Chooses a protocol asset path
- Evolve → Strategy: scores · Applies evolution strategy and policy
- Selector → Candidate Eval: ranks · Evaluates candidate assets before selection
- Strategy → Curriculum: guides · Progression policy informs strategy choices
- Selector → Mutation: adapts · Transforms selected assets into a prompt-ready form
- Mutation → Prompt: assembles · Builds the structured prompt payload
- GEP Assets → Selector: seeds · Provides canonical genes, capsules, and events
- Signals → Memory: persists · Records local evidence and history
- Evolve → Trace: records · Writes execution trace and learning signals
- Evolve → Solidify: guards · Passes through safety and promotion boundary
- Solidify → Validator: verifies · Routes claimed validation into sandboxed checks
- Validator → Report: emits · Produces structured validation outcome
- Evolve → Report: attaches · Uses validation result as part of evolution record
- A2A → Hub Client: uses · Network bridge delegates to hub services
- A2A → Task Receiver: feeds · Receives tasks and worker assignments
- A2A → ATP: integrates · Optional worker/merchant participation layer
- Adapters → Proxy: connects · Host runtimes interact through proxy/session boundary
- Proxy → Evolve: triggers · Session events and sync flows can initiate evolution
- Ops → Evolve: operates · Lifecycle and recovery commands act on the engine
- Ops → Proxy: manages · Daemon ops manage long-running proxy state
