ninadphalak/LLM-Shield-Proxy: v1.3.0: Stateless Cryptography, MCP Governance, Air-Gapped Egress, and System Hardening
Authors/Creators
Description
chunk-invariance 0.3.0 checks a stream filter against the shapes real providers stream text in, not only against a single cut.
pip install --upgrade chunk-invariance
pip install "chunk-invariance[tokens]" # optional: real token boundaries
Stream-shaped splits, now in the default check
Many providers send about one tokenizer token per event, so a value arrives in many small pieces (555, ., 867, ., 530, 9), and a piece often ends right after a mark inside the value. Others batch a few tokens per event. A filter can be right whenever a value spans two chunks and still be wrong when it spans many.
| Named set | Splits |
|---|---|
| "tokens" | one token per chunk, then 2, 3 and 4 tokens per chunk |
| "punctuation" | for each ., ? or ! followed by a non-space character: a chunk that ends right after it, alone and inside the token stream |
| "fixed-size" | chunks of 1, 2, 3, 4 and 8 characters |
| "n-part" | seeded random splits into exactly 3, 4, 6 and 8 parts |
| "streams" | all four, duplicates removed |
Behaviour change: the default splits="default" is now the whole input, every single cut, then the stream shapes, so assert_chunk_invariant checks a few dozen more splits per input and returns a larger count. splits="all-two-part" keeps the 0.2.0 behaviour.
Token boundaries come from tiktoken (o200k_base) when the tokens extra is installed and its encoding can be loaded, and otherwise from a small built-in tokenizer. The base install stays standard library only. The generators are importable (token_splits, punctuation_splits, fixed_size_splits, n_part_splits, stream_splits, tokenize), and chunk_invariance.examples.lookahead_one is a worked wrong design that passes every single cut and fails a token stream.
MCP server
The server's tools are unchanged (two-part splits or up to three parts). Since 0.2.0 the server runs only functions defined in the project's own files: before, a tool call could name any standard-library callable (#214).
The npm package stays at 0.1.0; the stream shapes are Python only for now.
Notes
Files
ninadphalak/LLM-Shield-Proxy-chunk-invariance-v0.3.0.zip
Additional details
Related works
- Is supplement to
- Software: https://github.com/ninadphalak/LLM-Shield-Proxy/tree/chunk-invariance-v0.3.0 (URL)
Software
- Repository URL
- https://github.com/ninadphalak/LLM-Shield-Proxy