Skip to content

fix(herdr): silence broken-pipe noise in capability probes - #6

Merged
rega10 merged 3 commits into
mainfrom
fm/fm-herdr-brokenpipe-noise
Jul 25, 2026
Merged

rega10 merged 3 commits into
mainfrom
fm/fm-herdr-brokenpipe-noise

Conversation

@rega10

@rega10 rega10 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

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

  • Replace Herdr’s large-schema printf | grep -Fq capability checks with in-process substring matching, preserving fail-closed behavior without TTY broken-pipe noise.
  • Add large-schema PTY regression coverage for silent successful probes, missing capabilities, and source-shape protection against early-exit schema pipelines.
  • Document the isolated Herdr verification and make GitLab merge-request URL parsing compatible with Bash 3.2.

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.

Herdr capability gate — operator-visible PTY verification
Synthetic schema: ~360 KB; live/default Herdr session: not contacted

[both required needles present]
capability_rc=0
pty_shell_rc=0
broken_pipe_messages=0
write_error_messages=0

[pane.agent_status_changed absent]
capability_rc=1
pty_shell_rc=0
broken_pipe_messages=0
write_error_messages=0
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (1h20m13s)

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 ✅
  • 🚨 tests failed with exit code 1
  • 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.sh
  • bash tests/fm-backend-herdr.test.sh
  • Manual PTY probe of fm_backend_herdr_events_capable using a ~360 KB synthetic schema: verified rc=0 with both needles, rc=1 when one needle was absent, and zero Broken pipe or write error messages in both cases.
  • git status --short after testing confirmed no transient working-tree artifacts.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

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
rega10 merged commit 7a2b1c4 into main Jul 25, 2026
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
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