Skip to content

ci(claude): name a capped review bot instead of "review failed" - #4126

Merged
kovtcharov-amd merged 2 commits into
mainfrom
fix/claude-run-outage-signature
Sep 25, 2026
Merged

kovtcharov-amd merged 2 commits into
mainfrom
fix/claude-run-outage-signature

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

A review bot that ran out of budget now looks different from a review that found problems. Until now both rendered the same: pr-review / run went red with "Claude produced no review" plus a warning blaming an upstream install crash, and the only way to tell a spend cap from a genuinely broken review was to pull the job log and read the CLI's raw result object. On #4119 and #4120 that was a weekly-cap rejection both times, and the lane said "the action crashed" — a cause that wasn't there.

The lane still fails. That's the point: an outage that renders as a pass is how 50 PRs once merged unreviewed. What changed is that the red is now legible — each verdict gets its own named step, so the checks list carries the cause without opening a log.

🔍 Technical details

claude-run.yml classifies the run from claude-code-action's execution_file into ok / errored / not_started / no_output, and each gets its own named step.

The outage gate keys on the CLI's own numbers, never on the rejection wording: a run that reached a model always bills tokens into modelUsage, so is_error with an empty usage map and zero cost means the request was refused before any model work. Wording is used only to narrow an outage the numbers already established (to name the budget case and say "don't rotate the credential"), never to create or suppress one — the rejection text quotes a reset date that moves, embeds a U+00B7, and in both observed cases carried no body at all. That's the same failure mode #4120 fixed on the eval preflight's probe classifier, which owns the authoritative phrase list.

The ENOENT install-crash claim now fires only when there is genuinely no execution log — which is what that crash actually looks like.

Only require_comment callers (pr-review) fail, unchanged from before: an outage on the optional lanes still must not red-X a contributor's PR.

Not doable outside YAML: pull_request_target checks out the untrusted fork tree with secrets in scope, so this file must not run a script from that tree — the detection itself has to be inline bash + jq. The tests compensate by extracting the step's real run: body and executing it against captured execution logs.

Test plan

  • pytest tests/unit/test_claude_review_posting.py — 24 tests. Nine execute the step's actual run: body against real captured execution logs, including the verbatim test(eval): write scorecard fixtures as UTF-8 so Windows can run them #4119/fix(ci): read "weekly limit" as a quota outage, not an unknown failure #4120 outage result.
  • Mutation check (already run): dropping the modelUsage term, dropping the cost term, or accepting any is_error record instead of the CLI's result record each fails exactly one test.
  • Zero-cost is not sufficient on its own — a Claude subscription run bills $0 per request, and the fixtures assert such a run still classifies ok / errored, never as an outage.
  • On the next real cap, confirm the pr-review checks list shows "Claude never reached a model — budget or credential, not this PR" rather than "Claude produced no review".

Closes nothing; makes #4080 self-reporting. Companion to #4120, which fixed the same misclassification on the eval preflight's probe.

When the review bot hit the Anthropic weekly cap, the pr-review lane went red
with "Claude produced no review" and a warning blaming an upstream install
crash — the same two lines a genuinely broken review emits. Authors and the
fleet spent days pulling job logs to find out which it was.

The lane now classifies the run from claude-code-action's execution_file and
gives each verdict its own named step, so the checks list carries the cause:
a run that reached a model always bills tokens into modelUsage, so is_error
with an empty usage map means the request was refused before any model work.
The verdict keys on those numbers, never on the rejection wording — the text
quotes a reset date that moves, embeds a U+00B7, and in both observed cases
(#4119, #4120) was absent entirely. Wording only narrows an outage the numbers
already established, to name the budget case specifically.

It still fails. An outage that renders as a pass is how 50 PRs merged
unreviewed; the goal is a legible red, not a green.

The detection has to live in workflow YAML: pull_request_target checks out the
untrusted fork tree with secrets in scope, so this file may not run a script
from that tree. The tests execute the step's real `run:` body against captured
execution logs instead, and skip where bash or jq is unavailable.
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes labels Sep 22, 2026
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

The safety note this PR rewrites is 46 action versions out of date, which quietly voids the one check it asks future bumpers to perform.

The header caveat still says the execution_file output was verified against v1.0.184, and that a bump could silently disable both the retry gate and this new classification. The workflow actually pins v1.0.230. Since the whole verdict in this PR reads from execution_file, "last verified at v1.0.184" is the sentence a reviewer would rely on — and it hasn't been true for a long time.

The good news is the mechanism is fine and you can say so with evidence rather than a re-test: today's runs on v1.0.230 still produce execution_file, which is exactly how the cap was diagnosable in the first place.

🔍 Technical details

.github/workflows/claude-run.yml on fix/claude-run-outage-signature:

  • line 29 — # \execution_file` output, which is specific to the pinned action SHA (v1.0.184).`
  • line 32 — # Re-verified when moving v1.0.183 -> v1.0.184: \execution_file` is still produced`
  • lines 338 and 361 — uses: anthropics/claude-code-action@4036a180cf690f49529f5d8c79c998855287f590 # v1.0.230

Evidence that the output survived the bump: PR #4124's pr-review / run job 106707681126 (2026-09-22 10:28 UTC, v1.0.230) reaches the verification step and reads a real result record —

{"type":"result","subtype":"success","is_error":true,"duration_ms":461,
 "num_turns":1,"total_cost_usd":0,"permission_denials_count":0,"modelUsage":{}}

That is also a live confirmation of this PR's classifier: empty modelUsage with total_cost_usd: 0 after 461 ms and one turn, which not_started catches and the current main mislabels as the install-phase ENOENT crash.

Suggested edit is just the two comment lines — bump v1.0.184 to v1.0.230 and re-date the re-verification to that job.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Offline replay — this PR's CI structurally cannot exercise this change

pull_request_target resolves uses: ./.github/workflows/claude-run.yml from the base ref, so every check on this PR ran main's copy of the lane. The change is invisible to its own CI. To close that gap, the new classifier was replayed offline against 25 archived pr-review / run jobs whose true cause is already known.

It got all 25 right. The 17 spend-cap jobs are now named as a budget outage instead of "the review failed", the 7 genuine reviews still read as successes, and one job that had been lumped in with the outage turns out to be a third cause entirely — a GitHub API rate limit that killed the action before Claude started. main's lane reported all 25 of those with two interchangeable messages; this one separates them into four.

The case that mattered most is the second disguise — the ~36s jobs whose annotation reads "the action crashed or errored before completing (often the upstream install-phase ENOENT flake)". That wording was never true: those jobs reached the CLI, got refused, and saved an execution log. They now classify as a budget outage, and ENOENT is only named when there is genuinely no log.

One honest caveat, and it is a wording issue rather than a misclassification: the no-log branch tells the reader to suspect the pinned action SHA, but PR #4105's log plainly said API rate limit exceeded for installation. The headline ("the review never ran, this red says nothing about your PR") is correct there; the suggested culprit is not. Worth a follow-up, not a blocker.

🔍 Technical details

Method. Each archived job log was replayed through the harness step's real run: body extracted from claude-run.yml at 5fbd97538e, executed under bash with jq 1.7.1 — the same jq version ubuntu-latest ships. The CLI's stream-json records were reconstructed from each log and fed in as EXEC_FILE.

Fidelity check. The reconstruction was validated against the runner's own live verdict: every job main's lane called ✅ ... completed replays as ok (7/7), and every job it called "did not finish" replays as not_started or no_output (18/18). 25/25 agreement, so the replayed input matches what the runner actually saw. Runtime output was compared only after stripping ESC[36;1m-prefixed lines, which are echoed script source rather than output.

jobs PRs true cause verdict correct
17 #4095, #4108, #4109, #4111, #4114–#4120, #4123–#4126, #4129, #4130 Anthropic spend cap — is_error: true, num_turns: 1, total_cost_usd: 0, modelUsage: {} not_started ✅
1 #4105 (job 106596633316) GitHub API rate limit; action died before the CLI ran, no execution log no_output ✅ (classification)
7 #3604, #3612, #3613, #3614, #3615, #3619, #3627 real review, published ok (12–41 turns, $1.17–$4.29, claude-opus-5) ✅

Both disguises resolve to the same record, which is why one classification removes both:

job 106701403107 (PR #4126, 46s, "disguise 1")  -> not_started
job 106715688827 (PR #4129, 36s, "disguise 2")  -> not_started

Emitted annotation for both:

::error title=Claude review never ran (harness outage)::The review for PR #4129 NEVER RAN,
so this red says nothing about PR #4129. The CLI errored on turn 1 having billed $0 with an
empty model-usage map — the request was refused before it reached a model. CAUSE: an exhausted
Anthropic spend/rate limit (amd/gaia#4080) or a rejected credential. ... Re-running this job
changes nothing until that does.

Still exits 1 on require_comment lanes — nothing was made to pass, skip, or continue-on-error.

Why zero cost alone would have been wrong: a Claude subscription bills $0 per request, so cost cannot carry the signal by itself; the empty modelUsage map is the load-bearing fact. The sampled population contains no subscription-billed run, so that term is pinned by a unit-test fixture rather than by this replay.

Scope limits worth stating. The 7 green runs are from an older window (PRs #3604–#3627) because no pr-review / run has succeeded since the cap was hit — the labelled set is therefore split across two time windows, not one continuous sample. And the replay exercises the classifier's logic, not GitHub's steps.a1.outputs.execution_file || steps.a2.outputs.execution_file wiring, which only a real run can prove.

An offline replay of 25 archived pr-review jobs turned up a cause the
no-log branch did not account for: PR #4105 (job 106596633316) died on
`API rate limit exceeded for installation`, a GitHub API limit, with no
execution log at all. The message told that reader the pinned
claude-code-action SHA was the suspect, which is the wrong fix.

Both causes are indistinguishable from inside the step — the action's
own output is not reachable from a later step — so the message now names
both and points at the failed `Run Claude` annotation, which does say
which one. The headline the outage classification exists to deliver is
unchanged: the review never ran, so the red says nothing about the PR.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

The not_started predicate holds against the live outage — I checked it against the real payload rather than assuming. All four inert jobs from #4080 (two models, three event types) carry an empty modelUsage with zero cost, so the branch fires instead of falling through to errored.

That leaves the gating, not the detection, as the open question. After this merges, a green issue-triage or pr-rereview still means the model may never have run — those lanes take the warning and exit 0, which is the false green #4138 is about.

One option, and it is your call: split the gate by classification rather than by caller.

  • not_started fails every caller. The model was never invoked, so there is nothing it could be except an infrastructure fault — it cannot be confused with a clean review.
  • no_output stays gated on require_comment, exactly as you have it. Claude ran and had nothing to say. That is legitimate silence and should stay green on the optional lanes.

That preserves your stated intent for the case where it is load-bearing, while the case that can only be a platform fault goes red everywhere. The contributor-noise cost looks cosmetic: main's branch protection requires zero status checks, so a red pr-rereview blocks nothing. And the noise is better answered by the failure text — saying plainly that this is an outage on our side, not a defect in their PR — than by going green.

🔍 Technical details

Payload, identical across pr-review (opus-5), pr-rereview (sonnet-4-6), issue-triage and issue-handler (opus-5) apart from duration_ms (505 / 244 / 385 / 433):

{
  "type": "result",
  "subtype": "success",
  "is_error": true,
  "duration_ms": 385,
  "num_turns": 1,
  "total_cost_usd": 0,
  "permission_denials_count": 0,
  "modelUsage": {}
}

Against Classify the Claude run: .is_error != true → false; ((.modelUsage // {}) | length) == 0 → true; (.total_cost_usd // 0) == 0 → true ⇒ not_started. Each execution log holds exactly one type: "result" object, so the | last selection is unambiguous.

Two smaller observations from the same logs:

  • steps.a1.outputs.execution_file is set even when a1 fails — the current verification step ran with EXEC_FILE=/home/runner/work/_temp/claude-execution-output.json, and the action prints Log saved to that same path — so the output is reachable on the failure path. What I could not confirm from the log is that the file is still on disk at classify time. If it were not, this outage would land in no_output instead, which is the one branch the split above leaves green.
  • .result and .error are both absent in all four records, so detail resolves empty and the wording-narrowing grep never fires here — the generic "budget or credential" cause is what prints. Consistent with what the PR body says about the empty body; noting it so the fallback text is not a surprise.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit d540acf Sep 25, 2026
31 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/claude-run-outage-signature branch September 25, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants