Skip to main content

E-10 Memory Manager

Brick E: Data, RAG, context, memory. French version: E-10-memory-manager

1. Role and responsibilities​

Session and persistent memory (user, agent, project) with ACL, TTL, classification and erasure.

  • Write with DLP check and write policy
  • Search semantically (E-07)
  • Expire and erase (E-12)

2. Position in the architecture and interactions​

  • Callers: Agents, Context Manager, SDK.
  • Execution path: Synchronous.
  • 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: PostgreSQL + Qdrant
  • 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.memory_items

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: scope, kind, content, content_ref, embedding_ref, classification, acl, ttl_seconds, expires_at, write, deletion, version
  • Validation: POST /v1/contracts/{name}/validate; manifest apply: POST /v1/manifests/apply.

6. API endpoints​

  • POST /v1/memory
  • GET /v1/memory
  • GET /v1/memory/{id}
  • DELETE /v1/memory/{id}
  • POST /v1/memory/search

Request POST /v1/memory:

{
"scope": { "type": "user", "id": "usr_42" },
"kind": "preference",
"content": "Préfère le français",
"classification": "internal",
"ttl_seconds": 7776000
}

Response:

{
"memory_id": "mem_5",
"version": 1,
"expires_at": "2025-04-10T10:00:00Z"
}

7. SDK examples​

Python:

from enterprise_ai import EnterpriseAI

client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
m = client.memory.write(scope={"type": "user", "id": "usr_42"}, kind="preference", content="Préfère le français")
client.memory.delete(m["memory_id"])

TypeScript:

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

const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
const m = await client.memory.write({ scope: { type: "user", id: "usr_42" }, kind: "preference", content: "Prefers French" });

Java:

EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
JsonNode m = client.memory().write(Map.of("scope", Map.of("type", "user", "id", "usr_42"), "kind", "preference", "content", "Prefers French"));

Go:

c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
m, _ := c.Memory.Write(ctx, map[string]any{"scope": map[string]any{"type": "user", "id": "usr_42"}, "kind": "preference", "content": "Prefers French"})

8. Configuration​

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

9. Security controls​

  • No secret nor restricted data in persistent memory
  • OpenFGA ACL per item
  • 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_memory_items{scope}, eai_memory_writes_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: memory.create, memory.delete

11. FinOps units​

  • Stored items, embeddings, searches.
  • Emitted as Usage Event (POST /v1/finops/usage) with tenant, project, agent and run.

12. Failure modes and resilience​

  • Optimistic version (409 on conflict)
  • Normalized errors (error envelope, message_i18n en/fr)

13. Standalone adoption (client of a client)​

  • enterprise_ai.memory + 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. Expired item not returned
  2. Writing an IBAN blocked
  3. Cross-tenant access refused
  4. Error returned in fr with Accept-Language: fr