BotUser
679e07a074
fix(gateway): close order-dependency + missing-verb gap in launchctl lifecycle guards
...
The gateway-lifecycle guards in cron/lifecycle_guard.py (Branch B, the
unconditional hard-block used by cron creation and the terminal tool when
_HERMES_GATEWAY=1) and tools/approval.py's launchctl rule both matched
`launchctl <verb> ... hermes[.-]?gateway` as a single sequential regex,
requiring the hermes-gateway label to appear literally AFTER the verb.
A shell command that builds the label earlier in the string — e.g. a
for-loop reading labels from a list defined before the actual launchctl
call — defeats that ordering entirely:
for item in 'ai.hermes.gateway-apollo:...' 'ai.hermes.gateway:...'; do
label=${item%%:*}; plist=${item#*:}
launchctl bootout "gui/$uid/$label"
launchctl bootstrap "gui/$uid" "$plist"
done
The literal text "hermes.gateway" only ever appears in the for-list,
never after "bootout" — so `[^\n]*\bhermes[.\-]?gateway` never matches at
the verb's position, even though the command unambiguously targets the
gateway's own launchd label.
cron/lifecycle_guard.py's verb list also didn't include `bootout` at all
(present in tools/approval.py's list and covered by its own test suite —
`launchctl bootout ai.hermes.gateway` is explicitly asserted as dangerous
there — so the omission in the sibling file looks like list drift between
the two guards rather than an intentional exclusion).
`bootout` is the verb that actually deregisters a launchd job (unlike
kickstart/stop, which just bounce a still-registered one), so a command
using it evades both guards, then removes the service from launchd with
no supervisor left to bring it back — worse than a simple restart-loop.
We hit this for real: a gateway self-restart (triggered from a chat
request to change the default model) used a raw terminal `launchctl
bootout`/`bootstrap` loop across 4 launchd labels instead of the normal
`hermes gateway restart` path. It slipped past both guards, self-bootout
killed the process mid-drain before its own follow-up bootstrap could
run, and all 4 gateway profiles ended up fully deregistered from launchd
with zero user approval (approvals.mode: manual was configured) until
someone manually re-bootstrapped them.
Fix: both guards now check "a launchctl lifecycle verb appears somewhere
AND a hermes-gateway label appears somewhere", independent of order, and
cron/lifecycle_guard.py's verb list gains bootout/kill/disable/remove to
match tools/approval.py's existing set. Internal recovery code
(hermes_cli/gateway.py's own `subprocess.run(["launchctl", "bootout",
...])` calls) is unaffected — these guards only scan shell-command
strings composed by the agent's terminal/cron tools, not the CLI's
trusted internal subprocess argument lists.
Adds regression tests in both test files reproducing the exact incident
command (label built in an earlier for-loop segment, referenced only via
`$label` at the point of the verb).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
2026-08-23 17:56:36 -07:00
..
2026-08-10 12:28:10 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 22:10:13 -07:00
2026-08-20 05:26:37 -05:00
2026-07-29 13:39:40 -07:00
2026-08-18 21:06:18 -05:00
2026-08-02 21:17:49 +05:30
2026-07-29 13:39:40 -07:00
2026-08-12 19:20:03 -07:00
2026-07-12 22:43:57 -07:00
2026-07-29 11:19:24 -07:00
2026-07-13 04:31:55 -07:00
2026-08-12 02:43:23 -07:00
2026-08-23 17:56:36 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-14 21:19:15 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 13:47:29 +05:30
2026-08-15 02:51:59 +05:30
2026-08-02 15:11:21 -07:00
2026-07-29 13:39:40 -07:00
2026-08-23 03:57:43 -07:00
2026-08-24 00:57:15 +05:30
2026-08-23 03:57:43 -07:00
2026-08-21 15:23:51 -07:00
2026-08-24 01:05:07 +05:30
2026-08-24 02:39:06 +05:30
2026-08-02 00:11:50 -07:00
2026-08-02 00:11:50 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-13 02:38:28 -07:00
2026-08-13 02:38:28 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-12 19:13:32 -07:00
2026-07-29 13:39:40 -07:00
2026-08-23 13:27:04 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-21 22:33:45 +05:30
2026-08-21 22:33:45 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-13 02:38:28 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-13 02:38:28 -07:00
2026-07-29 13:39:40 -07:00
2026-08-15 00:33:01 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-15 04:23:26 -07:00
2026-08-02 11:18:41 +05:30
2026-08-19 16:31:16 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 22:08:47 -07:00
2026-08-14 21:24:36 -07:00
2026-08-18 21:28:53 -04:00
2026-08-20 01:16:25 +05:30
2026-08-09 22:09:49 -04:00
2026-08-19 14:59:51 -05:00
2026-08-12 17:42:34 +05:30
2026-08-09 22:09:49 -04:00
2026-08-12 15:36:23 +05:30
2026-07-29 19:48:37 -07:00
2026-07-29 10:06:27 -07:00
2026-08-16 11:34:40 -07:00
2026-08-16 11:34:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 11:34:40 -07:00
2026-08-16 11:34:40 -07:00
2026-08-09 22:09:49 -04:00
2026-07-29 13:39:40 -07:00
2026-08-15 18:20:55 -07:00
2026-08-15 17:11:53 -07:00
2026-08-15 22:18:09 -07:00
2026-07-29 13:39:40 -07:00
2026-08-15 18:20:55 -07:00
2026-07-29 13:39:40 -07:00
2026-08-15 22:36:52 -07:00
2026-08-19 22:58:02 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 19:48:37 -07:00
2026-08-08 05:44:18 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 00:25:20 +05:30
2026-07-29 13:39:40 -07:00
2026-08-14 20:46:50 -07:00
2026-08-14 20:46:50 -07:00
2026-07-31 22:33:00 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-08 05:21:09 -07:00
2026-07-29 13:39:40 -07:00
2026-08-18 00:01:56 -07:00
2026-08-07 08:58:02 -07:00
2026-08-15 02:44:38 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 09:07:42 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 22:06:32 -07:00
2026-08-16 20:14:51 -07:00
2026-07-29 13:39:40 -07:00
2026-07-22 12:13:01 -05:00
2026-07-09 15:38:32 +05:30
2026-08-02 00:11:50 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 16:44:31 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:36:03 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-09 14:35:02 -07:00
2026-07-29 13:39:40 -07:00
2026-08-01 10:52:34 -07:00
2026-08-20 05:26:37 -05:00
2026-08-07 09:11:48 -07:00
2026-08-02 00:36:03 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 00:25:20 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 21:30:53 -07:00
2026-07-29 13:39:40 -07:00
2026-08-10 01:23:34 -07:00
2026-08-12 01:16:34 -07:00
2026-07-29 13:39:40 -07:00
2026-08-10 00:23:45 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-06 01:55:58 -07:00
2026-08-03 22:53:32 +05:30
2026-07-29 13:39:40 -07:00
2026-08-01 14:31:51 -07:00
2026-08-12 15:21:47 +05:30
2026-07-29 13:39:40 -07:00
2026-08-23 17:54:20 -07:00
2026-08-23 17:45:47 -05:00
2026-08-08 12:31:19 -07:00
2026-08-09 22:09:49 -04:00
2026-07-31 10:17:55 -04:00
2026-08-06 19:35:47 -06:00
2026-08-12 15:21:47 +05:30
2026-07-29 13:39:40 -07:00
2026-08-08 04:19:38 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 23:11:56 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:11:50 -07:00
2026-07-29 13:39:40 -07:00
2026-07-24 17:10:39 -07:00
2026-08-03 22:53:32 +05:30
2026-07-29 13:39:40 -07:00
2026-08-08 14:49:28 -07:00
2026-08-16 11:32:02 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 10:07:30 -07:00
2026-08-08 03:59:42 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-13 20:30:26 -07:00
2026-07-30 07:18:08 -05:00
2026-07-29 13:39:40 -07:00
2026-08-13 10:47:40 -07:00
2026-08-08 05:13:46 -07:00
2026-08-03 14:09:46 +05:30
2026-08-14 22:33:44 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-17 02:10:32 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-09 22:09:49 -04:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 09:07:55 -07:00
2026-08-19 16:10:01 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 10:17:55 -04:00
2026-07-29 13:39:40 -07:00
2026-07-17 20:55:24 +00:00
2026-08-16 23:26:10 -07:00
2026-08-18 20:03:18 -07:00
2026-08-16 23:26:10 -07:00
2026-08-16 23:26:10 -07:00
2026-07-31 21:21:10 -07:00
2026-08-16 23:26:10 -07:00
2026-07-28 14:31:24 -07:00
2026-08-16 23:26:10 -07:00
2026-08-17 01:56:50 -07:00
2026-07-29 13:39:40 -07:00
2026-08-08 02:21:36 -05:00
2026-08-16 23:26:10 -07:00
2026-07-29 13:39:40 -07:00
2026-08-08 02:21:36 -05:00
2026-07-29 13:39:40 -07:00
2026-08-03 14:24:37 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 23:26:10 -07:00
2026-08-16 23:26:10 -07:00
2026-07-29 13:39:40 -07:00
2026-08-15 23:37:15 -07:00
2026-07-29 13:39:40 -07:00
2026-08-18 21:57:53 -07:00
2026-08-18 20:03:18 -07:00
2026-07-21 12:43:00 -07:00
2026-07-18 18:49:56 -04:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-17 03:03:35 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-17 20:55:24 +00:00
2026-07-29 13:39:40 -07:00
2026-07-05 21:48:36 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 16:31:16 -07:00
2026-08-17 03:03:35 -07:00
2026-08-03 14:24:37 +05:30
2026-08-10 10:40:19 -07:00
2026-07-29 15:13:21 -07:00
2026-07-24 15:47:12 -07:00
2026-07-07 15:16:00 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 23:26:10 -07:00
2026-08-16 22:08:18 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 23:26:10 -07:00
2026-08-16 23:26:10 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 08:58:32 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-14 21:15:08 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 01:19:28 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-23 03:56:37 -07:00
2026-08-06 19:35:47 -06:00
2026-08-01 10:47:20 -07:00
2026-07-29 13:39:40 -07:00
2026-08-12 15:21:47 +05:30
2026-07-29 13:39:40 -07:00
2026-08-02 15:51:43 -07:00
2026-08-04 14:34:24 +05:30
2026-08-02 15:12:02 -07:00
2026-08-22 11:15:44 -07:00
2026-07-29 13:39:40 -07:00
2026-08-12 19:01:30 -07:00
2026-08-22 02:25:12 -04:00
2026-08-16 22:09:37 -07:00
2026-08-02 15:11:02 -07:00
2026-08-14 21:41:26 -07:00
2026-08-10 12:07:50 -07:00
2026-08-10 01:28:57 -07:00
2026-08-16 22:08:28 -07:00
2026-07-29 13:39:40 -07:00
2026-08-09 23:40:15 -07:00
2026-08-06 19:35:47 -06:00
2026-08-10 01:23:34 -07:00
2026-08-09 23:30:02 -07:00
2026-08-09 23:35:07 -07:00
2026-08-08 12:17:50 -05:00
2026-07-29 13:39:40 -07:00
2026-08-08 14:56:38 +05:30
2026-08-02 20:11:20 -07:00
2026-07-29 13:39:40 -07:00
2026-08-11 09:56:13 +10:00
2026-08-19 22:41:13 -07:00
2026-08-02 15:13:24 -07:00
2026-08-07 08:58:25 -07:00
2026-08-02 15:13:04 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-13 01:34:00 +05:30
2026-08-16 22:06:50 -07:00
2026-08-14 22:34:51 -07:00
2026-07-29 13:39:40 -07:00
2026-08-12 16:27:19 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-15 07:07:40 +05:30
2026-08-09 22:09:49 -04:00
2026-08-12 16:27:19 -07:00
2026-08-13 20:30:26 -07:00
2026-08-15 00:34:29 -07:00
2026-08-13 01:06:51 -05:00
2026-08-22 15:07:05 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 01:53:44 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 02:02:34 -07:00
2026-07-29 13:39:40 -07:00
2026-08-18 12:52:53 -07:00
2026-08-16 22:06:41 -07:00
2026-08-08 11:12:27 -07:00
2026-07-31 07:30:30 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 07:30:30 -07:00
2026-08-02 15:12:43 -07:00
2026-08-09 22:09:49 -04:00
2026-08-17 17:04:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 21:31:10 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 01:23:17 +05:30
2026-08-09 23:14:18 -07:00
2026-07-29 13:39:40 -07:00
2026-07-30 22:31:42 -07:00
2026-08-18 14:14:42 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 07:30:30 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-26 19:30:02 -07:00
2026-08-21 22:33:45 +05:30
2026-08-13 11:09:51 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-12 02:56:33 -07:00
2026-08-21 14:56:28 +10:00
2026-08-02 21:54:10 +05:30
2026-08-10 10:40:19 -07:00
2026-08-19 16:10:01 -07:00
2026-08-12 19:01:30 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 19:26:12 +05:30
2026-07-29 13:39:40 -07:00
2026-08-03 14:30:05 +05:30
2026-08-06 09:40:27 -07:00
2026-08-17 19:41:32 +05:30
2026-07-24 11:45:57 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-09 22:09:49 -04:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:10:13 -07:00
2026-08-07 09:07:55 -07:00
2026-08-07 18:41:57 -06:00
2026-08-08 04:28:19 -07:00
2026-07-29 13:39:40 -07:00
2026-08-01 15:41:21 -07:00
2026-08-12 13:57:59 +05:30
2026-08-15 23:48:15 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 19:48:37 -07:00
2026-08-17 10:03:36 -07:00
2026-08-16 22:05:59 -07:00
2026-08-01 15:38:57 -07:00
2026-08-08 04:19:49 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:11:50 -07:00
2026-08-03 13:47:29 +05:30
2026-08-02 15:52:14 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-09 22:09:49 -04:00
2026-08-14 20:24:42 -07:00
2026-08-14 20:24:42 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 16:31:16 -07:00
2026-07-21 05:27:23 -07:00
2026-08-19 01:34:54 -05:00
2026-08-19 11:20:28 -05:00
2026-07-29 13:39:40 -07:00
2026-07-14 02:59:39 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 16:10:01 -07:00
2026-08-19 16:10:01 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-08 22:54:20 +05:30
2026-08-09 22:09:49 -04:00
2026-08-08 22:54:20 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 16:10:01 -07:00
2026-07-28 11:55:48 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-28 11:53:36 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-09 22:09:49 -04:00
2026-07-29 13:39:40 -07:00
2026-08-16 21:20:29 -07:00
2026-08-16 22:08:05 -07:00
2026-07-29 13:39:40 -07:00
2026-08-16 22:08:28 -07:00
2026-08-13 20:30:26 -07:00
2026-08-15 12:53:37 +05:30
2026-08-08 14:49:28 -07:00
2026-08-08 19:59:12 -04:00
2026-08-08 19:59:12 -04:00
2026-08-23 13:27:04 +05:30
2026-08-23 13:27:04 +05:30
2026-08-10 01:23:38 -07:00
2026-08-23 15:06:03 +05:30
2026-08-08 22:54:20 +05:30
2026-08-23 03:54:52 -07:00
2026-07-29 13:39:40 -07:00
2026-07-28 18:12:26 -07:00
2026-08-09 22:09:49 -04:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 14:38:02 +05:30
2026-07-28 11:57:37 -07:00
2026-08-09 22:09:49 -04:00
2026-08-14 01:08:13 -07:00
2026-07-29 13:39:40 -07:00
2026-08-20 00:20:17 -07:00
2026-08-20 02:04:32 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-19 15:15:27 -07:00
2026-07-29 13:39:40 -07:00
2026-08-20 00:17:25 -07:00
2026-08-19 23:03:58 -07:00
2026-07-29 13:39:40 -07:00
2026-08-20 00:17:25 -07:00
2026-08-08 12:33:19 -07:00
2026-07-29 13:39:40 -07:00
2026-08-13 23:36:25 -07:00
2026-08-08 01:12:16 +05:30
2026-08-09 22:09:49 -04:00
2026-08-08 12:34:46 -07:00
2026-08-20 20:20:23 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:12:23 -07:00
2026-08-16 21:20:29 -07:00
2026-08-16 21:20:29 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 14:12:25 -07:00
2026-07-29 13:39:40 -07:00