fix: resolve PM stamp reads through installation root

This commit is contained in:
ethernet
2026-09-24 09:07:31 -04:00
parent 7f05c3e020
commit b207701287
4 changed files with 22 additions and 4 deletions

View File

@@ -107,8 +107,10 @@ def store_root(project_root: Path) -> Path:
if not store.is_relative_to(root.parent):
raise RuntimeError("payload store escapes its root")
return store
from hermes_cli.steward import install_stamp_path
for directory in (root, *root.parents):
stamp = directory / "install-stamp.json"
stamp = install_stamp_path(directory)
if stamp.is_file():
try:
data = json.loads(stamp.read_text(encoding="utf-8-sig"))

View File

@@ -61,9 +61,9 @@ def _resident_runtime() -> tuple[Path, Path] | None:
if payload is not None:
runtime = payload / "pm-runtime"
else:
from pm.paths import install_root
from hermes_cli.steward import install_stamp_path
stamp_path = install_root() / "install-stamp.json"
stamp_path = install_stamp_path(project)
try:
stamp = json.loads(stamp_path.read_text(encoding="utf-8-sig"))
except FileNotFoundError:

View File

@@ -15,7 +15,7 @@ from pm.environments import install_state_dir, site_packages
ROOT = Path(__file__).resolve().parents[2]
BOOT_FILES = (
"hermes_bootstrap.py", "hermes_constants.py", "hermes_cli/__init__.py", "hermes_cli/_launchers.py",
"pm/environments.py", "hermes_cli/runtime_state.py",
"pm/environments.py", "pm/paths.py", "hermes_cli/runtime_state.py",
"hermes_cli/_early_recovery.py", "hermes_cli/_parser.py",
"hermes_cli/venv_sync.py", "hermes_cli/steward.py",
"hermes_cli/stderr_timestamp.py",

View File

@@ -55,6 +55,22 @@ def test_ci_dependency_phase_uses_isolated_runtime(tmp_path, monkeypatch):
assert all(arguments["explicit"] for _, arguments in calls)
def test_store_root_reads_executing_trees_canonical_install_stamp(tmp_path, monkeypatch):
from pm import environments, paths
project = tmp_path / "source"
project.mkdir()
package = tmp_path / "package"
package.mkdir()
runtime = tmp_path / "packaged-tools"
(package / "install-stamp.json").write_text(json.dumps({"runtimeDir": str(runtime)}))
monkeypatch.setattr(paths, "repo_root", lambda: project)
monkeypatch.setenv("HERMES_INSTALL_ROOT", str(package))
monkeypatch.delenv("HERMES_RUNTIME_DIR", raising=False)
assert environments.store_root(project) == runtime
@pytest.mark.parametrize("distribution", ["nix", "docker"])
def test_packaged_runtime_uses_explicit_stamp_without_tool_downloads(tmp_path, monkeypatch, distribution):
from pm import runtime, paths