# votal-ai-hq/guardrailsbench architecture

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

- Interactive diagram: https://gitdiagram.com/votal-ai-hq/guardrailsbench
- Repository: https://github.com/votal-ai-hq/guardrailsbench

## Overview

GuardrailsBench builds policy-pack-driven datasets and evaluates guardrails at input and output stages, then scores and reports detection, robustness, utility, coverage, and latency. The main user workflow is CLI → dataset build or validation → system evaluation → metrics/reporting; the README also documents policy packs and remote HTTP guardrails. Some subsystem links rely on the README or SOURCE INDEX because their implementation was not excerpted; those links are omitted where evidence is insufficient.

Main entry points: [`src/guardrailsbench/runner.py`](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/runner.py) (Evaluation runner), [`src/guardrailsbench/cli.py`](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/cli.py) (CLI commands), [`src/guardrailsbench/build.py`](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/build.py) (Dataset builder), [`src/guardrailsbench/systems/base.py`](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/systems/base.py) (Screening and calibration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_cli["CLI commands<br/>[cli.py]"]
end

subgraph group_dataset["Dataset engineering"]
  node_builder["Dataset builder<br/>[build.py]"]
  node_attackgen["Attack transforms<br/>[attacks.py]"]
  node_policy["Policy packs<br/>[pack.py]"]
  node_packfiles["Pack definitions"]
  node_corpus["Seed corpus"]
  node_evaldata["Evaluation datasets<br/>[test.jsonl]"]
  node_validator["Dataset gates<br/>[validate.py]"]
end

subgraph group_systems["Guardrail systems"]
  node_registry["System registry<br/>[__init__.py]"]
  node_guardrail["Screening and calibration<br/>[base.py]"]
  node_baselines["Local baselines"]
  node_httpadapter["HTTP guardrail adapter<br/>[http_api.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_schema["Item and trace schema<br/>[schema.py]"]
  node_runner["Evaluation runner<br/>[runner.py]"]
  node_metrics["Benchmark metrics<br/>[metrics.py]"]
  node_report["Leaderboard and reports<br/>[report.py]"]
  node_leaderboard["Results output<br/>[LEADERBOARD.md]"]
end

subgraph group_integrations["External integrations"]
  node_endpoint(("Guardrail endpoint"))
end

node_engineer(("Benchmark user"))

node_engineer -->|"runs commands"| node_cli
node_cli -->|"builds dataset"| node_builder
node_builder -->|"ingests seed"| node_corpus
node_builder -->|"generates attacks"| node_attackgen
node_builder -->|"loads pack"| node_policy
node_policy -->|"loads definitions"| node_packfiles
node_builder -->|"writes splits"| node_evaldata
node_cli -->|"validates data"| node_validator
node_validator -->|"checks dataset"| node_evaldata
node_evaldata -->|"supplies items"| node_runner
node_cli -->|"starts evaluation"| node_runner
node_runner -->|"uses item traces"| node_schema
node_runner -->|"selects system"| node_registry
node_registry -->|"registers systems"| node_baselines
node_baselines -->|"implements screening"| node_guardrail
node_httpadapter -->|"implements interface"| node_guardrail
node_runner -->|"screens and calibrates"| node_guardrail
node_guardrail -->|"sends requests"| node_endpoint
node_runner -->|"scores traces"| node_metrics
node_metrics -->|"reads traces"| node_schema
node_cli -->|"renders results"| node_report
node_report -->|"formats scores"| node_metrics
node_report -->|"writes leaderboard"| node_leaderboard

click node_cli "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/cli.py"
click node_builder "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/build.py"
click node_attackgen "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/attacks.py"
click node_policy "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/pack.py"
click node_packfiles "https://github.com/votal-ai-hq/guardrailsbench/tree/main/src/guardrailsbench/packs"
click node_corpus "https://github.com/votal-ai-hq/guardrailsbench/blob/main/data/seed/custom_policy_5k_llmshield.csv"
click node_evaldata "https://github.com/votal-ai-hq/guardrailsbench/blob/main/data/test.jsonl"
click node_validator "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/validate.py"
click node_schema "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/schema.py"
click node_registry "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/systems/__init__.py"
click node_guardrail "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/systems/base.py"
click node_baselines "https://github.com/votal-ai-hq/guardrailsbench/tree/main/src/guardrailsbench/systems"
click node_httpadapter "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/systems/http_api.py"
click node_runner "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/runner.py"
click node_metrics "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/metrics.py"
click node_report "https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/report.py"
click node_leaderboard "https://github.com/votal-ai-hq/guardrailsbench/blob/main/LEADERBOARD.md"

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_engineer toneBlue
class node_builder,node_attackgen,node_policy,node_packfiles,node_corpus,node_evaldata,node_validator toneAmber
class node_registry,node_guardrail,node_baselines,node_httpadapter toneMint
class node_schema,node_runner,node_metrics,node_report,node_leaderboard toneRose
class node_endpoint toneIndigo
```

## Components

### User interface

- [CLI commands](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/cli.py): `src/guardrailsbench/cli.py`

### Dataset engineering

- [Dataset builder](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/build.py): `src/guardrailsbench/build.py`
- [Attack transforms](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/attacks.py): `src/guardrailsbench/attacks.py`
- [Policy packs](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/pack.py): `src/guardrailsbench/pack.py`
- [Pack definitions](https://github.com/votal-ai-hq/guardrailsbench/tree/main/src/guardrailsbench/packs): `src/guardrailsbench/packs`
- [Seed corpus](https://github.com/votal-ai-hq/guardrailsbench/blob/main/data/seed/custom_policy_5k_llmshield.csv): `data/seed/custom_policy_5k_llmshield.csv`
- [Evaluation datasets](https://github.com/votal-ai-hq/guardrailsbench/blob/main/data/test.jsonl): `data/test.jsonl`
- [Dataset gates](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/validate.py): `src/guardrailsbench/validate.py`

### Guardrail systems

- [System registry](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/systems/__init__.py): `src/guardrailsbench/systems/__init__.py`
- [Screening and calibration](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/systems/base.py): `src/guardrailsbench/systems/base.py`
- [Local baselines](https://github.com/votal-ai-hq/guardrailsbench/tree/main/src/guardrailsbench/systems): `src/guardrailsbench/systems`
- [HTTP guardrail adapter](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/systems/http_api.py): `src/guardrailsbench/systems/http_api.py`

### Evaluation

- [Item and trace schema](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/schema.py): `src/guardrailsbench/schema.py`
- [Evaluation runner](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/runner.py): `src/guardrailsbench/runner.py`
- [Benchmark metrics](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/metrics.py): `src/guardrailsbench/metrics.py`
- [Leaderboard and reports](https://github.com/votal-ai-hq/guardrailsbench/blob/main/src/guardrailsbench/report.py): `src/guardrailsbench/report.py`
- [Results output](https://github.com/votal-ai-hq/guardrailsbench/blob/main/LEADERBOARD.md): `LEADERBOARD.md`

### External integrations

- **Guardrail endpoint**

### Other components

- **Benchmark user**

## Connections

- Benchmark user → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Dataset builder: builds dataset (evidence: `src/guardrailsbench/cli.py`)
- Dataset builder → Seed corpus: ingests seed (evidence: `README.md`)
- Dataset builder → Attack transforms: generates attacks (evidence: `src/guardrailsbench/build.py`)
- Dataset builder → Policy packs: loads pack (evidence: `src/guardrailsbench/build.py`)
- Policy packs → Pack definitions: loads definitions (evidence: `README.md`)
- Dataset builder → Evaluation datasets: writes splits (evidence: `README.md`)
- CLI commands → Dataset gates: validates data (evidence: `src/guardrailsbench/cli.py`)
- Dataset gates → Evaluation datasets: checks dataset (evidence: `README.md`)
- Evaluation datasets → Evaluation runner: supplies items (evidence: `README.md`)
- CLI commands → Evaluation runner: starts evaluation (evidence: `src/guardrailsbench/cli.py`)
- Evaluation runner → Item and trace schema: uses item traces (evidence: `src/guardrailsbench/runner.py`)
- Evaluation runner → System registry: selects system (evidence: `src/guardrailsbench/runner.py`)
- System registry → Local baselines: registers systems (evidence: `src/guardrailsbench/systems/__init__.py`)
- Local baselines → Screening and calibration: implements screening (evidence: `src/guardrailsbench/systems/__init__.py`)
- HTTP guardrail adapter → Screening and calibration: implements interface (evidence: `src/guardrailsbench/systems/http_api.py`)
- Evaluation runner → Screening and calibration: screens and calibrates (evidence: `src/guardrailsbench/runner.py`)
- Screening and calibration → Guardrail endpoint: sends requests (evidence: `README.md`)
- Evaluation runner → Benchmark metrics: scores traces (evidence: `README.md`)
- Benchmark metrics → Item and trace schema: reads traces (evidence: `src/guardrailsbench/metrics.py`)
- CLI commands → Leaderboard and reports: renders results (evidence: `src/guardrailsbench/cli.py`)
- Leaderboard and reports → Benchmark metrics: formats scores (evidence: `src/guardrailsbench/report.py`)
- Leaderboard and reports → Results output: writes leaderboard (evidence: `README.md`)
