The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: lifecycle guard Branch A anchors the CLI name at command position (#77173 path false positive)
eaglezzz0522-cloud180f98112569
diff --git a/cron/lifecycle_guard.py b/cron/lifecycle_guard.pyindex 758c66d4f59..6f41a42e172 100644--- a/cron/lifecycle_guard.py+++ b/cron/lifecycle_guard.py@@ -64,7 +64,13 @@ _GATEWAY_LIFECYCLE_PATTERN = re.compile(# `start` is intentionally excluded: starting a gateway from inside a# gateway is benign (a no-op or "already running" error), and a# legitimate cron job might start a sibling profile's gateway.- r"(?:hermes\s+gateway\s+(?:restart|stop)\b)"+ # The leading separator class (#77173): `hermes` must sit at command+ # position — start of text, after whitespace/`;`/`&`/`|`, or inside a+ # substitution/subshell opener — not be a path component. Without it, a+ # file path with embedded spaces like `/docs/hermes gateway+ # restart-notes.md` matched via the `/hermes` tail and hard-blocked an+ # innocent `cat`.+ r"(?:(?:^|[\s;&|(`])hermes\s+gateway\s+(?:restart|stop)\b)"# Branch B: launchctl ops on a hermes-gateway label. macOS launchd# labels look like `ai.hermes.gateway` / `hermes-gateway`. Requiring the# gateway identifier prevents blocking unrelated hermes services (e.g.diff --git a/tests/hermes_cli/test_gateway_restart_loop.py b/tests/hermes_cli/test_gateway_restart_loop.pyindex 441c5346093..d62f50897da 100644--- a/tests/hermes_cli/test_gateway_restart_loop.py+++ b/tests/hermes_cli/test_gateway_restart_loop.py@@ -160,6 +160,11 @@ class TestGatewayLifecyclePattern:# #92372 Branch D: `p?kill` without a leading \b matched the "kill"# tail of "skill"."hermes skill view gateway-notes && echo hermes gateway docs",+ # #77173/#77536: a file path with embedded spaces containing the+ # lifecycle words must not match — `hermes` is a path component+ # there, not a command.+ "cat '/docs/hermes gateway restart-notes.md'",+ "less /home/user/notes/hermes gateway restart runbook.txt",])def test_safe_commands(self, text):assert not _contains_gateway_lifecycle_command(text), f"Should NOT match: {text!r}"@@ -169,6 +174,12 @@ class TestGatewayLifecyclePattern:"hermes gateway restart","hermes gateway restart; echo done","hermes gateway stop && echo stopped",+ # #77173 command-position anchor must not weaken separator/subshell+ # forms either.+ "true;hermes gateway restart",+ "true && hermes gateway stop",+ "echo $(hermes gateway restart)",+ "echo `hermes gateway restart`",])def test_boundary_fix_still_blocks_real_commands(self, text):assert _contains_gateway_lifecycle_command(text), f"Should match: {text!r}"