feat(healing): re-check membership mismatches before healing
A decision created moments before an audit shows up as missing=1 until the bouncer's next poll, which triggered a bouncer restart for nothing. When the audit finds a membership mismatch, wait membership_recheck_delay seconds (default 30, 0 disables) and audit again; only drift that is still present is reported and healed. Metadata drift is not delayed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79f72512e4
commit
772892b78d
7 files changed
+100
-3
No files matched your search
+23
@@ -88,6 +88,29 @@ def should_heal(history_file, drift_fingerprint, min_interval=900):
|
||||
return True
|
||||
|
||||
|
||||
def recheck_membership_mismatch(auditor, result, recheck_delay, wait=time.sleep):
|
||||
"""
|
||||
Re-audits after a short delay when the finding is a membership mismatch,
|
||||
so decisions the bouncer has not applied yet are not treated as drift.
|
||||
"""
|
||||
is_synced, _count, drift = result
|
||||
if is_synced or recheck_delay <= 0:
|
||||
return result
|
||||
if (drift or {}).get("reason") != "membership_mismatch":
|
||||
return result
|
||||
|
||||
logging.warning(
|
||||
f"Membership mismatch seen; re-checking in {recheck_delay}s before healing."
|
||||
)
|
||||
wait(recheck_delay)
|
||||
rechecked = auditor.reconcile()
|
||||
if rechecked[0]:
|
||||
logging.info("Membership mismatch cleared on re-check; no heal needed.")
|
||||
else:
|
||||
logging.warning("Drift persisted on re-check.")
|
||||
return rechecked
|
||||
|
||||
|
||||
def execute_heal_and_verify(auditor, reporter, count, drift, heal_verify_delay):
|
||||
"""
|
||||
Executes heal + post-heal verification and persists reporter state.
|
||||
|
||||
Reference in new issue
Block a user