Skip to content

The agent that grows with you

polish: reuse launchd domain probe, fast-observe in wedged tests, blank-line cleanup

kshitijk4poorb26a359de898
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py
index c65f9fe2d1c..5440fa86a86 100644
--- a/hermes_cli/gateway.py
+++ b/hermes_cli/gateway.py
@@ -5548,7 +5548,8 @@ def _wait_for_launchd_service_pid(
def launchd_restart():
label = get_launchd_label()
- target = f"{_launchd_domain()}/{label}"
+ domain = _launchd_domain()
+ target = f"{domain}/{label}"
from gateway.status import get_running_pid
try:
@@ -5610,7 +5611,7 @@ def launchd_restart():
# PID appears before trusting KeepAlive — mirrors the systemd
# branch's replacement observation.
if _wait_for_launchd_service_pid(
- label, pid, timeout=15.0, domain=_launchd_domain()
+ label, pid, timeout=15.0, domain=domain
):
print("✓ Service restart requested")
_clear_launchd_unsupported_marker()
diff --git a/tests/gateway/test_platform_base.py b/tests/gateway/test_platform_base.py
index c3e59b0c7d0..30ef0c837f4 100644
--- a/tests/gateway/test_platform_base.py
+++ b/tests/gateway/test_platform_base.py
@@ -1255,7 +1255,6 @@ class TestMediaFallbackDoesNotLeakHostPath:
assert self.SENSITIVE_PATH not in sent_text
-
class TestDockerProfileSandboxMediaTranslation:
"""MEDIA from persistent Docker sandboxes must resolve to the host
directory the profile's container actually bind-mounts (#93950).
@@ -1389,6 +1388,7 @@ class TestDockerProfileSandboxMediaTranslation:
for r in caplog.records
)
+
class _LockGovernanceProbeAdapter(BasePlatformAdapter):
"""Minimal concrete adapter for platform-lock takeover governance tests."""
diff --git a/tests/hermes_cli/test_update_wedged_gateway.py b/tests/hermes_cli/test_update_wedged_gateway.py
index 9775bece769..1668e6fe771 100644
--- a/tests/hermes_cli/test_update_wedged_gateway.py
+++ b/tests/hermes_cli/test_update_wedged_gateway.py
@@ -220,6 +220,15 @@ class TestLaunchdRestartWedgedIntegration:
"_graceful_restart_via_sigusr1",
lambda pid, timeout: events.append(("drain", pid, timeout)) or True,
)
+ # KeepAlive revival observed instantly — avoids the real 15s poll
+ # (mocked subprocess.run returns empty stdout, so the PID probe
+ # would otherwise burn the full observation timeout in time.sleep).
+ monkeypatch.setattr(
+ gateway_cli,
+ "_wait_for_launchd_service_pid",
+ lambda label, old_pid, timeout=10.0, *, domain: events.append("observe")
+ or True,
+ )
monkeypatch.setattr(
gateway_cli.subprocess,
"run",