Repository navigation
review-pr: publish the card as a PR review with findings anchored inline - #7303
Conversation
Today the bot posts card.md as one top-level issue comment. Across the 61
real cards it has published on this repo, those carry 229 findings; 120 of
them (52%) cite a `file:line`, and 65 of those lines are inside the PR's own
diff. Those are findings a reader would rather meet next to the code than
half-way down a wall of prose.
_publish.py now POSTs `/pulls/{pr}/reviews` with `event: "COMMENT"` -- never
APPROVE or REQUEST_CHANGES, this bot stays advisory and gates nothing. The
findings whose citation checks out and lands in the diff go up as `comments[]`
on their lines; everything else stays in the review body, together with a
one-line index of the ones that went inline. The index is not decoration:
without it a reader of the summary cannot tell whether findings exist
elsewhere or none do, and an invisible finding reads exactly like a finding
that was never made.
Anchoring is a privilege a finding earns. check_citations.py (ported from
ATOM, where it was built) is now wired in as run_one.sh step 3c: it writes
citations.txt, _lib.py collects it, and _publish.py refuses to anchor any
finding carrying a citation the checker flagged -- a top-level card that
cites a wrong line is a flaw the reader works around, but an inline comment
on a wrong line lands in the author's working view and is visibly wrong. With
no citations.txt at all nothing anchors and the whole card stays in the
summary, which is exactly what this bot posts today. The checker never gates
the run: it ran 1-for-2 on real cards, and a heuristic that withholds correct
reviews costs more than the defect it catches.
A review is all-or-nothing -- one anchor GitHub will not take fails the whole
call, summary included, which is worse than the comment this replaces. So a
refusal retries the same endpoint with the anchors folded back into the body
and says so. A review that silently sheds half its findings reads exactly
like a review that only had the other half.
Measured on ten of those real cards, replayed against the diffs they were
written for: the summary a reader meets first drops from 33,025 to 24,173
characters, 27% shorter, with 11 findings moved onto their lines.
Adapted from ATOM rather than copied: aiter's card writes `Review (advisory):`
where ATOM's writes `Review:` and adds a `Perf` line ATOM has no counterpart
for, so the summary matches on the bare word and keeps all three; the dedup
marker stays a literal `aiter-bot` instead of being derived from the
overridable AITER_BOT_NAME, and still searches issue comments as well as
reviews, so the markers already sitting on live PRs are not reposted over.
check_prompts.py gains three guards: the event stays COMMENT with exactly one
POST call site, the --post closure stays matched to the workflow's
permissions, and the anchoring wiring (run_one -> citations.txt -> _lib ->
_publish) cannot be half-removed in silence. selftest.sh now runs
_publish_test.py, and says out loud when pytest is absent rather than
passing over it.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
… be anchored Inline anchoring attached a finding to a single line. Two things that costs, both measured on this bot's own archived cards: Spans. 25 of 221 archived findings cite a line *range* -- `layernorm.py:1002-1012` -- and every one was anchored to line 1002 alone, so the reader saw a comment pinned to one line of a block the finding is about, which reads as a claim about that line. GitHub takes a span as start_line..line with a side for each end; cite a range and it is now anchored as one. Both endpoints and everything between must be commentable, which is exactly "inside one hunk" -- checking the ends alone would accept a span across the gap between two hunks, and one malformed entry fails the whole review, summary and all other comments with it. When only part of the span is in the diff the end that is gets a single-line anchor, rather than the finding being dropped. The span pattern is deliberately tight: an ASCII hyphen with no whitespace. A loose one reads the real card sentence "flash_kda.py:381 - 6 published tuning candidates" as the backwards span 381..6. Over 221 findings the tight form matched 25 spans and no false positive; the loose form added that one sentence and nothing true. Permalinks. A citation whose line the diff does not reach cannot be anchored -- GitHub is right to refuse it -- and used to sit in the summary as bare `moe.py:5220` text the reader had to go and find. It now also gets a blob permalink pinned to the head SHA, alone on its own line, which is the only place GitHub expands one into the code it names. Pinned and not a branch: a link that drifts off the code it was written about is a wrong anchor arriving late. The finding's own text is untouched -- the link is in addition, never instead. Neither is invented. Both run through the same gate anchoring already had: a citation check_citations.py flagged, or a card it never ran on, gets no anchor and no link, and a path that does not resolve to a file this PR touched gets no link either. A blob URL built from an unresolved basename is a guess, and a link to the wrong code is worse than no link for the same reason a wrong anchor is. Verified by replaying eight real cards against the diffs they were written for: of 37 findings, 11 now take a span anchor, 16 a single line, 2 a permalink only, 8 nothing. Auditing every span citation in the 57-card corpus, 23 of 35 span-anchor cleanly, 1 falls back to an endpoint, and 11 resolve to no file in the diff and so are left alone. Replaying also turned up a defect in the index line this change introduced: when a span collapses to one endpoint the index strips `path:563` and leaves the opening "-569". Fixed and pinned by a test. _publish_test.py gains 16 cases (spans, the hunk gap, the prose false positive, the permalink gates, and a refused *range* review degrading with its text intact); check_prompts.py gains two drift checks that build a review over a synthetic two-hunk diff and assert the shape GitHub will take rather than the source that produced it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Found by running the reviewer on this PR, on box 8, end to end. Seven gates green, 33 unit tests passing, and the payload it produced carried zero inline comments. Either bug alone is enough to erase the feature; both were present. **Citations resolved against the wrong tree.** check_citations.py picked one tree for every citation and preferred merge-target, which fetch.sh checks out at BASE_SHA -- the code before the PR. Citations into lines this PR added could never resolve there: `_publish.py:221 -- file has 171 lines`, 171 being the length on base. All six were hard-failed. head/ holds the PR's version of each changed file, merge-target/ the pre-PR tree for everything else, so neither alone is right; resolution now tries them in order per file. The reviewer found this one itself and graded it 🔴. **A 50%-precision heuristic vetoed the feature.** flagged_citations() counted both halves of the checker's output, so a proximity note disqualified a finding exactly as a hard failure did. They are not the same claim: a hard failure means the citation resolves to nothing, while a note says a quoted symbol is not within five lines of the cited one -- a quality hint the checker's own docstring puts at ~50% precision. Only hard failures disqualify now. A heuristic that silently switches off what it guards is the worse failure: a wrong anchor is visible and correctable, an absent one looks exactly like a review with nothing to say. Verified on the real card from that run, with the trees rebuilt from the PR's own head and base: **0 anchors and a 4163-character summary before, 5 anchors and 990 after**. Three tests pinned the old veto rule and failed, which is what they are for; the veto test's fixture now uses a hard failure, and a new test pins that a note leaves the anchor in place. Still unverified: whether GitHub accepts these payloads. No code here has made a live review call. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…f deleting it Ported from ATOM, where this failed for real. The first live auto-validation run got as far as invoking the validator, then died: the consumer that checks a validation report runs under errexit, and `import jsonschema` failed on the runner. No card was produced at all. aiter's consumer has the same shape -- 33 fail-closed checks, any one of which aborts fetch.sh -- so it has the same failure available to it. A review that vanishes reads, to the human waiting on it, exactly like a bot that is down, and a missing optional dependency is not evidence that anything about the PR is wrong. The integrity checks stay fail-closed: evidence that does not match this PR's head, base or patch is still never consumed. What changes is the consequence of rejecting it -- the rejection is captured, its reason recorded in auto_validation_outcome.txt, and the review falls through to the no-evidence branch, so the card says validation did not run and names why. _degrade_test.sh extracts the real consumer region out of fetch.sh by its line markers and drives those bytes with a report for the wrong head, asserting all four things the live failure got wrong. Collapsing `set +e` back reproduces that failure exactly -- verified in both repos before committing. Not ported: ATOM also had to make its validator print why a non-PASS verdict happened, because it printed the verdict alone and the report evaporated with the scratch dir. aiter's validator already names its output file, so that is a different situation and is left alone rather than changed on spec. selftest: 85 green / 0 red. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…t it
Ported from ATOM, where this happened twice in a row on a live run. The log
ended mid-sentence and said nothing further:
[run_one #2889] fetch...
GraphQL: API rate limit already exceeded for user ID 349247671.
Two defects, both present here in the same shape. errexit aborts run_one
inside the fetch pipeline, before the line that classifies a failed fetch can
run; the status is then written by the EXIT trap, which wrote the file and
printed nothing -- so the one place the reader already was said the least.
The traps now say their piece out loud, and the fetch status is taken as a
value and classified.
The classification it would have reached was also wrong for this cause:
"check gh auth/token, network, git and disk" sends someone hunting a broken
credential when the credential is fine and a quota is empty. A quota resets on
GitHub's own clock and the only correct response is to wait and re-run, so it
is named separately, quoting the refusal, and it states that nothing about the
PR was examined -- a run that looked at nothing must not be mistaken for a
review that found nothing.
_fetchfail_test.sh drives that classification with a fetch that fails two
ways, asserting the quota is named, the non-examination stated, and that a
non-quota failure still falls through to the generic cause.
selftest: 86 green / 0 red.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
"The quota resets on GitHub's own clock (an hour at most)" is not something anyone can plan around -- it means the same thing one minute before the refill and fifty-nine minutes before it. GitHub's /rate_limit endpoint does not count against the quota, so the exact refill time is readable even while the quota is spent. The line now names it: GitHub's API quota for this bot is spent (the token is fine) -- it refills at 06:26 UTC, in about 25 min; re-comment then. Nothing about this PR was examined. What is wrong, how long, what to do, and that nothing was looked at. The vague wording survives as the fallback for when the reset time cannot be read -- a wrong number would be worse than no number. The test caught a real defect while being extended for this: the reset lookup ends in a grep, which returns non-zero when it matches nothing, and under errexit that killed the run outright -- so the fallback line could never be reached. Fixed, and both paths are now asserted, along with a non-quota failure keeping its own cause. ATOM 97 green / 0 red, aiter 86 green / 0 red. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Measured on the bot's own token today: rocm-atom-bot reports core 58/60 and graphql 0/0. An authenticated account gets 5000/5000 -- 60 with GraphQL at zero is the profile GitHub leaves on an account it has restricted. That is what has been failing every run, and it is not a quota that refills. I had this wrong twice in a row, and told a person to wait an hour for it. The message shipped an hour ago would have said the same: it reads the reset timestamp and promises a refill. For a restricted account that promise sends someone to wait for something that never arrives, which is worse than the vague wording it replaced. So the two are now distinguished by what only one of them looks like -- a 60-call cap with GraphQL disabled -- and the restricted case says plainly that waiting will not clear it, and that the account needs unflagging or the bot needs a different one. Both still say that nothing about the PR was examined. Test covers all four paths now: refill time readable, refill time unreadable, restricted account, and a non-quota failure keeping its own cause. Removing the restricted branch makes it fail on both of its assertions. ATOM 97 green / 0 red. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… did used the wrong flags Found by this bot reviewing its own PR. All three findings held up under my own verification; two of them are about code committed today. 1. check_citations.py's main() called tree_for(); only trees_for() exists, and it then passed a `trees` it never assigned. Every invocation raised NameError. run_one.sh's `|| true` swallowed the crash, citations.txt carried a Python traceback, and _publish.py's flagged_citations() read that traceback as "nothing flagged" -- so findings were anchored inline with zero citation checking, which is the exact failure this checker was added to prevent. The proof is this PR's own run: reports/PR-7303/citations.txt is a traceback, and the gate was green. The 34 pytest cases all exercise check(). Nothing called main(). A function no test calls is a function that does not work yet, so _citations_test.sh now runs it end to end on a resolvable and an unresolvable citation; restoring the NameError fails all four assertions. 2. Every fetch-failure classification added today was unreachable in production. run_one.sh runs `set -euo pipefail`, and W="$(grep ... | tail | cut)" is a fatal assignment when grep matches nothing -- the script died there, before any classification. The region tests passed only because they ran the extracted bytes under bare `set -e`. Measured both ways: `set -e` writes the status file and names the cause; `set -euo pipefail` exits 1 silently with no status at all. That is the defect this project exists to catch, sitting in my own test. All region tests now run under the flags the scripts actually use, and removing the guard fails eight assertions instead of passing. 3. The same unguarded shape in fetch.sh's rejection handler (also `set -euo pipefail`), which would kill the handler whose whole purpose is to keep the review alive. Guarded in both repos. ATOM 98 green / 0 red, aiter 87 green / 0 red. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The bot's review of this PR reported that the diff no longer applies to the merge target: main gained e10bd0a (#6865), whose [derive] selftest block lands exactly where this branch adds its own test lines. Verified -- that one file is the only conflict, and every other changed file's base blob still matches main. Both sides are kept: #6865's [derive]/[mapping] cases and this branch's degrade, fetch-failure and citation tests are unrelated checks in the same file. selftest is 97 green / 0 red on the merged tree, ruff clean, 34 pytest cases passing. Merged rather than rebased so the published branch only ever moves forward. # Conflicts: # .claude/skills/review-pr/selftest.sh
Found by this bot reviewing this PR, and it is the half of its own earlier finding that I fixed badly. That finding asked for two things: stop check_citations.py crashing, and stop flagged_citations() reading a crash as "nothing was flagged". I did the first and left the second, so the crash was gone but the defence against the next one was never built. The module docstring already promised this behaviour -- "when citations.txt is missing or the checker could not run, nothing is anchored" -- while the code did the opposite for the one case that actually happened: a file with content but no CITATIONS verdict line returned an empty set, which means "every citation checks out", so every finding anchored with no checking at all. Absence of a verdict line is now treated as "the checker did not run", however the file got that way. The test feeds the real traceback this PR produced two revisions ago; removing the guard fails it. aiter 35 pytest cases, ATOM 33. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
zufayu
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #7303 — review-pr: publish the card as a PR review with findings anchored inline
Review (advisory):
Validation (deterministic): N/A — no runtime surface changed
Perf (advisory): N/A — no runtime surface changed
📝 [verified] The PR body's verification counts trail the head it will merge at: the Update section says _publish_test.py "goes from 17 cases to 33" while the file at head has 34 (selftest prints "34 passed"), and the Verification block's "84 green / 0 red" selftest snapshot is 97 / 0 at head — a body whose whole argument is measured, checkable claims should not ship stale ones. Reviewer should ask the author to refresh the counts before marking ready.
📝 [verified] No live GitHub review call has ever been made by this code (the PR's own "What is not verified"), so the exact payload shape — start_line/start_side as built, the hunk-containment rule as modelled — is untested against the real API, with only the degrade-to-summary fallback standing behind it. Reviewer should ask the author to attach the _publish.py <pr> --payload dry-run JSON on one real PR (the body's own suggested landing step) before marking ready.
1 finding(s) posted inline, on the lines they are about:
.claude/skills/review-pr/_publish.py:211-248— _publish.py:211-248
b841de1 staged `.claude/skills/review-pr/` as a directory, which picked up the eleven files a review run had just written to reports/PR-7303/. They are not part of this change: they are one run's output, about one commit, and `run_one.sh` regenerates them. A tracked card is also wrong the moment the PR moves -- the one committed here reports a finding that is already fixed at head, and it cites a crashed citations.txt as evidence. A .gitignore in the skill directory stops the next one, because the mistake is `git add <dir>` and that will happen again. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
main() returned 0 whether the review went up or was refused. It printed "❌ failed to post" and then told the caller everything was fine -- so a refusal would be invisible to the workflow step, on every run, while each card was quietly lost. That matters most for the one refusal the degrade path cannot cover. The anchored-then-summary fallback handles a bad anchor; it cannot handle a token that may post issue comments but not create reviews at all (`Issues: write` without `Pull requests: write` on a fine-grained PAT). Both attempts fail, and until now the step stayed green. This is not hypothetical here: aiter-bot has `read` on this repo and has created zero reviews across the PRs checked, where it has posted an issue comment on each. That is equally consistent with "the scope is fine and it has never tried" and with "the scope is missing" -- the two are indistinguishable from the outside, which is the whole shape this pipeline exists to break. The holder says the scope is sufficient; this makes being wrong about that cost one red step instead of every card. The test pins the refusal the API actually sends and asserts its words reach the operator. Writing it caught a second defect in itself: stubbing every API call made the gate skip on PR metadata, so the test passed without reaching the code it names. It now refuses only the review POST. aiter 36 cases / 97 green, ATOM 34 cases / 98 green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Both defects found by @zoe-cop in review; both verified before changing anything, and both hold. The basename fallback searched trees[0], which is head/ -- a sparse tree holding only the files the PR changed. A citation of real context code by bare basename (moe.py:5220 in a file this PR never touched) therefore matched nothing and was reported as "no such file in the tree", i.e. an invented path, rather than the ambiguity note it was meant to get. _unflagged_cites then forfeits the whole finding's anchor AND permalink on any single hard failure, including a correct, fully-qualified, in-diff citation in the same sentence. So citing context code switched anchoring off silently -- the failure this checker was added to prevent, produced by the checker. It now searches merge-target/, the full tree at BASE_SHA. Fixing that exposed a second half: hits[0] could come from the diff (present in head/) or from the basename search (present in merge-target/), while resolution assumed one tree, so a single hit landed on "is in the diff but not the tree". Resolution now follows whichever tree actually holds the file. Verified on all three verdicts: a lone context file resolves, several of the same name give a note, an invented path still fails. Second: the summary-only retry appended the folded findings to a body still carrying build_review's "N finding(s) posted inline, on the lines they are about" index. True of the attempt GitHub refused, false of the one being sent, where comments[] is empty -- so the degraded review pointed the reader at lines carrying nothing and then listed the same findings again. That is the inverse of the silence this fallback exists to prevent. The index is now stripped before folding. @zoe-cop also diagnosed why the existing test could not catch it: it asserts a retry happened and that comments[] emptied, never what the body says, so it passes on the stale index alone. The new test asserts the anchored body carries the index and the degraded body does not. selftest 97 green / 0 red, 37 pytest cases. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Found by running this PR's own verification the way its description tells a
reviewer to: on a clean `git archive HEAD` export, not the working tree.
$ python3 check_prompts.py
FileNotFoundError: '.claude/skills/review-pr/SKILL.md'
_skill_md asked git for the repo root. `git rev-parse --show-toplevel` prints
an empty string when there is no repo, and Path("", ".claude", ...) is then a
RELATIVE path resolved against the caller's cwd -- so the check that exists to
catch prompt drift could not run at all in the one place a reviewer would run
it. It passed every time it was tried because every trial was inside a
checkout, including a "fresh /tmp worktree", which is still a git tree.
SKILL.md sits next to check_prompts.py. It reads it from there and asks git
nothing.
The guard reproduces a real export -- `git archive HEAD | tar -x` of the
tracked tree, no .git -- and asserts exit 0 from a cwd outside it. Writing it
the obvious way first (copy the skill directory alone) asserted something the
project does not promise and failed on an unrelated missing workflow file; a
guard has to test the thing that was promised, which here is the export.
Restoring the git-root lookup turns it red in both repos.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The guard added a moment ago built its fixture with `git archive HEAD`. Run from a working tree that passes; run the suite from a clean export -- which is what this PR's description tells a reviewer to do -- and there is no repo to archive from, so the guard failed and the suite went red for a reason that had nothing to do with the code under test. A guard that only works inside a checkout cannot test leaving one. It now builds the fixture directly: the skill tree at its repo depth plus the workflow file the check reads, in a directory with no .git. No git involved, so it behaves the same inside a checkout and outside one. This also closes the loop the previous commit opened. The whole suite now runs green from inside a clean export in both repos -- aiter 98/0, ATOM 99/0, drift clean, pytest passing -- which is the state the verification instructions have been describing all along and that nothing had ever checked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…efuter Hit while re-reviewing ATOM#2762, whose diff grew past the 40-minute worker budget after main was merged in. Raising AGENT_TIMEOUT is the obvious response and the timeout message names that exact knob -- but a review runs two agents in series, and the gate that starts each one refuses to begin an attempt that cannot finish inside RUN_BUDGET. So with AGENT_TIMEOUT=5400 against the default RUN_BUDGET=7200, the worker runs, the refuter cannot start, the `independent` gate reds, and the review is withheld after an hour of work -- reported as a timeout whose named fix makes it worse the next time. The constraint is AGENT_TIMEOUT x 2 <= RUN_BUDGET, and nothing enforced it. It is checked now before any work is spent, with an error that names both numbers and both ways out. Exit 2, distinct from the review's own failures. Verified on three pairs: 5400/7200 refused, 5400/14400 accepted, and the shipped defaults (2400/7200 here, 2400/6000 on aiter) unaffected. Removing the check turns the selftest red. ATOM 100 green / 0 red, aiter 99 green / 0 red. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
CI's "Lint the skill for real errors" step runs ruff with --select F,E9 -- the rules that catch actual mistakes rather than style -- and it went red on F401: `import subprocess` became dead when _skill_md stopped shelling out to `git rev-parse` in 058dfd0. My own ruff run used the repo's default rule set, which does not include F401, so the check I ran and the check CI runs were not the same check. ATOM is unaffected: its check_prompts still calls subprocess elsewhere. selftest 99 green / 0 red, ruff --select F,E9 clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…direct (#7525) Co-authored-by: Cursor <[email protected]> #7303 moved the gate's heredoc opener to `<<'PY' 2>"$WORK/validation_rejected.txt"`. run_review_gate extracts the block with a pattern that wants a newline right after `<<'PY'`, so it found no block and the three identity-gate tests failed. The opener may now carry text after the delimiter. Co-authored-by: Xin Huang <[email protected]>
What this changes
Today
_publish.pypostscard.mdas one top-level issue comment. This changes it to post a PR review —POST /repos/{owner}/{repo}/pulls/{pr}/reviewswithevent: "COMMENT", neverAPPROVEorREQUEST_CHANGES— with the findings that can be anchored attached to the lines they are about, and everything else left in the review body.The mechanism is ported from ROCm/ATOM's
feat/atom-review-bot. ATOM's bot has never posted successfully (its machine account is flagged), so this code has never run against live GitHub. aiter's bot is live, which is why this is a draft — see "What is not verified" below.Why
Across the 61 real cards this bot has already published on this repo, there are 229 findings. 120 (52%) cite a
file:line, and 65 of those lines are inside the PR's own diff. Those are findings a reader would rather meet next to the code than half-way down a wall of prose.Measured on ten of those real cards, replayed against the diffs they were written for:
Every card gets shorter. But read the rows honestly: where nothing anchors (#5767, #6188, #6343, #5776) the card only loses ~300–400 characters, and that is the bold one-sentence PR summary the review body omits — not the mechanism working. The real win is the four rows with ≥2 anchors. On aiter, only 28% of findings anchor (65/229), against the ~50% ATOM measured, because aiter findings more often cite a line of context code the PR did not touch, or carry no
file:lineat all. 35 of 61 cards would get at least one inline comment; 26 would be unchanged in substance.The index is not decoration
The review body ends with a one-line index of every finding that went inline:
Without it, a reader of the summary alone cannot tell whether three findings exist elsewhere or none do — and an invisible finding reads exactly like a finding that was never made.
Anchoring is a privilege a finding earns
check_citations.pycomes across from ATOM and is wired in asrun_one.shstep 3c. It writescitations.txt,_lib.pycollects it into the report dir, and_publish.pyrefuses to anchor any finding carrying a citation the checker flagged — even if another citation in the same sentence would resolve. A top-level card that cites a wrong line is a flaw the reader works around; an inline comment on a wrong line lands in the author's working view and is visibly wrong, and a reviewer who gets burned once stops reading the rest.With no
citations.txtat all, nothing anchors and the whole card stays in the summary — i.e. exactly what this bot posts today. That is the intended degradation.The checker never gates the run (
|| true, not in_gates.py). It ran 1-for-2 on real cards; a 50%-precision heuristic that withholds correct reviews costs more than the defect it catches. It did earn its keep here: on #5776 it flaggedaiter/mla.py:2693, and that finding correctly lost its inline slot.Degrade-to-summary
A review is all-or-nothing: one
comments[]entry naming a line GitHub will not accept fails the whole call, summary included — strictly worse than the issue comment this replaces. So a refusal retries the same endpoint with the anchors folded back into the body and says[ANCHORS REFUSED -- folded into summary]. A review that silently sheds half its findings reads exactly like a review that only had the other half. Two tests pin this.Adapted, not transcribed
Where aiter differs from ATOM and what changed as a result:
SKILL.mdwritesReview (advisory):, not ATOM'sReview:, and adds aPerf (advisory|deterministic):line ATOM has no counterpart for. ATOM's literal"Review:"/"Validation"prefixes would have dropped all three status lines, leaving a summary with no verdict in it. The summary now matches on the bare word and keeps every one, in card order. Pinned by a test.BOTis overridable viaAITER_BOT_NAME; the dedup marker is deliberately not derived from it, or a box with that var set would repost over every review the real bot already published. Andalready_posted()now searches both the issues-comments and the reviews endpoints — aiter's markers are sitting in live issue comments right now, and a check that only read reviews would repost on top of all of them. Both pinned by tests.AITER_BOT_TOKEN(_FILE),AITER_BOT_REPO, repo defaultROCm/aiter, status file.aiter-review-status, annotation titleaiter-bot— all kept as aiter had them._api_raw()(the.diffmedia type) is new; aiter had no caller for it.check_citations.pyprovenance. Its measurements are ATOM's and have not been rerun on aiter's cards; the docstring now says so instead of presenting them as local facts. Its "ambiguous bare basename" comment was recounted against this tree (aiter has 8utils.py, 7quant.py)._lib.py.citations.txtjoinsOPTIONAL, notREQUIRED: a run whose worker died before writing a card has no citations to check, and absence is not a defect._publish.pywas ATOM's minus the anchoring work, plus the env-overridableREPO/BOT; both overrides are kept..github/scripts/pr_self_review.pyis a separate system that PATCHes its own comment in place. It is not this skill and nothing here goes near it. The workflow YAML is also untouched.Guards
check_prompts.pygains three checks:check_publish_review_is_advisory— the event staysCOMMENT,APPROVE/REQUEST_CHANGESappear nowhere in the file, and there is exactly one POST call site,pulls/{pr}/reviews.check_publish_needs_post_flag—_publish.pyfalls back to~/.git-credentialson the self-hosted box, a human PAT with write access, soGITHUB_TOKENscoping does not stop it posting at all; the missing--postflag is the only closure. If the workflow ever grantsissues: writeorpull-requests: write, the invocation must pass--postexplicitly.check_anchoring_has_a_citation_check—run_one.sh→citations.txt→_lib.py→_publish.pycannot be half-removed in silence, because that degradation looks identical to a card whose findings simply cite nothing.selftest.shnow runs_publish_test.py(37 cases: the--postclosure, the anchoring rule, dedup, the degrade-to-summary fallback), and says out loud whenpytestis absent rather than passing over it — a check that did not run is not a check that passed.Verification, verbatim, on a clean tree built with
git archive HEAD(Baseline on
origin/mainwas93 green / 0 redandOK: 0 drift(s); the extra green is the new pytest block.)preflight.shon the same tree:20 green / 1 red. The red is pre-existing and environmental — the self-hosted runner is not installed as a systemd service — and is untouched by this change.What is verified live, and what still is not
A real review was posted by this code on 2026-11-03 —
pullrequestreview-5749640123,
this PR reviewing itself at
72d8c7c3baa9. What GitHub actually stored, read backthrough the API:
That settles the three things the anchor rules were only reasoned about: the API
accepts the payload as built, a range anchor resolves to the span rather than its
first line, and
event: "COMMENT"lands asCOMMENTED— the bot cannot approve orrequest changes.
citations.txtwas produced by a realrun_one.shin the same run(
CITATIONS: every cited file:line resolves (1 proximity note(s))), and the runclosed 7 gates green with 3 findings, all 3 surviving independent refutation.
Still not verified:
The degrade-to-summary fallback has never fired against the real API. The anchors
were accepted, so the refusal path stayed on the stub that rejects any payload
carrying
comments[]. It is untested where it matters most, and a review isall-or-nothing, so this is the residual risk this PR carries.
AITER_BOT_TOKEN's scope is unconfirmed by use. The live post was made with aclassic PAT carrying
repo(zufayu), not with the bot's token. The token holdersays the scope is sufficient; what is on record is that
aiter-bothasreadon thisrepo and has created zero reviews across the PRs checked, while posting an issue
comment on each — equally consistent with "the scope is fine and it has never tried"
and with "the scope is missing". Creating a review needs
Pull requests: writewherean issue comment needs only
Issues: write, and the anchor fallback cannot cover thiscase: it handles a bad anchor, not a token that cannot create reviews at all.
Rather than argue the point, being wrong about it is now cheap: a refused post exits
non-zero, so the first run under the bot's own token either works or turns one step
red with the API's own words. Previously it would have printed a failure line and
exited 0, losing a card per run under a green step.
The ten-card replay used each PR's head as it stands now, and only PRs whose head
still matches the SHA in the card's marker, so those diffs are the ones the findings
were written against. The 61-card population figures used current diffs, so for PRs
that have moved since review they are an approximation.
A review is attached to the commit it read. Pushing between the review and the publish
leaves the comment on the older commit — observed here, where the finding posted was
already fixed at head. In production the window is one job; by hand it is as long as
you take.
Landed checks
Done, in this order:
_publish.py <pr> --payloadon this PR and read the JSON, then--postfor real. Both outputs are quoted above. The remaining step for whoever mergesthis is the first run under
AITER_BOT_TOKENrather than a personal PAT.🤖 Generated with Claude Code
PR Self-Review
Reviewed revision
1d33254bb341Behavior and intent
_publish.pyposted the review card as one top-level issue comment. On ten realaiter-botcards that comment averages 3300 characters of dense prose, and a singlefinding averages ~900 — a paragraph each, in a wall nobody reads to the end. Half the
findings cite a
file:line, so some of them can be attached to the code they are aboutinstead.
It now posts
POST /pulls/{n}/reviewswithevent: "COMMENT"— neverAPPROVEorREQUEST_CHANGES; this bot does not gate merges — anchoring the findings whose citedline is inside the diff, and keeping the rest, plus a one-line index of the anchored
ones, in the review body. The index matters: without it a reader of the summary cannot
tell whether findings exist elsewhere or none do, and an invisible finding reads exactly
like one that was never made.
Anchoring is gated on
check_citations.py, ported here from ATOM along with therun_one.shstep and_lib.OPTIONALentry that produce and collectcitations.txt.A finding whose citation the checker could not resolve is not anchored: an inline
comment on the wrong line lands in the author's working view and is visibly wrong, and
a reviewer burned once stops reading the rest.
Three further changes landed here because this PR's own review found them, and each is
the same defect wearing a different hat — a check that does not run looks exactly like
a check that passes:
errexit, producing no cardat all. One missing optional import took the whole review down, which reads to the
person waiting on it like the bot being offline. The integrity checks stay fail-closed
— evidence that does not match this PR's head, base or patch is still never used — but
rejecting it now degrades the review and records why, instead of deleting it.
errexitkilledrun_one.shinside the fetch pipelinebefore the classification could run, and the exit trap wrote a status file while
printing nothing, so the log ended mid-sentence. The traps now speak, and a spent
GitHub quota is told apart from a token fault and from an account GitHub has
restricted (60 core calls with GraphQL at 0), because only one of those is fixed by
waiting.
flagged_citations()read a crashed checker as a clean verdict.check_citations.pyraised
NameErroron every call,run_one.sh's|| trueswallowed it, and thetraceback in
citations.txtreturned an empty flagged-set — "every citation checksout" — so findings anchored with no checking at all, which is precisely what the
checker exists to prevent. Absence of a
CITATIONSverdict line now means the checkerdid not run, matching the contract this module's own docstring already stated.
Validation and unverified scope
Validated from inside a clean tree built with
git archive HEAD— not merely exported and then run from the working copy. Running it the second way is what foundcheck_prompts.pyresolving SKILL.md throughgit rev-parse --show-toplevel, which returns an empty string outside a checkout and silently makes the path relative to the caller's cwd:Baseline on
origin/mainbefore the change: 93 green / 0 red, 0 drift;_publish_test.pydoes not exist there, so all 37 cases are new. Measured on ten realpublished cards replayed against the diffs they were written for: 36 findings, 11
anchored, summary 33025 → 24173 characters (−27%). The win is concentrated in the four
cards with ≥2 anchors; cards where nothing anchors barely shrink.
Validated against the live API, on this PR, 2026-11-03, hardware irrelevant (one
gh apicall from a CPU box):The run that produced that card was a real
run_one.shagainst this repo: 7 gatesgreen,
citations.txta genuine verdict (every cited file:line resolves, 1 proximitynote), 3 findings, 3 surviving independent refutation.
Unverified, and listed above in full: the degrade-to-summary fallback has never fired
against the real API, because the anchors were accepted;
AITER_BOT_TOKEN's scope isstill unconfirmed by use, since the live post used a personal PAT with
repo; and the61-card population figures use current diffs, so for PRs that moved after review they
are an approximation.
One honesty note on method: three of the defects fixed in this PR were found by this
bot reviewing this PR, and two of those were in code written the same day — including a
test suite that passed only because it ran the extracted shell region under bare
set -ewhile the real script runsset -euo pipefail, so every classification itclaimed to cover was unreachable in production.
PR-specific question
The boundary this introduces: a review is all-or-nothing. GitHub rejects the entire
call — summary included — if any single
comments[]entry names a line it will notaccept. The old single comment either posted or did not; after this change, one bad
anchor could lose a whole review, findings and all. That is a strictly worse failure
than the one it replaces, so it is covered three ways:
finding only earns one if
check_citations.pyresolved its citation. A citation thechecker could not vouch for — including one it never checked, because it crashed —
forfeits the slot.
do_postretries the same endpoint with the anchors folded back into thebody and says
[ANCHORS REFUSED -- folded into summary]. Two tests pin that path,including that the folded body still carries the anchored finding's full text. A
review that silently sheds half its findings reads exactly like one that only ever
had the other half.
summary alone can tell that findings exist elsewhere rather than inferring there are
none.
The evidence is uneven, and the gap is in the most important place. Paths 1 and 3
are now covered by a live call: a range anchor was accepted and stored on the span
(
start_line=211 line=248). Path 2 — the refusal — has only ever run against a stubthat rejects any payload with
comments[], because the real API accepted ours. Thefallback is the thing standing between one bad anchor and a lost review, and it is the
one piece still unproven against the API it exists to survive.
Changed op tests
None— noop_tests/file is touched. The change is confined to.claude/skills/review-pr/.Update — anchors point at the section, and what cannot be anchored gets a link
The anchoring above attaches a finding to one line. Two follow-on changes, both measured
on this bot's own archived cards.
1. Range anchors
25 of 221 archived findings cite a line range —
layernorm.py:1002-1012— and everyone was anchored to line 1002 alone, so the reader saw a comment pinned to one line of a
block the finding is about, which reads as a claim about that line. GitHub spells a span
as
start_line+linewith astart_side/sidefor each end; a cited range is nowanchored as one.
Both endpoints and every line between must be commentable. That is exactly "inside one
hunk" —
commentable()holds one contiguous run per hunk — and checking the two endpointsalone would accept a span across the gap between hunks, which is a malformed range, which
fails the whole review. When only part of the span is in the diff, the end that is takes
a single-line anchor rather than the finding being dropped.
The span pattern is deliberately tight — ASCII hyphen, no surrounding whitespace. A loose
one reads the real card sentence
flash_kda.py:381 — 6 published tuning candidatesas thebackwards span
381..6. Over 221 findings the tight form matched 25 spans and no falsepositive; the loose form added that one sentence and nothing true.
2. Permalinks for what cannot be anchored
A citation whose line the diff does not reach cannot be anchored — GitHub is right to
refuse it — and used to sit in the summary as bare
moe.py:5220text the reader had to goand find. It now also gets a blob permalink pinned to the head SHA, alone on its own
line, which is the only place GitHub expands one into the code it names. Pinned and not a
branch: a link that drifts off the code it was written about is a wrong anchor arriving
late. The finding's own
path:linetext is untouched — the link is in addition.Neither is invented
Both run through the gate anchoring already had. A citation
check_citations.pyflagged,or a card it never ran on, gets no anchor and no link. A path that does not resolve to
a file this PR touched gets no link either: a blob URL built from an unresolved basename is
a guess, and a link to the wrong code is worse than no link, for the same reason a wrong
anchor is.
Measured
Replaying eight real cards against the diffs they were written for — 37 findings:
Auditing every span citation in the 57-card corpus: 23 of 35 span-anchor cleanly, 1
falls back to an endpoint (part of the span is outside the diff), and 11 resolve to no file
in the diff — a vLLM path, an ambiguous basename matching two changed files, context code
the PR does not touch — and so are correctly left alone. None was too wide for
MAX_SPAN.Replaying also found a defect this change introduced: when a span collapses to one endpoint
the summary index stripped
path:563and left the line opening with a bare-569. Fixed,and pinned by a test.
The all-or-nothing boundary, again
A malformed span is a new way to fail the whole call. The degrade-to-summary fallback
covers it like any other refusal, and a test now pins that a refused range review degrades
with the span finding's text intact and folded as
path:101-104, not as a bare line._publish_test.pyis new in this PR and carries 37 cases.check_prompts.pygains two drift checks thatbuild a review over a synthetic two-hunk diff and assert the shape GitHub will take —
start_line < line, matching sides, span inside one hunk, permalinks gated — rather thanthe source that produced it.
Verified against the real API
A range anchor was posted and read back:
start_line=211 line=248 side=RIGHT start_side=RIGHT, stored on the span, not collapsed to its first line. Thehunk-containment rule held on a real diff. What remains untested is the refusal path —
the anchors were accepted, so the degrade-to-summary fallback has still only ever run
against a stub.