The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): a moved HEAD holds paused gateways for dependencies only where a launch syncs them
Tekniume9803548f59b
diff --git a/hermes_cli/update_pause_record.py b/hermes_cli/update_pause_record.pyindex 426723cac97..51310dda389 100644--- a/hermes_cli/update_pause_record.py+++ b/hermes_cli/update_pause_record.py@@ -13,7 +13,7 @@ says nothing about the other tree.Resuming is gated on a whole tree: no interrupted-pull marker; at the pre-update HEAD, no trackedchange beyond the ones present at pause time (git died before moving HEAD); at a moved HEAD,-dependencies current for it (a build step may rewrite tracked files there). Every pause folded into+dependencies current for it where a launch syncs them (a build step may rewrite tracked files there). Every pause folded intoa record keeps its own baseline (``baselines``): each one taken at the current HEAD must hold.Otherwise the record stays for the next launch, which runs after the interrupted-pull restore andthe dependency sync.@@ -210,11 +210,26 @@ def stamp_tree(token: dict, root: Path | None = None) -> dict:return token-def _venv_is_current(root: Path) -> bool:+def _deps_hold_resume(root: Path) -> bool:+ """At a moved HEAD: are stale dependencies a reason to keep the paused set stopped?++ Only where waiting converges. A self-managed install (``updateMechanism: self``) syncs its+ dependencies at the start of every launch (``venv_sync.prepare_launch``), before startup+ recovery runs, so a deferred set comes back on the next launch. Anywhere else nothing a launch+ does makes them current (a developer checkout owns its own venv): the set resumes now, as it+ did before the pause was durable, and a currency the probe cannot establish never holds it+ either — the restarted gateway's own launch syncs or reports the remedy.+ """+ if (os.environ.get("HERMES_DISABLE_LAZY_INSTALLS", "").lower() in ("1", "true", "yes")+ or not (root / ".git").exists() or not (root / "pyproject.toml").is_file()):+ return False # prepare_launch skips the sync: waiting would never endtry:+ from hermes_cli.steward import read_install_stamp+ if read_install_stamp(root).get("updateMechanism") != "self":+ return Falseimport pm- return bool(pm.venv_is_current(project_root=root))- except Exception: # health: allow BLE001 -- fail closed: any error reading the venv state means "not current", so paused gateways stay stopped+ return not pm.venv_is_current(project_root=root)+ except Exception: # health: allow BLE001 -- unknown currency must not strand the set: resume, the gateway's own launch syncs or names the remedyreturn False@@ -241,7 +256,7 @@ def tree_is_whole(token: dict, root: Path | None = None) -> tuple[bool, str]:if unexpected:return False, f"the checkout has {len(unexpected)} file(s) git left half-written (e.g. {unexpected[0]})"return True, ""- if not _venv_is_current(root):+ if _deps_hold_resume(root):return False, "dependencies are not current for the updated code yet"return True, ""diff --git a/tests/hermes_cli/test_update_pause_record.py b/tests/hermes_cli/test_update_pause_record.pyindex 92621ec3fcd..a4538832181 100644--- a/tests/hermes_cli/test_update_pause_record.py+++ b/tests/hermes_cli/test_update_pause_record.py@@ -106,12 +106,12 @@ def test_resume_waits_for_a_whole_tree(tmp_path):assert pause_record.tree_is_whole(token, root)[0] is Falsemarker.unlink()- _git(root, "commit", "-qam", "v2") # HEAD moved: only a dependency sync for it makes it whole+ _git(root, "commit", "-qam", "v2") # HEAD moved: judged on its dependencies alone(root / "b.py").write_text("rewritten by a build step\n", encoding="utf-8")- whole, why = pause_record.tree_is_whole(token, root)- # A committed update is judged on its dependencies alone; a tracked file the build rewrote- # must not keep the gateways stopped on every later launch.- assert not whole and "dependencies" in why, why+ # A committed update: a tracked file the build rewrote must not keep the gateways stopped on+ # every later launch, and on a checkout whose launches never sync dependencies (this one has+ # no install stamp) waiting for them would never end either (review 5411136378).+ assert pause_record.tree_is_whole(token, root) == (True, "")def test_an_update_adopting_an_orphan_never_certifies_the_tree_it_left_torn(tmp_path, monkeypatch):@@ -149,7 +149,7 @@ def test_an_adopted_baseline_never_replaces_this_runs_own(tmp_path, monkeypatch)owner=pause_record.UNOWNED)(root / "a.py").write_text("v2\n", encoding="utf-8")_git(root, "commit", "-qam", "Y") # the killed update moved HEAD, synced Y's dependencies, then died- monkeypatch.setattr(pause_record, "_venv_is_current", lambda root: True)+ monkeypatch.setattr(pause_record, "_deps_hold_resume", lambda root: False)adopted, claims = pause_record.adopt_orphans()token = pause_record.record_pause({"resume_needed": True, "profiles": {"beta": 99}}, adopted, claims)@@ -685,3 +685,31 @@ def test_the_tree_gate_finds_pm_git_and_runs_it_in_the_updaters_custody(tmp_pathmonkeypatch.setenv("PATH", str(tmp_path / "no-git"))assert pause_record.head_sha(root) == headassert ran == [pm_git], "the gate's git bypassed update_custody.run_git"++[email protected]("mechanism, probe, holds", [+ ("self", lambda **kw: False, True), # the next launch syncs first: deferring converges+ ("self", lambda **kw: True, False),+ ("self", lambda **kw: (_ for _ in ()).throw(ValueError("invalid recorded dependency state")), False),+ (None, lambda **kw: False, False), # nothing a launch does makes them current: main resumed+])+def test_a_moved_head_holds_gateways_for_dependencies_only_where_a_launch_syncs_them(+ tmp_path, monkeypatch, mechanism, probe, holds):+ """Review 5411136378 decision (moved HEAD): stale dependencies defer the resume only where the+ next launch makes them current; an unknown currency never strands a committed update's set."""+ import pm+ from hermes_cli import steward+ root = tmp_path / "checkout"+ root.mkdir()+ _git(root, "init", "-q")+ (root / "pyproject.toml").write_text("[project]\nname = 'x'\n", encoding="utf-8")+ _git(root, "add", ".")+ _git(root, "commit", "-qm", "v1")+ token = pause_record.stamp_tree({"resume_needed": True}, root)+ _git(root, "commit", "-q", "--allow-empty", "-m", "v2") # the update moved HEAD+ monkeypatch.delenv("HERMES_DISABLE_LAZY_INSTALLS", raising=False)+ monkeypatch.setattr(steward, "read_install_stamp", lambda r: {"updateMechanism": mechanism} if mechanism else {})+ monkeypatch.setattr(pm, "venv_is_current", probe)+ whole, why = pause_record.tree_is_whole(token, root)+ assert whole is not holds, why+ assert not holds or "dependencies" in why