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"(?:(?