memory-enrichment.ts module split
The file mixes four concerns in ~424 lines: NER/entity extraction, retrieval-text construction, DB persistence (persistMemoryEntities), and temporal relationship writing (recordTemporalRelationshipsForUpdate). This makes it hard to test extraction logic independently and will grow unwieldy as the relationship API expands.
Suggested split:
entity-extraction.ts — NER, regex constants, extractEntityRefs
retrieval-text.ts — buildRetrievalText, snippet helpers
- Keep DB writers in
memory-enrichment.ts or move to a dedicated memory-persistence.ts
Migration try/catch wrapping 6 tables
In schema.ts, all six new CREATE TABLE + ten CREATE INDEX statements from PR #72 are wrapped in a single try { db.exec(...) } catch { /* already exists */ } block. If any statement fails for a reason other than "already exists" (FK reference order, constraint name collision, etc.) the entire block is silently swallowed and the DB is left in an unknown partial state.
Fix: Give each table its own guarded block, matching the per-column try/catch pattern used for existing-table migrations elsewhere in the file.
memory-enrichment.ts module split
The file mixes four concerns in ~424 lines: NER/entity extraction, retrieval-text construction, DB persistence (
persistMemoryEntities), and temporal relationship writing (recordTemporalRelationshipsForUpdate). This makes it hard to test extraction logic independently and will grow unwieldy as the relationship API expands.Suggested split:
entity-extraction.ts— NER, regex constants,extractEntityRefsretrieval-text.ts—buildRetrievalText, snippet helpersmemory-enrichment.tsor move to a dedicatedmemory-persistence.tsMigration try/catch wrapping 6 tables
In
schema.ts, all six newCREATE TABLE+ tenCREATE INDEXstatements from PR #72 are wrapped in a singletry { db.exec(...) } catch { /* already exists */ }block. If any statement fails for a reason other than "already exists" (FK reference order, constraint name collision, etc.) the entire block is silently swallowed and the DB is left in an unknown partial state.Fix: Give each table its own guarded block, matching the per-column
try/catchpattern used for existing-table migrations elsewhere in the file.