# sethgammon/citadel architecture

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

- Interactive diagram: https://gitdiagram.com/sethgammon/citadel
- Repository: https://github.com/sethgammon/citadel

## Overview

Citadel is an operating layer for Claude Code and OpenAI Codex. The documented user journey starts with a request through `/do`, selects a workflow, runs it within repository and approval boundaries, records evidence, and leaves a resume action when interrupted. The repository also supports persistent project context, parallel worktrees, safeguards, MCP tools, and codebase memory. Relationships below follow explicit README statements or source-index references; unsampled capabilities are represented without guessing their internal call paths.

Main entry points: [`core/control-plane/service.js`](https://github.com/sethgammon/citadel/blob/main/core/control-plane/service.js) (Control-plane service), [`core/operation-controller/controller.js`](https://github.com/sethgammon/citadel/blob/main/core/operation-controller/controller.js) (Operation controller), [`core/skills/routing.js`](https://github.com/sethgammon/citadel/blob/main/core/skills/routing.js) (Skill routing), [`hooks_src/user-prompt-submit.js`](https://github.com/sethgammon/citadel/blob/main/hooks_src/user-prompt-submit.js) (Prompt hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Agent entry and runtime"]
  node_claude["Claude runtime<br/>[runtime.js]"]
  node_codex["Codex runtime<br/>[runtime.js]"]
  node_request_route["Skill routing<br/>[routing.js]"]
  node_prompt_hook["Prompt hook"]
  node_config["Activation config<br/>[activation.js]"]
end

subgraph group_execution["Workflow execution"]
  node_controller["Operation controller<br/>[controller.js]"]
  node_op_service["Control-plane service<br/>[service.js]"]
  node_op_contracts["Operation contracts<br/>[graph-contract.js]"]
  node_graph_run["Graph execution<br/>[graph-run.js]"]
  node_forks["Parallel worktrees<br/>[orchestrator.js]"]
end

subgraph group_state["State and safeguards"]
  node_op_policy["Control policy<br/>[policy.js]"]
  node_governance["Governance authority<br/>[authority.js]"]
  node_memory[("Repository memory")]
  node_coordination["Work coordination<br/>[claims.js]"]
end

subgraph group_evidence["Evidence and integrations"]
  node_proof["Proof verification<br/>[index.js]"]
  node_state_mcp["State MCP tools<br/>[index.js]"]
  node_protocol["MCP protocol adapter"]
  node_code_map["Codebase map<br/>[index.js]"]
  node_memory_mcp["Codebase memory MCP<br/>[index.js]"]
end

node_user(("Developer"))

node_user -->|"submits request"| node_claude
node_user -->|"submits request"| node_codex
node_claude -.->|"routes request"| node_request_route
node_codex -.->|"routes request"| node_request_route
node_request_route -.->|"selects workflow"| node_controller
node_controller -.->|"dispatches operation"| node_op_service
node_op_service -->|"uses contracts"| node_op_contracts
node_op_service -->|"uses operations"| node_graph_run
node_controller -.->|"checks boundaries"| node_op_policy
node_op_service -.->|"checks authority"| node_governance
node_prompt_hook -.->|"loads activation"| node_config
node_prompt_hook -.->|"preserves session state"| node_memory
node_forks -.->|"claims ownership"| node_coordination
node_forks -->|"uses governance"| node_governance
node_op_service -.->|"publishes evidence"| node_proof
node_user -->|"requests state tools"| node_state_mcp
node_state_mcp -->|"adapts protocol"| node_protocol
node_memory_mcp -->|"queries map"| node_code_map
node_memory_mcp -->|"adapts protocol"| node_protocol
node_proof -->|"verifies receipts"| node_op_contracts

click node_claude "https://github.com/sethgammon/citadel/blob/main/runtimes/claude-code/runtime.js"
click node_codex "https://github.com/sethgammon/citadel/blob/main/runtimes/codex/runtime.js"
click node_request_route "https://github.com/sethgammon/citadel/blob/main/core/skills/routing.js"
click node_prompt_hook "https://github.com/sethgammon/citadel/blob/main/hooks_src/user-prompt-submit.js"
click node_config "https://github.com/sethgammon/citadel/blob/main/core/config/activation.js"
click node_controller "https://github.com/sethgammon/citadel/blob/main/core/operation-controller/controller.js"
click node_op_service "https://github.com/sethgammon/citadel/blob/main/core/control-plane/service.js"
click node_op_contracts "https://github.com/sethgammon/citadel/blob/main/core/operations/graph-contract.js"
click node_graph_run "https://github.com/sethgammon/citadel/blob/main/core/operations/graph-run.js"
click node_op_policy "https://github.com/sethgammon/citadel/blob/main/core/operation-control/policy.js"
click node_governance "https://github.com/sethgammon/citadel/blob/main/core/governance/authority.js"
click node_memory "https://github.com/sethgammon/citadel/blob/main/core/memory/repository-store.js"
click node_coordination "https://github.com/sethgammon/citadel/blob/main/core/coordination/claims.js"
click node_forks "https://github.com/sethgammon/citadel/blob/main/core/forks/orchestrator.js"
click node_proof "https://github.com/sethgammon/citadel/blob/main/core/proof/index.js"
click node_state_mcp "https://github.com/sethgammon/citadel/blob/main/mcp-servers/citadel-state/index.js"
click node_protocol "https://github.com/sethgammon/citadel/blob/main/mcp-servers/protocol-adapter.js"
click node_code_map "https://github.com/sethgammon/citadel/blob/main/core/map/index.js"
click node_memory_mcp "https://github.com/sethgammon/citadel/blob/main/mcp-servers/codebase-memory/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_claude,node_codex,node_request_route,node_prompt_hook,node_config toneBlue
class node_controller,node_op_service,node_op_contracts,node_graph_run,node_forks toneAmber
class node_op_policy,node_governance,node_memory,node_coordination toneMint
class node_proof,node_state_mcp,node_protocol,node_code_map,node_memory_mcp toneRose
class node_user toneIndigo
```

## Components

### Agent entry and runtime

- [Claude runtime](https://github.com/sethgammon/citadel/blob/main/runtimes/claude-code/runtime.js): `runtimes/claude-code/runtime.js`
- [Codex runtime](https://github.com/sethgammon/citadel/blob/main/runtimes/codex/runtime.js): `runtimes/codex/runtime.js`
- [Skill routing](https://github.com/sethgammon/citadel/blob/main/core/skills/routing.js): `core/skills/routing.js`
- [Prompt hook](https://github.com/sethgammon/citadel/blob/main/hooks_src/user-prompt-submit.js): `hooks_src/user-prompt-submit.js`
- [Activation config](https://github.com/sethgammon/citadel/blob/main/core/config/activation.js): `core/config/activation.js`

### Workflow execution

- [Operation controller](https://github.com/sethgammon/citadel/blob/main/core/operation-controller/controller.js): `core/operation-controller/controller.js`
- [Control-plane service](https://github.com/sethgammon/citadel/blob/main/core/control-plane/service.js): `core/control-plane/service.js`
- [Operation contracts](https://github.com/sethgammon/citadel/blob/main/core/operations/graph-contract.js): `core/operations/graph-contract.js`
- [Graph execution](https://github.com/sethgammon/citadel/blob/main/core/operations/graph-run.js): `core/operations/graph-run.js`
- [Parallel worktrees](https://github.com/sethgammon/citadel/blob/main/core/forks/orchestrator.js): `core/forks/orchestrator.js`

### State and safeguards

- [Control policy](https://github.com/sethgammon/citadel/blob/main/core/operation-control/policy.js): `core/operation-control/policy.js`
- [Governance authority](https://github.com/sethgammon/citadel/blob/main/core/governance/authority.js): `core/governance/authority.js`
- [Repository memory](https://github.com/sethgammon/citadel/blob/main/core/memory/repository-store.js): `core/memory/repository-store.js`
- [Work coordination](https://github.com/sethgammon/citadel/blob/main/core/coordination/claims.js): `core/coordination/claims.js`

### Evidence and integrations

- [Proof verification](https://github.com/sethgammon/citadel/blob/main/core/proof/index.js): `core/proof/index.js`
- [State MCP tools](https://github.com/sethgammon/citadel/blob/main/mcp-servers/citadel-state/index.js): `mcp-servers/citadel-state/index.js`
- [MCP protocol adapter](https://github.com/sethgammon/citadel/blob/main/mcp-servers/protocol-adapter.js): `mcp-servers/protocol-adapter.js`
- [Codebase map](https://github.com/sethgammon/citadel/blob/main/core/map/index.js): `core/map/index.js`
- [Codebase memory MCP](https://github.com/sethgammon/citadel/blob/main/mcp-servers/codebase-memory/index.js): `mcp-servers/codebase-memory/index.js`

### Other components

- **Developer**

## Connections

- Developer → Claude runtime: submits request (evidence: `README.md`)
- Developer → Codex runtime: submits request (evidence: `README.md`)
- Claude runtime → Skill routing: routes request
- Codex runtime → Skill routing: routes request
- Skill routing → Operation controller: selects workflow
- Operation controller → Control-plane service: dispatches operation
- Control-plane service → Operation contracts: uses contracts (evidence: `core/control-plane/service.js`)
- Control-plane service → Graph execution: uses operations (evidence: `core/control-plane/service.js`)
- Operation controller → Control policy: checks boundaries
- Control-plane service → Governance authority: checks authority
- Prompt hook → Activation config: loads activation
- Prompt hook → Repository memory: preserves session state
- Parallel worktrees → Work coordination: claims ownership
- Parallel worktrees → Governance authority: uses governance
- Control-plane service → Proof verification: publishes evidence
- Developer → State MCP tools: requests state tools (evidence: `README.md`)
- State MCP tools → MCP protocol adapter: adapts protocol (evidence: `mcp-servers/citadel-state/index.js`)
- Codebase memory MCP → Codebase map: queries map (evidence: `mcp-servers/codebase-memory/index.js`)
- Codebase memory MCP → MCP protocol adapter: adapts protocol (evidence: `mcp-servers/codebase-memory/index.js`)
- Proof verification → Operation contracts: verifies receipts (evidence: `core/proof/index.js`)
