The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): the paused-gateway tree gate finds PM's git and runs it in the update's custody
Teknium1f6a9ba106c2
diff --git a/hermes_cli/update_pause_record.py b/hermes_cli/update_pause_record.pyindex eb9a54516bc..426723cac97 100644--- a/hermes_cli/update_pause_record.py+++ b/hermes_cli/update_pause_record.py@@ -41,6 +41,7 @@ import globimport hashlibimport jsonimport os+import shutilimport subprocessimport sysimport threading@@ -137,12 +138,38 @@ def _mutex(wait_s: float = _MUTEX_WAIT_S):os.close(fd)+def _git_executable() -> str:+ """The git ``hermes update`` runs, found without installing anything: PATH's, else the copy+ install.ps1 staged in PM's store (``_subprocess_compat.expose_pm_git`` puts it on PATH only+ inside the updater). A bare ``git`` on such an install dies with WinError 2, so every gate+ read would fail and the paused gateways would never be restarted."""+ found = shutil.which("git")+ if found:+ return found+ with suppress(Exception): # health: allow BLE001 -- no PM, no store, no Windows git package: PATH's answer ("git") stands+ import pm+ from pm import paths+ from pm.lock import Lockfile++ recorded = pm.installed_package("git", allow_outdated=True)+ if recorded is not None and recorded.binary is not None and recorded.binary.is_file():+ return str(recorded.binary)+ package, target = pm.get_package("git"), pm.current_target()+ version = Lockfile(paths.lockfile_path()).version("git")+ staged = package.binary(paths.store_root() / package.store_entry(version, target), target)+ if staged is not None and staged.is_file():+ return str(staged)+ return "git"++def _git(root: Path, *args: str) -> subprocess.CompletedProcess | None:+ """A read-only git query in the updater's custody (``update_custody.run_git``: job-bound on+ Windows inside an update, custody config in argv); ``None`` when git cannot run."""+ from hermes_cli.update_custody import run_gittry:- return subprocess.run(- ["git", "-C", str(root), *args], capture_output=True, text=True, encoding="utf-8",- errors="replace", stdin=subprocess.DEVNULL, timeout=30, check=False)- except (OSError, subprocess.SubprocessError):+ return run_git([_git_executable(), "-C", str(root)], args, capture_output=True, text=True,+ encoding="utf-8", errors="replace", stdin=subprocess.DEVNULL, timeout=30, check=False)+ except (OSError, ValueError, subprocess.SubprocessError):return Nonediff --git a/tests/hermes_cli/test_update_pause_record.py b/tests/hermes_cli/test_update_pause_record.pyindex fc3333bafe2..92621ec3fcd 100644--- a/tests/hermes_cli/test_update_pause_record.py+++ b/tests/hermes_cli/test_update_pause_record.py@@ -660,3 +660,28 @@ def test_a_host_without_psutil_records_an_identity_the_liveness_rule_can_prove(mident = pause_record.identity()assert ident["ct"] is not None, "no creation time without psutil"assert update_lock.incarnation_live(ident["pid"], ident["ct"]) is True+++def test_the_tree_gate_finds_pm_git_and_runs_it_in_the_updaters_custody(tmp_path, monkeypatch):+ """Review 5411136378 fix 3: on an install whose only git is PM's staged copy (no git on PATH),+ a bare ``git`` made ``head_sha`` None, so ``tree_is_whole`` refused forever."""+ import shutil+ from types import SimpleNamespace++ import pm+ from hermes_cli import update_custody+ root = tmp_path / "checkout"+ root.mkdir()+ _git(root, "init", "-q")+ (root / "a.py").write_text("v1\n", encoding="utf-8")+ _git(root, "add", ".")+ _git(root, "commit", "-qm", "v1")+ head, pm_git = _git(root, "rev-parse", "HEAD"), shutil.which("git")+ ran, real_run_git = [], update_custody.run_git+ monkeypatch.setattr(update_custody, "run_git", lambda cmd, args, **kw: ran.append(cmd[0]) or real_run_git(cmd, args, **kw))+ monkeypatch.setattr(pm, "installed_package",+ lambda name, allow_outdated=False: SimpleNamespace(binary=Path(pm_git)) if name == "git" else None)+ (tmp_path / "no-git").mkdir()+ monkeypatch.setenv("PATH", str(tmp_path / "no-git"))+ assert pause_record.head_sha(root) == head+ assert ran == [pm_git], "the gate's git bypassed update_custody.run_git"