Skip to content

fix(gateway): classify service-managed status pids - #16349

Open
WuKongAI-CMU wants to merge 1 commit into
NousResearch:mainfrom
WuKongAI-CMU:fix/gateway-status-systemd-pids
Open

fix(gateway): classify service-managed status pids#16349
WuKongAI-CMU wants to merge 1 commit into
NousResearch:mainfrom
WuKongAI-CMU:fix/gateway-status-systemd-pids

Conversation

@WuKongAI-CMU

Copy link
Copy Markdown
Contributor

Summary

Fixes #16264

Tests

  • pytest tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_prefers_system_service_when_only_system_unit_exists tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_reports_manual_process_when_service_is_stopped tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_does_not_label_systemd_pid_manual_when_unit_file_is_profile_scoped tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_on_termux_shows_manual_guidance -q
  • git diff --check

Note: running the full tests/hermes_cli/test_gateway_service.py file on macOS currently hits unrelated user-systemd preflight failures in existing systemd_start/restart tests; the status-path regression tests above pass.

Gateway status already includes service-owned PIDs discovered through the service manager, but when the current profile lacks its expected unit path the fallback branch labeled those PIDs as manual foreground runs. Reusing the existing service PID discovery keeps the status output accurate without changing service control behavior.

Constraint: Profile-specific unit paths can be absent while a matching hermes-gateway service is still active under systemd.

Rejected: Dispatch every wildcard service to systemd_status | current status helpers are scoped to get_service_name() and would misreport cross-profile units.

Confidence: high

Scope-risk: narrow

Directive: Keep status display and service-control actions separate; this branch only corrects classification of already-discovered PIDs.

Tested: pytest tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_prefers_system_service_when_only_system_unit_exists tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_reports_manual_process_when_service_is_stopped tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_does_not_label_systemd_pid_manual_when_unit_file_is_profile_scoped tests/hermes_cli/test_gateway_service.py::TestGatewaySystemServiceRouting::test_gateway_status_on_termux_shows_manual_guidance -q

Tested: git diff --check

Not-tested: Full test file on macOS has existing systemd preflight failures unrelated to status output.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 27, 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 isolating the fallback classification path. The reported systemd bug remains on current main: hermes_cli/gateway.py:7038-7057 falls through when the active profile's expected unit file is absent, while find_gateway_pids() includes _get_service_pids() results at hermes_cli/gateway.py:609.

Problems

  • The new is_macos() rendering branch cannot cover a legacy/profile-mismatched launchd label: _get_service_pids() only runs launchctl list for get_launchd_label() at hermes_cli/gateway.py:143-145, which is derived from the active profile. Please add label-mismatch discovery and a test, or scope the claim to systemd.
  • The patch needs a small manual integration on current main: git apply --check applies the main fallback hunk at hermes_cli/gateway.py:7053 and the test hunks, but rejects the adjacent guidance hunk.

Suggested changes

  • Preserve the focused missing-unit/service-PID regression test when salvaging the systemd change.

Related PR #62195 is a different open approach in the same status-classification cluster, not evidence that this bug is fixed. This is an automated hermes-sweeper review.

Comment thread hermes_cli/gateway.py
pid_text = ", ".join(map(str, managed_pids))
if supports_systemd_services():
print(f"✓ Gateway is running as a systemd service (PID: {pid_text})")
elif is_macos():

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.

This only renders launchd ownership after _get_service_pids() has matched the PID, but that helper queries launchctl list only for the current get_launchd_label(). A legacy/profile-mismatched launchd label therefore still falls through as manual. Please add mismatched-label discovery and coverage, or narrow this PR's claim to systemd.

@teknium1 teknium1 added 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
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 type/bug Something isn't working

Projects

None yet

3 participants