Skip to content

Commit 71b2193

Browse files
author
Vish Devarajan
committed
New Features added
1 parent e904675 commit 71b2193

8 files changed

Lines changed: 318 additions & 7 deletions

File tree

BENCHMARKS.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Benchmarks and Regression Notes
2+
3+
## Local Micro-benchmarks
4+
5+
Baseline captured on March 22, 2026 from the local development environment with 500 iterations:
6+
7+
- `guard_model_request()` average latency: `0.086 ms`
8+
- `OutputFirewall.inspect()` average latency: `0.026 ms`
9+
10+
These numbers are for short text-only prompts and responses. Real latency will increase when you add:
11+
12+
- retrieval grounding documents
13+
- custom prompt detectors
14+
- named-entity detection
15+
- larger multimodal message payloads
16+
17+
## False-positive Rollout Guidance
18+
19+
Recommended rollout order:
20+
21+
1. Start with `preset="shadow_first"`
22+
2. Capture `report["telemetry"]` and `on_telemetry` output in structured logs
23+
3. Add route-level overrides for high-risk flows such as admin, billing, exports, and tool-calling
24+
4. Promote specific routes from shadow mode to blocking only after reviewing false-positive rates
25+
26+
## Regression Expectations
27+
28+
Current regression coverage includes:
29+
30+
- prompt-injection overrides
31+
- system-prompt leakage attempts
32+
- token and secret leakage
33+
- Australian PII masking
34+
- route-policy suppression
35+
- custom prompt detectors
36+
- provider adapter wrappers
37+
- multimodal message-part masking
38+
39+
Run the regression suite with:
40+
41+
```bash
42+
python3 -m unittest discover -s tests
43+
```

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 0.1.5
4+
5+
- Added route-level operational telemetry summaries for easier rollout visibility
6+
- Added stronger rollout presets for RAG-safe and agent-tool workflows
7+
- Expanded enterprise-oriented rollout docs around provider coverage, observability, and control-plane usage
8+
9+
## 0.1.4
10+
11+
- Added richer multimodal message-part normalization and masking
12+
- Added provider adapters and stable wrapper guidance as first-class release docs
13+
- Added migration notes, benchmark notes, and rollout guidance for false-positive tuning
14+
- Expanded route-level and domain-level policy documentation for RAG and agent workflows
15+
316
## 0.1.0
417

518
- Initial public release
@@ -13,4 +26,3 @@
1326
- Canary tokens
1427
- Dashboard helpers
1528
- Red-team eval harness
16-

MIGRATING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Migrating to 0.1.4
2+
3+
## Stable Contracts
4+
5+
The following APIs are intended to be the long-term integration surface for the 0.1.x line:
6+
7+
- `guard_model_request()`
8+
- `review_model_response()`
9+
- `protect_model_call()`
10+
- `protect_with_adapter()`
11+
- `ToolPermissionFirewall`
12+
- `RetrievalSanitizer`
13+
14+
These contracts are also exposed in `CORE_INTERFACES` so applications can log or assert the expected interface version.
15+
16+
## What Changed in 0.1.4
17+
18+
- Added richer multimodal/message-part handling for mixed text, image, and file content
19+
- Added provider adapters for OpenAI, Anthropic, Gemini, and OpenRouter
20+
- Added presets and route-level policy overrides
21+
- Added custom prompt detector hooks for domain tuning
22+
- Expanded rollout guidance, benchmarks, and regression notes
23+
24+
## Migration Notes
25+
26+
- If you previously passed message content as arrays of parts, 0.1.4 now preserves those parts in `content_parts` while still producing the text view in `content`.
27+
- If you were wrapping providers manually, prefer `protect_with_adapter()` plus the adapter factories in `blackwall_llm_shield.providers`.
28+
- If you want conservative rollout, switch to `preset="shadow_first"` before enabling hard blocking on every route.
29+
30+
## Compatibility
31+
32+
- Existing string-based `messages[].content` flows remain supported.
33+
- Existing `guard_model_request()` and `OutputFirewall` usage remain backward-compatible.

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Python security toolkit for AI applications and LLM-enabled services. Blackwall
1414
- Emits structured telemetry for prompt risk, masking volume, and output review outcomes
1515
- Includes first-class provider adapters for OpenAI, Anthropic, Gemini, and OpenRouter
1616
- Inspects outputs for leakage, unsafe code, grounding drift, and tone violations
17+
- Handles mixed text, image, and file message parts more gracefully in text-first multimodal flows
18+
- Adds operator-friendly telemetry summaries and stronger presets for RAG and agent-tool workflows
1719
- Ships drop-in FastAPI/Flask middleware and LangChain/LlamaIndex callback helpers
1820
- Enforces tool permissions and approval gates
1921
- Sanitizes retrieval documents for RAG pipelines
@@ -67,6 +69,10 @@ Use `shadow_mode` with `shadow_policy_packs` or `compare_policy_packs` to measur
6769

6870
Use `create_openai_adapter()`, `create_anthropic_adapter()`, `create_gemini_adapter()`, or `create_openrouter_adapter()` with `protect_with_adapter()` when you want Blackwall to wrap the provider call end to end.
6971

72+
### Observability and control-plane support
73+
74+
Use `summarize_operational_telemetry()` with emitted telemetry events when you want route-level summaries, blocked-event counts, and rollout visibility for operators.
75+
7076
### Output grounding and tone review
7177

7278
`OutputFirewall` can compare a response to retrieval documents and flag unsupported claims or unprofessional tone before the answer leaves your service.
@@ -101,6 +107,17 @@ Helps keep hostile or manipulative text in retrieved documents from becoming mod
101107

102108
Pair it with `protect_model_call()` by passing sanitized documents into `firewall_options={"retrieval_documents": docs}` and gate any tool or admin action with `ToolPermissionFirewall`.
103109

110+
### Contract Stability
111+
112+
The 0.1.x line treats `guard_model_request()`, `protect_with_adapter()`, `review_model_response()`, `ToolPermissionFirewall`, and `RetrievalSanitizer` as the long-term integration contracts. The exported `CORE_INTERFACES` map can be logged or asserted by applications that want to pin expected behavior.
113+
114+
Recommended presets:
115+
116+
- `shadow_first` for low-friction rollout
117+
- `strict` for high-sensitivity routes
118+
- `rag_safe` for retrieval-heavy flows
119+
- `agent_tools` for tool-calling and approval-gated agent actions
120+
104121
## Example Workflow
105122

106123
```python
@@ -156,6 +173,44 @@ shield = BlackwallShield(
156173
)
157174
```
158175

176+
## Route and Domain Examples
177+
178+
For RAG:
179+
180+
```python
181+
shield = BlackwallShield(
182+
preset="shadow_first",
183+
route_policies=[
184+
{
185+
"route": "/api/rag/search",
186+
"options": {
187+
"policy_pack": "government",
188+
"output_firewall_defaults": {
189+
"retrieval_documents": kb_docs,
190+
},
191+
},
192+
},
193+
],
194+
)
195+
```
196+
197+
For agent tool-calling:
198+
199+
```python
200+
tool_firewall = ToolPermissionFirewall(
201+
allowed_tools=["search", "lookup_customer", "create_refund"],
202+
require_human_approval_for=["create_refund"],
203+
)
204+
```
205+
206+
## Operational Telemetry Summaries
207+
208+
```python
209+
summary = summarize_operational_telemetry(events)
210+
print(summary["by_route"])
211+
print(summary["highest_severity"])
212+
```
213+
159214
### `AuditTrail`
160215

161216
Produces signed events you can summarize into operations dashboards or audit pipelines.
@@ -177,12 +232,18 @@ Produces signed events you can summarize into operations dashboards or audit pip
177232
- `make version-packages` explains the automated versioning flow for Python
178233
- merges to `main` trigger release automation that prepares version/release PRs and publishes to PyPI after merge
179234

235+
## Migration and Benchmarks
236+
237+
- See [MIGRATING.md](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/MIGRATING.md) for compatibility notes and stable contract guidance
238+
- See [BENCHMARKS.md](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/BENCHMARKS.md) for baseline latency numbers and regression coverage
239+
180240
## Rollout Notes
181241

182242
- Start with `preset="shadow_first"` or `shadow_mode=True` and inspect `report["telemetry"]` plus `on_telemetry` events before enabling hard blocking.
183243
- Use `RetrievalSanitizer` and `ToolPermissionFirewall` in front of RAG, search, admin actions, and tool-calling flows.
184244
- Add regression prompts for instruction overrides, prompt leaks, token leaks, and Australian PII samples so upgrades stay safe.
185245
- Expect some latency increase from grounding checks, output review, and custom detectors; benchmark with your real prompt and response sizes before enforcing globally.
246+
- For agent workflows, keep approval-gated tools and route-specific presets separate from end-user chat routes so operators can see distinct risk patterns.
186247

187248
## New Modules
188249

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "vpdeva-blackwall-llm-shield-python"
7-
version = "0.1.3"
7+
version = "0.1.5"
88
description = "Open-source Python enterprise LLM protection toolkit for Python services"
99
readme = "README.md"
1010
requires-python = ">=3.9"

src/blackwall_llm_shield/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
CORE_INTERFACES,
2020
POLICY_PACKS,
2121
build_shield_options,
22+
summarize_operational_telemetry,
2223
build_admin_dashboard_model,
2324
create_fastapi_guard,
2425
create_langchain_callbacks,
@@ -85,6 +86,7 @@
8586
"ProviderAdapter",
8687
"SHIELD_PRESETS",
8788
"build_shield_options",
89+
"summarize_operational_telemetry",
8890
"build_admin_dashboard_model",
8991
"create_fastapi_guard",
9092
"create_langchain_callbacks",

0 commit comments

Comments
 (0)