# monolithic-dev/agent-mandate architecture

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

- Interactive diagram: https://gitdiagram.com/monolithic-dev/agent-mandate
- Repository: https://github.com/monolithic-dev/agent-mandate

## Overview

Agent Mandate is an authority gateway for AI agents: instructions and delegations are grounded in trusted human utterances, checked at the action boundary, and explained through graph lineage. The principal path is agent action → gateway check → authority decision → tenant graph, with held actions available for owner approval. The product also includes REST/MCP interfaces, lineage analysis, evaluations, notifications, and a web console. Some subsystem links are documented rather than shown in sampled implementation, so those links are marked dashed or omitted.

Main entry points: [`src/mandate/authority/service.py`](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/authority/service.py) (Authority service), [`src/mandate/api/app.py`](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/app.py) (REST API), [`ui/src/pages/Studio.tsx`](https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/pages/Studio.tsx) (Console workflows), [`src/mandate/api/tenancy.py`](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/tenancy.py) (Tenant runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_enforcement["Authority enforcement"]
  node_gateway["Action gateway<br/>[guard.py]"]
  node_authority["Authority service<br/>[service.py]"]
  node_policy["Authority checks<br/>[check.py]"]
  node_parser["Instruction parser<br/>[parser.py]"]
  node_domain["Domain models<br/>[domain.py]"]
end

subgraph group_graph["Authority graph"]
  node_graphstore[("Tenant graph store<br/>[store.py]")]
  node_graphclient["FalkorDB client<br/>[client.py]"]
  node_tenant["Tenant runtime<br/>[tenancy.py]"]
end

subgraph group_interfaces["Interfaces and operations"]
  node_api["REST API<br/>[app.py]"]
  node_mcp["MCP servers<br/>[agent_server.py]"]
  node_audit[("Audit trail<br/>[audit.py]")]
  node_webhooks["Webhook delivery<br/>[notify.py]"]
end

subgraph group_lineage["Lineage and evaluation"]
  node_lineage["Lineage analysis<br/>[whatif.py]"]
  node_eval["Evaluation harness<br/>[runner.py]"]
end

subgraph group_console["Web console"]
  node_ui["Console application<br/>[App.tsx]"]
  node_uipages["Console workflows<br/>[Studio.tsx]"]
  node_uiclient["Typed API client<br/>[api.ts]"]
  node_graphview["Graph explorer view<br/>[GraphExplorer.tsx]"]
  node_uicomponents["Console UI primitives<br/>[ui.tsx]"]
  node_icons["Icon components<br/>[icons.tsx]"]
end

node_agent(("AI agent"))
node_owner(("Trusted owner"))

node_agent -->|"proposes action"| node_gateway
node_gateway -->|"requests decision"| node_authority
node_authority -->|"checks authority"| node_policy
node_authority -->|"parses utterances"| node_parser
node_parser -->|"creates instructions"| node_domain
node_authority -->|"validates entities"| node_domain
node_authority -.->|"persists authority"| node_graphstore
node_tenant -->|"builds runtime"| node_authority
node_tenant -->|"configures graph"| node_graphclient
node_graphstore -.->|"executes queries"| node_graphclient
node_graphclient -.->|"reads and writes"| node_graphstore
node_api -->|"resolves tenant"| node_tenant
node_api -->|"handles authority routes"| node_authority
node_api -->|"exposes action gate"| node_gateway
node_api -.->|"records changes"| node_audit
node_api -->|"notifies owners"| node_webhooks
node_mcp -->|"offers agent tools"| node_gateway
node_owner -->|"manages authority"| node_api
node_authority -->|"supports what-if"| node_lineage
node_lineage -->|"replays graph state"| node_graphstore
node_eval -->|"runs scenarios"| node_tenant
node_ui -->|"routes workflows"| node_uipages
node_uipages -->|"requests API data"| node_uiclient
node_uiclient -->|"calls REST endpoints"| node_api
node_uipages -.->|"renders graph exploration"| node_graphview
node_uipages -->|"uses primitives"| node_uicomponents
node_uicomponents -->|"renders icons"| node_icons

click node_gateway "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/gateway/guard.py"
click node_authority "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/authority/service.py"
click node_policy "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/authority/check.py"
click node_parser "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/authority/parser.py"
click node_domain "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/models/domain.py"
click node_graphstore "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/graph/store.py"
click node_graphclient "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/graph/client.py"
click node_tenant "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/tenancy.py"
click node_api "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/app.py"
click node_mcp "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/mcp_servers/agent_server.py"
click node_audit "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/audit.py"
click node_webhooks "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/notify.py"
click node_lineage "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/lineage/whatif.py"
click node_eval "https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/eval/runner.py"
click node_ui "https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/App.tsx"
click node_uipages "https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/pages/Studio.tsx"
click node_uiclient "https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/api.ts"
click node_graphview "https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/components/GraphExplorer.tsx"
click node_uicomponents "https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/components/ui.tsx"
click node_icons "https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/icons.tsx"

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_gateway,node_authority,node_policy,node_parser,node_domain toneBlue
class node_graphstore,node_graphclient,node_tenant toneAmber
class node_api,node_mcp,node_audit,node_webhooks toneMint
class node_lineage,node_eval toneRose
class node_ui,node_uipages,node_uiclient,node_graphview,node_uicomponents,node_icons,node_agent,node_owner toneIndigo
```

## Components

### Authority enforcement

- [Action gateway](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/gateway/guard.py): `src/mandate/gateway/guard.py`
- [Authority service](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/authority/service.py): `src/mandate/authority/service.py`
- [Authority checks](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/authority/check.py): `src/mandate/authority/check.py`
- [Instruction parser](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/authority/parser.py): `src/mandate/authority/parser.py`
- [Domain models](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/models/domain.py): `src/mandate/models/domain.py`

### Authority graph

- [Tenant graph store](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/graph/store.py): `src/mandate/graph/store.py`
- [FalkorDB client](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/graph/client.py): `src/mandate/graph/client.py`
- [Tenant runtime](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/tenancy.py): `src/mandate/api/tenancy.py`

### Interfaces and operations

- [REST API](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/app.py): `src/mandate/api/app.py`
- [MCP servers](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/mcp_servers/agent_server.py): `src/mandate/mcp_servers/agent_server.py`
- [Audit trail](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/audit.py): `src/mandate/api/audit.py`
- [Webhook delivery](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/api/notify.py): `src/mandate/api/notify.py`

### Lineage and evaluation

- [Lineage analysis](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/lineage/whatif.py): `src/mandate/lineage/whatif.py`
- [Evaluation harness](https://github.com/monolithic-dev/agent-mandate/blob/main/src/mandate/eval/runner.py): `src/mandate/eval/runner.py`

### Web console

- [Console application](https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/App.tsx): `ui/src/App.tsx`
- [Console workflows](https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/pages/Studio.tsx): `ui/src/pages/Studio.tsx`
- [Typed API client](https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/api.ts): `ui/src/api.ts`
- [Graph explorer view](https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/components/GraphExplorer.tsx): `ui/src/components/GraphExplorer.tsx`
- [Console UI primitives](https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/components/ui.tsx): `ui/src/components/ui.tsx`
- [Icon components](https://github.com/monolithic-dev/agent-mandate/blob/main/ui/src/icons.tsx): `ui/src/icons.tsx`

### Other components

- **AI agent**
- **Trusted owner**

## Connections

- AI agent → Action gateway: proposes action (evidence: `README.md`)
- Action gateway → Authority service: requests decision (evidence: `README.md`)
- Authority service → Authority checks: checks authority (evidence: `src/mandate/authority/service.py`)
- Authority service → Instruction parser: parses utterances (evidence: `src/mandate/authority/service.py`)
- Instruction parser → Domain models: creates instructions (evidence: `src/mandate/authority/parser.py`)
- Authority service → Domain models: validates entities (evidence: `src/mandate/authority/service.py`)
- Authority service → Tenant graph store: persists authority
- Tenant runtime → Authority service: builds runtime (evidence: `src/mandate/api/tenancy.py`)
- Tenant runtime → FalkorDB client: configures graph (evidence: `src/mandate/api/tenancy.py`)
- Tenant graph store → FalkorDB client: executes queries
- FalkorDB client → Tenant graph store: reads and writes
- REST API → Tenant runtime: resolves tenant (evidence: `src/mandate/api/tenancy.py`)
- REST API → Authority service: handles authority routes
- REST API → Action gateway: exposes action gate (evidence: `README.md`)
- REST API → Audit trail: records changes (evidence: `src/mandate/api/app.py`)
- REST API → Webhook delivery: notifies owners (evidence: `src/mandate/api/app.py`)
- MCP servers → Action gateway: offers agent tools (evidence: `README.md`)
- Trusted owner → REST API: manages authority (evidence: `README.md`)
- Authority service → Lineage analysis: supports what-if (evidence: `src/mandate/lineage/whatif.py`)
- Lineage analysis → Tenant graph store: replays graph state (evidence: `README.md`)
- Evaluation harness → Tenant runtime: runs scenarios
- Console application → Console workflows: routes workflows (evidence: `ui/src/App.tsx`)
- Console workflows → Typed API client: requests API data (evidence: `ui/src/api.ts`)
- Typed API client → REST API: calls REST endpoints (evidence: `ui/src/api.ts`)
- Console workflows → Graph explorer view: renders graph exploration
- Console workflows → Console UI primitives: uses primitives (evidence: `ui/src/App.tsx`)
- Console UI primitives → Icon components: renders icons (evidence: `ui/src/components/ui.tsx`)
