Skip to content

The agent that grows with you

fix(telemetry): a partial update with a failed build or restart keeps that failed_stage

Tekniumce1463987917
diff --git a/hermes_cli/observability/shared_metrics_update.py b/hermes_cli/observability/shared_metrics_update.py
index 7ed77391ff0..6899aa4be18 100644
--- a/hermes_cli/observability/shared_metrics_update.py
+++ b/hermes_cli/observability/shared_metrics_update.py
@@ -169,10 +169,12 @@ def _receipt_stages(receipt: dict[str, Any]) -> list[dict[str, Any]]:
# The fleet matrix is only passed to finalize by the post-restart verification.
if isinstance(fleet, list) and fleet and not any(s["name"] == "verify" for s in stages):
# ---- iuf c1 ----
- # ``partial`` is written only by update_cmd_fleet._verify_fleet_after_update, so verification
- # failed even when every fleet row reads current (zero rows expected, an unaccounted runtime,
- # a dashboard that did not come back, a Windows resume failure).
- bad = _fleet_bad(receipt) or receipt.get("outcome") == "partial"
+ # ``partial`` is written only by update_cmd_fleet._verify_fleet_after_update, which also
+ # writes it for a failed build or restart; with no failed stage mark, verification itself
+ # failed even when every fleet row reads current (zero rows expected, an unaccounted
+ # runtime, a dashboard that did not come back, a Windows resume failure).
+ bad = _fleet_bad(receipt) or (
+ receipt.get("outcome") == "partial" and not any(s.get("outcome") == "failed" for s in stages))
# ---- end iuf c1 ----
stages.append({
"name": "verify", "outcome": "failed" if bad else "success",
diff --git a/tests/hermes_cli/test_shared_metrics_install_failures.py b/tests/hermes_cli/test_shared_metrics_install_failures.py
index 59dc2d53da7..645f0b70e89 100644
--- a/tests/hermes_cli/test_shared_metrics_install_failures.py
+++ b/tests/hermes_cli/test_shared_metrics_install_failures.py
@@ -104,6 +104,18 @@ def test_a_failed_update_whose_every_stage_passed_names_where_and_why_it_failed(
}
[email protected](("failed", "failure_class"), [("build", "build_failed"), ("restart", "restart_failed")])
+def test_a_partial_run_with_a_failed_stage_keeps_that_stage_and_its_verify_row_passes(failed, failure_class):
+ """Invariant: the verification writes ``partial`` for a failed build or restart too, so a
+ failed stage mark (not the synthetic verify stage) is where the run failed."""
+ stages = [(name, "failed" if name == failed else result) for name, result in _ALL_PASSED]
+ extra = {"gateway_restart": {"incomplete": True}} if failed == "restart" else {}
+ run, stage_rows = update_metrics.update_receipt_fields(
+ _receipt("partial", stages, exit_code=1, fleet=[{"state": "current"}], **extra))
+ assert (run["failed_stage"], run["failure_class"]) == (failed, failure_class)
+ assert [(s["stage"], s["outcome"]) for s in stage_rows if s["outcome"] == "failed"] == [(failed, "failed")]
+
+
@pytest.mark.parametrize(("receipt", "expected"), [
(_receipt("success", _ALL_PASSED), "none"),
(_receipt("refused", [], steps=[{"name": "admission", "ok": False}], stop_reason="docker"), "managed_install"),
diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.md
index 434fb679c47..68c09ef6893 100644
--- a/website/docs/developer-guide/relay-shared-metrics.md
+++ b/website/docs/developer-guide/relay-shared-metrics.md
@@ -506,7 +506,7 @@ they failed. Rows recorded before the change keep their old field set and still
| Metric | Dimensions added | Question it answers |
|---|---|---|
| `hermes.extension.install.count` | failure class, registry | Why skill, plugin and MCP installs fail, and which skills-hub source fails. `failure_class` is `none` on success, else a closed name for the failure exit that stopped the install. Skills: `ambiguous`, `auth_rejected`, `fetch_failed`, `invalid_bundle`, `invalid_name`, `not_found`, `rate_limited`, `scan_blocked`, `stale_index`. Plugins: `already_installed`, `clone_failed`, `deps_declined`, `deps_failed`, `git_missing`, `incompatible`, `invalid_source`, `manifest_invalid`, `non_interactive`, `removed_from_catalog`, `scan_blocked`. MCP servers: `auth_required`, `bootstrap_failed`, `clone_failed`, `config_invalid`, `config_rejected`, `connect_failed`, `git_missing`, `missing_credentials`, `server_start_failed`. Every kind may also read `exception`, `filesystem_error`, `network`, `other`, `permission`. A raised error without a named class is classified by its Python type only (`PermissionError` reads `permission`, connection and timeout errors `network`, other `OSError`s `filesystem_error`, anything else `exception`, its type name dropped). `registry` is set on skill rows only: the skills-hub adapter that resolved or served the skill, one of `browse-sh`, `clawhub`, `github`, `hermes-index`, `lobehub`, `official`, `skills-sh`, `url`, `well-known` (the adapter ids `tools/skills_hub_search.py::create_source_router` builds), `unresolved` when no adapter answered, `none` for built-in restores and every plugin/MCP row, `other` otherwise. Never the identifier, URL, error text or path; `name` keeps its existing catalog-or-`custom` rule. |
-| `hermes.update.run` | failure class | Why `hermes update` fails, next to where (`failed_stage`). `none` unless the outcome is `failed` or `refused`. Derived from the final update receipt only: `aborted_before_apply`, `build_failed`, `deps_failed`, `exception`, `fleet_stale`, `fleet_unverified`, `git_failed`, `interrupted`, `lock_held`, `managed_install`, `os_error`, `restart_failed`, `subprocess_failed`, else `other`; Desktop packaged self-updates report `unknown` (their RPC carries a stage, never a reason). An exception that ended the run is read by its type name alone, never its message. A failed run whose every stage mark passed now reads `failed_stage` `verify` (the post-restart verification wrote `partial`) or `restart` (a skipped restart left the fleet owing one) instead of `other`. |
+| `hermes.update.run` | failure class | Why `hermes update` fails, next to where (`failed_stage`). `none` unless the outcome is `failed` or `refused`. Derived from the final update receipt only: `aborted_before_apply`, `build_failed`, `deps_failed`, `exception`, `fleet_stale`, `fleet_unverified`, `git_failed`, `interrupted`, `lock_held`, `managed_install`, `os_error`, `restart_failed`, `subprocess_failed`, else `other`; Desktop packaged self-updates report `unknown` (their RPC carries a stage, never a reason). An exception that ended the run is read by its type name alone, never its message. A failed run whose every stage mark passed now reads `failed_stage` `verify` (the post-restart verification wrote `partial`) or `restart` (a skipped restart left the fleet owing one) instead of `other`; a `partial` run with a failed build or restart mark keeps that stage, and its verify stage row is failed only when the fleet has a stale or down row. |
<!-- ---- end iuf c1 ---- -->
<!-- ---- iuf c2 ---- -->
#### Fresh installs