mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 00:28:14 +01:00
docs/chatkit
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 ( |
||
|
|
f114ea0259 |
fix(auto-merge): the sweep waited forever for CI that could never run (#123)
The green-base guard asks "is there a CI run for the base tip?". For an
automated merge the answer is permanently no: a push made with GITHUB_TOKEN
emits no workflow events, so every merge this script performs lands on the base
and produces NO CI run. `pick_base_run` then falls through to its last resort —
the newest run of all, belonging to some older commit — the sha comparison
fails, and the sweep exits 0.
The re-arm at the bottom of this file is exactly the cure, and it is
unreachable: it is gated on `merged_any`, and nothing can merge while the guard
holds. The block sits upstream of its own remedy. The guard's own comment
predicted this ("with no CI run ever produced by an automated merge, the very
next sweep would block forever") and the re-arm was placed where it cannot
answer it.
Measured on bitbaum/loki 2026-09-22: base CI history stopped on 09-13, every
sweep since exited in ~7 seconds reporting success, and FOUR non-draft green
PRs sat unmerged for up to fifteen days — the oldest opened 09-07. A human
eventually noticed and merged one by hand. A stall that exits 0 is
indistinguishable from "nothing to merge"; this is the fourth time that shape
has cost this fleet real time, after evig (11 PRs, 14h), aoz-begleitung and
ai-kit (9 days each).
The fix does NOT relax the guard. Merging onto an unverified base stays
refused. It supplies the missing evidence instead: when the tip has no run and
none is in flight, dispatch CI for it so the next sweep has a real verdict.
Self-healing, and it fails safe — a red result is then handled by the red-base
path rather than hidden by this branch.
The "genuinely catching up" case is preserved exactly: if any run is still
in flight, it waits as before and dispatches nothing. Dispatching there is what
caused the concurrency-cancellation storm on loki 2026-09-10.
This logic had no test — fleet CI covered it with `bash -n` alone, which is how
a permanent deadlock shipped. scripts/test/auto-merge-sweep-no-base-ci.sh now
drives the real script against a stubbed gh (which it was already written to
tolerate) across all three paths, and is wired into CI. Mutation-tested:
restoring the unconditional exit fails it.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|