Repository navigation
fix(skills): a found match reported as missing — grep -q SIGPIPEd awk - #608
Merged
Merged
Conversation
Root cause of the #606 failure, where `agent skills (lint + drift)` claimed `frontend-design-system` never names `frontend-design` against a tree where it does, at body line 26, and then passed on rerun. `names_skill_in_backticks` was skill_body "$file" | grep -qF "\`$skill\`" under `set -euo pipefail`. `grep -q` exits the instant it matches, which closes the pipe while `awk` is still writing the rest of the body. `awk` takes SIGPIPE, the PIPELINE exits 141, and the function reports the name missing. The match was found; the plumbing threw it away. It is a race, which is why three independent reproductions of the exact `refs/pull/606/merge` tree all passed locally and why the rerun was green. All three house skills are exposed, not just the one that fired: each names its counterpart at body line 26, 31 or 34, leaving 6.6-9.7 kB still to write. The largest remainder belongs to `frontend-design-system` -- 9,739 bytes -- which is the one that failed. The repository already knew this pattern. `tf-helpers-test.sh` carries a comment avoiding it verbatim ("`grep -q` would also SIGPIPE the guard on the way"), and ci-and-supply-chain's skill states the rule for `detect` jobs: `grep -c`, not `grep -q`, on anything behind a pipe, because a false skip beats a failure. `skills-check.sh` simply had an instance nobody had connected to it. The O4 row pairing check had the same shape with a small writer; hardened too. Fixed by capturing and then matching in bash, which needs no pipe at all. A race cannot be trusted to the gate's own green, so it gets a suite: `scripts/ci/skills-check-test.sh`, wired into the existing toolchain-free `skills` job. It forces the losing side of the race deterministically -- 239 kB of body after an early match, so the writer MUST block -- and carries two guards against itself: a negative control (a genuinely absent name must still report missing) and a mutation check asserting the PRE-FIX implementation fails the same case. Without that second one the suite could not tell the fix from the bug. It also greps the gate for new `| grep -q` instances, because the fix is one line away from being tidied back off. Observed failing on purpose: reverting the one-line fix in place turns the suite red on two assertions and names the file and line. Restored byte-identically. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Nov 6, 2026
7 tasks done
athvin
added a commit
that referenced
this pull request
Nov 29, 2026
…or it (#641) (#1425) `writer | grep -q` under pipefail is a race: grep exits on the first match, the writer takes SIGPIPE, and the pipeline returns 141, so a needle that WAS present reads as absent. #608 fixed the one instance that fired. The rule was stated only for detect jobs, and the guard scanned one file. - All 23 live sites (not just the four the ticket listed) drop -q and redirect to /dev/null instead. grep without -q drains its input, so the exit status is the same and the writer is never cut off. skills-check-test's pre-fix form stays as its mutation control and carries the exception marker. - scripts/ci/piped-grep-q-check.sh scans every tracked *.sh, ignoring comments and '# piped-grep-q: intentional'. Its self-test must FAIL on a planted violation first. It runs in make check and in rust.yml's ungated layout steps. - ci-and-supply-chain states the rule repo-wide, and tf-helpers-test.sh cross-references it. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Root cause of the #606 failure, where
agent skills (lint + drift)claimedfrontend-design-systemnever namesfrontend-design— against a tree where it does,at body line 26 — then passed on rerun.
The bug
grep -qexits the instant it matches. That closes the pipe whileawkis stillwriting the rest of the body,
awktakes SIGPIPE, the pipeline exits 141, andthe function reports the name missing. The match was found; the plumbing threw it
away.
Proven deterministically — the string is present once, and the shipped helper denies it:
Why it looked unreproducible
It's a race. Three independent reproductions of the exact
refs/pull/606/mergetree — the branch, a synthesized merge, and the fetched merge ref, each running
allfaithfully — all passed. That is what a race looks like from outside.All three house skills are exposed, not just the one that fired:
frontend-design-systemfrontend-data-uirust-conventionsThe largest remainder is
frontend-design-system's — and that is the one that failed.The repo already knew this pattern
tf-helpers-test.shcarries a comment avoiding it verbatim — "grep -qwould alsoSIGPIPE the guard on the way" — and
ci-and-supply-chain's skill states the rule fordetectjobs:grep -c, notgrep -q, on anything behind a pipe, because a falseskip beats a failure.
skills-check.shjust had an instance nobody had connected toit. The O4 row-pairing check had the same shape with a small writer; hardened too.
Fixed by capturing and then matching in bash — no pipe at all.
A race can't be trusted to the gate's own green
So it gets
scripts/ci/skills-check-test.sh, wired into the existing toolchain-freeskillsjob. It forces the losing side every time (239 kB of body after an earlymatch, so the writer must block), and carries two guards against itself:
suite would pass against a function that returns true unconditionally;
Without it the suite couldn't tell the fix from the bug.
It also greps the gate for new
| grep -qinstances, because the fix is one line frombeing tidied back off.
Observed failing on purpose
Reverting the one-line fix in place turns the suite red on two assertions and names the
file and line:
Restored byte-identically afterwards (
diff -qclean).Verification
skills-check.sh allgreen: 20 skills, 3 overrides, references current.rust.ymlparses as YAML;actionlint.shclean — 426uses:references, allS9-pinned.
make checkgreen.🤖 Generated with Claude Code