The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor: count planned gateways by kind, document the deliberate limits
DavidMetcalfe2594c5786ffa
diff --git a/hermes_cli/update_inventory.py b/hermes_cli/update_inventory.pyindex 10a5474e9bf..47032dfc564 100644--- a/hermes_cli/update_inventory.py+++ b/hermes_cli/update_inventory.py@@ -423,7 +423,14 @@ def match_runtime_outcomes(be attributed to one successor (the fleet probe publishes at most one row per profile), so onereplacement cannot have replaced two planned processes. Such a profile keeps the name-pathverdict instead of letting an untouched sibling vanish behind a successor that can only have- replaced one of them.+ replaced one of them. That resolves conservatively on purpose: pairing a successor to the planned+ process it replaced would need a start-time identity that neither the plan record nor the fleet+ row carries, and a tripwire firing on an anomalous plan is the intended direction.++ Credit is deliberately NOT gated on restart bookkeeping either: the failure this fallback exists+ for already had bookkeeping (``restarted_services`` named the service label — only the+ profile↔label name match failed), and a gateway launchd respawned by itself has no restart-phase+ record at all while the fleet row still proves its successor runs the new code.See #91277.They never borrow the gateway's outcome: ``relaunched_profiles`` and ``hermes-gateway*`` name a@@ -450,9 +457,11 @@ def match_runtime_outcomes()# Baseline identity: the fleet probe publishes at most one row per profile, so successor# evidence is only attributable when the plan holds ONE gateway runtime for that profile.+ # Counted by kind explicitly: serve/dashboard rows for the same profile are different+ # processes and must never make a gateway's successor evidence look ambiguous.planned_gateways: dict[str, int] = {}for _planned in plan.runtimes:- if isinstance(_planned, RuntimeRecord) and _planned.kind not in _SERVE_KINDS:+ if isinstance(_planned, RuntimeRecord) and _planned.kind == "gateway":planned_gateways[_planned.profile] = planned_gateways.get(_planned.profile, 0) + 1def _outcome(r: RuntimeRecord) -> str:diff --git a/tests/hermes_cli/test_restart_plan_reconciliation.py b/tests/hermes_cli/test_restart_plan_reconciliation.pyindex c2b0f83dd1b..88aff7989fc 100644--- a/tests/hermes_cli/test_restart_plan_reconciliation.py+++ b/tests/hermes_cli/test_restart_plan_reconciliation.py@@ -536,15 +536,18 @@ def test_successor_credit_stays_per_profile_with_several_planned_runtimes():def test_successor_evidence_is_gateway_only_and_stays_optional():"""Serve/dashboard rows reconcile in their own vocabulary, and callers that- pass no ``live_gateway_pids`` keep the bookkeeping-only verdict."""+ pass no ``live_gateway_pids`` keep the bookkeeping-only verdict. Two non-gateway+ rows for the same profile must not make the gateway's evidence look ambiguous:+ the baseline count is per gateway kind."""outcomes = match_runtime_outcomes(- _plan(_rt("coder", 76508, supervisor="launchd"), _serve("coder", 900)),+ _plan(_rt("coder", 76508, supervisor="launchd"),+ _serve("coder", 900), _serve("coder", 901, kind="dashboard")),restarted_services=[], relaunched_profiles=[],externally_supervised_profiles=[], killed_pids=set(), failed_units=[],live_gateway_pids={"coder": {76796}},)by_pid = {o["pid"]: o["outcome"] for o in outcomes}- assert by_pid == {76508: "restarted", 900: "unaccounted"}+ assert by_pid == {76508: "restarted", 900: "unaccounted", 901: "unaccounted"}without_probe = match_runtime_outcomes(_plan(_rt("coder", 76508, supervisor="launchd")),