From afb785c721c5b6e9be922e7ace5accdb1157f627 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:39:57 -0500 Subject: [PATCH 1/7] fix(source-control): cap pr-verify repeated FAILs only at a FAILed head Owner decision Q245 (option a): pr-verify's repeated-fail cap closes a pull request only when its current head itself has a FAIL verdict; FAILs at superseded heads no longer close it. Reader.evidence now returns verify:repeated-fail only when a counted FAIL that is not superseded stands at the vetted head and FAILs sit at max_fails or more heads, that one included. A head whose newest verdicts pass, or whose own FAIL is superseded, goes on to the earlier-fail or pass decision. Sibling-PR counting, the capped-close floor, draft-judged exclusions, verify:fail and VERIFY_FINAL stay. The cap tests that expected it at a passing head now put a FAIL at the head; new tests pin a pass after FAILs at four older heads and a FAIL at the head after them. The docstring, verify-cap.mjs, the convention README, schema and pr-pipeline.yaml state the new condition. Closes #17646 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtVYpJGw3s2scXJV5jf --- .../fix-pr-verify-cap-head-fail-d4570a1c.md | 7 + .../fix-pr-verify-cap-head-fail-d4570a1c.md | 7 + .../scripts/pr-merge/enable-auto-merge.mjs | 4 +- .github/scripts/pr-unblock/verify-cap.mjs | 11 +- docs/conventions/pr-pipeline.yaml | 6 +- docs/conventions/pr-pipeline/README.md | 24 +-- .../pr-pipeline/pr-pipeline.schema.json | 2 +- .../scripts/babysit_merge_policy.py | 8 +- .../scripts/babysit_verify_evidence.py | 63 ++++--- .../tests/test_babysit_verify_evidence.py | 171 +++++++++++------- 10 files changed, 189 insertions(+), 114 deletions(-) create mode 100644 .changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md create mode 100644 .changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md diff --git a/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md new file mode 100644 index 00000000000..b062d60042e --- /dev/null +++ b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -0,0 +1,7 @@ +--- +bump: patch +--- + +### Fixed + +- pr-verify's repeated-fail cap (`merge.max-verify-fails`, `verify:repeated-fail`) closes a pull request only when its current head itself has a FAIL that is not superseded (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). FAILs at superseded heads no longer close it: a pass at the head goes on to the normal pass decision. pr-merge's `capped_close` and pr-unblock's `verify-cap.mjs` read the same reader, so both follow it; the README's Verifier verdict section, the schema and `pr-pipeline.yaml` say so. diff --git a/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md new file mode 100644 index 00000000000..341512ba7ea --- /dev/null +++ b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -0,0 +1,7 @@ +--- +bump: patch +--- + +### Fixed + +- `babysit_verify_evidence.py` refuses `verify:repeated-fail` only when a counted FAIL that is not superseded stands at the vetted head and FAILs sit at `merge.max-verify-fails` or more heads, that one included (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). A head whose newest verdicts pass, or whose own FAIL is superseded, goes on to the `verify:earlier-fail` or pass decision, whatever FAILs sit at earlier heads or on other pull requests for its issues. Before, FAILs at superseded heads kept counting, so the pr-merge lane closed a pull request whose current head had passed. Counting across other pull requests, the capped-close floor, draft-judged exclusions and `verify:fail` at the head are unchanged. diff --git a/.github/scripts/pr-merge/enable-auto-merge.mjs b/.github/scripts/pr-merge/enable-auto-merge.mjs index 5242d9bc980..c638f5fa979 100755 --- a/.github/scripts/pr-merge/enable-auto-merge.mjs +++ b/.github/scripts/pr-merge/enable-auto-merge.mjs @@ -47,8 +47,8 @@ // untrusted work in any spelling and none ever removed by a non-human, so // one added after admission refuses for a person // (`untrusted-provenance`). Then a pr-verify PASS or PASS-NOTES stands at that head, no FAIL is -// at it, no earlier FAIL is uncleared, FAILs sit at fewer than -// merge.max-verify-fails heads, and the spec is unchanged and trusted. A +// at it, no earlier FAIL is uncleared, and the spec is unchanged and +// trusted. A // read that fails, or a line without the link's answer, refuses. Only the // scheduled run and // a hand-started one read them (READER_EVENTS), last, for a pull request diff --git a/.github/scripts/pr-unblock/verify-cap.mjs b/.github/scripts/pr-unblock/verify-cap.mjs index 4c47ed04ac3..26922f9ac05 100644 --- a/.github/scripts/pr-unblock/verify-cap.mjs +++ b/.github/scripts/pr-unblock/verify-cap.mjs @@ -1,10 +1,13 @@ // verify-cap.mjs: whether pr-verify's FAILs on a pull request are at the // merge gate's cap (`verify:repeated-fail`), read by the gate's own reader, // babysit_verify_evidence.py `evidence`, so the cap is counted in one place. -// The cap never clears for the pull request: a fix round's push could never -// merge, so feedback-dispatch.mjs and fix-ci-dispatch.mjs start no -// address-feedback or fix-ci round on it and post nothing; the pr-merge lane -// closes it for a fresh attempt at its issue (owner decision 2026-10-29). A +// The cap applies only when a FAIL that is not superseded stands at the head +// (owner decision Q245, +// https://github.com/melodic-software/claude-code-plugins/issues/17646); FAILs +// at earlier heads alone never reach it. At that head it never clears and the pr-merge lane closes the pull +// request for a fresh attempt at its issue (owner decision 2026-10-29), so +// feedback-dispatch.mjs and fix-ci-dispatch.mjs start no address-feedback or +// fix-ci round on it and post nothing. A // FAIL run of another pull request for the same issue that cannot be read // (`verify:unreadable` with the reader's SIBLING_UNREADABLE detail), or an // artifact listing that does not fit in this caller's limit (a detail that diff --git a/docs/conventions/pr-pipeline.yaml b/docs/conventions/pr-pipeline.yaml index 9022a66fa49..8bae55247c0 100644 --- a/docs/conventions/pr-pipeline.yaml +++ b/docs/conventions/pr-pipeline.yaml @@ -1635,8 +1635,10 @@ merge: max-minutes: 60 max-skips: 3 # pr-verify FAILs at this many distinct heads of one PR hold it, never to - # merge unattended, whatever a later pass says, so pushing until the - # verifier passes once does not merge it (owner decision 2026-10-21). The + # merge unattended (owner decision 2026-10-21), when one that is not + # superseded stands at its head; FAILs at earlier heads alone leave a pass + # at the head to decide (owner decision Q245, + # https://github.com/melodic-software/claude-code-plugins/issues/17646). The # pr-merge lane closes a lanes App one for a fresh attempt at its issue, # and address-feedback and fix-ci start no more rounds on it (owner # decision 2026-10-29). diff --git a/docs/conventions/pr-pipeline/README.md b/docs/conventions/pr-pipeline/README.md index 4bdc23550b3..45d0d907aaa 100644 --- a/docs/conventions/pr-pipeline/README.md +++ b/docs/conventions/pr-pipeline/README.md @@ -2113,8 +2113,7 @@ work in any spelling, and none ever removed by a non-human or through an App, so after admission refuses as `untrusted-provenance`, `untrusted-provenance-removed-by-non-human` or `issue-labels-unreadable`, each a refusal a person clears, the removal one only through a new issue: see the trust hold below), a PASS or PASS-NOTES of [pr-verify](#verifier-verdict) stands at the head, -no FAIL is at it, no earlier FAIL is uncleared, FAILs sit at fewer than `merge.max-verify-fails` -heads, and the spec is unchanged and trusted; and `evidence --lane-reviews` finds no hold on the +no FAIL is at it, no earlier FAIL is uncleared, and the spec is unchanged and trusted; and `evidence --lane-reviews` finds no hold on the gate's risk score (`babysit_risk.score` over the inputs the gate builds, at the lane room's rung): an open CRITICAL security finding or a review not bound to the head, whether or not the lane applied its hold label, a symlink, submodule or other non-regular mode, a high path, the manifest @@ -2963,12 +2962,14 @@ other artifact with such a name is ignored. The resolver and the gate each hold dependency-manager list, and one test runs both to keep them equal. At the pull request's vetted head: -- counted `fail` verdicts at `merge.max-verify-fails` (default 3) or more distinct heads of the pull - request, tied as in the item after next, refuse (`verify:repeated-fail`) whatever a later pass - says, a `fail` at the head included. A value that is not a count of 1 or more, an empty or - non-scalar one included, is 1, so any earlier `fail` holds. Before a `fail` at the head or a - pass decides, counted `fail` verdicts of other pull requests in this repository, for its linked - issues, count too, at their own heads, unless that pull request merged or is a closed lanes App +- a counted `fail` at the head that is not superseded (the next item), with counted `fail` + verdicts at `merge.max-verify-fails` (default 3) or more distinct heads of the pull request, tied + as in the item after next, that head included, refuses (`verify:repeated-fail`). `fail` verdicts + at other heads alone never cap: a head whose newest verdicts pass, or whose `fail` is superseded, + goes on to the items below (owner decision Q245, 2026-11-20). A value that is not a count of 1 or + more, an empty or non-scalar one included, is 1, so any `fail` standing at the head caps. Before a + `fail` at the head decides, counted `fail` verdicts of other pull requests in this repository, + for its linked issues, count too, at their own heads, unless that pull request merged or is a closed lanes App attempt, so a second pull request for the same issue, closing or `Refs:`, does not reset the count. Every `fail` of such a pull request that closes one of the issues counts. Every counted `fail` of one whose name carries the issue counts too, from the listing the gate already reads: @@ -3009,8 +3010,9 @@ head: relink), else at least one body edit from the last `fail`'s run's creation (a body fix). The lanes App, any other Bot, an actor GitHub cannot name, a read that fails or is cut short, a time that cannot be read, or the same linked issues with no body edit keep the refusal. Both the - resolver and the gate read these acts in one GraphQL query, only on this path. A superseded `fail` still counts toward `merge.max-verify-fails`, and the - passes then decide as below. A judgment on an older listing (pr-merge's provisional one) can + resolver and the gate read these acts in one GraphQL query, only on this path. Supersession is judged before the cap: a superseded `fail` caps + nothing at its own head, and the passes then decide as below; it still counts toward + `merge.max-verify-fails` when a later head fails. A judgment on an older listing (pr-merge's provisional one) can still refuse `verify:fail` until a listing that holds the superseding pass is read; - a counted `fail` at another head of the pull request (its number, one of its commits, or a verdict recording its head branch, read from the name's digest, or for a name without one from @@ -3113,7 +3115,7 @@ round (`pr-dispatch-feedback.yml`, above), whose push the verifier judges again. ([when work stops for the owner](../../contracts/loop-lane/README.md#when-work-stops-for-the-owner)): it still refuses the merge, with no label. Only `verify:untrusted-spec` needs a human, since the spec's provenance is a trust boundary. `verify:too-old` waits for the fresh pass above, with no label. `verify:repeated-fail` never -clears for the pull request, so it never merges unattended, and no person's label goes on for it +clears at its failed head, so the pull request never merges unattended there, and no person's label goes on for it (owner decision 2026-10-29). Instead, while `merge.report-only` is false, the pr-merge lane closes a lanes App pull request at it for a fresh attempt at its issue (`babysit_verify_evidence.py` `capped_close`, run by `enable-auto-merge.mjs` through the reader's `capped-close` command, or by the gate under diff --git a/docs/conventions/pr-pipeline/pr-pipeline.schema.json b/docs/conventions/pr-pipeline/pr-pipeline.schema.json index db63b88e69c..092bf9ed925 100644 --- a/docs/conventions/pr-pipeline/pr-pipeline.schema.json +++ b/docs/conventions/pr-pipeline/pr-pipeline.schema.json @@ -1431,7 +1431,7 @@ "type": "integer", "minimum": 1, "default": 3, - "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` whatever a later pass says: the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any earlier fail holds." + "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` when one that is not superseded stands at its head; fail verdicts at other heads alone never do (owner decision Q245): the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any fail standing at the head caps." }, "verify-cap-attempts": { "type": "integer", diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py index 0683be840d6..4119a2a178a 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py @@ -915,9 +915,11 @@ def floor(self) -> Floor: # `RISK_ESCALATION_MINUTES`. risk_escalation_minutes: int = RISK_ESCALATION_MINUTES # `merge.max-verify-fails`: counted pr-verify FAILs at distinct heads of - # one pull request at which it holds, never to merge unattended, whatever - # a later pass says (`babysit_verify_evidence`). Absent is `MAX_VERIFY_FAILS`; anything - # but a whole number of at least 1 is 1, so any earlier FAIL holds. + # one pull request at which it holds, never to merge unattended, when one + # that is not superseded stands at its head (`babysit_verify_evidence`, + # https://github.com/melodic-software/claude-code-plugins/issues/17646). + # Absent is `MAX_VERIFY_FAILS`; anything but a whole number of at least 1 + # is 1, so any FAIL standing at the head caps. max_verify_fails: int = MAX_VERIFY_FAILS # `merge.verify-cap-attempts`: fresh attempts one issue gets after the # pr-merge lane closes its pull request at the FAIL cap or as too old diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py index dfec20c6af1..2f8fed5cb07 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py @@ -21,11 +21,14 @@ `Reader.evidence` decides one pull request at its vetted head, in this order: -- counted FAILs at `max_fails` or more distinct heads of this pull request - (tied as in the item after next): `verify:repeated-fail`, whatever a pass - says, a FAIL at the head included. Before a FAIL at the head or a pass - decides, FAILs of other pull requests in this repository that are not - merged, nor a closed lanes App attempt (`_counts`), and close one of its +- a counted FAIL at the head, under any pull request number, that is not + superseded (the next item), with counted FAILs at `max_fails` or more + distinct heads of this pull request (tied as in the item after next), that + head included: `verify:repeated-fail`. FAILs at other heads alone never + cap: a head whose newest verdicts pass, or whose FAIL is superseded, goes + on to the items below (owner decision Q245, 2026-11-20). Before a FAIL at + the head decides, FAILs of other pull requests in this repository that are + not merged, nor a closed lanes App attempt (`_counts`), and close one of its issues (its closing issues, or its `Refs:` issue) count too, at their own heads, and so does every FAIL of such a pull request whose name carries one of those issues, a `Refs:` pull request's FAILs among them (a FAIL among @@ -43,10 +46,11 @@ at least one from the first FAIL's creation for a pass that records other linked issues than each FAIL does (a relink), else at least one body edit from the last FAIL's creation (a body fix judged at the same head). - A superseded FAIL still counts toward `max_fails`, and the passes then - decide as below; the report's `supersededAtHead` names it, for pr-unblock - to resolve that FAIL's fail-note threads. Any record, time or read that - fails keeps `verify:fail`; + Supersession is judged before the cap. A superseded FAIL caps nothing at + its own head, and the passes then decide as below; it still counts toward + `max_fails` when a later head FAILs. The report's `supersededAtHead` names + it, for pr-unblock to resolve that FAIL's fail-note threads. Any record, + time or read that fails keeps `verify:fail`; - a counted FAIL at another head of this pull request: its number, one of its commits (`pulls//commits`), or a verdict recording its head branch (read from the name's digest, else from its verdict.json) for a pull request that @@ -140,9 +144,10 @@ and enable-auto-merge.mjs shows one that stands as a failing `pr-merge/unarmed` status. `verify:spec-changed` and `verify:too-old` wait for the lanes to judge the head again. -`verify:repeated-fail` never clears (`VERIFY_FINAL`), so the gate never merges -such a pull request unattended: the pr-merge lane closes a lanes App one for a -fresh attempt (`capped_close`), and address-feedback and fix-ci start no +`verify:repeated-fail` never clears at its FAILed head (`VERIFY_FINAL`), so +the gate never merges such a pull request unattended: the pr-merge lane +closes a lanes App one for a fresh attempt (`capped_close`), and +address-feedback and fix-ci start no round on a pull request at `verify:repeated-fail` (pr-unblock verify-cap.mjs). A `verify:fail` or `verify:earlier-fail` only waits: @@ -1826,7 +1831,6 @@ class Reader: head_refs_path: str | None = field( default_factory=lambda: os.environ.get(HEAD_REFS_ENV) or None ) - # `merge.max-verify-fails`: FAILed heads at which a pass no longer clears. max_fails: int = merge_policy.MAX_VERIFY_FAILS # `merge.agent-identity`, the lanes App's login: its trusted-list id is # the author a size split's sub-issue needs (`_split_child`); unset, no @@ -4361,10 +4365,14 @@ def capped(heads: set[str]) -> str: refusal: str | None detail = unreadable head_superseded = False - if len(failed) >= self.max_fails: + if ( + head in failed + and not (head_superseded := superseded(head)) + and len(failed) >= self.max_fails + ): refusal = REPEATED_FAIL detail = f"fails at {len(failed)} heads ({_heads(failed)}), the cap is {self.max_fails}" - elif head in failed and not (head_superseded := superseded(head)): + elif head in failed and not head_superseded: # A FAIL here gets a fix round, so the cap counts the other pull # requests for its issues first: a round past it cannot merge. heads = failed | elsewhere()[1] @@ -4393,19 +4401,15 @@ def capped(heads: set[str]) -> str: # Every pass of the run that started last must allow # (`_newest`), so listing order decides nothing; any unreadable # one refuses (`_Unreadable`). - live, others = elsewhere() - heads = failed | others - if len(heads) >= self.max_fails: - refusal, detail = REPEATED_FAIL, capped(heads) - else: - refusals = { - self._pass_refusal(run_id, name, number, head, live, pr, artifact) - for run_id, name, artifact in self._newest(passes) - } - refusal = next( - (r for r in (SPEC_CHANGED, UNTRUSTED_SPEC) if r in refusals), - None, - ) + live = elsewhere()[0] + refusals = { + self._pass_refusal(run_id, name, number, head, live, pr, artifact) + for run_id, name, artifact in self._newest(passes) + } + refusal = next( + (r for r in (SPEC_CHANGED, UNTRUSTED_SPEC) if r in refusals), + None, + ) elif unread_pass: refusal, detail = UNREADABLE, unread_pass elif too_old: @@ -4854,7 +4858,8 @@ def _superseded( A relink at a merge-only head needs its body edit from the last FAIL's creation, as a body fix does: a FAIL created after an edit already judged that edit. - A superseded FAIL still counts toward `max_fails`. A record, time or + A superseded FAIL still counts toward a later FAILed head's + `max_fails`. A record, time or read that fails is False.""" judged_at = judged_at or sha fails = fail_artifacts.get(sha, []) diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py index 47f820a1991..a5be809b071 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py @@ -1373,7 +1373,7 @@ def test_another_prs_fail_at_the_head_keeps_it(self) -> None: fake.records[name] = record(99, verdict="fail", linked_issues=[]) self.assertEqual(read(fake).refusal, "verify:fail") - def test_a_superseded_fail_still_counts_toward_the_cap(self) -> None: + def test_a_superseded_fail_at_the_head_does_not_reach_the_cap(self) -> None: fake = self.relinked() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), @@ -1381,8 +1381,9 @@ def test_a_superseded_fail_still_counts_toward_the_cap(self) -> None: mock.patch.object(ve, "gh_api_with_headers", side_effect=_page_with_date), ): reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) - refusal = reader.evidence(PR, HEAD, pull()).refusal - self.assertEqual(refusal, "verify:repeated-fail") + evidence = reader.evidence(PR, HEAD, pull()) + self.assertIsNone(evidence.refusal) + self.assertIs(evidence.report()["supersededAtHead"], True) def merge_only(self, *, superseded: bool) -> FakeGitHub: """The relinked FAIL and pass at EARLIER, and a head that only merged @@ -1543,13 +1544,14 @@ def test_the_report_names_a_fail_superseded_at_the_head(self) -> None: self.assertEqual(evidence.refusal, "verify:fail") self.assertIs(evidence.report()["supersededAtHead"], False) - def test_the_report_names_no_fail_superseded_elsewhere_or_capped(self) -> None: + def test_the_report_names_no_fail_superseded_elsewhere(self) -> None: # Superseded at an earlier head only: nothing at this head gave way. merge_only = ARelinkByPeopleSupersedesAFailAtItsHead().merge_only( superseded=True ) self.assertIs(read(merge_only).report()["supersededAtHead"], False) - # At the cap the FAIL at the head is never judged superseded. + + def test_a_superseded_fail_at_the_head_is_judged_before_the_cap(self) -> None: fake = self.edited() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), @@ -1558,8 +1560,8 @@ def test_the_report_names_no_fail_superseded_elsewhere_or_capped(self) -> None: ): reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) evidence = reader.evidence(PR, HEAD, pull()) - self.assertEqual(evidence.refusal, "verify:repeated-fail") - self.assertIs(evidence.report()["supersededAtHead"], False) + self.assertIsNone(evidence.refusal) + self.assertIs(evidence.report()["supersededAtHead"], True) # Pull request #16602's FAIL notes at head 27fe8d09, as its pr-verify @@ -1891,6 +1893,14 @@ def also_closes_issue_8(fake: FakeGitHub, *closers: int) -> FakeGitHub: return fake +def failing_at_head(fake: FakeGitHub) -> FakeGitHub: + """`fake` with a FAIL of this pull request at the head (run 9): the cap + closes only on a head whose own FAIL stands (owner decision Q245).""" + fake.artifacts.append(artifact(named(HEAD, "fail"), 9)) + fake.runs[9] = judged(9, OLDER_START) + return fake + + class FailsOnAnotherPullRequestForTheSameIssueCount(unittest.TestCase): """A second open pull request for the same issue does not reset the cap: counted FAILs of any open pull request in this repository that closes one @@ -1915,21 +1925,22 @@ def sibling_fails(*shas: str, number: int = SIBLING) -> FakeGitHub: return fake def test_three_fails_on_an_open_pull_request_refuse(self) -> None: - evidence = read(self.sibling_fails(*SIBLING_HEADS)) + evidence = read(failing_at_head(self.sibling_fails(*SIBLING_HEADS))) self.assertEqual(evidence.refusal, "verify:repeated-fail") self.assertFalse(evidence.needs_human) - def test_two_there_and_one_here_refuse(self) -> None: - fake = self.sibling_fails(*SIBLING_HEADS[:2]) - fake.artifacts.append(artifact(named(EARLIER, "fail"), 9)) - fake.runs[9] = judged(9, OLDER_START) + def test_three_fails_there_leave_a_pass_at_the_head_to_decide(self) -> None: + self.assertIsNone(read(self.sibling_fails(*SIBLING_HEADS)).refusal) + + def test_two_there_one_here_and_a_fail_at_the_head_refuse(self) -> None: + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS[:2])) + fake.artifacts.append(artifact(named(EARLIER, "fail"), 8)) + fake.runs[8] = judged(8, OLDER_START) self.assertEqual(read(fake).refusal, "verify:repeated-fail") def test_two_there_and_a_fail_at_the_head_reach_the_cap(self) -> None: # Not verify:fail: a fix round whose push could never merge. - fake = self.sibling_fails(*SIBLING_HEADS[:2]) - fake.artifacts.append(artifact(named(HEAD, "fail"), 9)) - fake.runs[9] = judged(9, OLDER_START) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS[:2])) evidence = read(fake) self.assertEqual(evidence.refusal, "verify:repeated-fail") self.assertFalse(evidence.needs_human) @@ -1965,7 +1976,7 @@ def test_a_closed_pull_request_of_anyone_else_still_counts(self) -> None: None, ): with self.subTest(author): - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) fake.closer_states[SIBLING] = "CLOSED" if author is not None: fake.closer_authors[SIBLING] = author @@ -1989,7 +2000,7 @@ def test_a_capped_close_record_starts_the_count_again(self) -> None: self.assertIsNone(read_as_lane(fake).refusal) def test_fails_after_the_newest_record_still_count(self) -> None: - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) fake.closing_comments[7] = [ capped_record( SIBLING + 2, LANES_APP_ACTOR, createdAt="2026-09-01T00:00:00Z" @@ -2008,7 +2019,7 @@ def test_only_the_caps_own_close_resets_the_count(self) -> None: None, ): with self.subTest(author): - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) fake.closers[7] = [(SIBLING, REPO), (SIBLING + 2, REPO), (PR, REPO)] if author is not None: fake.closer_authors[SIBLING + 2] = author @@ -2016,14 +2027,20 @@ def test_only_the_caps_own_close_resets_the_count(self) -> None: def test_a_record_resets_only_its_own_issue(self) -> None: # A close on one issue ends no attempt at another, whose FAILs stay. - fake = also_closes_issue_8(self.sibling_fails(*SIBLING_HEADS)) + fake = also_closes_issue_8(failing_at_head(self.sibling_fails(*SIBLING_HEADS))) self.assertEqual(read_as_lane(fake).refusal, "verify:repeated-fail") # Records on both of them end the attempts at both. fake.closing_comments[7] = [capped_record(SIBLING + 2, LANES_APP_ACTOR)] - self.assertIsNone(read_as_lane(fake).refusal) + self.assertEqual( + read_as_lane(fake).refusal, + "verify:fail", + "the FAIL at the head alone is under the cap and waits for a fix round", + ) def test_a_pull_request_for_two_issues_counts_for_the_one_not_reset(self) -> None: - fake = also_closes_issue_8(self.sibling_fails(*SIBLING_HEADS), SIBLING) + fake = also_closes_issue_8( + failing_at_head(self.sibling_fails(*SIBLING_HEADS)), SIBLING + ) self.assertEqual(read_as_lane(fake).refusal, "verify:repeated-fail") def test_a_capped_close_record_anyone_else_wrote_or_edited_resets_nothing( @@ -2058,12 +2075,12 @@ def test_a_capped_close_record_anyone_else_wrote_or_edited_resets_nothing( ), ): with self.subTest(name): - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) fake.closing_comments[7] = [node] self.assertEqual(read_as_lane(fake).refusal, "verify:repeated-fail") def test_without_the_lane_identity_no_record_resets(self) -> None: - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) fake.closing_comments[7] = [capped_record(SIBLING, LANES_APP_ACTOR)] self.assertEqual(read(fake).refusal, "verify:repeated-fail") @@ -2175,7 +2192,7 @@ def test_after_a_capped_close_record_the_next_attempt_is_uncapped(self) -> None: def test_the_attempts_own_three_fails_still_cap(self) -> None: fake = self.attempt() - for i, sha in enumerate((EARLIER, IN_PR, UNRELATED), start=9): + for i, sha in enumerate((EARLIER, IN_PR, HEAD), start=9): fake.artifacts.append(artifact(named(sha, "fail"), i)) fake.runs[i] = judged(i, OLDER_START) self.assertEqual(read(fake).refusal, "verify:repeated-fail") @@ -2216,7 +2233,8 @@ def test_a_merged_pull_requests_three_fails_leave_the_attempt_uncapped( self.assertIsNone(read(self.attempt("MERGED")).refusal) def test_the_same_fails_cap_while_that_pull_request_is_open(self) -> None: - self.assertEqual(read(self.attempt("OPEN")).refusal, "verify:repeated-fail") + fake = failing_at_head(self.attempt("OPEN")) + self.assertEqual(read(fake).refusal, "verify:repeated-fail") class FailsOnARefsPullRequestForTheSameIssueCount(unittest.TestCase): @@ -2249,11 +2267,15 @@ def sibling_fails(*shas: str, suffix: str = "-i7") -> FakeGitHub: return fake def test_three_fails_on_another_refs_pull_request_refuse(self) -> None: - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) evidence = read(fake) self.assertEqual(evidence.refusal, "verify:repeated-fail") self.assertFalse(evidence.needs_human) - self.assertEqual(downloads(fake), 0) + self.assertEqual( + downloads(fake), + 1, + "only the head FAIL's own record, read to judge whether it is superseded", + ) def test_two_there_and_a_fail_at_the_head_reach_the_cap(self) -> None: fake = self.sibling_fails(*SIBLING_HEADS[:2]) @@ -2271,11 +2293,13 @@ def test_only_names_that_carry_the_issue_count(self) -> None: # writer named issues) counts only for its own pull request. for suffix, refusal in ( ("-i7.8", "verify:repeated-fail"), - ("-i8", None), - ("", None), + ("-i8", "verify:fail"), + ("", "verify:fail"), ): with self.subTest(suffix): - fake = self.sibling_fails(*SIBLING_HEADS, suffix=suffix) + fake = failing_at_head( + self.sibling_fails(*SIBLING_HEADS, suffix=suffix) + ) self.assertEqual(read(fake).refusal, refusal) def test_a_long_cross_reference_timeline_holds_nothing(self) -> None: @@ -2290,7 +2314,7 @@ def test_a_long_cross_reference_timeline_holds_nothing(self) -> None: fake = self.sibling_fails(*SIBLING_HEADS[:2]) fake.mentions[7], fake.mentions_total[7] = mentions, 101 self.assertIsNone(read(fake).refusal) - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) fake.mentions[7], fake.mentions_total[7] = mentions, 101 self.assertEqual(read(fake).refusal, "verify:repeated-fail") @@ -2298,8 +2322,8 @@ def test_a_refs_pull_requests_own_state_decides(self) -> None: # A `Refs:` pull request is in no closing list, so its state is read # on its own; a failed read is unreadable, never an excuse. for answer, refusal in ( - ({"state": "closed", "merged_at": "2026-10-02T00:00:00Z"}, None), - ({"state": "closed", "user": LANES_APP_USER}, None), + ({"state": "closed", "merged_at": "2026-10-02T00:00:00Z"}, "verify:fail"), + ({"state": "closed", "user": LANES_APP_USER}, "verify:fail"), ({"state": "closed"}, "verify:repeated-fail"), ( {"state": "closed", "user": {"login": "someone", "type": "User"}}, @@ -2309,7 +2333,7 @@ def test_a_refs_pull_requests_own_state_decides(self) -> None: ("error", "verify:unreadable"), ): with self.subTest(refusal=refusal, answer=answer): - fake = self.sibling_fails(*SIBLING_HEADS) + fake = failing_at_head(self.sibling_fails(*SIBLING_HEADS)) if answer == "error": fake.fail.add(f"pulls/{SIBLING}") else: @@ -2342,10 +2366,15 @@ def named_fails(*shas: str, suffix: str = "-i7") -> FakeGitHub: return fake def test_three_named_fails_refuse(self) -> None: - evidence = read(self.named_fails(*SIBLING_HEADS)) + fake = failing_at_head(self.named_fails(*SIBLING_HEADS)) + evidence = read(fake) self.assertEqual(evidence.refusal, "verify:repeated-fail") self.assertFalse(evidence.needs_human) - self.assertEqual(downloads(self.named_fails(*SIBLING_HEADS)), 0) + self.assertEqual( + downloads(fake), + 1, + "only the head FAIL's own record, read to judge whether it is superseded", + ) def test_two_named_and_a_fail_at_the_head_reach_the_cap(self) -> None: fake = self.named_fails(*SIBLING_HEADS[:2]) @@ -2362,7 +2391,7 @@ def test_any_listed_issue_counts(self) -> None: ten = "-i" + ".".join(str(n) for n in range(1, 11)) for suffix in ("-i7.12", "-i3.7", ten): with self.subTest(suffix): - fake = self.named_fails(*SIBLING_HEADS, suffix=suffix) + fake = failing_at_head(self.named_fails(*SIBLING_HEADS, suffix=suffix)) self.assertEqual(read(fake).refusal, "verify:repeated-fail") def test_a_name_without_the_issue_does_not_count(self) -> None: @@ -2463,7 +2492,7 @@ def test_an_unreadable_run_of_a_named_fail_refuses(self) -> None: self.assertIsNone(read(fake).refusal) def test_a_record_on_another_issue_leaves_a_named_fail_counted(self) -> None: - fake = also_closes_issue_8(self.named_fails(*SIBLING_HEADS)) + fake = also_closes_issue_8(failing_at_head(self.named_fails(*SIBLING_HEADS))) self.assertEqual(read_as_lane(fake).refusal, "verify:repeated-fail") def test_an_unreadable_named_fail_before_the_record_reads_no_state(self) -> None: @@ -2493,9 +2522,10 @@ def test_a_foreign_run_never_counts(self) -> None: class RepeatedFailsHoldForTheLanes(unittest.TestCase): """FAILs at `merge.max-verify-fails` (default 3) distinct heads of one - pull request hold it, never to merge unattended, whatever a later pass - says (owner decision 2026-10-21), for the lanes with no label (owner rule - 2026-10-27); fewer leave the pass to decide.""" + pull request hold it, never to merge unattended (owner decision + 2026-10-21), for the lanes with no label (owner rule 2026-10-27), only + when one of them stands at the head (owner decision Q245, 2026-11-20); a + pass at the head, or fewer heads, leave the pass to decide.""" @staticmethod def failed_at(*shas: str) -> FakeGitHub: @@ -2507,13 +2537,28 @@ def failed_at(*shas: str) -> FakeGitHub: runs=runs, ) - def test_fails_at_three_heads_refuse_despite_a_later_pass(self) -> None: - evidence = read(self.failed_at(EARLIER, IN_PR, UNRELATED)) + def test_fails_at_three_earlier_heads_leave_a_later_pass_to_decide(self) -> None: + self.assertIsNone(read(self.failed_at(EARLIER, IN_PR, UNRELATED)).refusal) + + def test_a_pass_after_fails_at_four_earlier_heads_decides(self) -> None: + oldest = "1" * 40 + fake = self.failed_at(EARLIER, IN_PR, UNRELATED, oldest) + fake.diffs[oldest] = change("1111") + evidence = read(fake) + self.assertIsNone(evidence.refusal) + self.assertEqual(len([v for v in evidence.verdicts if v.verdict == "fail"]), 4) + + def test_a_fail_at_the_head_after_fails_at_four_earlier_heads_caps(self) -> None: + oldest = "1" * 40 + fake = self.failed_at(EARLIER, IN_PR, UNRELATED, oldest, HEAD) + fake.diffs[oldest] = change("1111") + evidence = read(fake) self.assertEqual(evidence.refusal, "verify:repeated-fail") self.assertFalse(evidence.needs_human) self.assertEqual( evidence.detail, - f"fails at 3 heads ({EARLIER}, {IN_PR}, {UNRELATED}), the cap is 3", + f"fails at 5 heads ({oldest}, {HEAD}, {EARLIER}, {IN_PR}, {UNRELATED})," + " the cap is 3", ) def test_the_cap_fails_closed_when_its_fails_cannot_be_read(self) -> None: @@ -2604,11 +2649,11 @@ def test_a_fail_at_the_head_under_the_cap_stays_verify_fail(self) -> None: self.assertFalse(evidence.needs_human) def test_the_reader_takes_its_cap_from_the_setting(self) -> None: - fake = self.failed_at(EARLIER, IN_PR) + fake = self.failed_at(EARLIER, HEAD) for cap, expected in ( (2, "verify:repeated-fail"), (1, "verify:repeated-fail"), - (3, None), + (3, "verify:fail"), ): with self.subTest(cap=cap): with mock.patch.object(postmerge, "gh_capture", side_effect=fake): @@ -7098,9 +7143,9 @@ def test_a_tied_fail_after_the_pass_holds(self) -> None: # Only the untied FAILs' records: the pass decides nothing. self.assertEqual(download_requests(fake), 2) - def test_a_third_failed_head_reaches_the_cap(self) -> None: + def test_a_third_failed_head_at_the_head_reaches_the_cap(self) -> None: fake = self.heads() - fake.artifacts.append(artifact(named(IN_PR, "fail", 96), 5)) + fake.artifacts.append(artifact(named(HEAD, "fail", 96), 5)) fake.runs[5] = run(5) evidence = read(fake) self.assertEqual(evidence.refusal, "verify:repeated-fail") @@ -7157,8 +7202,10 @@ class TheByIdFetchDecidesAsGhRunDownloadDid(unittest.TestCase): report in each of the six cases and spend half the download requests. Two fields were changed since by design, not by the fetch: `needsHuman` is false for the repeated-FAIL cap (owner rule 2026-10-27), and the - report no longer carries `headFail`. Break `_record` on purpose and these - fail.""" + report no longer carries `headFail`. The cap needs a FAIL standing at the + head (owner decision Q245), so the third failed head is now at the head, + and a capped case also reads the head FAIL's record to judge whether it + is superseded. Break `_record` on purpose and these fail.""" @staticmethod def report( @@ -7181,7 +7228,7 @@ def cases(self) -> dict[str, tuple[FakeGitHub, dict[str, Any], int, int]]: before (`gh run download`, two each) and after (one each).""" heads = EachVerdictIsOneRequest.heads third = heads() - third.artifacts.append(artifact(named(IN_PR, "fail", 96), 5)) + third.artifacts.append(artifact(named(HEAD, "fail", 96), 5)) third.runs[5] = run(5) unreadable = heads() del unreadable.records[named(UNRELATED, "fail", 98)] @@ -7207,12 +7254,12 @@ def capped(*shas: str) -> str: third, self.report( "verify:repeated-fail", - ["pass"], - [*both, IN_PR], - detail=capped(EARLIER, TIE, IN_PR), + ["fail", "pass"], + both, + detail=capped(EARLIER, TIE, HEAD), ), - 4, - 2, + 6, + 3, ), "unreadable untied record": ( unreadable, @@ -7234,8 +7281,8 @@ def capped(*shas: str) -> str: both, detail=capped(EARLIER, TIE, HEAD), ), - 4, - 2, + 6, + 3, ), } @@ -8504,7 +8551,7 @@ def test_at_an_earlier_head(self) -> None: self.assertEqual(read(self.fail_at(EARLIER)).refusal, "verify:earlier-fail") def test_toward_the_cap(self) -> None: - heads = (EARLIER, IN_PR, UNRELATED) + heads = (EARLIER, IN_PR, HEAD) fake = self.fail_at(*heads) self.assertEqual(read(fake).refusal, "verify:repeated-fail") for sha in heads: @@ -8512,15 +8559,15 @@ def test_toward_the_cap(self) -> None: self.assertIsNone(read(fake).refusal) def test_toward_another_pull_requests_cap(self) -> None: - fake = FailsOnAnotherPullRequestForTheSameIssueCount.sibling_fails( - *SIBLING_HEADS + fake = failing_at_head( + FailsOnAnotherPullRequestForTheSameIssueCount.sibling_fails(*SIBLING_HEADS) ) for run_id in set(fake.runs) - {1}: fake.runs[run_id] = judged(run_id, FAIL_JUDGED) self.assertEqual(read(fake).refusal, "verify:repeated-fail") for sha in SIBLING_HEADS: draft_race(fake, sha) - self.assertIsNone(read(fake).refusal) + self.assertEqual(read(fake).refusal, "verify:fail") def test_only_a_listed_draft_step_conclusion_reads_the_state(self) -> None: def draft_run(jobs: dict[str, Any]) -> bool: From a71c474d192a4030ec8e0cdc1cb2f2a1bdbd8501 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:43:10 -0500 Subject: [PATCH 2/7] test(source-control): pin a superseded head FAIL after FAILs at three heads Issue #17646's third acceptance item: the same history as the cap case, with the head's own FAIL superseded, gives the pass decision; left unanswered it still caps. Refs: #17646 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtVYpJGw3s2scXJV5jf --- .../tests/test_babysit_verify_evidence.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py index a5be809b071..4f1957d8467 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py @@ -1385,6 +1385,23 @@ def test_a_superseded_fail_at_the_head_does_not_reach_the_cap(self) -> None: self.assertIsNone(evidence.refusal) self.assertIs(evidence.report()["supersededAtHead"], True) + def test_fails_at_three_earlier_heads_cap_only_an_unsuperseded_head_fail( + self, + ) -> None: + def history() -> FakeGitHub: + fake = self.relinked() + for i, sha in enumerate((EARLIER, IN_PR, UNRELATED), start=3): + fake.artifacts.append(artifact(named(sha, "fail"), i)) + fake.runs[i] = judged(i, OLDER_START) + return fake + + evidence = read(history()) + self.assertIsNone(evidence.refusal, "a superseded head FAIL is a clean head") + self.assertIs(evidence.report()["supersededAtHead"], True) + unanswered = history() + unanswered.relink = relink_answer() + self.assertEqual(read(unanswered).refusal, "verify:repeated-fail") + def merge_only(self, *, superseded: bool) -> FakeGitHub: """The relinked FAIL and pass at EARLIER, and a head that only merged main since (the same change), with a pass of its own (run 3) that From bd9774734c49921ba417984ba337ba7e8fcb5f94 Mon Sep 17 00:00:00 2001 From: "melodic-automation-lanes[bot]" <337595936+melodic-automation-lanes[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 20:53:53 +0000 Subject: [PATCH 3/7] Address review feedback on fix/pr-verify-cap-head-fail Lane-Activity: pr-unblock/address-feedback Lane-Thread: PRRT_kwDOTCGFQM66b6f7 --- .../fix-pr-verify-cap-head-fail-d4570a1c.md | 2 +- .../fix-pr-verify-cap-head-fail-d4570a1c.md | 2 +- .github/scripts/pr-unblock/verify-cap.mjs | 7 +- docs/conventions/pr-pipeline.yaml | 6 +- docs/conventions/pr-pipeline/README.md | 13 ++-- .../pr-pipeline/pr-pipeline.schema.json | 2 +- .../scripts/babysit_merge_policy.py | 2 +- .../scripts/babysit_verify_evidence.py | 69 +++++++++++-------- .../tests/test_babysit_verify_evidence.py | 22 +++--- 9 files changed, 72 insertions(+), 53 deletions(-) diff --git a/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md index b062d60042e..de12549449d 100644 --- a/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md +++ b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -4,4 +4,4 @@ bump: patch ### Fixed -- pr-verify's repeated-fail cap (`merge.max-verify-fails`, `verify:repeated-fail`) closes a pull request only when its current head itself has a FAIL that is not superseded (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). FAILs at superseded heads no longer close it: a pass at the head goes on to the normal pass decision. pr-merge's `capped_close` and pr-unblock's `verify-cap.mjs` read the same reader, so both follow it; the README's Verifier verdict section, the schema and `pr-pipeline.yaml` say so. +- pr-verify's repeated-fail cap (`merge.max-verify-fails`, `verify:repeated-fail`) closes a pull request only when its current head itself has a FAIL (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). The cap is judged before that FAIL's supersession, so a capped head stays capped. FAILs at superseded heads no longer close it: a pass at the head goes on to the normal pass decision. pr-merge's `capped_close` and pr-unblock's `verify-cap.mjs` read the same reader, so both follow it; the README's Verifier verdict section, the schema and `pr-pipeline.yaml` say so. diff --git a/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md index 341512ba7ea..a3394b97e12 100644 --- a/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md +++ b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -4,4 +4,4 @@ bump: patch ### Fixed -- `babysit_verify_evidence.py` refuses `verify:repeated-fail` only when a counted FAIL that is not superseded stands at the vetted head and FAILs sit at `merge.max-verify-fails` or more heads, that one included (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). A head whose newest verdicts pass, or whose own FAIL is superseded, goes on to the `verify:earlier-fail` or pass decision, whatever FAILs sit at earlier heads or on other pull requests for its issues. Before, FAILs at superseded heads kept counting, so the pr-merge lane closed a pull request whose current head had passed. Counting across other pull requests, the capped-close floor, draft-judged exclusions and `verify:fail` at the head are unchanged. +- `babysit_verify_evidence.py` refuses `verify:repeated-fail` only when a counted FAIL stands at the vetted head and FAILs sit at `merge.max-verify-fails` or more heads, that one included (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). A head with no FAIL of its own goes on to the `verify:earlier-fail` or pass decision, whatever FAILs sit at earlier heads or on other pull requests for its issues. The cap is still judged before supersession, so a capped head stays capped. Before, FAILs at superseded heads kept counting, so the pr-merge lane closed a pull request whose current head had passed. Counting across other pull requests, the capped-close floor, draft-judged exclusions and `verify:fail` at the head are unchanged. diff --git a/.github/scripts/pr-unblock/verify-cap.mjs b/.github/scripts/pr-unblock/verify-cap.mjs index 26922f9ac05..492ab2eb178 100644 --- a/.github/scripts/pr-unblock/verify-cap.mjs +++ b/.github/scripts/pr-unblock/verify-cap.mjs @@ -1,10 +1,11 @@ // verify-cap.mjs: whether pr-verify's FAILs on a pull request are at the // merge gate's cap (`verify:repeated-fail`), read by the gate's own reader, // babysit_verify_evidence.py `evidence`, so the cap is counted in one place. -// The cap applies only when a FAIL that is not superseded stands at the head -// (owner decision Q245, +// The cap applies only when a FAIL stands at the head (owner decision Q245, // https://github.com/melodic-software/claude-code-plugins/issues/17646); FAILs -// at earlier heads alone never reach it. At that head it never clears and the pr-merge lane closes the pull +// at earlier heads alone never reach it. The reader judges the cap before +// supersession, so at that head it never clears, even when a later pass +// supersedes the head's FAIL, and the pr-merge lane closes the pull // request for a fresh attempt at its issue (owner decision 2026-10-29), so // feedback-dispatch.mjs and fix-ci-dispatch.mjs start no address-feedback or // fix-ci round on it and post nothing. A diff --git a/docs/conventions/pr-pipeline.yaml b/docs/conventions/pr-pipeline.yaml index 8bae55247c0..39cb32adf30 100644 --- a/docs/conventions/pr-pipeline.yaml +++ b/docs/conventions/pr-pipeline.yaml @@ -1635,9 +1635,9 @@ merge: max-minutes: 60 max-skips: 3 # pr-verify FAILs at this many distinct heads of one PR hold it, never to - # merge unattended (owner decision 2026-10-21), when one that is not - # superseded stands at its head; FAILs at earlier heads alone leave a pass - # at the head to decide (owner decision Q245, + # merge unattended (owner decision 2026-10-21), when one stands at its + # head, superseded or not; FAILs at earlier heads alone leave a pass at + # the head to decide (owner decision Q245, # https://github.com/melodic-software/claude-code-plugins/issues/17646). The # pr-merge lane closes a lanes App one for a fresh attempt at its issue, # and address-feedback and fix-ci start no more rounds on it (owner diff --git a/docs/conventions/pr-pipeline/README.md b/docs/conventions/pr-pipeline/README.md index 45d0d907aaa..50b26db4a24 100644 --- a/docs/conventions/pr-pipeline/README.md +++ b/docs/conventions/pr-pipeline/README.md @@ -2962,11 +2962,11 @@ other artifact with such a name is ignored. The resolver and the gate each hold dependency-manager list, and one test runs both to keep them equal. At the pull request's vetted head: -- a counted `fail` at the head that is not superseded (the next item), with counted `fail` +- a counted `fail` at the head, superseded (the next item) or not, with counted `fail` verdicts at `merge.max-verify-fails` (default 3) or more distinct heads of the pull request, tied as in the item after next, that head included, refuses (`verify:repeated-fail`). `fail` verdicts - at other heads alone never cap: a head whose newest verdicts pass, or whose `fail` is superseded, - goes on to the items below (owner decision Q245, 2026-11-20). A value that is not a count of 1 or + at other heads alone never cap: a head with no counted `fail` goes on to the items below (owner + decision Q245, 2026-11-20). A value that is not a count of 1 or more, an empty or non-scalar one included, is 1, so any `fail` standing at the head caps. Before a `fail` at the head decides, counted `fail` verdicts of other pull requests in this repository, for its linked issues, count too, at their own heads, unless that pull request merged or is a closed lanes App @@ -3010,9 +3010,10 @@ head: relink), else at least one body edit from the last `fail`'s run's creation (a body fix). The lanes App, any other Bot, an actor GitHub cannot name, a read that fails or is cut short, a time that cannot be read, or the same linked issues with no body edit keep the refusal. Both the - resolver and the gate read these acts in one GraphQL query, only on this path. Supersession is judged before the cap: a superseded `fail` caps - nothing at its own head, and the passes then decide as below; it still counts toward - `merge.max-verify-fails` when a later head fails. A judgment on an older listing (pr-merge's provisional one) can + resolver and the gate read these acts in one GraphQL query, only on this path. The cap is judged before supersession, so a capped head stays + capped: the pr-unblock dispatchers record it as handled. Under the cap a superseded `fail` + refuses nothing at its own head, and the passes then decide as below; it still counts toward + `merge.max-verify-fails`, at its own head and when a later head fails. A judgment on an older listing (pr-merge's provisional one) can still refuse `verify:fail` until a listing that holds the superseding pass is read; - a counted `fail` at another head of the pull request (its number, one of its commits, or a verdict recording its head branch, read from the name's digest, or for a name without one from diff --git a/docs/conventions/pr-pipeline/pr-pipeline.schema.json b/docs/conventions/pr-pipeline/pr-pipeline.schema.json index 092bf9ed925..4f7d53fe0f4 100644 --- a/docs/conventions/pr-pipeline/pr-pipeline.schema.json +++ b/docs/conventions/pr-pipeline/pr-pipeline.schema.json @@ -1431,7 +1431,7 @@ "type": "integer", "minimum": 1, "default": 3, - "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` when one that is not superseded stands at its head; fail verdicts at other heads alone never do (owner decision Q245): the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any fail standing at the head caps." + "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` when one stands at its head, superseded or not; fail verdicts at other heads alone never do (owner decision Q245): the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any fail standing at the head caps." }, "verify-cap-attempts": { "type": "integer", diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py index 4119a2a178a..64069830844 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py @@ -916,7 +916,7 @@ def floor(self) -> Floor: risk_escalation_minutes: int = RISK_ESCALATION_MINUTES # `merge.max-verify-fails`: counted pr-verify FAILs at distinct heads of # one pull request at which it holds, never to merge unattended, when one - # that is not superseded stands at its head (`babysit_verify_evidence`, + # stands at its head, superseded or not (`babysit_verify_evidence`, # https://github.com/melodic-software/claude-code-plugins/issues/17646). # Absent is `MAX_VERIFY_FAILS`; anything but a whole number of at least 1 # is 1, so any FAIL standing at the head caps. diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py index 2f8fed5cb07..d95aa239724 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py @@ -21,12 +21,12 @@ `Reader.evidence` decides one pull request at its vetted head, in this order: -- a counted FAIL at the head, under any pull request number, that is not - superseded (the next item), with counted FAILs at `max_fails` or more - distinct heads of this pull request (tied as in the item after next), that - head included: `verify:repeated-fail`. FAILs at other heads alone never - cap: a head whose newest verdicts pass, or whose FAIL is superseded, goes - on to the items below (owner decision Q245, 2026-11-20). Before a FAIL at +- a counted FAIL at the head, under any pull request number, superseded (the + next item) or not, with counted FAILs at `max_fails` or more distinct heads + of this pull request (tied as in the item after next), that head included: + `verify:repeated-fail`. FAILs at other heads alone never cap: a head with + no counted FAIL goes on to the items below (owner decision Q245, + 2026-11-20). Before a FAIL at the head decides, FAILs of other pull requests in this repository that are not merged, nor a closed lanes App attempt (`_counts`), and close one of its issues (its closing issues, or its `Refs:` issue) count too, at their own @@ -46,10 +46,12 @@ at least one from the first FAIL's creation for a pass that records other linked issues than each FAIL does (a relink), else at least one body edit from the last FAIL's creation (a body fix judged at the same head). - Supersession is judged before the cap. A superseded FAIL caps nothing at - its own head, and the passes then decide as below; it still counts toward - `max_fails` when a later head FAILs. The report's `supersededAtHead` names - it, for pr-unblock to resolve that FAIL's fail-note threads. Any record, + The cap is judged before supersession, so a capped head stays capped + (`VERIFY_FINAL`). Under the cap a superseded FAIL refuses nothing at its + own head, and the passes then decide as below; it still counts toward + `max_fails`, at its own head and when a later head FAILs. The report's + `supersededAtHead` names it, false when the cap decided, for pr-unblock to + resolve that FAIL's fail-note threads. Any record, time or read that fails keeps `verify:fail`; - a counted FAIL at another head of this pull request: its number, one of its commits (`pulls//commits`), or a verdict recording its head branch (read @@ -4345,15 +4347,23 @@ def superseded(sha: str) -> bool: ) return self._superseded(number, sha, fail_artifacts, at) + read_elsewhere: list[tuple[dict[Any, Any], set[str]]] = [] + def elsewhere() -> tuple[dict[Any, Any], set[str]]: - return self._elsewhere( - number, - failed_by_pr, - unread_prs, - failed_by_issue, - unread_issues, - fail_times, - ) + # Read once: the cap at a superseded FAIL at the head and the + # passes below both need it, and `_elsewhere` reads live issues. + if not read_elsewhere: + read_elsewhere.append( + self._elsewhere( + number, + failed_by_pr, + unread_prs, + failed_by_issue, + unread_issues, + fail_times, + ) + ) + return read_elsewhere[0] def capped(heads: set[str]) -> str: return ( @@ -4364,21 +4374,24 @@ def capped(heads: set[str]) -> str: refusal: str | None detail = unreadable - head_superseded = False - if ( - head in failed - and not (head_superseded := superseded(head)) - and len(failed) >= self.max_fails - ): + # The cap decides before supersession: a FAIL at the head at the cap + # stays capped there whatever supersedes it later (VERIFY_FINAL), as + # the pr-unblock dispatchers record a capped head as handled. + head_superseded = head in failed and superseded(head) + if head in failed and len(failed) >= self.max_fails: refusal = REPEATED_FAIL detail = f"fails at {len(failed)} heads ({_heads(failed)}), the cap is {self.max_fails}" - elif head in failed and not head_superseded: + head_superseded = False + elif ( + head in failed + and len(heads := failed | elsewhere()[1]) >= self.max_fails + ): # A FAIL here gets a fix round, so the cap counts the other pull # requests for its issues first: a round past it cannot merge. - heads = failed | elsewhere()[1] + refusal, detail = REPEATED_FAIL, capped(heads) + head_superseded = False + elif head in failed and not head_superseded: refusal = FAIL - if len(heads) >= self.max_fails: - refusal, detail = REPEATED_FAIL, capped(heads) elif fails and ( not self._passes_follow(fails, passes) or not self._change_differs( diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py index 4f1957d8467..9661a9decab 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py @@ -1373,7 +1373,9 @@ def test_another_prs_fail_at_the_head_keeps_it(self) -> None: fake.records[name] = record(99, verdict="fail", linked_issues=[]) self.assertEqual(read(fake).refusal, "verify:fail") - def test_a_superseded_fail_at_the_head_does_not_reach_the_cap(self) -> None: + def test_a_superseded_fail_at_the_head_at_the_cap_stays_capped(self) -> None: + # The cap never clears at its FAILed head (VERIFY_FINAL): the + # pr-unblock dispatchers record a capped head as handled. fake = self.relinked() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), @@ -1382,10 +1384,10 @@ def test_a_superseded_fail_at_the_head_does_not_reach_the_cap(self) -> None: ): reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) evidence = reader.evidence(PR, HEAD, pull()) - self.assertIsNone(evidence.refusal) - self.assertIs(evidence.report()["supersededAtHead"], True) + self.assertEqual(evidence.refusal, "verify:repeated-fail") + self.assertIs(evidence.report()["supersededAtHead"], False) - def test_fails_at_three_earlier_heads_cap_only_an_unsuperseded_head_fail( + def test_fails_at_three_earlier_heads_cap_a_head_fail_superseded_or_not( self, ) -> None: def history() -> FakeGitHub: @@ -1396,8 +1398,8 @@ def history() -> FakeGitHub: return fake evidence = read(history()) - self.assertIsNone(evidence.refusal, "a superseded head FAIL is a clean head") - self.assertIs(evidence.report()["supersededAtHead"], True) + self.assertEqual(evidence.refusal, "verify:repeated-fail") + self.assertIs(evidence.report()["supersededAtHead"], False) unanswered = history() unanswered.relink = relink_answer() self.assertEqual(read(unanswered).refusal, "verify:repeated-fail") @@ -1568,7 +1570,9 @@ def test_the_report_names_no_fail_superseded_elsewhere(self) -> None: ) self.assertIs(read(merge_only).report()["supersededAtHead"], False) - def test_a_superseded_fail_at_the_head_is_judged_before_the_cap(self) -> None: + def test_the_cap_is_judged_before_a_superseded_fail_at_the_head(self) -> None: + # Under the cap the body fix lets the pass decide (above); at it the + # head stays capped, and the report names nothing superseded. fake = self.edited() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), @@ -1577,8 +1581,8 @@ def test_a_superseded_fail_at_the_head_is_judged_before_the_cap(self) -> None: ): reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) evidence = reader.evidence(PR, HEAD, pull()) - self.assertIsNone(evidence.refusal) - self.assertIs(evidence.report()["supersededAtHead"], True) + self.assertEqual(evidence.refusal, "verify:repeated-fail") + self.assertIs(evidence.report()["supersededAtHead"], False) # Pull request #16602's FAIL notes at head 27fe8d09, as its pr-verify From 5dc6f4deee916e0af65e820cc8335dcb5e193481 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 16:09:11 -0500 Subject: [PATCH 4/7] style(source-control): drop the review-feedback comments comment-lint rejects Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtVYpJGw3s2scXJV5jf --- .../skills/babysit-prs/scripts/babysit_verify_evidence.py | 5 ----- .../scripts/tests/test_babysit_verify_evidence.py | 4 ---- 2 files changed, 9 deletions(-) diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py index d95aa239724..1cc374c4335 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py @@ -4350,8 +4350,6 @@ def superseded(sha: str) -> bool: read_elsewhere: list[tuple[dict[Any, Any], set[str]]] = [] def elsewhere() -> tuple[dict[Any, Any], set[str]]: - # Read once: the cap at a superseded FAIL at the head and the - # passes below both need it, and `_elsewhere` reads live issues. if not read_elsewhere: read_elsewhere.append( self._elsewhere( @@ -4374,9 +4372,6 @@ def capped(heads: set[str]) -> str: refusal: str | None detail = unreadable - # The cap decides before supersession: a FAIL at the head at the cap - # stays capped there whatever supersedes it later (VERIFY_FINAL), as - # the pr-unblock dispatchers record a capped head as handled. head_superseded = head in failed and superseded(head) if head in failed and len(failed) >= self.max_fails: refusal = REPEATED_FAIL diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py index 9661a9decab..05198a60a49 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py @@ -1374,8 +1374,6 @@ def test_another_prs_fail_at_the_head_keeps_it(self) -> None: self.assertEqual(read(fake).refusal, "verify:fail") def test_a_superseded_fail_at_the_head_at_the_cap_stays_capped(self) -> None: - # The cap never clears at its FAILed head (VERIFY_FINAL): the - # pr-unblock dispatchers record a capped head as handled. fake = self.relinked() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), @@ -1571,8 +1569,6 @@ def test_the_report_names_no_fail_superseded_elsewhere(self) -> None: self.assertIs(read(merge_only).report()["supersededAtHead"], False) def test_the_cap_is_judged_before_a_superseded_fail_at_the_head(self) -> None: - # Under the cap the body fix lets the pass decide (above); at it the - # head stays capped, and the report names nothing superseded. fake = self.edited() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), From aebeb1114eb571ec8fbb3aa2fc8814021b9cfd0b Mon Sep 17 00:00:00 2001 From: "melodic-automation-lanes[bot]" <337595936+melodic-automation-lanes[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 21:25:23 +0000 Subject: [PATCH 5/7] Address review feedback on fix/pr-verify-cap-head-fail Lane-Activity: pr-unblock/address-feedback --- .../fix-pr-verify-cap-head-fail-d4570a1c.md | 2 +- .../fix-pr-verify-cap-head-fail-d4570a1c.md | 2 +- docs/conventions/pr-pipeline.yaml | 5 +- docs/conventions/pr-pipeline/README.md | 9 ++- .../pr-pipeline/pr-pipeline.schema.json | 2 +- .../scripts/babysit_merge_policy.py | 3 +- .../scripts/babysit_verify_evidence.py | 25 +++--- .../tests/test_babysit_verify_evidence.py | 76 +++++++++++++------ 8 files changed, 80 insertions(+), 44 deletions(-) diff --git a/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md index de12549449d..437894456ec 100644 --- a/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md +++ b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -4,4 +4,4 @@ bump: patch ### Fixed -- pr-verify's repeated-fail cap (`merge.max-verify-fails`, `verify:repeated-fail`) closes a pull request only when its current head itself has a FAIL (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). The cap is judged before that FAIL's supersession, so a capped head stays capped. FAILs at superseded heads no longer close it: a pass at the head goes on to the normal pass decision. pr-merge's `capped_close` and pr-unblock's `verify-cap.mjs` read the same reader, so both follow it; the README's Verifier verdict section, the schema and `pr-pipeline.yaml` say so. +- pr-verify's repeated-fail cap (`merge.max-verify-fails`, `verify:repeated-fail`) closes a pull request only when its current head itself has a FAIL that is not superseded (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). Supersession is judged before the cap, so a superseded FAIL at the head counts as a clean head. FAILs at superseded heads no longer close it: a pass at the head goes on to the normal pass decision. pr-merge's `capped_close` and pr-unblock's `verify-cap.mjs` read the same reader, so both follow it; the README's Verifier verdict section, the schema and `pr-pipeline.yaml` say so. diff --git a/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md index a3394b97e12..d2eba6e05dd 100644 --- a/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md +++ b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -4,4 +4,4 @@ bump: patch ### Fixed -- `babysit_verify_evidence.py` refuses `verify:repeated-fail` only when a counted FAIL stands at the vetted head and FAILs sit at `merge.max-verify-fails` or more heads, that one included (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). A head with no FAIL of its own goes on to the `verify:earlier-fail` or pass decision, whatever FAILs sit at earlier heads or on other pull requests for its issues. The cap is still judged before supersession, so a capped head stays capped. Before, FAILs at superseded heads kept counting, so the pr-merge lane closed a pull request whose current head had passed. Counting across other pull requests, the capped-close floor, draft-judged exclusions and `verify:fail` at the head are unchanged. +- `babysit_verify_evidence.py` refuses `verify:repeated-fail` only when a counted FAIL stands at the vetted head and FAILs sit at `merge.max-verify-fails` or more heads, that one included (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). A head with no FAIL of its own goes on to the `verify:earlier-fail` or pass decision, whatever FAILs sit at earlier heads or on other pull requests for its issues. Supersession is judged before the cap, so a FAIL at the head that a trusted relink or body fix superseded counts as a clean head and the cap does not refuse there. Before, FAILs at superseded heads kept counting, so the pr-merge lane closed a pull request whose current head had passed. Counting across other pull requests, the capped-close floor, draft-judged exclusions and `verify:fail` at the head are unchanged. diff --git a/docs/conventions/pr-pipeline.yaml b/docs/conventions/pr-pipeline.yaml index 39cb32adf30..b71966c3b8a 100644 --- a/docs/conventions/pr-pipeline.yaml +++ b/docs/conventions/pr-pipeline.yaml @@ -1636,8 +1636,9 @@ merge: max-skips: 3 # pr-verify FAILs at this many distinct heads of one PR hold it, never to # merge unattended (owner decision 2026-10-21), when one stands at its - # head, superseded or not; FAILs at earlier heads alone leave a pass at - # the head to decide (owner decision Q245, + # head and is not superseded there; a superseded FAIL at the head, or + # FAILs at earlier heads alone, leave a pass at the head to decide (owner + # decision Q245, # https://github.com/melodic-software/claude-code-plugins/issues/17646). The # pr-merge lane closes a lanes App one for a fresh attempt at its issue, # and address-feedback and fix-ci start no more rounds on it (owner diff --git a/docs/conventions/pr-pipeline/README.md b/docs/conventions/pr-pipeline/README.md index 50b26db4a24..1886d449e29 100644 --- a/docs/conventions/pr-pipeline/README.md +++ b/docs/conventions/pr-pipeline/README.md @@ -3010,10 +3010,11 @@ head: relink), else at least one body edit from the last `fail`'s run's creation (a body fix). The lanes App, any other Bot, an actor GitHub cannot name, a read that fails or is cut short, a time that cannot be read, or the same linked issues with no body edit keep the refusal. Both the - resolver and the gate read these acts in one GraphQL query, only on this path. The cap is judged before supersession, so a capped head stays - capped: the pr-unblock dispatchers record it as handled. Under the cap a superseded `fail` - refuses nothing at its own head, and the passes then decide as below; it still counts toward - `merge.max-verify-fails`, at its own head and when a later head fails. A judgment on an older listing (pr-merge's provisional one) can + resolver and the gate read these acts in one GraphQL query, only on this path. Supersession is judged before the cap + ([#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)): a superseded + `fail` counts as a clean head at its own head, so it refuses nothing there, neither cap applies, + and the passes then decide as below; it still counts toward `merge.max-verify-fails` when a + later head fails. A judgment on an older listing (pr-merge's provisional one) can still refuse `verify:fail` until a listing that holds the superseding pass is read; - a counted `fail` at another head of the pull request (its number, one of its commits, or a verdict recording its head branch, read from the name's digest, or for a name without one from diff --git a/docs/conventions/pr-pipeline/pr-pipeline.schema.json b/docs/conventions/pr-pipeline/pr-pipeline.schema.json index 4f7d53fe0f4..db1aa4ae58e 100644 --- a/docs/conventions/pr-pipeline/pr-pipeline.schema.json +++ b/docs/conventions/pr-pipeline/pr-pipeline.schema.json @@ -1431,7 +1431,7 @@ "type": "integer", "minimum": 1, "default": 3, - "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` when one stands at its head, superseded or not; fail verdicts at other heads alone never do (owner decision Q245): the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any fail standing at the head caps." + "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` when one stands at its head and is not superseded there; a superseded fail at the head, or fail verdicts at other heads alone, never do (owner decision Q245, #17646):the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any fail standing unsuperseded at the head caps." }, "verify-cap-attempts": { "type": "integer", diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py index 64069830844..f3273ec48ac 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py @@ -916,7 +916,8 @@ def floor(self) -> Floor: risk_escalation_minutes: int = RISK_ESCALATION_MINUTES # `merge.max-verify-fails`: counted pr-verify FAILs at distinct heads of # one pull request at which it holds, never to merge unattended, when one - # stands at its head, superseded or not (`babysit_verify_evidence`, + # stands at its head and is not superseded there + # (`babysit_verify_evidence`, # https://github.com/melodic-software/claude-code-plugins/issues/17646). # Absent is `MAX_VERIFY_FAILS`; anything but a whole number of at least 1 # is 1, so any FAIL standing at the head caps. diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py index 1cc374c4335..cc0b91da54a 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py @@ -46,12 +46,11 @@ at least one from the first FAIL's creation for a pass that records other linked issues than each FAIL does (a relink), else at least one body edit from the last FAIL's creation (a body fix judged at the same head). - The cap is judged before supersession, so a capped head stays capped - (`VERIFY_FINAL`). Under the cap a superseded FAIL refuses nothing at its - own head, and the passes then decide as below; it still counts toward - `max_fails`, at its own head and when a later head FAILs. The report's - `supersededAtHead` names it, false when the cap decided, for pr-unblock to - resolve that FAIL's fail-note threads. Any record, + Supersession is judged before the cap (#17646): a superseded FAIL counts + as a clean head at its own head, so it refuses nothing there, neither cap + applies, and the passes then decide as below; it still counts toward + `max_fails` when a later head FAILs. The report's `supersededAtHead` names + it, for pr-unblock to resolve that FAIL's fail-note threads. Any record, time or read that fails keeps `verify:fail`; - a counted FAIL at another head of this pull request: its number, one of its commits (`pulls//commits`), or a verdict recording its head branch (read @@ -146,7 +145,8 @@ and enable-auto-merge.mjs shows one that stands as a failing `pr-merge/unarmed` status. `verify:spec-changed` and `verify:too-old` wait for the lanes to judge the head again. -`verify:repeated-fail` never clears at its FAILed head (`VERIFY_FINAL`), so +`verify:repeated-fail` clears at its FAILed head only when that FAIL is +later superseded there; otherwise it stands (`VERIFY_FINAL`), so the gate never merges such a pull request unattended: the pr-merge lane closes a lanes App one for a fresh attempt (`capped_close`), and address-feedback and fix-ci start no @@ -4372,20 +4372,21 @@ def capped(heads: set[str]) -> str: refusal: str | None detail = unreadable + # Supersession is judged before the cap (#17646): a superseded FAIL + # here counts as a clean head, so neither cap refuses at it. head_superseded = head in failed and superseded(head) - if head in failed and len(failed) >= self.max_fails: + head_failed = head in failed and not head_superseded + if head_failed and len(failed) >= self.max_fails: refusal = REPEATED_FAIL detail = f"fails at {len(failed)} heads ({_heads(failed)}), the cap is {self.max_fails}" - head_superseded = False elif ( - head in failed + head_failed and len(heads := failed | elsewhere()[1]) >= self.max_fails ): # A FAIL here gets a fix round, so the cap counts the other pull # requests for its issues first: a round past it cannot merge. refusal, detail = REPEATED_FAIL, capped(heads) - head_superseded = False - elif head in failed and not head_superseded: + elif head_failed: refusal = FAIL elif fails and ( not self._passes_follow(fails, passes) diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py index 05198a60a49..7911f73e31a 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py @@ -1261,7 +1261,9 @@ class ARelinkByPeopleSupersedesAFailAtItsHead(unittest.TestCase): changed there and it passed again, when every body edit and issue connect or disconnect from the FAIL's creation to the pass's start was a trusted person's; any other actor, a read that fails or the same linked issues - keep it. It still counts toward the FAIL cap, and a merge-only head + keep it. At its own head it counts as a clean head, so the FAIL cap + does not refuse there (#17646); it still counts toward the cap when a + later head FAILs, and a merge-only head carries it forward unless it was superseded at its own head or by the merge-only head's own pass under the same rule, which there also needs a trusted body edit.""" @@ -1373,21 +1375,39 @@ def test_another_prs_fail_at_the_head_keeps_it(self) -> None: fake.records[name] = record(99, verdict="fail", linked_issues=[]) self.assertEqual(read(fake).refusal, "verify:fail") - def test_a_superseded_fail_at_the_head_at_the_cap_stays_capped(self) -> None: - fake = self.relinked() - with ( - mock.patch.object(postmerge, "gh_capture", side_effect=fake), - mock.patch.object(ve.merge_policy, "gh_capture", side_effect=fake), - mock.patch.object(ve, "gh_api_with_headers", side_effect=_page_with_date), - ): - reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) - evidence = reader.evidence(PR, HEAD, pull()) + def test_a_superseded_fail_at_the_head_at_the_cap_lets_the_pass_decide( + self, + ) -> None: + """#17646: supersession is judged before the cap, so a superseded + FAIL at the head counts as a clean head; the same FAIL not superseded + stays capped.""" + + def evidence_at_cap_one(fake: FakeGitHub) -> ve.Evidence: + with ( + mock.patch.object(postmerge, "gh_capture", side_effect=fake), + mock.patch.object(ve.merge_policy, "gh_capture", side_effect=fake), + mock.patch.object( + ve, "gh_api_with_headers", side_effect=_page_with_date + ), + ): + reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) + return reader.evidence(PR, HEAD, pull()) + + evidence = evidence_at_cap_one(self.relinked()) + self.assertIsNone(evidence.refusal) + self.assertIs(evidence.report()["supersededAtHead"], True) + unanswered = self.relinked() + unanswered.relink = relink_answer() + evidence = evidence_at_cap_one(unanswered) self.assertEqual(evidence.refusal, "verify:repeated-fail") self.assertIs(evidence.report()["supersededAtHead"], False) - def test_fails_at_three_earlier_heads_cap_a_head_fail_superseded_or_not( + def test_fails_at_three_earlier_heads_cap_only_a_head_fail_not_superseded( self, ) -> None: + """#17646's reader test: the same history where the head's FAIL is + superseded does not yield `verify:repeated-fail`.""" + def history() -> FakeGitHub: fake = self.relinked() for i, sha in enumerate((EARLIER, IN_PR, UNRELATED), start=3): @@ -1396,8 +1416,8 @@ def history() -> FakeGitHub: return fake evidence = read(history()) - self.assertEqual(evidence.refusal, "verify:repeated-fail") - self.assertIs(evidence.report()["supersededAtHead"], False) + self.assertNotEqual(evidence.refusal, "verify:repeated-fail") + self.assertIs(evidence.report()["supersededAtHead"], True) unanswered = history() unanswered.relink = relink_answer() self.assertEqual(read(unanswered).refusal, "verify:repeated-fail") @@ -1568,15 +1588,27 @@ def test_the_report_names_no_fail_superseded_elsewhere(self) -> None: ) self.assertIs(read(merge_only).report()["supersededAtHead"], False) - def test_the_cap_is_judged_before_a_superseded_fail_at_the_head(self) -> None: - fake = self.edited() - with ( - mock.patch.object(postmerge, "gh_capture", side_effect=fake), - mock.patch.object(ve.merge_policy, "gh_capture", side_effect=fake), - mock.patch.object(ve, "gh_api_with_headers", side_effect=_page_with_date), - ): - reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) - evidence = reader.evidence(PR, HEAD, pull()) + def test_a_superseded_fail_at_the_head_is_judged_before_the_cap(self) -> None: + """#17646: a body-fixed FAIL at the head counts as a clean head, so + the cap does not refuse it; an App edit keeps the FAIL capped.""" + + def evidence_at_cap_one(fake: FakeGitHub) -> ve.Evidence: + with ( + mock.patch.object(postmerge, "gh_capture", side_effect=fake), + mock.patch.object(ve.merge_policy, "gh_capture", side_effect=fake), + mock.patch.object( + ve, "gh_api_with_headers", side_effect=_page_with_date + ), + ): + reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) + return reader.evidence(PR, HEAD, pull()) + + evidence = evidence_at_cap_one(self.edited()) + self.assertIsNone(evidence.refusal) + self.assertIs(evidence.report()["supersededAtHead"], True) + evidence = evidence_at_cap_one( + self.edited(relink_answer([(RELINK_AT, LANES_ACTOR)])) + ) self.assertEqual(evidence.refusal, "verify:repeated-fail") self.assertIs(evidence.report()["supersededAtHead"], False) From 7fe2095def5b53ec2269365c5e152556e07081ef Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 16:32:26 -0500 Subject: [PATCH 6/7] fix(source-control): judge a superseded head FAIL before the cap and expire a capped head's handled mark Restore issue #17646's order (owner decision Q245): Reader.evidence checks supersession first, so a superseded FAIL at the head counts as a clean head and gets the earlier-fail or pass decision, not verify:repeated-fail. The three reader tests, the README, pr-pipeline.yaml, the schema, the docstring and both changelog fragments say so again. A cap no longer holds a head for good, so feedback-dispatch.mjs and fix-ci-dispatch.mjs stop recording a capped head as handled: a head whose FAIL a later pass superseded is read again and dispatched. The dispatch record's version is 7, so cap marks written by version 6 are dropped. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtVYpJGw3s2scXJV5jf --- .../fix-pr-verify-cap-head-fail-d4570a1c.md | 2 +- .../fix-pr-verify-cap-head-fail-d4570a1c.md | 2 +- .../scripts/pr-unblock/dispatch-record.mjs | 6 +- .github/scripts/pr-unblock/dispatch.test.mjs | 4 +- .../scripts/pr-unblock/feedback-dispatch.mjs | 11 ++-- .../pr-unblock/feedback-dispatch.test.mjs | 26 ++++---- .../scripts/pr-unblock/fix-ci-dispatch.mjs | 7 +- .../pr-unblock/fix-ci-dispatch.test.mjs | 19 +++--- .github/scripts/pr-unblock/verify-cap.mjs | 15 ++--- docs/conventions/pr-pipeline.yaml | 6 +- docs/conventions/pr-pipeline/README.md | 13 ++-- .../pr-pipeline/pr-pipeline.schema.json | 2 +- .../scripts/babysit_merge_policy.py | 2 +- .../scripts/babysit_verify_evidence.py | 64 ++++++++----------- .../tests/test_babysit_verify_evidence.py | 18 +++--- 15 files changed, 89 insertions(+), 108 deletions(-) diff --git a/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md index de12549449d..2bc28641b0b 100644 --- a/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md +++ b/.changes/pr-pipeline/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -4,4 +4,4 @@ bump: patch ### Fixed -- pr-verify's repeated-fail cap (`merge.max-verify-fails`, `verify:repeated-fail`) closes a pull request only when its current head itself has a FAIL (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). The cap is judged before that FAIL's supersession, so a capped head stays capped. FAILs at superseded heads no longer close it: a pass at the head goes on to the normal pass decision. pr-merge's `capped_close` and pr-unblock's `verify-cap.mjs` read the same reader, so both follow it; the README's Verifier verdict section, the schema and `pr-pipeline.yaml` say so. +- pr-verify's repeated-fail cap (`merge.max-verify-fails`, `verify:repeated-fail`) closes a pull request only when its current head itself has a FAIL that is not superseded (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). FAILs at superseded heads no longer close it: a pass at the head goes on to the normal pass decision. pr-merge's `capped_close` and pr-unblock's `verify-cap.mjs` read the same reader, so both follow it; the README's Verifier verdict section, the schema and `pr-pipeline.yaml` say so. pr-unblock's address-feedback and fix-ci dispatchers no longer record a capped head as handled, so a head whose FAIL a later pass supersedes is dispatched again; the dispatch record's version is 7, so heads an earlier version recorded at the cap are read again. diff --git a/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md index a3394b97e12..341512ba7ea 100644 --- a/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md +++ b/.changes/source-control/fix-pr-verify-cap-head-fail-d4570a1c.md @@ -4,4 +4,4 @@ bump: patch ### Fixed -- `babysit_verify_evidence.py` refuses `verify:repeated-fail` only when a counted FAIL stands at the vetted head and FAILs sit at `merge.max-verify-fails` or more heads, that one included (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). A head with no FAIL of its own goes on to the `verify:earlier-fail` or pass decision, whatever FAILs sit at earlier heads or on other pull requests for its issues. The cap is still judged before supersession, so a capped head stays capped. Before, FAILs at superseded heads kept counting, so the pr-merge lane closed a pull request whose current head had passed. Counting across other pull requests, the capped-close floor, draft-judged exclusions and `verify:fail` at the head are unchanged. +- `babysit_verify_evidence.py` refuses `verify:repeated-fail` only when a counted FAIL that is not superseded stands at the vetted head and FAILs sit at `merge.max-verify-fails` or more heads, that one included (owner decision Q245, [#17646](https://github.com/melodic-software/claude-code-plugins/issues/17646)). A head whose newest verdicts pass, or whose own FAIL is superseded, goes on to the `verify:earlier-fail` or pass decision, whatever FAILs sit at earlier heads or on other pull requests for its issues. Before, FAILs at superseded heads kept counting, so the pr-merge lane closed a pull request whose current head had passed. Counting across other pull requests, the capped-close floor, draft-judged exclusions and `verify:fail` at the head are unchanged. diff --git a/.github/scripts/pr-unblock/dispatch-record.mjs b/.github/scripts/pr-unblock/dispatch-record.mjs index 7d6282e9aa6..abbc1e52fc0 100644 --- a/.github/scripts/pr-unblock/dispatch-record.mjs +++ b/.github/scripts/pr-unblock/dispatch-record.mjs @@ -48,10 +48,12 @@ export async function sendDispatch(api, log, { workflow, base, node, inputs, lab // version 5 a resolve-conflicts head a select job's stop left under an older // base, and version 6 a resolve-conflicts, sync-shared-copies or // review-dependency head a head-lag stop left (limit-stop.mjs -// lagStopsRelease). A fix-ci +// lagStopsRelease), and version 7 an address-feedback or fix-ci head +// pr-verify's FAIL cap held, which a superseded FAIL now clears +// (https://github.com/melodic-software/claude-code-plugins/issues/17646). A fix-ci // head recorded at its per-head cap needs no new version: a record with no // fix-ci entry reads the same either way; nor do fix-docs runs, read as none. -export const RECORD_VERSION = 6; +export const RECORD_VERSION = 7; // The fix-docs runs kept per head, newest last: the reader drops the settled // runs that do not count, so more than this many is a tampered entry. const MAX_DOCS_RUNS = 20; diff --git a/.github/scripts/pr-unblock/dispatch.test.mjs b/.github/scripts/pr-unblock/dispatch.test.mjs index 688b9967f6c..10e76645f38 100644 --- a/.github/scripts/pr-unblock/dispatch.test.mjs +++ b/.github/scripts/pr-unblock/dispatch.test.mjs @@ -1480,13 +1480,13 @@ test("main carries the record in DISPATCH_RECORD and writes it only when it chan DISPATCH_RECORD: path, }; // A recorded head no open PR carries any more is dropped. - writeFileSync(path, JSON.stringify({ version: 6, handled: { [CHECK_NAME]: ["f".repeat(40)] }, bases: { ["f".repeat(40)]: "b".repeat(40) }, dispatched: {} })); + writeFileSync(path, JSON.stringify({ version: 7, handled: { [CHECK_NAME]: ["f".repeat(40)] }, bases: { ["f".repeat(40)]: "b".repeat(40) }, dispatched: {} })); const options = () => ({ api: fakeApi({ pages: [[pr(1)]], checked: new Set([pr(1).headRefOid]) }), sleep: async () => {}, log: () => {}, loadLimits: async () => LIMIT_DEFAULTS, loadAdoption: async () => ({}), loadOwnedBranches: async () => [] }); try { writeFileSync(output, ""); assert.equal(await main(env, options()), 0); assert.equal(readFileSync(output, "utf8"), "listed=true\nrecord-changed=true\n"); - assert.deepEqual(JSON.parse(readFileSync(path, "utf8")), { version: 6, handled: { [CHECK_NAME]: [pr(1).headRefOid] }, bases: {}, dispatched: {}, docsRuns: {} }); + assert.deepEqual(JSON.parse(readFileSync(path, "utf8")), { version: 7, handled: { [CHECK_NAME]: [pr(1).headRefOid] }, bases: {}, dispatched: {}, docsRuns: {} }); writeFileSync(output, ""); assert.equal(await main(env, options()), 0); assert.equal(readFileSync(output, "utf8"), "listed=true\n"); diff --git a/.github/scripts/pr-unblock/feedback-dispatch.mjs b/.github/scripts/pr-unblock/feedback-dispatch.mjs index 72f84cfd41c..e5ea13a6d8c 100644 --- a/.github/scripts/pr-unblock/feedback-dispatch.mjs +++ b/.github/scripts/pr-unblock/feedback-dispatch.mjs @@ -747,8 +747,10 @@ export async function dispatchFeedback({ } } // Last, as it costs a full verifier read, and on a pass-only dispatch too: a - // later pass clears no cap, and a push past it could never merge, so - // pr-merge closes the pull request for a fresh attempt. It closes only the + // pass clears the cap only by superseding the head's FAIL + // (https://github.com/melodic-software/claude-code-plugins/issues/17646), + // and a push past it could never merge, so pr-merge closes the pull request + // for a fresh attempt. It closes only the // lanes App's: an adopted owner's is never skipped. A pass-only round skips // only on a cap the reader found: it only resolves notes a pass superseded, // and nothing sends it again, so a cap that could not be read (#11354) @@ -777,11 +779,6 @@ export async function dispatchFeedback({ return skip(`#${number} has no unresolved review thread, and the verifier read for an earlier FAIL ${readFailed ? "failed" : `could not count every FAIL (${capped})`}; a later pass inside the retry window reads it again`); } if (capped) { - // The cap never clears for the head: later runs skip it before any - // read. A sibling read that failed is read again next run. - if (capFinal(capped)) { - markHandled(record, settings.checkName, head); - } const warning = deadlineWarning(number, capped); if (warning) { log(warning); diff --git a/.github/scripts/pr-unblock/feedback-dispatch.test.mjs b/.github/scripts/pr-unblock/feedback-dispatch.test.mjs index 8be3e738ac3..98544d94d57 100644 --- a/.github/scripts/pr-unblock/feedback-dispatch.test.mjs +++ b/.github/scripts/pr-unblock/feedback-dispatch.test.mjs @@ -218,10 +218,6 @@ const pull = (overrides) => [ }, ]; -// Owner decision 2026-10-29: pr-verify's FAILs at the cap never clear for the -// pull request, so a fix round's push could never merge: the gate's reader -// (verify-cap.mjs) says so, the dispatcher starts no round and posts nothing, -// and pr-merge closes it for a fresh attempt. test("a PR whose pr-verify FAILs are at the cap gets no address-feedback round", async () => { const api = fakeApi(); const asked = []; @@ -234,13 +230,20 @@ test("a PR whose pr-verify FAILs are at the cap gets no address-feedback round", assert.deepEqual(api.calls.dispatch, []); assert.deepEqual(asked, [{ number: 42, head: HEAD, base: "b".repeat(40), expected: [] }]); assert.match(lines.join("\n"), /^skip: #42: .*verify:repeated-fail/m); - // The cap never clears for the head: a later run at it reads nothing. +}); + +test("a capped head whose FAIL a later pass superseded is read again and dispatched", async () => { const record = emptyRecord(); - await decide(api, resolvedLane(), { verifyCapped, record }); - const again = await decide(fakeApi(), resolvedLane(), { verifyCapped, record }); - assert.equal(again.result, null); - assert.equal(asked.length, 2); - assert.match(again.lines.join("\n"), /\(recorded\)/); + const answers = [{ cap: "verify:repeated-fail: fails at 3 heads, the cap is 3", supersededAtHead: false }, { cap: null, supersededAtHead: true }]; + const verifyCapped = () => answers.shift(); + const capped = await decide(fakeApi(), resolvedLane(), { verifyCapped, record }); + assert.equal(capped.result, null, "capped: no round"); + assert.equal(record.handled.size, 0, "the cap is not recorded as handling the head"); + const api = fakeApi(); + const cleared = await decide(api, resolvedLane(), { verifyCapped, record }); + assert.deepEqual(cleared.result, { number: 42, workflowRunId: "38779200001" }); + assert.deepEqual(api.calls.dispatch.map((call) => call.inputs["pr-number"]), ["42"]); + assert.equal(answers.length, 0, "a superseded head FAIL is a clean head (#17646): the second run reads the verifier again"); }); // A sibling pull request's FAIL run the reader cannot read may hide the cap: @@ -276,8 +279,6 @@ test("a PR skipped because the listing did not fit warns with the reader's detai assert.ok(!sibling.lines.some((line) => line.includes("verify-deadline-skip")), sibling.lines.join("\n")); }); -// A verifier PASS at a new head clears no cap, so the pass-only dispatch -// starts no round either. test("a pass-only dispatch of a PR whose pr-verify FAILs are at the cap gets no round", async () => { const api = fakeApi(); const { result, lines } = await decide(api, resolvedLane(), { passOnly: true, verifyCapped: () => "verify:repeated-fail: fails at 3 heads, the cap is 3" }); @@ -319,7 +320,6 @@ test("a pass-only dispatch names the head superseded only when the gate's reader assert.deepEqual(await inputs({ passOnly: true, verifyCapped: () => ({ cap: null, supersededAtHead: false }) }), [undefined]); assert.deepEqual(await inputs({ passOnly: true, verifyCapped: () => null }), [undefined]); assert.deepEqual(await inputs({ verifyCapped: () => ({ cap: null, supersededAtHead: true }) }), [undefined]); - // A cap the reader found still skips the round, superseded or not. assert.deepEqual(await inputs({ passOnly: true, verifyCapped: () => ({ cap: "verify:repeated-fail: fails at 3 heads, the cap is 3", supersededAtHead: true }) }), []); }); diff --git a/.github/scripts/pr-unblock/fix-ci-dispatch.mjs b/.github/scripts/pr-unblock/fix-ci-dispatch.mjs index 3e36ca91e6b..954f98cad18 100644 --- a/.github/scripts/pr-unblock/fix-ci-dispatch.mjs +++ b/.github/scripts/pr-unblock/fix-ci-dispatch.mjs @@ -63,7 +63,7 @@ import { failingChecks } from "./fix-ci-context.mjs"; import { prHold, reviewReader } from "./gate-source.mjs"; import { HEAD_LAG_STOP, KILL_SWITCH_STOP, killSwitchStop, laneStop, releasesHead } from "./limit-stop.mjs"; import { serverFailure } from "./request-budget.mjs"; -import { final as capFinal, deadlineWarning } from "./verify-cap.mjs"; +import { deadlineWarning } from "./verify-cap.mjs"; export const DEFAULTS = Object.freeze({ base: "main", @@ -683,11 +683,6 @@ export async function dispatchCiFixes({ log(warning); } log(`skip fix-ci #${node.number}: pr-verify's FAILs are at the cap or cannot all be read (${verifyCap}); pr-merge closes it for a fresh attempt, so no fix-ci round`); - // The cap never clears for the head: later runs skip it before any - // read. A sibling read that failed is read again next run. - if (capFinal(verifyCap)) { - markHandled(record, checkName, node.headRefOid); - } continue; } if (fixCiRuns.some((run) => run.conclusion === "NEUTRAL" && run.title === HEAD_LAG_STOP)) { diff --git a/.github/scripts/pr-unblock/fix-ci-dispatch.test.mjs b/.github/scripts/pr-unblock/fix-ci-dispatch.test.mjs index 7ff06a26fe6..4268b96d226 100644 --- a/.github/scripts/pr-unblock/fix-ci-dispatch.test.mjs +++ b/.github/scripts/pr-unblock/fix-ci-dispatch.test.mjs @@ -241,17 +241,16 @@ test("a PR whose pr-verify FAILs are at the cap gets no fix-ci round", async () assert.match(lines.join("\n"), /^skip fix-ci #5: .*verify:repeated-fail/m); }); -test("a capped head is recorded, so the next run skips it without reading the verifier again", async () => { +test("a capped head whose FAIL a later pass superseded is read again and dispatched", async () => { const record = emptyRecord(); - let reads = 0; - const verifyCapped = () => { - reads += 1; - return "verify:repeated-fail"; - }; - await run({ pages: [[pr(5)]] }, { verifyCapped, record }); - const { api } = await run({ pages: [[pr(5)]] }, { verifyCapped, record }); - assert.equal(reads, 1); - assert.deepEqual(api.calls.dispatch, []); + const answers = ["verify:repeated-fail: fails at 3 heads, the cap is 3", null]; + const verifyCapped = () => answers.shift(); + const capped = await run({ pages: [[pr(5)]] }, { verifyCapped, record }); + assert.deepEqual(capped.api.calls.dispatch, [], "capped: no round"); + assert.equal(record.handled.size, 0, "the cap is not recorded as handling the head"); + const cleared = await run({ pages: [[pr(5)]] }, { verifyCapped, record }); + assert.deepEqual(cleared.api.calls.dispatch.map((call) => call.inputs["pr-number"]), ["5"]); + assert.equal(answers.length, 0, "a superseded head FAIL is a clean head (#17646): the second run reads the verifier again"); }); test("a head whose sibling FAIL run cannot be read is skipped but not recorded", async () => { diff --git a/.github/scripts/pr-unblock/verify-cap.mjs b/.github/scripts/pr-unblock/verify-cap.mjs index 492ab2eb178..e99ac44252c 100644 --- a/.github/scripts/pr-unblock/verify-cap.mjs +++ b/.github/scripts/pr-unblock/verify-cap.mjs @@ -1,14 +1,15 @@ // verify-cap.mjs: whether pr-verify's FAILs on a pull request are at the // merge gate's cap (`verify:repeated-fail`), read by the gate's own reader, // babysit_verify_evidence.py `evidence`, so the cap is counted in one place. -// The cap applies only when a FAIL stands at the head (owner decision Q245, +// The cap applies only when a FAIL that is not superseded stands at the head +// (owner decision Q245, // https://github.com/melodic-software/claude-code-plugins/issues/17646); FAILs -// at earlier heads alone never reach it. The reader judges the cap before -// supersession, so at that head it never clears, even when a later pass -// supersedes the head's FAIL, and the pr-merge lane closes the pull +// at earlier heads alone never reach it, and a later supersession of the +// head's FAIL clears it. While it applies, the pr-merge lane closes the pull // request for a fresh attempt at its issue (owner decision 2026-10-29), so // feedback-dispatch.mjs and fix-ci-dispatch.mjs start no address-feedback or -// fix-ci round on it and post nothing. A +// fix-ci round on it and post nothing, and record nothing, so a head whose +// cap cleared is read again. A // FAIL run of another pull request for the same issue that cannot be read // (`verify:unreadable` with the reader's SIBLING_UNREADABLE detail), or an // artifact listing that does not fit in this caller's limit (a detail that @@ -159,9 +160,6 @@ async function fetchCarry(env) { } } -// Whether a verifyCapReader answer never clears for the head, so a -// dispatcher records the head as handled: the cap does, a sibling read that -// failed may clear next run. export const final = (answer) => typeof answer === "string" && answer.startsWith(CAPPED); // The workflow annotation for a skip because the listing did not fit in the @@ -197,7 +195,6 @@ function stderrSummary(stderr) { // A function of { number, head, base, expected } that returns the reader's cap refusal, // `verify:repeated-fail` with its detail (the FAILed heads), the sibling // read's or the caller limit's `verify:unreadable` with its detail, or null. -// Only the first never clears for the head (`final`). // `base`: the pull request's base commit, so the reader takes the gate's // merge.max-verify-fails (the lower of that commit's and main's). // `expected`: refusals the round is sent for, which warn nothing. diff --git a/docs/conventions/pr-pipeline.yaml b/docs/conventions/pr-pipeline.yaml index 39cb32adf30..8bae55247c0 100644 --- a/docs/conventions/pr-pipeline.yaml +++ b/docs/conventions/pr-pipeline.yaml @@ -1635,9 +1635,9 @@ merge: max-minutes: 60 max-skips: 3 # pr-verify FAILs at this many distinct heads of one PR hold it, never to - # merge unattended (owner decision 2026-10-21), when one stands at its - # head, superseded or not; FAILs at earlier heads alone leave a pass at - # the head to decide (owner decision Q245, + # merge unattended (owner decision 2026-10-21), when one that is not + # superseded stands at its head; FAILs at earlier heads alone leave a pass + # at the head to decide (owner decision Q245, # https://github.com/melodic-software/claude-code-plugins/issues/17646). The # pr-merge lane closes a lanes App one for a fresh attempt at its issue, # and address-feedback and fix-ci start no more rounds on it (owner diff --git a/docs/conventions/pr-pipeline/README.md b/docs/conventions/pr-pipeline/README.md index 50b26db4a24..45d0d907aaa 100644 --- a/docs/conventions/pr-pipeline/README.md +++ b/docs/conventions/pr-pipeline/README.md @@ -2962,11 +2962,11 @@ other artifact with such a name is ignored. The resolver and the gate each hold dependency-manager list, and one test runs both to keep them equal. At the pull request's vetted head: -- a counted `fail` at the head, superseded (the next item) or not, with counted `fail` +- a counted `fail` at the head that is not superseded (the next item), with counted `fail` verdicts at `merge.max-verify-fails` (default 3) or more distinct heads of the pull request, tied as in the item after next, that head included, refuses (`verify:repeated-fail`). `fail` verdicts - at other heads alone never cap: a head with no counted `fail` goes on to the items below (owner - decision Q245, 2026-11-20). A value that is not a count of 1 or + at other heads alone never cap: a head whose newest verdicts pass, or whose `fail` is superseded, + goes on to the items below (owner decision Q245, 2026-11-20). A value that is not a count of 1 or more, an empty or non-scalar one included, is 1, so any `fail` standing at the head caps. Before a `fail` at the head decides, counted `fail` verdicts of other pull requests in this repository, for its linked issues, count too, at their own heads, unless that pull request merged or is a closed lanes App @@ -3010,10 +3010,9 @@ head: relink), else at least one body edit from the last `fail`'s run's creation (a body fix). The lanes App, any other Bot, an actor GitHub cannot name, a read that fails or is cut short, a time that cannot be read, or the same linked issues with no body edit keep the refusal. Both the - resolver and the gate read these acts in one GraphQL query, only on this path. The cap is judged before supersession, so a capped head stays - capped: the pr-unblock dispatchers record it as handled. Under the cap a superseded `fail` - refuses nothing at its own head, and the passes then decide as below; it still counts toward - `merge.max-verify-fails`, at its own head and when a later head fails. A judgment on an older listing (pr-merge's provisional one) can + resolver and the gate read these acts in one GraphQL query, only on this path. Supersession is judged before the cap: a superseded `fail` caps + nothing at its own head, and the passes then decide as below; it still counts toward + `merge.max-verify-fails` when a later head fails. A judgment on an older listing (pr-merge's provisional one) can still refuse `verify:fail` until a listing that holds the superseding pass is read; - a counted `fail` at another head of the pull request (its number, one of its commits, or a verdict recording its head branch, read from the name's digest, or for a name without one from diff --git a/docs/conventions/pr-pipeline/pr-pipeline.schema.json b/docs/conventions/pr-pipeline/pr-pipeline.schema.json index 4f7d53fe0f4..092bf9ed925 100644 --- a/docs/conventions/pr-pipeline/pr-pipeline.schema.json +++ b/docs/conventions/pr-pipeline/pr-pipeline.schema.json @@ -1431,7 +1431,7 @@ "type": "integer", "minimum": 1, "default": 3, - "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` when one stands at its head, superseded or not; fail verdicts at other heads alone never do (owner decision Q245): the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any fail standing at the head caps." + "description": "Counted pr-verify fail verdicts at this many distinct heads of one pull request refuse it `verify:repeated-fail` when one that is not superseded stands at its head; fail verdicts at other heads alone never do (owner decision Q245): the pr-merge lane closes a lanes App pull request for a fresh attempt at its issue, and address-feedback and fix-ci start no more rounds on it (README.md, Verifier verdict). Any other value is 1, so any fail standing at the head caps." }, "verify-cap-attempts": { "type": "integer", diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py index 64069830844..4119a2a178a 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py @@ -916,7 +916,7 @@ def floor(self) -> Floor: risk_escalation_minutes: int = RISK_ESCALATION_MINUTES # `merge.max-verify-fails`: counted pr-verify FAILs at distinct heads of # one pull request at which it holds, never to merge unattended, when one - # stands at its head, superseded or not (`babysit_verify_evidence`, + # that is not superseded stands at its head (`babysit_verify_evidence`, # https://github.com/melodic-software/claude-code-plugins/issues/17646). # Absent is `MAX_VERIFY_FAILS`; anything but a whole number of at least 1 # is 1, so any FAIL standing at the head caps. diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py index 1cc374c4335..2f8fed5cb07 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py @@ -21,12 +21,12 @@ `Reader.evidence` decides one pull request at its vetted head, in this order: -- a counted FAIL at the head, under any pull request number, superseded (the - next item) or not, with counted FAILs at `max_fails` or more distinct heads - of this pull request (tied as in the item after next), that head included: - `verify:repeated-fail`. FAILs at other heads alone never cap: a head with - no counted FAIL goes on to the items below (owner decision Q245, - 2026-11-20). Before a FAIL at +- a counted FAIL at the head, under any pull request number, that is not + superseded (the next item), with counted FAILs at `max_fails` or more + distinct heads of this pull request (tied as in the item after next), that + head included: `verify:repeated-fail`. FAILs at other heads alone never + cap: a head whose newest verdicts pass, or whose FAIL is superseded, goes + on to the items below (owner decision Q245, 2026-11-20). Before a FAIL at the head decides, FAILs of other pull requests in this repository that are not merged, nor a closed lanes App attempt (`_counts`), and close one of its issues (its closing issues, or its `Refs:` issue) count too, at their own @@ -46,12 +46,10 @@ at least one from the first FAIL's creation for a pass that records other linked issues than each FAIL does (a relink), else at least one body edit from the last FAIL's creation (a body fix judged at the same head). - The cap is judged before supersession, so a capped head stays capped - (`VERIFY_FINAL`). Under the cap a superseded FAIL refuses nothing at its - own head, and the passes then decide as below; it still counts toward - `max_fails`, at its own head and when a later head FAILs. The report's - `supersededAtHead` names it, false when the cap decided, for pr-unblock to - resolve that FAIL's fail-note threads. Any record, + Supersession is judged before the cap. A superseded FAIL caps nothing at + its own head, and the passes then decide as below; it still counts toward + `max_fails` when a later head FAILs. The report's `supersededAtHead` names + it, for pr-unblock to resolve that FAIL's fail-note threads. Any record, time or read that fails keeps `verify:fail`; - a counted FAIL at another head of this pull request: its number, one of its commits (`pulls//commits`), or a verdict recording its head branch (read @@ -4347,21 +4345,15 @@ def superseded(sha: str) -> bool: ) return self._superseded(number, sha, fail_artifacts, at) - read_elsewhere: list[tuple[dict[Any, Any], set[str]]] = [] - def elsewhere() -> tuple[dict[Any, Any], set[str]]: - if not read_elsewhere: - read_elsewhere.append( - self._elsewhere( - number, - failed_by_pr, - unread_prs, - failed_by_issue, - unread_issues, - fail_times, - ) - ) - return read_elsewhere[0] + return self._elsewhere( + number, + failed_by_pr, + unread_prs, + failed_by_issue, + unread_issues, + fail_times, + ) def capped(heads: set[str]) -> str: return ( @@ -4372,21 +4364,21 @@ def capped(heads: set[str]) -> str: refusal: str | None detail = unreadable - head_superseded = head in failed and superseded(head) - if head in failed and len(failed) >= self.max_fails: - refusal = REPEATED_FAIL - detail = f"fails at {len(failed)} heads ({_heads(failed)}), the cap is {self.max_fails}" - head_superseded = False - elif ( + head_superseded = False + if ( head in failed - and len(heads := failed | elsewhere()[1]) >= self.max_fails + and not (head_superseded := superseded(head)) + and len(failed) >= self.max_fails ): + refusal = REPEATED_FAIL + detail = f"fails at {len(failed)} heads ({_heads(failed)}), the cap is {self.max_fails}" + elif head in failed and not head_superseded: # A FAIL here gets a fix round, so the cap counts the other pull # requests for its issues first: a round past it cannot merge. - refusal, detail = REPEATED_FAIL, capped(heads) - head_superseded = False - elif head in failed and not head_superseded: + heads = failed | elsewhere()[1] refusal = FAIL + if len(heads) >= self.max_fails: + refusal, detail = REPEATED_FAIL, capped(heads) elif fails and ( not self._passes_follow(fails, passes) or not self._change_differs( diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py index 05198a60a49..4f1957d8467 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_verify_evidence.py @@ -1373,7 +1373,7 @@ def test_another_prs_fail_at_the_head_keeps_it(self) -> None: fake.records[name] = record(99, verdict="fail", linked_issues=[]) self.assertEqual(read(fake).refusal, "verify:fail") - def test_a_superseded_fail_at_the_head_at_the_cap_stays_capped(self) -> None: + def test_a_superseded_fail_at_the_head_does_not_reach_the_cap(self) -> None: fake = self.relinked() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), @@ -1382,10 +1382,10 @@ def test_a_superseded_fail_at_the_head_at_the_cap_stays_capped(self) -> None: ): reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) evidence = reader.evidence(PR, HEAD, pull()) - self.assertEqual(evidence.refusal, "verify:repeated-fail") - self.assertIs(evidence.report()["supersededAtHead"], False) + self.assertIsNone(evidence.refusal) + self.assertIs(evidence.report()["supersededAtHead"], True) - def test_fails_at_three_earlier_heads_cap_a_head_fail_superseded_or_not( + def test_fails_at_three_earlier_heads_cap_only_an_unsuperseded_head_fail( self, ) -> None: def history() -> FakeGitHub: @@ -1396,8 +1396,8 @@ def history() -> FakeGitHub: return fake evidence = read(history()) - self.assertEqual(evidence.refusal, "verify:repeated-fail") - self.assertIs(evidence.report()["supersededAtHead"], False) + self.assertIsNone(evidence.refusal, "a superseded head FAIL is a clean head") + self.assertIs(evidence.report()["supersededAtHead"], True) unanswered = history() unanswered.relink = relink_answer() self.assertEqual(read(unanswered).refusal, "verify:repeated-fail") @@ -1568,7 +1568,7 @@ def test_the_report_names_no_fail_superseded_elsewhere(self) -> None: ) self.assertIs(read(merge_only).report()["supersededAtHead"], False) - def test_the_cap_is_judged_before_a_superseded_fail_at_the_head(self) -> None: + def test_a_superseded_fail_at_the_head_is_judged_before_the_cap(self) -> None: fake = self.edited() with ( mock.patch.object(postmerge, "gh_capture", side_effect=fake), @@ -1577,8 +1577,8 @@ def test_the_cap_is_judged_before_a_superseded_fail_at_the_head(self) -> None: ): reader = ve.Reader(REPO, "main", now=NOW, max_fails=1) evidence = reader.evidence(PR, HEAD, pull()) - self.assertEqual(evidence.refusal, "verify:repeated-fail") - self.assertIs(evidence.report()["supersededAtHead"], False) + self.assertIsNone(evidence.refusal) + self.assertIs(evidence.report()["supersededAtHead"], True) # Pull request #16602's FAIL notes at head 27fe8d09, as its pr-verify From 11483a016920129120e77e318dea3e7057aae6f1 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 17:08:30 -0500 Subject: [PATCH 7/7] test(source-control): declare feedback-dispatch's read of resolve-config's package.json Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtVYpJGw3s2scXJV5jf --- .github/scripts/pr-unblock/feedback-dispatch.test.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/pr-unblock/feedback-dispatch.test.mjs b/.github/scripts/pr-unblock/feedback-dispatch.test.mjs index 98544d94d57..afa213379c9 100644 --- a/.github/scripts/pr-unblock/feedback-dispatch.test.mjs +++ b/.github/scripts/pr-unblock/feedback-dispatch.test.mjs @@ -1,3 +1,4 @@ +// test-scope: .github/actions/resolve-config/package.json import assert from "node:assert/strict"; import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { join } from "node:path";