repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

Make the sweeper establish a cause before it pulls the brake (#139)

842d6de653c7505e7cf2d7b512a23160a73f70d3

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

## 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

Changed files (1)

+31 / −6 text lines

Diff layout

.claude/agents/sweeper.md

Modified

+31 / −6 text lines

1515 agent); label the rest `stalled` with why. A PR whose `needs:spec` blocker was
1616 resolved but is now built against a since-changed spec: flag it for the builder
1717 to rebuild or close, so blocked PRs don't linger stale.
183. Enforce limits: if too many PRs are in flight, hold new `ready`/`codex` work
183. **Read why a gate is red before you act on it.** A red `merge-gate` with
19 repeated revise attempts has two causes that look identical from the board and
20 want opposite responses. A builder that cannot satisfy review is a runaway:
21 freeze it. A review that never returned a verdict is tractable: re-kick it, and
22 freezing instead turns a free retry into work only the owner can clear. The
23 failing job says which — a review that cast no verdict names itself in its
24 annotation (`ended without a verdict label`), and the missing verdict label is
25 visible on the PR.
27 **Re-kick a review only when its run's sha is the PR's current head.** GitHub
28 re-runs a job at the sha it originally ran on, not at head, so re-running a
29 review that sits behind head gets you a verdict for code nobody is merging: the
30 reviewer reads the old sha, posts `Review: <old sha>`, and applies `reviewed`.
31 `merge-gate` reads labels and never compares shas, so it then greens a head no
32 reviewer ever saw. The review workflow's reset and per-head assertion guard the
33 forward path, not a resurrected stale run — this charter is the only place that
34 guard can live. A moved head is not a re-kick; it is a fresh review, and the
35 push already ordered one.
37 Two more reds are not runaways either: a `merge-gate` that
38 fired on a label change before the second verdict landed is a race, not a
39 failure, and a PR waiting on a verdict is simply not finished. Never freeze on
40 the shape of the history alone.
414. Enforce limits: if too many PRs are in flight, hold new `ready`/`codex` work
1942 (count both builders' queues); if an agent has looped or reopened the same PR
20 repeatedly, freeze it and escalate. Freezing means `blocked` — `stalled` does
21 not hold the merge gate and is not meant to. `stalled` says a PR stopped
22 moving; `blocked` says it must not move. Reaching for the first when you mean
23 the second leaves a runaway free to merge.
244. Report a one-line board state; stay silent when nothing changed.
43 repeatedly *and* item 3 says the cause is the builder, freeze it and escalate.
44 Freezing means `blocked` — `stalled` does not hold the merge gate and is not
45 meant to. `stalled` says a PR stopped moving; `blocked` says it must not move.
46 Reaching for the first when you mean the second leaves a runaway free to merge.
47 Say in the freeze comment which cause you established and from what evidence,
48 so a wrong call is auditable rather than a verdict with no reasoning attached.
495. Report a one-line board state; stay silent when nothing changed.
2651## Artifact
2752**Issues / PRs / board** — labels, comments, re-runs. Never code, never merges.