Project Blueprint: Citadel
Document Version: 1.0 Status: Proposed
1. Vision & Mission
Project Name: Citadel
Vision: To be the command and control layer for the AI-powered enterprise--an indomitable runtime that forges chaotic agentic processes into disciplined, resilient, and effective digital legions.
Mission: To provide an unshakeable, OTP-powered fortress for stateful AI agents. Citadel imposes order on the chaos of distributed systems, guaranteeing the lifecycle, state integrity, and operational resilience of every agent under its command. It is the architectural high ground from which reliable AI applications are built and governed.
2. The Problem: The Unruly Frontier of Agentic AI
The AI frontier is a lawless territory. Developers are creating powerful agents, but they are deploying them into the wild as scattered, fragile scripts. This approach is untenable for production systems, leading to critical vulnerabilities:
- Tactical Instability (State Management): How is an agent's memory and context--its most valuable asset--protected during a crash? A stateless architecture treats this as an afterthought, leading to catastrophic amnesia.
- Lack of Discipline (Lifecycle): When an agent process fails, does it simply vanish? Without a supervisory command structure, a single bug can silently dismantle an entire agent workforce.
- Broken Lines of Communication: In multi-agent systems, how do specialized agents (a "planner," an "executor," a "reviewer") coordinate their actions? Ad-hoc messaging leads to race conditions and brittle, unmaintainable chaos.
- Operational Blindness: Without a central command, developers are fighting blind, unable to see the health, status, and performance of their agent population in real-time.
Citadel is the answer. It is not merely a framework; it is the fortified infrastructure that transforms this unruly frontier into a disciplined, strategic asset.
3. Core Concepts & Fortress Architecture
Citadel is a complete, clustered OTP application designed for strategic dominance. It provides the architectural foundation and command structure for an entire population of AI agents.
The Core Architectural Primitives:
-
Sentinel (
GenServer): The individual unit of command. Every agent deployed withinCitadelis instantiated as a Sentinel--a living, stateful, and supervisedGenServerprocess. This provides absolute process isolation, ensuring the failure of one Sentinel can never cascade to another. -
The Garrison (
Horde.DynamicSupervisor): The organizational structure for the Sentinels. The Garrison is a distributed supervisor powered byHorde. It is responsible for stationing Sentinels across the entireCitadelcluster, ensuring they are always running and automatically resurrecting them on healthy nodes if their host node falls. -
The Command Registry (
Horde.Registry): The distributed intelligence network. The Command Registry allows any Sentinel to be addressed by a unique, strategic name (e.g.,{"squadron": "alpha", "unit": 7}). This enables location-transparent communication: a Sentinel can issue a command to another without knowing its physical location within the cluster's fortifications.
Diagram: Citadel Cluster Command Structure
subgraph "External Network"
LB[Load Balancer / Gateway]
end
subgraph "The Citadel (Distributed BEAM Cluster)"
direction LR
NodeA["Citadel Node A (Bastion)"]
NodeB["Citadel Node B (Bastion)"]
NodeC["Citadel Node C (Bastion)"]
subgraph NodeA
PhoenixEndpoint[Phoenix Endpoint]
GarrisonA[Garrison Supervisor]
Sentinel1[Sentinel Process 1]
Sentinel4[Sentinel Process 4]
end
subgraph NodeB
GarrisonB[Garrison Supervisor]
Sentinel2[Sentinel Process 2]
Sentinel5[Sentinel Process 5]
end
subgraph NodeC
GarrisonC[Garrison Supervisor]
Sentinel3[Sentinel Process 3]
Sentinel6[Sentinel Process 6]
end
end
LB --> PhoenixEndpoint
PhoenixEndpoint -->|Issues Command via Registry| Sentinel3
Sentinel3 -->|Coordinates with| Sentinel5
linkStyle 2 stroke-width:2px,stroke:red,stroke-dasharray: 5 5;
linkStyle 3 stroke-width:2px,stroke:blue,stroke-dasharray: 5 5;
%% Horde's internal command & control network (gossip protocol)
GarrisonA <--> GarrisonB
GarrisonB <--> GarrisonC
GarrisonA <--> GarrisonC