From 20e308fea70533bf3bfa5b91f318e88156e7e8de Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 23 Aug 2026 16:44:08 -0700 Subject: [PATCH] fix: use lookbehind anchor so binary-decoded and remote-read content still scans The separator-class anchor broke two fail-closed tests (binary bytes decode to U+FFFD adjacent to the CLI name; remote head-c reads). A negative lookbehind excluding path/word chars keeps the #77173 fix while preserving every fail-closed content-scan path. --- cron/lifecycle_guard.py | 14 +++++++------- tests/hermes_cli/test_gateway_restart_loop.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cron/lifecycle_guard.py b/cron/lifecycle_guard.py index 6f41a42e17..a55f27055c 100644 --- a/cron/lifecycle_guard.py +++ b/cron/lifecycle_guard.py @@ -64,13 +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. - # 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)" + # The lookbehind (#77173): `hermes` must not be a path component or a + # word tail. Excluding `/`, word chars, `.` and `-` keeps file paths + # with embedded spaces (`/docs/hermes gateway restart-notes.md`) from + # matching via the `/hermes` tail, while every real command position + # (start of text, whitespace, `;`/`&`/`|`, `$(`, backtick, even a + # U+FFFD from binary-content decoding) still matches. + r"(?:(?