E-02 DLP Gateway
Brick E: Data, RAG, context, memory. French version: E-02-dlp-gateway
1. Role and responsibilities
Inspects and transforms flows (prompts, tool outputs, messages, documents): detect, mask, tokenize, block.
- Apply eai.dlp_rules
- Choose the mode by policy and destination
- Tokenize via E-03 in tokenize mode
2. Position in the architecture and interactions
- Callers: Model Gateway, Tool Gateway, Channel Gateway, A2A.
- Execution path: Synchronous, inline.
- Every interaction goes through the Control Plane API v1 (
/v1) behind the API Gateway (D-14).
3. Open source component and developed part
- Open source: Presidio (anonymizer)
- Developed: Gateway, rules, modes.
- External integration through an adapter
eai/integrations/<system>.pywith an in-process fallback when the URL is not configured.
4. Data model
Tables (schema eai, tenant_id RLS):
eai.dlp_rules
Common columns: id uuid, tenant_id uuid NOT NULL, created_at, updated_at; RLS policy current_setting('app.tenant_id', true)::uuid.
5. Contract
- Applied contract: policy-contract (obligations dlp)
- JSON Schema:
contracts/v1/policy-contract.schema.json - Key fields:
obligations[].type=dlp, mode - Validation:
POST /v1/contracts/{name}/validate; manifest apply:POST /v1/manifests/apply.
6. API endpoints
POST /v1/dlp/inspectPOST /v1/dlp/redactGET /v1/dlp/rulesPOST /v1/dlp/rules
Request POST /v1/dlp/redact:
{
"text": "Appelez-moi au 06 12 34 56 78",
"mode": "mask"
}
Response:
{
"text": "Appelez-moi au <PHONE_NUMBER>",
"findings": [
{
"type": "PHONE_NUMBER"
}
],
"action": "masked"
}
7. SDK examples
Python:
from enterprise_ai import EnterpriseAI
client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
out = client.dlp.redact(text="...", mode="mask")
TypeScript:
import { EnterpriseAI } from "@enterprise-ai/sdk";
const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
const out = await client.dlp.redact({ text: "...", mode: "mask" });
Java:
EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
JsonNode out = client.dlp().redact(Map.of("text", "Call me at +33 6 12 34 56 78", "mode", "mask"));
Go:
c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
out, _ := c.DLP.Redact(ctx, map[string]any{"text": "...", "mode": "mask"})
8. Configuration
- Environment variables:
EAI_DATABASE_URL - Helm values keys:
controlPlane.config,controlPlane.secrets
9. Security controls
- Block mode for secret toward external provider
- Rules editable by security_officer
- Every request carries the tenant resolved from the credential; PostgreSQL RLS
- Every mutation and policy decision writes a hash-chained audit event
10. Observability
- Prometheus metrics:
eai_dlp_findings_total{type,mode} - Traces: OpenTelemetry spans with GenAI semantic conventions (
gen_ai.operation.name,gen_ai.agent.id,gen_ai.tool.name), attributeseai.tenant_id,eai.run_id,traceparentpropagation. - Audit actions:
dlp.redact,dlp.inspect
11. FinOps units
- Inspected characters.
- Emitted as Usage Event (
POST /v1/finops/usage) with tenant, project, agent and run.
12. Failure modes and resilience
- Fail closed on restricted data
- Normalized errors (error envelope, message_i18n en/fr)
13. Standalone adoption (client of a client)
- enterprise_ai.dlp + Control Plane.
- SDK:
enterprise_ai.privacy / dlp / knowledge_bases / memory / retention / lineage - Minimal deployment: Helm chart with
controlPlane.enabled=trueand PostgreSQL; disabled external components use their in-process fallback.
14. Acceptance tests
- block mode -> 403 dlp_blocked
- mask replaces the entity
- Cross-tenant access refused
- Error returned in fr with Accept-Language: fr
Adapter files and streaming output DLP
- A file sent to a specialized adapter (for example
/v1/gateway/audio/transcriptions) goes through the F11 multimodal DLP before the call: text extracted by type (document, image OCR, audio transcript) and metadata (file name). Inblockmode the answer is 422dlp_blockedwithdirection=fileand the adapter is not called. - Adapter text responses (
text,transcript,ocr_textfields,text/*responses) go through the response DLP with the tenant mode. - When streaming, a sliding buffer is always active as soon as the DLP is not
off: the end of the text (EAI_STREAM_DLP_HOLDBACK_CHARS, 128 characters by default) is held back, and an entity found across the cut is kept whole for the next chunk. A value split between two chunks is therefore detected and masked.
Governed RAG (kit L4)
Presidio (presidio-analyzer and presidio-anonymizer, spaCy en_core_web_sm) is tested for real on fictitious banking examples (FR IBAN, Luhn card, French phone, email, name) in tests/test_data_presidio_real.py; the builtin recognizers stay the fallback.