A Technical Whitepaper on Multi-Scope Memory Systems,
Hybrid Authorization, and Corporate AI Deployments
Part I — Foundation
Large language models are stateless. Each inference call begins with a blank slate, bounded by a finite context window. This creates a fundamental disconnect between the growing ambitions of AI agents—which must sustain coherent behavior over hours, days, and weeks of interaction—and their inability to remember, learn, or adapt from past experience.
In enterprise settings, the consequences are severe:
Today, every team building a production AI agent assembles the same ad-hoc architecture: a vector database for embeddings, Redis for session state, PostgreSQL for user profiles, and custom glue code to stitch them together. This patchwork—replicated across thousands of organizations—fails at precisely the capabilities agents need most:
The industry has begun to converge on a solution: a shared layer of memory and governance that sits beneath all of a company's AI agents, so that what one agent learns is available to every other one instead of disappearing when the session ends. This "enterprise AI brain" is not a better model—it is a brain.
However, this rapid evolution outpaces governance, raising critical concerns about data ownership, security risks such as context poisoning, and the ethical implications of employee data. Experts urge companies to audit AI memory, assign context-layer ownership, and establish clear policies.
A shared cognitive memory layer must support multiple memory types, each with distinct purposes, access patterns, and lifecycles.
| Memory Type | Description | Retention | Scope |
|---|---|---|---|
| Working Memory | The agent's current context window; immediate task state | Session-bound | Agent + User |
| Episodic Memory | Interaction history; specific events and their context | Medium-term | User / Team |
| Semantic Memory | Learned facts, relationships, and entity knowledge | Long-term | Team / Org |
| Procedural Memory | Learned workflows, patterns, and operational knowledge | Long-term | Team / Org |
| Personalized Memory | Stable preferences, habits, and constraints about users or teams | Long-term | User |
Personalized memory tracks stable information about particular users, teams, or environments: preferences, habits, recurring constraints, and prior interactions. This state must not be collapsed into the agent's general self-improvement store, because user-specific traces obey different retention, retrieval, and privacy rules.
Current memory systems can be read as four broad architectural paradigms, progressing from simple to sophisticated:
The enterprise architecture proposed in this paper operates at the Hierarchical Memory and Orchestration level, with provisions for adaptive optimization.
The core innovation of this architecture is its explicit, multi-dimensional scoping model. Every memory record is scoped along multiple axes, ensuring that information flows correctly between different organizational levels while maintaining strict boundaries.
Personal memory belongs exclusively to a single user-agent pairing. It functions as a private workspace containing communication preferences and working style, personal priorities and follow-ups, individual constraints and recurring preferences, and private notes and decision context. These memories are invisible to other users' agents and are subject to the strictest retention and privacy rules.
Team memory is shared across a defined group—a project team, department, or functional unit. It contains business facts and domain knowledge relevant to the team, shared workflows and operational procedures, team-specific conventions and standards, and collective decisions and their rationale. Team memory is the primary mechanism for organizational learning at the group level. Teams follow the organization's role and reporting hierarchy (a team can contain sub-teams); projects (3.1.5) cut across teams.
Agent memory allows individual AI agents to build self-knowledge across sessions. This includes what approaches worked and which failed, which tools were most effective for specific task types, strategies that produced the best outcomes, and agent-specific performance patterns. Agent-scoped memory enables agents to improve their own performance over time without requiring human intervention or explicit retraining. Two kinds of agent are covered: agents a person is using, which act with that person's rights, and independent AI bots with their own work identities (for example a Jira account), which take assigned jobs like a team member and always have a named human sponsor.
Organizational memory represents the highest level of collective knowledge. It contains company-wide policies and procedures, strategic context and business objectives, cross-team patterns and best practices, and institutional knowledge derived from aggregated experience. Organizational memory is the foundation of the "enterprise brain" concept—a layer that allows all AI agents to learn collectively.
Project memory holds requirements, decisions, timelines and deliverables for one initiative. Its members come from many teams, and one or more project leads decide what enters it. Project members read it; project leads write it.
User memory holds one person's profile, preferences and history across every AI tool they use, so each of their agents respects the same preferences. It is separate from Personal memory: User memory is shared with the person's delegated agents and can contribute to promotion by rule, while Personal memory stays private.
Client memory holds facts about one client the organization works for: contacts, agreements, preferences and history across that client's projects. Only the people assigned to the client and the members of its linked projects can read it, and it is walled off from every other client. It is restricted by default, can be deleted in one step when the work for that client ends, and client-specific details are removed before any lesson moves beyond it.
Above the organization sits the Account: the customer of the memory platform. One account can own and manage several organizations; its administrators can set account-wide guidance and settings, and see every scope in their organizations except Personal memory, which requires a logged emergency access with a stated reason and notice to the person.
The critical mechanism connecting these scopes is the promotion pipeline—the process by which memories move from lower scopes to higher scopes:
User / Agent → Team → Project → Organizational
Personal memory is never promoted.
Promotion criteria include:
When a memory is promoted, it is anonymized to remove user-specific identifying information while preserving the operational insight. For example, "User A prefers tabs over spaces" might be promoted to "The team's codebase convention uses tabs for indentation."
Promotion from User or Agent to Team can happen automatically when at least three independent sources agree, confidence is high and no personal data is found. Promotion to Project or Organizational memory always needs approval by the project lead or organizational governance.
In multi-tenant environments, every memory record must carry a tenant boundary so that one account's agents, users, facts, and deletion requests never affect another account. In this architecture the tenant is the Account, which can own several organizations. Tenant isolation should be enforced by the database layer, not just application code.
The architecture enforces this through:
tenant_id column protected by database-level row-level security. Queries cannot accidentally leak across tenants.account_id (the tenant column), with RLS enabled and forced, and the memory worker runs under its own database role. The search index (Hindsight) keeps one bank per account, with separate banks for Personal and Client memory. Hash partitioning and per-partition HNSW indexes are not used in Phase 1; they remain a Phase 2 scaling option.
Within a single tenant (organization), memory scopes form a hierarchy:
| Scope Level | Access Boundary | Example |
|---|---|---|
| User | Single user only | Personal preferences |
| Agent | Single agent instance | Learned patterns |
| Team | Defined group | Team conventions |
| Project | Project members from many teams | Requirements and decisions |
| Organization | All users | Company policies |
| Client | People assigned to one client and its linked projects | Client-specific facts, walled off from other clients |
| Account | Account administrators across the account's organizations | Account-wide guidance and settings |
Each memory record carries metadata identifying its scope, and retrieval queries automatically filter based on the requesting user's authenticated scope permissions.
A conventional enterprise AI platform may promise that client data is isolated, but the technical architecture may still rely on ordinary database separation, access-control lists, tenant labels, or post-hoc audit logs. These mechanisms do not necessarily prevent a downstream AI workflow from reusing data across entities.
This architecture prevents cross-entity reuse through:
Part II — Authorization and Access Control
| Layer | Responsibility | Typical Questions |
|---|---|---|
| RBAC | Coarse-grained, system-level governance | Is this user an admin? Can this service account call the memory API? Can this role manage tenants? |
| ReBAC | Fine-grained, relationship-based access to shared or nested content | Is this user a member of the team that owns this memory? Is this agent delegated by the user? Is this memory shared with the project group? |
| ABAC | Dynamic, context-dependent rules and caveats | Is the request within allowed hours? Does the data residency match? Is the sensitivity label compatible with the purpose? |
A request passes through three gates in order:
Only if all three pass is the request allowed. This is a deny-by-default pipeline.
User-generated content platforms with multi-scope memory combine three properties that no single model handles well:
The hybrid model is not a preference—it is a necessity. Each layer covers the blind spots of the others:
| Requirement | RBAC | ReBAC | ABAC |
|---|---|---|---|
| Tenant admin can manage all teams | ✔ | — | — |
| User can read team memory they belong to | — | ✔ | — |
| Agent can read memory delegated by its owner | — | ✔ | — |
Memory with sensitivity=restricted requires purpose=support | — | — | ✔ |
| Cross-region access blocked by data residency | — | — | ✔ |
| Only auditors can export memory | ✔ | — | — |
| Promotion from personal to team scope requires ownership | — | ✔ | — |
| Layer | Code Location | Responsibility |
|---|---|---|
| Authentication | API gateway / auth middleware | Resolve user identity, tenant ID, agent ID, session context |
| RBAC | Auth service or dedicated RBAC module | Load roles, resolve coarse permissions |
| ReBAC | Relationship service / graph store | Store and query relationship tuples |
| ABAC | Policy engine or policy module | Evaluate dynamic context rules |
| Enforcement | Memory service + middleware | Combine decisions, enforce at read/write boundaries |
| Audit | Cross-cutting logging service | Record every decision with reason and policy version |
The memory object table should include scope and ownership metadata. The following sketch is consistent with the schema in Part I and adds authorization-relevant fields:
memory_objects (
id UUID,
tenant_id UUID,
scope_type ENUM('personal','user','agent','team','project','client','org','account'),
scope_id UUID,
owner_id UUID,
sensitivity_label TEXT,
policy_tags JSONB,
content TEXT,
created_at TIMESTAMP,
updated_at TIMESTAMP
)
A relationship table supports the ReBAC layer:
relationships (
id UUID,
tenant_id UUID,
subject_type ENUM('user','agent','bot','team','org'),
subject_id UUID,
relation TEXT, -- e.g. 'member_of', 'owner_of', 'delegated_to'
object_type ENUM('team','project','client','memory','agent','org','account'),
object_id UUID,
created_at TIMESTAMP
)
RBAC tables support coarse governance:
roles (id, tenant_id, name)
permissions (id, name, resource_type, action)
role_permissions (role_id, permission_id)
user_roles (user_id, role_id, tenant_id)
user_id, tenant_id, agent_id if present.can(user, 'memory:read', 'team_memory').has_relation(user, 'member_of', team_id).sensitivity == 'internal' AND purpose == 'support' AND time within business_hours.scope_type, scope_id, owner_id, sensitivity_label, policy_tags to memory records.relationships table or graph store.AuthzContext into every request.POST /authorize internal endpoint or SDK for the memory service to call.authz_decision_id, policy_version.The authorization model touches four categories of entities. Each is summarized below with its role in the hybrid pipeline.
| Entity Category | Examples | Used By |
|---|---|---|
| Subject | User, Agent, Service Account | RBAC, ReBAC, ABAC |
| Resource | Memory, Team, Organization | RBAC, ReBAC, ABAC |
| Relationship | membership, ownership, delegation, parent-child | ReBAC |
| Context | time, IP, purpose, data residency, device | ABAC |
Subjects may be human users or autonomous agents. Both must be first-class principals with stable identifiers. Agents should carry a delegation relationship to their owning user or team, which the ReBAC layer uses to resolve access.
Every principal has a type: human, delegated_agent (acts for a person, never with more rights than that person), bot (independent, with its own identity and a human sponsor) or service. Each request also carries a caller context: the verified identity, type, the person being acted for and the client application, plus declared values such as the model name, current project, purpose and token budget. Only verified values decide access; declared values can narrow access and shape the response, and all of them are recorded in the audit trail.
Memories are the primary protected resource. Teams and organizations are also resources for membership and administrative actions. Each memory carries its scope metadata, which determines which relationship and policy checks apply.
Relationships form a directed graph. The most important relations for the multi-scope memory architecture are:
member_of — user or agent to teamowner_of — user or agent to memorydelegated_by — agent to userparent_of — team to sub-teamauditor_of — user to tenantThe context object is assembled per request and passed to the ABAC evaluator. It should include only the attributes needed for policy evaluation, and it should be treated as untrusted input unless cryptographically attested.
1. Request arrives at API gateway.
2. Authentication middleware validates token/session.
3. Authz middleware builds AuthzContext:
- subject: user_id, agent_id, roles
- resource: memory_id, scope_type, scope_id, owner_id
- action: read | write | delete | share | promote
- environment: time, IP, purpose, device, data_residency
4. RBAC gate: coarse permission check.
5. ReBAC gate: relationship path check.
6. ABAC gate: policy evaluation.
7. Decision: allow or deny.
8. If allow, memory service executes.
9. Audit log records decision, reason, policy version, relation path.
def authorize(ctx: AuthzContext) -> Decision:
# 1. RBAC
if not rbac.check(ctx.subject, ctx.action, ctx.resource_type):
return Deny("RBAC: missing coarse permission")
# 2. ReBAC
relation_path = rebac.find_path(
subject=ctx.subject,
relation=ctx.required_relation,
object=ctx.resource_scope
)
if not relation_path:
return Deny("ReBAC: no relationship to resource")
# 3. ABAC
abac_decision = abac.evaluate(
subject=ctx.subject,
resource=ctx.resource,
action=ctx.action,
environment=ctx.environment,
relation_path=relation_path
)
if not abac_decision.allowed:
return Deny(f"ABAC: {abac_decision.reason}")
return Allow(relation_path=relation_path, policy_version=abac_decision.version)
Client → Gateway: request(memory_id, action)
Gateway → AuthN: validate(token)
AuthN → Gateway: subject, tenant, agent
Gateway → AuthZ: build AuthzContext
AuthZ → RBAC: check(subject, action, resource_type)
RBAC → AuthZ: allow/deny
AuthZ → ReBAC: find_path(subject, relation, scope)
ReBAC → AuthZ: path or empty
AuthZ → ABAC: evaluate(context, path)
ABAC → AuthZ: allow/deny + version
AuthZ → Gateway: final decision
Gateway → MemoryService: execute (if allow)
MemoryService → Audit: log decision
MemoryService → Gateway: result
Gateway → Client: response
team_id checks.Part III — Operations and Governance
Memory governance ensures that shared memory remains subject to organizational policies throughout its lifecycle. This includes:
For regulated industries, the ability to reconstruct what an agent knew at any point in time is essential. The architecture provides:
The architecture is designed to address major regulatory frameworks:
Memory poisoning attacks represent a distinct threat category (OWASP ASI06). These attacks attempt to inject false or misleading memories that degrade agent performance or cause harmful actions. The architecture defends against this through:
Effective memory retrieval requires more than simple semantic similarity. The architecture employs multi-channel retrieval, combining:
Candidates from each channel are fused using reciprocal rank fusion, producing a ranked list that balances precision and recall.
When an agent needs to generate a response, the system assembles a context package containing:
The assembly process is token-aware, ensuring the context package fits within the model's context window while maximizing relevance.
Memory enters the system through explicit saves by people or their AI, end-of-session summaries the person confirms, optional client hooks, and connectors that import existing knowledge (for example Jira) to seed project and organizational memory. Nothing from a person's conversations reaches a shared scope without an approval step.
memory_get_context, memory_search, memory_save, memory_request_change and resource_lookup) paired with REST endpoints, and connectors for Jira, read-only PostgreSQL views and IMAP mailboxes. Imports are staged and approved by the project or client lead before they become memory. Secrets for connectors are held in OpenBao.
In multi-agent systems, different agents may have different access permissions and responsibilities. The retrieval layer implements role-aware routing, ensuring that:
This prevents agents from accessing memories outside their authorized scope, even when operating within the same tenant.
Every memory also carries an audience label: internal, restricted or external_ok. An agent or bot replying to someone outside the organization receives only external_ok memories. Memory derived by promotion or synthesis takes the strictest label of its sources. All models receive the same facts; only the size and format of the response is adapted to each model and application.
The architecture supports multiple storage backends to accommodate different deployment scenarios:
The storage layer abstracts these backends behind a unified interface, allowing organizations to start with SQLite and migrate to PostgreSQL as their needs grow.
The choice of embedding model significantly impacts retrieval quality. The architecture supports:
nomic-embed-text, bge-m3) for air-gapped or privacy-sensitive deployments.Embedding model selection is configurable per tenant, allowing organizations to optimize for their specific vocabulary and use cases.
Enterprise deployments demand predictable latency. The architecture targets:
| Operation | Target Latency (p95) |
|---|---|
| Memory write (governed) | < 10 ms |
| Memory retrieval (hybrid) | < 100 ms |
| Context assembly | < 150 ms |
| Full query cycle | < 300 ms |
These targets are achievable through in-memory caching, efficient indexing, and parallel retrieval across channels.
The architecture supports multiple deployment topologies:
An internal worker, separate from the models people chat with, turns what people and AIs write into clean shared memory: it extracts short facts, keeps one neutral writing style whichever model sent the input, detects duplicates and contradictions, anonymizes content for promotion, drafts syntheses and flags suspicious text. It runs in the background and is never in the request path, so the system still works in a reduced form without it. It uses one model-agnostic interface: a small local model to start, with a cloud model or GPU as later options.
The ultimate value of a shared memory layer is the compounding of organizational knowledge. When agents and users contribute memories, and those memories are promoted and refined, the entire organization becomes smarter over time. This creates a positive feedback loop:
This architecture can be understood as a memory operating system for AI agents—a unified context layer that replaces the fragile patchwork of vector databases, session stores, and custom glue code. Like an operating system manages hardware resources, this layer manages memory resources:
The fundamental shift enabled by shared memory is the transformation of AI from tool to teammate. Tools are stateless—they perform a function and return a result. Teammates learn, adapt, and build shared understanding over time. This transformation has profound implications for how organizations deploy and manage AI:
The enterprise AI landscape is at an inflection point. Organizations have deployed AI agents across business functions, but the majority of these deployments are not delivering expected ROI—not because the models are inadequate, but because the infrastructure lacks persistent, shared memory.
This paper has presented a comprehensive architecture for a shared cognitive memory layer that addresses this gap. The architecture provides:
The transition from stateless tools to stateful teammates is not merely a technical upgrade—it is an architectural shift that redefines how organizations deploy, manage, and derive value from AI. The organizations that build this shared memory layer today will be the ones that unlock the full potential of their AI investments tomorrow.
MemoryObject {
id: UUID
tenant_id: UUID (RLS-enforced)
scope: ENUM(personal, user, agent, team, project, client, org, account)
scope_id: UUID (user_id, agent_id, team_id, etc.)
memory_type: ENUM(episodic, semantic, procedural, working)
content: TEXT (encrypted at rest)
embedding: VECTOR(1536)
confidence: FLOAT [0.0, 1.0]
importance: FLOAT [0.0, 1.0]
occurrence_count: INTEGER
source_lineage: JSONB (provenance chain)
policy_composition: JSONB
sensitivity_label: TEXT
policy_tags: JSONB
created_at: TIMESTAMP
updated_at: TIMESTAMP
expires_at: TIMESTAMP (TTL)
superseded_by: UUID (nullable)
is_current: BOOLEAN
version: INTEGER
}
memories table (tenant column account_id) with versions in memory_versions and lineage in memory_links (derived from, promoted from, contradicts, supersedes). It adds audience label, must-apply flag and validity dates. Embeddings are held by Hindsight, not in this row, and the 1536-dimension vector is not used. Content is not encrypted per tenant in Phase 1; that is a Phase 2 item.
| Subject | Relation | Object |
|---|---|---|
user:alice | member_of | team:engineering |
user:alice | owner_of | memory:123 |
agent:code-helper | delegated_by | user:alice |
team:engineering | parent_of | team:backend |
user:bob | auditor_of | tenant:acme |
| Term | Definition |
|---|---|
| KV Cache | Key-Value cache; the physical memory used during LLM inference. |
| RLS | Row-Level Security; database-level access control. |
| TTL | Time-to-Live; automatic expiration of records. |
| HNSW | Hierarchical Navigable Small World; a vector index algorithm. |
| p95 | 95th percentile latency. |
| RBAC | Role-Based Access Control. |
| ReBAC | Relationship-Based Access Control. |
| ABAC | Attribute-Based Access Control. |
| RLHF | Reinforcement Learning from Human Feedback. |
| SFT | Supervised Fine-Tuning. |
| MoE | Mixture of Experts. |
| UGC | User-Generated Content. |
| Account | The customer of the memory platform; the tenant, which can own several organizations. |
| Client | A company or person an organization works for; its memory is walled off from other clients. |
| cMCP | The reference implementation of this architecture (Appendix D). |
| Hindsight | The open-source memory engine used as the search index in the reference implementation. |
cMCP is the reference implementation of this architecture. Phase 1 (stages 1a to 1f: core memory, projects and sync, grants and bots, account and client levels with promotion, web UI and admin console, integration hub; then, in stages 1g to 1t, automatic capture from AI apps, a space registry, collective and organizational memory, space knowledge, device keys, a bot library, digital workers and guarded risk switches) is built and tested on a pilot server, with relaxed security, and moves to IT-Labs hardware next. Phase 2 (security hardening, compliance, multi-tenant product) is planned and is described in this paper as future development.
| Component | Version | Role | Licence |
|---|---|---|---|
| PostgreSQL | 18 | Governed record, row-level security, job queue | PostgreSQL Licence |
| pgvector | current release for PostgreSQL 18 | Vector storage used by the search index | PostgreSQL Licence |
| Hindsight | 0.10.2 | Memory search index (chunks mode) | MIT |
| Ollama | 0.35.0 | Serves the local CPU model for fact extraction | MIT |
| Qwen3 4B Instruct | 2507 | Default extraction model | Apache-2.0 |
| Memory worker (own code) | Phase 1 | Extraction, indexing, promotion, synthesis, housekeeping jobs | Own code |
| FastAPI and MCP Python SDK | 0.142 and 2.2 (Python 3.12) | REST service and MCP server (streamable HTTP, OAuth) | MIT |
| Keycloak | 26 | Identity: logins, bot identities, tokens | Apache-2.0 |
| Next.js | 16 | Web UI and admin console | MIT |
| Valkey | 8 | Cache, rate limits, sessions | BSD-3-Clause |
| OpenBao | 2.5 | Connector secrets (Transit encryption) | MPL-2.0 |
| Caddy | 2.11 | Router behind Apache (host-based routing, rate limits) | Apache-2.0 |
| Apache HTTP Server | existing host | Public entry on port 443 with TLS | Apache-2.0 |
Planned for Phase 2 (not built): ABAC context rules with a policy engine such as Cedar or OPA, a dedicated relationship store such as SpiceDB or OpenFGA if relationship queries become a bottleneck, hash-chained audit, PII detection (Presidio), per-tenant encryption keys, SCIM, a cloud model or GPU for extraction, multi-tenant hosting, Helm and an air-gapped bundle, and the compliance and penetration-test work.