fix(update): re-embed files whose vectors are missing

Merged
LE
7d ago
+252-22

Follow-up to #298. vera update only compared file hashes, so after .vera/vectors.db was deleted (or lost rows) it reported the index as up to date and search stayed keyword-only until a full vera index.

  • Update compares the vec_chunks row count with the metadata chunk count. The vector database is read with a read-only connection, so a missing file is not created and the flat sidecar is not loaded. Measured on a 336k-chunk index: about 40 ms warm, and the counts match exactly on a healthy index.
  • When the counts differ it compares ids: every unchanged file with a chunk lacking a vector is re-embedded through the normal modified-file path, and vectors whose chunk is gone are deleted so the counts agree again. Partial loss re-embeds only the affected files.
  • The search warning for a missing vector database now says run \vera update .` to restore vector search`.
  • Moved a misplaced doc comment back onto remove_file_parse_data.

Tests: update_restores_lost_vectors_for_unchanged_files covers one file's vectors deleted (1 modified, 1 unchanged), the whole database deleted (2 modified), a no-op follow-up, and an orphan vector being removed. End to end with the CLI: warning on search, update re-embeds both files, search clean, second update reports up to date.

Summary by CodeRabbit

  • Bug Fixes
    • vera update . now detects and restores missing vectors without re-indexing the entire collection, and removes vectors that no longer correspond to indexed content.
    • Search guidance now recommends vera update . when indexed content is missing vectors.
  • Documentation
    • Updated troubleshooting guidance and v2.1.3 release notes to reflect vector recovery during updates.