fix(update): detect launchd-style dashboard/serve cmdlines when scanning stale processes - #68968
fix(update): detect launchd-style dashboard/serve cmdlines when scanning stale processes#68968nelsonwang2026 wants to merge 1 commit into
Conversation
…ing stale processes
The stale-process scanner in _find_stale_dashboard_pids matched the
dashboard/serve subcommand via a contiguous substring
("hermes_cli.main dashboard"). Real launch cmdlines interpose flags
between the module and the subcommand, e.g. launchd spawns
'python -m hermes_cli.main --profile orchestrator dashboard ...'.
The substring never matched, so hermes update left the old backend
running and the dashboard kept reporting the previous version via
/api/status (frontend/backend mismatch).
Switch to token-based matching: require the standalone token
'dashboard' or 'serve' AND a Hermes process marker. This still
excludes unrelated cmdlines that merely contain the word 'dashboard'
(e.g. a chat session).
Regression: a harness asserts the launchd cmdline is now detected,
noise is rejected, and both POSIX (ps) and Windows (wmic) paths match.
Related competing fixes: #44165, #56723, and #56745 address the same stale dashboard/serve scan when flags precede the subcommand. This patch uses broad token-plus-Hermes-marker matching; the others use positional parsing or selector stripping. Maintainer choice is needed. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing a real stale-runtime gap: current main still uses contiguous dashboard/serve command patterns in hermes_cli/dashboard_procs.py:56-66,103,136, so selectors before the subcommand are missed.
Problems
- Blocking: the proposed
_is_hermes_web_server_cmd()athermes_cli/main.py:6111-6117only checks whetherdashboard/serveoccurs anywhere in a whitespace-split command line. It does not verify that token is the subcommand. A non-server Hermes process with a baredashboardargument satisfies the marker and token checks, then reaches the kill path used by update cleanup (hermes_cli/update_cmd.py:486). - Current main moved the active scanner into
hermes_cli/dashboard_procs.pyin c64a4d7; this PR changes only the formermain.pylocation and adds no test file.
Suggested changes
- Port a positional, entrypoint-aware matcher to
_scan_dashboard_processesand consume known global selectors before requiringdashboardorserveas the first positional command. - Add POSIX and WMIC coverage for the profile-prefixed launch form and for prompt/profile-value false positives.
Automated hermes-sweeper review.
|
|
||
| def _is_hermes_web_server_cmd(command: str) -> bool: | ||
| toks = command.split() | ||
| if not any(tok in web_server_subcommands for tok in toks): |
There was a problem hiding this comment.
This accepts dashboard or serve anywhere in argv, including a non-server Hermes prompt/argument. Because lines 6113-6117 only establish that it is a Hermes process, the update cleanup can kill that unrelated process. Parse from the Hermes entrypoint and require the first positional subcommand after recognized global flags instead.
Root cause
The stale-process scanner in
_find_stale_dashboard_pids(hermes_cli/main.py) matched the dashboard/serve subcommand via a contiguous substring, e.g."hermes_cli.main dashboard". Real launch cmdlines interpose flags between the module and the subcommand. On macOS the launchd dashboard agent spawns:The substring never matched, so
hermes updateleft the old backend process running. The frontend kept reporting the previous version via/api/status(frontend/backend version mismatch) until the user manually ranlaunchctl kickstart -k.Fix
Switch from contiguous-substring matching to token-based matching: require the standalone token
dashboardorserveAND a Hermes process marker (hermes_cli/hermes). This still excludes unrelated cmdlines that merely contain the word "dashboard" (e.g. a chat session mentioning it). Applied to both the POSIX (ps) and Windows (wmic) scan paths.Regression / verification
python -m hermes_cli.main --profile orchestrator dashboard ...is now detected.py_compilepasses; patch verified to apply cleanly on pristinemain(git apply --check).Scope
Single file
hermes_cli/main.py(3 hunks, +30/-13). No behavior change for the normalhermes dashboardforeground path.🤖 Generated with Hermes Agent