Skip to content

feat(memory): knowledge graph memory with temporal entity-relationship tracking #1222

@bug-ops

Description

@bug-ops

Summary

Add graph-based knowledge memory to augment existing vector + keyword semantic search. The graph stores entities, relationships, and communities extracted from conversations, enabling multi-hop reasoning, temporal fact tracking, and cross-session entity linking.

Motivation

Current limitations of flat vector + FTS5 search:

  • No entity relationships (cannot answer "how is X related to Y?")
  • No multi-hop reasoning (cannot chain A->B->C)
  • No temporal fact tracking (cannot track "user preferred X, then switched to Y")
  • No contradiction detection (conflicting facts coexist)
  • No cross-session entity linking

Industry benchmarks (Zep/Graphiti, arxiv:2501.13956) show +18.5% accuracy on multi-session temporal reasoning and 90% latency reduction vs full-context approaches.

Architecture

  • Storage: SQLite adjacency tables (graph_entities, graph_edges, graph_communities) + Qdrant embeddings for entity/fact search
  • Extraction: LLM-powered entity/relation extraction running in background (non-blocking)
  • Resolution: Exact-match entity deduplication (MVP), embedding-based resolution (follow-up)
  • Retrieval: Entity match + recursive CTE BFS + RRF fusion with existing vector/keyword results
  • Temporal: Bi-temporal edges (valid_from/valid_to for facts, created_at/expired_at for ingestion)
  • Feature flag: graph-memory (opt-in, zero impact on existing pipeline)

Design Documents

  • Research: .local/plan/graph-memory-research.md
  • Architecture: .local/plan/graph-memory-architecture.md
  • Critique: .local/plan/graph-memory-critique.md

Implementation Phases

Cross-Epic Dependencies (with #1195 Untrusted Content Isolation)

Graph Memory Security Epic Relationship
#1225 (extraction write) #1207 (memory write poisoning) Graph extraction is a new write path — poisoning guard must cover GraphStore writes
#1226 (graph retrieval) #1203 (memory retrieval sanitization) Graph recall is a new read path — sanitizer must cover graph_recall() output
#1223 (FuturesUnordered refactor) #1199 (context sanitizer, closed) Refactoring must preserve sanitizer integration from #1199
#1228 (community summaries) #1204 (quarantined summarizer) Shared pattern: isolated LLM call — first implemented sets the abstraction

Recommended order: #1207 before or with #1225; #1203 before or with #1226.

Follow-up Issues

Estimates

  • ~2800 LOC production + ~1300 LOC tests
  • 92 new tests across 6 phases
  • Feature-gated: zero impact when disabled

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestepicMilestone-level tracking issuegraph-memoryKnowledge graph memory featurememoryzeph-memory crate (SQLite)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions