Repository navigation
fix(ci): the merge bus needs actions: read, and must not read a 403 as data - #482
Merged
Merged
Conversation
… as data
The first live bus run died in the build step with
gh: Resource not accessible by integration (HTTP 403)
gh: Not Found (HTTP 404)
having created nothing. Declaring a `permissions:` block sets every scope you do
not name to `none`, and the bus names only `contents: write` and
`pull-requests: write` — so the starvation pre-flight and the verdict
classification, both of which read `/actions/runs` to count executed steps, had
no `actions: read` and got a 403.
Nothing offline could have caught it: the simulator stubs `gh`, so token scopes
are never exercised. This is the live ladder earning its keep, and the reason
the repo insists a gate be observed working rather than reasoned about.
The 404 was the more interesting half. `gh` put its error text on stdout as well
as stderr, and the pre-flight interpolated the call straight into
`for rid in $(gh api ...)` — so the error became the loop's word list and the
next request went to `/actions/runs/gh:/jobs`. A FAILED API CALL IS NOT DATA:
the status is now checked explicitly, run ids and step counts are both verified
numeric, and an unreadable API is treated as unknown rather than as an answer.
The pre-flight fails OPEN on an unreadable API, deliberately — it only saves a
wasted batch during an outage, so letting a permissions hiccup block every merge
would be the worse trade. The verdict step fails the other way, and that
asymmetry is the point: with the API unreadable, `executed` stays 0, which would
have relabelled a genuinely RED batch as `starved` — suppressing the
`bus-failed` label and the member comments, and sending everyone to look at
their billing instead of the diff. Claiming starvation now requires evidence
rather than the absence of it.
Two simulator scenarios cover these, `preflight-blind` and `verdict-blind`, and
both were mutation-tested back to the original code. Getting there took two
passes worth recording: the stub first emitted the 403 on stderr only, which is
a tidier failure than the one that happened, and the mutation first kept the
numeric guard that absorbs the garbage. A scenario that does not reproduce the
real failure proves nothing about the fix. Suite now 56 assertions.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Nov 5, 2026
athvin
added a commit
that referenced
this pull request
Nov 5, 2026
… not data (#543) The third live attempt at a real landing was refused: #510 skip its detect jobs failed, so every gate reported skipped without running — re-run CI before batching #510 was fine. All three of its detect jobs had completed `success` twenty minutes earlier and the PR was CLEAN; the `14:18:16` timestamp that looked like a push was `updated_at` moving when the `merge-bus` label was added. The check I added in #490 was this: [ "$(gh api ... --paginate --jq '...|length' 2>/dev/null || echo 0)" != "0" ] `--paginate` emits one jq result per page and `|| echo 0` appends another on failure, so a call that emits a page and THEN errors — a secondary rate limit being the obvious candidate, given how many calls this loop makes per candidate — yields the two-line string "0\n0", which is `!= "0"`. A healthy PR is then refused as unverified. This is exactly the defect the pre-flight was fixed for in #482, reintroduced here one commit later. Replaced with a `detect_failures` function that reads the status explicitly, requires one line of three bare integers, and FAILS OPEN on anything else — consistent with the pre-flight, because `mergeStateStatus == CLEAN` remains the gate and a rate limit must not block every merge. It also compares `total_count` against what it fetched, so a commit with more than a page of check-runs says so instead of answering from a prefix. Two further traps hit while fixing it, both the same shape as the original: Whitespace-collapsing is NOT a fix. `"0\n0"` with the newline stripped is `"00"` — still numeric, still `!= "0"`. And the function's own warnings went to STDOUT, so `$(detect_failures …)` captured the warning text along with the count and skipped the PR anyway. A function whose stdout IS its return value must put diagnostics on stderr. My isolation test printed the warning and I read it as informational rather than as contamination; the simulator scenario is what caught it. Covered by `detect-read-flaky`, which asserts a healthy PR still rides when the check-runs read emits output and then fails. Mutation-tested both ways: putting the warnings back on stdout is caught, and restoring the original one-liner is caught. `detect-died` still skips, so the real guard is intact. Suite now 72 assertions. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first live bus run failed. This is why.
It died in the build step having created nothing — no branch, no bus PR, no merges.
Root cause: declaring a
permissions:block sets every scope you don't name tonone. The bus namedcontents: writeandpull-requests: writeonly — but both the starvation pre-flight and the verdict classification read/actions/runsto count executed steps, and neither hadactions: read.Nothing offline could have caught this. The simulator stubs
gh, so token scopes are never exercised. This is exactly why this repo insists a gate be observed working rather than reasoned about — the mutation-tested suite passed 45/45 against a workflow that could not make a single API call.The 404 was the more interesting half
ghput its error text on stdout as well as stderr, and the pre-flight interpolated the call straight into the loop:So the error became the word list, and the next request went to
/actions/runs/gh:/jobs— hence the 404 on a garbage run id. A failed API call is not data. The status is now checked explicitly, run ids and step counts are both verified numeric, and an unreadable API is treated as unknown rather than as an answer.The two failure modes are deliberately asymmetric
The pre-flight fails open. It only saves a wasted batch during an outage, so letting a permissions hiccup block every merge would be the worse trade. It warns and proceeds.
The verdict step fails closed. With the API unreadable,
executedstays 0 — which would have relabelled a genuinely red batch asstarved, suppressing thebus-failedlabel and the member comments, and sending everyone to check their billing instead of the diff. Claiming starvation now requires evidence rather than the absence of it.That second one was a latent bug independent of the 403, and it would have been actively misleading the first time a real batch went red during any API hiccup.
Verification
Two new simulator scenarios,
preflight-blindandverdict-blind, both mutation-tested back to the original code. Suite is now 56 assertions, all passing.Getting there took two corrections worth recording:
ghdid.Only then did the mutant get caught — on
never requested a garbage run id, reproducing the production 404 precisely. A scenario that does not reproduce the real failure proves nothing about the fix.Ladder status
#467 RIDE, nothing created🤖 Generated with Claude Code