fix: keep leftover recipe history envelope after a mid-put crash - #1310
Conversation
If history/v{N}.json already snapshots the current live row, the
previous put died between the two renames. Do not overwrite that
archive on the next successful write; only advance live.
Co-authored-by: Cursor <cursoragent@cursor.com>
CI E2E report — ❌ Failed
|
…-skip-stale-history-overwrite
The skip-overwrite guard must prove the leftover archive snapshots current live. An unreadable file cannot prove that, so fall through to the overwrite path instead of raising LocalRecipeStoreError, which would leave the canonical_id permanently unwritable. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Follow-up on review: two notes, one code change.
|
Description
put_recipefirst writes an archive copy of the current live row at version N, then replaces the live row with N+1: two independent atomic writes. A crash between those two renames leaves the live row at N while the archive for N already exists. The next successful put used to overwrite that archive — the same snapshot, but a freshreplaced_by/archived_atenvelope, discarding the provenance recorded by the interrupted write.If the archive for the current live version already holds that same snapshot, it is now left alone and only the live row advances. This is not a two-phase journal: a crash still drops the in-flight N+1 payload.
Linked issue(s)
None.
Tests
50 passed on the targeted tests.
ruff check/ruff format --checkon the changed files passed.Breaking changes
No. Archive envelopes that already match the live row are no longer rewritten.