Make the sweeper establish a cause before it pulls the brake (#139)
842d6de653c7505e7cf2d7b512a23160a73f70d3
Oliver Jan Krylow <oliver@bugabinga.net> ·
SSH signature · not checked
- Parent 1: fd5b0fd8dacb
## What forced this On #124 the sweeper froze a PR with `blocked` and `stalled`, reporting a repeated revision loop with the gate still failing. The shape it saw was real — revise had fired several times and `merge-gate` was red across all of them. The cause was not. The gate was red because `reviewer` ended without casting a verdict, the #114 assertion firing verbatim: `reviewer ended without a verdict label (have: [security-cleared,codex-reviewed])`. Clearing the two labels and re-running the failed jobs against the identical head produced a clean verdict with no code change. The freeze was correct on the evidence it had; the evidence was misleading, and the charter never asked for better. ## The call Read why the gate is red before acting on it. Mission item 3 keyed the freeze on the shape of the history — an agent looping on the same PR — with nothing directing it to establish a cause, so the misdiagnosis was the charter's default rather than one run's slip. Two causes look identical from the board and want opposite responses: a builder that cannot satisfy review is a runaway and should be frozen; a review that never returned should be re-kicked, which is free. The evidence that separates them already exists and costs nothing to read — a no-verdict failure names itself in its annotation, and the missing verdict label is visible on the PR. ## What we deliberately didn't do Did not weaken the freeze. A genuine repeated-revision runaway still gets `blocked` and still escalates; the added condition is that item 3 must first say the builder is the cause. Did not detect this from labels alone. The label state is what misled the sweeper in the first place — `blocked` plus a red gate looks the same either way. The job annotation is the discriminator, so that is what the charter now names. ## Evidence The first version of this PR introduced a fail-open on the sole required gate, and the review caught it. It said "re-kick it" and stopped, dropping #128's identical-head precondition. GitHub re-runs a job at the sha it originally ran on, so re-kicking a run that sits behind head produces a verdict for code nobody is merging: the reviewer reads the old sha, posts its marker for that sha, applies `reviewed`, and `merge-gate` — which compares labels and never shas — greens a head no reviewer saw. The workflow's reset and per-head assertion guard the forward path but not a resurrected stale run, so the charter is the only place that guard can live. Item 3 now bounds the re-kick to the PR's current head; a moved head is a fresh review, which the push already ordered. Worth stating plainly: the manual re-runs on #124 and #125 that motivated this change were safe only because those heads had not moved. That was a precondition relied on and not written down, which is exactly how it went missing from the charter. Separately, #131 produced five red `merge-gate` runs in twenty-six minutes, every one a label-change race where the gate evaluated before the second verdict landed. Under the old charter that is five data points shaped like a flailing PR; item 3 now names that case, and a PR simply waiting on a verdict, so neither reads as a runaway. ## Surface touched `.claude/agents/sweeper.md` — mission items 2 through 5. ## If this ages badly If the sweeper becomes too slow to freeze a real runaway because it is establishing causes, the fix is a bound on how long it investigates before defaulting to freeze — not removing the read. Reverting this file restores the previous behaviour exactly; it holds no state. Closes #128