fix(cli): surface reindex embedding failures and index identity - #1240
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ecc85d2c2d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Trigger: every entity attempted across the selected projects failed to embed. | ||
| # Why: requested search work and other project summaries must still finish first. | ||
| # Outcome: the command preserves useful output but no longer reports false success. | ||
| if embedding_entities_total > 0 and embedding_errors_total == embedding_entities_total: |
There was a problem hiding this comment.
Exclude skipped entities from the all-failed denominator
When a selected project contains any opted-out or already-current entity, total_entities includes it while errors does not, so every entity that actually required embedding can fail and this comparison still exits 0. For example, one embed: false note plus one eligible note that hits the manifest-ownership guard yields total_entities=2, skipped=1, and errors=1, followed by Reindex complete!; base the failure decision on entities that required vector work rather than all database entities.
AGENTS.md reference: AGENTS.md:L132-L133
Useful? React with 👍 / 👎.
| if not entity_ids: | ||
| return VectorSyncBatchResult( | ||
| entities_total=0, | ||
| entities_synced=0, | ||
| entities_failed=0, | ||
| ) | ||
| return await self.repository.sync_entity_vectors_batch([]) |
There was a problem hiding this comment.
Avoid initializing the vector backend for an empty batch
When reindex --embeddings is run before any entities have been indexed, this new call reaches sync_entity_vectors_internal, which invokes _ensure_vector_tables() before checking the empty list; for an external index such as unavailable Milvus, that connects to or even creates the remote collection and can fail before the CLI prints its intended No indexed entities found guidance. Preserve index/model identity without executing backend synchronization when there is no work.
Useful? React with 👍 / 👎.
Signed-off-by: phernandez <paul@basicmachines.co>
Closes #1237. Found live during the Milvus tire-kick (#1235):
reindex --embeddingsagainst a manifest owned by another vector index failed for all 226 entities, printed
"Reindex complete!", and exited 0 — with the instructive guard message visible only in
basic-memory.log.
What changed
VectorSyncBatchResultnow carriesvector_index,embedding_model, andsample_errors(first 3 distinct messages, normalized; recorded at everycontinue_on_errorcatch site including the orphan fail-safe).Embeddings complete (index=sqlite-vec, model=FastEmbedEmbeddingProvider:BAAI/bge-small-en-v1.5): ...and prints a single bounded
Representative error:line when errors occurred.command finishes its remaining phases (search reindex, other projects), prints
Reindex failed: all vector embedding attempts failed., and exits 1. Partial failurestays exit 0 with the sample error shown.
Sample output for the tire-kick scenario:
Verification
(dedupe, cap, orphan fail-safe), service propagation tests: 41 passed focused;
1,116-test prescribed sweep passed in codex's run.
just typecheck,just lint: clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01CPdSXDbYyhyZ1TwgFnpEv8