# charan-suresh/interlock architecture

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

- Interactive diagram: https://gitdiagram.com/charan-suresh/interlock
- Repository: https://github.com/charan-suresh/interlock

## Overview

INTERLOCK is a deterministic security gateway and defensive benchmark for LLM-agent tool execution. A request enters through the API, selects a defense mode, and in the INTERLOCK mode is planned before untrusted inputs are processed; execution then passes through gateway checks before tools run. Value labels, provenance, quarantine, and corroboration support those checks. The API also exposes benchmark runs and replay, while the web app presents comparison and execution visualizations. Some UI wiring and runtime details are unsampled, so those links are omitted.

Main entry points: [`interlock/core/executor.py`](https://github.com/charan-suresh/interlock/blob/main/interlock/core/executor.py) (Plan execution), [`interlock/core/gateway.py`](https://github.com/charan-suresh/interlock/blob/main/interlock/core/gateway.py) (Policy gateway), [`web/components/CompareView.tsx`](https://github.com/charan-suresh/interlock/blob/main/web/components/CompareView.tsx) (Run comparison), [`interlock/core/handles.py`](https://github.com/charan-suresh/interlock/blob/main/interlock/core/handles.py) (Value vault)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and UI"]
  node_api["HTTP API<br/>[api.py]"]
  node_webpage["Demo app<br/>[page.tsx]"]
end

subgraph group_security["Security runtime"]
  node_defense["Defense modes"]
  node_interlock["INTERLOCK mode<br/>[interlock.py]"]
  node_planner["Plan generation<br/>[planner.py]"]
  node_plan["Plan contract<br/>[plan.py]"]
  node_executor["Plan execution<br/>[executor.py]"]
  node_gateway["Policy gateway<br/>[gateway.py]"]
  node_quarantine["Quarantine extraction<br/>[quarantine.py]"]
  node_vault[("Value vault<br/>[handles.py]")]
  node_labels["Flow labels<br/>[labels.py]"]
  node_corroboration["Corroboration<br/>[corroborate.py]"]
  node_policy["Policy contract<br/>[policy.py]"]
  node_events["Execution events<br/>[events.py]"]
  node_llm["LLM client<br/>[llm.py]"]
end

subgraph group_tools["Tools and evidence"]
  node_registry["Tool schemas<br/>[registry.py]"]
  node_mocks["Mock tools<br/>[mocks.py]"]
  node_collector[("Exfiltration collector<br/>[collector.py]")]
end

subgraph group_benchmark["Benchmark arena"]
  node_arena["Benchmark runner<br/>[runner.py]"]
  node_metrics["Arena metrics<br/>[metrics.py]"]
end

subgraph group_views["Web views"]
  node_compare["Run comparison<br/>[CompareView.tsx]"]
  node_flowchart["Plan flowchart"]
  node_timeline["Execution timeline"]
  node_verdict["Verdict panel<br/>[VerdictPanel.tsx]"]
  node_media["Media inspector<br/>[MediaInspector.tsx]"]
  node_collectorview["Collector terminal"]
  node_scoreboard["Benchmark scoreboard<br/>[Scoreboard.tsx]"]
  node_labelsview["Label chip<br/>[LabelChip.tsx]"]
end

node_user(("Requestor"))

node_user -->|"submits task"| node_api
node_api -->|"selects mode"| node_defense
node_api -->|"runs benchmarks"| node_arena
node_interlock -->|"generates plan"| node_planner
node_planner -->|"requests completion"| node_llm
node_planner -->|"builds plan"| node_plan
node_planner -->|"loads tool schemas"| node_registry
node_interlock -->|"executes plan"| node_executor
node_executor -->|"checks tool call"| node_gateway
node_executor -->|"uses handles"| node_vault
node_executor -->|"extracts untrusted data"| node_quarantine
node_executor -->|"verifies claims"| node_corroboration
node_executor -->|"dispatches tools"| node_mocks
node_executor -->|"publishes events"| node_events
node_quarantine -->|"stores extracted values"| node_vault
node_quarantine -->|"extracts structured data"| node_llm
node_corroboration -->|"checks ancestry"| node_vault
node_vault -->|"attaches labels"| node_labels
node_gateway -->|"resolves handles"| node_vault
node_gateway -->|"enforces flow labels"| node_labels
node_gateway -->|"checks contract"| node_plan
node_gateway -->|"evaluates policy"| node_policy
node_gateway -->|"looks up sink"| node_registry
node_gateway -->|"publishes replans"| node_events
node_mocks -->|"logs exfiltration"| node_collector
node_mocks -->|"uses schemas"| node_registry
node_api -->|"replays events"| node_events
node_arena -->|"computes metrics"| node_metrics
node_arena -->|"runs model"| node_llm
node_arena -->|"runs defense modes"| node_defense
node_compare -->|"renders"| node_flowchart
node_compare -->|"renders"| node_timeline
node_compare -->|"renders"| node_verdict
node_compare -->|"renders"| node_media
node_compare -->|"renders"| node_collectorview
node_flowchart -->|"renders"| node_labelsview
node_timeline -->|"renders"| node_labelsview
node_verdict -->|"renders"| node_labelsview
node_media -->|"renders"| node_labelsview

click node_api "https://github.com/charan-suresh/interlock/blob/main/interlock/api.py"
click node_webpage "https://github.com/charan-suresh/interlock/blob/main/web/app/page.tsx"
click node_compare "https://github.com/charan-suresh/interlock/blob/main/web/components/CompareView.tsx"
click node_flowchart "https://github.com/charan-suresh/interlock/blob/main/web/components/AnimatedFlowchart.tsx"
click node_timeline "https://github.com/charan-suresh/interlock/blob/main/web/components/ExecutionTimeline.tsx"
click node_verdict "https://github.com/charan-suresh/interlock/blob/main/web/components/VerdictPanel.tsx"
click node_media "https://github.com/charan-suresh/interlock/blob/main/web/components/MediaInspector.tsx"
click node_collectorview "https://github.com/charan-suresh/interlock/blob/main/web/components/CollectorTerminal.tsx"
click node_scoreboard "https://github.com/charan-suresh/interlock/blob/main/web/components/Scoreboard.tsx"
click node_labelsview "https://github.com/charan-suresh/interlock/blob/main/web/components/LabelChip.tsx"
click node_defense "https://github.com/charan-suresh/interlock/tree/main/interlock/defenses"
click node_interlock "https://github.com/charan-suresh/interlock/blob/main/interlock/defenses/interlock.py"
click node_planner "https://github.com/charan-suresh/interlock/blob/main/interlock/core/planner.py"
click node_plan "https://github.com/charan-suresh/interlock/blob/main/interlock/core/plan.py"
click node_executor "https://github.com/charan-suresh/interlock/blob/main/interlock/core/executor.py"
click node_gateway "https://github.com/charan-suresh/interlock/blob/main/interlock/core/gateway.py"
click node_quarantine "https://github.com/charan-suresh/interlock/blob/main/interlock/core/quarantine.py"
click node_vault "https://github.com/charan-suresh/interlock/blob/main/interlock/core/handles.py"
click node_labels "https://github.com/charan-suresh/interlock/blob/main/interlock/core/labels.py"
click node_corroboration "https://github.com/charan-suresh/interlock/blob/main/interlock/core/corroborate.py"
click node_policy "https://github.com/charan-suresh/interlock/blob/main/interlock/core/policy.py"
click node_registry "https://github.com/charan-suresh/interlock/blob/main/interlock/tools/registry.py"
click node_mocks "https://github.com/charan-suresh/interlock/blob/main/interlock/tools/mocks.py"
click node_collector "https://github.com/charan-suresh/interlock/blob/main/interlock/tools/collector.py"
click node_events "https://github.com/charan-suresh/interlock/blob/main/interlock/core/events.py"
click node_llm "https://github.com/charan-suresh/interlock/blob/main/interlock/core/llm.py"
click node_arena "https://github.com/charan-suresh/interlock/blob/main/interlock/arena/runner.py"
click node_metrics "https://github.com/charan-suresh/interlock/blob/main/interlock/arena/metrics.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_api,node_webpage toneBlue
class node_defense,node_interlock,node_planner,node_plan,node_executor,node_gateway,node_quarantine,node_vault,node_labels,node_corroboration,node_policy,node_events,node_llm toneAmber
class node_registry,node_mocks,node_collector,node_user toneMint
class node_arena,node_metrics toneRose
class node_compare,node_flowchart,node_timeline,node_verdict,node_media,node_collectorview,node_scoreboard,node_labelsview toneIndigo
```

## Components

### API and UI

- [HTTP API](https://github.com/charan-suresh/interlock/blob/main/interlock/api.py): `interlock/api.py`
- [Demo app](https://github.com/charan-suresh/interlock/blob/main/web/app/page.tsx): `web/app/page.tsx`

### Security runtime

- [Defense modes](https://github.com/charan-suresh/interlock/tree/main/interlock/defenses): `interlock/defenses`
- [INTERLOCK mode](https://github.com/charan-suresh/interlock/blob/main/interlock/defenses/interlock.py): `interlock/defenses/interlock.py`
- [Plan generation](https://github.com/charan-suresh/interlock/blob/main/interlock/core/planner.py): `interlock/core/planner.py`
- [Plan contract](https://github.com/charan-suresh/interlock/blob/main/interlock/core/plan.py): `interlock/core/plan.py`
- [Plan execution](https://github.com/charan-suresh/interlock/blob/main/interlock/core/executor.py): `interlock/core/executor.py`
- [Policy gateway](https://github.com/charan-suresh/interlock/blob/main/interlock/core/gateway.py): `interlock/core/gateway.py`
- [Quarantine extraction](https://github.com/charan-suresh/interlock/blob/main/interlock/core/quarantine.py): `interlock/core/quarantine.py`
- [Value vault](https://github.com/charan-suresh/interlock/blob/main/interlock/core/handles.py): `interlock/core/handles.py`
- [Flow labels](https://github.com/charan-suresh/interlock/blob/main/interlock/core/labels.py): `interlock/core/labels.py`
- [Corroboration](https://github.com/charan-suresh/interlock/blob/main/interlock/core/corroborate.py): `interlock/core/corroborate.py`
- [Policy contract](https://github.com/charan-suresh/interlock/blob/main/interlock/core/policy.py): `interlock/core/policy.py`
- [Execution events](https://github.com/charan-suresh/interlock/blob/main/interlock/core/events.py): `interlock/core/events.py`
- [LLM client](https://github.com/charan-suresh/interlock/blob/main/interlock/core/llm.py): `interlock/core/llm.py`

### Tools and evidence

- [Tool schemas](https://github.com/charan-suresh/interlock/blob/main/interlock/tools/registry.py): `interlock/tools/registry.py`
- [Mock tools](https://github.com/charan-suresh/interlock/blob/main/interlock/tools/mocks.py): `interlock/tools/mocks.py`
- [Exfiltration collector](https://github.com/charan-suresh/interlock/blob/main/interlock/tools/collector.py): `interlock/tools/collector.py`

### Benchmark arena

- [Benchmark runner](https://github.com/charan-suresh/interlock/blob/main/interlock/arena/runner.py): `interlock/arena/runner.py`
- [Arena metrics](https://github.com/charan-suresh/interlock/blob/main/interlock/arena/metrics.py): `interlock/arena/metrics.py`

### Web views

- [Run comparison](https://github.com/charan-suresh/interlock/blob/main/web/components/CompareView.tsx): `web/components/CompareView.tsx`
- [Plan flowchart](https://github.com/charan-suresh/interlock/blob/main/web/components/AnimatedFlowchart.tsx): `web/components/AnimatedFlowchart.tsx`
- [Execution timeline](https://github.com/charan-suresh/interlock/blob/main/web/components/ExecutionTimeline.tsx): `web/components/ExecutionTimeline.tsx`
- [Verdict panel](https://github.com/charan-suresh/interlock/blob/main/web/components/VerdictPanel.tsx): `web/components/VerdictPanel.tsx`
- [Media inspector](https://github.com/charan-suresh/interlock/blob/main/web/components/MediaInspector.tsx): `web/components/MediaInspector.tsx`
- [Collector terminal](https://github.com/charan-suresh/interlock/blob/main/web/components/CollectorTerminal.tsx): `web/components/CollectorTerminal.tsx`
- [Benchmark scoreboard](https://github.com/charan-suresh/interlock/blob/main/web/components/Scoreboard.tsx): `web/components/Scoreboard.tsx`
- [Label chip](https://github.com/charan-suresh/interlock/blob/main/web/components/LabelChip.tsx): `web/components/LabelChip.tsx`

### Other components

- **Requestor**

## Connections

- Requestor → HTTP API: submits task (evidence: `interlock/api.py`)
- HTTP API → Defense modes: selects mode (evidence: `interlock/api.py`)
- HTTP API → Benchmark runner: runs benchmarks (evidence: `interlock/api.py`)
- INTERLOCK mode → Plan generation: generates plan (evidence: `interlock/defenses/interlock.py`)
- Plan generation → LLM client: requests completion (evidence: `interlock/core/planner.py`)
- Plan generation → Plan contract: builds plan (evidence: `interlock/core/planner.py`)
- Plan generation → Tool schemas: loads tool schemas (evidence: `interlock/core/planner.py`)
- INTERLOCK mode → Plan execution: executes plan (evidence: `interlock/defenses/interlock.py`)
- Plan execution → Policy gateway: checks tool call (evidence: `interlock/core/executor.py`)
- Plan execution → Value vault: uses handles (evidence: `interlock/core/executor.py`)
- Plan execution → Quarantine extraction: extracts untrusted data (evidence: `interlock/core/executor.py`)
- Plan execution → Corroboration: verifies claims (evidence: `interlock/core/executor.py`)
- Plan execution → Mock tools: dispatches tools (evidence: `interlock/core/executor.py`)
- Plan execution → Execution events: publishes events (evidence: `interlock/core/executor.py`)
- Quarantine extraction → Value vault: stores extracted values (evidence: `interlock/core/quarantine.py`)
- Quarantine extraction → LLM client: extracts structured data (evidence: `interlock/core/quarantine.py`)
- Corroboration → Value vault: checks ancestry (evidence: `interlock/core/corroborate.py`)
- Value vault → Flow labels: attaches labels (evidence: `interlock/core/handles.py`)
- Policy gateway → Value vault: resolves handles (evidence: `interlock/core/gateway.py`)
- Policy gateway → Flow labels: enforces flow labels (evidence: `interlock/core/gateway.py`)
- Policy gateway → Plan contract: checks contract (evidence: `interlock/core/gateway.py`)
- Policy gateway → Policy contract: evaluates policy (evidence: `interlock/core/gateway.py`)
- Policy gateway → Tool schemas: looks up sink (evidence: `interlock/core/gateway.py`)
- Policy gateway → Execution events: publishes replans (evidence: `interlock/core/gateway.py`)
- Mock tools → Exfiltration collector: logs exfiltration (evidence: `interlock/tools/mocks.py`)
- Mock tools → Tool schemas: uses schemas (evidence: `interlock/tools/mocks.py`)
- HTTP API → Execution events: replays events (evidence: `interlock/api.py`)
- Benchmark runner → Arena metrics: computes metrics (evidence: `interlock/arena/runner.py`)
- Benchmark runner → LLM client: runs model (evidence: `interlock/arena/runner.py`)
- Benchmark runner → Defense modes: runs defense modes (evidence: `interlock/arena/runner.py`)
- Run comparison → Plan flowchart: renders (evidence: `web/components/CompareView.tsx`)
- Run comparison → Execution timeline: renders (evidence: `web/components/CompareView.tsx`)
- Run comparison → Verdict panel: renders (evidence: `web/components/CompareView.tsx`)
- Run comparison → Media inspector: renders (evidence: `web/components/CompareView.tsx`)
- Run comparison → Collector terminal: renders (evidence: `web/components/CompareView.tsx`)
- Plan flowchart → Label chip: renders (evidence: `web/components/AnimatedFlowchart.tsx`)
- Execution timeline → Label chip: renders (evidence: `web/components/ExecutionTimeline.tsx`)
- Verdict panel → Label chip: renders (evidence: `web/components/VerdictPanel.tsx`)
- Media inspector → Label chip: renders (evidence: `web/components/MediaInspector.tsx`)
