Repository navigation
fix(review-runs): converge the live-work red listing before trusting it - #1243
Conversation
The status=-filtered listing that produces the default-branch red rows had no freshness handling, so a cached cold page that omits the newest rows publishes an all-clear over a live failure. Closes #1241
tend-agent
left a comment
There was a problem hiding this comment.
The doubled read is the right direction and does real work. Probing actions/runs from this session against repos it had not touched: on astral-sh/uv the first read returned a newest red row of 2026-08-18T15:55:41Z (total_count 1209) and an immediate repeat of the identical URL returned 2026-09-14T02:15:41Z (total_count 1499). So a second read does reach a fresher snapshot, and adjacency is not a problem.
Two reads are not enough, though. On openai/codex the same probe took three to reach the live row — 2026-08-15T05:55:10Z (total_count 3447), then 2026-08-28T00:09:18Z (10228), then 2026-09-14T04:37:18Z (13669). Stopping at two would have published "newest red row of any kind is 2026-08-28" with a 2026-09-14 failure standing on the branch, which is the claim shape this section exists to protect. Nor is it a cold-start cost a session pays once: a later single read of that same URL came back with the 2026-08-15 snapshot again after the fresh one, so each call independently gets whichever snapshot it gets.
A stale page is internally coherent, so the rows alone can't tell a session it has converged, and total_count is not a signal either — #1241 recorded it identical at 587 across a stale and a fresh page, and here it moved with the staleness. What the recipe can do is re-read each filter until two consecutive pages agree, capped, and union those. That costs the same two calls as this PR wherever the endpoint answers consistently, and spends more only where the answers are still moving — which is exactly the case that currently escapes.
Two smaller things in the same area. sort -u orders by conclusion then created_at ascending, because gojq sorts object keys — so the newest rows land at the bottom of each conclusion group, while the claim the section asks the session to make is about the newest row; sort -ru leads each group with its newest row at no extra cost. And the new paragraph restates what the code comment above it now says, with its last two sentences arguing for the design rather than instructing the session; CLAUDE.md's "Authoring skills" asks for the rule or recipe with motivation cut.
Pushing all three to the branch.
tend-agent
left a comment
There was a problem hiding this comment.
The convergence loop accepts an empty page on the first read, which is the one answer it most needs to re-check. prev= starts equal to what an empty page produces, so [ "$page" = "$prev" ] is true on iteration one and the loop breaks having read once. Probing this repo with status=timed_out, which has no rows: one read, then break.
That matters because empty is the maximally under-reporting answer, and it is reachable for the same reason the fixed pair was insufficient. startup_failure and timed_out typically carry a handful of rows spanning months on any one repo, so a snapshot old enough to predate all of them is empty rather than merely short — and the sweep then publishes "main is green" off a single unverified read, the claim shape this PR exists to protect. A gh api call that errors lands in the same branch (empty page, immediate break); its stderr is at least visible to the session, unlike the stale-empty case, which is indistinguishable from a genuinely clean filter.
Inline suggestion below: start prev at a value no page can equal. A genuinely empty filter then costs two reads instead of one, and a stale-empty one gets the same treatment as a stale-short one. Pushing that to the branch.
Separately, and a maintainer's call rather than mine: the block now runs ~22 lines carrying a retry cap, a convergence test and an empty-output guard, which is what running-in-ci's "Scripts over prose recipes" points at — "When a skill's code block needs edge-case handling or grows past a couple of dozen lines, put the logic in a tested script and leave the skill a one-line invocation with the intent." plugins/tend-ci-runner/scripts/ already carries github_cli and list_recent_runs.py for this workflow, and a script could separate a failed read from an empty one, which the shell form cannot. I'm not pushing that — the recipe is correct once prev is initialized, and the conversion is a change of shape, not a fix.
An empty page equalled prev's initial value, so a filter answering empty converged on its first read — the one answer most worth re-checking, since a stale-empty page reads as a clean filter and supports "main is green".
| [ "$page" = "$prev" ] && break | ||
| prev=$page | ||
| done | ||
| done | sort -ru |
There was a problem hiding this comment.
this seems like quite messy code, can we improve? We seem to be mixing bash and jq, can we rewrite in a much better way?
There was a problem hiding this comment.
Agreed — rewritten in #1245. The loop is now plugins/tend-ci-runner/scripts/red_default_branch_runs.py, the same move #1027 made for Step 4's signals: one converged-read helper for both listings, union by run id for the red rows and newest-wins for the closure read. The sentinel string is gone (Python compares read one against read two, not against a value no page can produce) and so is the sort -ru dependence on gojq's key order. Six tests cover it, with a fake gh that serves a different page per read of the same URL. The skill keeps a one-line invocation and three sentences of intent.
| ``` | ||
|
|
||
| The closure call sometimes serves a cached row weeks behind the true latest green, and staleness only moves the answer backwards — so before reporting any path as still failing, re-run its closure call once and take the newer answer. | ||
| Both calls sometimes serve an older page, and staleness moves each answer backwards — in opposite directions. On the closure read a too-old green fails to close a path that is already fixed, so the sweep over-reports: re-run that call once and take the newer answer before reporting any path as still failing. On the red listing the missing rows are the *newest* ones, so the sweep under-reports — a stale page supports "`main` is green" while a failure stands on it. Consecutive reads of the same URL have returned different snapshots, and a stale page is internally coherent, so agreement between two of them is the only convergence signal the rows carry; that is what the loop above waits for. Rows come out newest-first within each conclusion. |
There was a problem hiding this comment.
are we totally sure about this? I would guess it's more likely our code than GH is serving stale data...
There was a problem hiding this comment.
Fair challenge — I re-probed it rather than re-citing the old evidence, and it is GitHub.
Twenty reads of the byte-identical URL repos/openai/codex/actions/runs?branch=main&status=failure&per_page=50 from this session. Nineteen: newest row 2026-09-14T17:36:27Z, total_count 13704, ETag: W/"c96197dbc10b243ece16d458b824a31…". One, interleaved with fresh reads on both sides: newest row 2026-08-15T05:55:10Z, total_count 3229, and a different ETag.
The differing ETag is what rules out our side. A cache replaying a stored response replays its validator with it, so two distinct ETags mean the origin built two distinct representations — and total_count dropping to 3229 says the snapshot behind the smaller one indexes a fraction of the repo's runs, which is a server-side index rather than a truncated page. Neither response carried an Age header, so no intermediary served it. On the client side gh caches only under --cache, which nothing here passes, and the credential proxy sets flow.response.stream = True and never inspects a response body, so there is nothing between gh and the API holding a page.
Rate, for what the sweep is worth paying: ~1 read in 20, three listings per run, so a single-read sweep drops the newest rows on roughly one run in seven — and that is the run reporting the branch green.
…1245) ## Problem Two review comments on #1243, both on the block that landed there: - the convergence loop is messy — nested bash around a `gh --jq` pipeline, mixing the two languages; - and a prior question: is GitHub really serving stale pages, or is it our code? ## Solution `plugins/tend-ci-runner/scripts/red_default_branch_runs.py` replaces the loop, following the same move #1027 made for Step 4's outcome signals. One converged-read helper serves both listings: union by run id for the red rows, newest-wins for the closure read. The sentinel string is gone — Python compares the first read against the second rather than against a value no page can produce — and so is the dependence on gojq's key order, since the rows are sorted on `created_at` rather than on the text `sort -ru` happens to produce. The script also emits the scope the section's published claim rests on, instead of leaving the session to reconstruct it: `paths_closed_by_later_green` names the workflows checked, `reached_back_to` how far the listing reached, and `unconverged_listings` names any URL that never settled — a sweep that publishes an unsettled listing as complete is the outward error the whole mechanism exists to prevent. The skill keeps three sentences of intent and a one-line invocation. ## Is it GitHub or is it us? It is GitHub. I re-probed `repos/openai/codex/actions/runs?branch=main&status=failure&per_page=50` from this session, twenty reads of the byte-identical URL. Nineteen returned a newest row of `2026-09-14T17:36:27Z` with `total_count` 13704 and `ETag: W/"c96197dbc10b243ece16d458b824a31…"`. One returned a newest row of `2026-08-15T05:55:10Z` with `total_count` 3229 and a *different* ETag — one read out of twenty, interleaved with fresh ones on either side. The differing ETag is what settles it. A cache replaying a stored response replays its validator too, so two distinct ETags mean the origin built two distinct representations; and `total_count` moving from 13704 to 3229 says the snapshot behind the smaller one indexes a fraction of the repo's runs, which is a server-side index, not a truncated page. No `Age` header on either, so no intermediary served it. The client side is clear too: `gh` caches only under `--cache`, which nothing here passes, and the credential proxy sets `flow.response.stream = True` and never inspects a response body ([`proxy/inject_credentials.py`](https://github.com/max-sixty/tend/blob/main/proxy/inject_credentials.py)), so there is nothing between `gh` and the API that could hold a page. What that rate means for the sweep: at roughly 1 in 20 per read and three listings per run, a single-read sweep drops the newest rows on something like one run in seven — and the run it happens on is one that reports the branch green. ## Testing `generator/tests/test_red_default_branch_runs.py` — six tests, fake `gh` serving a different page per read of the same URL, which is what the endpoint does. They pin the regression (a stale first page must not hide the newest failure), that a consistent listing costs exactly two reads, that an empty answer is re-read before it is believed, that an unsettled listing is named rather than published, and both closure cases (a later green closes the path; a `dynamic/dependabot/...` path 404s and stays live). Ran the script against `max-sixty/tend` live: 12s, closes six workflow paths on their later greens, leaves the CodeQL and Dependabot rows live, `unconverged_listings` empty. Full `uv run pytest` is 1139 passed, with the two `test_refresh_consumers.py` DNS failures the sandbox always has. `pre-commit` passes on the three files. --------- Co-authored-by: tend-agent <[email protected]> Co-authored-by: tend-agent <[email protected]>
Problem
review-runs's live-work sweep decides whether the default branch is red right now from threestatus=-filtered run listings. #1210 gave the per-path closure call below them a freshness check; the listing that produces the rows still had none, and nothing downstream can recover a row it never returned.The two calls fail in opposite directions, which is why one fix did not cover the other. On the closure read a stale answer is a too-old green: it fails to close a path that is already fixed, and the sweep over-reports. On the red listing the omitted rows are the newest ones, so the sweep under-reports — a stale page supports "
mainis green" while a failure stands on it. The skill instructs the session to publish that claim with its scope stated, so the wrong answer ships as a published claim rather than an internal miss.The reporter's evidence checks out against the API: on
max-sixty/worktrunkthe cold call at ~07:58Z on 2026-09-14 returned a newest red row of2026-09-05T20:32:15Z, whilenightlyrun 34808417481 —pushonmain,conclusion: failure, created2026-09-14T05:06:36Z— was live at that moment: the re-run that cleared the path (34810650044) only concludedsuccessat2026-09-14T08:05:24Z. Calls two and three to the byte-identical URL, minutes later, returned it.Solution
Re-read each
status=filter until two consecutive pages agree — capped at four reads — and union what they returned. On an endpoint answering consistently that is two calls, the same cost as reading each filter once more unconditionally; it spends more only where the answers are still moving, which is the case that escapes a fixed pair.A fixed pair was the first shape here, and review found it insufficient. Probing untouched repos,
astral-sh/uvwent stale-then-fresh across two adjacent reads of the identical URL (newest row2026-08-18T15:55:41Z, then2026-09-14T02:15:41Z), butopenai/codextook three —2026-08-15T05:55:10Z,2026-08-28T00:09:18Z,2026-09-14T04:37:18Z— so stopping at two would have published a newest red row of2026-08-28with a2026-09-14failure standing. A later single read of that same URL returned the2026-08-15snapshot again, so this is not a cold-start cost a session pays once: each call independently gets whichever snapshot it gets.A stale page is internally coherent, so the rows cannot tell a session it has converged, and
total_countis not a signal — #1241 recorded it identical at 587 across a stale and a fresh page. Agreement between consecutive reads is what is left.The union is
sort -rurather thansort -u: gojq sorts object keys, so the lines lead withconclusionthencreated_at, and descending puts each conclusion group's newest row first — the row the section's published claim is about.The prose that carried the reassurance is rescoped. It previously read "staleness only moves the answer backwards" attached to the closure paragraph, where a session scanning the section could take it as covering the sweep; it now names the direction each call fails in and what the loop waits for.
I considered the reporter's alternative — one unfiltered
?branch=main&per_page=100pass filtered client-side — and it does not carry the case on its own. It serves stale pages too (a first read of it on this repo returned a newest row of2026-08-28T00:36:57Zwithtotal_count9372, against 17039 live), and on a busy repo it reaches back only hours. It would have to be unioned in addition to the filtered calls.Testing
No test. #1212 removed the 34 tests that pinned wording in skills and docs, including the one #1210 added for the closure read, on the grounds that a substring assertion constrains phrasing without constraining behavior — so adding one here would reinstate exactly what that change deleted.
Instead I ran the amended recipe against
openai/codex, the repo where the drift was widest: it returns 71 rows, no blank lines from the empty-page guard, and its newestfailurerow is the2026-09-14T04:37:18Zone that the first read had dropped. Againstmax-sixty/tendthe doubled reads collapse cleanly undersort -u— 100 lines to 51 distinct run IDs — sincegh api --jqemits one compact object per line with sorted keys.pre-commitpasses on the file, and the tests that touch this skill (test_review_runs_corrections.py,test_evidence_scripts.py,test_list_recent_runs.py) pass at 39.Closes #1241 — automated triage