# sanjayimmanuel24/graphgate architecture

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

- Interactive diagram: https://gitdiagram.com/sanjayimmanuel24/graphgate
- Repository: https://github.com/sanjayimmanuel24/graphgate

## Overview

GraphGate is a research prototype for a security gate in iterative LLM code refinement. In the sampled runtime, a user configures and runs a refinement harness: the driver sends prompts to a code-generation client, updates repository snapshots, and records traces; traces can then be replayed deterministically. Dataset modules prepare and slice vulnerability scenarios, and injection supports placing a regression into a run. The README describes the intended temporal code-graph security gate, but the project status is M1.1 and no gate-analysis implementation is established by the supplied evidence. Relationships below follow excerpts and SOURCE INDEX references; unsampled modules are represented only where their paths are listed.

Main entry points: [`src/graphgate/harness/driver.py`](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/driver.py) (Loop driver), [`src/graphgate/cli.py`](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/cli.py) (CLI), [`src/graphgate/harness/replay.py`](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/replay.py) (Trace replay), [`src/graphgate/llm/anthropic_client.py`](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/llm/anthropic_client.py) (Anthropic client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Run entry"]
  node_cli["CLI<br/>[cli.py]"]
  node_config["Run config<br/>[config.py]"]
end

subgraph group_loop["Refinement harness"]
  node_driver["Loop driver<br/>[driver.py]"]
  node_snapshot["Repo snapshot<br/>[snapshot.py]"]
  node_diff["Change diff<br/>[diff.py]"]
  node_trace["Trace records<br/>[trace.py]"]
  node_replay["Trace replay<br/>[replay.py]"]
end

subgraph group_data["Scenario data"]
  node_events["Event loader<br/>[events.py]"]
  node_scrub["Source scrubber<br/>[scrub.py]"]
  node_slicing["Scenario slicer<br/>[slicing.py]"]
  node_advisories["Advisories<br/>[advisories.py]"]
  node_fixpairs["Fix pairs<br/>[fix_pairs.py]"]
  node_labels["Scenario labels<br/>[labels.py]"]
  node_seeds["Seed repositories<br/>[seed_repos.py]"]
  node_traceplan["Trace planning<br/>[traceplan.py]"]
end

subgraph group_llm["Model clients"]
  node_protocol["Client protocol<br/>[base.py]"]
  node_anthropic["Anthropic client"]
  node_cache[("Response cache<br/>[cache.py]")]
end

node_user(("Researcher"))
node_modelservice(("Anthropic API"))

node_user -->|"runs"| node_cli
node_cli -->|"configures"| node_config
node_cli -->|"starts"| node_driver
node_cli -->|"replays"| node_replay
node_cli -->|"creates"| node_anthropic
node_cli -->|"wraps with"| node_cache
node_driver -->|"reads"| node_config
node_driver -->|"uses"| node_snapshot
node_driver -->|"uses"| node_diff
node_driver -->|"writes"| node_trace
node_driver -->|"requests via"| node_protocol
node_driver -->|"injects using"| node_slicing
node_replay -->|"reconstructs"| node_snapshot
node_replay -->|"reads"| node_trace
node_replay -->|"implements"| node_protocol
node_replay -->|"uses injection"| node_slicing
node_anthropic -->|"implements"| node_protocol
node_anthropic -->|"reads"| node_config
node_anthropic -->|"sends requests"| node_modelservice
node_cache -->|"wraps"| node_protocol
node_events -->|"scrubs with"| node_scrub
node_events -->|"slices with"| node_slicing
node_scrub -->|"uses"| node_slicing

click node_cli "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/cli.py"
click node_config "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/config.py"
click node_driver "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/driver.py"
click node_snapshot "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/snapshot.py"
click node_diff "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/diff.py"
click node_trace "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/trace.py"
click node_replay "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/replay.py"
click node_protocol "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/llm/base.py"
click node_anthropic "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/llm/anthropic_client.py"
click node_cache "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/llm/cache.py"
click node_events "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/events.py"
click node_scrub "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/scrub.py"
click node_slicing "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/slicing.py"
click node_advisories "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/advisories.py"
click node_fixpairs "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/fix_pairs.py"
click node_labels "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/labels.py"
click node_seeds "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/seed_repos.py"
click node_traceplan "https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/traceplan.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_cli,node_config toneBlue
class node_driver,node_snapshot,node_diff,node_trace,node_replay toneAmber
class node_events,node_scrub,node_slicing,node_advisories,node_fixpairs,node_labels,node_seeds,node_traceplan,node_modelservice toneMint
class node_protocol,node_anthropic,node_cache toneRose
class node_user toneIndigo
```

## Components

### Run entry

- [CLI](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/cli.py): `src/graphgate/cli.py`
- [Run config](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/config.py): `src/graphgate/config.py`

### Refinement harness

- [Loop driver](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/driver.py): `src/graphgate/harness/driver.py`
- [Repo snapshot](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/snapshot.py): `src/graphgate/harness/snapshot.py`
- [Change diff](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/diff.py): `src/graphgate/harness/diff.py`
- [Trace records](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/trace.py): `src/graphgate/harness/trace.py`
- [Trace replay](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/harness/replay.py): `src/graphgate/harness/replay.py`

### Scenario data

- [Event loader](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/events.py): `src/graphgate/dataset/events.py`
- [Source scrubber](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/scrub.py): `src/graphgate/dataset/scrub.py`
- [Scenario slicer](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/slicing.py): `src/graphgate/dataset/slicing.py`
- [Advisories](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/advisories.py): `src/graphgate/dataset/advisories.py`
- [Fix pairs](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/fix_pairs.py): `src/graphgate/dataset/fix_pairs.py`
- [Scenario labels](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/labels.py): `src/graphgate/dataset/labels.py`
- [Seed repositories](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/seed_repos.py): `src/graphgate/dataset/seed_repos.py`
- [Trace planning](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/dataset/traceplan.py): `src/graphgate/dataset/traceplan.py`

### Model clients

- [Client protocol](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/llm/base.py): `src/graphgate/llm/base.py`
- [Anthropic client](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/llm/anthropic_client.py): `src/graphgate/llm/anthropic_client.py`
- [Response cache](https://github.com/sanjayimmanuel24/graphgate/blob/master/src/graphgate/llm/cache.py): `src/graphgate/llm/cache.py`

### Other components

- **Researcher**
- **Anthropic API**

## Connections

- Researcher → CLI: runs (evidence: `README.md`)
- CLI → Run config: configures (evidence: `src/graphgate/cli.py`)
- CLI → Loop driver: starts (evidence: `src/graphgate/cli.py`)
- CLI → Trace replay: replays (evidence: `src/graphgate/cli.py`)
- CLI → Anthropic client: creates (evidence: `src/graphgate/cli.py`)
- CLI → Response cache: wraps with (evidence: `src/graphgate/cli.py`)
- Loop driver → Run config: reads (evidence: `src/graphgate/harness/driver.py`)
- Loop driver → Repo snapshot: uses (evidence: `src/graphgate/harness/driver.py`)
- Loop driver → Change diff: uses (evidence: `src/graphgate/harness/driver.py`)
- Loop driver → Trace records: writes (evidence: `src/graphgate/harness/driver.py`)
- Loop driver → Client protocol: requests via (evidence: `src/graphgate/harness/driver.py`)
- Loop driver → Scenario slicer: injects using (evidence: `src/graphgate/harness/driver.py`)
- Trace replay → Repo snapshot: reconstructs (evidence: `src/graphgate/harness/replay.py`)
- Trace replay → Trace records: reads (evidence: `src/graphgate/harness/replay.py`)
- Trace replay → Client protocol: implements (evidence: `src/graphgate/harness/replay.py`)
- Trace replay → Scenario slicer: uses injection (evidence: `src/graphgate/harness/replay.py`)
- Anthropic client → Client protocol: implements (evidence: `src/graphgate/llm/anthropic_client.py`)
- Anthropic client → Run config: reads (evidence: `src/graphgate/llm/anthropic_client.py`)
- Anthropic client → Anthropic API: sends requests (evidence: `src/graphgate/llm/anthropic_client.py`)
- Response cache → Client protocol: wraps (evidence: `src/graphgate/llm/cache.py`)
- Event loader → Source scrubber: scrubs with (evidence: `src/graphgate/dataset/events.py`)
- Event loader → Scenario slicer: slices with (evidence: `src/graphgate/dataset/events.py`)
- Source scrubber → Scenario slicer: uses (evidence: `src/graphgate/dataset/scrub.py`)
