The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
update: refuse source checkouts on Termux hosts with the APT hint
ethernet09a49ab37ea5
diff --git a/hermes_cli/steward.py b/hermes_cli/steward.pyindex aad8e175b87..c42ed62a485 100644--- a/hermes_cli/steward.py+++ b/hermes_cli/steward.py@@ -58,6 +58,18 @@ STEWARD_UPDATE_MESSAGES = {),}+# A git checkout on a Termux host is not ours to update either: the lock+# pins a bionic CPython with no Android wheels, so a source sync would+# build sdists on the phone. The APT package is the only supported shape.+SOURCE_ON_TERMUX_UPDATE_MESSAGE = (+ "✗ This Hermes is a source checkout running under Termux.\n"+ "\n"+ "Source installs are not supported on Termux — `hermes update` would\n"+ "build Python packages on the device. Switch to the APT package:\n"+ " pkg install hermes-agent"+)+SOURCE_ON_TERMUX_UPDATE_COMMAND = "pkg install hermes-agent"+_STEWARD_UPDATE_FALLBACK = ("✗ This Hermes install is managed by {steward}.\n"diff --git a/hermes_cli/update_contract.py b/hermes_cli/update_contract.pyindex 419037e4fcb..775b6b4c252 100644--- a/hermes_cli/update_contract.py+++ b/hermes_cli/update_contract.py@@ -91,6 +91,17 @@ def evaluate_update_admission(project_root: Path) -> Optional[UpdateRefusal]:)steward = sealed_steward(project_root)+ if steward is None:+ from hermes_constants import is_termux++ if is_termux():+ from hermes_cli.steward import SOURCE_ON_TERMUX_UPDATE_COMMAND, SOURCE_ON_TERMUX_UPDATE_MESSAGE++ return UpdateRefusal(+ code=STEWARD_APT_TERMUX,+ message=SOURCE_ON_TERMUX_UPDATE_MESSAGE,+ update_command=SOURCE_ON_TERMUX_UPDATE_COMMAND,+ )if steward is not None and steward != "unknown":from hermes_cli.config import recommended_update_command_for_methoddiff --git a/tests/hermes_cli/test_update_contract.py b/tests/hermes_cli/test_update_contract.pyindex 4b574580f05..b24bf2fd3cf 100644--- a/tests/hermes_cli/test_update_contract.py+++ b/tests/hermes_cli/test_update_contract.py@@ -191,6 +191,25 @@ def _sealed_tree(tmp_path: Path, distribution: str) -> Path:return root+def test_admission_source_checkout_on_termux_host_refuses_with_apt_hint(tmp_path, monkeypatch):+ """A git checkout is normally admitted, but not on a Termux host: the+ lock has no Android wheels, so a source sync would build sdists on the+ phone. The refusal must point at the APT package, never `hermes update`."""+ import hermes_cli.image_provenance as ip++ monkeypatch.setattr(ip, "IMAGE_PROVENANCE_PATH", tmp_path / "absent.json")+ (tmp_path / ".git").mkdir()+ monkeypatch.delenv("TERMUX_VERSION", raising=False)+ monkeypatch.setenv("PREFIX", "/data/data/com.termux/files/usr")+ refusal = evaluate_update_admission(tmp_path)+ assert refusal is not None and refusal.code == "apt-termux"+ assert "pkg install hermes-agent" in refusal.message+ assert refusal.update_command == "pkg install hermes-agent"+ assert "hermes update" not in refusal.update_command+ monkeypatch.setenv("PREFIX", "/usr")+ assert evaluate_update_admission(tmp_path) is None, "the same checkout off Termux stays updatable"++def test_admission_apt_termux_refuses_with_pkg_upgrade(tmp_path, monkeypatch):"""A sealed apt-termux tree (no .git) is refused by the steward gate:the package manager owns the code tree, so remediation is pkg upgrade