Store-owned retain: a failed retain leaves its document committed with no facts, so a retry is a no-op delta
Author: nicoloboschiCreated Oct 1, 2026Updated Oct 1, 2026
Found with hindsight-system-tests run against a store that owns its memories (store_owned = True). Postgres is unaffected.
Story: test_62_operation_failures.py::test_a_failed_operation_can_be_retried_after_the_cause_is_fixed — extraction fails, the cause is fixed, retry_operation runs, and the fact never appears.
What happens
retain_batch_asyncopens a retain session. The streaming producersession.adds the document's chunk texts (with the fullcontent_hash) before extraction finishes.- Extraction raises. The
finallyin_run_retain_executionstill callsretain_session.commit()— deliberately ("a retain that fails part-way must not discard what its earlier parts already produced"), andtest_retain_outbox_session.pypins it (failure == "retain"→steps == ["commit"]). - The store now holds the document, with its full content hash and zero facts.
- The retry runs
_try_delta_retain, which loads that document, sees an identical hash, and takes theDELTA RETAIN (no changes)path — nothing is re-extracted.
On Postgres the document row is written in the same transaction as the facts, so a failed extraction leaves no document and the retry does a full retain.
Possible fixes
- Abort the session (instead of committing) when the single-sub-batch path fails — the chunked path keeps commit-on-failure for the sub-batches that did finish.
- Or commit partial work without stamping the final
content_hash, so a later retain cannot mistake a failed document for a complete one.
Source: vectorize-io/hindsight