Skip to main content

CLEO Cognitive Architecture

CLEO as a Neural Brain for Autonomous AI Agents CLEO transforms AI agents from stateless responders into systematic reasoning systems with persistent memory. Unlike traditional vector-based RAG systems that rely on similarity search, CLEO implements a PageIndex-inspired vectorless RAG that uses hierarchical reasoning for context retrieval.
Key Innovation: “Similarity does not equal relevance - what we truly need in retrieval is relevance, and that requires reasoning.”

Performance Comparison

ApproachAccuracy (FinanceBench)Method
Traditional Vector RAG~30-50%Similarity search
CLEO Graph-RAG~98.7%Hierarchical reasoning

Neural Network Mappings

CLEO exhibits neural-like behaviors through its task graph architecture:
Neural ConceptCLEO Implementation
NeuronsTasks (spanning all projects via Nexus)
Synapsesrelates field entries (knowledge graph edges)
WeightsHierarchy boosts: Sibling (+0.15), Cousin (+0.08), Ancestor (+0.04)
ActivationSimilarity scores 0.0-1.0 determine signal strength
PropagationContext flows parent→child with exponential decay
Memory IndexingDual-index (forward + reverse) for O(1) lookup
AdaptationConfigurable thresholds via config.json

The Complete Brain Hierarchy

CLEO implements a fractal neural architecture where each level contains the same patterns:
┌─────────────────────────────────────────────────────────────────────┐
│                     CLEO NEXUS (Global Brain)                       │
│                     ~/.cleo/nexus/registry.json                     │
│                                                                     │
│   ┌──────────────────┐    ┌──────────────────┐    ┌────────────┐  │
│   │   PROJECT A      │    │   PROJECT B      │    │ PROJECT C  │  │
│   │  (Macro-Neuron)  │◄──►│  (Macro-Neuron)  │◄──►│ (Macro-N)  │  │
│   │                  │    │                  │    │            │  │
│   │  ┌────┐ ┌────┐  │    │  ┌────┐ ┌────┐  │    │  ┌────┐    │  │
│   │  │Epic│ │Epic│  │    │  │Epic│ │Epic│  │    │  │Epic│    │  │
│   │  └─┬──┘ └─┬──┘  │    │  └─┬──┘ └────┘  │    │  └─┬──┘    │  │
│   │    │      │     │    │    │             │    │    │       │  │
│   │ ┌──┴─┐ ┌──┴─┐   │    │ ┌──┴─┐          │    │ ┌──┴─┐     │  │
│   │ │Task│ │Task│   │    │ │Task│──────────┼────┼─►Task│     │  │
│   │ └────┘ └────┘   │    │ └────┘          │    │ └────┘     │  │
│   └──────────────────┘    └──────────────────┘    └────────────┘  │
│                                                                     │
│   Cross-Project Edges (depends: "projectB:T001")                   │
└─────────────────────────────────────────────────────────────────────┘

Level 1: Global Brain (Nexus)

At the highest level, CLEO Nexus acts as the global cortex:
ComponentNeural AnalogDescription
~/.cleo/nexus/BrainCentral intelligence hub
registry.jsonCortex MapIndex of all project neurons
Cross-project depsLong-range axonsConnections spanning projects

Level 2: Projects as Macro-Neurons

Each registered project is a macro-neuron in the global brain:
ComponentNeural AnalogDescription
ProjectMacro-NeuronSelf-contained processing unit
.cleo/ directoryNucleusLocal state and memory
todo.jsonDendritesInput structure (tasks to process)
todo-archive.jsonLong-term memoryCompleted task storage
Project permissionsMyelin sheathAccess control (read/write/execute)

Level 3: Epics as Neural Clusters

Within each project, Epics are clusters of related neurons:
ComponentNeural AnalogDescription
EpicNeural ClusterGroup of related tasks
Epic childrenCluster neuronsTasks belonging to the epic
Epic labelsCluster tagsSemantic categorization

Level 4: Tasks as Individual Neurons

At the atomic level, Tasks are individual neurons:
ComponentNeural AnalogDescription
TaskNeuronSingle unit of work/memory
depends fieldAxon terminalsOutput connections
relates fieldDendritesInput/association connections
Task statusActivation statepending/active/blocked/done
LabelsNeurotransmitter typesSemantic classification
NotesMemory contentStored information

Cross-Project Synapses

Tasks can form cross-project dependencies that span macro-neurons:
# In project-frontend/todo.json
{
  "id": "T002",
  "title": "Create login page",
  "depends": ["T001", "project-backend:T003"]  # Cross-project synapse!
}
This creates a direct neural pathway from project-frontend:T002 to project-backend:T003.
Key Insight: The same patterns repeat at each level - neurons (tasks) within clusters (epics) within macro-neurons (projects) within the global brain (Nexus). This is how biological neural networks organize.

Core Architecture: Vectorless RAG

CLEO’s retrieval system eliminates vector databases in favor of:

1. Hierarchical Semantic Trees

The Epic→Task→Subtask hierarchy mirrors document table-of-contents structure:
Epic: Authentication System Overhaul
├── Task: Research OAuth providers
│   ├── Subtask: Evaluate Auth0
│   └── Subtask: Evaluate Clerk
├── Task: Design token management
└── Task: Implement login flow

2. LLM Reasoning Over Structure

Instead of embedding similarity, CLEO uses the LLM to reason about:
  • Task relationships and dependencies
  • Hierarchical context inheritance
  • Semantic relevance through structure

3. Five Discovery Methods

From lib/graph-rag.sh:
MethodAlgorithmUse Case
Label-BasedJaccard similarity on shared tagsFinding tasks with common labels
Description-BasedKeyword extraction + stopword removal + JaccardSemantic text matching
File-BasedRelationship through shared code filesCode-centric discovery
Hierarchy-BasedLCA (Lowest Common Ancestor) + tree distanceStructural relationships
Auto ModeMerges all methods with hierarchy boostingDefault comprehensive search

Context Propagation (Memory Inheritance)

CLEO implements “memory decay” where distant information weakens - similar to neural networks:
Self:        weight 1.0   (100% own context)
Parent:      weight 0.5   (50% parent context inherited)
Grandparent: weight 0.25  (25% grandparent context)
This creates natural context scoping where:
  • Immediate task context is strongest
  • Epic-level context provides background
  • Distant ancestors contribute minimally

Scoring Formula

final_score = min(1.0, base_score + hierarchy_boost)

Where:
  base_score = max(labels_score, description_score, files_score)
  hierarchy_boost = sibling_boost + cousin_boost + ancestor_boost

Key Algorithms

Lowest Common Ancestor (LCA)

_find_lca(task_a, task_b)  # Find shared ancestor in hierarchy
_tree_distance(a, b)       # Calculate graph distance between tasks
The LCA algorithm enables:
  • Finding related tasks through common parents
  • Calculating semantic distance in the hierarchy
  • Boosting relevance for structurally close tasks

Graph Cache (O(1) Index)

CLEO maintains dual indexes for instant lookup:
Forward Index:  task → dependencies (what this task needs)
Reverse Index:  task → dependents (what depends on this task)
  • Checksum-based invalidation: Automatic rebuild on structure changes
  • Persistent: Cache survives across sessions
  • O(1) lookup: Instant dependency queries
  • Location: .cleo/.cache/

The relates Field: Knowledge Graph Edges

Tasks connect through typed relationships:
Relation TypeMeaning
relates-toGeneral semantic relationship
spawned-fromTask created from another task’s work
deferred-toWork postponed to another task
supersedesReplaces an older task
duplicatesSame work as another task
These create undirected edges in the knowledge graph, enabling:
  • Cross-cutting context discovery
  • Dependency chain analysis
  • Impact assessment for changes

CLEO Nexus: Cross-Project Neural Brain

The Nexus system (v0.80.0+) extends CLEO’s brain across multiple projects, creating a unified global graph where each project is a node containing its own task subgraph.

The Global Graph Model

                    ┌─────────────────────────────────────┐
                    │         NEXUS GLOBAL GRAPH          │
                    │                                     │
   ┌────────────────┤                                     ├────────────────┐
   │                │                                     │                │
   ▼                ▼                                     ▼                ▼
┌──────┐  edge   ┌──────┐                             ┌──────┐  edge   ┌──────┐
│ CLEO │◄───────►│ API  │                             │ WEB  │◄───────►│MOBILE│
│      │         │      │                             │      │         │      │
└───┬──┘         └───┬──┘                             └───┬──┘         └───┬──┘
    │                │                                    │                │
    ▼                ▼                                    ▼                ▼
┌───────────┐   ┌───────────┐                       ┌───────────┐   ┌───────────┐
│ Epic:Auth │   │ Epic:API  │                       │ Epic:UI   │   │Epic:Native│
│ ├─T001    │   │ ├─T001    │                       │ ├─T001    │   │ ├─T001    │
│ ├─T002────┼───┼─►T002     │                       │ ├─T002◄───┼───┼─┤T002     │
│ └─T003    │   │ └─T003    │                       │ └─T003    │   │ └─T003    │
└───────────┘   └───────────┘                       └───────────┘   └───────────┘
Each project node contains:
  • Its own task graph (epics, tasks, subtasks)
  • Intra-project edges (depends within project)
  • Inter-project edges (depends across projects via project:task_id syntax)

Commands

CommandPurpose
cleo nexus initInitialize the global brain
cleo nexus register <path>Register a project’s task graph
cleo nexus listList registered projects
cleo nexus query <project:task>Query task across projects
cleo nexus discover <task>Cross-project semantic search
cleo nexus deps <task>Analyze dependencies across projects
cleo nexus syncSync project metadata
cleo nexus unregisterRemove a project

Query Syntax

Nexus uses a unified query syntax for cross-project operations:
# Query specific project
cleo nexus query myproject:T001

# Query current project
cleo nexus query .:T001

# Query all projects (wildcard)
cleo nexus query "*:T001"

Permission Control

Three-tier access model:
Query tasks and relationships
  • View task details
  • Query dependencies
  • Discover related tasks
cleo nexus register ./project --permissions read

Example Usage

# Initialize Nexus (once)
cleo nexus init

# Register projects
cleo nexus register ~/projects/backend --name backend --permissions execute
cleo nexus register ~/projects/frontend --name frontend --permissions write

# Discover related tasks across all projects
cleo nexus discover backend:T001 --limit 5

# Analyze cross-project dependencies
cleo nexus deps frontend:T002 --reverse

Practical Benefits for Autonomous Agents

1. Persistent Goals

Memory Persistence

Tasks survive context window resets. The agent can:
  • Resume work from where it left off
  • Maintain long-term objectives
  • Track progress across sessions

2. Extreme Context Efficiency

ct find "query"   # 99% less context than ct list
ct show T1234     # Full details only when needed
The “query before expand” pattern minimizes token usage.

3. Systematic Reasoning

The RCSD pipeline prevents “jumping to code”:
Research → Consensus → Specification → Decomposition
Each phase has:
  • Defined inputs and outputs
  • Validation gates
  • Evidence requirements

4. Multi-Agent Coordination

2-tier architecture enables parallel work:
Tier 0: ORCHESTRATOR
├── Coordinates workflows
├── Spawns subagents via Task tool
└── Reads manifest summaries only

Tier 1: CLEO-SUBAGENT (universal executor)
├── Receives fully-resolved prompts
├── Executes delegated work
└── Outputs: file + manifest entry + summary

Agent Integration Pattern

To use CLEO as your agent’s cognitive backbone:
1

Initialize CLEO

cleo init
2

Start a Session

cleo session start --scope epic:T001 --auto-focus --name "Work Session"
3

Query Before Acting

cleo find "relevant query"  # Minimal context
cleo show T1234             # Full details when needed
4

Track Progress

cleo focus set T1234        # Set active task
cleo complete T1234         # Mark complete
cleo next                   # Get next suggestion
5

End Session

cleo session end --note "Progress summary"

Data Directory Structure

.cleo/                      # Project-level data
├── todo.json              # Active task graph (neurons)
├── todo-archive.json      # Completed tasks
├── config.json            # Configuration (adaptation)
├── todo-log.jsonl          # Immutable audit trail
├── sessions.json          # Session state
├── .cache/                # Graph indexes (O(1) lookup)
│   ├── hierarchy.index.json
│   ├── children.index.json
│   └── depth.index.json
└── .backups/              # Automatic backups

~/.cleo/nexus/             # Global brain (cross-project)
├── registry.json          # Registered projects
└── cache/                 # Cross-project indexes

Why This Matters

Traditional AI agents suffer from:
ProblemCLEO Solution
AmnesiaPersistent task state with semantic retrieval
ImpulsivityRCSD/IVTR protocols enforce systematic reasoning
IsolationMulti-agent orchestration with manifest communication
InefficiencyGraph-based O(1) lookups and minimal context queries
This transforms AI from “smart autocomplete” to “systematic reasoning system with externalized cognition.”

References


Next Steps