Skip to content

refactor(pr): replace the PR check mechanics with gh pr checks #7499

Backlog
4 of 4 issues completed
Backlog

Description

@dan-petty

Problem

devops-cli rebuilds check and merge logic that GitHub and gh already have. It polls check runs and statuses, and removes the older runs. It guesses which workflows a PR starts. It decides "ready" and "merge".

The code (lines at commit d0bc3dffa), about 2,100 lines and 111 tests:

  • src/devops_cli/github/check_verdict.py:251-270: latest_run_of_each_check. Its docstring says "gh pr checks also shows only the newer run".
  • check_verdict.py:342-470 and :507-548: the verdict.
  • github/workflow_triggers.py:1-129: a copy of the on.pull_request branch and path filters of GitHub.
  • merge_readiness.py:282-357: the readiness.
  • pr_monitor.py:646-713: the poll loop.
  • onboard/template_pr.py:31-55, :137-146 and :312-377: the same checks for the template PR.

Every agent PR and every person PR goes through this code. In 30 days it broke 17 times:

Change

Replace the mechanics with gh and the merge rules of GitHub.

  • Tool: GitHub CLI (https://github.com/cli/cli), MIT, v2.106.0 (2026-11-25).
  • gh pr checks <n> --required --watch --fail-fast --interval <s> replaces the poll loop, the filter for the latest run and the trigger guess. GitHub reports only the checks that run, and the newest run of each.
  • gh pr view <n> --json mergeStateStatus,statusCheckRollup,reviewDecision replaces the readiness reads.
  • gh pr ready marks a draft ready.
  • gh pr merge <n> --auto --squash --match-head-commit <sha> replaces the merge mechanics. GitHub merges only that head commit, after the required checks pass. Who may merge does not change.
  • The ruleset rule required_review_thread_resolution makes GitHub refuse a merge while a review thread is open. A person adds it to the ruleset baseline.

Keep, because these rules are project policy over the gh output:

  • the grounding rules, and the plan and stage-eval rules;
  • the settle time of the Copilot review;
  • the map of exit codes and the fail-closed report.

Keep one fallback. A private repository on the Free plan has no rulesets, so --required reads nothing there. For such a repository, read all checks with gh pr checks and no --required.

Delete:

  • workflow_triggers.py and its tests.
  • latest_run_of_each_check and the custom dedup in check_verdict.py.
  • The poll loop of pr_monitor.py, and the check reads of template_pr.py.

Existing tool considered

  • gh (MIT, v2.106.0). It covers the check list, the watch, the readiness fields, the ready mark and the auto-merge. It has no project policy rules.
  • peter-evans/enable-pull-request-automerge. It is not chosen, because its last release is from 2023-03. gh pr merge --auto does the same.

Done when

  • workflow_triggers.py, latest_run_of_each_check and the custom poll loop are deleted.
  • The monitor, ready and merge commands of devops pr run gh pr checks --required --watch and gh pr merge --auto --match-head-commit.
  • A test proves that each command sends these gh arguments and maps the gh exit code to the project verdict.
  • A test proves the all-checks fallback for a repository with no ruleset.
  • The tests of the policy rules stay and pass.

Source

Source: https://github.com/dan-petty/devops-cli/blob/d0bc3dffa781951f7b49935ba545cad82b2ecfaf/src/devops_cli/github/check_verdict.py

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    type/refactor
    source/agent
    on Nov 28, 2026
  2. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor
  3. added
    status/new
    effort/medium
    value/high
    scope/pr
    priority/p2-medium
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 28, 2026
  4. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor

    This item is larger than one pull request: about 20 modules read checks through check_verdict.py. It is split by command into four sub-issues:

    Evidence for the split and the design:

    • gh v2.106.0 is in the devcontainer (the build info of /usr/local/bin/gh). In pkg/cmd/pr/checks/checks.go, --watch and --json exclude each other, and a head with no check exits 1 with no checks reported, the same exit code as a failed check.
    • --required cannot replace the trigger guess. It cannot tell a branch that requires no check from required checks that have not started. The rules of the base branch (GET /repos/{repo}/rules/branches/{base}) tell them apart.
    • On PR fix(repos): Keep live rules and stricter thresholds #7481, 3 of 29 checks were required (isRequired of the GraphQL rollup). If the readiness verdict used --required, pr ready would pass a failed Fail-to-Pass Check, CodeQL or Plan Check. That lowers a quality threshold (AGENTS.md rule 5), so refactor(pr): read the readiness checks with gh pr checks #7508 keeps all checks in the verdict.
    • required_review_thread_resolution is already true in the rules of main and in the onboard baseline (src/devops_cli/github/onboard/ruleset_merge.py:51). No person step remains for it. The thread blocker of the readiness verdict stays, because it names the threads to fix (pr_threads.py is in the Keep table of the audit).
    • devops pr has no merge command. The only merge mechanics are those of the onboard template pull request (refactor(repos): wait for and merge the onboard template PR with gh #7512).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumowner/agentpriority/p2-mediumscope/prsource/agentstatus/in-progresstype/refactorvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions