Skip to content

fix(gateway): read-only liveness probe + non-root-workspace root guard - #50047

Draft
arminanton wants to merge 2 commits into
NousResearch:mainfrom
arminanton:fix/gateway-liveness-and-root-guard
Draft

fix(gateway): read-only liveness probe + non-root-workspace root guard#50047
arminanton wants to merge 2 commits into
NousResearch:mainfrom
arminanton:fix/gateway-liveness-and-root-guard

Conversation

@arminanton

Copy link
Copy Markdown
Contributor

Two robustness fixes: (1) the passive liveness probe opens the gateway lock read-only so it can't crash the gateway with PermissionError on an alien/root-owned lock file; (2) a root-ownership guard refuses to launch the gateway as root when $HERMES_HOME is owned by a non-root user (the bindfs dual-systemd trap), overridable via HERMES_ALLOW_ROOT_GATEWAY.

Two robustness fixes: (1) the passive liveness probe opens the gateway lock read-only so it can't crash the gateway with PermissionError on an alien/root-owned lock file; (2) a root-ownership guard refuses to launch the gateway as root when $HERMES_HOME is owned by a non-root user (the bindfs dual-systemd trap), overridable via HERMES_ALLOW_ROOT_GATEWAY.
@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 Jun 21, 2026
… guard

The two-case root guard checked the general workspace-owner case (Case 2)
before the specific official-Docker case (Case 1), so inside the official
image the workspace-owner message pre-empted the Docker-specific guidance and
broke test_run_gateway_refuses_root_in_official_docker. Reorder so the more
specific Docker case wins first; both behaviors preserved, all gateway tests pass.
arminanton added a commit to arminanton/hermes-agent that referenced this pull request Jun 22, 2026
…aught+fixed 2 real defects (NousResearch#50047 root-guard order, NousResearch#50048 force_plain test sig); xhigh test is overlay-only; clean-only failures are upstream bugs our PRs fix
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for addressing the foreign-lock and root-workspace failure modes. The first issue is reproducible from the current implementation: gateway/status.py:758 still opens an existing lock with "a+", and current main only applies the root guard inside the official Docker checkout at hermes_cli/gateway.py:4679-4703.

Problems

  • The proposed open(..., "r") probe is not Windows-safe with the current helper. gateway/status.py:568-575 writes a newline to an empty handle before msvcrt.locking; the read-only PR handle cannot do that, so an empty unlocked lock is reported active.
  • The PR changes no tests. Existing coverage uses an "a+" Windows handle and verifies that write (tests/gateway/test_status.py:762-790), while root-guard coverage is limited to official Docker (tests/hermes_cli/test_gateway.py:81-115).

Suggested changes

  • Keep the probe lock-capable on Windows while catching permission failures conservatively, and add the foreign-lock, empty-Windows-lock, non-root-workspace, and Docker-message regression cases.

Automated hermes-sweeper review.

@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:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 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 sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants