Skip to content

feat: typed auto-edges — self-wiring knowledge graph on every remember() #346

Closed

Description

@ajianaz

Motivation

Inspired by GBrain's self-wiring graph — every put_page extracts entity refs via pure pattern matching (zero LLM calls) and creates typed edges. This produces +31.4 P@5 improvement over vector-only RAG.

Uteke currently stores relationships in a JSON metadata blob (graph.rs), which is:

  • Manual (user must specify relationships)
  • O(n) scan for incoming edges (get_related loops all memories)
  • No auto-extraction from content

Proposal

Auto-extract entity references on every remember() call using pure string parsing — no LLM.

Edge Table (new SQLite table)

CREATE TABLE IF NOT EXISTS memory_edges (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    source_id TEXT NOT NULL,
    target_id TEXT NOT NULL,
    edge_type TEXT NOT NULL,
    created_at TEXT NOT NULL,
    FOREIGN KEY (source_id) REFERENCES memories(id),
    FOREIGN KEY (target_id) REFERENCES memories(id)
);
CREATE INDEX idx_edges_source ON memory_edges(source_id);
CREATE INDEX idx_edges_target ON memory_edges(target_id);
CREATE INDEX idx_edges_type ON memory_edges(edge_type);

Extraction Patterns (zero LLM)

Pattern Edge Type Example
[[memory-slug]] references [[rust-async]] → references
@tag-name tagged_as @security → tagged_as
^memory-id supersedes ^abc123 → supersedes
>uuid replies_to >def456 → replies_to
Existing metadata.relationships (as-is) Backward compatible

New CLI Commands

uteke edges <memory-id>          # list all edges (outgoing + incoming)
uteke edges <memory-id> --deep   # multi-hop traversal (BFS, configurable depth)
uteke graph                       # show graph summary (node count, edge count, density)

Migration from Current System

  • Existing metadata.relationships JSON field → auto-migrate to memory_edges table
  • graph.rs parse_relationships() → deprecate, use table queries
  • get_related() → rewrite as SQL JOIN (currently O(n) scan)
  • recall_related() → use table-based BFS (faster, no metadata parsing)

Scope

  • Add memory_edges SQLite table + migration (schema v5)
  • Implement pattern-based entity extraction in remember() flow
  • Rewrite get_related() to use SQL instead of JSON scan
  • Rewrite recall_related() BFS to use edge table
  • Add uteke edges CLI subcommand
  • Add uteke graph CLI subcommand (summary stats)
  • Migration script: metadata.relationships → memory_edges rows
  • Tests: extraction patterns, traversal, deduplication, cycle detection

Non-Goals

  • LLM-based entity extraction (out of scope — pure pattern matching only)
  • External knowledge graph formats (RDF, etc.)
  • Graph visualization (separate issue)

References

Activity

  1. added this to the milestone on Jun 14, 2026
  2. added
    enhancement
    scope:core
    type:feature
    priority:high
    epic:memory-engine
    next-up
    on Jun 14, 2026
  3. modified the milestones: , v0.2.1 — DX & Ecosystem on Jun 14, 2026
  4. added a commit that references this issue on Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementepic:memory-enginenext-uppriority:highscope:coretype:feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions