The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(docker): start gateway through s6 runtime service
KoNit-K20b8cd75e87d
diff --git a/hermes_cli/gateway_runtime_service.py b/hermes_cli/gateway_runtime_service.pyindex 03cb4758b7a..fae61693d17 100644--- a/hermes_cli/gateway_runtime_service.py+++ b/hermes_cli/gateway_runtime_service.py@@ -149,6 +149,23 @@ def _systemd(home: Path, deadline: float) -> ExistingService | None:return found[0] if found else None+def _s6(home: Path) -> ExistingService:+ """Find the container gateway slot that owns ``home``.++ TUI clients call ``ensure_gateway_runtime`` inside the Docker image too.+ They must request that s6 starts the registered slot, rather than falling+ through the Linux systemd probe and treating s6 as inaccessible.+ """+ from hermes_cli.service_manager import S6ServiceManager++ profile = home.name if home.parent.name == "profiles" else "default"+ manager = S6ServiceManager()+ service_name = f"gateway-{profile}"+ if not (manager.scandir / service_name).is_dir():+ raise RuntimeStartError("service_manager_unavailable")+ return ExistingService("s6", (service_name,), manager.is_running(service_name))++def _launchd(home: Path, deadline: float) -> ExistingService | None:import pwdsuffix = service_suffix(home)@@ -225,6 +242,10 @@ def _no_supervisor(home: Path, deadline: float) -> None:def discover_existing_gateway_service(home: Path, *, deadline: float) -> ExistingService | None:+ from hermes_cli.service_manager import _s6_running++ if _s6_running():+ return _s6(home)backend = {"linux": _systemd, "darwin": _launchd, "win32": _windows,"android": _no_supervisor}.get(sys.platform)if backend is None:@@ -241,6 +262,13 @@ def start_existing_gateway_service(service: ExistingService, *, deadline: float)"""Request start once; only live control readiness can establish success."""if service.running:return+ if service.backend == "s6":+ from hermes_cli.service_manager import S6ServiceManager+ try:+ S6ServiceManager().start(service.start_argv[0])+ except (OSError, RuntimeError, ValueError) as exc:+ raise RuntimeStartError("service_start_failed") from exc+ returntry:result = _run(service.start_argv, deadline, encoding=None)except subprocess.TimeoutExpired:diff --git a/tests/hermes_cli/test_gateway_runtime_service.py b/tests/hermes_cli/test_gateway_runtime_service.pyindex 5dfc78682c9..6d3756d9128 100644--- a/tests/hermes_cli/test_gateway_runtime_service.py+++ b/tests/hermes_cli/test_gateway_runtime_service.py@@ -334,6 +334,39 @@ def test_android_python_reaches_the_unmanaged_start(tmp_path, monkeypatch):assert spawned == [home.resolve()]+def test_s6_runtime_ensure_starts_the_registered_gateway_slot(tmp_path, monkeypatch):+ """A Docker TUI client starts its s6 gateway instead of probing systemd."""+ from hermes_cli import gateway_runtime_service as service+ from hermes_cli import service_manager++ home = tmp_path / "data"+ home.mkdir()+ scandir = tmp_path / "run-service"+ (scandir / "gateway-default").mkdir(parents=True)+ started = []++ class FakeS6ServiceManager:+ def __init__(self):+ self.scandir = scandir++ def is_running(self, name):+ assert name == "gateway-default"+ return False++ def start(self, name):+ started.append(name)++ monkeypatch.setattr(service_manager, "_s6_running", lambda: True)+ monkeypatch.setattr(service_manager, "S6ServiceManager", FakeS6ServiceManager)+ monkeypatch.setattr(service, "_systemd", lambda *_args: pytest.fail("s6 must not probe systemd"))++ found = service.discover_existing_gateway_service(home, deadline=time.monotonic() + 5)++ assert found is not None and found.backend == "s6"+ service.start_existing_gateway_service(found, deadline=time.monotonic() + 5)+ assert started == ["gateway-default"]++def test_windows_startup_folder_entry_still_restarts_a_stopped_owner(tmp_path, monkeypatch):"""The Startup-folder fallback is login persistence only (no start verb, no identity): with itpresent and no Scheduled Task registered, ensure takes the same detached direct spawn manual