PromptGate 0.3 — changelog
Archived from CHANGELOG.md, which keeps the unreleased changes and the latest release.
0.3.0 - 2026-10-19
Section titled “0.3.0 - 2026-10-19”The guardrails release: every request can be inspected before a provider sees it — in any API format, including tool results and attachments — for secrets, personal data and prompt injection; keys can be limited to networks and office hours; tool output is trimmed to save tokens; and personal data can be redacted reversibly, so users still read it in the answer. Guardrails apply globally, per model alias or per key, reload without a restart, and are measured on every build with pgfuzz.
-
Guardrails —
guardrails:inspects every request before a provider sees it, in any API format: messages, system prompts, tool calls and results, Responses and embeddings input. Actionsblock(422 in the SDK’s error shape),mask([KEYWORD]) andlog; per-guardroles(user, assistant, system, tool); overrides per model alias andpg_key, field by field. Findings (never the matched text) appear in the console, the request log (guard, schema v3) and thepromptgate_guardrail_findings_totalmetric. First guards:keywords(whole words, case-insensitive) andlength. 4 µs for a 2 KB request. -
Attachments are inspected — text, docx, xlsx, pptx and PDFs with a text layer in requests (Anthropic documents, OpenAI file parts, Responses input files) are read in-process and checked by every content guard; text files can be masked.
guardrails.attachmentssetsaction: blockto refuse all attachments,unreadable: blockto refuse images, scans, remote URLs and file ids, andmax_bytes. Formats are recognised by content; extraction is bounded against decompression bombs and isolated against malformed PDFs. New dependency:github.com/ledongthuc/pdf(BSD-3-Clause, pure Go). -
Secret scanner —
guardrails.secretsfinds API keys, tokens, private keys and passwords in connection strings in messages, tool results and attachments: PromptGate’s curated rules (incl. current OpenAIsk-proj-keys, LLM providers andpg_keys) plus 221 gitleaks formats with their entropy thresholds and allowlists. Block (default), mask ([AWS_ACCESS_KEY]) or log;kinds,exclude,custompatterns. Rules run only around literals every match must contain: 14 µs per 2 KB request, 2.5 ms per 200 KB of code; adversarial input is cut off and refused rather than scanned unbounded. pgfuzz recall 100%, no false positives on 1.4 MB of real code. -
PII filter —
guardrails.piimasks e-mail addresses, phone numbers (international, US, national with trunk 0), IBANs, credit card numbers, US SSNs and IP addresses as[EMAIL],[PHONE], …;blockandlogtoo. Checksums and ranges (mod-97, Luhn, SSA ranges, issuer lengths) are on by default (validate); loopback and0.0.0.0are skipped;allowexempts values or whole domains;customadds patterns (RE2 or v1’s/re/flags). Hand-written scanners instead of regular expressions: 2.6 µs per 2 KB request. pgfuzz recall 100% over 5,000 values, no false positives on 2.6 MB of real code and docs. -
Prompt-injection detection —
guardrails.prompt_injectionblocks attempts to take over the model in English and German: ignoring or forgetting previous instructions, overriding rules, role assumption (“you are now …”), system-prompt leaks, jailbreak modes and smuggled chat-template tokens ([INST],<|im_start|>, …). Phrases match word by word with gaps, so single words never trigger; zero-width characters, soft hyphens and odd spaces are stripped first.kinds,languages,customphrases in a small syntax or regular expressions; user content by default,mask/logfor tool results. pgfuzz recall 100% over 4,200 payloads incl. zero-width obfuscation; only real injection text found in 3.4 MB of code and docs. ≈ 6 µs for a 2 KB user message. -
Reversible redaction —
action: redacton any guard that can mask replaces findings with numbered tokens ([[EMAIL_001]], the same token for the same value) and puts the originals back into the answer: buffered JSON and event streams, every API format, after translation, in text and tool-call arguments. Tokens split across stream events are reassembled — an event ending in a token start waits for the next piece; text that isn’t a token passes unchanged. The mapping lives only for the request. ≈ 0.5 µs per streamed event. -
Token saver —
guardrails.token_savertrims tool results before any provider sees them: terminal escape codes and progress-bar redraws, trailing whitespace and blank-line runs, repeated outputs (the first copy stays, so prompt caches keep hitting) and, withtruncate_bytes, oversized output (head and tail kept, cut at line ends).action: logis a dry run. Savings appear in the request log (token_saver: trimmed duplicate×2 (41.7 KB)) and inpromptgate_token_saver_bytes_total{key,mode}. Transformers are a new guard kind: they run before every detector, which then scans the trimmed text. -
Access rules —
guardrails.ip_allowlist(allow/denywith IPs and CIDRs) andguardrails.time_window(weekly windows withdays,from,to,timezone; windows past midnight belong to the day they start) refuse with 403, globally, per alias or per key.server.trusted_proxiesnames reverse proxies whoseX-Forwarded-Foris read, from the right, so clients can’t claim an address themselves. Guards may now set their block status. -
Contextual PII —
guardrails.pii_contextualfinds names, postal addresses, dates of birth and kinds you describe (custom) by asking a model through any configured provider. The model only lists what it found; PromptGate locates those strings as whole words and masks, redacts, blocks or logs them, so the model never rewrites a request and can’t invent what gets changed. One call per new text, in parallel; answers cached by text, so a resent conversation costs a call for its new messages only.on_error: allow|block. Guards can now prepare per request (seeguard.Preparer) and call providers with their server-side keys; the provider is checked when the config loads. -
Guardrail quality gate —
scripts/pgfuzz-gate.shruns pgfuzz against the built binary: recall of secrets, PII and prompt injection (≥ 99%) and, new, the false-positive rate on a negative corpus of benign look-alikes (100% must pass). CI runs it on every push once the pgfuzz deploy key is set. -
promptgate licensesandTHIRD_PARTY_NOTICES.md— licenses of all third-party modules and data in the binary, generated bytools/gennoticesand checked in CI; deb/rpm/apk packages install them under/usr/share/doc/promptgate.
Changed
Section titled “Changed”-
The secret scanner’s own rules ignore placeholders in docs and examples —
sk-xxxxxxxx…,ghp_YOUR_TOKEN_HERE…, long runs of one character — as the gitleaks rules already did. Found by the new negative corpus. -
The keyword index of the secret scanner is a byte-class DFA with premultiplied states: ≈ 10% faster.
-
Guardrails decode escaped JSON strings themselves instead of through
encoding/json: 200 KB of source code is scanned 20–40% faster by every guard (PII 1.2 → 0.7 ms).
- Translated answers escape U+2028 and U+2029 as
encoding/jsondoes, and write backspace and form feed as\b/\f; a round-trip test couldn’t tell the difference, a byte-for-byte comparison now does. THIRD_PARTY_NOTICES.mdcovers the modules of every release target (it missedmousetrap, linked into Windows builds only).- Guardrails read a message’s role even when
contentcomes beforerole(clients that sort keys), and a content block’s type even when it comes last; such messages andtool_resultblocks were treated as user content, sorolessettings didn’t apply to them. promptgate logs -fno longer exits with “context canceled” when stopped while it reads the log.
Known limitations
Section titled “Known limitations”pii_contextualis tested against an OpenAI-compatible mock, not yet against a live model; detection quality depends on the model chosen.- Prompt-injection detection matches known phrasings in English and
German; paraphrases and other languages can pass. Spelled-out e-mail
addresses (
ana at firma dot de) are not detected. - Images and scanned PDFs are not read (no OCR); files uploaded through a provider’s Files API reach PromptGate as ids only.
- Redaction restores exact tokens only; a model that rewrites one
(
EMAIL_001) leaves it as written.
Performance
Section titled “Performance”Every v0.2 feature plus every in-process guardrail on at once
(bench/results/2026-10-19-go-v0.3.0-release.md):
- Overhead at p50 for a short request: 0.16 ms buffered, 0.15 ms streamed (v0.2.0: 0.15 / 0.13 ms); ≈ 32,500 req/s with 16 clients.
- A 26 KB coding-agent request — tool result with source code and colour codes — 0.69 ms, of which the guardrails take ≈ 0.3 ms.
- Restoring redacted values in a stream: ≈ 0.01 ms per answer.
- Per 2 KB: keywords 4 µs, PII 3 µs, injection 6 µs, secrets 13 µs.
- 16.5 MB binary (6.6 MB gzip); with guardrails on, ready in ≈ 65 ms and ≈ 52 MB RAM at idle (without: 44 ms, 36 MB).