Skip to content

The agent that grows with you

refactor(update): the startup half of a previous update runs from main_install_repair

Teknium2489694dae93
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index dcb4ee27f8b..57d85dcce2e 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -863,7 +863,7 @@ from hermes_cli.old_updater_main import (
_windows_shim_in_process_chain,
_write_web_ui_build_stamp,
)
-from hermes_cli.main_install_repair import _cleanup_quarantined_exes
+from hermes_cli.main_install_repair import _cleanup_quarantined_exes, _recover_update_debts_on_startup
from hermes_cli.main_install_repair import ( # frozen updater surface: update_cmd*.py resolve these via _m()
_UPDATE_REEXEC_ENV,
_clear_lazy_refresh_incomplete_marker,
@@ -3553,19 +3553,7 @@ def main():
# process resolves fresh source against old bytecode. Never raises.
_sweep_stale_bytecode_if_checkout_changed()
- # Dependency recovery already ran before imports. Report any fleet restart
- # still owed by a previous update without restarting services here.
- if "update" not in sys.argv[1:]:
- try:
- from hermes_cli.update_cmd_fleet import _warn_pending_fleet_restart_on_startup
-
- _warn_pending_fleet_restart_on_startup()
- except Exception:
- pass
- from hermes_cli.update_pause_record import recover as _recover_paused_gateways
- # Unconditional: recover() itself skips the PARSED `update`/`gateway run` commands; a raw argv
- # value equal to "update" (`--resume update`) is no reason to strand paused gateways.
- _recover_paused_gateways() # a killed `hermes update` left gateways paused (Windows)
+ _recover_update_debts_on_startup() # owed fleet restarts, gateways a killed update paused
if _first_positional_argv() != "update":
from hermes_cli.boot_bootstrap import maybe_run_boot_bootstrap
diff --git a/hermes_cli/main_install_repair.py b/hermes_cli/main_install_repair.py
index 676c1607572..1bc84258801 100644
--- a/hermes_cli/main_install_repair.py
+++ b/hermes_cli/main_install_repair.py
@@ -186,6 +186,23 @@ def _quarantine_stamp_ms(stale: Path) -> int | None:
return None
+def _recover_update_debts_on_startup() -> None:
+ """The startup half of a previous update, run on every launch before dispatch."""
+ # Dependency recovery already ran before imports. Report any fleet restart
+ # still owed by a previous update without restarting services here.
+ if "update" not in sys.argv[1:]:
+ try:
+ from hermes_cli.update_cmd_fleet import _warn_pending_fleet_restart_on_startup
+
+ _warn_pending_fleet_restart_on_startup()
+ except Exception: # a startup warning never blocks the launch it warns about
+ logger.debug("pending fleet restart check failed", exc_info=True)
+ from hermes_cli.update_pause_record import recover as _recover_paused_gateways
+ # Unconditional: recover() itself skips the PARSED `update`/`gateway run` commands; a raw argv
+ # value equal to "update" (`--resume update`) is no reason to strand paused gateways.
+ _recover_paused_gateways() # a killed `hermes update` left gateways paused (Windows)
+
+
def _cleanup_quarantined_exes(scripts_dir: Path | None = None) -> None:
"""Sweep — and where necessary RESCUE — ``hermes.exe.old.*`` from updates.