fix(core): defer superseded vector generations - #1203
Merged
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
14 tasks
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.
Why
An older embedding job can prepare physical vector-manifest row IDs, wait for embedding generation, and resume after a newer entity generation has replaced those rows. Core treated every missing prepared row as corruption, so stale work could exhaust worker retries even though the newer job already owned convergence.
The persistence boundary needs to distinguish a superseded logical chunk generation from a manifest row that is unexpectedly missing for the current generation. Broadly swallowing the error would hide real corruption.
Closes #1200.
What Changed
Implementation Details
PendingEmbeddingJobnow contains the logical generation identity needed after the embedding await._persist_embeddingsvalidates that identity against the manifest when the physical row still exists. If the row disappeared, it reconstructs current chunks only for affected entities and compares(entity_id, chunk_key, source_hash).EmbeddingPersistenceResultmakes every row outcome explicit: persisted or superseded. The batch orchestrator fails if persistence does not classify every flushed row, and any superseded work keeps that entity out of the synchronized set. This preserves the newer generation's ownership without adding retries, a tenant-wide lock, or exception swallowing.The existing external-adapter manifest lock still spans adapter I/O and ready publication. Built-in adapters retain their generation-safe write behavior.
Testing
Vector manifest rows disappeared before writeand was counted failed.BASIC_MEMORY_TEST_POSTGRES=1 LOGFIRE_IGNORE_NO_CONFIG=1 uv run pytest -p pytest_mock --no-cov -q tests/repository/test_vector_manifest_generation_ownership.py --tb=short— 4 passed.just fast-check— Ruff format/lint andtytype checking passed.git diff --cached --check— passed before commit.Risks / Follow-ups