The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: endpoint discovery canonicalizes the caller's home before matching served profiles
Teknium7ee15a24dcc9
diff --git a/hermes_cli/gateway_runtime.py b/hermes_cli/gateway_runtime.pyindex e14047a547b..975bd048ebb 100644--- a/hermes_cli/gateway_runtime.py+++ b/hermes_cli/gateway_runtime.py@@ -41,8 +41,11 @@ def _endpoint(payload: dict, home: Path) -> GatewayDiscovery:profiles = payload.get("served_profiles")if not isinstance(profiles, list):return GatewayDiscovery("inaccessible", reason_code="profile_mismatch")+ # Canonicalize BOTH sides: on Windows normcase lower-cases the served spelling, so a+ # caller's mixed-case Path (WorkerRPC) never matched and every worker saw owner_unavailable.+ wanted = _canonical_home(home)matches = [p for p in profiles if isinstance(p, dict)- and isinstance(p.get("home"), str) and _canonical_home(p["home"]) == str(home)]+ and isinstance(p.get("home"), str) and _canonical_home(p["home"]) == wanted]if len(matches) != 1 or not isinstance(matches[0].get("profile_id"), str) or not matches[0]["profile_id"]:return GatewayDiscovery("inaccessible", reason_code="profile_mismatch")state = payload.get("state")diff --git a/tests/hermes_cli/test_gateway_runtime_home_identity.py b/tests/hermes_cli/test_gateway_runtime_home_identity.pynew file mode 100644index 00000000000..ffb4d5c6803--- /dev/null+++ b/tests/hermes_cli/test_gateway_runtime_home_identity.py@@ -0,0 +1,40 @@+"""Endpoint discovery matches served homes by canonical identity on BOTH sides.++``_canonical_home`` resolves symlinks and case-folds (Windows ``normcase``). A caller+passing an un-canonicalized spelling of the same directory (the managed worker's+``WorkerRPC``, a symlinked HERMES_HOME) must still find its owner; otherwise the worker+sees ``profile_mismatch`` -> ``owner_unavailable`` although the daemon is ready.+"""+import os+from pathlib import Path++import pytest+++def _ready_payload(home: str) -> dict:+ return {'runtime_protocol': 1, 'state': 'ready', 'instance_id': 'inst', 'authority_epoch': 3,+ 'capabilities': ['session-authority-v1'], 'api_origin': 'http://127.0.0.1:4321',+ 'supervisor': 'none', 'served_profiles': [{'profile_id': home, 'home': home}]}+++def test_endpoint_matches_served_home_under_any_canonical_spelling(tmp_path):+ from hermes_cli.gateway_runtime import _canonical_home, _endpoint+ real = tmp_path / 'real-home'+ real.mkdir()+ served = str(real.resolve())+ spellings = [real, Path(served), Path(_canonical_home(served))]+ if os.name == 'nt':+ spellings.append(Path(served.swapcase()))+ else:+ link = tmp_path / 'link-home'+ link.symlink_to(real, target_is_directory=True)+ spellings.append(link)+ for home in spellings:+ discovery = _endpoint(_ready_payload(served), home)+ assert discovery.state == 'ready', (home, discovery)+ assert discovery.endpoint.profile_id == served+ # A different directory is still refused: canonical matching is not prefix or fuzzy matching.+ other = tmp_path / 'other-home'+ other.mkdir()+ assert _endpoint(_ready_payload(served), other).reason_code == 'profile_mismatch'+ assert _endpoint(_ready_payload(served), Path(served + '-suffix')).reason_code == 'profile_mismatch'