Skip to content

The agent that grows with you

fix: resolve installed names from the requested profile root

Teknium258049b38f80
diff --git a/hermes_cli/gateway_runtime_service.py b/hermes_cli/gateway_runtime_service.py
index dc1ad571237..c3ee2cbc892 100644
--- a/hermes_cli/gateway_runtime_service.py
+++ b/hermes_cli/gateway_runtime_service.py
@@ -34,10 +34,15 @@ def remaining(deadline: float) -> float:
def service_suffix(home: Path) -> str:
- from hermes_constants import get_default_hermes_root
+ from hermes_constants import _get_platform_default_hermes_home
from hermes_cli.gateway import _profile_name_from_home
- default = get_default_hermes_root().resolve()
+ default = _get_platform_default_hermes_home().resolve()
home = home.resolve()
+ # Mirror the installer's custom-root rule for the REQUESTED home, not the
+ # initiating client's environment. Two custom roots can share a unit name;
+ # effective binding validation, not a guessed hash, disambiguates them.
+ if not home.is_relative_to(default):
+ default = home.parent.parent if home.parent.name == "profiles" else home
if home == default:
return ""
return _profile_name_from_home(home, default) or hashlib.sha256(str(home).encode()).hexdigest()[:8]
@@ -205,7 +210,7 @@ def start_existing_gateway_service(service: ExistingService, *, deadline: float)
if service.running:
return
try:
- result = _run(service.start_argv, deadline)
+ result = _run(service.start_argv, deadline, encoding=None)
except subprocess.TimeoutExpired:
raise TimeoutError from None
except OSError as exc:
diff --git a/tests/hermes_cli/test_gateway_runtime_service_roots.py b/tests/hermes_cli/test_gateway_runtime_service_roots.py
new file mode 100644
index 00000000000..d73bd51e802
--- /dev/null
+++ b/tests/hermes_cli/test_gateway_runtime_service_roots.py
@@ -0,0 +1,29 @@
+"""Explicit requested-root naming and start-response encoding contracts."""
+import subprocess
+import sys
+import time
+from pathlib import Path
+
+import pytest
+
+
[email protected]('named', [False, True])
+def test_requested_service_name_does_not_borrow_callers_home(tmp_path, monkeypatch, named):
+ from hermes_cli.gateway_runtime_service import service_suffix
+ from hermes_cli.gateway import _profile_suffix
+ monkeypatch.setattr(Path, 'home', lambda: tmp_path)
+ requested = tmp_path / 'custom'
+ if named:
+ requested = requested / 'profiles' / 'worker'
+ requested.mkdir(parents=True)
+ monkeypatch.setenv('HERMES_HOME', str(requested))
+ installed = _profile_suffix()
+ monkeypatch.setenv('HERMES_HOME', str(tmp_path / '.hermes'))
+ assert service_suffix(requested) == installed
+
+
+def test_service_start_does_not_decode_irrelevant_supervisor_output():
+ from hermes_cli.gateway_runtime_service import ExistingService, start_existing_gateway_service
+ service = ExistingService('systemd', (sys.executable, '-c', 'import sys; sys.stdout.buffer.write(bytes([255]))'))
+ start_existing_gateway_service(service, deadline=time.monotonic() + 5)