Skip to content

The agent that grows with you

Adapt incoming install and upgrade E2E fixtures to PM

ethernetc1a239407bcb
diff --git a/tests/e2e/core/upgrade/_helpers.py b/tests/e2e/core/upgrade/_helpers.py
index 3534c2b26af..ba0099d8ffe 100644
--- a/tests/e2e/core/upgrade/_helpers.py
+++ b/tests/e2e/core/upgrade/_helpers.py
@@ -143,7 +143,9 @@ def sandbox_argv(argv: Sequence[str], *, writable: Iterable[Path]) -> list[str]:
"""Wrap ``argv`` in the bwrap sandbox (no-op when bubblewrap is unusable)."""
if not BWRAP_OK:
return list(argv)
- cmd = ["bwrap", "--dev-bind", "/", "/"]
+ # The child's allowlisted PATH may omit the Nix-provided bwrap (notably a login shell
+ # with a clean distro PATH); resolve it in the parent before wrapping the command.
+ cmd = [shutil.which("bwrap") or "bwrap", "--dev-bind", "/", "/"]
real_hermes = REAL_HOME / ".hermes"
if real_hermes.is_dir():
cmd += ["--ro-bind", str(real_hermes), str(real_hermes)]
diff --git a/tests/e2e/core/upgrade/_install_helpers.py b/tests/e2e/core/upgrade/_install_helpers.py
index d694d5df0a9..2685f2f3888 100644
--- a/tests/e2e/core/upgrade/_install_helpers.py
+++ b/tests/e2e/core/upgrade/_install_helpers.py
@@ -7,7 +7,8 @@ of that this module stages what a real user machine looks like to the installer
the official clone URLs are rewritten to by the sandbox's own ``~/.gitconfig``, plus a ``git``
wrapper that reports the official URL for ``remote get-url origin`` (``insteadOf`` would
otherwise expose the local path and send the updater down the fork path);
-* a managed ``$HERMES_HOME/bin/uv`` pointing at the host's uv (warm cache, no download);
+* the real host uv on PATH as an optional warm-cache shortcut; the installer
+ still rejects a version below its PM pin and provisions the pinned artifact;
* ``TMPDIR`` inside the sandbox root (the host's is not writable in the sandbox).
"""
@@ -100,6 +101,18 @@ class Sandbox:
"""The command the installer put on PATH, as a user's shell resolves it."""
return str(self.home / ".local" / "bin" / "hermes")
+ @property
+ def python(self) -> str:
+ """The installed PM generation's selected interpreter, not a legacy checkout venv."""
+ from pm.environments import install_key
+
+ facts = self.hermes_home / "installs" / install_key(self.checkout) / "facts.json"
+ assert facts.is_file(), f"installer did not publish PM facts at {facts}"
+ selected = json.loads(facts.read_text(encoding="utf-8"))["packages"]["venv"]["environment"]
+ python = Path(selected) / "bin" / "python"
+ assert python.is_file(), f"selected PM Python missing: {python}"
+ return str(python)
+
def run(self, argv: list[str], *, timeout: float = 600, cwd: Path | None = None,
input: str | None = None) -> subprocess.CompletedProcess:
return H.run(argv, env=self.env, cwd=cwd or self.root, writable=[self.root], timeout=timeout, input=input)
@@ -119,11 +132,6 @@ def new_sandbox(root: Path, origin: Path | None = None, *, pythonpath: Path | No
env["TMPDIR"] = str(root / "tmp")
env["SHELL"] = "/bin/bash"
# A fresh machine: ~/.local/bin is NOT on PATH yet; the installer must wire it up.
- managed = home / ".hermes" / "bin"
- managed.mkdir(parents=True)
- uv = managed / "uv"
- uv.write_text(f'#!/bin/sh\nif [ "$1" = self ]; then exit 0; fi\nexec "{real_uv()}" "$@"\n', encoding="utf-8")
- uv.chmod(0o755)
if origin is not None:
(home / ".gitconfig").write_text(
f'[url "file://{origin}"]\n insteadOf = {OFFICIAL_HTTPS}\n insteadOf = {OFFICIAL_SSH}\n', encoding="utf-8")
@@ -146,7 +154,7 @@ def run_installer(sb: Sandbox, *, timeout: float = 1800) -> subprocess.Completed
"""HEAD's scripts/install.sh, non-interactive, as the documented `curl | bash` run does it."""
script = sb.root / "install.sh"
shutil.copy(H.WORKTREE / "scripts" / "install.sh", script)
- return sb.run(["bash", str(script), "--skip-setup", "--skip-browser", "--skip-computer-use", "--non-interactive"],
+ return sb.run(["bash", str(script), "--non-interactive"],
timeout=timeout, input="")
diff --git a/tests/e2e/core/upgrade/test_install_fresh.py b/tests/e2e/core/upgrade/test_install_fresh.py
index 4d81b2c2c77..784221e2cc3 100644
--- a/tests/e2e/core/upgrade/test_install_fresh.py
+++ b/tests/e2e/core/upgrade/test_install_fresh.py
@@ -18,6 +18,7 @@ from __future__ import annotations
import json
import re
import shutil
+from pathlib import Path
import pytest
@@ -26,7 +27,7 @@ from tests.e2e.core.upgrade import _install_helpers as I
from tests.fakes.fake_llm_provider import FakeLLMServer
pytestmark = [
- pytest.mark.linux_only,
+ pytest.mark.platforms("linux"),
pytest.mark.skipif(H.sandbox_required_reason() is not None, reason=str(H.sandbox_required_reason())),
pytest.mark.skipif(shutil.which("git") is None, reason="git required"),
pytest.mark.skipif(I.real_uv() is None, reason="uv required"),
@@ -55,7 +56,10 @@ def _login_shell_hermes(sb: I.Sandbox) -> str:
"""Resolve `hermes` the way a new login shell would: PATH comes only from the rc files."""
env = dict(sb.env)
env["PATH"] = "/usr/local/bin:/usr/bin:/bin"
- cp = H.run(["bash", "-lc", "command -v hermes"], env=env, cwd=sb.root, writable=[sb.root], timeout=60)
+ bash = shutil.which("bash")
+ assert bash is not None, "bash required for install.sh and the login-shell probe"
+ cp = H.run([bash, "-lic", "command -v hermes"], env=env, cwd=sb.root, writable=[sb.root], timeout=60)
+ assert cp.returncode == 0, H.describe(cp)
return cp.stdout.strip()
@@ -97,7 +101,7 @@ def _turn(sb: I.Sandbox, provider: FakeLLMServer, marker: str) -> None:
def _configure(sb: I.Sandbox, provider: FakeLLMServer) -> None:
- py = str(sb.checkout / "venv" / "bin" / "python")
+ py = sb.python
ver = sb.run([py, "-c", "from hermes_cli.config_defaults import DEFAULT_CONFIG as D; print(D['_config_version'])"])
assert ver.returncode == 0, I.describe(ver)
version = int(ver.stdout.strip().splitlines()[-1])
@@ -114,29 +118,32 @@ def test_fresh_install_serves_head_and_runs_a_turn(installed, provider):
assert first.returncode == 0, "install.sh failed on an empty HOME:\n" + I.describe(first)
assert I.git("rev-parse", "HEAD", cwd=sb.checkout) == I.head_sha(), "installed checkout is not the published commit"
assert I.git("status", "--porcelain", "--untracked-files=no", cwd=sb.checkout) == "", "installer dirtied the checkout"
- # A new login shell finds the command through the rc files the installer edited.
- assert _login_shell_hermes(sb) == sb.hermes, "a new shell does not resolve `hermes` to the installed launcher"
- assert all(n >= 1 for n in _path_lines(sb).values()), f"PATH not wired into the shell rc: {_path_lines(sb)}"
ver = sb.cli("--version")
assert ver.returncode == 0 and I.TRACEBACK not in ver.stdout + ver.stderr, I.describe(ver)
- probe = sb.run([str(sb.checkout / "venv" / "bin" / "python"), "-c", "import hermes_cli, run_agent; print(hermes_cli.__file__); print(run_agent.__file__)"])
+ probe = sb.run([sb.python, "-c", "import hermes_cli, run_agent; print(hermes_cli.__file__); print(run_agent.__file__)"])
assert probe.returncode == 0, I.describe(probe)
+ workspace = Path(sb.python).parent.parent.parent / "workspace"
for line in probe.stdout.split():
- assert line.startswith(str(sb.checkout)), f"installed venv imports code from outside the checkout: {line}"
+ imported = Path(line)
+ assert imported.is_relative_to(workspace), f"installed PM environment imports code from outside the selected workspace: {line}"
+ assert imported.read_bytes() == (sb.checkout / imported.relative_to(workspace)).read_bytes(), (
+ f"installed PM workspace does not match the checkout: {line}")
for rel in ("config.yaml", ".env", "SOUL.md"):
assert (sb.hermes_home / rel).is_file(), f"installer did not seed ~/.hermes/{rel}"
_configure(sb, provider)
_turn(sb, provider, "first turn on a fresh install")
db = I.db_state(sb.hermes_home / "state.db")
assert db["integrity"] == [("ok",)] and len(db["sessions"]) == 1 and db["n_messages"] >= 2, db
+ # A new login shell finds the command through the rc files the installer edited.
+ assert all(n >= 1 for n in _path_lines(sb).values()), f"PATH not wired into the shell rc: {_path_lines(sb)}"
+ assert _login_shell_hermes(sb) == sb.hermes, "a new shell does not resolve `hermes` to the installed launcher"
def test_rerunning_the_installer_is_idempotent(installed, provider):
sb, first = installed
assert first.returncode == 0, I.describe(first)
- if not (sb.hermes_home / "state.db").exists():
- _configure(sb, provider)
- _turn(sb, provider, "first turn on a fresh install")
+ _configure(sb, provider)
+ _turn(sb, provider, "session that must survive the installer re-run")
before = _state(sb)
rc_before = _path_lines(sb)
commit = I.git("rev-parse", "HEAD", cwd=sb.checkout)
@@ -147,8 +154,8 @@ def test_rerunning_the_installer_is_idempotent(installed, provider):
after = _state(sb)
for key in before:
assert after[key] == before[key], f"re-running the installer changed the user's {key}"
- assert _path_lines(sb) == rc_before, f"PATH line appended again: {rc_before} -> {_path_lines(sb)}"
- assert _login_shell_hermes(sb) == sb.hermes
_turn(sb, provider, "turn after re-running the installer")
db = I.db_state(sb.hermes_home / "state.db")
assert set(before["db"]["sessions"]) < set(db["sessions"]), "earlier session lost or new turn not persisted"
+ assert _path_lines(sb) == rc_before, f"PATH line appended again: {rc_before} -> {_path_lines(sb)}"
+ assert _login_shell_hermes(sb) == sb.hermes
diff --git a/tests/e2e/core/upgrade/test_profile_update_cron.py b/tests/e2e/core/upgrade/test_profile_update_cron.py
index 48fb4503bf2..b266a63d1fe 100644
--- a/tests/e2e/core/upgrade/test_profile_update_cron.py
+++ b/tests/e2e/core/upgrade/test_profile_update_cron.py
@@ -24,7 +24,7 @@ from tests.e2e.core.upgrade import _helpers as H
from tests.e2e.core.upgrade import _install_helpers as I
pytestmark = [
- pytest.mark.linux_only,
+ pytest.mark.platforms("linux"),
pytest.mark.skipif(H.sandbox_required_reason() is not None, reason=str(H.sandbox_required_reason())),
]
diff --git a/tests/e2e/core/upgrade/test_update_userstate_import.py b/tests/e2e/core/upgrade/test_update_userstate_import.py
index b21d22c4a94..293c6004ee2 100644
--- a/tests/e2e/core/upgrade/test_update_userstate_import.py
+++ b/tests/e2e/core/upgrade/test_update_userstate_import.py
@@ -20,7 +20,7 @@ from tests.e2e.core.upgrade import _helpers as H
from tests.e2e.core.upgrade import _install_helpers as I
pytestmark = [
- pytest.mark.linux_only,
+ pytest.mark.platforms("linux"),
pytest.mark.skipif(H.sandbox_required_reason() is not None, reason=str(H.sandbox_required_reason())),
]
diff --git a/tests/e2e/core/upgrade/test_update_userstate_realistic.py b/tests/e2e/core/upgrade/test_update_userstate_realistic.py
index 981a632fa67..b985041c01c 100644
--- a/tests/e2e/core/upgrade/test_update_userstate_realistic.py
+++ b/tests/e2e/core/upgrade/test_update_userstate_realistic.py
@@ -35,7 +35,7 @@ from tests.e2e.core.upgrade import _install_helpers as I
from tests.fakes.fake_llm_provider import FakeLLMServer
pytestmark = [
- pytest.mark.linux_only,
+ pytest.mark.platforms("linux"),
# The real updater runs against a throwaway install inside the sandbox, never this checkout.
pytest.mark.live_system_guard_bypass,
pytest.mark.skipif(H.sandbox_required_reason() is not None, reason=str(H.sandbox_required_reason())),
@@ -64,8 +64,8 @@ def _ok(cp):
def _config_versions(sb: I.Sandbox) -> tuple[int, int]:
- """(latest, support floor) ``_config_version`` of the code in the sandbox checkout's venv."""
- cp = _ok(sb.run([str(sb.checkout / "venv" / "bin" / "python"), "-c", _VERSIONS_PY]))
+ """(latest, support floor) from the installed PM-selected interpreter."""
+ cp = _ok(sb.run([sb.python, "-c", _VERSIONS_PY]))
latest, floor = cp.stdout.strip().splitlines()[-1].split()
return int(latest), int(floor)
@@ -128,6 +128,10 @@ def _seed_home(sb: I.Sandbox, provider: FakeLLMServer) -> tuple[dict[str, str],
(home / "memories" / "MEMORY.md").write_text(f"- {name}: user prefers tabs\n", encoding="utf-8")
markers[name] = f"pre-update session in the {name} profile"
_ok(sb.cli(*_pargs(name), "-z", markers[name]))
+ # A normal CLI turn migrates old configs on launch. Model the user's older
+ # hand-edited config as the state immediately before the update, not before
+ # the turns that seed the sessions.
+ (home / "config.yaml").write_text(I.provider_config(provider.base_url, versions[name], extra), encoding="utf-8")
hh = sb.hermes_home
skill = hh / "skills" / "my-own-skill"
skill.mkdir(parents=True, exist_ok=True)
@@ -161,7 +165,7 @@ def world(tmp_path_factory, provider):
(sb.checkout / "my_local_notes.txt").write_text("untracked notes in the checkout\n", encoding="utf-8")
snap = _snapshot(sb)
target = I.publish_commit(origin, root, "release: e2e bump 1", {"docs/e2e-update-marker.txt": "release 1\n"})
- update = sb.cli("update", "--yes", timeout=UPDATE_TIMEOUT)
+ update = sb.cli("update", "--yes", "--branch", "main", timeout=UPDATE_TIMEOUT)
return {"sb": sb, "origin": origin, "root": root, "markers": markers, "versions": versions,
"snap": snap, "target": target, "update": update}
@@ -263,7 +267,7 @@ def conflicting_leg(world):
before = I.tree_digest(ext)
target = I.publish_commit(world["origin"], world["root"], "release: e2e bump 2",
{"docs/e2e-update-marker.txt": "release 2 rewrote this file\n"})
- update = sb.cli("update", "--yes", timeout=UPDATE_TIMEOUT)
+ update = sb.cli("update", "--yes", "--branch", "main", timeout=UPDATE_TIMEOUT)
return {"ext": ext, "before": before, "target": target, "update": update}