Skip to content

fix: handle empty Hermes process arguments on Bash 3.2 - #8384

Closed
m-moravcik wants to merge 2 commits into
kunchenguid:mainfrom
m-moravcik:fm/pub-fm-hermes-bash32-words-20261112
Closed

m-moravcik wants to merge 2 commits into
kunchenguid:mainfrom
m-moravcik:fm/pub-fm-hermes-bash32-words-20261112

Conversation

@m-moravcik

@m-moravcik m-moravcik commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Separate upstream PR: bin/fm-hermes-process-lib.sh line 6 fails under macOS /bin/bash 3.2 with words[@]: unbound variable (empty array expansion under set -u). Approved upstream contribution limited to this change; no extra widening.

What Changed

  • Opravená expanzia prázdneho poľa pri rozpoznávaní procesov Hermes, aby pod Bash 3.2 so set -u nespôsobovala chybu unbound variable.
  • Pridaný regresný test, ktorý overuje, že prázdne argumenty vrátia nezhodu bez chyby pod /bin/bash aj aktuálnym Bashom.

Risk Assessment

✅ Low: The change is one line. It swaps an empty-array expansion that crashes bash 3.2 under set -u for the standard ${words[@]+"${words[@]}"} idiom. For a non-empty array the result is unchanged: each element stays a separate word, spaces included, because the inner expansion is quoted. The new regression test calls the public function in a fresh set -u child shell and checks that an empty argv is a clean non-match. On macOS /bin/bash 3.2 that test fails before the fix and passes after it, and the change stays inside the approved intent.

Testing

Pôvodný pád bol reprodukovaný cez skutočnú kontrolu živosti; oprava prešla tromi lokálnymi scenármi aj priamou regresiou. Zachované sú výstupy a stopa prázdneho vstupu. Hermes CLI ani prihlásenie sa neoverovali; všetky testovacie procesy sú ukončené.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Kontrola nečinnej lokálnej tmux relácie pod Bash 3.2 zvládne prázdne argumenty bez pádu ✅ pass live live-transcript.log; empty-argv-trace.txt
Kontrola živosti rozpozná skutočný Node so syntetickým Hermes entrypointom a natívny proces so syntetickými Python argumentmi ✅ pass live live-transcript.log: target: python; target: node
Nesúvisiaci Node eval proces nezíska Hermes identitu cez entrypoint uvedený v neskoršom argumente ✅ pass live live-transcript.log: target: decoy
Evidence: Porovnanie pôvodného kódu a opravy

Source: Porovnanie pôvodného kódu a opravy

GNU bash, version 3.2.57(1)-release (arm64-apple-darwin26)
tmux 3.5a
idle 120x30 bash 69736
idle OS argv: /bin/sh -i
python 120x30 python3 69738
python OS argv: {run-worktree}/.test-toolchain-hermes/lab/python3 -m tui_gateway.entry
node 120x30 node 69741
node OS argv: /opt/homebrew/bin/node {run-worktree}/.test-toolchain-hermes/lab/ui-tui/dist/entry.js
decoy 120x30 node 69755
decoy OS argv: /opt/homebrew/bin/node -e console.log("decoy ready"); setInterval(()=>{},1000) {run-worktree}/.test-toolchain-hermes/lab/ui-tui/dist/entry.js
{"name": "baseline: idle pane on Bash 3.2", "exit": 127, "stdout": "", "stderr": "{run-worktree}/.test-toolchain-hermes/lab/baseline/bin/fm-hermes-process-lib.sh: line 6: words[@]: unbound variable\n"}
{"name": "target: idle", "exit": 0, "stdout": "dead\nprobe returned normally\n", "stderr": ""}
{"name": "target: python", "exit": 0, "stdout": "alive\nprobe returned normally\n", "stderr": ""}
{"name": "target: node", "exit": 0, "stdout": "alive\nprobe returned normally\n", "stderr": ""}
{"name": "target: decoy", "exit": 0, "stdout": "ambiguous\nprobe returned normally\n", "stderr": ""}
{"name": "direct regression: baseline-lib.sh", "exit": 127, "stdout": "", "stderr": "~/.no-mistakes/evidence/01M7796J4KWQENNQE6HJ8Z8ZN8/hermes-bash32/baseline-lib.sh: line 6: words[@]: unbound variable\n"}
{"name": "direct regression: fm-hermes-process-lib.sh", "exit": 0, "stdout": "empty status=1; shell continued\n", "stderr": ""}
All three live scenarios passed. Real Node and synthetic Python-shaped native argv; no real Hermes CLI or login used.
private tmux kill-server exit 0
private tmux list-sessions after cleanup exit 1
all pane process PIDs are gone
Evidence: Vykonaná cesta s prázdnymi argumentmi

Source: Vykonaná cesta s prázdnymi argumentmi

+ fm_hermes_process_matches '' 69736
dead
probe returned normally
Evidence: Rozsah, postup a obmedzenia dôkazov

Source: Rozsah, postup a obmedzenia dôkazov

# Hermes Bash 3.2 live validation

The authoritative acceptance criterion is that empty argv is a clean non-match under macOS Bash 3.2 with nounset. The process-identity contract in docs/verification/hermes.md (Foreground process liveness) and the existing Hermes harness regression examples supplies the positive and adversarial oracles: the supported Node entry and Python module shapes identify an agent; an unrelated Node eval carrying the entry path is ambiguous.

The driver ran the real Firstmate tmux backend against a private, 120x30 session, using a locally compiled tmux 3.5a and libevent 2.1.12. It compared the baseline library from a02b089835a114844cc53d0429570155dfe4ef3a with target 9a382a512480e91fa86675b5f005715f33dc4093. No product source was edited.

The idle pane reproduces the real macOS no-/proc fallback: the backend passes empty args plus the real foreground PID. Baseline exits 127 with words[@]: unbound variable. Target returns dead, status 0, and no stderr. The trace excerpt confirms that this exact empty-argv path executed.

Positive input processes are a real Node runtime executing a synthetic ui-tui/dist/entry.js and a native sleep-only argv carrier launched as python3 -m tui_gateway.entry. The latter supplies synthetic process-identity input; it is not a Python interpreter or Hermes CLI. Both yield alive. A real Node eval process carrying the same entry path as a later argument yields ambiguous. These are local parser/liveness proofs, not a real Hermes application or login validation.

Exploratory Homebrew and Apple Python launchers exposed uppercase Python argv, outside the existing lowercase matcher contract, so they were unsuitable carriers for the supported python3 shape. No widening of this narrowly approved fix was made. Native empty-argv and short-lived-process ancestry explorations did not reproduce the failure; the real tmux idle path did. A first trace collection had a Python UTF-8 decoding failure; the driver now tolerates non-UTF-8 Bash xtrace bytes and completed with exit 0.

The focused empty-input regression was also executed directly against both libraries: baseline exits 127, target returns non-match status 1 and the shell continues. The private server and all four pane PIDs were confirmed stopped before completion. Build dependencies and runtime fixtures were removed from the worktree after testing. No full suite, linter, formatter, pipeline control, push or PR action was run.

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Kontrola nečinnej lokálnej tmux relácie pod Bash 3.2 zvládne prázdne argumenty bez pádu ✅ pass live live-transcript.log; empty-argv-trace.txt
Kontrola živosti rozpozná skutočný Node so syntetickým Hermes entrypointom a natívny proces so syntetickými Python argumentmi ✅ pass live live-transcript.log: target: python; target: node
Nesúvisiaci Node eval proces nezíska Hermes identitu cez entrypoint uvedený v neskoršom argumente ✅ pass live live-transcript.log: target: decoy
  • /bin/bash --version: potvrdená verzia 3.2.57.
  • Lokálne zostavenie libevent 2.1.12 a tmux 3.5a cez configure a make -j4.
  • python3 -u ~/.no-mistakes/evidence/01M7796J4KWQENNQE6HJ8Z8ZN8/hermes-bash32/drive-live.py: dokončené so statusom 0.
  • Skutočný fm_backend_agent_state tmux na súkromnom sockete: pôvodná knižnica, oprava, podporované argumenty a zavádzajúci argument.
  • Priame vykonanie regresie s prázdnym vstupom pod set -u proti pôvodnej aj opravenej knižnici.
  • Prieskumné spustenia fm-harness.sh ancestry a dostupných Python launcherov; ich obmedzenia sú zaznamenané v README.
  • Overené ukončenie súkromného servera a všetkých procesov; dočasné zostavenie odstránené a pracovný strom čistý.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with the previous CI coverage gap addressed.

Reviews (2) · Last reviewed commit: "no-mistakes(ci): Captain, ci-2 opravené:..." · Reviewed by Greptile

Comment thread tests/fm-hermes-harness.test.sh Resolved
…Hermes regresiu s TAP plánom a skorým ukončením. Bash 3.2.57: oprava prešla, pôvodná expanzia preukázateľne zlyhala. Lint, workflow testy a git diff --check prešli. Zmeny zostali lokálne; ci-1 bez zásahu
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @m-moravcik. I read the whole change on 34026e93. The one-line ${words[@]+"${words[@]}"} fix makes an empty argv a clean non-match under macOS /bin/bash 3.2 with set -u, and the result is unchanged for non-empty input. The new regression test runs under both /bin/bash and the current Bash. Your follow-up commit adds it to the stock macOS Bash CI job, which settles Greptile's P2, and that thread is resolved. The no-mistakes attestation binds this head with no skipped steps, live validation is go (3 of 3, with the baseline crash reproduced), the coverage guard and repo invariants pass, and it merges cleanly with current main afc5b760.

Status: with the captain for a decision. This isn't waiting on you. The PR edits .github/workflows/ci.yml, and we never run our usual full-suite step on a PR that changes CI configuration. Kun reviews and decides those himself. Contract class (my own read): restore, because stock macOS Bash is a supported runtime and the Hermes liveness check crashed on an idle pane. VISION.md: every rule aligns. There's nothing more for you to do here unless Kun asks.

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