Skip to main content

Module enrich

Module enrich 

Source
Expand description

Handler for the enrich CLI subcommand (GAP-14 + GAP-18).

Enriches the knowledge graph by running LLM-powered analysis over memories and entities that are missing key structural data. Operations are:

  • memory-bindings: memories without memory_entities rows get entity extraction
  • entity-descriptions: entities with NULL/empty descriptions get LLM descriptions
  • body-enrich: memories with short bodies get expanded by the LLM (GAP-18)
  • all others: scan + structured NDJSON output (not-yet-implemented dispatch)

Architecture mirrors ingest_claude.rs: SCAN → JUDGE (LLM) → PERSIST, with a SQLite queue DB (.enrich-queue.sqlite) for resume/retry support.

§DRY opportunity

extract_with_claude, parse_claude_output, emit_json, and the open_queue_db queue schema in ingest_claude.rs are private functions that duplicate patterns used here verbatim. A future refactoring could extract them into a shared src/commands/llm_runner.rs module (or src/llm_runner.rs) without changing any public APIs. That extraction requires editing ingest_claude.rs, which is outside this stream’s boundary — flagged here for the Integration stream to evaluate.

Structs§

EnrichArgs
Arguments for the enrich subcommand.

Enums§

EnrichMode
LLM provider for enrichment.
EnrichOperation
Operation to perform in the enrich command.

Functions§

run
Main entry point for the enrich command.