Chapter 1. Zero Data Retention & Privacy: eliminating leaks and PII/GDPR exposure | Grigoriy Dobryakov

Grigoriy Dobryakov

Course · Enterprise AI Governance Architecture

Chapter 1AI Governance course

Chapter 1. Zero Data Retention & Privacy: eliminating leaks and PII/GDPR exposure

A Kovcheg employee pastes a customer's statement into the assistant so it can draft a reply to a complaint. The statement contains a name, passport number, IBAN, address, transaction amounts. The assistant calls a cloud model. From this point, the bank customer's PII has physically left the perimeter and now sits in the provider's infrastructure — at minimum in active processing, and by default in abuse-monitoring logs for 30 days. The customer doesn't know this and never consented to such a transfer.

This isn't a hypothetical risk — it's the single most common way companies violate GDPR through AI: not through malice, but because nothing stood in the request path to strip the data before the model call. This chapter covers the first control plane: the data plane, the layer that guarantees the company's confidential data and users' PII don't leak, don't end up in a provider's logs, and don't feed into training of public models.

The customer's business goal

For Kovcheg, the cost of a leak isn't an abstract fine — it's a combination: GDPR sanctions + banking-secrecy violation + loss of regulatory trust. The plane's job: the model never sees real PII, and the company can prove it. Three promises to the business:

  1. PII and banking secrets never leave the perimeter in plaintext.
  2. The provider does not store prompts and does not train on them (Zero Data Retention).
  3. A customer's right to erasure (GDPR Art. 17) isn't broken by data having leaked into someone else's training and becoming irretrievable.

Driver: threat or regulator

Architectural pattern

In-Flight Anonymization Gateway + ZDR — a layer in front of the LLM call that de-identifies data on the way in and restores it on the way out, plus a contractual Zero Data Retention agreement as a second line of defense. The model works with placeholders; real values live inside the perimeter for a fraction of a second.

              ┌────────── Anonymization Gateway ──────────┐
 "Ivanov I.I.,│  detect (NER+regex) → mask → <PERSON_1>    │
  IBAN RS35…" │        │                                    │  masked prompt
 ────────────►│        ▼                                    │──────────────► LLM (ZDR)
              │  mapping → Redis (TTL = request lifetime)    │◄──────────────
              │        ▲                                    │  masked answer
 "Dear        │  unmask ◄── mapping                         │
  Ivanov I.I."│                                             │
 ◄────────────└─────────────────────────────────────────────┘

Engineering stack & providers

Engineering implementation

### Step 1. Gateway as the only door to the model

Direct LLM calls from services are forbidden by network policy — everything routes through the gateway. Otherwise any developer who calls the API directly bypasses the whole plane.

### Step 2. Detection and reversible masking

NER + regex find entities; each is replaced with a typed placeholder, and the reverse mapping is stored in Redis under the trace_id key (the same id used in the audit trail — ch. 4):

results = analyzer.analyze(text=prompt, language="en")   # Presidio NER
masked, mapping = reversible_mask(prompt, results)        # <PERSON_1>, <IBAN_1>...
redis.setex(f"pii:{trace_id}", TTL_SECONDS, json.dumps(mapping))

resp = llm.call(masked, extra_headers={"x-zdr": "true"})
answer = unmask(resp, json.loads(redis.get(f"pii:{trace_id}")))

### Step 3. Fail-closed

If the detector is unavailable or confidence is below threshold, the request is blocked, not passed through as-is. Privacy is a property that fails silently; so the default is to refuse, not to pass through.

### Step 4. ZDR as the second line of defense

Masking is never complete (see below), so ZDR is mandatory regardless: even if something leaked through, the provider contractually does not store it and does not train on it. Two lines of defense, not one.

Where it breaks

Standards and mapping

Lab and artifact

Deploy LiteLLM + Presidio in front of Kovcheg; build a golden dataset of synthetic customer PII (varied formats, transliterations, quasi-identifiers); measure the detector's precision/recall by type, and latency; enable fail-closed; sign/document ZDR in the DPA. Artifact: gateway config + a recall report on the golden dataset + a map of the mapping store with its encryption mode and TTL (evidence for ch. 6).

Maturity checklist

Sources

In practice

How it actually works — engineering breakdowns

Standalone howto from practice, showing this control plane on real code and a working artifact.

Read next

Putting AI into production under regulatory risk?

Designing the control plane for your system: privacy, access, guardrails, audit, EU AI Act / ISO 42001 compliance — as working architecture, not a policy PDF.

Email me

The transition engine

Next Move Engine — the system that takes a team to an autonomous delivery loop.

Next Move Engine →