Skip to content

The agent that grows with you

fix(gateway): read no profile config for a generic multiplexer refusal

unsupportedpastelse57149e4adec
diff --git a/hermes_cli/gateway_runtime.py b/hermes_cli/gateway_runtime.py
index bd940eebe6d..818ace3cc7a 100644
--- a/hermes_cli/gateway_runtime.py
+++ b/hermes_cli/gateway_runtime.py
@@ -219,11 +219,15 @@ def _served_by_multiplexer(home: Path, *, timeout: float) -> GatewayDiscovery |
payload = query_identify(root, timeout=timeout)
except PermissionError as exc:
# The multiplexer's pipe proved the boundary: name it for the secondary too (#140706), unless
- # the boot policy never serves this home (a standalone secondary starts its own gateway).
+ # the boot policy never serves this home (a standalone secondary starts its own gateway). Any
+ # other refusal is "not served" before a config is read, as on POSIX, where none is proven.
+ named = _refused_owner_verdict(exc)
+ if named is None:
+ return None
from hermes_cli.gateway_multiplex_mode import host_serves_named_profile
if host_serves_named_profile(root, home) is False:
return None
- return _refused_owner_verdict(exc)
+ return named
except (FileNotFoundError, ConnectionRefusedError, TimeoutError, DiscoveryError,
OSError, ValueError, TypeError):
return None
diff --git a/tests/gateway/test_runtime_bootstrap_server_identity.py b/tests/gateway/test_runtime_bootstrap_server_identity.py
index e45f072b2d0..57216031058 100644
--- a/tests/gateway/test_runtime_bootstrap_server_identity.py
+++ b/tests/gateway/test_runtime_bootstrap_server_identity.py
@@ -195,6 +195,16 @@ def test_a_served_secondary_keeps_ignoring_any_other_multiplexer_refusal(served_
assert runtime.discover_gateway_endpoint(home, timeout=1).state == "absent"
+def test_a_generic_multiplexer_refusal_never_reads_the_profile_configs(served_secondary):
+ """A plain PermissionError (POSIX too, where no pipe proves anything) is "not served" before any
+ config is read, so an unparseable default ``config.yaml`` still leaves the secondary ``absent``."""
+ from hermes_cli import gateway_runtime as runtime
+ home, _starts = served_secondary(lambda: (_ for _ in ()).throw(PermissionError("no token")))
+ (home.parent.parent / "config.yaml").write_text("gateway: [unclosed\n multiplex_profiles: {\n",
+ encoding="utf-8")
+ assert runtime.discover_gateway_endpoint(home, timeout=1).state == "absent"
+
+
def test_a_standalone_secondary_is_not_refused_for_its_elevated_default_gateway(served_secondary):
"""``gateway.standalone: true`` opts the profile out of the multiplexer, so the default gateway's
refusal is not its verdict: discovery stays its own ``absent`` and ensure starts its own gateway."""