# rubanchakravarthib308-spec/agent-control-plane architecture

> Architecture diagram of the GitHub repository rubanchakravarthib308-spec/agent-control-plane, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rubanchakravarthib308-spec/agent-control-plane
- Repository: https://github.com/rubanchakravarthib308-spec/agent-control-plane

## Overview

Agent Control Plane is a guarded agent-execution layer. A goal is planned and validated, high-risk steps require scoped human approval, and each step must acquire an idempotency claim before tool execution and verification. The control plane records run state and audit events through a pluggable store, with in-memory and PostgreSQL implementations. Optional model-provider and human-review callbacks are integration boundaries, not execution authorities. Edges reflect the README and shown source; unsampled integrations are not expanded beyond documented boundaries.

Main entry points: [`src/control-plane.ts`](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/control-plane.ts) (Control Plane), [`src/planner.ts`](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/planner.ts) (Planner Adapter), [`src/run-store.ts`](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/run-store.ts) (Run Store Contract), [`src/postgres-run-store.ts`](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/postgres-run-store.ts) (PostgreSQL Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_planning["Planning"]
  node_planner["Planner Adapter<br/>[planner.ts]"]
  node_plan_validation["Plan Validation<br/>[planner.ts]"]
end

subgraph group_governance["Safety Governance"]
  node_control_plane["Control Plane<br/>[control-plane.ts]"]
  node_approval_policy["Approval Policy<br/>[approval-policy.ts]"]
  node_domain_types["Domain Types<br/>[types.ts]"]
end

subgraph group_execution["Execution"]
  node_tool_registry["Tool Registry<br/>[tool-registry.ts]"]
  node_tool_handlers["Registered Tool Handlers<br/>[tool-registry.ts]"]
  node_verification["Verification Callback"]
end

subgraph group_persistence["Run Persistence"]
  node_run_store_contract["Run Store Contract<br/>[run-store.ts]"]
  node_memory_store[("In-Memory Store")]
  node_postgres_store["PostgreSQL Store"]
  node_postgres_db[("PostgreSQL Database")]
  node_run_schema["Run Schema<br/>[001_run_store.sql]"]
  node_claim_schema["Execution Claims Schema"]
end

node_goal(("Agent Goal"))
node_model_provider(("Model Provider"))
node_human_reviewer(("Human Reviewer"))

node_goal -->|"submits goal"| node_control_plane
node_control_plane -->|"requests plan"| node_planner
node_planner -->|"generates proposal"| node_model_provider
node_planner -->|"validates plan"| node_plan_validation
node_control_plane -->|"builds and checks"| node_approval_policy
node_control_plane -->|"requests decision"| node_human_reviewer
node_control_plane -->|"executes step"| node_tool_registry
node_tool_registry -->|"dispatches handler"| node_tool_handlers
node_control_plane -->|"verifies output"| node_verification
node_control_plane -->|"records run"| node_run_store_contract
node_memory_store -->|"implements contract"| node_run_store_contract
node_postgres_store -->|"implements contract"| node_run_store_contract
node_control_plane -->|"defaults to"| node_memory_store
node_postgres_store -->|"reads and writes"| node_postgres_db
node_postgres_db -.->|"uses run tables"| node_run_schema
node_postgres_db -.->|"uses claim table"| node_claim_schema
node_control_plane -->|"uses domain records"| node_domain_types

click node_planner "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/planner.ts"
click node_plan_validation "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/planner.ts"
click node_control_plane "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/control-plane.ts"
click node_approval_policy "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/approval-policy.ts"
click node_tool_registry "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/tool-registry.ts"
click node_tool_handlers "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/tool-registry.ts"
click node_domain_types "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/types.ts"
click node_run_store_contract "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/run-store.ts"
click node_memory_store "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/memory-run-store.ts"
click node_postgres_store "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/postgres-run-store.ts"
click node_run_schema "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/migrations/001_run_store.sql"
click node_claim_schema "https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/migrations/002_execution_claims.sql"

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_planner,node_plan_validation,node_human_reviewer toneBlue
class node_control_plane,node_approval_policy,node_domain_types toneAmber
class node_tool_registry,node_tool_handlers,node_verification toneMint
class node_run_store_contract,node_memory_store,node_postgres_store,node_postgres_db,node_run_schema,node_claim_schema toneRose
class node_goal,node_model_provider toneIndigo
```

## Components

### Planning

- [Planner Adapter](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/planner.ts): `src/planner.ts`
- [Plan Validation](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/planner.ts): `src/planner.ts`

### Safety Governance

- [Control Plane](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/control-plane.ts): `src/control-plane.ts`
- [Approval Policy](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/approval-policy.ts): `src/approval-policy.ts`
- [Domain Types](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/types.ts): `src/types.ts`

### Execution

- [Tool Registry](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/tool-registry.ts): `src/tool-registry.ts`
- [Registered Tool Handlers](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/tool-registry.ts): `src/tool-registry.ts`
- **Verification Callback**

### Run Persistence

- [Run Store Contract](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/run-store.ts): `src/run-store.ts`
- [In-Memory Store](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/memory-run-store.ts): `src/memory-run-store.ts`
- [PostgreSQL Store](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/src/postgres-run-store.ts): `src/postgres-run-store.ts`
- **PostgreSQL Database**
- [Run Schema](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/migrations/001_run_store.sql): `migrations/001_run_store.sql`
- [Execution Claims Schema](https://github.com/rubanchakravarthib308-spec/agent-control-plane/blob/main/migrations/002_execution_claims.sql): `migrations/002_execution_claims.sql`

### Other components

- **Agent Goal**
- **Model Provider**
- **Human Reviewer**

## Connections

- Agent Goal → Control Plane: submits goal (evidence: `README.md`)
- Control Plane → Planner Adapter: requests plan (evidence: `src/control-plane.ts`)
- Planner Adapter → Model Provider: generates proposal (evidence: `src/planner.ts`)
- Planner Adapter → Plan Validation: validates plan (evidence: `src/planner.ts`)
- Control Plane → Approval Policy: builds and checks (evidence: `src/control-plane.ts`)
- Control Plane → Human Reviewer: requests decision (evidence: `src/control-plane.ts`)
- Control Plane → Tool Registry: executes step (evidence: `src/control-plane.ts`)
- Tool Registry → Registered Tool Handlers: dispatches handler (evidence: `src/tool-registry.ts`)
- Control Plane → Verification Callback: verifies output (evidence: `src/control-plane.ts`)
- Control Plane → Run Store Contract: records run (evidence: `src/control-plane.ts`)
- In-Memory Store → Run Store Contract: implements contract (evidence: `src/memory-run-store.ts`)
- PostgreSQL Store → Run Store Contract: implements contract (evidence: `src/postgres-run-store.ts`)
- Control Plane → In-Memory Store: defaults to (evidence: `src/control-plane.ts`)
- PostgreSQL Store → PostgreSQL Database: reads and writes (evidence: `src/postgres-run-store.ts`)
- PostgreSQL Database → Run Schema: uses run tables
- PostgreSQL Database → Execution Claims Schema: uses claim table
- Control Plane → Domain Types: uses domain records (evidence: `src/control-plane.ts`)
