# vinith2431/null_bytes_track-2 architecture

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

- Interactive diagram: https://gitdiagram.com/vinith2431/null_bytes_track-2
- Repository: https://github.com/vinith2431/null_bytes_track-2

## Overview

Aegis is a defense-in-depth security system for tool-using LLM agents. Its main workflow takes a user message through input guards and model reasoning, gates proposed tool actions, scans retrieved content, then verifies a grounded answer before returning it and recording security events. The graph preserves documented Q-Gate, classical detection, taint/action authorization, and output-verification branches. Some subsystem links rely on README-level workflow descriptions; unsampled implementation details are not inferred beyond those documented relationships.

Main entry points: [`aegis/pipeline.py`](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/pipeline.py) (Agent pipeline), [`aegis/llm.py`](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/llm.py) (LLM interface), [`aegis/line1/action_token.py`](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/line1/action_token.py) (Action tokens), [`web/server.py`](https://github.com/vinith2431/null_bytes_track-2/blob/main/web/server.py) (Web chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Entry"]
  node_web["Web chat<br/>[server.py]"]
end

subgraph group_control["Agent Control"]
  node_pipeline["Agent pipeline<br/>[pipeline.py]"]
  node_contracts["Session contracts<br/>[contracts.py]"]
  node_config["Layer config<br/>[config.py]"]
end

subgraph group_protection["Security Layers"]
  node_input["Input guards<br/>[classify.py]"]
  node_normalize["Input normalization<br/>[normalize.py]"]
  node_risk["Turn risk<br/>[risk.py]"]
  node_toolgate["Tool safety gate<br/>[gate.py]"]
  node_actiontoken["Action tokens<br/>[action_token.py]"]
  node_taint["Taint tracking<br/>[taint.py]"]
  node_ingress["Retrieved-content checks<br/>[process.py]"]
  node_scan["Sensitive-data scan<br/>[scan.py]"]
  node_qgate["Q-Gate detector<br/>[detector.py]"]
  node_kernel["Quantum kernel<br/>[kernel.py]"]
  node_rbf["Classical RBF<br/>[baseline_rbf.py]"]
end

subgraph group_evidence["Tools and Answers"]
  node_tools["Simulated tools<br/>[sim.py]"]
  node_grounding["Grounded prompting<br/>[prompt.py]"]
  node_citation["Citation checks<br/>[citation_check.py]"]
  node_nli["Claim entailment<br/>[nli.py]"]
  node_output["Output decisions<br/>[decide.py]"]
  node_refusal["Output refusal<br/>[refusal.py]"]
end

subgraph group_ops["Model and Audit"]
  node_llm["LLM interface<br/>[llm.py]"]
  node_provider["LLM provider"]
  node_audit[("Hash-chain audit<br/>[chain.py]")]
end

node_user(("User"))

node_user -->|"sends message"| node_web
node_web -->|"runs turn"| node_pipeline
node_pipeline -->|"normalizes input"| node_normalize
node_pipeline -->|"classifies input"| node_input
node_pipeline -->|"tracks risk"| node_risk
node_pipeline -->|"requests reasoning"| node_llm
node_llm -->|"calls model"| node_provider
node_pipeline -->|"checks tool call"| node_toolgate
node_toolgate -->|"mints token"| node_actiontoken
node_pipeline -->|"authorizes action"| node_actiontoken
node_pipeline -->|"marks arguments"| node_taint
node_pipeline -->|"executes permitted call"| node_tools
node_tools -->|"consumes token"| node_actiontoken
node_pipeline -->|"processes retrieved content"| node_ingress
node_ingress -->|"scans content"| node_scan
node_pipeline -->|"checks untrusted text"| node_qgate
node_qgate -->|"scores kernel"| node_kernel
node_pipeline -.->|"checks classical baseline"| node_rbf
node_pipeline -->|"builds grounded prompt"| node_grounding
node_grounding -->|"generates answer"| node_llm
node_pipeline -->|"validates citations"| node_citation
node_pipeline -->|"checks entailment"| node_nli
node_pipeline -->|"decides answer"| node_output
node_output -->|"returns refusal"| node_refusal
node_pipeline -->|"records events"| node_audit
node_pipeline -->|"reads layer flags"| node_config

click node_web "https://github.com/vinith2431/null_bytes_track-2/blob/main/web/server.py"
click node_pipeline "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/pipeline.py"
click node_contracts "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/contracts.py"
click node_config "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/config.py"
click node_input "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/inputguard/classify.py"
click node_normalize "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/inputguard/normalize.py"
click node_risk "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/inputguard/risk.py"
click node_toolgate "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/toolsafety/gate.py"
click node_actiontoken "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/line1/action_token.py"
click node_taint "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/line1/taint.py"
click node_ingress "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/ingress/process.py"
click node_scan "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/ingress/scan.py"
click node_qgate "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/qgate/detector.py"
click node_kernel "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/qgate/kernel.py"
click node_rbf "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/qgate/baseline_rbf.py"
click node_tools "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/tools/sim.py"
click node_grounding "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/grounding/prompt.py"
click node_citation "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/citation_check.py"
click node_nli "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/nli.py"
click node_output "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/decide.py"
click node_refusal "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/refusal.py"
click node_llm "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/llm.py"
click node_audit "https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/audit/chain.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_web,node_user toneBlue
class node_pipeline,node_contracts,node_config toneAmber
class node_input,node_normalize,node_risk,node_toolgate,node_actiontoken,node_taint,node_ingress,node_scan,node_qgate,node_kernel,node_rbf toneMint
class node_tools,node_grounding,node_citation,node_nli,node_output,node_refusal toneRose
class node_llm,node_provider,node_audit toneIndigo
```

## Components

### User Entry

- [Web chat](https://github.com/vinith2431/null_bytes_track-2/blob/main/web/server.py): `web/server.py`

### Agent Control

- [Agent pipeline](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/pipeline.py): `aegis/pipeline.py`
- [Session contracts](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/contracts.py): `aegis/contracts.py`
- [Layer config](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/config.py): `aegis/config.py`

### Security Layers

- [Input guards](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/inputguard/classify.py): `aegis/inputguard/classify.py`
- [Input normalization](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/inputguard/normalize.py): `aegis/inputguard/normalize.py`
- [Turn risk](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/inputguard/risk.py): `aegis/inputguard/risk.py`
- [Tool safety gate](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/toolsafety/gate.py): `aegis/toolsafety/gate.py`
- [Action tokens](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/line1/action_token.py): `aegis/line1/action_token.py`
- [Taint tracking](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/line1/taint.py): `aegis/line1/taint.py`
- [Retrieved-content checks](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/ingress/process.py): `aegis/ingress/process.py`
- [Sensitive-data scan](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/ingress/scan.py): `aegis/ingress/scan.py`
- [Q-Gate detector](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/qgate/detector.py): `aegis/qgate/detector.py`
- [Quantum kernel](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/qgate/kernel.py): `aegis/qgate/kernel.py`
- [Classical RBF](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/qgate/baseline_rbf.py): `aegis/qgate/baseline_rbf.py`

### Tools and Answers

- [Simulated tools](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/tools/sim.py): `aegis/tools/sim.py`
- [Grounded prompting](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/grounding/prompt.py): `aegis/grounding/prompt.py`
- [Citation checks](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/citation_check.py): `aegis/output/citation_check.py`
- [Claim entailment](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/nli.py): `aegis/output/nli.py`
- [Output decisions](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/decide.py): `aegis/output/decide.py`
- [Output refusal](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/output/refusal.py): `aegis/output/refusal.py`

### Model and Audit

- [LLM interface](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/llm.py): `aegis/llm.py`
- **LLM provider**
- [Hash-chain audit](https://github.com/vinith2431/null_bytes_track-2/blob/main/aegis/audit/chain.py): `aegis/audit/chain.py`

### Other components

- **User**

## Connections

- User → Web chat: sends message (evidence: `README.md`)
- Web chat → Agent pipeline: runs turn (evidence: `web/server.py`)
- Agent pipeline → Input normalization: normalizes input (evidence: `README.md`)
- Agent pipeline → Input guards: classifies input (evidence: `README.md`)
- Agent pipeline → Turn risk: tracks risk (evidence: `README.md`)
- Agent pipeline → LLM interface: requests reasoning (evidence: `README.md`)
- LLM interface → LLM provider: calls model (evidence: `aegis/llm.py`)
- Agent pipeline → Tool safety gate: checks tool call (evidence: `aegis/pipeline.py`)
- Tool safety gate → Action tokens: mints token (evidence: `aegis/toolsafety/gate.py`)
- Agent pipeline → Action tokens: authorizes action (evidence: `aegis/pipeline.py`)
- Agent pipeline → Taint tracking: marks arguments (evidence: `aegis/pipeline.py`)
- Agent pipeline → Simulated tools: executes permitted call (evidence: `README.md`)
- Simulated tools → Action tokens: consumes token (evidence: `aegis/tools/sim.py`)
- Agent pipeline → Retrieved-content checks: processes retrieved content (evidence: `README.md`)
- Retrieved-content checks → Sensitive-data scan: scans content (evidence: `aegis/ingress/process.py`)
- Agent pipeline → Q-Gate detector: checks untrusted text (evidence: `README.md`)
- Q-Gate detector → Quantum kernel: scores kernel (evidence: `aegis/qgate/detector.py`)
- Agent pipeline → Classical RBF: checks classical baseline (evidence: `README.md`)
- Agent pipeline → Grounded prompting: builds grounded prompt (evidence: `README.md`)
- Grounded prompting → LLM interface: generates answer (evidence: `README.md`)
- Agent pipeline → Citation checks: validates citations (evidence: `README.md`)
- Agent pipeline → Claim entailment: checks entailment (evidence: `README.md`)
- Agent pipeline → Output decisions: decides answer (evidence: `README.md`)
- Output decisions → Output refusal: returns refusal (evidence: `aegis/output/decide.py`)
- Agent pipeline → Hash-chain audit: records events (evidence: `aegis/pipeline.py`)
- Agent pipeline → Layer config: reads layer flags (evidence: `aegis/pipeline.py`)
