Skip to content

Commit 7d3d644

Browse files
committed
docs: add v0.2.0 LangGraph documentation
1 parent a0e95df commit 7d3d644

9 files changed

Lines changed: 563 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.0] — Unreleased
9+
10+
### Added
11+
12+
- **LangGraph integration** — `prooflayer.integrations.langgraph.SecurityMiddleware` wraps compiled LangGraph agents and supports sync, async, streaming, tool-call, state-update, and audit-log paths.
13+
- **Runtime detection categories for LangGraph** — prompt injection, jailbreak, tool abuse, output/input exfiltration, scope drift, state manipulation, multi-turn slow-burn attacks, and streaming output filtering.
14+
- **Adversarial evals** — `prooflayer.evals` adds a 30-probe built-in LangGraph suite, GARAK Docker runner, PromptFoo Docker runner, LangGraph target adapter, and JSON/Markdown findings reports.
15+
- **Compliance evidence** — `prooflayer.compliance` adds NIST AI RMF, EU AI Act, SOC 2, and HIPAA framework registries, event-to-control mapping, hashed evidence records, Markdown reports, and optional PDF output.
16+
- **Audit logging** — `prooflayer.audit` emits structured events with sha256 chain-of-custody hashes and SIEM-compatible JSON.
17+
- **Examples** — five LangGraph examples covering RAG, tool calling, multi-agent supervision, memory attacks, and production compliance reporting.
18+
19+
### Notes
20+
21+
- ProofLayer is positioned as complementary to LangSmith: LangSmith covers tracing and generic evals; ProofLayer covers adversarial evals, runtime security, and compliance evidence.
22+
- v0.1.0 MCP runtime and proxy integrations remain supported.
23+
824
## [0.1.0] — 2026-05-12
925

1026
Initial open-source release of ProofLayer's runtime rules layer.

‎README.md‎

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
55

6-
ProofLayer Runtime is the open runtime security layer for MCP servers. It sits
7-
on the tool-call path, scans MCP requests with local rules, and can warn, block,
8-
or stop dangerous calls before they reach the underlying server.
6+
ProofLayer Runtime is the open runtime security layer for MCP servers and
7+
LangGraph agents. It sits on the tool-call or agent-execution path, scans
8+
requests with local rules, and can warn, block, or stop dangerous actions before
9+
they reach the underlying server, tool, state update, or output stream.
910

1011
The runtime works by itself in rules-only mode. It can also call the
1112
`prooflayer-detector` service over `/v1/detect` for model-backed scoring of
@@ -18,6 +19,13 @@ offering; see [proof-layer.com](https://www.proof-layer.com).
1819

1920
- Local MCP runtime wrappers for synchronous and MCP Python SDK servers.
2021
- HTTP proxy transport for JSON-RPC `tools/call` traffic.
22+
- LangGraph runtime wrapper with prompt injection, jailbreak, tool abuse,
23+
exfiltration, scope drift, state manipulation, multi-turn, and streaming
24+
checks.
25+
- Adversarial evals for LangGraph agents through a built-in suite, GARAK, and
26+
PromptFoo.
27+
- Compliance evidence mapped to NIST AI RMF, EU AI Act Articles 13-15, SOC 2
28+
CC6/CC7, and HIPAA Security Rule.
2129
- YAML detection rules for prompt injection, jailbreaks, command injection,
2230
data exfiltration, role manipulation, tool poisoning, SSRF/XXE, and SQL
2331
injection.
@@ -78,6 +86,53 @@ Install MCP Python SDK support:
7886
pip install -e ".[mcp]"
7987
```
8088

89+
Install LangGraph support:
90+
91+
```bash
92+
pip install -e ".[langgraph]"
93+
```
94+
95+
Install everything:
96+
97+
```bash
98+
pip install -e ".[all]"
99+
```
100+
101+
## LangGraph Security Layer
102+
103+
ProofLayer is complementary to LangGraph and LangSmith:
104+
105+
| Layer | What it does | Provided by |
106+
|---|---|---|
107+
| Agent orchestration | Build, deploy, run agents | LangGraph |
108+
| Tracing + observability | See what agents did | LangSmith |
109+
| Generic evals | LLM-as-judge, regression tests | LangSmith |
110+
| Adversarial evals | GARAK / PromptFoo red-team probes | ProofLayer |
111+
| Runtime security | Real-time prompt injection, tool abuse, exfil detection + blocking | ProofLayer |
112+
| Compliance evidence | NIST AI RMF / EU AI Act / SOC 2 / HIPAA audit-defensible reports | ProofLayer |
113+
114+
Three-line integration:
115+
116+
```python
117+
from prooflayer.integrations.langgraph import SecurityConfig, SecurityMiddleware
118+
119+
middleware = SecurityMiddleware(SecurityConfig(prompt_injection="block"))
120+
secured_graph = middleware.wrap(graph.compile())
121+
result = secured_graph.invoke({"input": user_input})
122+
```
123+
124+
Run the examples:
125+
126+
```bash
127+
python examples/integrations/langgraph/01_simple_rag.py
128+
python examples/integrations/langgraph/02_tool_calling_agent.py
129+
python examples/integrations/langgraph/03_multi_agent_supervisor.py
130+
python examples/integrations/langgraph/04_memory_attack_demo.py
131+
python examples/integrations/langgraph/05_production_template.py
132+
```
133+
134+
See [docs/integrations/langgraph.md](docs/integrations/langgraph.md), [docs/evals.md](docs/evals.md), and [docs/compliance.md](docs/compliance.md).
135+
81136
## Verify Locally
82137

83138
Benign call:

‎SPRINT_PROGRESS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
- Day 15: Added NIST AI RMF, EU AI Act, SOC 2, and HIPAA compliance framework registries with 20 AI-applicable controls each and schema tests.
1616
- Day 16: Added compliance evidence records, deterministic event-to-control mapping, Markdown report generation, optional PDF rendering, and tests.
1717
- Day 17: Added four additional LangGraph sample apps for tool validation, multi-agent state monitoring, multi-turn memory attacks, and production compliance reporting.
18+
- Day 18: Added LangGraph integration, evals, compliance, architecture, and API docs; updated README positioning and CHANGELOG for v0.2.0.

‎docs/api.md‎

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# API Reference
2+
3+
This reference covers the v0.2.0 LangGraph, evals, compliance, and audit surfaces.
4+
5+
## `prooflayer.integrations.langgraph`
6+
7+
### `SecurityConfig`
8+
9+
Runtime security configuration for LangGraph middleware.
10+
11+
Key fields:
12+
13+
- `prompt_injection`
14+
- `jailbreak`
15+
- `tool_abuse`
16+
- `exfil`
17+
- `scope_drift`
18+
- `state_manipulation`
19+
- `multi_turn`
20+
- `compliance_frameworks`
21+
- `emit_to`
22+
- `allowed_tools`
23+
- `session_id_key`
24+
- `streaming_block_mode`
25+
- `blocked_token`
26+
27+
Detection actions are `allow`, `warn`, or `block`.
28+
29+
### `SecurityMiddleware`
30+
31+
Wraps compiled LangGraph objects and exposes:
32+
33+
- `wrap(compiled_graph)`
34+
- `get_audit_log(session_id=None)`
35+
- `scan_input(payload, config=None)`
36+
- `scan_output(payload, config=None)`
37+
- `scan_state_update(state_update, config=None)`
38+
- `record_event(event)`
39+
40+
### `ToolValidator`
41+
42+
Validates LangGraph tool calls:
43+
44+
- allowlist enforcement
45+
- suspicious argument inspection
46+
- output capture events
47+
48+
### `StreamingFilter`
49+
50+
Filters streamed chunks and event payloads for critical output detections.
51+
52+
### Exceptions
53+
54+
- `SecurityException`
55+
- `BlockedError`
56+
57+
## `prooflayer.evals`
58+
59+
### `LangGraphEvalTarget`
60+
61+
Adapts a secured LangGraph object for eval runners:
62+
63+
- `invoke(prompt, config=None)`
64+
- `ainvoke(prompt, config=None)`
65+
- `handle_chat_completions(request)`
66+
67+
### `EvalRunner`
68+
69+
Top-level orchestration:
70+
71+
- `run_builtin_suite(target)`
72+
- `run_all(target, output_dir, endpoint_url=None, promptfoo_config=None, garak_probes=None)`
73+
74+
### `GarakRunner`
75+
76+
Docker-backed GARAK runner:
77+
78+
- `build_command(endpoint_url, output_dir, probes=None)`
79+
- `run(endpoint_url, output_dir, probes=None)`
80+
- `parse_report(output_dir)`
81+
82+
### `PromptFooRunner`
83+
84+
Docker-backed PromptFoo runner:
85+
86+
- `build_command(config_path, output_path, env=None)`
87+
- `run(config_path, output_path, env=None)`
88+
- `parse_report(output_path)`
89+
90+
### `ReportGenerator`
91+
92+
Renders eval reports as JSON and Markdown.
93+
94+
## `prooflayer.compliance`
95+
96+
### `ComplianceEmitter`
97+
98+
Maps runtime events into framework controls:
99+
100+
- `emit(event, previous_hash=None)`
101+
- `load_framework(framework)`
102+
103+
### `EvidenceRecord`
104+
105+
Auditor-facing evidence schema with sha256 chain-of-custody hashing.
106+
107+
### `ComplianceReportGenerator`
108+
109+
Renders compliance evidence:
110+
111+
- `build(evidence_records, title=...)`
112+
- `to_markdown(evidence_records, title=..., output_path=None)`
113+
- `to_pdf(markdown, output_path)`
114+
115+
## `prooflayer.audit`
116+
117+
### `AuditEvent`
118+
119+
Structured runtime event with:
120+
121+
- session ID
122+
- rule ID
123+
- severity
124+
- decision
125+
- evidence snippet
126+
- timestamp
127+
- source
128+
- metadata
129+
- previous hash
130+
- event hash
131+
132+
### `AuditLogger`
133+
134+
Emits audit events to:
135+
136+
- stdout
137+
- JSONL files
138+
- SIEM-compatible JSON

‎docs/architecture.md‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,86 @@ For servers built with the official MCP Python SDK, `ProofLayerMCPWrapper` provi
214214
- **Tool poisoning detection** -- scans `list_tools` descriptions for injected instructions
215215

216216
All three scanning points use the same `DetectionEngine` and scoring pipeline.
217+
218+
## LangGraph Integration
219+
220+
`prooflayer.integrations.langgraph.SecurityMiddleware` wraps compiled LangGraph objects and preserves the normal invocation interface:
221+
222+
- `invoke`
223+
- `ainvoke`
224+
- `stream`
225+
- `astream`
226+
- `stream_events`
227+
- `astream_events`
228+
229+
LangGraph hot path:
230+
231+
```
232+
User input
233+
|
234+
v
235+
SecurityMiddleware.before_node("__graph__")
236+
|
237+
+--> DetectionEngine rules: prompt injection, jailbreak, tool abuse, exfil
238+
+--> StateManipulationDetector for state-like inputs
239+
+--> MultiTurnDetector keyed by thread_id/session_id
240+
|
241+
v
242+
Compiled LangGraph executes
243+
|
244+
v
245+
SecurityMiddleware.after_node("__graph__")
246+
|
247+
+--> DetectionEngine output exfil checks
248+
+--> ScopeDriftDetector
249+
|
250+
v
251+
Secured result or BlockedError
252+
```
253+
254+
Tool-level hooks are available for graph nodes that call tools:
255+
256+
```
257+
LangGraph tool node
258+
|
259+
v
260+
middleware.hooks.on_tool_call(tool_name, tool_args)
261+
|
262+
+--> Tool allowlist
263+
+--> Argument exfil and tool-abuse inspection
264+
|
265+
v
266+
Tool executes or BlockedError
267+
```
268+
269+
Streaming output is filtered chunk by chunk. Critical detections either raise `BlockedError` or replace the chunk with the configured blocked token.
270+
271+
## Evals and Compliance
272+
273+
The eval layer normalizes findings from three sources:
274+
275+
- ProofLayer built-in adversarial probes
276+
- GARAK Docker runner
277+
- PromptFoo Docker runner
278+
279+
Eval reports can be rendered as JSON and Markdown.
280+
281+
The compliance layer maps runtime events and eval reports into framework controls:
282+
283+
```
284+
Detection event / eval report
285+
|
286+
v
287+
ComplianceEmitter
288+
|
289+
+--> NIST AI RMF
290+
+--> EU AI Act Articles 13-15
291+
+--> SOC 2 CC6/CC7
292+
+--> HIPAA Security Rule
293+
|
294+
v
295+
EvidenceRecord with sha256 chain hash
296+
|
297+
v
298+
Markdown / optional PDF report
299+
```

0 commit comments

Comments
 (0)