Skip to content

ci: no piped grep -q under pipefail anywhere, and a repo-wide guard for it (#641) - #1425

Merged
athvin merged 1 commit into
mainfrom
ci/641-piped-grep-q
Nov 29, 2026
Merged

athvin merged 1 commit into
mainfrom
ci/641-piped-grep-q

Conversation

@athvin

@athvin athvin commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #641

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

No shell in the repo pipes into grep -q.

  • All 23 live sites converted, not just the four the ticket listed. Each drops -q and redirects to /dev/null: grep without -q drains its input, so the exit status is unchanged and the writer is never SIGPIPE'd. skills-check-test.sh's pre-fix form stays as its mutation control, with the exception marker.
  • New repo-wide guard, scripts/ci/piped-grep-q-check.sh, over every tracked *.sh. It ignores comments and lines marked # 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.
  • Rule stated repo-wide in ci-and-supply-chain, not just for detect jobs. tf-helpers-test.sh cross-references it, and CLAUDE.md's make check list includes it.

Why

Under pipefail, writer | grep -q returns 141 when the writer loses the race, so a FOUND match reads as missing. #608 fixed the one that fired. The single-file guard and the detect-only wording left every other script exposed.

Proof

make check exit 0. The guard's self-test caught its own fixture strings on the first full run (they were untracked during the earlier local run), which was fixed by marking them. skills-check-test, workflow-shell-check(-test), actionlint-required-test and alert-path-check-test all pass after the conversion.

Risk & rollback

Every converted line keeps its exit semantics. Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on brians-MacBook-Pro · 2026-11-29T10:41:48Z

  • main is green with this change on it — the merge SHA, and the run
    that proves it. A later head SHA with this commit as an ancestor counts;
    a cancelled run with zero jobs does not: — b8cfb25, rust 46243891571 + frontend 46243891587 success
  • images built, or correctly never ran because nothing that goes into
    an image changed: — success, run 46243891609
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: — run 46243905259 success; scripts only, no runtime change
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change: — infra, devcontainer success on b8cfb25; rust.yml's new ungated guard step ran in that push run
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: — Piped grep -q under pipefail: 4 live sites, a single-file guard, and a rule scoped too narrowly to find #641 CLOSED by ci: no piped grep -q under pipefail anywhere, and a repo-wide guard for it (#641) #1425 via automation
  • follow-ups are open for everything deferred here — numbers: — none
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: — ci-and-supply-chain states the rule repo-wide; the guard catches its own fixtures unless marked, which is how it was proven to fire

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

Decision on the two small-writer sites the ticket asked about (skills-check.sh: printf '%s' "$desc" and head -3): converted rather than allowlisted, so the guard needs no per-site reasoning.

🤖 Generated with Claude Code

…or it (#641)

`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: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

terraform plan

286089d · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 0 0 0
dev 0 0 0
prod 0 0 0

Planned with -refresh=false, so this is the config-versus-state diff and
not out-of-band drift. That is a security choice, not a speed one: a refreshing
plan reads secret values, and the plan role is assumable from any PR branch —
which can edit the workflow it runs under. Drift is caught at apply time, which
refreshes fully.

@athvin
athvin merged commit b8cfb25 into main Nov 29, 2026
47 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 29, 2026 08:42 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — b3573d06 Deployed Nov 29, 2026 by athvin via remove closed PR previews #154
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.

Piped grep -q under pipefail: 4 live sites, a single-file guard, and a rule scoped too narrowly to find

2 participants