The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fixup: keep main.py and update_failure_class under their health caps
Tekniumf05d29821378
diff --git a/hermes_cli/main.py b/hermes_cli/main.pyindex 347984bcada..7e9ea1efb3e 100644--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@ -2324,13 +2324,12 @@ def _update_preflight_handled(args) -> bool:"""Managed-install refusal, --plan, admission gate, --check. True = nothing more to do."""from hermes_cli.config import is_managed, managed_errorfrom hermes_cli.update_channel import handle_metadata_args+ from hermes_cli.update_cmd_common import _record_stopif handle_metadata_args(args, PROJECT_ROOT):sys.exit(0)if is_managed():managed_error("update Hermes Agent")- from hermes_cli.update_cmd_common import _record_stop-_record_stop("managed_install", without_receipt="refused") # before the lock: a metrics row onlyreturn True@@ -2361,15 +2360,10 @@ def _update_preflight_handled(args) -> bool:sys.exit(VENV_HOLDERS_EXIT)return True- # Image/package-managed admission gate: baked provenance marker first- # (fail-closed on malformed), then docker/nix/apt heuristics. Records a- # `refused` receipt and exits 2 (refused-by-contract, distinct from errors).- # Image-managed / package-managed admission gate (#91277 Phase 3): one shared decision for every- # mutation surface. Prints the real update command, records a `refused` receipt so fleet tooling sees- # the blocked attempt, and exits 2 (refused-by-contract, distinct from exit 1 errors).- # Shared admission gate (#91277 Phase 3): same marker-first decision as the apply path, so --check can- # never report git state for an install whose real update mechanism is an image pull.- # The response keeps the pre-existing per-kind error codes the dashboard UI already keys on. See #91277.+ # Image/package-managed admission gate (#91277 Phase 3): baked provenance marker first (fail-closed+ # on malformed), then docker/nix/apt heuristics; one shared decision for every mutation surface, so+ # --check never reports git state for an image-managed install. Prints the real update command,+ # records a `refused` receipt and exits 2 (refused-by-contract, distinct from exit 1 errors).from hermes_cli.update_contract import (evaluate_update_admission,record_refusal_receipt,@@ -2427,12 +2421,9 @@ def cmd_update(args):print(describe_holder(_update_lock.holder))_finalize_update_output(_update_io_state)from hermes_cli.update_cmd_common import _record_stop-- # No receipt: latest.json and the running record belong to the update holding the lock.- _record_stop("lock_held", without_receipt="refused")+ _record_stop("lock_held", without_receipt="refused") # no receipt: latest.json is the holder'ssys.exit(UPDATE_EXIT_CONCURRENT)-from hermes_cli.update_cmd import _cmd_update_implfrom pm import InstallErrordiff --git a/hermes_cli/observability/shared_metrics_update.py b/hermes_cli/observability/shared_metrics_update.pyindex c756d0f7299..25841c7de7a 100644--- a/hermes_cli/observability/shared_metrics_update.py+++ b/hermes_cli/observability/shared_metrics_update.py@@ -61,7 +61,8 @@ _OS_ERROR_TYPES = frozenset(_SUBPROCESS_ERROR_TYPES = frozenset({"CalledProcessError", "SubprocessError", "TimeoutExpired"})# Exception type name -> class, first match wins; any other type reads ``exception``._EXCEPTION_TYPE_CLASSES = (- (_PM_ERROR_TYPES, "deps_failed"), (_OS_ERROR_TYPES, "os_error"), (_SUBPROCESS_ERROR_TYPES, "subprocess_failed"),+ (frozenset({"PermissionError"}), "permission_denied"), (_PM_ERROR_TYPES, "deps_failed"),+ (_OS_ERROR_TYPES, "os_error"), (_SUBPROCESS_ERROR_TYPES, "subprocess_failed"),)# Fixed stop-reason prefixes Hermes itself writes (only the prefix is read, never what follows):# _update_takeover's preparation failure and update_completion's Windows gateway resume failure.@@ -91,6 +92,21 @@ def _restart_incomplete(receipt: dict[str, Any]) -> bool:isinstance(row, dict) and row.get("outcome") == "failed" for row in outcomes)+def _named_stop(receipt: dict[str, Any], stages: list[dict[str, Any]]) -> str | None:+ """The class the run named itself: the user's parked changes on a committed run, or the closed+ ``stop_class`` a pre-apply exit recorded (read only while nothing was applied)."""+ from .shared_metrics_contract import UPDATE_STOP_CLASSES++ if receipt.get("outcome") == "partial" and receipt.get("user_action"):+ # Committed; only the user's stashed changes are owed (record_user_action, exit 1). Since C3+ # this is the only ``partial`` a receipt gets; older releases' verification wrote it too.+ return "local_changes_parked"+ stop_class = receipt.get("stop_class")+ if stop_class in UPDATE_STOP_CLASSES and not any(s["name"] == "apply" for s in stages):+ return stop_class+ return None++def update_failure_class(receipt: dict[str, Any], stages: list[dict[str, Any]], outcome: str) -> str:"""Why a failed/refused/partial run stopped, from fields the FINAL receipt already carries.@@ -99,8 +115,6 @@ def update_failure_class(receipt: dict[str, Any], stages: list[dict[str, Any]],never outlive the exit that recorded it. Parked copies (update_receipt._metric_receipt) carryevery field read here except the free text; copies parked by older releases have no ``schema``."""- from .shared_metrics_contract import UPDATE_STOP_CLASSES-if outcome not in {"failed", "refused"}:return "none"raw_steps = receipt.get("steps")@@ -114,13 +128,8 @@ def update_failure_class(receipt: dict[str, Any], stages: list[dict[str, Any]],exc_type = match.group(1) if match else ""if exc_type == "KeyboardInterrupt" or exit_code == 130:return "interrupted"- if receipt.get("outcome") == "partial" and receipt.get("user_action"):- # Committed; only the user's stashed changes are owed (record_user_action, exit 1). Since C3- # this is the only ``partial`` a receipt gets; older releases' verification wrote it too.- return "local_changes_parked"- stop_class = receipt.get("stop_class")- if stop_class in UPDATE_STOP_CLASSES and not any(s["name"] == "apply" for s in stages):- return stop_class+ if named := _named_stop(receipt, stages):+ return namedif outcome == "refused":# Exit 2 at the command boundary is the updater's refusal convention; on main the only# open-receipt exit 2 is another updater holding the lock (update_finish).@@ -140,8 +149,6 @@ def update_failure_class(receipt: dict[str, Any], stages: list[dict[str, Any]],return by_reasonif _DISK_FULL_ERRNO.match(reason):return "disk_full"- if exc_type == "PermissionError":- return "permission_denied"if exc_type:return next((cls for types, cls in _EXCEPTION_TYPE_CLASSES if exc_type in types), "exception")marked = {s["name"] for s in stages}