The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): exclude internal build tools from source install roots
ethernet59013e824772
diff --git a/hermes_cli/_update_takeover.py b/hermes_cli/_update_takeover.pyindex a6de50fc006..c072aec6572 100644--- a/hermes_cli/_update_takeover.py+++ b/hermes_cli/_update_takeover.py@@ -14,7 +14,7 @@ def prepare(request: dict) -> tuple[Path, dict[str, str]]:from pm import paths, receiptfrom pm.client import ensure, sync_venv, venv_is_currentfrom pm.lock import Lockfile- from pm.registry import get_package+ from pm.registry import source_install_packagesfrom hermes_cli.runtime_paths import activation_environment, install_state_dir, runtime_facts_pathfrom hermes_cli._launchers import resolve_store_pythonfrom hermes_cli.venv_sync import publish_launchers@@ -24,9 +24,8 @@ def prepare(request: dict) -> tuple[Path, dict[str, str]]:lock = Lockfile(paths.lockfile_path())# A pre-PM installation has no required-tool facts. A current Python# generation alone does not prove its Node/Git/tool closure is ready.- for name in lock.names():- if not get_package(name).optional or name == "python":- ensure(name, explicit=True)+ for name in source_install_packages(lock.names()):+ ensure(name, explicit=True)extras = ["all"] if not runtime_facts_path(root).is_file() else Nonerepair_marker = install_state_dir(root) / ".repair-incomplete"# Repair preserves the old stamp. Changed source inputs instead needdiff --git a/pm/cli.py b/pm/cli.pyindex 6b4292dc3d6..a59be14c10d 100644--- a/pm/cli.py+++ b/pm/cli.py@@ -14,7 +14,7 @@ from pm.ensure import _facts, _lockfile, _store, ensure, stage_onlyfrom pm.operations import lock_projectfrom pm.package import InstallErrorfrom pm.paths import repo_root-from pm.registry import get_package+from pm.registry import get_package, source_install_packagesfrom pm.store import ALL_TARGETS, current_target, hash_urlfrom pm.update import Resolved, resolve_package, reuse_index_responses@@ -121,9 +121,7 @@ def cmd_install(args) -> int:return 1# Source-install launchers require the store interpreter, even though# Python remains optional when provisioning individual tools.- names = args.names or [- n for n in _lockfile().names() if not get_package(n).optional or n == "python"- ]+ names = args.names or source_install_packages(_lockfile().names())failed = _install_names(names, target=cross_target)if not args.names:from pm.ensure import sync_venvdiff --git a/pm/package.py b/pm/package.pyindex b9c2c3c90d3..aa61cd3391e 100644--- a/pm/package.py+++ b/pm/package.py@@ -51,10 +51,10 @@ class Package:name: unique id.deps: packages installed before this one.optional: not part of the root closure; installed on demand.- internal: a package manager pm uses inside install steps — never on- PATH and never part of the root closure. uv is the single internal- package; node/npm are shipped runtime tools (TUI, plugins), not- install machinery.+ internal: tooling PM uses inside install/build steps — never on PATH+ and never selected as an application root. Dependencies and explicit+ build requests can select it. node/npm are shipped runtime tools+ (TUI, plugins), not install machinery.on_path: contributes PATH dirs.url: template with {version} and {target} holes. override fetch_url()when a platform needs a completely different url.diff --git a/pm/registry.py b/pm/registry.pyindex ae93e6e1954..18d2311be81 100644--- a/pm/registry.py+++ b/pm/registry.py@@ -32,6 +32,12 @@ def all_packages() -> list[str]:return sorted(_packages)+def source_install_packages(names: list[str]) -> list[str]:+ """Select runtime roots; internal tools enter only through dependencies."""+ return [name for name in names+ if not get_package(name).internal and (name == "python" or not get_package(name).optional)]++def package_definitions(names: list[str] | None = None) -> list[dict[str, Any]]:"""Declarations for a fresh worker; built-ins already load with pm.diff --git a/tests/pm/test_install_default_closure.py b/tests/pm/test_install_default_closure.pyindex c6f3a2a6e18..cbd643feeb9 100644--- a/tests/pm/test_install_default_closure.py+++ b/tests/pm/test_install_default_closure.py@@ -40,11 +40,13 @@ def install_spy(monkeypatch):def test_default_closure_includes_the_boot_interpreter(install_spy):assert pm.cli.cmd_install(argparse.Namespace(names=None)) == 0assert "python" in install_spy["names"]+ assert all(not pm.cli.get_package(name).internal for name in install_spy["names"])assert install_spy["sync_extras"] == ["all"]-def test_explicit_names_pass_through_untouched(install_spy) -> None:- assert pm.cli.cmd_install(argparse.Namespace(names=["npm", "ripgrep"])) == 0- assert install_spy["names"] == ["npm", "ripgrep"][email protected]("names", [["npm", "ripgrep"], ["dmgbuild"]])+def test_explicit_names_pass_through_untouched(install_spy, names) -> None:+ assert pm.cli.cmd_install(argparse.Namespace(names=names)) == 0+ assert install_spy["names"] == namesassert install_spy["sync_extras"] is Nonediff --git a/tests/pm/test_takeover_preparation.py b/tests/pm/test_takeover_preparation.pyindex d4a9dfa5365..6d47a3c6a75 100644--- a/tests/pm/test_takeover_preparation.py+++ b/tests/pm/test_takeover_preparation.py@@ -56,6 +56,9 @@ def test_fresh_takeover_prepares_generation_and_runs_selected_python(tmp_path):lock.set_pin(name, "fixture", {})Facts(store / "facts.json").record(name, "fixture", name, {"PATH": [str(binary.parent)]}, store,target=target, digest=tree_digest(entry))+ # The application lock also pins build-only suppliers. A CLI takeover must+ # not select them as runtime roots, even when they cannot run on this host.+ lock.set_pin("dmgbuild", "fixture", {})lock.save()# Probe the selected-interpreter boundary; app completion orchestration has# its own contract tests. This script cannot import the dep from the parent.@@ -78,6 +81,7 @@ def test_fresh_takeover_prepares_generation_and_runs_selected_python(tmp_path):assert Path(output['dep']).is_relative_to(home / "installs")assert (root / ".hermes/bin/hermes").is_file()assert not (root / "venv").exists()+ assert Facts(store / "facts.json").get("dmgbuild") is None# Repair restores the recorded graph; a checkout update must also advance# that graph to the new source inputs before normal bootstrap checks it.