From 2ea5287da0ed3556110e5e5c88210b41db19ec6d Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 22 Aug 2026 03:52:02 +0530 Subject: [PATCH] fix(state): only flag uninspectable Hermes processes as holders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cmdline fallback was matching every system daemon with an unreadable fd table (init, systemd-journald, dockerd, etc.), causing FTS rebuilds to be skipped on every Linux system. Add _looks_like_hermes filter so only processes whose cmdline contains Hermes markers are flagged — matching @jackulau's suggestion of 'uninspectable AND identifiable as another Hermes process.' --- hermes_state.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hermes_state.py b/hermes_state.py index 6d6a4ddb62..1e2132ea2c 100644 --- a/hermes_state.py +++ b/hermes_state.py @@ -3065,6 +3065,21 @@ def _read_proc_cmdline(pid: int) -> Optional[str]: return None +_HERMES_CMDLINE_MARKERS = ("hermes_cli.main", "hermes_cli/main", "hermes serve", + "hermes-agent", "hermes gateway", "hermes chat") + + +def _looks_like_hermes(cmdline: str) -> bool: + """Heuristic: does this cmdline look like a Hermes process? + + Used to decide whether an uninspectable process (fd table unreadable + due to different user) should be treated as a potential state.db holder. + We only flag processes that look like Hermes, not every system daemon. + """ + lower = cmdline.lower() + return any(marker in lower for marker in _HERMES_CMDLINE_MARKERS) + + # Lifecycle statuses surfaced by session pickers. Classification looks ONLY at # a session's final message row — role, whether it carries tool_calls, and its # finish_reason — so it stays O(1) per session (see @@ -4283,9 +4298,11 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin) # Cannot read this process's fd table (different # user, e.g. root gateway vs user desktop). # /proc//cmdline is world-readable by default, - # so check whether this is a Hermes process. + # so check whether this is a Hermes process — + # only flag uninspectable holders that look like + # another Hermes instance, not every system daemon. cmdline = _read_proc_cmdline(pid) - if cmdline is not None: + if cmdline is not None and _looks_like_hermes(cmdline): holders.append((pid, f"uninspectable holder: {cmdline[:80]}")) continue for fd in fds: