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)
  • re-embed: memories without a vector row get re-embedded without rewriting body

Architecture mirrors ingest_claude.rs: SCAN → JUDGE (LLM) → PERSIST, with a SQLite queue DB derived next to --db (GAP-SG-64) for resume/retry support.

§DRY note

v1.0.97: claude_runner.rs now hosts the shared Claude invocation helpers (run_claude, parse_claude_output, spawn_with_memory_limit). The queue DB schema in ingest_claude.rs still duplicates open_queue_db here — a future pass can unify them.

Structs§

DeadItem
GAP-SG-23: one dead-letter row reported by --list-dead.
DeadSummary
GAP-SG-23/11: summary footer for --list-dead and --requeue-dead.
EnrichArgs
Arguments for the enrich subcommand.
EnrichStatus
Read-only enrich --status report (no LLM, no singleton).
WaitingItem
GAP-SG-16: one pending queue row waiting on its backoff cooldown.

Enums§

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

Functions§

cleanup_queue_entry
GAP-SG-13: remove a memory’s enrich-queue entry when the memory is deleted or force-merged, so the dead-letter / pending sidecar never references a row that no longer exists. Best-effort and a no-op when the queue file is absent (the common case after a clean run, which removes it). Targets BOTH memory_id (populated at enqueue for memory ops, GAP-SG-12) and item_key (the memory name) so pending rows enqueued before id resolution are also cleared. Errors are logged, never propagated — cleanup must not fail the caller’s delete/upsert.
run
Main entry point for the enrich command.