Skip to content

fix(cli): use runtime pid fallback for gateway detection on macOS#11445

Closed
Hyena0x wants to merge 1 commit into
NousResearch:mainfrom
Hyena0x:fix/macos-gateway-pid-detection
Closed

fix(cli): use runtime pid fallback for gateway detection on macOS#11445
Hyena0x wants to merge 1 commit into
NousResearch:mainfrom
Hyena0x:fix/macos-gateway-pid-detection

Conversation

@Hyena0x

@Hyena0x Hyena0x commented Apr 17, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes a macOS gateway-status false negative where find_gateway_pids() can return an empty list even though the current profile's gateway is alive and healthy.

On this macOS setup, hermes cron list reported Gateway is not running while the gateway process was actually running and cron jobs were firing. The root problem is that find_gateway_pids() relies on service-manager / process-list probing that can miss the active gateway, while Hermes already has a more authoritative current-profile runtime check in gateway.status.get_running_pid().

This PR takes the smallest possible approach:

  • keep the existing cross-profile scan logic intact
  • for the current profile only, consult get_running_pid() first
  • merge that PID into the result when present

This approach is preferable because it reuses Hermes' existing PID-file/runtime validation helper instead of adding more macOS-specific parsing logic for launchctl or broadening platform-specific ps handling.

Related Issue

No dedicated issue filed.

Related open PRs for the same symptom:

This PR intentionally takes a narrower approach by reusing the existing runtime PID helper and adding regression tests.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • hermes_cli/gateway.py
    • update find_gateway_pids() to reuse gateway.status.get_running_pid() for the current profile before falling back to broader process scanning
  • tests/hermes_cli/test_gateway_service.py
    • add regression test covering runtime PID fallback for the current profile
    • add regression test ensuring exclude_pids still takes precedence over the runtime PID fallback

How to Test

  1. On macOS, start a gateway for the current profile so that gateway.status.get_running_pid() returns a live PID.
  2. Run hermes cron list (or call find_gateway_pids() directly) and verify the gateway is detected instead of being reported as not running.
  3. Run:
    • pytest -n 0 tests/hermes_cli/test_gateway_service.py -q

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4 (arm64)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Relevant targeted test output:

$ pytest -n 0 tests/hermes_cli/test_gateway_service.py -q
72 passed in 1.72s

Relevant user-visible symptom before the fix on macOS:

hermes cron list
...
⚠  Gateway is not running — jobs won't fire automatically.

After applying the fix, find_gateway_pids() correctly returns the current profile gateway PID via get_running_pid().

@teknium1

Copy link
Copy Markdown
Contributor

Superseded by #11896 (salvaged from @snreynolds's #11167). Your macOS find_gateway_pids fallback is included in the unified snapshot path that landed. Thanks @Hyena0x!

@teknium1 teknium1 closed this Apr 18, 2026
@Hyena0x

Hyena0x commented Apr 18, 2026

Copy link
Copy Markdown
Author

Thanks — glad this got addressed.

@Hyena0x Hyena0x deleted the fix/macos-gateway-pid-detection branch April 18, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants