The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): an explicit --profile default names the default profile (#100817, salvage #100888)
Sahil Vishnalya684fd0e36eb9
diff --git a/gateway/status.py b/gateway/status.pyindex 151e45dbeb8..b8efbf169a4 100644--- a/gateway/status.py+++ b/gateway/status.py@@ -834,11 +834,13 @@ def _command_line_belongs_to_profile(command: str, profile_home: Path) -> bool:if profile_flag_value(command_lc) == profile_name.lower():return Truereturn command_line_names_hermes_home(command_lc, home_lc)- # Default profile: accept unless argv names another profile (any spelling the CLI pre-parser+ # Default profile: accept unless argv names ANOTHER profile (any spelling the CLI pre-parser# accepts, ``--profile=ops`` included -- a substring test let that gateway pass as the default's)# or a conflicting explicit HERMES_HOME= (its absence is not disqualifying -- HERMES_HOME usually- # arrives via the env).- if profile_flag_value(command_lc) is not None:+ # arrives via the env). ``--profile default`` names this profile: a hand-written launchd plist+ # mirrors the named-profile service shape, and rejecting it reported a live default gateway+ # as stopped (#100817).+ if profile_flag_value(command_lc) not in (None, "default"):return Falsereturn not hermes_home_assignments(command_lc) or command_line_names_hermes_home(command_lc, home_lc)diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex 150aed0655d..98da16e74ef 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -603,8 +603,9 @@ def _scan_gateway_pids(# Root home: reject argv that advertises another profile in any spelling the CLI pre-parser# accepts (``--profile=ops`` slipped past a substring test, so a default-profile fallback stop- # could SIGTERM the named gateway) or a HERMES_HOME= naming another home.- if profile_flag_value(command_lc) is not None:+ # could SIGTERM the named gateway) or a HERMES_HOME= naming another home. An explicit+ # ``--profile default`` names this home (#100817).+ if profile_flag_value(command_lc) not in (None, "default"):return Falseif hermes_home_assignments(command_lc):return command_line_names_hermes_home(command_lc, current_home_lc)diff --git a/tests/gateway/test_status.py b/tests/gateway/test_status.pyindex 37bcfb2b2c4..d0ba3d3673e 100644--- a/tests/gateway/test_status.py+++ b/tests/gateway/test_status.py@@ -425,6 +425,18 @@ class TestGatewayRuntimeStatus:), cmdline+ def test_command_line_belongs_to_profile_accepts_explicit_default(self):+ """``--profile default`` names THE DEFAULT PROFILE: a hand-written launchd plist that+ mirrors the named-profile service shape must still count as the default home's gateway+ (#100817), while a foreign ``-p coder`` keeps being rejected."""+ default_home = Path("/opt/hermes-data")+ for cmdline in (+ "hermes --profile default gateway run --replace --external-supervisor",+ "/opt/hermes/.venv/bin/hermes -p default gateway run",+ ):+ assert status._command_line_belongs_to_profile(cmdline, default_home) is True, cmdline+ assert status._command_line_belongs_to_profile("hermes -p coder gateway run", default_home) is False+def test_command_line_belongs_to_profile_normalizes_separators(self):"""A Windows argv renders HERMES_HOME with backslashes while theprofile's Path may carry forward slashes (and, on Windows, vice