Repository navigation
Description
Summary
An embedding job can prepare vector-manifest row IDs, wait on embedding generation, and then fail terminally because a newer entity generation removed those old rows. Production later converged, so the Logfire fingerprint was optimistically resolved, but the worker semantics are still wrong: losing ownership to a newer generation is stale work, not a fatal storage invariant violation.
The fix must distinguish superseded old-generation rows from unexpectedly missing current-generation rows. Broadly swallowing the exception would hide real corruption.
Production evidence
Observed release: Cloud release 837b8c258ddb9ca78d0d9d897cec9202f7650c28, pinning Core revision de4589d24155332002709f5529c9bdd4937861a4.
Logfire issue #2234 — 7bdbc18a-a201-489e-aa0f-0978ce4cf216 — recorded 124 matches across production and development.
The failing job found 64 prepared manifest IDs missing and exhausted its retries. A newer same-entity job succeeded while the old job was unwinding, followed by several more successful jobs. Current read-only database verification showed 214 ready manifest rows, 214 embeddings, no missing embeddings, and no source-hash mismatches. Identifying tenant and note values are intentionally omitted.
Causal chain
- Job A prepares manifest rows and retains their physical row IDs.
- Job A awaits embedding generation.
- Job B observes a newer entity/content generation, creates replacement chunk keys, and removes the old manifest rows.
- Job A resumes and
_persist_embeddingsqueries its prepared row IDs. - Source-hash changes already classify work as stale and skip it, but physically missing old-generation rows raise
VectorManifestRowsDisappearedError. - Job A retries and can terminate even though job B already owns convergence and the final vector state is correct.
The vector adapter's generation-safe upsert is keyed by logical generation/chunk identity. The persistence layer should use that ownership information rather than treating every missing historical physical row as corruption.
Required outcome
When an embedding job resumes, determine whether each missing prepared row belongs to a superseded generation. Skip or explicitly mark that work superseded and let the newer generation own convergence. Continue to raise for a manifest row that should exist for the current generation.
Result accounting must not claim that an entity became synchronized if all of the job's work was superseded; it should report a stale/deferred outcome or otherwise preserve the newer generation's ownership.
Non-solutions
- Catching and ignoring every missing-manifest exception
- Increasing retries
- Preventing all concurrent embedding work with a tenant-wide lock
- Recreating deleted historical rows without checking generation ownership
Acceptance criteria
- A real PostgreSQL regression blocks job A after manifest preparation, lets job B replace/delete the old chunk generation, then resumes job A.
- Job A exits as superseded/deferred without terminal failure.
- Job B's current-generation manifests and embeddings remain ready and correct.
- Unexpected absence of a current-generation manifest still raises a visible correctness error.
- A fully superseded job does not mark the entity synchronized on its own.
- External and built-in vector adapters honor the same generation-ownership contract.
- Concurrent retries remain idempotent and do not resurrect stale chunks.
- The regression verifies final manifest/embedding parity and source-hash consistency.
Activity
claude commentedon Aug 6, 2026
Claude finished @phernandez's task in 2m 9s —— View job
Triage complete
Classification
buglabel already present).src/basic_memory/repository/semantic_vector_sync.py(VectorManifestRowsDisappearedError,_persist_embeddings). Labeledcloudsince the failure surfaces in the cloud embedding worker's job lifecycle, though the fix lives in this core repo._persist_embeddings, distinguish superseded-old-generation from missing-current-generation rows, keep both external and built-in vector adapters honoring the same contract, avoid falsely marking a fully-superseded job as "synchronized," and ship a real-Postgres regression that races job A against job B. This is architectural/behavioral work, not a quick patch.Duplicate check: Searched open/closed issues for
VectorManifestRowsDisappearedError,_persist_embeddings, and related terms — no existing duplicate found. This is a new, well-specified report with clear repro conditions, root cause, and acceptance criteria already included, so no reproduction/clarification request is needed.Labels:
bugandproductionwere already present. Repo label probing found the priority/component/complexity taxonomy described in my triage instructions (e.g.high,database,complex) does not exist in this repo — those--add-labelcalls were silently ignored, so no incorrect priority/complexity labels were applied. I did addcloud(valid, existing label, appropriate component tag).documentation,duplicate,enhancement,question. My available tools only permit adding labels (viaedit-issue-labels.sh), not removing them, so I could not undo this myself. Could a maintainer please remove these four labels from this issue? Apologies for the noise — final intended label state is justbug,production,cloud.No implementation work was started, per triage-only scope.