Stage 6 · Zero-Data-Retention (ZDR) Gateway & Reversible PII/PHI Redaction Proxy Pattern
Enterprise privacy egress gateway combining hybrid NER/regex PII/PHI detection with ephemeral request-scoped vault tokenization, ZDR-enforced LLM provider endpoints, and streaming placeholder re-hydration inside the customer trust boundary.
Best For
Regulated healthcare, fintech, and legal apps calling external LLM APIs under HIPAA/GDPR/PCI mandates where raw PII/PHI must never leave the private VPC.
Human-AI Boundary
Secrets and payment PANs trigger hard irreversible blocking; only workflow-essential identifiers use short-TTL encrypted in-memory vault mappings for re-hydration.
Anti-Patterns to Avoid
- Applying irreversible `[REDACTED]` masking to all entities when downstream SQL/API tools or user summaries still require accurate entity linkage
- Writing unmasked prompts or raw JWT/API keys into observability traces (LangSmith/OTel/Datadog) while only scrubbing the LLM payload
Latency/Cost Profile & Eval Metrics
Presidio ONNX/SpaCy + regex pipeline 18-35ms p95; streaming Trie re-hydration < 2ms · Dedicated CPU/ONNX redaction sidecar + short-TTL encrypted Redis mapping vault (no raw PII stored on disk)
- PII/PHI Recall & Residual Leakage Rate: >= 99.5% recall on SSN/CC/MRN/API secrets; 0 unmasked secret egress in adversarial red-team runs (Benchmark with synthetic multi-lingual medical/financial adversarial corpus including typos and JSON payloads)
- Over-Redaction Utility Loss: <= 3% task accuracy degradation vs unredacted baseline via type-preserving pseudonyms (Replace `<PERSON_1>` consistently across conversation turns so model reasoning over entity relationships stays intact)
💰 Business ROI Model & Evidence Level
production_practice🏗️ End-to-End Architecture Pipeline
Run regex + ONNX NER over prompts and retrieved chunks, replacing entities with consistent typed tokens stored in an encrypted short-TTL Redis vault.
Route solely to ZDR-contracted endpoints (disabling vendor debug logging) and scrub telemetry spans before persistence.
Verify caller RBAC scope and re-hydrate typed tokens inline via sliding-prefix SSE buffering without breaking streaming smoothness.
🚨 Production Failure Modes & Signatures
- Cross-turn entity inconsistency (`John` mapped to `<PERSON_1>` in turn 1 and `<PERSON_4>` in turn 2) breaking multi-turn coreference
- Prompt injection tricking the LLM into transforming `<PII_1>` (e.g. base64 or spacing) so re-hydration fails or leaks mapping behavior
🎤 Interview Defense & System Design Deep-Dive Q&A
- How do you handle SSE token splitting when re-hydrating `<PERSON_1>` placeholders in real time without adding noticeable streaming jitter?
- Why is turning off vendor training via ZDR insufficient without an in-VPC redaction gateway and telemetry log scrubber?
Bidirectional Taxonomy Links
Internal Tools & Primary Sources
- Microsoft Presidio — Context-Aware PII Detection & Anonymization Engine (official_docs, 2026-11-30)
- OpenAI Enterprise Privacy & Zero Data Retention (ZDR) API Controls (official_docs, 2026-11-30)