Skip to content

The agent that grows with you

fix: log missing successor evidence for a planned gateway

DavidMetcalfeb7bb7685d31c
diff --git a/hermes_cli/update_cmd_fleet.py b/hermes_cli/update_cmd_fleet.py
index 21023ca9fa9..aec6e660123 100644
--- a/hermes_cli/update_cmd_fleet.py
+++ b/hermes_cli/update_cmd_fleet.py
@@ -2008,9 +2008,11 @@ def _verify_fleet_after_update(restart, *, _pre_update_plan, _windows_gateway_re
if _pre_update_plan is not None and _pre_update_plan.runtimes:
from hermes_cli.update_inventory import (match_runtime_outcomes, report_unaccounted_runtimes)
from hermes_cli.update_receipt import row_is_external
- # Gateway incarnation evidence: a service can serve a profile its own name does not
- # encode (root-home launchd label + sticky active profile, hashed custom HERMES_HOME),
- # so the bookkeeping's service names alone cannot credit the planned runtime.
+ # Gateway incarnation evidence, from the post-restart fleet snapshot collected above: a
+ # service can serve a profile its own name does not encode (root-home launchd label +
+ # sticky active profile, hashed custom HERMES_HOME), so the bookkeeping's service names
+ # alone cannot credit the planned runtime. A profile the probe produced no row for simply
+ # has no evidence — that runtime stays on the name-matching path (and logs it).
_live_gateway_pids = _live_gateway_pids_from_fleet(_fleet_snapshot)
_runtime_outcomes = match_runtime_outcomes(
_pre_update_plan,
diff --git a/hermes_cli/update_inventory.py b/hermes_cli/update_inventory.py
index 5483ca5e520..c5c17adea65 100644
--- a/hermes_cli/update_inventory.py
+++ b/hermes_cli/update_inventory.py
@@ -479,6 +479,15 @@ def match_runtime_outcomes(
live = successors.get(r.profile)
if live and r.pid not in live:
return "restarted"
+ if not live:
+ # No row for this profile: the fallback has nothing to work with and reconciliation
+ # stays on the service-name path. Logged because the tripwire below reads identically
+ # whether the evidence was missing or the restart was actually missed.
+ logger.debug(
+ "No post-restart gateway evidence for profile %r (planned pid %s via %s) — "
+ "reconciling on restart bookkeeping alone",
+ r.profile, r.pid, r.restart_via,
+ )
return "external" if r.pid in external else "unaccounted"
for r in plan.runtimes:
diff --git a/tests/hermes_cli/test_restart_plan_reconciliation.py b/tests/hermes_cli/test_restart_plan_reconciliation.py
index 48cbdc02bdc..457b4d858cc 100644
--- a/tests/hermes_cli/test_restart_plan_reconciliation.py
+++ b/tests/hermes_cli/test_restart_plan_reconciliation.py
@@ -450,6 +450,23 @@ def test_gateway_successor_credit_requires_a_live_replacement():
assert empty_evidence[0]["outcome"] == "unaccounted"
+def test_missing_successor_evidence_is_logged(caplog):
+ """A profile the fleet probe has no row for logs why reconciliation stayed on
+ the name-matching path: the tripwire output reads identically whether the
+ evidence was missing or the restart was genuinely missed."""
+ import logging
+
+ with caplog.at_level(logging.DEBUG, logger="hermes_cli.update_inventory"):
+ outcomes = match_runtime_outcomes(
+ _plan(_rt("coder", 76508, supervisor="launchd")),
+ restarted_services=["ai.hermes.gateway"], relaunched_profiles=[],
+ externally_supervised_profiles=[], killed_pids=set(), failed_units=[],
+ live_gateway_pids={},
+ )
+ assert outcomes[0]["outcome"] == "unaccounted"
+ assert "No post-restart gateway evidence for profile 'coder'" in caplog.text
+
+
def test_successor_evidence_never_outranks_stopped_or_failed():
"""Bookkeeping verdicts stay authoritative when the incarnation evidence is
also passed: the successor branch is reached only after them, so a killed or