Skip to content

The agent that grows with you

fix(tests): sandbox a dev shell whose HERMES_HOME is the Windows platform root, and pin lazy state.db home resolution

teknium1cf7895c1bd9e
diff --git a/tests/conftest.py b/tests/conftest.py
index 7cbabca510e..f020209ef81 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -77,8 +77,14 @@ def _hermes_home_points_at_production(value: str) -> bool:
if not value:
return True
try:
+ # The platform-default root, not a hardcoded ``~/.hermes``: Windows installs live under
+ # ``%LOCALAPPDATA%\hermes``, and a dev shell exporting that path used to be honored as
+ # "custom", pinning import-time paths (``tui_gateway.server._hermes_home``) to the live
+ # install so the state.db guard tripped on every store-touching test (#112692).
+ from hermes_state_guard import _real_platform_state_root
+
resolved = Path(value).expanduser().resolve()
- real_root = (Path.home() / ".hermes").resolve()
+ real_root = _real_platform_state_root() or (Path.home() / ".hermes").resolve()
except Exception:
return True
if resolved == real_root:
diff --git a/tests/tui_gateway/test_launch_db_home_override_race.py b/tests/tui_gateway/test_launch_db_home_override_race.py
index 551cfb90874..0f7f71e5b00 100644
--- a/tests/tui_gateway/test_launch_db_home_override_race.py
+++ b/tests/tui_gateway/test_launch_db_home_override_race.py
@@ -46,6 +46,23 @@ def test_get_db_first_touch_under_foreign_override_uses_launch_path(launch_db_en
reset_hermes_home_override(token)
+def test_get_db_follows_a_process_home_redirected_after_import(monkeypatch, tmp_path):
+ """The launch handle resolves ``HERMES_HOME`` at first use, not at import (#112692): a harness
+ that redirects the env after ``tui_gateway.server`` is imported must not open the import-time
+ home's state.db. Only the context-local override is ignored (#102526), never the process env."""
+ redirected = tmp_path / "redirected"
+ redirected.mkdir()
+ monkeypatch.setattr(server, "_db", None)
+ monkeypatch.setattr(server, "_db_error", None)
+ monkeypatch.setenv("HERMES_HOME", str(redirected))
+ try:
+ db = server._get_db()
+ assert db is not None
+ assert db.db_path.resolve() == (redirected / "state.db").resolve()
+ finally:
+ registry.close_all()
+
+
def test_insights_get_reads_the_requested_profile_store_not_the_launch_handle(launch_db_env, monkeypatch, tmp_path):
"""``insights.get {profile}`` was ``scoped=True`` then ``_get_db()``: a scoped first touch pinned
the launch handle to the foreign store. It must count the requested profile's sessions through