This library is an asynchronous, distributed defensive pipeline built to maintain state correctness under multi-process contention. It supports Redis (pinning session counters to a single slot for atomic updates in Redis Cluster), PostgreSQL, and MySQL.
Features: • Multi-turn jailbreak mitigation and state synchronization across pods. • Scope-gated capability tokens for tool-calling defense (cryptographically signed constraints). • Side-channel exfiltration blocking (scans output for leaks hidden in Markdown/HTML media tags or CSS url() before it completes streaming). • Protection against invisible Unicode codepoint smuggling and homoglyph attacks (e.g., bypassing lexical lists using Cyrillic lookalikes). • Zero-downtime signing key rotation. Honest limitations (as detailed in the docs): • Lexical pattern lists cover 6 common languages; you'll need to extend them based on your traffic. • It handles signed constraints but doesn't authenticate principals; that boundary belongs strictly at your gateway. • No heuristic replaces dedicated red-teaming. It's meant to provide infrastructure-level enforcement and measurement tools (shadow mode, Prometheus metrics).
The project is fully open source (MIT), written in Python (>=3.10), and available on PyPI.
GitHub Repository: https://github.com/matteocacciola/llm-security-pipeline
I would appreciate any feedback on the architecture, edge cases I might have missed, or database deadlock handling under heavy same-key contention.