Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scripts/ci/pr_review_merge_scheduler_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,19 @@ def failed_status_checks(
for node in status_contexts
if (node.get("state") or "").upper() == "SUCCESS"
}
# The mirror of ``successful_status_contexts``. ``opencode-review-dispatch.yml``
# publishes the optional ``opencode-review`` commit status once and can record
# ``failure`` minutes before the authoritative exact-head required review
# concludes ``success``; nothing rewrites that status afterwards. Keyed on the
# required-context name so a sibling job of the OpenCode workflow succeeding
# cannot retire a genuine ``opencode-review`` failure. ``is_opencode_context``
# keeps this inert in central required-workflow mode, where the CheckRun is the
# non-authoritative placeholder and the status is the real verdict.
successful_check_run_contexts = {
node.get("name")
for node in check_runs
if (node.get("conclusion") or "").upper() == "SUCCESS" and is_opencode_context(node)
}
for index, node in enumerate(check_runs):
if is_non_authoritative_coverage_check_run(node):
continue
Expand All @@ -2555,6 +2568,8 @@ def failed_status_checks(
if state in {"FAILURE", "ERROR"}:
if ignore_opencode and is_opencode_context(node):
continue
if is_opencode_context(node) and "opencode-review" in successful_check_run_contexts:
continue
failed.append(node.get("context") or "status-context")
return failed

Expand Down
53 changes: 53 additions & 0 deletions tests/test_pr_review_merge_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3312,6 +3312,59 @@ def test_review_state_and_failed_checks():
assert sched.failed_status_checks(manual_opencode_supersedes_pr_target_failure) == ["lint"]


def test_successful_opencode_check_run_supersedes_a_stale_dispatch_status():
"""A concluded exact-head OpenCode check run retires the dispatch status it outlived.

``opencode-review-dispatch.yml`` publishes the ``opencode-review`` commit
status once, from whichever dispatch reaches the publish step first, and it
calls that status optional while naming the exact-head required review
authoritative. When the dispatch loses the race it records ``failure``
minutes before the required ``opencode-review`` check run concludes
``success`` on the very same head, and nothing ever rewrites the status.
Measured on 2026-09-09: 36 of the 69 open non-draft pull requests carried
exactly that pair, each permanently ``BLOCKED`` behind a verdict its own
authoritative check run had already superseded.

``failed_status_checks`` already lets a successful status context retire a
failing check run of the same name; this is that rule's missing direction.
"""
stale_dispatch_status = make_pr(
statusCheckRollup={
"contexts": {
"nodes": [
{
"__typename": "CheckRun",
"name": "opencode-review",
"conclusion": "SUCCESS",
},
{"context": "opencode-review", "state": "FAILURE"},
{"context": "lint", "state": "ERROR"},
]
}
}
)
assert sched.failed_status_checks(stale_dispatch_status) == ["lint"]

still_failing_without_a_successful_check_run = make_pr(
statusCheckRollup={
"contexts": {
"nodes": [
{
"__typename": "CheckRun",
"name": "opencode-review",
"conclusion": "FAILURE",
},
{"context": "opencode-review", "state": "FAILURE"},
]
}
}
)
assert still_failing_without_a_successful_check_run is not None
assert sched.failed_status_checks(
still_failing_without_a_successful_check_run
) == ["opencode-review", "opencode-review"]


def test_scheduler_query_requests_pull_request_author():
"""Fetch the authoritative author identity used by the independent-review gate."""
assert "\n author { login }\n" in sched.PULL_REQUEST_FIELDS_FRAGMENT
Expand Down
Loading