The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): make only a missing dependency generation a terminal bootstrap failure
Tekniumb2b85bdf719b
diff --git a/pm/environments.py b/pm/environments.pyindex d080d0e0895..231ae77c1b7 100644--- a/pm/environments.py+++ b/pm/environments.py@@ -432,6 +432,10 @@ def running_from_selected_environment(project_root: Path) -> bool:return any(Path(entry).resolve() == selected for entry in sys.path if entry)+class NoCommittedEnvironment(RuntimeError):+ """PM's store Python with no committed generation: no retry fixes it, only `hermes pm repair`."""++def _require_own_dependencies(project_root: Path) -> None:"""With nothing committed, an interpreter keeps the packages it booted with.@@ -443,7 +447,7 @@ def _require_own_dependencies(project_root: Path) -> None:if sys.prefix != sys.base_prefix:return # a venv interpreter (developer .venv, test env) carries its own packagesif Path(sys.base_prefix).resolve().is_relative_to(store_root(project_root).resolve()):- raise RuntimeError("no dependency environment is committed for this install")+ raise NoCommittedEnvironment("no dependency environment is committed for this install")def activate_dependencies(project_root: Path) -> None:diff --git a/tests/tui_gateway/test_ink_helper_dependencies.py b/tests/tui_gateway/test_ink_helper_dependencies.pyindex 17dbdeaac03..d4dd33e86bd 100644--- a/tests/tui_gateway/test_ink_helper_dependencies.py+++ b/tests/tui_gateway/test_ink_helper_dependencies.py@@ -82,6 +82,21 @@ def test_packaged_gateway_bootstrap_boots_the_root_it_is_given_or_names_why_it_cassert "unavailable" not in booted.stderr+def test_unreadable_install_state_is_retried_not_terminal():+ """An I/O error on the install state can be one-off: it takes the ordinary failure path the+ client retries, never the terminal verdict that ends the TUI's gateway for its lifetime."""+ import pm.environments++ state = pm.environments.install_state_dir(_ROOT)+ (state / ".install.lock").mkdir(parents=True) # os.open(O_RDWR) on a directory: OSError++ child = _ink_child("gateway_bootstrap.py", "--start")++ assert child.returncode == 1+ assert "gateway unavailable" not in child.stderr, child.stderr+ assert "Traceback" not in child.stderr, child.stderr++@pytest.mark.platforms("linux")def test_clipboard_image_converts_wayland_jpeg_with_the_generations_pillow(tmp_path):"""A non-PNG Wayland clipboard image is converted with Pillow, a core dependency; ImageMagickdiff --git a/ui-tui/scripts/gateway_bootstrap.py b/ui-tui/scripts/gateway_bootstrap.pyindex 6b04f4e6846..6e26c5c51af 100644--- a/ui-tui/scripts/gateway_bootstrap.py+++ b/ui-tui/scripts/gateway_bootstrap.py@@ -37,7 +37,7 @@ def failure_message(receipt) -> str:def bootstrap(start: bool, recover: bool = False) -> dict:- from pm.environments import activate_dependencies+ from pm.environments import NoCommittedEnvironment, activate_dependencies# Ink runs this on HERMES_PYTHON with PYTHONPATH=<root> only. On a source install that is PM's# store Python, which owns no packages, and the no-owner discovery fallback already imports one@@ -45,7 +45,10 @@ def bootstrap(start: bool, recover: bool = False) -> dict:# hermes_bootstrap does for every other entry point.try:activate_dependencies(python_root())- except (RuntimeError, OSError) as exc: # no committed generation / unreadable install state+ except NoCommittedEnvironment as exc:+ # Only a missing generation is terminal. An I/O error reading the install state (OSError)+ # or a damaged record (RuntimeError) reaches the ordinary failure path below, which the+ # client retries: a one-off read error must not end the TUI's gateway for its lifetime.raise ImportError(f"dependency environment unavailable: {exc}") from excfrom hermes_constants import get_hermes_homefrom hermes_cli.gateway_runtime import (attachable, control_home_for, discover_gateway_endpoint,