Skip to content

fix(gateway): block uninstall from gateway child - #20489

Closed
KeaneYan wants to merge 1 commit into
NousResearch:mainfrom
KeaneYan:fix/launchd-stop-gateway-child-guard
Closed

fix(gateway): block uninstall from gateway child#20489
KeaneYan wants to merge 1 commit into
NousResearch:mainfrom
KeaneYan:fix/launchd-stop-gateway-child-guard

Conversation

@KeaneYan

@KeaneYan KeaneYan commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • re-scope the fix to the remaining gateway-child gap on current main: gateway uninstall
  • reject hermes gateway uninstall when _HERMES_GATEWAY=1
  • extend the shared lifecycle guard to catch hermes gateway uninstall and direct launchctl bootout ... hermes.gateway commands
  • retain the existing command-level stop/restart protections instead of duplicating them in launchd_stop()

Tests

  • scripts/run_tests.sh tests/hermes_cli/test_gateway_restart_loop.py -q (70 passed)
  • ruff check hermes_cli/gateway.py cron/lifecycle_guard.py tests/hermes_cli/test_gateway_restart_loop.py

Rebased onto current main (e589b73).

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels May 6, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for identifying the launchd child-process hazard. The restart and stop portions have since been covered on current main: hermes_cli/gateway.py:6778 and :6871 reject gateway-child stop/restart, while tools/terminal_tool.py:2257 blocks matching lifecycle commands before execution.

Problems

  • The launchd_stop() guard and its dispatch tests duplicate those current command-level protections, so they need rework rather than a direct cherry-pick.
  • A narrower gap remains: hermes_cli/gateway.py:6681 dispatches uninstall to launchd_uninstall(), whose launchctl bootout at :4165 is not guarded. The current terminal lifecycle pattern in cron/lifecycle_guard.py:54 covers only restart|stop.

Suggested changes

  • Re-scope the salvage to protect gateway uninstall from a gateway child, using the existing marker guard or the proposed ancestry check, and add a regression for that current path.
  • Update stop/restart tests to assert the existing command-level behavior.

Automated hermes-sweeper review.

Comment thread hermes_cli/gateway.py
@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
@KeaneYan
KeaneYan force-pushed the fix/launchd-stop-gateway-child-guard branch from 16a8087 to ba90d22 Compare July 13, 2026 03:47
@KeaneYan KeaneYan changed the title fix(gateway): refuse launchd bootout from gateway child fix(gateway): block uninstall from gateway child Jul 13, 2026
@KeaneYan
KeaneYan force-pushed the fix/launchd-stop-gateway-child-guard branch from ba90d22 to e5a6099 Compare August 6, 2026 03:53
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #93336 (c94ee2e) — your uninstall guard was cherry-picked with your authorship preserved in git log, adapted to the PID-ownership gate that replaced the raw env check (#92560), so CLI sessions spawned under the gateway tree can still uninstall while the gateway itself cannot self-target. The launchctl bootout coverage from your original scope had already landed via #93297. Thanks for the long patience on this one — filed in May, landed in August, but landed.

@teknium1 teknium1 closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants