You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory graph is dead in production: edges table has no writer #307
Code audit finding (memory-server): the 'edges' table (src/db.js:215) has no production writer — nothing in src/ inserts edges, only tests do (test/graph.test.js). Consequences: the graph retriever's 2-hop BFS (src/memory.js:495-630) degenerates to a direct mentions lookup, relation semantics are unused, and there is no memory_expand tool to traverse the graph.
Either wire a writer (entity co-occurrence within entries is free; LLM-extracted relations at write time is the stronger version, and write-time entity resolution is the consistent lesson from the memory-systems research) or remove the dead retriever leg. Note: entity extraction is also regex-only (wikilinks, file extensions, PascalCase; src/extract.js), and kinds repo/agent/tool are declared but never produced.
Wire the writer, not delete the leg.linkEntities() (src/memory.js:247) already resolves entities and writes mentions at store time — co-occurrence edges are ~10 lines in that same loop, and they bring the existing 130-line BFS in graphSearch() alive without touching it.
relation = 'co_occurs', pairs normalised src<dst so an unordered pair is one row, INSERT OR IGNORE on the existing PK.
One-shot backfill for existing DBs: edges derived from mentions via self-join, guarded by a janitor_state key.
Bounded for free — extractEntities() already caps at 15 entities/entry → ≤105 pairs.
Deliberately out of scope:
memory_expand tool — that's a new feature, not the reported bug. File separately if an agent actually needs manual traversal.
LLM-extracted relations — adds a provider dep and network latency to a write path that has neither. Co-occurrence is the free version; typed relations are the upgrade path if relation semantics ever get a consumer.
extract.js regex-only extraction and the unused repo/agent/tool kinds — harmless as-is, no consumer blocked.
linkEntities() collects resolved entity ids and writes one co_occurs edge per unordered pair, src<dst normalised so a pair is never mirrored into two rows.
One-shot backfill derives edges from pre-existing mentions via self-join, guarded by janitor_state.edges_backfill_v1.
Tests cover: no mirrored duplicates; graphSearch() genuinely reaching a 2-hop entry (A mentions X+Y, B mentions Y+Z, query on X returns B); backfill populating and not double-running.
Found on review, fixed separately (a63ea48): the edges PK indexes src as its leading column, so the UNION half of the BFS neighbour probe — WHERE dst = ? — was a full table scan, executed once per dequeued node. EXPLAIN QUERY PLAN confirmed SCAN edges. Free while the table was empty; not free now that each entry writes up to 105 rows. Added idx_edges_dst. No index on entry_id — that path is deleteEntry only, not a loop.
Activity
currentbits commentedon Aug 17, 2026
Approach decided (grok worker
a926f13dimplementing):Wire the writer, not delete the leg.
linkEntities()(src/memory.js:247) already resolves entities and writesmentionsat store time — co-occurrence edges are ~10 lines in that same loop, and they bring the existing 130-line BFS ingraphSearch()alive without touching it.relation = 'co_occurs', pairs normalised src<dst so an unordered pair is one row,INSERT OR IGNOREon the existing PK.edgesderived frommentionsvia self-join, guarded by ajanitor_statekey.extractEntities()already caps at 15 entities/entry → ≤105 pairs.Deliberately out of scope:
memory_expandtool — that's a new feature, not the reported bug. File separately if an agent actually needs manual traversal.extract.jsregex-only extraction and the unused repo/agent/tool kinds — harmless as-is, no consumer blocked.currentbits commentedon Aug 17, 2026
Implemented and verified on
coder/memory-graph-is-dead-in-production-edges-fba1f2(65bbd70+a63ea48). 131/131 memory-server tests pass.linkEntities()collects resolved entity ids and writes oneco_occursedge per unordered pair,src<dstnormalised so a pair is never mirrored into two rows.mentionsvia self-join, guarded byjanitor_state.edges_backfill_v1.graphSearch()genuinely reaching a 2-hop entry (A mentions X+Y, B mentions Y+Z, query on X returns B); backfill populating and not double-running.Found on review, fixed separately (
a63ea48): theedgesPK indexessrcas its leading column, so the UNION half of the BFS neighbour probe —WHERE dst = ?— was a full table scan, executed once per dequeued node.EXPLAIN QUERY PLANconfirmedSCAN edges. Free while the table was empty; not free now that each entry writes up to 105 rows. Addedidx_edges_dst. No index onentry_id— that path isdeleteEntryonly, not a loop.Left open pending merge to main.
Merge pull request #327 from currentbits/coder/memory-graph-is-dead-i…