Engineering

The Librarian: auto-linking your knowledge graph

How background jobs compute TF-IDF and cosine similarity on every save so auto-linking stays fast, isolated, and fully reversible.

A personal knowledge base becomes exponentially more useful when memories are interconnected. Manually curating hyperlinks between hundreds of documents quickly becomes a chore — so an AI memory system needs an autonomous background mechanism to discover and weave connections between related memories.

The core challenge isn’t just calculating similarity: it is keeping this relationship discovery fast, decoupled, and completely isolated from real-time ingestion.

New Memory Saved Async Queue Zero write stall Relation Engine Lexical & Semantic overlap Threshold Gated Knowledge Graph Weighted Bi-directional

The Mechanics of Autonomous Graph Discovery

Rather than forcing heavy all-pairs calculations during synchronous user ingestion, relation discovery operates as an event-driven background pipeline:

  1. Decoupled Event Stream: Ingesting a note returns immediately to ensure sub-millisecond response times. A background worker picks up the newly indexed record.
  2. Feature Extraction: High-salience key terms and structural entities are vectorized.
  3. Similarity Gating: Candidates in the same workspace are scored against a confidence threshold, ensuring only genuine relationships form edges in the graph.

High-Level Algorithm

function DiscoverGraphRelations(newDocument, candidatePool):
    # Step 1: Extract feature representation
    targetVector = ExtractFeatureWeights(newDocument)
    
    discoveredEdges = []
    
    # Step 2: Evaluate similarity against candidate pool
    for candidate in candidatePool:
        if candidate.id == newDocument.id:
            continue
            
        score = CalculateCosineSimilarity(targetVector, candidate.vector)
        
        # Step 3: Threshold gate ensures quality over quantity
        if score >= RELATION_CONFIDENCE_THRESHOLD:
            discoveredEdges.append({
                sourceId: newDocument.id,
                targetId: candidate.id,
                weight: score,
                relationType: "RELATED_TO"
            })
            
    # Step 4: Persist bi-directional graph edges
    GraphStore.insertEdges(discoveredEdges)

Architectural Benefits

  • Non-Blocking Write Path: Document ingestion never waits on graph computation.
  • Dynamic Exploration: Agents can traverse 1-hop and 2-hop graph neighborhoods over the Model Context Protocol (MCP) to gather comprehensive context during complex research tasks.
All field notes

Kiomon Engineering

We build persistent context, knowledge, and memory infrastructure for AI agents over native MCP.

Give your AI agent a brain that remembers

Stream persistent context to Claude Code, Cursor, and any MCP agent with zero setup friction.

Get started free View docs