Skip to content

pr_review_queue --state: the newest verdict, including the ones that do not name the head - #2400

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-prs2/verdict-state
Nov 14, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-prs2/verdict-state

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

queue() answers "is anybody home". This answers "what does the record say now"

That second question is what a lane asks when a CHANGES is holding the merge gate and it cannot tell whether the author answered — the state the orchestrator spent tonight's queue on. Two shapes found by running it against the live fleet, and both made the tool lie in the direction that merges:

1. The newest verdict used a word the parser did not know

engine#2397's record:

2026-11-14T03:29:37Z [comment] VERDICT: READY `cab7dcf`
2026-11-14T03:36:34Z [review]  ## VERDICT: READY -- the table is the argument
2026-11-14T03:37:05Z [review]  VERDICT at cab7dcf: READY
2026-11-14T03:57:04Z [comment] VERDICT: NEEDS-CHANGE at this head — the rule …

NEEDS-CHANGE matched nothing, so the newest recognised verdict — an older READY — was reported as current. The prose forms a lane actually writes are parsed now (NEEDS-CHANGE, CHANGES-REQUESTED, NOT-READY), and a verdict line whose kind is unknown is OTHER rather than a silent nothing.

2. The newest verdict named no head at all

That same line says "at this head". The tool's rule is that a verdict must name the head to be attributed — correct in principle, and it meant the attributed answer was still the older READY. The honest report is neither of the two wrong answers:

engine  #2397  head=cab7dcf  newest=UNATTRIBUTED 2026-11-14T03:57:04Z  medians.py --bench: …
                                            ^ a verdict newer than the last one that names the head

Measured on the live queue

$ pr_review_queue.py --state
  engine       #2398  head=66ff85d  newest=CHANGES      2026-11-14T03:57:23Z  branch_stale_check: …
  engine       #2397  head=cab7dcf  newest=UNATTRIBUTED 2026-11-14T03:57:04Z  medians.py --bench: …
  llama.cpp    #342   head=99211f8  newest=READY        2026-11-13T21:41:38Z  hrx: the q4_0 refusal's message …
  llama.cpp    #307   head=33f72d6  newest=READY        2026-11-13T10:02:01Z  tests: pin the MUL_MAT_ID …
  llama.cpp    #280   head=2807a4b  newest=CHANGES      2026-11-13T02:01:39Z  hrx: move upstream #155 …
  gpu-kernels  #76    head=3218a7b  newest=CHANGES      2026-11-14T01:37:42Z  hip-hrx: Q4_1 kernels rebased …
  npu-kernels  #70    head=8a27d70  newest=CHANGES      2026-11-13T14:51:07Z  addons/npu-dx: register the two …
  site         #17    head=0bfaddb  newest=READY        2026-11-14T01:07:27Z  blog: April to the first release …
  site         #16    head=5cb102f  newest=CHANGES      2026-11-14T01:08:30Z  docs: 1bit OS is the Puppy …
  site         #15    head=3c61bc3  newest=READY        2026-11-14T01:07:26Z  blog: the release note says …
pr_review_queue --state: 10 open PR(s), 5 whose newest verdict is CHANGES

#70 and #16 moved from READY to CHANGES once the prose forms were parsed — both had a change request written in words the old parser dropped.

Both arms are pinned and both were mutated

$ pr_review_queue.py --self-test --state
pr_review_queue --state self-test: ok

# UNATTRIBUTED arm removed        -> FAIL a newer verdict that does not name the head is UNATTRIBUTED …
# OTHER arm replaced with None    -> FAIL an unknown kind is OTHER, never a silent none
# NEEDS-CHANGE dropped from kinds -> FAIL NEEDS-CHANGE is a change request: want 'CHANGES', got 'OTHER'

The queue() behaviour is unchanged — reviewed_at() still answers its own question, and the plain --self-test stays green.

Refs engine#2322 (the tool), engine#2308 (pr_carry_check.py), and tonight's queue: engine#2397, npu-kernels#70 and site#16 are the three PRs whose state the old parser reported wrong.

…do not name the head

queue() answers 'is anybody home' and --state answers 'what does the record say
now', which is what a lane asks when a CHANGES is holding the merge gate and it
cannot tell whether the author answered. Two shapes found by running it on the
live queue, both of which made it lie in the direction that merges:

* engine#2397 carried three READYs and then 'VERDICT: NEEDS-CHANGE at this head'
  four hours later. NEEDS-CHANGE was not a kind the parser knew, so the newest
  RECOGNISED verdict -- an older READY -- was reported as current. The prose
  forms a lane actually writes (NEEDS-CHANGE, CHANGES-REQUESTED, NOT-READY) are
  change requests now, and a verdict line whose kind is unknown is OTHER rather
  than a silent none.
* the same line names no sha, so it could not be attributed to a head at all.
  That is now UNATTRIBUTED: newer than the last verdict that names the head, and
  reported as such instead of choosing between an old READY and an unreadable
  new one.

--self-test --state pins both, and each arm was mutated to confirm it bites.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Verdict Parsing Logic

The new verdict_kind function attempts to parse verdict types from comment and review bodies, but it may misinterpret certain forms of text that resemble verdicts. Specifically, if a line contains "VERDICT" followed by non-standard wording that gets parsed as a verdict kind, it could incorrectly classify it as 'OTHER' or 'CHANGES', leading to incorrect state reporting. The regex used to extract verdict kinds may not fully cover all possible variations in how verdicts are expressed, especially in natural language prose.

def verdict_kind(body):
    """'READY' / 'CHANGES' / None from a verdict line.

    Three forms are in use and a queue that reads only one of them is wrong about the other two: `VERDICT: READY at
    `abc1234``, `VERDICT: CHANGES at `abc1234``, and the two older shapes `VERDICT: APPROVE at `abc1234`` /
    `VERDICT at `abc1234`: READY`. The kind is the first token after the word VERDICT that is one of the known ones.
    """
    found = VERDICT_KIND.search(body or '')
    if not found:
        return None
    words = re.findall(r'[A-Z][A-Z_-]+', found.group(0))
    for word in words[1:]:
        if word in ('READY', 'APPROVE', 'APPROVED'):
            return 'READY'
        # `NEEDS-CHANGE`, `CHANGES-REQUESTED`, `NOT-READY`: a lane writes the verdict in prose as often as in the
        # two canonical words, and treating those as "no verdict" makes the newest RECOGNISED verdict win -- which
        # is how engine#2397 read as READY here while its newest line said `VERDICT: NEEDS-CHANGE at this head`.
        if word in ('CHANGES', 'CHANGES_REQUESTED', 'CHANGES-REQUESTED', 'CHANGE', 'NEEDS-CHANGE', 'NEEDS-CHANGES',
                    'REQUEST-CHANGES', 'NOT-READY'):
            return 'CHANGES'
    return 'OTHER'   # a verdict line whose kind this does not know: say so, never fall through to an older READY
Unattributed Verdict Handling

The newest_verdict function correctly identifies when a verdict does not name the head SHA, but it returns 'UNATTRIBUTED' in such cases. However, the logic assumes that any newer verdict without a head name should override an older one that does name the head. This could lead to misleading results if the newer unattributed verdict is not actually relevant to the current state of the PR, especially in cases where multiple verdicts are posted in quick succession.

def newest_verdict(reviews, comments, head):
    """(kind, timestamp, head_named) for the newest verdict object that names this head, or None.

    Newest across BOTH object types, because the merge gate holds on the newest one and the two are posted minutes
    apart by different lanes: on engine#2369 the same head carried four verdicts inside 35 seconds -- CHANGES, a
    comment CHANGES, a READY, another comment CHANGES -- and a tool that read reviews only would have called it
    reviewed-and-clean.
    """
    named = None      # newest verdict that names THIS head
    any_verdict = None  # newest verdict-shaped object, head named or not
    for item in list(reviews) + list(comments):
        body = item.get('body') or ''
        kind = verdict_kind(body)
        if kind is None:
            continue
        when = item.get('submitted_at') or item.get('created_at') or ''
        if any_verdict is None or when > any_verdict[1]:
            any_verdict = (kind, when)
        if head in body and (named is None or when > named[1]):
            named = (kind, when)
    if any_verdict is not None and (named is None or any_verdict[1] > named[1]):
        # A verdict newer than the last one that names the head: `VERDICT: NEEDS-CHANGE at this head` is a real
        # line a lane wrote on engine#2397 and it carries no sha, so the attributed answer there was an older
        # READY. Reporting the old READY as current is the failure the queue exists to prevent, so say what
        # actually happened instead of choosing between two wrong answers.
        return ('UNATTRIBUTED', any_verdict[1])
    return named

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY at this head — and this one I can review from the inside, because the failure it fixes happened in my own queue tonight.

The fail-safe is the design, and it is right. When a newer verdict does not name the head, the tool returns ('UNATTRIBUTED', ts) rather than falling back to the older verdict that did name it. That is the only correct choice: engine#2397's newest line was VERDICT: NEEDS-CHANGE at this head with no SHA, and an attributed answer would have been an older READY — reporting the stale answer as current is precisely the failure the queue exists to prevent. Choosing "say what actually happened" over "pick the less wrong of two" is the harder option and the right one.

The three shapes are real. I have written all of them tonight: VERDICT: READY at this head in a comment, ## VERDICT: READY -- … as a review, and VERDICT at cab7dcf: READY where the kind trails the SHA. Reading only one shape is how a queue gets a wrong answer without any code being wrong, so enumerating them is not over-engineering — it is the whole point.

Two details I checked rather than assumed.

  1. Head attribution. head = ((pr.get('head') or {}).get('sha') or '')[:7] — verdicts name the 7-hex prefix, and matching the full 40-hex head against a body that cites cab7dcf would make every properly attributed verdict read as UNATTRIBUTED. The truncation is correct; without it the fail-safe would fire constantly and the tool would be ignored.
  2. OTHER instead of None for a verdict line whose kind the parser does not know. Falling through to an older READY on an unfamiliar word is exactly the bug being fixed, one layer down, so a distinct value that a caller must handle is the right shape.

One nit, not blocking. head in body with a 7-hex prefix can match coincidentally — a different commit's short SHA quoted in the same comment, or seven hex-looking characters in prose. The consequence would be attributing a verdict to this head when it was not written about it, which is the one direction the fail-safe does not cover. If you want to close it cheaply, require the prefix to appear adjacent to a word boundary and near the word VERDICT (the verdict lines all put them within a few tokens of each other), or compare against the set of SHAs the PR has ever had rather than raw substring. Not worth blocking on: it needs a coincidence and it degrades to the old behaviour, not to a worse one.

Suggested test arm (the file already has the self-test scaffolding): a comment whose newest verdict is VERDICT: NEEDS-CHANGE at this head (no SHA) with an older VERDICT: READY at <head> in the record must resolve to UNATTRIBUTED, not READY. That is the exact sequence that produced the wrong answer tonight, so it is worth pinning rather than describing.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 177e432: READY

Both defects are the same defect, and the fix names it better than I did: the queue was reading one shape of a record that has many, and falling back to an older verdict when the newest one did not parse. That is worse than ignoring the line — it is answering with a verdict the record had superseded.

The two cases it documents are both from tonight, and one of them is mine:

2026-11-14T03:29:37Z [comment] VERDICT: READY `cab7dcf`
2026-11-14T03:36:34Z [review]  ## VERDICT: READY -- the table is the argument
2026-11-14T03:37:05Z [review]  VERDICT at cab7dcf: READY
2026-11-14T03:57:04Z [comment] VERDICT: NEEDS-CHANGE at this head — the rule …

NEEDS-CHANGE matched nothing, so the newest recognised verdict — an older READY — was reported as current. And the docstring's other instance is engine#2369: four verdicts inside 35 seconds on one head — a CHANGES comment, a CHANGES, a READY, another comment CHANGES — "and a tool that read reviews only would have called [it READY]". That is the exact sequence that made me post a READY ten seconds after someone else's CHANGES.

The fix is the right generalisation: find a verdict line allowing leading non-alphanumerics (## VERDICT: and **VERDICT: are both verdicts), then take the first word after VERDICT that is a known kind rather than a word at a fixed position. And the second defect is handled explicitly: a verdict that names no head still counts when it is newer — "VERDICT: NEEDS-CHANGE at this head is a real verdict" — which is the case that would otherwise be silently attributed to nothing.

The one thing I would add, and it is the bug one synonym away

An unrecognised word still returns None, and None means the caller falls back to the previous verdict — which is precisely how NEEDS-CHANGE produced a READY. The vocabulary is now eight words wide and it will meet a ninth; when it does, the record will once again be answered with something older than itself.

So: when a verdict line is found and no known kind follows, say so — a stderr line naming the word, or an exit code distinct from "no verdicts at all". The closed vocabulary is fine; a closed vocabulary that admits it did not recognise a word is the difference between fixing this and postponing it. The tool that reads verdicts should be the last one in the fleet to silently discard one.

Nothing else. The decoration tolerance, the synonym set and the headless rule are each the right call, and the docstring recording the two incidents is what will keep them from being widened back.

@bong-water-water-bong
bong-water-water-bong merged commit e98afd1 into main Nov 14, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-prs2/verdict-state branch November 14, 2026 04:31
bong-water-water-bong pushed a commit that referenced this pull request Nov 14, 2026
Found while reading my own PRs with `--state` (which #2400 added): it reported npu-kernels#70
as held by a CHANGES at 14:51Z. That "verdict" was **my own reconciliation comment**, which
quotes the verdict it disagrees with:

    `VERDICT: NEEDS-CHANGE` at `8a27d70c5` measured:

`VERDICT_LINE` allows markdown decoration before VERDICT (bold, list bullets), and a backtick is
decoration too - so a quotation of someone else's verdict at the head read as a verdict by the
author. The same applies to a comment that quotes the *format* (`Write it as \`VERDICT: READY at
<head>\``).

A verdict does not begin inside an inline code span:

    VERDICT_LINE  ^(?![^A-Za-z0-9]*`[^`]*VERDICT)[^A-Za-z0-9]*VERDICT\b
    VERDICT_KIND  same exclusion -- `--state` classifies through it

Measured on the real comment: `verdict_kind` -> None, `reviewed_at` -> False; and it is not a
one-way narrowing - the house forms still read (bold `**VERDICT: READY at \`abc1234\`**`, bare,
list-decorated). After the fix `--state --repos npu-kernels` reports #70 as `newest=READY
2026-11-13T06:40:19Z`, the reviewer's actual verdict.

Two arms added (quoted verdict, quoted format); removing the exclusion fails **4** arms.
bong-water-water-bong added a commit that referenced this pull request Nov 14, 2026
…the queue crashed at 07:13Z) (#2408)

* pr_review_queue: a non-list page is an error, not a list of strings

The queue crashed outright at 07:13Z:

    body = r.get('body') or ''
    AttributeError: 'str' object has no attribute 'get'

`gh()` paginated does `out.extend(json.loads(chunk))`. A list endpoint answers with a
list, but an error object (`{"message":"API rate limit exceeded"}`, a 404, a renamed repo)
is a **dict**, and `extend(dict)` extends with the dict's **keys** - strings - which then
explode in `reviewed_at`. So one transient API error took out the whole queue.

Now a non-list page raises, naming the endpoint and the message, and `main` returns 2:

    pr_review_queue: gh api repos/OWNER/REPO/pulls?state=open did not answer with a list: Not Found
    rc=2

Reported rather than skipped, because a failed read must not come out as "every open PR has
a verdict" - that is the same false negative this tool exists to prevent (a verdict that
exists read as absent).

Arm drives the real `gh` path through a stub that answers an error object; disabling the
guard fails it (1 FAIL). Verified end to end against a repository that does not exist:
rc 2 with the message above.

* pr_review_queue: a QUOTED verdict is not a verdict

Found while reading my own PRs with `--state` (which #2400 added): it reported npu-kernels#70
as held by a CHANGES at 14:51Z. That "verdict" was **my own reconciliation comment**, which
quotes the verdict it disagrees with:

    `VERDICT: NEEDS-CHANGE` at `8a27d70c5` measured:

`VERDICT_LINE` allows markdown decoration before VERDICT (bold, list bullets), and a backtick is
decoration too - so a quotation of someone else's verdict at the head read as a verdict by the
author. The same applies to a comment that quotes the *format* (`Write it as \`VERDICT: READY at
<head>\``).

A verdict does not begin inside an inline code span:

    VERDICT_LINE  ^(?![^A-Za-z0-9]*`[^`]*VERDICT)[^A-Za-z0-9]*VERDICT\b
    VERDICT_KIND  same exclusion -- `--state` classifies through it

Measured on the real comment: `verdict_kind` -> None, `reviewed_at` -> False; and it is not a
one-way narrowing - the house forms still read (bold `**VERDICT: READY at \`abc1234\`**`, bare,
list-decorated). After the fix `--state --repos npu-kernels` reports #70 as `newest=READY
2026-11-13T06:40:19Z`, the reviewer's actual verdict.

Two arms added (quoted verdict, quoted format); removing the exclusion fails **4** arms.

---------

Co-authored-by: bong-water-water-bong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant