跳转到主要内容
页面

Architecture

Standalone memory service for AI tools, with durable memory, evidence, team isolation, and MCP access.

Architecture

Dense-Mem separates memory from the AI assistant.

The assistant still talks to the user and decides how to respond. Dense-Mem owns the memory database, evidence, embeddings, claims, facts, teams, profiles, and API keys.

System Map

flowchart TB
  subgraph Hosts["AI tools"]
    Claude["Claude Code"]
    Codex["Codex"]
    Other["Other MCP clients"]
  end

  subgraph DenseMem["Dense-Mem"]
    MCP["/mcp Streamable HTTP"]
    REST["REST API"]
    UserPortal["User portal /ui"]
    Portal["Control portal"]
    Metrics["Metrics endpoint /metrics"]
    Registry["Tool registry"]
    Memory["Memory orchestration"]
    Recall["Recall service"]
    Communities["Community detection"]
    Dreaming["Dreaming cycles"]
    Embeds["Embedding provider client"]
  end

  subgraph Storage["Storage"]
    Postgres["Postgres teams, profiles, audit, app config, operation logs"]
    Neo4j["Neo4j graph and vector indexes"]
    Redis["Redis optional shared limits"]
    Prometheus["Prometheus optional telemetry"]
  end

  Hosts --> MCP
  MCP --> Registry
  REST --> Registry
  UserPortal --> REST
  Portal --> REST
  Registry --> Memory
  Registry --> Recall
  Registry --> Communities
  Registry --> Dreaming
  Memory --> Embeds
  Recall --> Embeds
  Memory --> Neo4j
  Recall --> Neo4j
  Communities --> Neo4j
  Dreaming --> Neo4j
  REST --> Postgres
  REST --> Redis
  Metrics --> Prometheus
  REST --> Prometheus
  Portal --> Prometheus

Responsibility Boundary

AreaDense-Mem ownsAI assistant owns
Memory writesEvidence, typed claims, verification, gates, promotionDeciding what candidate memories to send
EmbeddingsFragment embeddings and recall-query embeddingsNo vectors for normal use
RetrievalFacts, claims, fragments, and clarificationsChoosing how to use recalled context
CorrectionsConflict detection and supersession recordsAsking the user which memory is correct
HypothesesCommunity summaries and dream recordsDeciding which hypotheses to ask the user to confirm
OperationsTeams, profiles, API keys, audit metadata, user portal, control portalClient-side MCP configuration

Dense-Mem is intentionally narrow. It does not replace the assistant. It gives the assistant a reliable memory service.

Memory Model

Dense-Mem uses three layers:

LayerPlain meaningWhy it exists
SourceFragmentOriginal evidence textPreserves where a memory came from.
ClaimA typed candidate assertionLets Dense-Mem check and gate possible memories.
FactA promoted active memoryGives assistants stable memory to recall.

The flow looks like this:

flowchart LR
  Fragment["SourceFragment evidence"] --> Claim["Claim candidate"]
  Claim --> Verify["Verify claim"]
  Verify --> Validated["Validated claim"]
  Validated --> Promote["Promote claim"]
  Promote --> Fact["Active fact"]
  Fact --> Supersede["Supersede after correction"]

Facts are not overwritten in place. Corrections create new facts and mark older comparable facts as superseded. That preserves history.

Conflict Handling

When a new memory conflicts with an active fact, Dense-Mem should return a clarification instead of guessing.

sequenceDiagram
  participant Assistant
  participant DM as Dense-Mem
  participant User

  Assistant->>DM: remember(candidate memory)
  DM->>DM: verify, gate, compare active facts
  DM-->>Assistant: clarification needed
  Assistant->>User: Which memory should I keep?
  User-->>Assistant: Keep the new one
  Assistant->>DM: confirm_memory(accept_claim)
  DM-->>Assistant: promoted and superseded result

This is important because memory systems should not silently decide what the user meant.

Team And Profile Isolation

Every memory operation is scoped to the authenticated API key.

An API key belongs to:

  • one team
  • one named profile
  • one profile role, either manager or member
  • one scope set, either read-only or read-write

Clients do not need to send a team ID for normal memory routes. Dense-Mem derives the team and profile from the bearer key.

Roles and scopes are separate. Scopes control knowledge access. Manager role controls team metadata and same-team member profile administration. Member keys cannot manage profiles, even with write scope.

Transport

Dense-Mem uses MCP Streamable HTTP at:

/mcp

Supported methods:

MethodPathPurpose
POST/mcpJSON-RPC requests and notifications.
GET/mcpServer-to-client SSE stream where supported.

REST and OpenAPI remain available for non-MCP integrations and operations.

Storage Choices

ComponentPurpose
PostgresTeams, profiles, key metadata, audit records, migrations.
Neo4jMemory graph, claims, facts, relationships, communities, dreams, vector indexes.
RedisOptional for one server; required for multi-instance shared limits.
PrometheusOptional telemetry store for the /ui app and control portal dashboards.

App config and operation logs also live in Postgres. App config drives runtime settings such as APP_TIMEZONE, scheduled dreaming, scheduled community detection, SSO public settings, and operation-log retention.

Embedding Ownership

Dense-Mem embeds normal write and recall text itself.

Clients send text. Dense-Mem sends that text to the configured embedding provider, stores the resulting vectors, and checks that model dimensions stay consistent.

Client-supplied vectors are reserved for advanced search use cases.