hermes_cli.runtime_paths (venv generations, selection, activation) moves to pm.environments, and gains venv_bin_dir / venv_python / project_python. Every in-tree caller asks pm for an interpreter now; pm no longer reaches back into hermes_cli for its own environment layout (pm.packages, pm.extras, pm.ensure, pm.paths imported hermes_cli.runtime_paths). The three open-coded "Scripts/python.exe or bin/python" ladders in pm collapse onto venv_python. hermes_constants.venv_python_path / venv_bin_dir and hermes_cli.runtime_paths stay as frozen-updater-surface shims only (tests/compat/old_updater_surface.json). To keep the boot path light, pm/__init__ resolves its facade lazily (PEP 562) and pm.registry loads the built-in package definitions on first read instead of at import: `import hermes_bootstrap` now loads pm + pm.environments only (25ms, was 37ms with the eager facade dragging in the downloader). The stripped-payload fixtures that ship only pre-import files keep working for the same reason. Also restores two frozen-surface re-exports the F401 sweep dropped (banner._github_compare_behind, cua_backend.resolve_cua_driver_cmd).
24 lines
914 B
Python
24 lines
914 B
Python
"""Recovery refuses corrupted metadata and never overwrites unrelated config."""
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from pm.environments import install_state_dir
|
|
from hermes_cli.runtime_state import recover_publication, runtime_lock
|
|
|
|
|
|
def test_invalid_journal_cannot_write_outside_home(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "home"))
|
|
repo = tmp_path / "repo"
|
|
outside = tmp_path / "outside" / "config.yaml"
|
|
outside.parent.mkdir()
|
|
outside.write_text("untouched")
|
|
state = install_state_dir(repo)
|
|
state.mkdir(parents=True)
|
|
journal = state / "publication.json"
|
|
journal.write_text(json.dumps({"config": str(outside), "previous": "eA==", "facts_before": None}))
|
|
with runtime_lock(repo), pytest.raises(RuntimeError, match="outside Hermes state"):
|
|
recover_publication(repo)
|
|
assert outside.read_text() == "untouched"
|
|
assert journal.exists()
|