# microsoft/rampart architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/rampart
- Repository: https://github.com/microsoft/rampart

## Overview

RAMPART is a pytest-native framework for testing agentic AI safety and security. Developers define attack or probe executions against an agent adapter; prompt drivers supply requests, execution strategies manage sessions and turns, evaluators assess behavior, and results capture verdicts and evidence for reporting. Supporting capabilities include adversarial payload generation, injection surfaces, LLM-backed judging, and pytest integration. Edges reflect the README and SOURCE INDEX references or shown execution calls; unsampled subsystems and their internal wiring are represented conservatively.

Main entry points: [`rampart/core/execution.py`](https://github.com/microsoft/rampart/blob/main/rampart/core/execution.py) (Execution lifecycle), [`rampart/attacks/_xpia.py`](https://github.com/microsoft/rampart/blob/main/rampart/attacks/_xpia.py) (XPIA strategy), [`rampart/core/evaluator.py`](https://github.com/microsoft/rampart/blob/main/rampart/core/evaluator.py) (Evaluator composition), [`rampart/pyrit_bridge/llm_bridge.py`](https://github.com/microsoft/rampart/blob/main/rampart/pyrit_bridge/llm_bridge.py) (PyRIT bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Test authoring"]
  node_test_api["Public test API<br/>[__init__.py]"]
  node_attacks["Attack factory<br/>[_factory.py]"]
  node_xpia["XPIA strategy<br/>[_xpia.py]"]
  node_probes["Probe factory<br/>[_factory.py]"]
  node_single_turn["Single-turn strategy<br/>[_single_turn.py]"]
end

subgraph group_runtime["Execution runtime"]
  node_execution["Execution lifecycle<br/>[execution.py]"]
  node_adapter["Agent adapter<br/>[adapter.py]"]
  node_prompt_driver["Prompt driver protocol<br/>[prompt_driver.py]"]
  node_llm_driver["LLM prompt driver<br/>[llm.py]"]
  node_static_driver["Static prompt driver<br/>[static.py]"]
  node_pyrit_bridge["PyRIT bridge<br/>[llm_bridge.py]"]
  node_llm_config["LLM configuration<br/>[llm.py]"]
  node_templates["Prompt templates<br/>[templates.py]"]
end

subgraph group_assessment["Evaluation and results"]
  node_evaluator["Evaluator composition<br/>[evaluator.py]"]
  node_llm_judge["LLM judge<br/>[llm_judge.py]"]
  node_response_eval["Response matcher"]
  node_result["Verdict and evidence<br/>[result.py]"]
  node_types["Shared domain types<br/>[types.py]"]
  node_text_utils["Text safety<br/>[text.py]"]
end

subgraph group_payloads["Payloads and surfaces"]
  node_payload_api["Payload facade<br/>[_facade.py]"]
  node_payload_generator["Payload generator<br/>[_generator.py]"]
  node_payload_template["Payload templates<br/>[template.py]"]
  node_payload_store["Payload store<br/>[_store.py]"]
  node_injection["Injection contract<br/>[injection.py]"]
  node_onedrive["OneDrive surface<br/>[onedrive.py]"]
end

subgraph group_integration["Pytest and reporting"]
  node_pytest_collection["Test collection<br/>[_collection.py]"]
  node_pytest_plugin["pytest plugin<br/>[plugin.py]"]
  node_pytest_session["Session handling<br/>[_session.py]"]
  node_report_sink["Report sink<br/>[sink.py]"]
  node_json_report["JSON report<br/>[json_file.py]"]
end

node_developer(("Test developer"))
node_pytest(("pytest runner"))
node_agent(("Agent under test"))
node_llm_service(("LLM service<br/>external"))

node_developer -->|"defines tests"| node_test_api
node_pytest -->|"loads plugin"| node_pytest_plugin
node_test_api -->|"exposes attacks"| node_attacks
node_test_api -->|"exposes probes"| node_probes
node_attacks -->|"builds strategy"| node_xpia
node_probes -->|"builds strategy"| node_single_turn
node_xpia -->|"extends lifecycle"| node_execution
node_single_turn -->|"extends lifecycle"| node_execution
node_execution -->|"creates session"| node_adapter
node_execution -->|"requests prompts"| node_prompt_driver
node_execution -->|"evaluates turns"| node_evaluator
node_execution -->|"builds result"| node_result
node_single_turn -->|"builds result"| node_result
node_agent -.->|"is wrapped by"| node_adapter
node_llm_driver -->|"implements"| node_prompt_driver
node_static_driver -->|"implements"| node_prompt_driver
node_llm_driver -->|"sends prompts"| node_pyrit_bridge
node_llm_config -->|"configures target"| node_pyrit_bridge
node_pyrit_bridge -.->|"calls model"| node_llm_service
node_llm_judge -->|"sends judge request"| node_pyrit_bridge
node_evaluator -.->|"composes evaluator"| node_llm_judge
node_evaluator -.->|"composes evaluator"| node_response_eval
node_payload_api -->|"delegates generation"| node_payload_generator
node_payload_generator -->|"uses template"| node_payload_template
node_xpia -->|"activates handles"| node_injection
node_onedrive -->|"implements contract"| node_injection
node_pytest_plugin -.->|"collects tests"| node_pytest_collection
node_pytest_collection -->|"invokes execution"| node_execution
node_pytest_session -->|"uses collection"| node_pytest_collection
node_pytest_session -->|"writes results"| node_report_sink
node_report_sink -->|"writes JSON"| node_json_report
node_json_report -->|"serializes verdict"| node_result
node_xpia -->|"uses domain types"| node_types
node_evaluator -->|"uses evaluation types"| node_types
node_llm_driver -->|"renders prompt"| node_templates
node_result -->|"sanitizes text"| node_text_utils

click node_test_api "https://github.com/microsoft/rampart/blob/main/rampart/__init__.py"
click node_attacks "https://github.com/microsoft/rampart/blob/main/rampart/attacks/_factory.py"
click node_xpia "https://github.com/microsoft/rampart/blob/main/rampart/attacks/_xpia.py"
click node_probes "https://github.com/microsoft/rampart/blob/main/rampart/probes/_factory.py"
click node_single_turn "https://github.com/microsoft/rampart/blob/main/rampart/probes/_single_turn.py"
click node_execution "https://github.com/microsoft/rampart/blob/main/rampart/core/execution.py"
click node_adapter "https://github.com/microsoft/rampart/blob/main/rampart/core/adapter.py"
click node_prompt_driver "https://github.com/microsoft/rampart/blob/main/rampart/core/prompt_driver.py"
click node_llm_driver "https://github.com/microsoft/rampart/blob/main/rampart/drivers/llm.py"
click node_static_driver "https://github.com/microsoft/rampart/blob/main/rampart/drivers/static.py"
click node_evaluator "https://github.com/microsoft/rampart/blob/main/rampart/core/evaluator.py"
click node_llm_judge "https://github.com/microsoft/rampart/blob/main/rampart/evaluators/llm_judge.py"
click node_response_eval "https://github.com/microsoft/rampart/blob/main/rampart/evaluators/response_contains.py"
click node_result "https://github.com/microsoft/rampart/blob/main/rampart/core/result.py"
click node_types "https://github.com/microsoft/rampart/blob/main/rampart/core/types.py"
click node_payload_api "https://github.com/microsoft/rampart/blob/main/rampart/payloads/_facade.py"
click node_payload_generator "https://github.com/microsoft/rampart/blob/main/rampart/payloads/_generator.py"
click node_payload_template "https://github.com/microsoft/rampart/blob/main/rampart/payloads/template.py"
click node_payload_store "https://github.com/microsoft/rampart/blob/main/rampart/payloads/_store.py"
click node_injection "https://github.com/microsoft/rampart/blob/main/rampart/core/injection.py"
click node_onedrive "https://github.com/microsoft/rampart/blob/main/rampart/surfaces/onedrive.py"
click node_pyrit_bridge "https://github.com/microsoft/rampart/blob/main/rampart/pyrit_bridge/llm_bridge.py"
click node_llm_config "https://github.com/microsoft/rampart/blob/main/rampart/core/llm.py"
click node_pytest_collection "https://github.com/microsoft/rampart/blob/main/rampart/pytest_plugin/_collection.py"
click node_pytest_plugin "https://github.com/microsoft/rampart/blob/main/rampart/pytest_plugin/plugin.py"
click node_pytest_session "https://github.com/microsoft/rampart/blob/main/rampart/pytest_plugin/_session.py"
click node_report_sink "https://github.com/microsoft/rampart/blob/main/rampart/reporting/sink.py"
click node_json_report "https://github.com/microsoft/rampart/blob/main/rampart/reporting/json_file.py"
click node_text_utils "https://github.com/microsoft/rampart/blob/main/rampart/common/text.py"
click node_templates "https://github.com/microsoft/rampart/blob/main/rampart/common/templates.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_test_api,node_attacks,node_xpia,node_probes,node_single_turn toneBlue
class node_execution,node_adapter,node_prompt_driver,node_llm_driver,node_static_driver,node_pyrit_bridge,node_llm_config,node_templates toneAmber
class node_evaluator,node_llm_judge,node_response_eval,node_result,node_types,node_text_utils toneMint
class node_payload_api,node_payload_generator,node_payload_template,node_payload_store,node_injection,node_onedrive toneRose
class node_pytest_collection,node_pytest_plugin,node_pytest_session,node_report_sink,node_json_report,node_developer,node_pytest,node_agent,node_llm_service toneIndigo
```

## Components

### Test authoring

- [Public test API](https://github.com/microsoft/rampart/blob/main/rampart/__init__.py): `rampart/__init__.py`
- [Attack factory](https://github.com/microsoft/rampart/blob/main/rampart/attacks/_factory.py): `rampart/attacks/_factory.py`
- [XPIA strategy](https://github.com/microsoft/rampart/blob/main/rampart/attacks/_xpia.py): `rampart/attacks/_xpia.py`
- [Probe factory](https://github.com/microsoft/rampart/blob/main/rampart/probes/_factory.py): `rampart/probes/_factory.py`
- [Single-turn strategy](https://github.com/microsoft/rampart/blob/main/rampart/probes/_single_turn.py): `rampart/probes/_single_turn.py`

### Execution runtime

- [Execution lifecycle](https://github.com/microsoft/rampart/blob/main/rampart/core/execution.py): `rampart/core/execution.py`
- [Agent adapter](https://github.com/microsoft/rampart/blob/main/rampart/core/adapter.py): `rampart/core/adapter.py`
- [Prompt driver protocol](https://github.com/microsoft/rampart/blob/main/rampart/core/prompt_driver.py): `rampart/core/prompt_driver.py`
- [LLM prompt driver](https://github.com/microsoft/rampart/blob/main/rampart/drivers/llm.py): `rampart/drivers/llm.py`
- [Static prompt driver](https://github.com/microsoft/rampart/blob/main/rampart/drivers/static.py): `rampart/drivers/static.py`
- [PyRIT bridge](https://github.com/microsoft/rampart/blob/main/rampart/pyrit_bridge/llm_bridge.py): `rampart/pyrit_bridge/llm_bridge.py`
- [LLM configuration](https://github.com/microsoft/rampart/blob/main/rampart/core/llm.py): `rampart/core/llm.py`
- [Prompt templates](https://github.com/microsoft/rampart/blob/main/rampart/common/templates.py): `rampart/common/templates.py`

### Evaluation and results

- [Evaluator composition](https://github.com/microsoft/rampart/blob/main/rampart/core/evaluator.py): `rampart/core/evaluator.py`
- [LLM judge](https://github.com/microsoft/rampart/blob/main/rampart/evaluators/llm_judge.py): `rampart/evaluators/llm_judge.py`
- [Response matcher](https://github.com/microsoft/rampart/blob/main/rampart/evaluators/response_contains.py): `rampart/evaluators/response_contains.py`
- [Verdict and evidence](https://github.com/microsoft/rampart/blob/main/rampart/core/result.py): `rampart/core/result.py`
- [Shared domain types](https://github.com/microsoft/rampart/blob/main/rampart/core/types.py): `rampart/core/types.py`
- [Text safety](https://github.com/microsoft/rampart/blob/main/rampart/common/text.py): `rampart/common/text.py`

### Payloads and surfaces

- [Payload facade](https://github.com/microsoft/rampart/blob/main/rampart/payloads/_facade.py): `rampart/payloads/_facade.py`
- [Payload generator](https://github.com/microsoft/rampart/blob/main/rampart/payloads/_generator.py): `rampart/payloads/_generator.py`
- [Payload templates](https://github.com/microsoft/rampart/blob/main/rampart/payloads/template.py): `rampart/payloads/template.py`
- [Payload store](https://github.com/microsoft/rampart/blob/main/rampart/payloads/_store.py): `rampart/payloads/_store.py`
- [Injection contract](https://github.com/microsoft/rampart/blob/main/rampart/core/injection.py): `rampart/core/injection.py`
- [OneDrive surface](https://github.com/microsoft/rampart/blob/main/rampart/surfaces/onedrive.py): `rampart/surfaces/onedrive.py`

### Pytest and reporting

- [Test collection](https://github.com/microsoft/rampart/blob/main/rampart/pytest_plugin/_collection.py): `rampart/pytest_plugin/_collection.py`
- [pytest plugin](https://github.com/microsoft/rampart/blob/main/rampart/pytest_plugin/plugin.py): `rampart/pytest_plugin/plugin.py`
- [Session handling](https://github.com/microsoft/rampart/blob/main/rampart/pytest_plugin/_session.py): `rampart/pytest_plugin/_session.py`
- [Report sink](https://github.com/microsoft/rampart/blob/main/rampart/reporting/sink.py): `rampart/reporting/sink.py`
- [JSON report](https://github.com/microsoft/rampart/blob/main/rampart/reporting/json_file.py): `rampart/reporting/json_file.py`

### Other components

- **Test developer**
- **pytest runner**
- **Agent under test**
- **LLM service**: external

## Connections

- Test developer → Public test API: defines tests
- pytest runner → pytest plugin: loads plugin
- Public test API → Attack factory: exposes attacks (evidence: `rampart/__init__.py`)
- Public test API → Probe factory: exposes probes (evidence: `rampart/__init__.py`)
- Attack factory → XPIA strategy: builds strategy (evidence: `rampart/attacks/_factory.py`)
- Probe factory → Single-turn strategy: builds strategy (evidence: `rampart/probes/_factory.py`)
- XPIA strategy → Execution lifecycle: extends lifecycle (evidence: `rampart/attacks/_xpia.py`)
- Single-turn strategy → Execution lifecycle: extends lifecycle (evidence: `rampart/probes/_single_turn.py`)
- Execution lifecycle → Agent adapter: creates session (evidence: `rampart/probes/_single_turn.py`)
- Execution lifecycle → Prompt driver protocol: requests prompts (evidence: `rampart/probes/_single_turn.py`)
- Execution lifecycle → Evaluator composition: evaluates turns (evidence: `rampart/core/execution.py`)
- Execution lifecycle → Verdict and evidence: builds result (evidence: `rampart/attacks/_xpia.py`)
- Single-turn strategy → Verdict and evidence: builds result (evidence: `rampart/probes/_single_turn.py`)
- Agent under test → Agent adapter: is wrapped by
- LLM prompt driver → Prompt driver protocol: implements (evidence: `rampart/drivers/llm.py`)
- Static prompt driver → Prompt driver protocol: implements (evidence: `rampart/drivers/static.py`)
- LLM prompt driver → PyRIT bridge: sends prompts (evidence: `rampart/drivers/llm.py`)
- LLM configuration → PyRIT bridge: configures target (evidence: `rampart/pyrit_bridge/llm_bridge.py`)
- PyRIT bridge → LLM service: calls model
- LLM judge → PyRIT bridge: sends judge request (evidence: `rampart/evaluators/llm_judge.py`)
- Evaluator composition → LLM judge: composes evaluator (evidence: `rampart/evaluators/llm_judge.py`)
- Evaluator composition → Response matcher: composes evaluator (evidence: `rampart/evaluators/response_contains.py`)
- Payload facade → Payload generator: delegates generation (evidence: `rampart/payloads/_facade.py`)
- Payload generator → Payload templates: uses template (evidence: `rampart/payloads/_generator.py`)
- XPIA strategy → Injection contract: activates handles (evidence: `rampart/attacks/_xpia.py`)
- OneDrive surface → Injection contract: implements contract (evidence: `rampart/surfaces/onedrive.py`)
- pytest plugin → Test collection: collects tests
- Test collection → Execution lifecycle: invokes execution (evidence: `rampart/pytest_plugin/_collection.py`)
- Session handling → Test collection: uses collection (evidence: `rampart/pytest_plugin/_session.py`)
- Session handling → Report sink: writes results (evidence: `rampart/pytest_plugin/_session.py`)
- Report sink → JSON report: writes JSON (evidence: `rampart/reporting/json_file.py`)
- JSON report → Verdict and evidence: serializes verdict (evidence: `rampart/reporting/json_file.py`)
- XPIA strategy → Shared domain types: uses domain types (evidence: `rampart/attacks/_xpia.py`)
- Evaluator composition → Shared domain types: uses evaluation types (evidence: `rampart/core/evaluator.py`)
- LLM prompt driver → Prompt templates: renders prompt (evidence: `rampart/drivers/llm.py`)
- Verdict and evidence → Text safety: sanitizes text (evidence: `rampart/core/result.py`)
