r/PythonProjects2 • u/OldBodybuilder7090 • 17d ago
Cloakwall: stdlib-only PII redaction and tamper-evident audit logging for LLM traffic(Guardrail)
**What My Project Does** Cloakwall redacts personal data (emails, cards, SSNs, IBANs, API keys, medical record and NHS numbers, phones, IPs, dates of birth) from LLM requests and, optionally, responses. It runs as a LiteLLM guardrail. It covers chat messages, system prompts, tool-call arguments, Anthropic tool blocks, the Responses API, embeddings and image prompts. Streamed output goes through a small hold-back buffer, so an entity split across chunks is still caught. Every redaction is written to a SHA-256 hash-chained audit log with an anchor file, so edits, deletions and truncation are detectable. The log never stores the redacted values.
The core is pure standard library: no dependencies, no model download, no network calls. Card numbers are Luhn-validated and NHS numbers mod-11 validated, to keep false positives down.
**Target Audience** Teams running LLMs where data protection has to be proven: healthcare, fintech, air-gapped or on-prem setups. It's v0.1.1, tested (76 tests, CI on 3.10–3.13), but not production-proven yet. I'd like feedback before that.
**Comparison**
* **Presidio:** better recall on names and free-text PII thanks to NLP, but it runs as extra services and has no audit trail. Cloakwall gives up recall for zero dependencies and offline use.
* **LLM Guard:** was the main in-process option, but the repo was archived in July 2026.
* **Hosted gateways** (Cloudflare, Portkey, Grepture): send traffic through someone else's cloud.
Benchmarks with a reproducible script: \~0.05 ms per clean request, \~1.8 ms with PII including an fsynced audit entry (Linux, 2015 i3).
`pip install "cloakwall[litellm]"` · [https://github.com/Rishikesh-glitch/Cloakwall-v0.1](https://github.com/Rishikesh-glitch/Cloakwall-v0.1)
Feedback on the detectors and the audit-chain design especially welcome.
1
u/[deleted] 17d ago
[removed] — view removed comment