# naralanaveen33-hub/dimitri architecture

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

- Interactive diagram: https://gitdiagram.com/naralanaveen33-hub/dimitri
- Repository: https://github.com/naralanaveen33-hub/dimitri

## Overview

Dimitri is an autonomous self-healing platform with two recovery paths: infrastructure recovery and application-code repair. Its central workflow detects an application failure, records an incident, diagnoses it, formulates and validates a patch, then stages and optionally promotes it through a guarded production canary. The graph also preserves monitoring, approvals, persistence, metrics, and incident communication. Some subsystem links are based on README-level capability descriptions; unsampled implementation details are not inferred beyond those documented flows.

Main entry points: [`agent/incident.py`](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/incident.py) (Incident Coordinator), [`agent/production/pipeline.py`](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/production/pipeline.py) (Production Pipeline), [`agent/monitor.py`](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/monitor.py) (Health Monitor), [`agent/patching/patch_engine.py`](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/patch_engine.py) (Patch Formulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Detection &amp; Coordination"]
  node_agent_entry["Agent Runtime<br/>[main.py]"]
  node_monitor["Health Monitor<br/>[monitor.py]"]
  node_incident["Incident Coordinator<br/>[incident.py]"]
  node_recovery["Recovery Helper<br/>[main.py]"]
end

subgraph group_repair["Diagnosis &amp; Repair"]
  node_diagnosis["Error Diagnosis<br/>[diagnosis.py]"]
  node_repair_planner["Repair Planning<br/>[repair_planner.py]"]
  node_patch_engine["Patch Formulation<br/>[patch_engine.py]"]
  node_ai_provider["AI Provider<br/>[ai_provider.py]"]
  node_patch_validator["Patch Security Checks<br/>[patch_validator.py]"]
  node_git_workspace["Isolated Git Workspace<br/>[git_manager.py]"]
end

subgraph group_release["Validation &amp; Release"]
  node_validation["Patch Validation<br/>[pipeline.py]"]
  node_sandbox["Sandbox Runner<br/>[sandbox_runner.py]"]
  node_staging["Staging Pipeline<br/>[pipeline.py]"]
  node_staging_deploy["Staging Deployment"]
  node_staging_rollback["Staging Rollback"]
  node_production["Production Pipeline<br/>[pipeline.py]"]
  node_canary["Canary Validation<br/>[canary_manager.py]"]
  node_production_rollback["Production Rollback"]
end

subgraph group_governance["Safety &amp; State"]
  node_autonomy["Autonomy Policy<br/>[autonomy.py]"]
  node_approvals["HMAC Approvals"]
  node_storage[("Incident Ledger<br/>[storage.py]")]
  node_metrics["Metrics<br/>[metrics.py]"]
end

subgraph group_communication["Operations &amp; Alerts"]
  node_notifier["Email Notifier<br/>[notifier.py]"]
  node_templates["Message Templates"]
end

node_application["Monitored Application"]
node_admin(("Administrator"))
node_prometheus["Prometheus"]
node_grafana["Grafana"]

node_agent_entry -->|"starts"| node_monitor
node_agent_entry -->|"initializes"| node_incident
node_application -->|"health probes"| node_monitor
node_monitor -.->|"reports failures"| node_incident
node_monitor -->|"dispatches restart"| node_recovery
node_incident -->|"diagnoses error"| node_diagnosis
node_diagnosis -->|"plans repair"| node_repair_planner
node_incident -->|"requests patch"| node_patch_engine
node_patch_engine -->|"generates proposal"| node_ai_provider
node_patch_engine -->|"validates patch"| node_patch_validator
node_patch_engine -->|"applies patch"| node_git_workspace
node_incident -.->|"validates repair"| node_validation
node_validation -->|"creates workspace"| node_git_workspace
node_validation -->|"runs sandbox"| node_sandbox
node_incident -->|"requests staging"| node_staging
node_staging -->|"deploys candidate"| node_staging_deploy
node_staging -->|"triggers rollback"| node_staging_rollback
node_staging -.->|"promotes candidate"| node_production
node_production -->|"checks level"| node_autonomy
node_production -->|"checks authorization"| node_approvals
node_production -->|"runs canary"| node_canary
node_production -->|"rolls back"| node_production_rollback
node_incident -->|"saves incident"| node_storage
node_incident -.->|"sends alerts"| node_notifier
node_notifier -->|"renders messages"| node_templates
node_admin -->|"authorizes action"| node_approvals
node_monitor -.->|"records metrics"| node_metrics
node_prometheus -.->|"scrapes metrics"| node_metrics
node_grafana -->|"visualizes metrics"| node_prometheus

click node_agent_entry "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/main.py"
click node_monitor "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/monitor.py"
click node_incident "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/incident.py"
click node_recovery "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/recovery_helper/main.py"
click node_diagnosis "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/diagnostics/diagnosis.py"
click node_repair_planner "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/diagnostics/repair_planner.py"
click node_patch_engine "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/patch_engine.py"
click node_ai_provider "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/ai_provider.py"
click node_patch_validator "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/patch_validator.py"
click node_git_workspace "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/git_manager.py"
click node_validation "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/validation/pipeline.py"
click node_sandbox "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/validation/sandbox_runner.py"
click node_staging "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/staging/pipeline.py"
click node_staging_deploy "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/staging/deployment_manager.py"
click node_staging_rollback "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/staging/rollback_manager.py"
click node_production "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/production/pipeline.py"
click node_canary "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/production/canary_manager.py"
click node_production_rollback "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/production/production_rollback_manager.py"
click node_autonomy "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/policy/autonomy.py"
click node_approvals "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/approvals/approval_manager.py"
click node_storage "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/storage.py"
click node_metrics "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/metrics.py"
click node_notifier "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/notifications/notifier.py"
click node_templates "https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/notifications/template_renderer.py"

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_agent_entry,node_monitor,node_incident,node_recovery toneBlue
class node_diagnosis,node_repair_planner,node_patch_engine,node_ai_provider,node_patch_validator,node_git_workspace toneAmber
class node_validation,node_sandbox,node_staging,node_staging_deploy,node_staging_rollback,node_production,node_canary,node_production_rollback toneMint
class node_autonomy,node_approvals,node_storage,node_metrics toneRose
class node_notifier,node_templates,node_application,node_admin,node_prometheus,node_grafana toneIndigo
```

## Components

### Detection & Coordination

- [Agent Runtime](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/main.py): `agent/main.py`
- [Health Monitor](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/monitor.py): `agent/monitor.py`
- [Incident Coordinator](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/incident.py): `agent/incident.py`
- [Recovery Helper](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/recovery_helper/main.py): `agent/recovery_helper/main.py`

### Diagnosis & Repair

- [Error Diagnosis](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/diagnostics/diagnosis.py): `agent/diagnostics/diagnosis.py`
- [Repair Planning](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/diagnostics/repair_planner.py): `agent/diagnostics/repair_planner.py`
- [Patch Formulation](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/patch_engine.py): `agent/patching/patch_engine.py`
- [AI Provider](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/ai_provider.py): `agent/patching/ai_provider.py`
- [Patch Security Checks](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/patch_validator.py): `agent/patching/patch_validator.py`
- [Isolated Git Workspace](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/patching/git_manager.py): `agent/patching/git_manager.py`

### Validation & Release

- [Patch Validation](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/validation/pipeline.py): `agent/validation/pipeline.py`
- [Sandbox Runner](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/validation/sandbox_runner.py): `agent/validation/sandbox_runner.py`
- [Staging Pipeline](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/staging/pipeline.py): `agent/staging/pipeline.py`
- [Staging Deployment](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/staging/deployment_manager.py): `agent/staging/deployment_manager.py`
- [Staging Rollback](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/staging/rollback_manager.py): `agent/staging/rollback_manager.py`
- [Production Pipeline](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/production/pipeline.py): `agent/production/pipeline.py`
- [Canary Validation](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/production/canary_manager.py): `agent/production/canary_manager.py`
- [Production Rollback](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/production/production_rollback_manager.py): `agent/production/production_rollback_manager.py`

### Safety & State

- [Autonomy Policy](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/policy/autonomy.py): `agent/policy/autonomy.py`
- [HMAC Approvals](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/approvals/approval_manager.py): `agent/approvals/approval_manager.py`
- [Incident Ledger](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/storage.py): `agent/storage.py`
- [Metrics](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/metrics.py): `agent/metrics.py`

### Operations & Alerts

- [Email Notifier](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/notifications/notifier.py): `agent/notifications/notifier.py`
- [Message Templates](https://github.com/naralanaveen33-hub/dimitri/blob/main/agent/notifications/template_renderer.py): `agent/notifications/template_renderer.py`

### Other components

- **Monitored Application**
- **Administrator**
- **Prometheus**
- **Grafana**

## Connections

- Agent Runtime → Health Monitor: starts (evidence: `agent/main.py`)
- Agent Runtime → Incident Coordinator: initializes (evidence: `agent/main.py`)
- Monitored Application → Health Monitor: health probes (evidence: `README.md`)
- Health Monitor → Incident Coordinator: reports failures (evidence: `agent/incident.py`)
- Health Monitor → Recovery Helper: dispatches restart (evidence: `README.md`)
- Incident Coordinator → Error Diagnosis: diagnoses error (evidence: `agent/incident.py`)
- Error Diagnosis → Repair Planning: plans repair (evidence: `agent/diagnostics/diagnosis.py`)
- Incident Coordinator → Patch Formulation: requests patch (evidence: `agent/incident.py`)
- Patch Formulation → AI Provider: generates proposal (evidence: `agent/patching/patch_engine.py`)
- Patch Formulation → Patch Security Checks: validates patch (evidence: `agent/patching/patch_engine.py`)
- Patch Formulation → Isolated Git Workspace: applies patch (evidence: `agent/patching/patch_engine.py`)
- Incident Coordinator → Patch Validation: validates repair (evidence: `agent/incident.py`)
- Patch Validation → Isolated Git Workspace: creates workspace (evidence: `agent/validation/pipeline.py`)
- Patch Validation → Sandbox Runner: runs sandbox (evidence: `agent/validation/pipeline.py`)
- Incident Coordinator → Staging Pipeline: requests staging (evidence: `agent/incident.py`)
- Staging Pipeline → Staging Deployment: deploys candidate (evidence: `agent/staging/pipeline.py`)
- Staging Pipeline → Staging Rollback: triggers rollback (evidence: `agent/staging/pipeline.py`)
- Staging Pipeline → Production Pipeline: promotes candidate
- Production Pipeline → Autonomy Policy: checks level (evidence: `agent/production/pipeline.py`)
- Production Pipeline → HMAC Approvals: checks authorization (evidence: `agent/production/pipeline.py`)
- Production Pipeline → Canary Validation: runs canary (evidence: `agent/production/pipeline.py`)
- Production Pipeline → Production Rollback: rolls back (evidence: `agent/production/pipeline.py`)
- Incident Coordinator → Incident Ledger: saves incident (evidence: `agent/incident.py`)
- Incident Coordinator → Email Notifier: sends alerts (evidence: `agent/incident.py`)
- Email Notifier → Message Templates: renders messages (evidence: `agent/notifications/notifier.py`)
- Administrator → HMAC Approvals: authorizes action (evidence: `agent/approvals/approval_manager.py`)
- Health Monitor → Metrics: records metrics
- Prometheus → Metrics: scrapes metrics (evidence: `README.md`)
- Grafana → Prometheus: visualizes metrics (evidence: `README.md`)
