Home/Docs/Architecture Decision Records/ADR-0011: Graph-First, Vector-Fallback

ADR-0011: Graph-First, Vector-FallbackπŸ”—

StatusπŸ”—

Accepted

ContextπŸ”—

Vector search (e.g., pgvector) is often treated as a silver bullet for retrieval. However, it struggles with precise entity relationships, hierarchical scope boundaries, and explicit access controls, leading to irrelevant or out-of-scope results.

DecisionπŸ”—

Graph-First, Vector-Fallback governs the Router graph-first memory read path. Its graph_first_retrieval.enabled C0 gate is off by default. When the gate is enabled, vector search is a fallback within that path.

Graph-First includes Engram discovery. After bounded seed selection, CellEdges expansion discovers related BrainCells and edges; a Brain-owned typed reverse lookup resolves the active BrainEngrams whose closed source refs contain that evidence. The Router then ranks and deduplicates the graph-expanded Engram set under its context budget. Implementations must batch this lookup and bound cycles, hops, relations, cells, Engrams, tokens, and query count.

When exact/structured/keyword seeding is insufficient, bounded vector search may produce fallback BrainCell seeds. Those candidates pass through the same tenant/scope checks, CellEdges expansion, and reverse Engram lookup once before raw vector results may fill a remaining gap. Vector results never bypass graph or Engram discovery, and the fallback cannot recursively start another vector pass.

Alternatives consideredπŸ”—

  • Pure vector-based semantic search for all retrieval. (Rejected: inaccurate for structured queries, harder to enforce strict tenant and graph boundaries).

ConsequencesπŸ”—

  • The enabled graph-first path enforces token-derived tenant and hierarchical scope_path first, uses structured/exact candidates to seed CellEdges traversal, resolves all related active BrainEngrams, and prefers their canonical/verified views over raw evidence before invoking pgvector.
  • Vector search is used to bridge semantic gaps only after structured boundaries have narrowed the search space.
  • Geospatial traversal is an optional extension consumer of this policy; the core scope_path contract is not a spatial coordinate system.

Non-goalsπŸ”—

  • Removing vector search entirely (it remains a powerful tool for unstructured semantic matching within a bounded subgraph).