fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for hermes chat detection (port of #2192 to main) - #2283
Conversation
…ermes chat detection Port of MemTensor#2192 (merged into fix-local-plugin-260824 on 24 Aug) onto main, so release trains building from main stop shipping the invalid pattern. The MemTensor#1915 fix shipped HERMES_CHAT_PROCESS_PATTERN as hermes(?:\\s+\\S+)*\\s+chat\\b. The (?:...) non-capturing group is PCRE syntax; pgrep -f compiles patterns with glibc POSIX ERE, which rejects it outright: pgrep: regex error: Invalid preceding regular expression (exit 2) isHermesChatRunning() collapses that failure to false, so on every daemon start the detection call errors once per poll cycle (visible as pgrep regex-error spam in journals) and the viewer stays stuck on disconnected. Fix (identical to reviewed MemTensor#2192): - pgrep wire pattern rebuilt from POSIX character classes + capturing groups only: hermes([[:space:]]+[^[:space:]]+)*[[:space:]]+chat([[:space:]]|$) - JS test helper split into its own literal (HERMES_CHAT_JS_PATTERN) so each engine gets a natively valid regex for the same grammar; chat must be a complete argv token (no chat-server false positives) - Linux-only regression runs the REAL pgrep binary and requires exit status 0 or 1, so a PCRE-ism can never pass unit tests again (the original bug sailed through because JS RegExp accepts (?:...))
🤖 Open Code ReviewTarget: PR #2283 ✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). Generated by cloud-assistant via Open Code Review. |
|
|
The ENV ISSUE above was a transient failure in the test executor's SSH transport, not a problem with this branch: That error occurs during SSH key exchange — before any git ref negotiation — so the branch was never actually fetched. Verified independently:
Could the automated test be re-run for this task? Happy to help if there's anything needed from the fork side. |
|
Thanks for the contribution and for validating the POSIX ERE behavior with the real This fix is already present on Closing this PR as duplicate/superseded so the same fix is not landed twice. It will reach |
Summary
Ports the reviewed pgrep pattern fix from #2192 onto
main, so release trains that build the local plugin frommainstop shipping an invalidpgrep -fpattern.#2192 was merged on 24 Aug into
fix-local-plugin-260824, butmain(and npm builds published from it, including 2.0.15) still carries the pre-fix pattern. This PR applies the identical reviewed change — POSIX character classes + capturing groups only for the pgrep wire format, with a dedicated JS literal for the unit-test helper.Root cause
HERMES_CHAT_PROCESS_PATTERNshipped ashermes(?:\\s+\\S+)*\\s+chat\\b. The(?:...)non-capturing group is PCRE syntax;pgrep -fon Linux compiles patterns with glibc POSIX ERE, which has no non-capturing groups and rejects the whole pattern:isHermesChatRunning()collapses every failure tofalse, so each detection poll errors and the daemon viewer stays stuck on"disconnected". The original #1915 fix passed its unit tests because JavaScript'sRegExpaccepts(?:...)— JS matching behaviour is a faithful proxy for matching, but not for pattern validity under ERE. Observed live on 26 Aug 2026 (plugin 2.0.15): one regex error per poll cycle in the daemon journal across reboots, pluscore.healthtimeouts during host load spikes while detection kept silently failing.Fix (identical to reviewed #2192)
hermes([[:space:]]+[^[:space:]]+)*[[:space:]]+chat([[:space:]]|$)HERMES_CHAT_JS_PATTERN) so each engine gets a natively valid regex for the same command grammar;chatmust be a complete argv token (nochat-serverfalse positives)pgrepbinary against the wire pattern and requires exit status 0 or 1 — exit 2 means a syntax error slipped back inVerification
pgrep -f 'hermes(?:\\s+\\S+)*\\s+chat\\b'→ exit 2 (Invalid preceding regular expression); new pattern → exit 0/1vitest run tests/unit/bridge/hermes-process.test.ts: 16/16 passed (includes the real-pgrep Linux regression)vitest run tests/unit/bridge/ tests/unit/bridge-status.test.ts→ 7 files / 39 tests passedtsc --noEmittype-check ofbridge/hermes-process.ts: cleanNotes
dist/files added.dev, but no plaindevbranch exists upstream; recent plugin fixes (fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for hermes chat detection #2192) were merged via feature branches, so this targetsmain. Happy to retarget if maintainers prefer another base.