feat: backfill-embeddings and touch-on-search for dream health#48
Merged
Conversation
…ealth Three pathologies caused the dream to produce only boosts: 1. 444/680 memories lack embeddings, making them invisible to merge detection 2. Search/list never touch memories, so access_count never updates for the 307 never-accessed memories — making boost/decay/staleness detection unreliable 3. All memories are <30 days old, so decay never activates (grace period) Fix 1: backfill-embeddings CLI command generates embeddings for memories that lack them, unblocking merge detection in the dream's light phase. Fix 2: Touch on search and list CLI commands updates access_count and accessed_at, giving the dream accurate data for boost and staleness decisions. The age/grace period issue will resolve naturally as the database ages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three pathologies caused the dream to produce only boosts (193 boosted, 0 decayed/merged/invalidated):
Embedding gap: 444/680 active memories lack embeddings, making them invisible to the dream's merge detection (
ConsolidateDuplicatesonly queries memories with embeddings). Without embeddings, duplicate pairs can't be found, soMergedCountstays at 0.Stale access tracking: 307/680 memories have never been accessed (
accessed_at IS NULL). Search and list CLI commands don't updateaccess_count/accessed_at, so the dream's boost logic (threshold 5) and staleness detection work on incomplete data.Grace period: All memories are <30 days old, so the decay grace period means nothing qualifies for decay yet. This resolves naturally as the DB ages.
Changes
backfill-embeddingsCLI command: Finds memories without embeddings, generates them via Ollama/nomic-embed-text, and stores them. Supports--dry-runand--batch-sizeflags for progress reporting.searchCmdandlistCmdnow callTouchBatchon returned memories, updating theiraccessed_atandaccess_count.openStoreWithVec(): New helper that opens the store with vec0 enabled (needed for backfill to store embeddings in the vec table).Testing
All existing tests pass. Dream tests, store tests, and CLI tests all green.