feat(reporter): count heals the gate suppresses
CI / Unit tests (push) Successful in 4s
CI / Unit tests (pull_request) Successful in 3s

A drift whose fingerprint matches a heal from the last heal_min_interval
seconds was counted as a drift event but never as a heal attempt, so the
24h counters showed a drift with no heal and no failure. Decide on the
heal before recording the check and report heals_suppressed_24h and
heals_suppressed_total, so every drift event is either a heal attempt
or a suppressed heal. The suppression warning now names the earlier
heal that did not hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-19 18:04:24 -04:00
1 parent 02ca338eb7
commit 4e8a4d6717
5 files changed
+50 -11

No files matched your search

+18
View File
@@ -54,6 +54,7 @@ class LocalStateReporter:
"drift_heal_attempts": max(0, int(metrics.get("drift_heal_attempts", 0))),
"heals": max(0, int(metrics.get("heals", 0))),
"heal_failures": max(0, int(metrics.get("heal_failures", 0))),
"heals_suppressed": max(0, int(metrics.get("heals_suppressed", 0))),
}
return normalized
@@ -63,6 +64,7 @@ class LocalStateReporter:
now_epoch,
drift_events_increment,
heal_result,
heal_suppressed=False,
):
current_hour = int(now_epoch // 3600)
min_hour = current_hour - 23
@@ -83,6 +85,7 @@ class LocalStateReporter:
"drift_heal_attempts": 0,
"heals": 0,
"heal_failures": 0,
"heals_suppressed": 0,
},
)
@@ -92,11 +95,14 @@ class LocalStateReporter:
bucket["heals"] += 1
if heal_result != "success":
bucket["heal_failures"] += 1
if heal_suppressed:
bucket["heals_suppressed"] += 1
drift_events_24h = sum(v["drift_events"] for v in buckets.values())
drift_heal_attempts_24h = sum(v["drift_heal_attempts"] for v in buckets.values())
heals_24h = sum(v["heals"] for v in buckets.values())
heal_failures_24h = sum(v["heal_failures"] for v in buckets.values())
heals_suppressed_24h = sum(v["heals_suppressed"] for v in buckets.values())
return (
buckets,
@@ -104,6 +110,7 @@ class LocalStateReporter:
drift_heal_attempts_24h,
heals_24h,
heal_failures_24h,
heals_suppressed_24h,
)
def update_status(
@@ -120,9 +127,13 @@ class LocalStateReporter:
checks_increment=0,
drift_events_increment=0,
heal_result=None,
heal_suppressed=False,
):
"""
Writes the current health snapshot to a JSON file.
heal_suppressed marks a drift the heal gate skipped because the same drift was
healed moments ago, so every drift event is either a heal attempt or a suppressed heal.
"""
previous = self._load_previous_state()
effective_heal_result = (
@@ -159,6 +170,9 @@ class LocalStateReporter:
drift_heal_attempts_total += 1
if heal_result != "success":
heal_failures_total += 1
heals_suppressed_total = max(0, self._get_int(previous, "heals_suppressed_total", 0))
if heal_suppressed:
heals_suppressed_total += 1
(
rolling_24h_buckets,
@@ -166,11 +180,13 @@ class LocalStateReporter:
drift_heal_attempts_24h,
heals_24h,
heal_failures_24h,
heals_suppressed_24h,
) = self._roll_24h_counters(
previous=previous,
now_epoch=now_epoch,
drift_events_increment=drift_events_increment,
heal_result=heal_result,
heal_suppressed=heal_suppressed,
)
uptime_seconds = max(0, int(now_epoch - self.started_at_epoch))
@@ -197,6 +213,8 @@ class LocalStateReporter:
"heal_failures_24h": heal_failures_24h,
"heals_total": heals_total,
"heal_failures_total": heal_failures_total,
"heals_suppressed_24h": heals_suppressed_24h,
"heals_suppressed_total": heals_suppressed_total,
"_rolling_24h_buckets": rolling_24h_buckets,
}