Skip to content

Architecture: split memory-enrichment.ts and fix migration try/catch scope #77

Description

@qiyundai

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.tsbuildRetrievalText, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions