fix(store): a stopped heal leaves no copy and no rebuild, and the bound names the heal

verify_and_heal copied the database aside before looking at the stop, so a
verification or an open that was stopped right after finding a drift left a
.mismatch copy behind. The look now comes first (heal_drift), before anything
is done: a stopped heal leaves the database and the folder exactly as they
were. The rebuild and its verification stay unstoppable once begun, since
stopped half way the live ledger would be part replayed.

INVARIANT 10's close bound said that heal was one pass over the journal and
named no term for it. It is about six (three in the rebuild, three in the
verification) plus the copy and one hash of each stored file, so it is now the
fourth named exception to the bound, with that cost, and 'an open stops
anywhere' says where it cannot.

Test: a stop before the heal leaves no copy and no rebuild; the same drift
heals when not stopped. It fails with the look moved back after the copy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 20:20:24 -07:00
1 parent 30e5fcf6da
commit 49ae7c0d13
4 files changed
+128 -30

No files matched your search

+2
View File
@@ -26,6 +26,8 @@
//! stop is looked at before it begins, never inside it. The database's
//! rebuild from the journal (`verify_and_heal`, healing a drift) is
//! one: stopped part way it would leave the live ledger part replayed.
//! The look comes before ANYTHING is done for the heal (the database
//! copied aside included), so a stopped heal leaves nothing behind.
//! ```
use crate::error::StoreError;