# dimashenkov/ai-incident-investigator architecture

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

- Interactive diagram: https://gitdiagram.com/dimashenkov/ai-incident-investigator
- Repository: https://github.com/dimashenkov/ai-incident-investigator

## Overview

AI SRE is a prototype Kubernetes incident investigator: a simulated Datadog alert and fixture-backed observations feed specialized agents, a root-cause conclusion, and a redacted Slack report. A separate Slack thread bot answers follow-up questions. Its documented improvement loop runs scenarios, scores results, diagnoses failures, and keeps prompt changes only when evaluation supports them. Source-index imports and excerpts support the internal assembly, context, validation, merge, and provider relationships; other workflow and integration links rely on README statements, since the generated workflow artifacts are not in the supplied tree.

Main entry points: [`src/core/assemble.ts`](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/assemble.ts) (Incident assembly), [`src/agents/context.ts`](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/agents/context.ts) (Agent contexts), [`src/core/redact.ts`](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/redact.ts) (Output redaction), [`src/providers/provider.ts`](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/provider.ts) (Provider contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_investigation["Incident investigation"]
  node_assembly["Incident assembly<br/>[assemble.ts]"]
  node_validation["Schema validation<br/>[validate.ts]"]
  node_agent_context["Agent contexts<br/>[context.ts]"]
  node_agent_slices["Agent slices<br/>[slice.ts]"]
  node_configuration["Model configuration<br/>[configuration.ts]"]
  node_merge["Result merge<br/>[merge.ts]"]
  node_root_cause["Root cause<br/>[assemble.ts]"]
  node_report["Incident report<br/>[report.ts]"]
end

subgraph group_providers["Observation providers"]
  node_provider_contract["Provider contract<br/>[provider.ts]"]
  node_provider_registry["Provider registry<br/>[registry.ts]"]
  node_fixture_data["Fixture providers<br/>[fixtures.ts]"]
  node_kubernetes_provider["Kubernetes provider<br/>[kubernetes.ts]"]
  node_rogue_provider["Fallback provider<br/>[rogue.ts]"]
end

subgraph group_slack["Slack interaction"]
  node_redaction["Output redaction<br/>[redact.ts]"]
  node_slack_publish["Slack publisher<br/>[slack-post.ts]"]
  node_thread_listener["Slack listener<br/>[slack.ts]"]
  node_thread_index[("Thread index<br/>[thread-index.ts]")]
  node_reply["Thread replies<br/>[reply.ts]"]
  node_thread_builder["Thread builder<br/>[thread.ts]"]
end

subgraph group_evaluation["Evaluation loop"]
  node_scenario_runner["Scenario runner<br/>[run-scenarios.mjs]"]
  node_run_scorer["Run scorer<br/>[score-run.mjs]"]
  node_eval_engine["Eval and keep rule<br/>[eval.ts]"]
  node_eval_command["Eval command<br/>[eval.mjs]"]
end

node_alert(("Datadog alert"))
node_slack_channel(("Slack channel"))

node_alert -->|"triggers"| node_assembly
node_assembly -->|"reads fixtures"| node_fixture_data
node_assembly -.->|"selects provider"| node_provider_registry
node_provider_registry -->|"implements"| node_provider_contract
node_fixture_data -->|"implements"| node_provider_contract
node_kubernetes_provider -->|"implements"| node_provider_contract
node_rogue_provider -->|"implements"| node_provider_contract
node_assembly -->|"validates incident"| node_validation
node_assembly -.->|"provides incident"| node_agent_context
node_agent_context -->|"builds contexts"| node_agent_slices
node_agent_context -->|"reads configuration"| node_configuration
node_agent_context -.->|"supplies context"| node_root_cause
node_root_cause -.->|"concludes for merge"| node_merge
node_merge -->|"checks result"| node_validation
node_merge -.->|"provides verdict"| node_report
node_report -.->|"formats for posting"| node_redaction
node_redaction -.->|"redacts output"| node_slack_publish
node_slack_publish -->|"posts report"| node_slack_channel
node_slack_channel -->|"receives questions"| node_thread_listener
node_thread_listener -.->|"indexes threads"| node_thread_index
node_thread_listener -.->|"routes question"| node_reply
node_reply -.->|"builds answer"| node_thread_builder
node_reply -.->|"redacts reply"| node_redaction
node_redaction -.->|"posts reply"| node_slack_channel
node_scenario_runner -->|"submits scenario"| node_alert
node_scenario_runner -.->|"records runs"| node_run_scorer
node_run_scorer -->|"supplies scores"| node_eval_command
node_eval_command -->|"applies keep rule"| node_eval_engine

click node_assembly "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/assemble.ts"
click node_provider_contract "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/provider.ts"
click node_provider_registry "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/registry.ts"
click node_fixture_data "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/fixtures.ts"
click node_kubernetes_provider "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/kubernetes.ts"
click node_rogue_provider "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/rogue.ts"
click node_validation "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/schema/validate.ts"
click node_agent_context "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/agents/context.ts"
click node_agent_slices "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/agents/slice.ts"
click node_configuration "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/configuration.ts"
click node_merge "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/merge.ts"
click node_root_cause "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/assemble.ts"
click node_report "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/report.ts"
click node_redaction "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/redact.ts"
click node_slack_publish "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/slack-post.ts"
click node_thread_listener "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/slack.ts"
click node_thread_index "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/thread-index.ts"
click node_reply "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/reply.ts"
click node_thread_builder "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/thread.ts"
click node_scenario_runner "https://github.com/dimashenkov/ai-incident-investigator/blob/main/scripts/run-scenarios.mjs"
click node_run_scorer "https://github.com/dimashenkov/ai-incident-investigator/blob/main/scripts/score-run.mjs"
click node_eval_engine "https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/eval.ts"
click node_eval_command "https://github.com/dimashenkov/ai-incident-investigator/blob/main/scripts/eval.mjs"

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_assembly,node_validation,node_agent_context,node_agent_slices,node_configuration,node_merge,node_root_cause,node_report toneBlue
class node_provider_contract,node_provider_registry,node_fixture_data,node_kubernetes_provider,node_rogue_provider toneAmber
class node_redaction,node_slack_publish,node_thread_listener,node_thread_index,node_reply,node_thread_builder toneMint
class node_scenario_runner,node_run_scorer,node_eval_engine,node_eval_command toneRose
class node_alert,node_slack_channel toneIndigo
```

## Components

### Incident investigation

- [Incident assembly](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/assemble.ts): `src/core/assemble.ts`
- [Schema validation](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/schema/validate.ts): `src/schema/validate.ts`
- [Agent contexts](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/agents/context.ts): `src/agents/context.ts`
- [Agent slices](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/agents/slice.ts): `src/agents/slice.ts`
- [Model configuration](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/configuration.ts): `src/core/configuration.ts`
- [Result merge](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/merge.ts): `src/core/merge.ts`
- [Root cause](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/assemble.ts): `src/core/assemble.ts`
- [Incident report](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/report.ts): `src/core/report.ts`

### Observation providers

- [Provider contract](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/provider.ts): `src/providers/provider.ts`
- [Provider registry](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/registry.ts): `src/providers/registry.ts`
- [Fixture providers](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/fixtures.ts): `src/providers/fixtures.ts`
- [Kubernetes provider](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/kubernetes.ts): `src/providers/kubernetes.ts`
- [Fallback provider](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/rogue.ts): `src/providers/rogue.ts`

### Slack interaction

- [Output redaction](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/redact.ts): `src/core/redact.ts`
- [Slack publisher](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/slack-post.ts): `src/providers/slack-post.ts`
- [Slack listener](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/slack.ts): `src/providers/slack.ts`
- [Thread index](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/providers/thread-index.ts): `src/providers/thread-index.ts`
- [Thread replies](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/reply.ts): `src/core/reply.ts`
- [Thread builder](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/thread.ts): `src/core/thread.ts`

### Evaluation loop

- [Scenario runner](https://github.com/dimashenkov/ai-incident-investigator/blob/main/scripts/run-scenarios.mjs): `scripts/run-scenarios.mjs`
- [Run scorer](https://github.com/dimashenkov/ai-incident-investigator/blob/main/scripts/score-run.mjs): `scripts/score-run.mjs`
- [Eval and keep rule](https://github.com/dimashenkov/ai-incident-investigator/blob/main/src/core/eval.ts): `src/core/eval.ts`
- [Eval command](https://github.com/dimashenkov/ai-incident-investigator/blob/main/scripts/eval.mjs): `scripts/eval.mjs`

### Other components

- **Datadog alert**
- **Slack channel**

## Connections

- Datadog alert → Incident assembly: triggers (evidence: `README.md`)
- Incident assembly → Fixture providers: reads fixtures (evidence: `src/core/assemble.ts`)
- Incident assembly → Provider registry: selects provider
- Provider registry → Provider contract: implements (evidence: `src/providers/registry.ts`)
- Fixture providers → Provider contract: implements (evidence: `src/providers/fixtures.ts`)
- Kubernetes provider → Provider contract: implements (evidence: `src/providers/kubernetes.ts`)
- Fallback provider → Provider contract: implements (evidence: `src/providers/registry.ts`)
- Incident assembly → Schema validation: validates incident (evidence: `src/core/assemble.ts`)
- Incident assembly → Agent contexts: provides incident
- Agent contexts → Agent slices: builds contexts (evidence: `src/agents/context.ts`)
- Agent contexts → Model configuration: reads configuration (evidence: `src/agents/context.ts`)
- Agent contexts → Root cause: supplies context (evidence: `README.md`)
- Root cause → Result merge: concludes for merge (evidence: `src/core/assemble.ts`)
- Result merge → Schema validation: checks result
- Result merge → Incident report: provides verdict
- Incident report → Output redaction: formats for posting (evidence: `README.md`)
- Output redaction → Slack publisher: redacts output (evidence: `README.md`)
- Slack publisher → Slack channel: posts report (evidence: `README.md`)
- Slack channel → Slack listener: receives questions (evidence: `README.md`)
- Slack listener → Thread index: indexes threads
- Slack listener → Thread replies: routes question
- Thread replies → Thread builder: builds answer
- Thread replies → Output redaction: redacts reply (evidence: `README.md`)
- Output redaction → Slack channel: posts reply (evidence: `README.md`)
- Scenario runner → Datadog alert: submits scenario (evidence: `README.md`)
- Scenario runner → Run scorer: records runs
- Run scorer → Eval command: supplies scores (evidence: `scripts/eval.mjs`)
- Eval command → Eval and keep rule: applies keep rule (evidence: `scripts/eval.mjs`)
