The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(terminal): strip a sealed payload's venv from child PYTHONPATH
ethernet671996b152e6
diff --git a/tests/tools/test_local_env_blocklist.py b/tests/tools/test_local_env_blocklist.pyindex 006d9b85552..8211fc249cf 100644--- a/tests/tools/test_local_env_blocklist.py+++ b/tests/tools/test_local_env_blocklist.py@@ -656,6 +656,24 @@ def test_runtime_provenance_is_independent_of_aliases_and_virtual_env(child_env,assert base["VIRTUAL_ENV"] == str(user_venv)[email protected]("child_env")+def test_sealed_payload_venv_is_runtime_provenance_without_facts(tmp_path, monkeypatch):+ """A sealed payload boots its store interpreter (not a venv) on its shipped venv+ before PM commits a generation; that venv's site-packages must never reach a child."""+ from pm.environments import site_packages+ shipped = tmp_path / "payload/venv"+ shipped.mkdir(parents=True)+ (shipped / "pyvenv.cfg").write_text("version = 3.14\n", encoding="utf-8")+ monkeypatch.setattr("pm.environments.install_state_dir", lambda repo: tmp_path / "payload/state")+ monkeypatch.setattr("pm.environments.payload_venv", lambda repo: shipped)+ monkeypatch.setattr(local, "_in_venv", False)+ monkeypatch.setattr(local, "_hermes_site_packages", None)+ user_site = tmp_path / "user-site"+ result = local._sanitize_subprocess_env(+ {"PYTHONPATH": os.pathsep.join([str(site_packages(shipped)), str(user_site)])})+ assert result["PYTHONPATH"] == str(user_site)++@pytest.mark.parametrize("existing,expected", [(["/usr/bin", "/bin"], ["/opt/hermes/bin", "/usr/bin", "/bin"]),(["/usr/bin", "/opt/hermes/bin"], ["/usr/bin", "/opt/hermes/bin"]),diff --git a/tools/environments/local_pythonpath.py b/tools/environments/local_pythonpath.pyindex 078f777edd0..5c2c1c08cfa 100644--- a/tools/environments/local_pythonpath.py+++ b/tools/environments/local_pythonpath.py@@ -71,14 +71,19 @@ def _build_hermes_repo_root_aliases(def _validated_runtime_venv(env: dict) -> Path | None:- """Producer-owned runtime venv identified by VIRTUAL_ENV, or None. The variable- alone is not provenance (users carry unrelated venvs): require the legacy Windows- base-Python producer's exact ``<repo>/venv`` layout AND a real ``pyvenv.cfg``."""- from pm.environments import runtime_facts_path, selected_venv+ """Producer-owned runtime venv, or None: PM's committed generation, else a sealed+ payload's shipped venv (its interpreter is not a venv, so ``_in_venv`` misses it),+ else VIRTUAL_ENV. The variable alone is not provenance (users carry unrelated+ venvs): require the legacy Windows base-Python producer's exact ``<repo>/venv``+ layout AND a real ``pyvenv.cfg``."""+ from pm.environments import payload_venv, runtime_facts_path, selected_venvroot = Path(__file__).resolve().parents[2]if runtime_facts_path(root).is_file():return selected_venv(root)+ shipped = payload_venv(root)+ if shipped is not None:+ return shippedcandidate = Path(env.get("VIRTUAL_ENV") or "")if not env.get("VIRTUAL_ENV") or not any(_same_path(candidate, root / "venv") for root in _state()._hermes_repo_root_aliases):