fix(healing): judge post-heal verification against the pre-heal decisions
A decision issued in the seconds between a heal and its verification is missing from the kernel until the bouncer's next poll, so verification reported the heal as failed even though it had fixed the drift it was started for. Seen on a node: a metadata heal fixed a stale TTL, a new ban arrived inside the 5 s window, and the heal was logged as failed; the next audit found the node in sync. reconcile() now records the decision values it saw (last_truth_values) and takes an optional baseline_truth. Post-heal verification passes the values the drift was found against; values whose LAPI membership changed since then are left out of the drift, logged with a count, returned as lapi_changed_values, and checked by the next regular audit. Drift on decisions that existed when the heal started still fails verification. The regular audit and the membership re-check are unchanged. Tests: baseline handling in reconcile, the verification call, and a replay of the logged sequence (failed before, success now). 78 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6cb7fae06a
commit
16338a2507
5 files changed
+161
-4
No files matched your search
+10
-2
@@ -118,6 +118,10 @@ def execute_heal_and_verify(auditor, reporter, count, drift, heal_verify_delay):
|
||||
Executes heal + post-heal verification and persists reporter state.
|
||||
"""
|
||||
drift = drift or {}
|
||||
# The decisions the drift was found against. Verification is judged against
|
||||
# them, so a decision issued after the heal started (which the bouncer only
|
||||
# applies on its next poll) is not counted as a failed heal.
|
||||
baseline_truth = getattr(auditor, "last_truth_values", None)
|
||||
if hasattr(auditor, "heal_with_drift"):
|
||||
heal_ok = auditor.heal_with_drift(drift)
|
||||
else:
|
||||
@@ -138,7 +142,10 @@ def execute_heal_and_verify(auditor, reporter, count, drift, heal_verify_delay):
|
||||
)
|
||||
time.sleep(heal_verify_delay)
|
||||
try:
|
||||
post_is_synced, post_count, post_drift = auditor.reconcile()
|
||||
if baseline_truth is None:
|
||||
post_is_synced, post_count, post_drift = auditor.reconcile()
|
||||
else:
|
||||
post_is_synced, post_count, post_drift = auditor.reconcile(baseline_truth=baseline_truth)
|
||||
heal_result = "success" if post_is_synced else "failed"
|
||||
verify_error = None if post_is_synced else "Post-heal verification failed"
|
||||
reporter.update_status(
|
||||
@@ -159,7 +166,8 @@ def execute_heal_and_verify(auditor, reporter, count, drift, heal_verify_delay):
|
||||
f"post={post_drift.get('fingerprint', '')} "
|
||||
f"missing={post_drift.get('missing_count', 0)} "
|
||||
f"extra={post_drift.get('extra_count', 0)} "
|
||||
f"metadata={post_drift.get('metadata_drift_count', 0)}"
|
||||
f"metadata={post_drift.get('metadata_drift_count', 0)} "
|
||||
f"lapi_changed={len(post_drift.get('lapi_changed_values', []))}"
|
||||
)
|
||||
except Exception as e:
|
||||
heal_result = "verify_error"
|
||||
|
||||
Reference in new issue
Block a user