Complete M7.7 recovery verification before readiness

ADR-0065: before any readiness, recovery now verifies the head's tail.
The trace object must exist with its manifest digest, its header must
bind profile, region, predecessor and range; the predecessor (schema v6
load_region_commit) must hash to the digest the head names; replaying
the trace from the predecessor's verified payload must reproduce every
report and the exact head bytes; and trace-derived decisions must equal
the head's durable decisions. Missing, corrupt or non-reproducing tails
quarantine (RecoveryError::tail); nothing older or empty is served.

Test-only crash seams (HostConfig::crash_hook, PublishHooks) and
evo-server --crash-at deliver real SIGKILL at before-upload,
before-transaction, after-commit and after-ack. The kill matrix,
a SIGSTOP/SIGCONT stale owner and damaged-head startups all behave as
the durability contract requires; successors verify before readiness.

Validated: PostgreSQL suites under GCC Release, clang-tidy and
ASan/UBSan; tail-skip and replay-equality mutations each caught. No
Docker/Gitea CI, production-lease kill test or deployment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-28 22:31:40 -04:00
co-authored by Claude Opus 5.5
parent d6d0408aae
commit 30411a83f9
24 changed files with 990 additions and 284 deletions
+19
View File
@@ -216,6 +216,25 @@ load_region_checkpoint(Postgres& db, RegionKey key, milliseconds timeout) {
return CommittedCheckpoint{*head, std::move(*manifest)};
}
std::expected<CommittedCheckpoint, LeaseStoreFailure>
load_region_commit(Postgres& db, RegionKey key, std::uint64_t sequence, milliseconds timeout) {
const std::array<std::string, 3> p{std::to_string(key.world), std::to_string(key.region),
std::to_string(sequence)};
auto rows = db.query("SELECT * FROM evolution.load_region_commit($1::evolution.u64, "
"$2::evolution.u64, $3::evolution.u64)",
p, timeout);
if (!rows)
return std::unexpected{classify(rows.error())};
auto head = parse_head(*rows, 6);
if (!head || rows->size() != 1)
return std::unexpected{malformed(false)};
const auto& manifest_text = (*rows)[0][5];
auto manifest = manifest_text ? unhex_bytes(*manifest_text) : std::nullopt;
if (!manifest)
return std::unexpected{malformed(false)};
return CommittedCheckpoint{*head, std::move(*manifest)};
}
std::expected<RegionHead, LeaseStoreFailure>
publish_region_checkpoint(Postgres& db, std::span<const std::uint8_t> manifest,
std::span<const std::uint8_t> decisions, milliseconds timeout) {