VEX Architecture

System design and component breakdown for VEX.

System Overview

┌─────────────────────────────────────────────────────────────┐
│                     Gateway Layer                           │
│  vex-api: Axum HTTP + JWT + Rate Limiting + Circuit Breaker │
├─────────────────────────────────────────────────────────────┤
│                   Intelligence Layer                        │
│  vex-llm              │  vex-adversarial                    │
│  DeepSeek/OpenAI      │  Red/Blue Debate Engine             │
├─────────────────────────────────────────────────────────────┤
│                    Execution Layer                          │
│  vex-runtime          │  vex-queue                          │
│  Orchestrator/Executor│  Async Worker Pool                  │
├─────────────────────────────────────────────────────────────┤
│                      Core Layer                             │
│  vex-core             │  vex-temporal                       │
│  Agent/Genome/Merkle  │  Episodic Memory + Decay            │
├─────────────────────────────────────────────────────────────┤
│                   Persistence Layer                         │
│  vex-persist: SQLite + Migrations + Audit Logs              │
└─────────────────────────────────────────────────────────────┘

Key Concepts

Fractal Agents

Agents are hierarchical and can spawn child agents for subtasks. Each agent has:

  • Genome — Evolutionary traits mapped to LLM parameters
  • Context — Hashable context packets with TTL
  • Shadow — Optional Red agent for verification

Adversarial Verification

Every Blue agent can have a Red shadow that challenges its outputs:

  1. Blue agent generates response
  2. Shadow detects potential issues
  3. Multi-round debate if needed
  4. Consensus voting determines final output

Temporal Memory

Bio-inspired memory with automatic decay:

HorizonDurationMax Entries
Immediate5 min10
ShortTerm1 hour25
MediumTerm24 hours50
LongTerm1 week100
Permanent500

Merkle Proofs

All agent decisions are hash-chained:

  • SHA-256 content hashing
  • Merkle tree construction
  • Tamper-evident audit trails
  • Proof verification in O(log n)

Data Flow

User Request
    │
    ▼
┌─────────┐
│ vex-api │ ─── JWT Auth + Rate Limit
└────┬────┘
     │
     ▼
┌─────────────┐
│ vex-runtime │ ─── Orchestrator
└──────┬──────┘
       │
       ▼
┌──────────────┐     ┌────────────────┐
│  Blue Agent  │ ◄── │  vex-temporal  │
└──────┬───────┘     │  (Memory)      │
       │             └────────────────┘
       ▼
┌──────────────┐
│   vex-llm    │ ─── DeepSeek/OpenAI
└──────┬───────┘
       │
       ▼
┌────────────────┐
│ vex-adversarial│ ─── Shadow verification
└───────┬────────┘
        │
        ▼
   Final Response
   + Merkle Proof

Crate Dependencies

vex-api
├── vex-runtime
│   ├── vex-core
│   ├── vex-adversarial
│   │   └── vex-core
│   └── vex-llm
├── vex-persist
├── vex-queue
└── vex-llm