Skip to main content

E-12 Data Retention

Brick E: Data, RAG, context, memory. French version: E-12-data-retention

1. Role and responsibilities​

Enforces TTL, archiving and erasure (right to be forgotten), with legal hold taking precedence.

  • Policies by resource type and classification
  • Scheduled execution
  • Subject erasure across PostgreSQL, Qdrant, S3

2. Position in the architecture and interactions​

  • Callers: Scheduler (C-09), DPO via portal.
  • Execution path: Durable workflow (batch).
  • 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: none (to develop)
  • Developed: Fully developed.
  • External integration through an adapter eai/integrations/<system>.py with an in-process fallback when the URL is not configured.

4. Data model​

Tables (schema eai, tenant_id RLS):

  • eai.retention_policies

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: memory-contract
  • JSON Schema: contracts/v1/memory-contract.schema.json
  • Key fields: ttl_seconds, expires_at, deletion
  • Validation: POST /v1/contracts/{name}/validate; manifest apply: POST /v1/manifests/apply.

6. API endpoints​

  • GET /v1/retention/policies
  • POST /v1/retention/policies
  • POST /v1/retention/run
  • POST /v1/retention/erase
  • POST /v1/retention/legal-hold

Request POST /v1/retention/erase:

{
"subject": {
"type": "user",
"id": "usr_42"
},
"scope": [
"sessions",
"memory",
"documents"
]
}

Response:

{
"erasure_id": "era_8",
"status": "running",
"legal_hold_blocked": []
}

7. SDK examples​

Python:

from enterprise_ai import EnterpriseAI

client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
client.privacy.erase_subject(subject_id="usr_42")

TypeScript:

import { EnterpriseAI } from "@enterprise-ai/sdk";

const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
await client.retention.erase({ subject_id: "usr_42", reason: "gdpr_request" });

Java:

EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
client.retention().erase(Map.of("subject_id", "usr_42", "reason", "gdpr_request"));

Go:

c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
c.Retention.Erase(ctx, map[string]any{"subject_id": "usr_42", "reason": "GDPR erasure request"})

8. Configuration​

  • Environment variables: EAI_DATABASE_URL
  • Helm values keys: controlPlane.config, controlPlane.secrets

9. Security controls​

  • Erasure and legal hold restricted to security_officer / tenant_admin
  • Erasure evidence in the audit
  • 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_retention_deleted_total{resource}, eai_retention_archived_total
  • Traces: OpenTelemetry spans with GenAI semantic conventions (gen_ai.operation.name, gen_ai.agent.id, gen_ai.tool.name), attributes eai.tenant_id, eai.run_id, traceparent propagation.
  • Audit actions: retention.run, retention.erase, retention.legal_hold

11. FinOps units​

  • Storage reduction.
  • Emitted as Usage Event (POST /v1/finops/usage) with tenant, project, agent and run.

12. Failure modes and resilience​

  • Erasure resumable step by step
  • Normalized errors (error envelope, message_i18n en/fr)

13. Standalone adoption (client of a client)​

  • enterprise_ai.privacy + Control Plane.
  • SDK: enterprise_ai.privacy / dlp / knowledge_bases / memory / retention / lineage
  • Minimal deployment: Helm chart with controlPlane.enabled=true and PostgreSQL; disabled external components use their in-process fallback.

14. Acceptance tests​

  1. Legal hold prevents erasure
  2. Expired item removed by run
  3. Cross-tenant access refused
  4. Error returned in fr with Accept-Language: fr