Skip to content

The agent that grows with you

chore(update): post-commit catch-all boundaries carry the code-health waiver

Teknium7b3dae822bfe
diff --git a/hermes_cli/source_build.py b/hermes_cli/source_build.py
index 086a1e9c12d..37e94aab5b4 100644
--- a/hermes_cli/source_build.py
+++ b/hermes_cli/source_build.py
@@ -130,7 +130,7 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:
try:
step()
return True
- except Exception as exc: # noqa: BLE001 — collected and raised after the independent steps
+ except Exception as exc: # health: allow BLE001 -- collected and raised after the independent steps
print(f" ⚠ {name} failed: {_failure_text(exc)}")
failures.append((name, exc))
return False
@@ -180,7 +180,7 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:
from hermes_cli.memory_provider_migration import migrate_all_homes
migrate_all_homes()
- except Exception as exc:
+ except Exception as exc: # health: allow BLE001 -- post-commit boundary: the failure is reported as a follow-up, never fails the committed update
print(f" ⚠ Memory provider migration skipped: {exc}")
# Same for a gateway platform / toolset that left core (Home Assistant): every home that used
# it gets its catalog plugin (hermes_cli/left_core_migration.py).
@@ -188,7 +188,7 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:
from hermes_cli.left_core_migration import migrate_all_homes as migrate_left_core
migrate_left_core()
- except Exception as exc:
+ except Exception as exc: # health: allow BLE001 -- post-commit boundary: the failure is reported as a follow-up, never fails the committed update
print(f" ⚠ Plugin migration skipped: {exc}")
if failures:
raise ProductBuildError(failures)
diff --git a/hermes_cli/source_completion.py b/hermes_cli/source_completion.py
index 603690ea25d..40cdccfdd31 100644
--- a/hermes_cli/source_completion.py
+++ b/hermes_cli/source_completion.py
@@ -105,7 +105,7 @@ def _complete_locked(
# config migration, the maintenance, or (in an update) the gateway restart after it.
try:
run()
- except (Exception, SystemExit) as exc: # noqa: BLE001 — reported as an owed follow-up
+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- reported as an owed follow-up
from hermes_cli.update_receipt import record_followup
reason = str(exc) or type(exc).__name__
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py
index 52c03ec25fe..965dec28612 100644
--- a/hermes_cli/update_cmd.py
+++ b/hermes_cli/update_cmd.py
@@ -747,7 +747,7 @@ def _resume_paused_gateways_at_exit(token: dict | None, request: dict | None) ->
return
try:
_m()._resume_windows_gateways_after_update(token)
- except Exception as exc: # noqa: BLE001 — a restart failure is owed, not the update's status
+ except Exception as exc: # health: allow BLE001 -- a restart failure is owed, not the update's status
from hermes_cli.update_receipt import _current, amend_terminal_followup, record_followup
reason = f"Windows gateway recovery failed: {exc}"
@@ -791,7 +791,7 @@ def _complete_source_update(request: dict | None) -> None:
# Dependencies owed (A6): the bootstrap child cannot resume paused gateways; this process can.
try:
_m()._resume_windows_gateways_after_update(token)
- except Exception as exc: # noqa: BLE001 — the code is committed (C3)
+ except Exception as exc: # health: allow BLE001 -- the code is committed (C3)
from hermes_cli.update_receipt import amend_terminal_followup, record_followup
reason = f"Windows gateway recovery failed: {exc}"
@@ -807,7 +807,7 @@ def _complete_source_update(request: dict | None) -> None:
try:
if adopt_retired_channel(request):
print(f"→ Source subscription moved to {request['channel_retirement']['destination']}")
- except Exception as exc: # noqa: BLE001 — the code is committed (C3); the next update re-adopts
+ except Exception as exc: # health: allow BLE001 -- the code is committed (C3); the next update re-adopts
from hermes_cli.update_receipt import amend_terminal_followup, record_followup
reason = str(exc) or type(exc).__name__
diff --git a/hermes_cli/update_cmd_fleet_verify.py b/hermes_cli/update_cmd_fleet_verify.py
index 9275e0f0660..59f092d95fe 100644
--- a/hermes_cli/update_cmd_fleet_verify.py
+++ b/hermes_cli/update_cmd_fleet_verify.py
@@ -346,6 +346,6 @@ def _verify_fleet_after_update(restart, *, _pre_update_plan, _windows_gateway_re
try:
from hermes_cli.gateway_migrate import maybe_auto_migrate_after_update
maybe_auto_migrate_after_update()
- except (Exception, SystemExit) as exc: # noqa: BLE001 — a SystemExit here must not fail a committed update
+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- a SystemExit here must not fail a committed update
logger.warning('Multiplex auto-migration after update failed: %s', exc)
print(f" ⚠ Gateway multiplex migration did not finish: {exc} (run `hermes gateway migrate` later)")
diff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.py
index 2c35430dc79..5504968d507 100644
--- a/hermes_cli/update_cmd_maint.py
+++ b/hermes_cli/update_cmd_maint.py
@@ -822,11 +822,11 @@ def _sweep_bytecode_after_update(branch: str) -> None:
if removed:
print(f" ✓ Cleared {removed} stale __pycache__ director{'y' if removed == 1 else 'ies'}")
_m()._record_bytecode_fingerprint()
- except Exception as exc: # noqa: BLE001 — owed to the next launch's fingerprint sweep
+ except Exception as exc: # health: allow BLE001 -- owed to the next launch's fingerprint sweep
record_followup("bytecode_sweep", str(exc) or type(exc).__name__)
try:
_m()._refresh_bootstrap_cache_scripts(branch)
- except Exception as exc: # noqa: BLE001 — refreshed again by the next update
+ except Exception as exc: # health: allow BLE001 -- refreshed again by the next update
record_followup("bootstrap_scripts", str(exc) or type(exc).__name__,
retry="the next `hermes update` refreshes them")
@@ -995,7 +995,7 @@ def _run_post_update_maintenance(
def owed_step(name, run):
try:
run()
- except (Exception, SystemExit) as exc: # noqa: BLE001 — the code is committed; retry later
+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- the code is committed; retry later
reason = str(exc) or type(exc).__name__
record_followup(name, reason)
if followups is not None:
diff --git a/hermes_cli/update_completion.py b/hermes_cli/update_completion.py
index 5767e2d8823..26d4f567a73 100644
--- a/hermes_cli/update_completion.py
+++ b/hermes_cli/update_completion.py
@@ -295,7 +295,7 @@ def _complete_selected(request: dict) -> bool:
completion_message=request.get("completion_message"),
announce=None if request.get("completion_message") else "\n✓ Code updated!",
followups=followups)
- except (Exception, SystemExit) as exc: # noqa: BLE001 — e.g. the shared update lock refused the tail
+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- e.g. the shared update lock refused the tail
reason = str(exc) or type(exc).__name__
record_followup("completion", reason)
followups.append(("completion", reason))
@@ -423,7 +423,7 @@ def _bootstrap(request: dict, request_path: Path, result_path: Path) -> int:
update_receipt.finalize_interrupted_update_receipt(
"KeyboardInterrupt: interrupted while installing dependencies", exit_code=130)
return _write_bootstrap_result(request, result_path, 130, _read_terminal_receipt(request))
- except (Exception, SystemExit) as exc: # noqa: BLE001 — after the commit point nothing fails the update
+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- after the commit point nothing fails the update
# The code is committed but its dependencies are not (A6): an owed follow-up, exit 0.
# Paused Windows gateways stay the parent's to resume (it has the dependencies).
return _settle_after_commit(request, result_path, "dependencies", str(exc) or type(exc).__name__)
diff --git a/hermes_cli/update_finish.py b/hermes_cli/update_finish.py
index 6ccc5df1bb6..acb56066c93 100644
--- a/hermes_cli/update_finish.py
+++ b/hermes_cli/update_finish.py
@@ -33,7 +33,7 @@ def finish_update(*, root, assume_yes, gateway_mode, pre_update_snapshot_id,
had_desktop_app_before_update=had_desktop_app_before_update,
pre_update_version=pre_update_version, followups=owed,
)
- except (Exception, SystemExit) as exc: # noqa: BLE001 — the code is committed; retry later
+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- the code is committed; retry later
reason = str(exc) or type(exc).__name__
record_followup("maintenance", reason)
owed.append(("maintenance", reason))
@@ -139,7 +139,7 @@ def main(context: Path, result: Path) -> int:
owed: list[tuple[str, str]] = []
try:
build_update_products(root, desktop=desktop)
- except (Exception, SystemExit) as exc: # noqa: BLE001 — committed code: owed, not failed
+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- committed code: owed, not failed
reason = str(exc) or type(exc).__name__
update_receipt.record_followup("build", reason)
owed.append(("build", reason))
diff --git a/tests/hermes_cli/test_web_server_update_status.py b/tests/hermes_cli/test_web_server_update_status.py
new file mode 100644
index 00000000000..7656849f5cb
--- /dev/null
+++ b/tests/hermes_cli/test_web_server_update_status.py
@@ -0,0 +1,88 @@
+"""Dashboard update status reads the ROOT home's shared update.log, correlated by action id."""
+
+import types
+
+import pytest
+
+import hermes_cli.web_server_gateway as _web_server_gateway
+
+
+class TestUpdateStatusRootLog:
+ @pytest.fixture(autouse=True)
+ def _setup_test_client(self, monkeypatch, _isolate_hermes_home):
+ """Create a TestClient and isolate the state DB under the test HERMES_HOME."""
+ try:
+ from starlette.testclient import TestClient
+ except ImportError:
+ pytest.skip("fastapi/starlette not installed")
+
+ import hermes_state
+ from hermes_constants import get_hermes_home
+ from hermes_cli.web_server import app, _SESSION_HEADER_NAME, _SESSION_TOKEN
+
+ monkeypatch.setattr(hermes_state, "DEFAULT_DB_PATH", get_hermes_home() / "state.db")
+
+ self.client = TestClient(app)
+ self.client.headers[_SESSION_HEADER_NAME] = _SESSION_TOKEN
+
+ def test_update_status_recovers_completed_result_after_dashboard_restart(self, monkeypatch, tmp_path):
+ # The dashboard runs under a profile home; ``hermes update`` mirrors to the ROOT home's
+ # update.log (main_dashboard), so the durable completion marker is read there.
+ root = tmp_path / "root"
+ (root / "logs").mkdir(parents=True)
+ monkeypatch.setenv("HERMES_HOME", str(root / "profiles" / "coder"))
+ action_id = "c" * 32
+ (tmp_path / "hermes-update.log").write_text(
+ f"=== hermes-update started 2026-08-17 11:19:34 {action_id} ===\n"
+ "pulling updates...\n",
+ encoding="utf-8",
+ )
+ (root / "logs" / "update.log").write_text(
+ "=== hermes update started 2026-08-17T11:19:35 ===\n"
+ "✓ Update complete!\n"
+ f"=== hermes-update completed {action_id} ===\n",
+ encoding="utf-8",
+ )
+ monkeypatch.setattr(_web_server_gateway, "_ACTION_LOG_DIR", tmp_path)
+ monkeypatch.setattr(_web_server_gateway, "_ACTION_PROCS", {})
+ monkeypatch.setattr(_web_server_gateway, "_ACTION_RESULTS", {})
+ monkeypatch.setattr(_web_server_gateway, "_ACTION_COMMANDS", {})
+ monkeypatch.setattr(_web_server_gateway, "_ACTION_IDS", {})
+
+ status = self.client.get("/api/actions/hermes-update/status?lines=2000")
+
+ assert status.status_code == 200
+ data = status.json()
+ assert data["running"] is False
+ assert data["exit_code"] == 0
+ assert data["action_id"] == action_id
+ assert f"=== hermes-update completed {action_id} ===" in data["lines"]
+
+
+ def test_update_status_ignores_another_profiles_completion_in_the_shared_root_log(self, monkeypatch, tmp_path):
+ # Every profile's ``hermes update`` mirrors into the ROOT update.log; profile A's success
+ # there must not certify the action profile B's dashboard started (and lost on restart).
+ root = tmp_path / "root"
+ (root / "logs").mkdir(parents=True)
+ monkeypatch.setenv("HERMES_HOME", str(root / "profiles" / "b"))
+ b_logs = tmp_path / "b-logs"
+ monkeypatch.setattr(_web_server_gateway, "_ACTION_LOG_DIR", b_logs)
+ for registry in ("_ACTION_PROCS", "_ACTION_RESULTS", "_ACTION_COMMANDS", "_ACTION_IDS"):
+ monkeypatch.setattr(_web_server_gateway, registry, {})
+ monkeypatch.setattr(_web_server_gateway.subprocess, "Popen", lambda *a, **kw: types.SimpleNamespace(pid=7))
+ b_id = "b" * 32
+ _web_server_gateway._spawn_hermes_action(["update"], "hermes-update", env_overrides={"HERMES_ACTION_ID": b_id})
+ _web_server_gateway._ACTION_PROCS.clear() # B's dashboard restarted: in-memory result lost
+
+ def status_after_root_completion(action_id):
+ (root / "logs" / "update.log").write_text(
+ "=== hermes update started 2026-08-17T11:19:35 ===\n"
+ f"=== hermes-update completed {action_id} ===\n", encoding="utf-8")
+ return self.client.get("/api/actions/hermes-update/status?lines=2000").json()
+
+ foreign = status_after_root_completion("a" * 32)
+ assert foreign["exit_code"] is None
+ assert "action_id" not in foreign
+ own = status_after_root_completion(b_id)
+ assert own["exit_code"] == 0
+ assert own["action_id"] == b_id