Skip to content

Graph-backed recall with JSONL sync #108

@ahoward

Description

@ahoward

Graph-Backed Recall with Audit Sync

Parent: #101 (Hippocampus v2)
Depends on: #102 (SQLite audit trail)
Priority: 3

What

`recall` is powered by the graph engine (CozoDB HNSW + Datalog), not SQLite scans. memories.db is write-only for normal operations. This issue ensures the two stay in sync and that the graph's full power is behind the simple `recall` verb.

How Recall Works Internally

When an agent calls `recall "authentication issues"`:

  1. Vector search: Embed query -> HNSW nearest neighbors on concepts (existing `/mind/search`)
  2. Graph traversal: For top results, walk 1-hop edges to find connected concepts (existing `/graph/neighbors`)
  3. Connection typing: Edges with CONFLICTS_WITH relation -> `conflict: true` flag on result
  4. Trust inference: Look up memory's `from_source` in memories.db -> assign trust tier
  5. Strength scoring: Combine vector similarity + recency + access count (existing decay scoring)
  6. Format: Return memories as `{id, what, from, tags, trust, strength, connections, conflict}`

This is what the graph buys us — a single `recall` call does semantic search, graph traversal, contradiction detection, and relevance scoring in one pass.

Auto-Connection on Remember

When a new memory is written:

  1. Embed the `what` field (existing behavior)
  2. Query HNSW for top-3 similar existing concepts (score > 0.7)
  3. Create `RELATES_TO` edges between the new concept and matches
  4. Return connections in the `remember` response

CozoDB handles this natively — edge create after vector search.

Audit Sync Guarantee

The dual-write from #102 ensures every graph write has a corresponding memories.db row. For sync validation:

  • Each memories.db row has `graph_id` pointing to the concept in mind.db
  • `brane admin verify` can cross-check: every memories.db row has a live concept, every concept has a memories.db row
  • Drift detected -> `brane admin rebuild` reconciles from memories.db

Acceptance Criteria

  • `recall` uses HNSW search + graph traversal (not SQLite scan)
  • `remember` auto-creates RELATES_TO edges to similar existing memories
  • `remember` response includes `connections` (top-3 similar)
  • Contradictions surfaced via CONFLICTS_WITH edges -> `conflict: true`
  • Trust tier included in recall results
  • `brane admin verify` cross-checks memories.db <-> mind.db consistency

Metadata

Metadata

Assignees

No one assigned

    Labels

    hippocampus-v2Brane Hippocampus v2 redesign

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions