# theusererr0r/deadbolt architecture

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

- Interactive diagram: https://gitdiagram.com/theusererr0r/deadbolt
- Repository: https://github.com/theusererr0r/deadbolt

## Overview

Deadbolt is a local control plane for human-approved, time-limited privileged actions. Hermes submits a structured request to the unprivileged bot, which relays it to the root executor; the executor validates it against root-owned policy, records it, and presents an approval card through Discord. After approval, the executor applies a fixed action and tracks expiry or rollback. Separate operator capabilities cover emergency stop and recovery, and approved body-capture exclusions. The README documents the external integrations; source excerpts establish key validation, persistence, and protocol responsibilities, but not every runtime call.

Main entry points: [`src/deadbolt/executor.py`](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/executor.py) (Root executor), [`src/deadbolt/actions.py`](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/actions.py) (Privileged actions), [`src/deadbolt/bot.py`](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/bot.py) (Bot relay), [`src/deadbolt/emergency_restore.py`](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/emergency_restore.py) (Boot-time restore)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_relay["Request and approval"]
  node_bot["Bot relay<br/>[bot.py]"]
  node_protocol["Socket protocol<br/>[protocol.py]"]
end

subgraph group_policy["Policy and actions"]
  node_executor["Root executor<br/>[executor.py]"]
  node_config["Policy configuration<br/>[config.py]"]
  node_actions["Privileged actions<br/>[actions.py]"]
  node_capturehelper["Capture helper"]
  node_ufw["UFW firewall"]
  node_exclusions["Exclusion matcher<br/>[exclusion_match.py]"]
  node_expiry["Capture expiry timer"]
end

subgraph group_state["State and audit"]
  node_store[("Request and emergency state<br/>[store.py]")]
  node_audit["Audit log<br/>[store.py]"]
end

subgraph group_emergency["Emergency controls"]
  node_nftables["Emergency nftables block"]
  node_restore["Boot-time restore"]
end

node_hermes(("Hermes agent"))
node_operator(("Discord operator"))
node_proxy["Hermes TLS proxy"]

node_hermes -->|"submits request"| node_bot
node_bot -->|"relays request"| node_executor
node_operator -->|"approves or denies"| node_bot
node_bot -->|"uses socket RPC"| node_protocol
node_executor -->|"serves socket RPC"| node_protocol
node_executor -->|"validates policy"| node_config
node_executor -->|"validates and applies"| node_actions
node_executor -->|"tracks requests"| node_store
node_executor -->|"records events"| node_audit
node_actions -->|"applies firewall rules"| node_ufw
node_actions -->|"runs fixed helper"| node_capturehelper
node_actions -->|"updates exclusions"| node_exclusions
node_proxy -.->|"checks equivalent logic"| node_exclusions
node_restore -->|"reads emergency state"| node_store
node_restore -->|"enforces block"| node_actions
node_actions -->|"installs emergency block"| node_nftables

click node_bot "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/bot.py"
click node_protocol "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/protocol.py"
click node_executor "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/executor.py"
click node_config "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/config.py"
click node_actions "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/actions.py"
click node_exclusions "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/exclusion_match.py"
click node_store "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/store.py"
click node_audit "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/store.py"
click node_restore "https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/emergency_restore.py"
click node_expiry "https://github.com/theusererr0r/deadbolt/blob/main/systemd/hermes-body-capture-expiry.timer"

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_bot,node_protocol toneBlue
class node_executor,node_config,node_actions,node_capturehelper,node_ufw,node_exclusions,node_expiry toneAmber
class node_store,node_audit toneMint
class node_nftables,node_restore toneRose
class node_hermes,node_operator,node_proxy toneIndigo
```

## Components

### Request and approval

- [Bot relay](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/bot.py): `src/deadbolt/bot.py`
- [Socket protocol](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/protocol.py): `src/deadbolt/protocol.py`

### Policy and actions

- [Root executor](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/executor.py): `src/deadbolt/executor.py`
- [Policy configuration](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/config.py): `src/deadbolt/config.py`
- [Privileged actions](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/actions.py): `src/deadbolt/actions.py`
- **Capture helper**
- **UFW firewall**
- [Exclusion matcher](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/exclusion_match.py): `src/deadbolt/exclusion_match.py`
- [Capture expiry timer](https://github.com/theusererr0r/deadbolt/blob/main/systemd/hermes-body-capture-expiry.timer): `systemd/hermes-body-capture-expiry.timer`

### State and audit

- [Request and emergency state](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/store.py): `src/deadbolt/store.py`
- [Audit log](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/store.py): `src/deadbolt/store.py`

### Emergency controls

- **Emergency nftables block**
- [Boot-time restore](https://github.com/theusererr0r/deadbolt/blob/main/src/deadbolt/emergency_restore.py): `src/deadbolt/emergency_restore.py`

### Other components

- **Hermes agent**
- **Discord operator**
- **Hermes TLS proxy**

## Connections

- Hermes agent → Bot relay: submits request (evidence: `README.md`)
- Bot relay → Root executor: relays request (evidence: `README.md`)
- Discord operator → Bot relay: approves or denies (evidence: `README.md`)
- Bot relay → Socket protocol: uses socket RPC (evidence: `src/deadbolt/bot.py`)
- Root executor → Socket protocol: serves socket RPC (evidence: `src/deadbolt/executor.py`)
- Root executor → Policy configuration: validates policy (evidence: `src/deadbolt/executor.py`)
- Root executor → Privileged actions: validates and applies (evidence: `src/deadbolt/executor.py`)
- Root executor → Request and emergency state: tracks requests (evidence: `src/deadbolt/executor.py`)
- Root executor → Audit log: records events (evidence: `README.md`)
- Privileged actions → UFW firewall: applies firewall rules (evidence: `README.md`)
- Privileged actions → Capture helper: runs fixed helper (evidence: `README.md`)
- Privileged actions → Exclusion matcher: updates exclusions (evidence: `README.md`)
- Hermes TLS proxy → Exclusion matcher: checks equivalent logic (evidence: `src/deadbolt/exclusion_match.py`)
- Boot-time restore → Request and emergency state: reads emergency state (evidence: `src/deadbolt/emergency_restore.py`)
- Boot-time restore → Privileged actions: enforces block (evidence: `src/deadbolt/emergency_restore.py`)
- Privileged actions → Emergency nftables block: installs emergency block (evidence: `README.md`)
