The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): rebuild a Desktop app whose artifacts an earlier update lost
teknium16b0a66576aa2
diff --git a/hermes_cli/AGENTS.md b/hermes_cli/AGENTS.mdindex 142a16e9ef7..c22640d8218 100644--- a/hermes_cli/AGENTS.md+++ b/hermes_cli/AGENTS.md@@ -115,8 +115,12 @@ it guards. `plan → snapshot → apply → restart-per-kind → verify → repo- **Apply**: git pull, or the Windows ZIP fallback — which fires ONLY when git itself failed(`_should_zip_fallback_on_update_error`, argv-classified; a dependency-install failure must nevertrigger a tree-clobbering re-download), REFUSES a dirty working tree (`-uall` + a pre-swap TOCTOU- re-check), and grafts the live `apps/desktop/release/` into the staged swap (the GitHub source- ZIP has no built desktop app; without the graft the swap deletes it).+ re-check — but ADMITS the gitignored build outputs below and `__pycache__/`, which every real+ install has), and grafts the live nested build outputs (`_ZIP_PRESERVED_NESTED`: `apps/desktop/+ {release,dist,node_modules}`, `hermes_cli/web_dist`) into the staged swap by hardlink (the GitHub+ source ZIP has none of them; without the graft the swap deletes them). Post-swap, the Desktop+ rebuild decision also trusts the build stamp under HERMES_HOME, so an install that already lost+ its artifacts in an earlier update is rebuilt instead of "forgotten" (#90495).- **Restart-per-kind**: systemd and launchd restarts are FLEET-WIDE (every `hermes-gateway*` unit /`ai.hermes.gateway*` LaunchAgent), drain-first (SIGUSR1), with per-unit/per-label failureisolation. Restarting only the invoking profile's service leaves siblings on stale `sys.modules`diff --git a/hermes_cli/main.py b/hermes_cli/main.pyindex 07e7456315d..abbe5bc6376 100644--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@ -815,6 +815,7 @@ from hermes_cli.main_desktop import ( # frozen updater surface: update_cmd*.py_desktop_dist_exists,_desktop_macos_relaunchable_fixup,_desktop_packaged_executable,+ _desktop_stamp_path,_install_rebuilt_desktop_app,)from hermes_cli.main_web_build import (diff --git a/hermes_cli/update_cmd_deps.py b/hermes_cli/update_cmd_deps.pyindex 4597384f813..05de64256b7 100644--- a/hermes_cli/update_cmd_deps.py+++ b/hermes_cli/update_cmd_deps.py@@ -914,9 +914,14 @@ def _rebuild_desktop_after_update(See #88251."""from hermes_cli.update_cmd import _m- # The release tree is git-ignored and can vanish mid-update; pre-update presence suffices.- # Never make people who never used Desktop pay for an Electron build.- has_desktop_app = had_desktop_app_before_update or _desktop_app_present(desktop_dir)+ # The release tree is git-ignored and can vanish mid-update; pre-update presence suffices. So does the+ # build stamp under HERMES_HOME: it outlives a swap that lost the artifacts in an earlier run, and+ # without it the install "forgets" Desktop was installed and never rebuilds (#90495). Never make+ # people who never used Desktop pay for an Electron build.+ has_desktop_app = (+ had_desktop_app_before_update+ or _desktop_app_present(desktop_dir)+ or _m()._desktop_stamp_path().is_file())if not ((desktop_dir / "package.json").exists() and _m()._resolve_node_runtime_npm() and has_desktop_app):return Truediff --git a/tests/hermes_cli/test_update_desktop_stale_warning.py b/tests/hermes_cli/test_update_desktop_stale_warning.pyindex c4f54c4c398..7d0eb165cc9 100644--- a/tests/hermes_cli/test_update_desktop_stale_warning.py+++ b/tests/hermes_cli/test_update_desktop_stale_warning.py@@ -56,6 +56,18 @@ def desktop_env(tmp_path, monkeypatch):def _install_rebuilt_desktop_app(_desktop_dir):return [], []+ @staticmethod+ def _desktop_packaged_executable(_desktop_dir):+ return None++ @staticmethod+ def _desktop_dist_exists(_desktop_dir):+ return False++ @staticmethod+ def _desktop_stamp_path():+ return tmp_path / "home" / "desktop-build-stamp.json"+monkeypatch.setattr(update_cmd, "_m", lambda: _FakeMain)monkeypatch.setattr("hermes_constants.with_hermes_node_path", lambda: {}, raising=False@@ -102,6 +114,27 @@ def test_up_to_date_desktop_returns_true_without_spawning(desktop_env):assert calls["builds"] == 0+def test_lost_desktop_with_surviving_build_stamp_is_rebuilt(desktop_env, monkeypatch):+ """#90495: a swap that lost release/ and dist/ in an EARLIER run leaves both presence terms false+ forever; the build stamp under HERMES_HOME survived and is the proof Desktop was installed here."""+ desktop_dir, calls = desktop_env+ monkeypatch.setattr(+ update_cmd._m(), "_run_logged_subprocess",+ staticmethod(lambda cmd, cwd=None, env=None: calls.__setitem__("builds", calls["builds"] + 1) or _Result(0)),+ )+ stamp = update_cmd._m()._desktop_stamp_path()+ stamp.parent.mkdir(parents=True)+ stamp.write_text('{"commit": "old"}', encoding="utf-8")++ assert _rebuild_desktop_after_update(desktop_dir, had_desktop_app_before_update=False) is True+ assert calls["builds"] == 1++ # Control: no stamp and no artifacts = Desktop was never installed here; nothing is built.+ stamp.unlink()+ assert _rebuild_desktop_after_update(desktop_dir, had_desktop_app_before_update=False) is True+ assert calls["builds"] == 1++def test_desktop_never_installed_returns_true(tmp_path, monkeypatch):spawned = []monkeypatch.setattr(