Files
fleet/scripts/ci/org-drift.baseline
CatoandClaude Opus 5.5 31de29870b fix(scripts): grep -q is never the reader of a pipe under pipefail (#140)
* fix(scripts): grep -q is never the reader of a pipe under pipefail

`echo "$x" | grep -q PAT` under `set -o pipefail` can report "not found"
for text that IS there: grep -q exits on its first match and closes the
pipe, the writer takes SIGPIPE (141), and pipefail makes the pipeline
status 141, so an `if` takes the else branch on a successful match.

It is not confined to payloads past the ~4KB pipe buffer. Measured in
loki (loki#874) on a real 1,158-byte output, 3,000 calls: 2/3000 false
misses for a phrase near the top, 0/3000 via a here-string. Rare per
call; a suite makes hundreds. loki's retire-site suite went red on
exactly those phrases twice this week.

48 copies in 14 scripts here, rewritten to `grep -q PAT <<<"$x"`,
including:
- auto-merge-sweep.sh: the required-check coverage test. A false miss
  marks a green job "uncovered".
- gc-merged-worktrees.sh: `in_use`. A false miss reads a live session's
  worktree as unused. The pushed / clean / MERGED guards still stand, so
  it cannot lose work, but it can remove a directory from under a live
  session.
- cicd-hygiene, nav-contract, org-drift, verify-floor audits and
  verify-predicates: false passes and false findings.

Checked: all 14 files pass `bash -n`; every file is a 1:1 line swap (48
lines); the 8 line-continuation sites keep the here-string before the
trailing backslash; fleet's 30 CI test scripts pass before and after
(30/30 -> 30/30); workflows still parse.

Gate: scripts/ci/test-no-grep-q-in-a-pipe.sh, wired into ci.yml. Scans
scripts/ and templates/, self-tests its detector both ways, and was
proven by restoring the original auto-merge-sweep.sh line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>

* fix(ci): main was red on a ratchet that fell, and a sweep test lied

Two failures on fleet main that were blocking every PR, including this
one. Neither was caused by the grep -q rewrite: main (7ed94a2, the base
of this branch) failed CI on the same step for the same reason.

1. org-drift ratchet fell. `org-drift-audit.sh --check` failed on main
   since c43464d with "baseline entries with no matching violation - the
   ratchet fell: bitbaum/README.md". Good news: someone fixed that drift.
   Nobody lowered the baseline, so main stayed red and the auto-merge
   sweep refused everything. Line removed; --check now passes (44 repos
   swept, 3 known violations, no new contradictions).

2. test-auto-merge-sweep.sh lied. Its verdict `[ "$FAIL" -eq 0 ]` sat at
   line 400 of 473, with ~70 lines of tests appended after it. A bash
   script exits with its LAST command's status, so the verdict was
   discarded: the suite exited 0 while printing "27 passed, 1 failed",
   and its later tests were not even counted. Verdict moved to the end;
   the suite now counts 38.

   The hidden failure was real and was mine: test 13 asserted the sweep
   always "waits for CI to catch up" when the newest base run is for an
   older commit. The deadlock fix changed that - it waits only while a
   run is in flight, and otherwise dispatches CI. Test 13 now asserts
   both cases (13a waits and dispatches nothing; 13b dispatches and does
   not merge). `rearms()` moved above its first use.

Proven by mutation: an injected late failure now fails the suite;
reverting the sweep to always-wait fails 13b; making it never wait fails
13a.

Gate: scripts/ci/test-verdict-is-last.sh, wired into ci.yml, requires
every suite's verdict to be its file's last command. Proven by restoring
the old mid-file verdict. All 34 fleet CI commands are now green, and
none exits 0 while reporting a failure.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>

---------

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 11:58:34 -07:00

38 lines
2.3 KiB
Plaintext

# Existing violations that predate the org-drift audit gate.
#
# Format: <repo>/<path> # why this one is allowed
#
# This list may FALL or hold. It may never RISE without a human deciding so in
# the same PR that adds the line.
bitbaum/CLAUDE.md # historical claim from before register existed
crewless/README.md # door disagreement from before apps.conf check existed
# ---------------------------------------------------------------------------
# RETIRED NAMES AND HOSTS — inventoried 2026-09-11, when registers/retired.json
# first made them findable. DEBT, not exemptions.
#
# Seven files, in four OTHER repos, so they cannot be fixed from this one.
# Each is an agent-facing document (CLAUDE.md / AGENTS.md / README.md), which
# is the worst place for a stale address: it is what the next session reads
# before touching the repo.
#
# sbb-fundbuero/{README,CLAUDE,AGENTS}.md "SBB Fundbüro" -> "Nordbahn Fundbüro"
# Do this one first. The site it ships is titled Nordbahn Fundbüro; the
# repo still names a real transport company on a demo unconnected to it.
# evig/{CLAUDE,AGENTS}.md revampit.orangecat.ch -> evig.orangecat.ch
# hirnli/CLAUDE.md revampit.orangecat.ch -> evig.orangecat.ch
# aoz-begleitung/CLAUDE.md aoz-wohnen.orangecat.ch -> aoz.orangecat.ch
#
# An earlier attempt baselined 51 files, generated with USE_LOCAL=1. That was
# wrong: the local sweep greps every docs/*.md in local checkouts, while the
# real scan reads a narrower set of paths from the org's default branches. CI
# rejected it correctly — 44 of those entries matched nothing the production
# scan can see, and a baseline full of unreachable entries is a ratchet that
# cannot fall. Generate a baseline with the instrument that will judge it.
#
# Remove a line when you fix the file. The count may fall; it may not rise.
# ---------------------------------------------------------------------------
evig/CLAUDE.md # documents that revampit.orangecat.ch still resolves and MUST stay a 308 — the record of the retirement, not an instance of it
aoz-begleitung/CLAUDE.md # `JWT_ISSUER` is still the literal string `aoz-housing` and must stay so: src/proxy.ts and src/lib/auth/config.ts pass it as the JWT issuer, and changing it invalidates every live session. A live auth value, not a name.