Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(e2e): make A7 fail-closed when the FLEET_METRIC family is absent [R3-M8]

Alfredo Lopez4d1209532d39
diff --git a/scripts/e2e/e2e-host-storm-gate.sh b/scripts/e2e/e2e-host-storm-gate.sh
index b1899559a..1015dd276 100755
--- a/scripts/e2e/e2e-host-storm-gate.sh
+++ b/scripts/e2e/e2e-host-storm-gate.sh
@@ -1451,26 +1451,34 @@ else:
# ── A7: recovered fleet convergence remains bounded (settled C2) ─────
fm = os.environ["FLEET_METRIC"]
-pre_failed = counter(b, fm, "result", "failed") - counter(a, fm, "result", "failed")
-post_started = counter(c2, fm, "result", "started")
-post_coalesced = counter(c2, fm, "result", "coalesced")
-post_trailing = counter(c2, fm, "result", "trailing")
-post_failed = counter(c2, fm, "result", "failed")
-problems = []
-if pre_failed != 0 or post_failed > 0:
- problems.append(f"fleet pass failures (pre={pre_failed:.0f} post={post_failed:.0f})")
-if os.environ.get("FLEET_COMPLETION_PROVEN") != "1":
- problems.append("replacement-pod initial fleet completion was not causally proven")
-if post_trailing > post_coalesced:
- problems.append(f"trailing={post_trailing:.0f} > coalesced={post_coalesced:.0f} (violates the single-pending-slot structure)")
-detail = (f"completion-proven={os.environ.get('FLEET_COMPLETION_PROVEN', 'missing')} "
- f"started={post_started:.0f} coalesced={post_coalesced:.0f} "
- f"trailing={post_trailing:.0f} failed={post_failed:.0f} "
- f"(replacement pod; A4 recovery-success fenced; pre-kill failed delta={pre_failed:.0f})")
-if problems:
- verdicts.append(("A7-fleet-recovery-bounded", False, "; ".join(problems) + f" [{detail}]"))
+# Presence check (A6 pattern): counter() returns 0 for an absent family, so
+# without this a renamed/unregistered FLEET_METRIC makes every count 0 and A7
+# passes vacuously. The causal leg (FLEET_COMPLETION_PROVEN) alone cannot catch
+# a metric rename — the metric itself must be registered on the running image.
+if fm not in c2_types:
+ verdicts.append(("A7-fleet-recovery-bounded", False,
+ f"{fm} not registered on the running image — is the branch HCC image deployed?"))
else:
- verdicts.append(("A7-fleet-recovery-bounded", True, detail))
+ pre_failed = counter(b, fm, "result", "failed") - counter(a, fm, "result", "failed")
+ post_started = counter(c2, fm, "result", "started")
+ post_coalesced = counter(c2, fm, "result", "coalesced")
+ post_trailing = counter(c2, fm, "result", "trailing")
+ post_failed = counter(c2, fm, "result", "failed")
+ problems = []
+ if pre_failed != 0 or post_failed > 0:
+ problems.append(f"fleet pass failures (pre={pre_failed:.0f} post={post_failed:.0f})")
+ if os.environ.get("FLEET_COMPLETION_PROVEN") != "1":
+ problems.append("replacement-pod initial fleet completion was not causally proven")
+ if post_trailing > post_coalesced:
+ problems.append(f"trailing={post_trailing:.0f} > coalesced={post_coalesced:.0f} (violates the single-pending-slot structure)")
+ detail = (f"completion-proven={os.environ.get('FLEET_COMPLETION_PROVEN', 'missing')} "
+ f"started={post_started:.0f} coalesced={post_coalesced:.0f} "
+ f"trailing={post_trailing:.0f} failed={post_failed:.0f} "
+ f"(replacement pod; A4 recovery-success fenced; pre-kill failed delta={pre_failed:.0f})")
+ if problems:
+ verdicts.append(("A7-fleet-recovery-bounded", False, "; ".join(problems) + f" [{detail}]"))
+ else:
+ verdicts.append(("A7-fleet-recovery-bounded", True, detail))
# ── A6: delete-cleanup counters consistent (settled window C2) ────────
dm = os.environ["DELETE_CLEANUP_METRIC"]
diff --git a/scripts/tests/test-host-storm-metric-gate.sh b/scripts/tests/test-host-storm-metric-gate.sh
index 829634095..e5d994bb5 100755
--- a/scripts/tests/test-host-storm-metric-gate.sh
+++ b/scripts/tests/test-host-storm-metric-gate.sh
@@ -32,6 +32,7 @@ clerum_hcc_host_delete_cleanup_total{outcome="confirmed"} 0
clerum_hcc_host_delete_cleanup_total{outcome="completed"} 0
clerum_hcc_host_delete_cleanup_total{outcome="retried"} 0
clerum_hcc_host_delete_cleanup_total{outcome="superseded"} 0
+# TYPE clerum_hcc_host_fleet_requests_total counter
clerum_hcc_host_fleet_requests_total{result="started"} ${fleet_started}
clerum_hcc_host_fleet_requests_total{result="coalesced"} ${fleet_coalesced}
clerum_hcc_host_fleet_requests_total{result="trailing"} ${fleet_trailing}
@@ -126,6 +127,21 @@ UNBOUNDED_TRAILING_OUTPUT="$(run_adjudicator "${WORK_DIR}/wake_healthy.prom")"
grep -Fq 'VERDICT|A7-fleet-recovery-bounded|FAIL|' <<<"$UNBOUNDED_TRAILING_OUTPUT" ||
fail "A7 false-passed trailing fleet work without a matching coalesced request"
+# M8: without the FLEET_METRIC family registered on the running image, counter()
+# returns 0 for every result label and A7 would pass vacuously (all-zero looks
+# like "no failures"). Strip the family's # TYPE line so it drops out of
+# c2_types (mirrors a metric rename / an image that never registered it) and
+# assert A7 FAILs on the presence check, not vacuously passes.
+write_metrics "${WORK_DIR}/c2.prom" 0 0 0 0 0
+grep -v '^# TYPE clerum_hcc_host_fleet_requests_total ' "${WORK_DIR}/c2.prom" \
+ >"${WORK_DIR}/c2.nofleet.prom"
+mv "${WORK_DIR}/c2.nofleet.prom" "${WORK_DIR}/c2.prom"
+MISSING_FAMILY_OUTPUT="$(run_adjudicator "${WORK_DIR}/wake_healthy.prom")"
+grep -Fq 'VERDICT|A7-fleet-recovery-bounded|FAIL|' <<<"$MISSING_FAMILY_OUTPUT" ||
+ fail "A7 vacuously passed with the FLEET_METRIC family absent from the scrape"
+grep -Fq 'not registered on the running image' <<<"$MISSING_FAMILY_OUTPUT" ||
+ fail "A7 failed for the wrong reason when the FLEET_METRIC family was absent"
+
WAKE_EVIDENCE_FUNCTION="$(
sed -n '/^_wake_urgent_evidence_recorded() {$/,/^}$/p' "$GATE"
)"