# lzwhehe/hesp architecture

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

- Interactive diagram: https://gitdiagram.com/lzwhehe/hesp
- Repository: https://github.com/lzwhehe/hesp

## Overview

HESP is a research system for triaging known alert types with a small local model as a log reader and a controller that chooses probes and validates conclusions. The main workflow is alert/task setup, probe execution, evidence interpretation, Bayesian state updates, probe selection and guarded stopping; study runners exercise this loop and generate research outputs. The README documents sec, sigma and comp-triage task families and local-model adapters. Some subsystem links rely on that documentation because their implementations were not sampled.

Main entry points: [`hesp_research/hesp/controller.py`](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/controller.py) (Controller loop), [`hesp_research/hesp/study.py`](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/study.py) (Study runner), [`hesp_research/hesp/sandbox.py`](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/sandbox.py) (Probe sandbox), [`hesp_research/hesp/planner.py`](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/planner.py) (Planner policies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Triage workflow"]
  node_controller["Controller loop<br/>[controller.py]"]
  node_ledger["Evidence ledger<br/>[core.py]"]
  node_selector["Probe selector<br/>[selectors.py]"]
  node_predictor["Prediction tables<br/>[predictors.py]"]
end

subgraph group_tasks["Task environments"]
  node_sandbox["Probe sandbox<br/>[sandbox.py]"]
  node_sec["Security triage<br/>[secapp.py]"]
  node_sigma["Sigma triage<br/>[sigmaapp.py]"]
  node_comp["Comp triage<br/>[compapp.py]"]
  node_guide["GUIDE triage<br/>[guideapp.py]"]
  node_web["Web interface<br/>[webapp.py]"]
  node_upload["Task upload<br/>[uploadapp.py]"]
end

subgraph group_models["Planning and reading"]
  node_rawlog["Raw-log reader<br/>[rawlog.py]"]
  node_llm["Local model client<br/>[llm.py]"]
  node_planner["Planner policies<br/>[planner.py]"]
end

subgraph group_research["Studies and analysis"]
  node_study["Study runner<br/>[study.py]"]
  node_audit["Audit analysis<br/>[audit.py]"]
  node_analysis["Study analysis<br/>[analysis.py]"]
  node_tables["Table studies<br/>[v10a_tables.py]"]
  node_mismatch["Mismatch studies<br/>[v10b_mismatch.py]"]
  node_v11["v1.1 experiments<br/>[v11_llmfree.py]"]
  node_v12["v1.2 experiments<br/>[v12_llmfree.py]"]
end

node_analyst(("Analyst"))

node_analyst -.->|"starts study"| node_study
node_study -.->|"runs episodes"| node_controller
node_controller -->|"updates beliefs"| node_ledger
node_controller -->|"chooses probes"| node_selector
node_controller -->|"gets likelihoods"| node_predictor
node_controller -.->|"executes probes"| node_sandbox
node_controller -.->|"requests decision"| node_planner
node_controller -.->|"classifies logs"| node_rawlog
node_planner -.->|"uses model"| node_llm
node_sandbox -->|"uses task behavior"| node_sec
node_sandbox -.->|"uses task behavior"| node_sigma
node_sandbox -->|"uses task behavior"| node_comp
node_sandbox -.->|"uses task behavior"| node_guide
node_web -.->|"serves probes"| node_sandbox
node_upload -.->|"provides tasks"| node_study
node_study -.->|"supports evaluation"| node_tables
node_study -.->|"supports evaluation"| node_mismatch
node_v11 -->|"runs comparisons"| node_controller
node_v12 -->|"runs comparisons"| node_controller
node_study -.->|"summarizes results"| node_analysis
node_study -.->|"audits runs"| node_audit

click node_study "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/study.py"
click node_controller "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/controller.py"
click node_ledger "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/core.py"
click node_selector "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/selectors.py"
click node_predictor "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/predictors.py"
click node_sandbox "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/sandbox.py"
click node_sec "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/secapp.py"
click node_sigma "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/sigmaapp.py"
click node_comp "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/compapp.py"
click node_guide "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/guideapp.py"
click node_rawlog "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/rawlog.py"
click node_llm "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/llm.py"
click node_planner "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/planner.py"
click node_web "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/webapp.py"
click node_upload "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/uploadapp.py"
click node_audit "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/audit.py"
click node_analysis "https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/analysis.py"
click node_tables "https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v10a_tables.py"
click node_mismatch "https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v10b_mismatch.py"
click node_v11 "https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v11_llmfree.py"
click node_v12 "https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v12_llmfree.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_controller,node_ledger,node_selector,node_predictor toneBlue
class node_sandbox,node_sec,node_sigma,node_comp,node_guide,node_web,node_upload toneAmber
class node_rawlog,node_llm,node_planner toneMint
class node_study,node_audit,node_analysis,node_tables,node_mismatch,node_v11,node_v12 toneRose
class node_analyst toneIndigo
```

## Components

### Triage workflow

- [Controller loop](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/controller.py): `hesp_research/hesp/controller.py`
- [Evidence ledger](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/core.py): `hesp_research/hesp/core.py`
- [Probe selector](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/selectors.py): `hesp_research/hesp/selectors.py`
- [Prediction tables](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/predictors.py): `hesp_research/hesp/predictors.py`

### Task environments

- [Probe sandbox](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/sandbox.py): `hesp_research/hesp/sandbox.py`
- [Security triage](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/secapp.py): `hesp_research/hesp/secapp.py`
- [Sigma triage](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/sigmaapp.py): `hesp_research/hesp/sigmaapp.py`
- [Comp triage](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/compapp.py): `hesp_research/hesp/compapp.py`
- [GUIDE triage](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/guideapp.py): `hesp_research/hesp/guideapp.py`
- [Web interface](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/webapp.py): `hesp_research/hesp/webapp.py`
- [Task upload](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/uploadapp.py): `hesp_research/hesp/uploadapp.py`

### Planning and reading

- [Raw-log reader](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/rawlog.py): `hesp_research/hesp/rawlog.py`
- [Local model client](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/llm.py): `hesp_research/hesp/llm.py`
- [Planner policies](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/planner.py): `hesp_research/hesp/planner.py`

### Studies and analysis

- [Study runner](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/study.py): `hesp_research/hesp/study.py`
- [Audit analysis](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/audit.py): `hesp_research/hesp/audit.py`
- [Study analysis](https://github.com/lzwhehe/hesp/blob/main/hesp_research/hesp/analysis.py): `hesp_research/hesp/analysis.py`
- [Table studies](https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v10a_tables.py): `hesp_research/scripts/v10a_tables.py`
- [Mismatch studies](https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v10b_mismatch.py): `hesp_research/scripts/v10b_mismatch.py`
- [v1.1 experiments](https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v11_llmfree.py): `hesp_research/scripts/v11_llmfree.py`
- [v1.2 experiments](https://github.com/lzwhehe/hesp/blob/main/hesp_research/scripts/v12_llmfree.py): `hesp_research/scripts/v12_llmfree.py`

### Other components

- **Analyst**

## Connections

- Analyst → Study runner: starts study
- Study runner → Controller loop: runs episodes
- Controller loop → Evidence ledger: updates beliefs (evidence: `hesp_research/hesp/controller.py`)
- Controller loop → Probe selector: chooses probes (evidence: `hesp_research/hesp/controller.py`)
- Controller loop → Prediction tables: gets likelihoods (evidence: `hesp_research/hesp/controller.py`)
- Controller loop → Probe sandbox: executes probes
- Controller loop → Planner policies: requests decision
- Controller loop → Raw-log reader: classifies logs
- Planner policies → Local model client: uses model
- Probe sandbox → Security triage: uses task behavior (evidence: `hesp_research/hesp/secapp.py`)
- Probe sandbox → Sigma triage: uses task behavior
- Probe sandbox → Comp triage: uses task behavior (evidence: `hesp_research/hesp/compapp.py`)
- Probe sandbox → GUIDE triage: uses task behavior
- Web interface → Probe sandbox: serves probes
- Task upload → Study runner: provides tasks
- Study runner → Table studies: supports evaluation (evidence: `hesp_research/scripts/v11_llmfree.py`)
- Study runner → Mismatch studies: supports evaluation (evidence: `hesp_research/scripts/v11_llmfree.py`)
- v1.1 experiments → Controller loop: runs comparisons (evidence: `hesp_research/scripts/v11_llmfree.py`)
- v1.2 experiments → Controller loop: runs comparisons (evidence: `hesp_research/scripts/v12_llmfree.py`)
- Study runner → Study analysis: summarizes results
- Study runner → Audit analysis: audits runs
