Repository navigation
fix(herdr): silence broken-pipe noise in capability probes - #6
Merged
Merged
Conversation
fm_backend_herdr_events_capable piped the ~220KB api schema into grep -Fq, which exits on first match and SIGPIPEs printf on a TTY every watcher cycle. Replace with in-process case substring matches; add unit coverage and document the before/after lab verification.
rega10
pushed a commit
that referenced
this pull request
Sep 5, 2026
…oise Re-implements the still-needed core of fork PR #6 (7a2b1c4) against current upstream code. The bundled fm-pr-lib.sh GitLab-MR regex tweak is dropped: that pattern is already byte-identical in upstream. fm_backend_herdr_events_capable piped the ~220KB `herdr api schema --json` payload into `grep -Fq`. grep exits on the first match and closes the pipe while printf is still writing, so every TTY-attached watcher probe printed "printf: write error: Broken pipe" twice. The gate still returned capable, so the noise trained operators to ignore real errors on that stream. Match the two event needles with in-process `case` substring matching instead: no pipe, no early-exit consumer, no SIGPIPE. Adds test_events_capable_* to tests/fm-backend-herdr.test.sh, which drive the gate against a large synthetic schema (needles mid-body) under a PTY and fail on any broken-pipe write error. The fork's source-byte-shape lock test is intentionally omitted per the repo's no-source-assertion test rule; the PTY cases prove the behavior instead. Documents the rationale in docs/herdr-backend.md. Claude-Session: https://claude.ai/code/session_0174SML661zGCCJueePCzpY5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Stop the benign but pervasive "printf: write error: Broken pipe" noise from the Herdr adapter on nearly every monitoring/supervision cycle. The noise trains operators to ignore that output stream, which is where real errors eventually get missed.
Root cause: fm_backend_herdr_events_capable piped the ~220KB herdr api schema into grep -Fq for two needle strings (events.subscribe and pane.agent_status_changed). grep -Fq exits on the first match and closes the pipe while printf is still writing, producing Broken pipe on a TTY. The capability gate still returned success, so this was pure pollution, not a false-negative capability check.
Fix deliberately addresses the producer/consumer relationship, not symptom visibility: replace the printf|grep -Fq pipes with in-process case substring matches. Explicitly do NOT redirect stderr to /dev/null and do NOT blanket-ignore SIGPIPE. Add regression coverage (TTY-backed large-schema capable/silent, missing-needle fails closed, source-shape lock against reintroducing early-exit grep on the schema). Document the before/after isolated lab verification in docs/herdr-backend.md. Captain's live default Herdr session must remain untouched.
What Changed
printf | grep -Fqcapability checks with in-process substring matching, preserving fail-closed behavior without TTY broken-pipe noise.Risk Assessment
✅ Low: The change is narrowly scoped, preserves fail-closed capability behavior, directly removes the producer/consumer SIGPIPE cause, and conforms to the required regression coverage and documentation criteria without introducing forbidden stderr or signal workarounds.
Testing
The previously successful full-suite baseline was supplemented with the targeted security and Herdr suites plus an operator-visible PTY verification; capability detection stayed silent and correct, the missing-needle path failed closed, the GitLab parser regression passed, and no issues remain.
Evidence: TTY-backed Herdr capability transcript
Capable schema: rc=0, zero broken-pipe/write-error messages. Missing needle: rc=1, zero noise. No live Herdr session contacted.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
🔧 **Test** - 1 issue found → auto-fixed ✅
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: Fix Bash 3.2 GitLab merge request parsing, captain
✅ Re-checked - no issues remain.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"Baseline provided as successful:command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-pr-check-security.test.shbash tests/fm-backend-herdr.test.shManual PTY probe offm_backend_herdr_events_capableusing a ~360 KB synthetic schema: verified rc=0 with both needles, rc=1 when one needle was absent, and zeroBroken pipeorwrite errormessages in both cases.git status --shortafter testing confirmed no transient working-tree artifacts.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.