Skip to main content

Production-Grade Agent Memory Framework for Agentic AI

Project description

๐Ÿง  GraphMem

The Human Brain for Your AI Agents

PyPI Python 3.9+ License: MIT GitHub

"Memory is the treasury and guardian of all things." โ€” Cicero

GraphMem is the first memory system that thinks like a human brain. It doesn't just store dataโ€”it forgets, consolidates, prioritizes, and evolves exactly like biological memory does.

This is the future of enterprise AI agents.


๐Ÿงฌ Why GraphMem Changes Everything

The Problem with Current AI Memory

Every production AI agent faces the same crisis:

Day 1:     "Who is the CEO?" โ†’ "Elon Musk" โœ…
Day 100:   Context window: OVERFLOW ๐Ÿ’ฅ
Day 365:   "Who is the CEO?" โ†’ "John... or was it Jane... maybe Elon?" ๐Ÿคฏ

Vector databases don't forget. They accumulate garbage until your agent drowns in irrelevant, conflicting, outdated information.

The GraphMem Solution: Memory That Thinks

GraphMem implements the four pillars of human memory:

Human Brain GraphMem Why It Matters
๐Ÿง  Forgetting Curve Memory Decay Irrelevant memories fade naturally
๐Ÿ”— Neural Networks Knowledge Graph Relationships between concepts
โญ Importance Weighting PageRank Centrality Hub concepts (Elon Musk) > peripheral ones
โฐ Episodic Memory Temporal Validity "CEO in 2015" vs "CEO now"

๐Ÿš€ Revolutionary Features

1. ๐Ÿ•ฐ๏ธ Point-in-Time Memory (Temporal Validity)

"Who was CEO in 2015?" โ€” No other memory system can answer this.

from datetime import datetime
from graphmem import GraphMem, MemoryConfig

memory = GraphMem(config)

# GraphMem tracks WHEN facts are true
memory.ingest("John Smith was CEO of ACME from 2010 to 2018")
memory.ingest("Jane Doe became CEO of ACME in July 2018")

# Point-in-time queries - like human episodic memory!
memory.query("Who was CEO in 2015?")      # โ†’ "John Smith" โœ…
memory.query("Who is CEO now?")           # โ†’ "Jane Doe" โœ…
memory.query("Who was CEO in 2019?")      # โ†’ "Jane Doe" โœ…

Use Cases:

  • ๐Ÿ“‹ "What contracts were active last quarter?"
  • ๐Ÿ‘” "Who was our legal counsel before 2020?"
  • ๐Ÿ“ˆ "What was our strategy during COVID?"

2. โญ PageRank Centrality (Hub Detection)

GraphMem uses Google's PageRank algorithm to identify important entities:

Importance Formula: ฯ(e) = w1ยทf1 + w2ยทf2 + w3ยทf3 + w4ยทf4

where:
  f1 = Temporal recency    (recent = important)
  f2 = Access frequency    (used often = important)  
  f3 = PageRank centrality (well-connected = important) โ† NEW!
  f4 = User feedback       (explicit signals)

Result: "Elon Musk" (connected to Tesla, SpaceX, Neuralink) scores 3x higher than "Austin, Texas" (connected only to Tesla HQ).

# PageRank automatically identifies hub entities
Elon Musk:      PR = 1.000 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ  # Hub - many connections
Tesla:          PR = 0.774 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ       # Important company
Austin:         PR = 0.520 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ            # Just a location

3. ๐Ÿง  Self-Evolution (Like Human Memory)

memory.evolve()  # This single line triggers:
Mechanism What Happens Human Equivalent
Decay Old unused memories fade (importance โ†’ 0) Forgetting curve
Consolidation 5 mentions of "user likes Python" โ†’ 1 strong memory Sleep consolidation
Rehydration Contradictions resolved ("CEO is John" โ†’ "CEO is Jane") Memory updating
Importance Scoring PageRank recalculated Synaptic strengthening

Result: 80% memory reduction while keeping what matters.

4. ๐Ÿข Enterprise Multi-Tenant Isolation

Each user gets their own brain. Complete data separation.

# Alice's memory
alice = GraphMem(config, user_id="alice", memory_id="chat")
alice.ingest("I work at Google as a senior engineer")

# Bob's memory (COMPLETELY ISOLATED)
bob = GraphMem(config, user_id="bob", memory_id="chat")
bob.ingest("I'm a doctor at Mayo Clinic")

# Alice can NEVER see Bob's data
alice.query("What does Bob do?")  # โ†’ "No information found" โœ…

# Bob can NEVER see Alice's data  
bob.query("Where does Alice work?")  # โ†’ "No information found" โœ…

Architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Neo4j Global Instance                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚           USER: alice              โ”‚            USER: bob                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚ ๐Ÿข Google  โ†’ ๐Ÿ‘ค Alice       โ”‚   โ”‚   โ”‚ ๐Ÿฅ Mayo Clinic โ†’ ๐Ÿ‘ค Bob     โ”‚   โ”‚
โ”‚  โ”‚     โ†“                       โ”‚   โ”‚   โ”‚       โ†“                     โ”‚   โ”‚
โ”‚  โ”‚ ๐Ÿ’ผ Senior Engineer          โ”‚   โ”‚   โ”‚   ๐Ÿฉบ Doctor                 โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                    Redis Cache (Also Isolated by user_id)                 โ”‚
โ”‚  alice:query:*  alice:search:*     โ”‚     bob:query:*  bob:search:*       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ’ก The 3-Line API

from graphmem import GraphMem, MemoryConfig

# Initialize (works with ANY OpenAI-compatible API)
config = MemoryConfig(
    llm_provider="openai_compatible",
    llm_api_key="your-key",
    llm_api_base="https://openrouter.ai/api/v1",
    llm_model="google/gemini-2.0-flash-001",
    embedding_provider="openai_compatible",
    embedding_api_key="your-key",
    embedding_api_base="https://openrouter.ai/api/v1",
    embedding_model="openai/text-embedding-3-small",
)

memory = GraphMem(config)

# That's it. 3 methods:
memory.ingest("Tesla is led by CEO Elon Musk...")  # โ† Extract knowledge
memory.query("Who is the CEO?")                    # โ† Ask questions
memory.evolve()                                    # โ† Let memory mature

๐Ÿ—๏ธ Architecture

High-Level Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                                  ๐Ÿง  GraphMem                                     โ”‚
โ”‚                         The Human Brain for AI Agents                            โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”‚
โ”‚   โ”‚  ingest()   โ”‚        โ”‚   query()   โ”‚        โ”‚  evolve()   โ”‚                 โ”‚
โ”‚   โ”‚  Learn new  โ”‚        โ”‚  Recall +   โ”‚        โ”‚  Mature     โ”‚                 โ”‚
โ”‚   โ”‚  knowledge  โ”‚        โ”‚  Reasoning  โ”‚        โ”‚  memories   โ”‚                 โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚                      โ”‚                      โ”‚
           โ–ผ                      โ–ผ                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                           ๐Ÿ” MULTI-TENANT LAYER                                  โ”‚
โ”‚                                                                                  โ”‚
โ”‚   Every operation is scoped by: user_id + memory_id                             โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚   โ”‚       USER: alice           โ”‚    โ”‚        USER: bob            โ”‚            โ”‚
โ”‚   โ”‚   memory_id: chat_1         โ”‚    โ”‚    memory_id: chat_1        โ”‚            โ”‚
โ”‚   โ”‚   memory_id: notes          โ”‚    โ”‚    memory_id: work          โ”‚            โ”‚
โ”‚   โ”‚   โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•      โ”‚    โ”‚    โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•     โ”‚            โ”‚
โ”‚   โ”‚   Complete isolation โœ…     โ”‚    โ”‚    Complete isolation โœ…    โ”‚            โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        ๐Ÿ•ธ๏ธ KNOWLEDGE GRAPH ENGINE                                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚   โ”‚ ENTITY EXTRACTION โ”‚   โ”‚   RELATIONSHIP    โ”‚   โ”‚    COMMUNITY      โ”‚         โ”‚
โ”‚   โ”‚                   โ”‚   โ”‚    DETECTION      โ”‚   โ”‚    DETECTION      โ”‚         โ”‚
โ”‚   โ”‚ โ€ข LLM-powered     โ”‚   โ”‚                   โ”‚   โ”‚                   โ”‚         โ”‚
โ”‚   โ”‚ โ€ข Named entities  โ”‚   โ”‚ โ€ข Semantic links  โ”‚   โ”‚ โ€ข Louvain algo    โ”‚         โ”‚
โ”‚   โ”‚ โ€ข Type inference  โ”‚   โ”‚ โ€ข Temporal bounds โ”‚   โ”‚ โ€ข Auto-clustering โ”‚         โ”‚
โ”‚   โ”‚ โ€ข Descriptions    โ”‚   โ”‚ โ€ข [t_s, t_e]      โ”‚   โ”‚ โ€ข LLM summaries   โ”‚         โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚   โ”‚ ENTITY RESOLUTION โ”‚   โ”‚    SEMANTIC       โ”‚   โ”‚   QUERY ENGINE    โ”‚         โ”‚
โ”‚   โ”‚                   โ”‚   โ”‚     SEARCH        โ”‚   โ”‚                   โ”‚         โ”‚
โ”‚   โ”‚ โ€ข Alias merging   โ”‚   โ”‚                   โ”‚   โ”‚ โ€ข Multi-hop       โ”‚         โ”‚
โ”‚   โ”‚ โ€ข Canonicalizationโ”‚   โ”‚ โ€ข Vector index    โ”‚   โ”‚ โ€ข Cross-cluster   โ”‚         โ”‚
โ”‚   โ”‚ โ€ข 95% accuracy    โ”‚   โ”‚ โ€ข Cosine sim      โ”‚   โ”‚ โ€ข Context assemblyโ”‚         โ”‚
โ”‚   โ”‚ โ€ข user_id aware   โ”‚   โ”‚ โ€ข user_id filter  โ”‚   โ”‚ โ€ข LLM synthesis   โ”‚         โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         ๐Ÿ”„ EVOLUTION ENGINE                                      โ”‚
โ”‚                      (Human Memory Simulation)                                   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚                      โญ PAGERANK CENTRALITY                              โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   PR(A) = (1-d) + d ร— ฮฃ(PR(Ti)/C(Ti))    where d = 0.85                 โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   Hub Detection:                                                         โ”‚   โ”‚
โ”‚   โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚ Elon Musk โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ†’ Tesla โ”€โ”€โ”€โ†’ Austin                          โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚    (HUB)       โ”œโ”€โ”€โ”€โ†’ SpaceX โ”€โ”€โ”€โ†’ Hawthorne                      โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚   PR=1.00      โ””โ”€โ”€โ”€โ†’ Neuralink                                  โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚                                                                  โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚ PageRank: Elon(1.00) > Tesla(0.77) > SpaceX(0.77) > Austin(0.52)โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚   โ”‚    MEMORY DECAY      โ”‚  โ”‚   CONSOLIDATION      โ”‚  โ”‚ TEMPORAL VALIDITY  โ”‚    โ”‚
โ”‚   โ”‚                      โ”‚  โ”‚                      โ”‚  โ”‚                    โ”‚    โ”‚
โ”‚   โ”‚ Ebbinghaus Curve:    โ”‚  โ”‚ LLM-based merging:   โ”‚  โ”‚ Time bounds:       โ”‚    โ”‚
โ”‚   โ”‚                      โ”‚  โ”‚                      โ”‚  โ”‚                    โ”‚    โ”‚
โ”‚   โ”‚ I(t) = Iโ‚€ยทe^(-ฮปt)    โ”‚  โ”‚ 5 mentions โ†’         โ”‚  โ”‚ valid_from: t_s    โ”‚    โ”‚
โ”‚   โ”‚                      โ”‚  โ”‚ 1 strong memory      โ”‚  โ”‚ valid_until: t_e   โ”‚    โ”‚
โ”‚   โ”‚ ฮป = decay rate       โ”‚  โ”‚                      โ”‚  โ”‚                    โ”‚    โ”‚
โ”‚   โ”‚                      โ”‚  โ”‚ 80% reduction        โ”‚  โ”‚ is_valid_at(t)     โ”‚    โ”‚
โ”‚   โ”‚ Unused โ†’ archived    โ”‚  โ”‚ while keeping value  โ”‚  โ”‚ supersede(end)     โ”‚    โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚                                                                                  โ”‚
โ”‚   Importance Formula: ฯ(e) = w1ยทf1 + w2ยทf2 + w3ยทf3 + w4ยทf4                      โ”‚
โ”‚   โ”œโ”€โ”€ f1: Recency (0.3)     - Recent access = important                         โ”‚
โ”‚   โ”œโ”€โ”€ f2: Frequency (0.3)   - Used often = important                            โ”‚
โ”‚   โ”œโ”€โ”€ f3: PageRank (0.2)    - Well-connected = important (HUB)                  โ”‚
โ”‚   โ””โ”€โ”€ f4: User signal (0.2) - Explicit importance                               โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                            ๐Ÿ’พ STORAGE LAYER                                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚
โ”‚  โ”‚                       CHOOSE YOUR STORAGE BACKEND                           โ”‚โ”‚
โ”‚  โ”‚                                                                             โ”‚โ”‚
โ”‚  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚โ”‚
โ”‚  โ”‚   โ”‚  InMemory   โ”‚     โ”‚   ๐Ÿ”ฅ TURSO ๐Ÿ”ฅ    โ”‚     โ”‚      NEO4J          โ”‚      โ”‚โ”‚
โ”‚  โ”‚   โ”‚  (Default)  โ”‚     โ”‚    (Embedded)   โ”‚     โ”‚    (Enterprise)     โ”‚      โ”‚โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค      โ”‚โ”‚
โ”‚  โ”‚   โ”‚ No persist  โ”‚     โ”‚ SQLite file     โ”‚     โ”‚ Full graph DB       โ”‚      โ”‚โ”‚
โ”‚  โ”‚   โ”‚ Zero config โ”‚     โ”‚ Works offline   โ”‚     โ”‚ ACID + clustering   โ”‚      โ”‚โ”‚
โ”‚  โ”‚   โ”‚ Dev/testing โ”‚     โ”‚ Cloud sync opt  โ”‚     โ”‚ Native Cypher       โ”‚      โ”‚โ”‚
โ”‚  โ”‚   โ”‚ Python vec  โ”‚     โ”‚ Native vec ๐Ÿš€   โ”‚     โ”‚ HNSW vec ๐Ÿš€         โ”‚      โ”‚โ”‚
โ”‚  โ”‚   โ”‚             โ”‚     โ”‚ ~10ms search    โ”‚     โ”‚ ~5ms search         โ”‚      โ”‚โ”‚
โ”‚  โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚โ”‚
โ”‚  โ”‚         โ”‚                     โ”‚                        โ”‚                    โ”‚โ”‚
โ”‚  โ”‚         โ”‚      ALL BACKENDS GET THE SAME FEATURES:     โ”‚                    โ”‚โ”‚
โ”‚  โ”‚         โ”‚   โœ… Multi-tenant  โœ… Temporal validity       โ”‚                    โ”‚โ”‚
โ”‚  โ”‚         โ”‚   โœ… PageRank      โœ… Memory evolution         โ”‚                    โ”‚โ”‚
โ”‚  โ”‚         โ”‚   โœ… Communities   โœ… Entity resolution        โ”‚                    โ”‚โ”‚
โ”‚  โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ”‚โ”‚
โ”‚  โ”‚                               โ”‚                                             โ”‚โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚   โ”‚         ๐Ÿ—ƒ๏ธ NEO4J GRAPH                 โ”‚   โ”‚         โšก REDIS CACHE        โ”‚ โ”‚
โ”‚   โ”‚         (Enterprise Option)            โ”‚   โ”‚        (Optional Layer)       โ”‚ โ”‚
โ”‚   โ”‚                                        โ”‚   โ”‚                               โ”‚ โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚      ENTITY NODES               โ”‚  โ”‚   โ”‚  โ”‚   EMBEDDING CACHE      โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข id, name, type               โ”‚  โ”‚   โ”‚  โ”‚                        โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข embedding[1536]              โ”‚  โ”‚   โ”‚  โ”‚  Key: emb:{text_hash}  โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข user_id โ† ISOLATION          โ”‚  โ”‚   โ”‚  โ”‚  TTL: 24 hours         โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข memory_id                    โ”‚  โ”‚   โ”‚  โ”‚  3x faster embeddings  โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข importance, access_count     โ”‚  โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚ โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚   โ”‚                               โ”‚ โ”‚
โ”‚   โ”‚                                        โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚ โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚   โ”‚  โ”‚   QUERY CACHE          โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚    RELATIONSHIP EDGES           โ”‚  โ”‚   โ”‚  โ”‚   (Multi-Tenant!)      โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข valid_from  โ† TEMPORAL       โ”‚  โ”‚   โ”‚  โ”‚                        โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข valid_until โ† VALIDITY       โ”‚  โ”‚   โ”‚  โ”‚  Key: query:{user}:*   โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  โ€ข user_id โ† ISOLATION          โ”‚  โ”‚   โ”‚  โ”‚  TTL: 5 minutes        โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚   โ”‚  โ”‚  Instant repeat: 0ms   โ”‚   โ”‚ โ”‚
โ”‚   โ”‚                                        โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚ โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚   โ”‚                               โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  VECTOR INDEX (HNSW)            โ”‚  โ”‚   โ”‚  Auto-Invalidation:           โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  Dimension: 1536, cosine        โ”‚  โ”‚   โ”‚  โ€ข ingest() โ†’ clear cache     โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  ~5ms similarity search         โ”‚  โ”‚   โ”‚  โ€ข evolve() โ†’ clear cache     โ”‚ โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚   โ”‚  โ€ข clear()  โ†’ clear cache     โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚   โ”‚   ๐Ÿ”ฅ TURSO (SQLite) - RECOMMENDED!    โ”‚   โ”‚      ๐Ÿ”ฅ TURSO CACHE           โ”‚ โ”‚
โ”‚   โ”‚      (Edge/Offline Option)            โ”‚   โ”‚     (Built-in to TursoStore)  โ”‚ โ”‚
โ”‚   โ”‚                                        โ”‚   โ”‚                               โ”‚ โ”‚
โ”‚   โ”‚  pip install "agentic-graph-mem[libsql]"  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚ โ”‚
โ”‚   โ”‚                                        โ”‚   โ”‚  โ”‚ No Redis needed!       โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โœ… Persists to local .db file         โ”‚   โ”‚  โ”‚ SQLite-based cache     โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โœ… Works completely offline           โ”‚   โ”‚  โ”‚ TTL support            โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โœ… Optional Turso Cloud sync          โ”‚   โ”‚  โ”‚ Multi-tenant keys      โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โœ… Native F32_BLOB vector search      โ”‚   โ”‚  โ”‚ Survives restarts      โ”‚   โ”‚ โ”‚
โ”‚   โ”‚  โœ… ~10ms vector similarity            โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚ โ”‚
โ”‚   โ”‚                                        โ”‚   โ”‚                               โ”‚ โ”‚
โ”‚   โ”‚  SAME FEATURES AS NEO4J:              โ”‚   โ”‚  Great for:                   โ”‚ โ”‚
โ”‚   โ”‚  โ€ข Temporal validity โœ…                โ”‚   โ”‚  โ€ข Edge AI devices           โ”‚ โ”‚
โ”‚   โ”‚  โ€ข PageRank centrality โœ…              โ”‚   โ”‚  โ€ข Offline agents            โ”‚ โ”‚
โ”‚   โ”‚  โ€ข Multi-tenant isolation โœ…           โ”‚   โ”‚  โ€ข Mobile apps               โ”‚ โ”‚
โ”‚   โ”‚  โ€ข Point-in-time queries โœ…            โ”‚   โ”‚  โ€ข Cost-sensitive deploys    โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                           ๐Ÿค– LLM PROVIDERS                                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚   โ”‚  OpenAI  โ”‚ โ”‚  Azure   โ”‚ โ”‚Anthropic โ”‚ โ”‚  Groq    โ”‚ โ”‚ Together โ”‚ โ”‚  Ollama  โ”‚ โ”‚
โ”‚   โ”‚  GPT-4o  โ”‚ โ”‚  OpenAI  โ”‚ โ”‚  Claude  โ”‚ โ”‚  Llama   โ”‚ โ”‚    AI    โ”‚ โ”‚  Local   โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚                    OpenRouter (100+ Models)                              โ”‚   โ”‚
โ”‚   โ”‚   google/gemini-2.0-flash โ”‚ anthropic/claude-3.5 โ”‚ meta-llama/llama-3   โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Data Flow: Ingest โ†’ Query โ†’ Evolve

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                              INGEST FLOW                                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  Input Document                    Knowledge Extraction                  Storage
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ "Tesla is    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ   โ”‚ LLM extracts:    โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ  โ”‚ Neo4j OR  โ”‚
 โ”‚  led by CEO  โ”‚                  โ”‚                  โ”‚               โ”‚ ๐Ÿ”ฅTurso   โ”‚
 โ”‚  Elon Musk"  โ”‚                  โ”‚ Entities:        โ”‚               โ”‚           โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚ โ€ข Tesla [Org]    โ”‚               โ”‚ (Tesla)โ”€โ”€โ”€โ”‚
        โ”‚                          โ”‚ โ€ข Elon Musk [Per]โ”‚               โ”‚     โ”‚     โ”‚
        โ”‚                          โ”‚                  โ”‚               โ”‚     โ–ผ     โ”‚
        โ”‚                          โ”‚ Relations:       โ”‚               โ”‚ CEO_OF    โ”‚
        โ”‚                          โ”‚ โ€ข (Elon)โ”€CEOโ”€โ–ถ   โ”‚               โ”‚     โ”‚     โ”‚
        โ”‚                          โ”‚   (Tesla)        โ”‚               โ”‚     โ–ผ     โ”‚
        โ”‚                          โ”‚                  โ”‚               โ”‚ (Elon)    โ”‚
        โ”‚                          โ”‚ Temporal:        โ”‚               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚                          โ”‚ โ€ข valid_from=now โ”‚                     โ”‚
        โ”‚                          โ”‚ โ€ข valid_until=โˆž  โ”‚                     โ–ผ
        โ”‚                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                                   โ”‚                         โ”‚ Redis OR  โ”‚
        โ”‚                                   โ”‚                         โ”‚ TursoCacheโ”‚
        โ”‚                                   โ–ผ                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚                          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                          โ”‚ Entity Resolutionโ”‚
        โ”‚                          โ”‚                  โ”‚
        โ”‚                          โ”‚ "Elon" = "Musk"  โ”‚
        โ”‚                          โ”‚ = "Elon Musk"    โ”‚
        โ”‚                          โ”‚ โ†’ Canonical: "Elon Musk"
        โ”‚                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚
        โ””โ”€โ”€โ”€ user_id + memory_id tagged on ALL nodes/edges


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                               QUERY FLOW                                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  User Question              Cache Check           Retrieval              Answer
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ "Who is the  โ”‚   โ”€โ”€โ”€โ–ถ   โ”‚  Redis    โ”‚  HIT   โ”‚           โ”‚   โ”€โ”€โ”€โ–ถ  โ”‚ "Elon    โ”‚
 โ”‚  CEO?"       โ”‚          โ”‚  Cache    โ”‚  โ”€โ”€โ”€โ–ถ  โ”‚  SKIP!    โ”‚         โ”‚  Musk"   โ”‚
 โ”‚              โ”‚          โ”‚           โ”‚        โ”‚           โ”‚         โ”‚          โ”‚
 โ”‚ user: alice  โ”‚          โ”‚ Key:      โ”‚        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚ mem: chat_1  โ”‚          โ”‚ query:    โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚ alice:    โ”‚  MISS
        โ”‚                  โ”‚ chat_1:   โ”‚  โ”€โ”€โ”€โ–ถ  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                  โ”‚ {hash}    โ”‚        โ”‚         RETRIEVAL              โ”‚
        โ”‚                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚                                โ”‚
        โ”‚                                       โ”‚  1. Embed query                โ”‚
        โ”‚                                       โ”‚  2. Vector search (Neo4j/Turso)โ”‚
        โ”‚                                       โ”‚     WHERE user_id = 'alice'    โ”‚
        โ”‚                                       โ”‚     AND memory_id = 'chat_1'   โ”‚
        โ”‚                                       โ”‚  3. Get related edges          โ”‚
        โ”‚                                       โ”‚  4. Filter by temporal         โ”‚
        โ”‚                                       โ”‚     is_valid_at(now) โœ…        โ”‚
        โ”‚                                       โ”‚  5. Rank by importance         โ”‚
        โ”‚                                       โ”‚     (PageRank score)           โ”‚
        โ”‚                                       โ”‚  6. Build context              โ”‚
        โ”‚                                       โ”‚  7. LLM generates answer       โ”‚
        โ”‚                                       โ”‚  8. Cache result in Redis      โ”‚
        โ”‚                                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚
        โ””โ”€โ”€โ”€ user_id ensures Alice NEVER sees Bob's data


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                              EVOLVE FLOW                                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  Trigger                    Evolution Cycle                         Result
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ memory       โ”‚   โ”€โ”€โ”€โ–ถ   โ”‚                                โ”‚     โ”‚            โ”‚
 โ”‚ .evolve()    โ”‚          โ”‚  1. PAGERANK RECALCULATION     โ”‚     โ”‚ โ€ข Hubs     โ”‚
 โ”‚              โ”‚          โ”‚     Build graph from edges     โ”‚     โ”‚   identifiedโ”‚
 โ”‚ user: alice  โ”‚          โ”‚     Compute PR scores          โ”‚     โ”‚            โ”‚
 โ”‚              โ”‚          โ”‚     Update importance          โ”‚     โ”‚ โ€ข 80%      โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚                                โ”‚     โ”‚   memory   โ”‚
        โ”‚                  โ”‚  2. MEMORY DECAY               โ”‚     โ”‚   reduced  โ”‚
        โ”‚                  โ”‚     I(t) = Iโ‚€ ร— e^(-ฮปt)        โ”‚     โ”‚            โ”‚
        โ”‚                  โ”‚     Archive if I < 0.1         โ”‚     โ”‚ โ€ข Conflictsโ”‚
        โ”‚                  โ”‚                                โ”‚     โ”‚   resolved โ”‚
        โ”‚                  โ”‚  3. CONSOLIDATION              โ”‚     โ”‚            โ”‚
        โ”‚                  โ”‚     Find similar memories      โ”‚     โ”‚ โ€ข Cache    โ”‚
        โ”‚                  โ”‚     LLM merges duplicates      โ”‚     โ”‚   cleared  โ”‚
        โ”‚                  โ”‚                                โ”‚     โ”‚            โ”‚
        โ”‚                  โ”‚  4. REHYDRATION                โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚                  โ”‚     Update contradictions      โ”‚
        โ”‚                  โ”‚     "CEO=John" โ†’ "CEO=Jane"    โ”‚
        โ”‚                  โ”‚                                โ”‚
        โ”‚                  โ”‚  5. CACHE INVALIDATION         โ”‚
        โ”‚                  โ”‚     Clear Redis for user       โ”‚
        โ”‚                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚
        โ””โ”€โ”€โ”€ Only evolves Alice's data (user_id scoped)

Multi-Tenant Data Isolation

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     ๐Ÿ” MULTI-TENANT ARCHITECTURE                                 โ”‚
โ”‚              (Works identically with Neo4j, Turso, or InMemory)                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚                    STORAGE BACKEND (Neo4j / Turso / InMemory)                    โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚                       GLOBAL VECTOR INDEX                                โ”‚   โ”‚
โ”‚   โ”‚                    (Entity.embedding, HNSW)                              โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   Query: db.index.vector.queryNodes(                                     โ”‚   โ”‚
โ”‚   โ”‚            'entity_embedding_index',                                     โ”‚   โ”‚
โ”‚   โ”‚            $top_k * 10,     โ† Fetch extra for filtering                  โ”‚   โ”‚
โ”‚   โ”‚            $query_embedding                                              โ”‚   โ”‚
โ”‚   โ”‚          )                                                               โ”‚   โ”‚
โ”‚   โ”‚          WHERE node.user_id = $user_id   โ† ISOLATION                     โ”‚   โ”‚
โ”‚   โ”‚          AND node.memory_id = $memory_id                                 โ”‚   โ”‚
โ”‚   โ”‚          RETURN node LIMIT $top_k                                        โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚   โ”‚         USER: alice           โ”‚   โ”‚          USER: bob                โ”‚     โ”‚
โ”‚   โ”‚                               โ”‚   โ”‚                                   โ”‚     โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚    memory: chat_1       โ”‚  โ”‚   โ”‚  โ”‚    memory: chat_1           โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”     โ”‚  โ”‚   โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”        โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ”‚Aliceโ”‚โ”€โ”€โ”€โ–ถโ”‚Googleโ”‚    โ”‚  โ”‚   โ”‚  โ”‚  โ”‚ Bob โ”‚โ”€โ”€โ”€โ–ถโ”‚Mayo  โ”‚       โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚  โ”‚   โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚Clinicโ”‚       โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚     โ”‚                   โ”‚  โ”‚   โ”‚  โ”‚     โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚     โ–ผ                   โ”‚  โ”‚   โ”‚  โ”‚     โ–ผ                      โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚  โ”‚   โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ”‚Engineerโ”‚             โ”‚  โ”‚   โ”‚  โ”‚  โ”‚Doctorโ”‚                  โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚  โ”‚   โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚     โ”‚
โ”‚   โ”‚                               โ”‚   โ”‚                                   โ”‚     โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚    memory: notes        โ”‚  โ”‚   โ”‚  โ”‚    memory: work             โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”     โ”‚  โ”‚   โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ”‚Pythonโ”‚โ”€โ”€โ–ถโ”‚ ML  โ”‚     โ”‚  โ”‚   โ”‚  โ”‚  โ”‚Patientโ”‚โ”€โ”€โ–ถโ”‚Recordโ”‚      โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚  โ”‚   โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚  โ”‚     โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚     โ”‚
โ”‚   โ”‚                               โ”‚   โ”‚                                   โ”‚     โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚                                                                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                           REDIS CACHE (ISOLATED)                                 โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   Alice's Keys:                      Bob's Keys:                         โ”‚   โ”‚
โ”‚   โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                      โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                          โ”‚   โ”‚
โ”‚   โ”‚   query:alice:chat_1:abc123          query:bob:chat_1:xyz789             โ”‚   โ”‚
โ”‚   โ”‚   search:alice:chat_1:def456         search:bob:chat_1:uvw321            โ”‚   โ”‚
โ”‚   โ”‚   search:alice:notes:ghi789          search:bob:work:rst654              โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   Shared (same text = same embedding):                                   โ”‚   โ”‚
โ”‚   โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                  โ”‚   โ”‚
โ”‚   โ”‚   emb:sha256_of_text โ†’ [0.1, 0.2, ...]                                   โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โœ… Alice can NEVER access Bob's cached queries                                โ”‚
โ”‚   โœ… Bob can NEVER access Alice's cached queries                                โ”‚
โ”‚   โœ… Embeddings shared (efficiency) - no sensitive data in embeddings           โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Temporal Validity Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       โฐ TEMPORAL VALIDITY                                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚   Every RELATIONSHIP has a time interval: [valid_from, valid_until]             โ”‚
โ”‚                                                                                  โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚                         CEO TRANSITIONS                                  โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   Timeline:  2010      2015      2018      2020      2025               โ”‚   โ”‚
โ”‚   โ”‚              โ”‚         โ”‚         โ”‚         โ”‚         โ”‚                   โ”‚   โ”‚
โ”‚   โ”‚              โ–ผ         โ–ผ         โ–ผ         โ–ผ         โ–ผ                   โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   John โ”€โ”€CEO_OFโ”€โ”€โ–ถ ACME   โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—                             โ”‚   โ”‚
โ”‚   โ”‚   valid: [2010-01-01, 2018-06-30]         โ•‘                             โ”‚   โ”‚
โ”‚   โ”‚                                            โ•‘                             โ”‚   โ”‚
โ”‚   โ”‚   Jane โ”€โ”€CEO_OFโ”€โ”€โ–ถ ACME                   โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•     โ”‚   โ”‚
โ”‚   โ”‚   valid: [2018-07-01, NULL]                โ† NULL = still current       โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                                  โ”‚
โ”‚   Point-in-Time Queries:                                                         โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   Q: "Who was CEO in 2015?"                                              โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   1. Find edges WHERE relation_type = 'CEO_OF'                           โ”‚   โ”‚
โ”‚   โ”‚   2. Filter: is_valid_at(datetime(2015, 6, 1))                           โ”‚   โ”‚
โ”‚   โ”‚      โ”œโ”€โ”€ John: valid_from=2010 โ‰ค 2015 โ‰ค valid_until=2018 โœ…             โ”‚   โ”‚
โ”‚   โ”‚      โ””โ”€โ”€ Jane: valid_from=2018 > 2015 โŒ                                 โ”‚   โ”‚
โ”‚   โ”‚   3. Return: "John Smith"                                                โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   Q: "Who is CEO now?"                                                   โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   1. Filter: is_valid_at(datetime.utcnow())                              โ”‚   โ”‚
โ”‚   โ”‚      โ”œโ”€โ”€ John: valid_until=2018 < now โŒ                                 โ”‚   โ”‚
โ”‚   โ”‚      โ””โ”€โ”€ Jane: valid_from=2018 โ‰ค now, valid_until=NULL โœ…                โ”‚   โ”‚
โ”‚   โ”‚   2. Return: "Jane Doe"                                                  โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                                  โ”‚
โ”‚   API:                                                                           โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   # Check validity at any point in time                                  โ”‚   โ”‚
โ”‚   โ”‚   edge.is_valid_at(datetime(2015, 6, 1))  # True/False                   โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   # Mark relationship as ended                                           โ”‚   โ”‚
โ”‚   โ”‚   edge.supersede(end_time=datetime(2018, 6, 30))                         โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ”‚   # Query edges at specific time                                         โ”‚   โ”‚
โ”‚   โ”‚   store.query_edges_at_time(                                             โ”‚   โ”‚
โ”‚   โ”‚       memory_id="company_kb",                                            โ”‚   โ”‚
โ”‚   โ”‚       query_time=datetime(2015, 6, 1),                                   โ”‚   โ”‚
โ”‚   โ”‚       relation_type="CEO_OF"                                             โ”‚   โ”‚
โ”‚   โ”‚   )                                                                      โ”‚   โ”‚
โ”‚   โ”‚                                                                          โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

File Structure

graphmem/
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ memory.py              # GraphMem main class
โ”‚   โ”œโ”€โ”€ memory_types.py        # MemoryNode, MemoryEdge (+ temporal validity)
โ”‚   โ””โ”€โ”€ exceptions.py          # Custom exceptions
โ”‚
โ”œโ”€โ”€ graph/
โ”‚   โ”œโ”€โ”€ knowledge_graph.py     # LLM-based extraction
โ”‚   โ”œโ”€โ”€ entity_resolver.py     # Deduplication (user_id aware)
โ”‚   โ””โ”€โ”€ community_detector.py  # Topic clustering
โ”‚
โ”œโ”€โ”€ evolution/
โ”‚   โ”œโ”€โ”€ memory_evolution.py    # Evolution orchestrator
โ”‚   โ”œโ”€โ”€ importance_scorer.py   # PageRank + multi-factor scoring
โ”‚   โ”œโ”€โ”€ decay.py               # Ebbinghaus forgetting curve
โ”‚   โ”œโ”€โ”€ consolidation.py       # LLM-based merging (user_id aware)
โ”‚   โ””โ”€โ”€ rehydration.py         # Contradiction resolution
โ”‚
โ”œโ”€โ”€ retrieval/
โ”‚   โ”œโ”€โ”€ query_engine.py        # Multi-hop + cross-cluster
โ”‚   โ”œโ”€โ”€ retriever.py           # Context retrieval
โ”‚   โ””โ”€โ”€ semantic_search.py     # Vector search (user_id filtered)
โ”‚
โ”œโ”€โ”€ stores/
โ”‚   โ”œโ”€โ”€ neo4j_store.py         # Graph + temporal + HNSW vector index
โ”‚   โ”œโ”€โ”€ turso_store.py         # SQLite + temporal + native vector (NEW!)
โ”‚   โ”œโ”€โ”€ memory_store.py        # In-memory (default)
โ”‚   โ””โ”€โ”€ redis_cache.py         # Multi-tenant cache
โ”‚
โ”œโ”€โ”€ llm/
โ”‚   โ”œโ”€โ”€ providers.py           # 10+ LLM providers
โ”‚   โ””โ”€โ”€ embeddings.py          # Embedding + cache
โ”‚
โ””โ”€โ”€ context/
    โ”œโ”€โ”€ context_engine.py      # Context assembly
    โ”œโ”€โ”€ chunker.py             # Semantic chunking
    โ””โ”€โ”€ multimodal.py          # JSON, CSV, Markdown, Code, Web

๐Ÿ“Š Why Enterprise Teams Choose GraphMem

Production Scale Performance

Metric Naive RAG GraphMem Advantage
1K conversations ๐Ÿ’ฅ Context overflow โœ… Bounded Handles growth
10K entities O(n) = 2.3s O(1) = 50ms 46x faster
1 year history 3,650 entries ~100 consolidated 97% reduction
Entity conflicts Duplicates Auto-resolved Clean data
Temporal queries โŒ Impossible โœ… Native Unique capability

Cost Efficiency

Naive RAG:  Send entire history every query    = $$$$$
GraphMem:   Retrieve only relevant subgraph    = $
                                                 โ”€โ”€โ”€โ”€โ”€
                                                 99% savings

Enterprise Requirements

Requirement GraphMem
Multi-tenant isolation โœ… user_id on every node
ACID transactions โœ… Neo4j backend
Horizontal scaling โœ… Neo4j cluster + Redis
Audit trail โœ… Temporal validity history
Data sovereignty โœ… Self-hosted option

๐Ÿ”ง Installation

# Core only (in-memory, for development)
pip install agentic-graph-mem

# ๐Ÿ”ฅ RECOMMENDED: Turso (SQLite persistence + offline)
pip install "agentic-graph-mem[libsql]"

# Enterprise: Neo4j + Redis (full graph power)
pip install "agentic-graph-mem[all]"

๐ŸŽฏ Which Backend Should You Choose?

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         STORAGE BACKEND DECISION TREE                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚   "Do you need data to persist between restarts?"                               โ”‚
โ”‚                           โ”‚                                                      โ”‚
โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                        โ”‚
โ”‚              โ”‚                         โ”‚                                        โ”‚
โ”‚              NO                       YES                                       โ”‚
โ”‚              โ”‚                         โ”‚                                        โ”‚
โ”‚              โ–ผ                         โ–ผ                                        โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    "Do you need complex graph queries                    โ”‚
โ”‚    โ”‚   InMemory      โ”‚     (multi-hop traversals, GDS algorithms)?"             โ”‚
โ”‚    โ”‚                 โ”‚                 โ”‚                                        โ”‚
โ”‚    โ”‚ โ€ข Development   โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                          โ”‚
โ”‚    โ”‚ โ€ข Testing       โ”‚    โ”‚                         โ”‚                          โ”‚
โ”‚    โ”‚ โ€ข Quick POCs    โ”‚   NO                        YES                         โ”‚
โ”‚    โ”‚ โ€ข Zero config   โ”‚    โ”‚                         โ”‚                          โ”‚
โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ–ผ                         โ–ผ                          โ”‚
โ”‚                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚
โ”‚                    โ”‚   ๐Ÿ”ฅ TURSO       โ”‚    โ”‚   NEO4J         โ”‚                  โ”‚
โ”‚                    โ”‚                 โ”‚    โ”‚                 โ”‚                  โ”‚
โ”‚                    โ”‚ โ€ข Edge/offline  โ”‚    โ”‚ โ€ข Enterprise    โ”‚                  โ”‚
โ”‚                    โ”‚ โ€ข Mobile apps   โ”‚    โ”‚ โ€ข Complex graphsโ”‚                  โ”‚
โ”‚                    โ”‚ โ€ข Single-user   โ”‚    โ”‚ โ€ข Multi-tenant  โ”‚                  โ”‚
โ”‚                    โ”‚ โ€ข No server     โ”‚    โ”‚ โ€ข Horizontal    โ”‚                  โ”‚
โ”‚                    โ”‚ โ€ข Simple setup  โ”‚    โ”‚   scaling       โ”‚                  โ”‚
โ”‚                    โ”‚ โ€ข SQLite-based  โ”‚    โ”‚ โ€ข ACID + clusterโ”‚                  โ”‚
โ”‚                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚
โ”‚                                                    โ”‚                            โ”‚
โ”‚                                      "Add high-performance caching?"            โ”‚
โ”‚                                                    โ”‚                            โ”‚
โ”‚                                           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                    โ”‚
โ”‚                                          YES              NO                    โ”‚
โ”‚                                           โ”‚               โ”‚                    โ”‚
โ”‚                                           โ–ผ               โ–ผ                    โ”‚
โ”‚                                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚                                    โ”‚  + REDIS  โ”‚    โ”‚ Neo4j onlyโ”‚              โ”‚
โ”‚                                    โ”‚  Cache    โ”‚    โ”‚ (still    โ”‚              โ”‚
โ”‚                                    โ”‚           โ”‚    โ”‚  great!)  โ”‚              โ”‚
โ”‚                                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Feature Comparison

Feature InMemory Turso ๐Ÿ”ฅ Neo4j
Persistence โŒ โœ… SQLite file โœ… Server
Works Offline โœ… โœ… โŒ
Vector Search Python Native F32_BLOB Native HNSW
Cloud Sync โŒ โœ… Optional โœ…
Setup Complexity None One file path Server required
Multi-hop Queries โœ… NetworkX โœ… NetworkX โœ… Native Cypher
PageRank โœ… โœ… โœ…
Temporal Validity โœ… โœ… โœ…
Multi-tenant โœ… โœ… โœ…
Best For Dev/Test Edge/Offline Enterprise

๐Ÿ“– Complete Examples

Basic Usage (In-Memory)

from graphmem import GraphMem, MemoryConfig

config = MemoryConfig(
    llm_provider="openai_compatible",
    llm_api_key="sk-or-v1-your-key",
    llm_api_base="https://openrouter.ai/api/v1",
    llm_model="google/gemini-2.0-flash-001",
    embedding_provider="openai_compatible",
    embedding_api_key="sk-or-v1-your-key",
    embedding_api_base="https://openrouter.ai/api/v1",
    embedding_model="openai/text-embedding-3-small",
)

memory = GraphMem(config)

# Learn
memory.ingest("Tesla is led by CEO Elon Musk. Founded in 2003.")
memory.ingest("SpaceX, founded by Elon Musk in 2002, builds rockets.")
memory.ingest("Neuralink develops brain-computer interfaces.")

# Recall
response = memory.query("What companies does Elon Musk lead?")
print(response.answer)  # "Elon Musk leads Tesla, SpaceX, and Neuralink."

# Mature
memory.evolve()  # Consolidates, decays, re-ranks importance

With Turso (SQLite Persistence + Offline Support) ๐Ÿ†•

from graphmem import GraphMem, MemoryConfig

# Turso gives you persistence without running Neo4j!
# Data survives restarts, works offline, can sync to cloud

config = MemoryConfig(
    llm_provider="openai_compatible",
    llm_api_key="sk-or-v1-your-key",
    llm_api_base="https://openrouter.ai/api/v1",
    llm_model="google/gemini-2.0-flash-001",
    embedding_provider="openai_compatible",
    embedding_api_key="sk-or-v1-your-key",
    embedding_api_base="https://openrouter.ai/api/v1",
    embedding_model="openai/text-embedding-3-small",
    
    # ๐Ÿ”ฅ Just add a file path - that's it!
    turso_db_path="my_agent_memory.db",
    
    # Optional: Sync to Turso Cloud for backups/multi-device
    # turso_url="https://your-db.turso.io",
    # turso_auth_token="your-token",
)

memory = GraphMem(config, user_id="alice")

# All data persists in my_agent_memory.db
memory.ingest("Alice is a software engineer at Google.")
memory.save()  # Data survives restart!

# Later, in a new session:
memory2 = GraphMem(config, user_id="alice")
response = memory2.query("Where does Alice work?")  # Still knows! โœ…

Why Turso over InMemory?

  • โœ… Data survives restarts (SQLite file)
  • โœ… Works offline (no network needed)
  • โœ… Optional cloud sync (Turso Cloud)
  • โœ… No server to manage (unlike Neo4j)
  • โœ… Per-user database files (true isolation)

Production: Multi-Tenant Chat System

from graphmem import GraphMem, MemoryConfig

# Base config (shared across all users)
base_config = MemoryConfig(
    llm_provider="openai_compatible",
    llm_api_key="sk-or-v1-your-key",
    llm_api_base="https://openrouter.ai/api/v1",
    llm_model="google/gemini-2.0-flash-001",
    embedding_provider="openai_compatible",
    embedding_api_key="sk-or-v1-your-key",
    embedding_api_base="https://openrouter.ai/api/v1",
    embedding_model="openai/text-embedding-3-small",
    # Production storage
    neo4j_uri="neo4j+ssc://xxx.databases.neo4j.io",
    neo4j_username="neo4j",
    neo4j_password="your-password",
    redis_url="redis://default:password@your-redis.cloud.redislabs.com:17983",
)

class ChatService:
    def get_memory(self, user_id: str, session_id: str) -> GraphMem:
        """Each user gets isolated memory."""
        return GraphMem(
            base_config,
            user_id=user_id,      # โ† Complete isolation
            memory_id=session_id,  # โ† Per-session memory
        )
    
    def chat(self, user_id: str, session_id: str, message: str) -> str:
        memory = self.get_memory(user_id, session_id)
        
        # Store user message as memory
        memory.ingest(message)
        
        # Generate response using memory
        response = memory.query(message)
        
        return response.answer

# Usage
service = ChatService()

# Alice's session (isolated)
alice_response = service.chat("alice", "session_1", "I'm a software engineer at Google")
alice_response = service.chat("alice", "session_1", "What do I do?")  # โ†’ "Software engineer at Google"

# Bob's session (completely separate)
bob_response = service.chat("bob", "session_1", "I'm a doctor")
bob_response = service.chat("bob", "session_1", "What does Alice do?")  # โ†’ "No information found"

Temporal Queries: Track Changes Over Time

from datetime import datetime
from graphmem.core.memory_types import MemoryEdge
from graphmem.stores.neo4j_store import Neo4jStore

store = Neo4jStore(uri, user, password)

# Track CEO transitions
john_ceo = MemoryEdge(
    id="john_ceo",
    source_id="john_smith",
    target_id="acme_corp",
    relation_type="CEO_OF",
    valid_from=datetime(2010, 1, 1),
    valid_until=datetime(2018, 6, 30),  # John left
)

jane_ceo = MemoryEdge(
    id="jane_ceo",
    source_id="jane_doe",
    target_id="acme_corp",
    relation_type="CEO_OF",
    valid_from=datetime(2018, 7, 1),
    valid_until=None,  # Current CEO
)

# Query by time period
ceo_2015 = store.query_edges_at_time(
    memory_id="company_kb",
    query_time=datetime(2015, 6, 1),
    relation_type="CEO_OF"
)
# โ†’ Returns John Smith's edge

ceo_now = store.query_edges_at_time(
    memory_id="company_kb",
    query_time=datetime.utcnow(),
    relation_type="CEO_OF"
)
# โ†’ Returns Jane Doe's edge

# Mark relationship as ended
store.supersede_relationship(
    memory_id="company_kb",
    edge_id="jane_ceo",
    end_time=datetime(2025, 12, 31)  # Jane leaves
)

๐Ÿงช Run the Evaluation

cd graphmem/evaluation
python run_eval.py

Uses MultiHopRAG dataset (2,556 QA samples, 609 documents).


๐Ÿ”ฌ The Science Behind GraphMem

Ebbinghaus Forgetting Curve

importance(t) = importance_0 ร— e^(-ฮป ร— (t - last_access))

Just like human memory, unused information fades exponentially.

PageRank for Entity Importance

PR(A) = (1-d) + d ร— ฮฃ(PR(Ti)/C(Ti))

Hub entities (connected to many concepts) are more importantโ€”exactly like neural hubs in the brain.

Temporal Validity

valid(r, t) = 1[t_s(r) โ‰ค t โ‰ค t_e(r)]

Every relationship has a time interval, enabling episodic memory recall.


๐Ÿญ Deployment Tiers

Scale Users Strategy Infrastructure
Development 1 InMemory (no persistence) Nothing required
Personal/Edge 1-10 ๐Ÿ”ฅ Turso (local SQLite) Single .db file per user
Startup 1-100 Turso + Cloud sync Turso Cloud (free tier)
Growth 100-10K Neo4j + Redis Neo4j Aura Pro + Redis Cloud
Enterprise 10K-100K Sharded by region Neo4j Enterprise Cluster
Global 100K+ Database per tenant Multi-region Neo4j Fabric

When to Use Each Storage

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                           STORAGE SELECTION GUIDE                                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                  โ”‚
โ”‚  ๐Ÿงช DEVELOPMENT / TESTING                                                       โ”‚
โ”‚     โ””โ”€โ–ถ InMemory (default)                                                      โ”‚
โ”‚         โ€ข pip install agentic-graph-mem                                         โ”‚
โ”‚         โ€ข config = MemoryConfig(...)  # No storage params needed                โ”‚
โ”‚                                                                                  โ”‚
โ”‚  ๐Ÿ“ฑ EDGE / OFFLINE / SIMPLE APPS                                                โ”‚
โ”‚     โ””โ”€โ–ถ ๐Ÿ”ฅ Turso (RECOMMENDED)                                                  โ”‚
โ”‚         โ€ข pip install "agentic-graph-mem[libsql]"                               โ”‚
โ”‚         โ€ข config = MemoryConfig(..., turso_db_path="agent.db")                  โ”‚
โ”‚         โ€ข Works offline, data persists, no server!                              โ”‚
โ”‚                                                                                  โ”‚
โ”‚  ๐Ÿข ENTERPRISE / HIGH-SCALE                                                     โ”‚
โ”‚     โ””โ”€โ–ถ Neo4j + Redis                                                           โ”‚
โ”‚         โ€ข pip install "agentic-graph-mem[all]"                                  โ”‚
โ”‚         โ€ข config = MemoryConfig(..., neo4j_uri=..., redis_url=...)              โ”‚
โ”‚         โ€ข Complex graph queries, horizontal scaling, ACID                       โ”‚
โ”‚                                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Dependencies

# Core (no external services, in-memory only)
pip install agentic-graph-mem

# With Turso (SQLite persistence, offline-first) - SIMPLEST OPTION!
pip install agentic-graph-mem libsql

# With Neo4j persistence (full graph database)
pip install "agentic-graph-mem[neo4j]"

# With Redis caching (high-performance cache)
pip install "agentic-graph-mem[redis]"

# Full production stack (Neo4j + Redis)
pip install "agentic-graph-mem[all]"

Storage Backend Comparison

Backend Persistence Vector Search Graph Algorithms Offline Use Case
InMemory โŒ โœ… (in Python) โœ… (NetworkX) โœ… Development, testing
Turso โœ… โœ… (native) โœ… (NetworkX) โœ… Edge/offline AI, simple deploys
Neo4j โœ… โœ… (HNSW) โœ… (GDS, native) โŒ Enterprise, complex graphs
Redis โš ๏ธ (volatile) โŒ โŒ โŒ Caching layer only

๐ŸŽฏ The Future of AI Memory

GraphMem isn't just another vector database wrapper. It's a paradigm shift:

Old Way GraphMem Way
Store everything Remember what matters
Static forever Evolves over time
No relationships Rich knowledge graph
"Who is CEO?" "Who was CEO in 2015?"
One user fits all Enterprise multi-tenant
Hope for the best PageRank prioritization

The agents of tomorrow will have memories that think.


๐Ÿค Contributing

We're building the future of AI memory. Join us!


๐Ÿ“„ License

MIT License - see LICENSE.


๐Ÿ™ Acknowledgments

  • Inspired by cognitive neuroscience research on human memory
  • Built on Neo4j, Redis, Turso (libSQL), and OpenAI
  • PageRank algorithm by Larry Page and Sergey Brin
  • Turso team for the amazing embedded SQLite with vector search

Made with ๐Ÿง  by Al-Amin Ibrahim

GitHub PyPI

"Give your AI agents the memory they deserve."

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentic_graph_mem-1.8.5.tar.gz (140.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentic_graph_mem-1.8.5-py3-none-any.whl (152.0 kB view details)

Uploaded Python 3

File details

Details for the file agentic_graph_mem-1.8.5.tar.gz.

File metadata

  • Download URL: agentic_graph_mem-1.8.5.tar.gz
  • Upload date:
  • Size: 140.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for agentic_graph_mem-1.8.5.tar.gz
Algorithm Hash digest
SHA256 8dd5511e4e3e0d2c1cee2740965ba4511e46f47a969fc01184cece88b3e6b503
MD5 649ca38cc90649f78c999212e8f9dfb8
BLAKE2b-256 fe1afdbaf1f5252fd38a4f0ed625bc7cd33dc2429588fddac3e7bbd307d7ddf6

See more details on using hashes here.

File details

Details for the file agentic_graph_mem-1.8.5-py3-none-any.whl.

File metadata

File hashes

Hashes for agentic_graph_mem-1.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 043704c928515601816ba27b6704223eb5b758f389937ef3958c048ad403acd8
MD5 f22ef1d8c3c31e51ea79f8341a7527fb
BLAKE2b-256 26c671cded70db1462fff506435d9212c1955391e494c7e9c1dfdd926810d18c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page