# sahil-ss9/hermaguard architecture

> Architecture diagram of the GitHub repository sahil-ss9/hermaguard, 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/sahil-ss9/hermaguard
- Repository: https://github.com/sahil-ss9/hermaguard

## Overview

HermaGuard is a read-only adversarial code-review system for AI-agent workflows. Its documented main path scans changed files deterministically, supplies context to three parallel reviewers, then consolidates and triages their findings into Markdown and JSON reports. The repository also provides accountability, verification, localization, rule, trajectory-audit, benchmark, and feedback tools. The README documents the review pipeline and several tool relationships; sampled source confirms pre-scan suppression and feedback-server behavior. The orchestrator itself is documented but is not present in the supplied file tree, so its node points to the README.

Main entry points: [`hermaguard_tools/_loader.py`](https://github.com/sahil-ss9/hermaguard/blob/main/hermaguard_tools/_loader.py) (Tool loader), [`README.md`](https://github.com/sahil-ss9/hermaguard/blob/main/README.md) (Markdown and JSON reports), [`tools/hermaguard-prescan/hermaguard-prescan.py`](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-prescan/hermaguard-prescan.py) (Deterministic pre-scan), [`mcp/hermaguard-feedback/server.py`](https://github.com/sahil-ss9/hermaguard/blob/main/mcp/hermaguard-feedback/server.py) (Feedback MCP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_review["Review workflow"]
  node_prescan["Deterministic pre-scan"]
  node_orchestrator["Review orchestrator<br/>[README.md]"]
  node_edge_hunter["Edge-case hunter<br/>[README.md]"]
  node_adversarial["Adversarial reviewer<br/>[README.md]"]
  node_blast_radius["Blast-radius reviewer<br/>[README.md]"]
  node_consolidator["Finding consolidator<br/>[README.md]"]
  node_reports["Markdown and JSON reports<br/>[README.md]"]
end

subgraph group_accountability["Finding accountability"]
  node_coverage["Coverage checklist"]
  node_verification["PoC verification"]
  node_harm_grader["Harm grader"]
end

subgraph group_analysis["Analysis tools"]
  node_locate["Fault localization"]
  node_role_patterns["Role-specific rules"]
  node_sanitize["Prompt sanitizer"]
  node_trajectory["Trajectory audit"]
  node_agents_linter["AGENTS.md linter<br/>[agentsmd-lint.py]"]
  node_loader["Tool loader<br/>[_loader.py]"]
end

subgraph group_feedback["Feedback and regression"]
  node_feedback_server["Feedback MCP server<br/>[server.py]"]
  node_feedback_db[("Feedback SQLite store<br/>[server.py]")]
  node_rule_compiler["Suppression rule compiler"]
  node_benchmark["Regression benchmark<br/>[app.py]"]
end

node_developer(("Developer"))

node_developer -->|"submits changed files"| node_prescan
node_prescan -->|"provides scan context"| node_orchestrator
node_orchestrator -->|"dispatches in parallel"| node_edge_hunter
node_orchestrator -->|"dispatches in parallel"| node_adversarial
node_orchestrator -->|"dispatches in parallel"| node_blast_radius
node_edge_hunter -->|"returns findings"| node_consolidator
node_adversarial -->|"returns findings"| node_consolidator
node_blast_radius -->|"returns findings"| node_consolidator
node_consolidator -->|"writes reports"| node_reports
node_coverage -.->|"validates coverage"| node_reports
node_verification -.->|"verifies findings"| node_reports
node_harm_grader -.->|"grades severity"| node_reports
node_feedback_server -->|"reads and writes"| node_feedback_db
node_reports -->|"records findings"| node_feedback_server
node_feedback_server -->|"compiles suppressions"| node_rule_compiler
node_rule_compiler -->|"supplies suppression rules"| node_prescan
node_benchmark -->|"scores JSON output"| node_reports
node_locate -.->|"supports localization"| node_orchestrator
node_role_patterns -.->|"provides SAST rules"| node_prescan
node_sanitize -.->|"supports prompt defense"| node_orchestrator
node_trajectory -.->|"emits audit findings"| node_reports
node_agents_linter -->|"scores instructions"| node_developer
node_loader -->|"loads tool script"| node_coverage
node_loader -->|"loads tool script"| node_locate
node_loader -->|"loads tool script"| node_role_patterns
node_loader -->|"loads tool script"| node_sanitize
node_loader -->|"loads tool script"| node_verification
node_loader -->|"loads tool script"| node_harm_grader
node_loader -->|"loads tool script"| node_prescan
node_loader -->|"loads tool script"| node_rule_compiler
node_loader -->|"loads tool script"| node_trajectory

click node_prescan "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-prescan/hermaguard-prescan.py"
click node_orchestrator "https://github.com/sahil-ss9/hermaguard/blob/main/README.md"
click node_edge_hunter "https://github.com/sahil-ss9/hermaguard/blob/main/README.md"
click node_adversarial "https://github.com/sahil-ss9/hermaguard/blob/main/README.md"
click node_blast_radius "https://github.com/sahil-ss9/hermaguard/blob/main/README.md"
click node_consolidator "https://github.com/sahil-ss9/hermaguard/blob/main/README.md"
click node_reports "https://github.com/sahil-ss9/hermaguard/blob/main/README.md"
click node_coverage "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-coverage/hermaguard-coverage.py"
click node_verification "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-verify/hermaguard-verify.py"
click node_harm_grader "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-grader/hermaguard_grader.py"
click node_locate "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-locate/hermaguard-locate.py"
click node_role_patterns "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-role-patterns/hermaguard-role-patterns.py"
click node_sanitize "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-sanitize/hermaguard-sanitize.py"
click node_trajectory "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-trajectory/hermaguard-trajectory.py"
click node_feedback_server "https://github.com/sahil-ss9/hermaguard/blob/main/mcp/hermaguard-feedback/server.py"
click node_feedback_db "https://github.com/sahil-ss9/hermaguard/blob/main/mcp/hermaguard-feedback/server.py"
click node_rule_compiler "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-compile-rules/hermaguard-compile-rules.py"
click node_benchmark "https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-benchmark/bugs/011-race-balance/code/app.py"
click node_agents_linter "https://github.com/sahil-ss9/hermaguard/blob/main/tools/agentsmd-linter/agentsmd-lint.py"
click node_loader "https://github.com/sahil-ss9/hermaguard/blob/main/hermaguard_tools/_loader.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_prescan,node_orchestrator,node_edge_hunter,node_adversarial,node_blast_radius,node_consolidator,node_reports toneBlue
class node_coverage,node_verification,node_harm_grader toneAmber
class node_locate,node_role_patterns,node_sanitize,node_trajectory,node_agents_linter,node_loader toneMint
class node_feedback_server,node_feedback_db,node_rule_compiler,node_benchmark toneRose
class node_developer toneIndigo
```

## Components

### Review workflow

- [Deterministic pre-scan](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-prescan/hermaguard-prescan.py): `tools/hermaguard-prescan/hermaguard-prescan.py`
- [Review orchestrator](https://github.com/sahil-ss9/hermaguard/blob/main/README.md): `README.md`
- [Edge-case hunter](https://github.com/sahil-ss9/hermaguard/blob/main/README.md): `README.md`
- [Adversarial reviewer](https://github.com/sahil-ss9/hermaguard/blob/main/README.md): `README.md`
- [Blast-radius reviewer](https://github.com/sahil-ss9/hermaguard/blob/main/README.md): `README.md`
- [Finding consolidator](https://github.com/sahil-ss9/hermaguard/blob/main/README.md): `README.md`
- [Markdown and JSON reports](https://github.com/sahil-ss9/hermaguard/blob/main/README.md): `README.md`

### Finding accountability

- [Coverage checklist](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-coverage/hermaguard-coverage.py): `tools/hermaguard-coverage/hermaguard-coverage.py`
- [PoC verification](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-verify/hermaguard-verify.py): `tools/hermaguard-verify/hermaguard-verify.py`
- [Harm grader](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-grader/hermaguard_grader.py): `tools/hermaguard-grader/hermaguard_grader.py`

### Analysis tools

- [Fault localization](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-locate/hermaguard-locate.py): `tools/hermaguard-locate/hermaguard-locate.py`
- [Role-specific rules](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-role-patterns/hermaguard-role-patterns.py): `tools/hermaguard-role-patterns/hermaguard-role-patterns.py`
- [Prompt sanitizer](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-sanitize/hermaguard-sanitize.py): `tools/hermaguard-sanitize/hermaguard-sanitize.py`
- [Trajectory audit](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-trajectory/hermaguard-trajectory.py): `tools/hermaguard-trajectory/hermaguard-trajectory.py`
- [AGENTS.md linter](https://github.com/sahil-ss9/hermaguard/blob/main/tools/agentsmd-linter/agentsmd-lint.py): `tools/agentsmd-linter/agentsmd-lint.py`
- [Tool loader](https://github.com/sahil-ss9/hermaguard/blob/main/hermaguard_tools/_loader.py): `hermaguard_tools/_loader.py`

### Feedback and regression

- [Feedback MCP server](https://github.com/sahil-ss9/hermaguard/blob/main/mcp/hermaguard-feedback/server.py): `mcp/hermaguard-feedback/server.py`
- [Feedback SQLite store](https://github.com/sahil-ss9/hermaguard/blob/main/mcp/hermaguard-feedback/server.py): `mcp/hermaguard-feedback/server.py`
- [Suppression rule compiler](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-compile-rules/hermaguard-compile-rules.py): `tools/hermaguard-compile-rules/hermaguard-compile-rules.py`
- [Regression benchmark](https://github.com/sahil-ss9/hermaguard/blob/main/tools/hermaguard-benchmark/bugs/011-race-balance/code/app.py): `tools/hermaguard-benchmark/bugs/011-race-balance/code/app.py`

### Other components

- **Developer**

## Connections

- Developer → Deterministic pre-scan: submits changed files (evidence: `README.md`)
- Deterministic pre-scan → Review orchestrator: provides scan context (evidence: `README.md`)
- Review orchestrator → Edge-case hunter: dispatches in parallel (evidence: `README.md`)
- Review orchestrator → Adversarial reviewer: dispatches in parallel (evidence: `README.md`)
- Review orchestrator → Blast-radius reviewer: dispatches in parallel (evidence: `README.md`)
- Edge-case hunter → Finding consolidator: returns findings (evidence: `README.md`)
- Adversarial reviewer → Finding consolidator: returns findings (evidence: `README.md`)
- Blast-radius reviewer → Finding consolidator: returns findings (evidence: `README.md`)
- Finding consolidator → Markdown and JSON reports: writes reports (evidence: `README.md`)
- Coverage checklist → Markdown and JSON reports: validates coverage
- PoC verification → Markdown and JSON reports: verifies findings
- Harm grader → Markdown and JSON reports: grades severity
- Feedback MCP server → Feedback SQLite store: reads and writes (evidence: `mcp/hermaguard-feedback/server.py`)
- Markdown and JSON reports → Feedback MCP server: records findings (evidence: `README.md`)
- Feedback MCP server → Suppression rule compiler: compiles suppressions (evidence: `README.md`)
- Suppression rule compiler → Deterministic pre-scan: supplies suppression rules (evidence: `README.md`)
- Regression benchmark → Markdown and JSON reports: scores JSON output (evidence: `README.md`)
- Fault localization → Review orchestrator: supports localization
- Role-specific rules → Deterministic pre-scan: provides SAST rules
- Prompt sanitizer → Review orchestrator: supports prompt defense
- Trajectory audit → Markdown and JSON reports: emits audit findings
- AGENTS.md linter → Developer: scores instructions (evidence: `README.md`)
- Tool loader → Coverage checklist: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → Fault localization: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → Role-specific rules: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → Prompt sanitizer: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → PoC verification: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → Harm grader: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → Deterministic pre-scan: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → Suppression rule compiler: loads tool script (evidence: `hermaguard_tools/_loader.py`)
- Tool loader → Trajectory audit: loads tool script (evidence: `hermaguard_tools/_loader.py`)
