Skip to content

fix(github): Fix check-readiness base and monitor merged state #2530

Closed

Description

@dan-petty

Problem Description

Two devops pr commands reported a wrong state for PR #2509 on 2026-10-28:

  1. devops pr check-readiness 2509 reported "not grounded" and named the archived changes of other issues (1024, 1652, 2429). The branch had a new merge commit (344adba) on top of main 5c4d24e. GitHub's pulls/2509/files list still used the old PR base 0137f23 and gave 184 files. The compare API main...344adba9 gave merge base 5c4d24e and 11 files, and the squash commit also has 11 files. Readiness read the stale file list, so its blocker was false.
  2. devops pr monitor 2509 printed "Checks: 0/0 passed" and then "100% READY FOR MERGING: All checks passed" in the interval in which a person merged the PR. For a merged PR, the monitor counted no checks and still reported ready.

Reproduction Steps

  1. Push a merge commit to an open PR branch so that the PR's merge base with main moves, and run uv run devops pr check-readiness <pr> within a few minutes.
  2. Run uv run devops pr monitor <pr> and merge the PR while it waits.

Expected vs Actual Behavior

Expected: readiness takes the PR's files from the merge base that the squash merge uses (for example the compare API of the base branch and the head), and pr monitor reports a merged or closed PR as merged or closed, with no check count and no "READY" line.

Actual: a false "not grounded" blocker, and "100% READY" with 0/0 checks for a merged PR.

Environment Diagnostics

main at 2026-10-28 (after #2442).

Logs, Traces, or Terminal Output

PR #2509 is not grounded: ... (names 1024, 1652, 2429)
Checks: 0/0 passed
100% READY FOR MERGING: All checks passed

Source: #2509

Alternatives check of 2026-11-07: partly.
Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub), Apache-2.0, last activity 2026-09-25, maintained.

Proposed design

Problem statement

devops pr check-readiness reads a pull request's file list from the pulls files endpoint, which keeps the merge base of the last push. A merge commit that moves the merge base makes readiness judge a stale list, report a false not-grounded blocker and name archived changes of other issues. devops pr monitor already reads merged and has a merged result, but the command prints its READY success line and the Checks: 0/0 status line on any exit 0, so a pull request merged during monitoring is still reported 100% ready, with no check count that means anything; a pull request closed unmerged has no terminal state at all and is judged as if it could still become ready.

Acceptance criteria

Requirement: Readiness reads the compare file list

devops pr check-readiness SHALL read the pull request's file list from the compare endpoint of the base branch's tip and the head commit.

Scenario: Moved merge base

  • WHEN The pull request branch holds a new merge commit and the pulls files endpoint still lists the files of the old base.
  • THEN The readiness read requests repos/{owner}/{repo}/compare/{base_sha}...{head_sha} and uses the files of that answer as the changed files.

Requirement: Readiness makes no pulls files request

devops pr check-readiness MUST NOT request pulls/{number}/files for the file list.

Scenario: Stale list names archived changes

  • WHEN The pulls files endpoint would name archived change folders of other issues and the compare answer does not.
  • THEN No request path of the readiness run ends with pulls/{number}/files, and the verdict holds no not-grounded blocker naming those folders.

Requirement: Fork head is named by owner and branch

devops pr check-readiness SHALL name the compare's head as owner:branch when the head repository differs from the base repository, and by its commit sha otherwise.

Scenario: Pull request from a fork

  • WHEN The pull request payload gives a head repository that is not the base repository.
  • THEN The compare request target is repos/{base_owner}/{repo}/compare/{base_sha}...{head_owner}:{head_ref}.

Requirement: A 300-file compare answer is reported

devops pr check-readiness SHALL report a compare answer that holds GitHub's 300-file limit as a possibly truncated file list, naming the limit.

Scenario: Compare answer at the limit

  • WHEN The compare endpoint returns exactly 300 files.
  • THEN The readiness output names GitHub's 300-file limit and does not report a not-grounded blocker for a change folder missing from that list.

Requirement: Monitor reads pull request state

devops pr monitor SHALL read the pull request state on every poll and stop polling on a closed pull request.

Scenario: Closed during monitoring

  • WHEN A poll reads state as closed and merged as false.
  • THEN The monitor makes no further poll and returns the closed result.

Requirement: Merged result in table output

devops pr monitor SHALL report a merged pull request as merged, with no check count and no READY line, and exit 0.

Scenario: Merged during monitoring

  • WHEN A poll reads merged as true.
  • THEN The output holds PR #<number> is merged., holds no Checks: line and no READY FOR MERGING, and the exit code is 0.

Requirement: Closed unmerged result

devops pr monitor SHALL report a closed unmerged pull request as closed, with no check count and no READY line, and exit 2.

Scenario: Closed without merge

  • WHEN A poll reads state as closed and merged as false.
  • THEN The output holds PR #<number> is closed., holds no Checks: line and no READY FOR MERGING, and the exit code is 2.

Requirement: Merged result in markdown output

devops pr monitor --format markdown SHALL report a merged pull request as merged and MUST NOT call it ready.

Scenario: Markdown of a merged pull request

  • WHEN The monitor's result is a merged pull request and the format is markdown.
  • THEN The **State** line holds merged and does not hold Ready for Merging.

Requirement: Dry-run plan names the compare endpoint

devops pr check-readiness --dry-run SHALL list the compare request for the file list and MUST NOT list pulls/{number}/files.

Scenario: Request plan of check-readiness

  • WHEN The dry-run plan of devops pr check-readiness is rendered.
  • THEN The plan holds a request whose target is repos/{repo}/compare/<base>...<head> and holds no target ending with pulls/<number>/files.

Existing Tool Considered

gidgethub/gidgethub (Apache-2.0, last activity 2026-09-25, maintained) supplies the GitHub REST client that ADR 0006 chooses, and the session already reads the compare endpoint through it (GitHubClient.get_merge_base). It lacks the change to read the compare endpoint's files for the readiness file list instead of the stale pulls files endpoint, the report of a 300-file answer as a possibly truncated list, and the change that makes pr monitor print a merged or closed pull request as such, with no check count and no READY line. The change adds no dependency and no second client.

Key questions

  • Does gidgethub cover the need?: Partly. gidgethub is the session's REST client (ADR 0006): the session's GitHubClient already reads pulls/{number} and compare/{base}...{head} through it, so both calls the fix needs are available with no new dependency. It does not decide which endpoint the readiness file list comes from, does not turn a 300-file compare answer into a reported truncation, and does not change what the monitor prints for a merged or closed pull request. [sources: docs/adr/0006-github-session-requests-go-through-gidgethub.md:3, src/devops_cli/github/client.py:424, src/devops_cli/github/client.py:456]
  • Which GitHub endpoint supplies the pull request file list at the merge base?: Use the compare endpoint GET /repos/{owner}/{repo}/compare/{base}...{head} with the base branch's tip and the head commit, and read its files. The pulls files endpoint keeps the base of the last push, which is the stale list that caused the false blocker. (best practice) [sources: src/devops_cli/github/client.py:456, src/devops_cli/github/merge_readiness.py:571, CHANGELOG.md:2817]
    • Chosen: Compare endpoint. It follows the current merge base, which is the diff the squash merge uses, and the session already reads it for the merge base (client.py:456).
    • Rejected: Pulls files endpoint. It keeps the base of the last push; the issue records 184 files where the compare answer gave 11.
    • Rejected: Local git diff. It needs a full checkout of both commits and adds a second source of truth beside the GitHub answer.
  • How should the compare endpoint's 300-file limit be handled?: Report it, do not judge on it. When the compare answer holds exactly 300 files, the read carries the reason that GitHub's compare file list is capped at 300 files, and the verdict names that limit where grounding applies instead of reporting a not-grounded blocker from a partial list. The project already recorded this rule: a compare answer that lists GitHub's limit of 300 files is held with a blocker naming the failure. (best practice) [sources: CHANGELOG.md:2817, src/devops_cli/github/client.py:456, src/devops_cli/github/merge_readiness.py:335]
    • Chosen: Report the 300-file answer as truncated. The project's record of the compare endpoint treats a 300-file answer as a failure to read, so a partial list never becomes a grounding verdict.
    • Rejected: Judge on the 300 files. A change folder beyond the cap would give the same kind of false not-grounded blocker this issue fixes.
    • Rejected: Page the compare file list. No source in the repository names a paging parameter for the compare file list; the recorded behaviour is a 300-file limit.
    • Rejected: Fall back to pulls files for large pull requests. That is the endpoint whose stale base caused the false blocker.
  • How should the compare request name the head commit of a pull request from a fork?: By owner:branch, built from the head's repository and ref, when the head repository differs from the base repository; by the head commit sha otherwise. CommitRef already carries the head's repository, sha and ref. (best practice) [sources: src/devops_cli/github/client.py:60, src/devops_cli/github/client.py:456]
    • Chosen: Owner and branch for a fork head, sha otherwise. The payload's head.repository and head.ref name a head that is not a commit of the base repository, and the same-repository case keeps the precise sha.
    • Rejected: Always the head sha. A fork's head commit is not a commit of the base repository, so the compare cannot resolve it against the base.
  • Is the merged state already handled by the monitor?: Yes, in the monitor and not in the command. get_pr_monitoring_status reads merged and returns before any check read, monitor_pr returns the PR #<number> is merged. result, but the command prints MESSAGES.pr.pr_ready_success on every exit 0 and the status callback prints Checks: 0/0 for the empty check list. That is exactly the 2026-11-11 output: Checks: 0/0 passed and 100% READY FOR MERGING. [sources: src/devops_cli/github/pr_monitor.py:534, src/devops_cli/github/pr_monitor.py:539, src/devops_cli/github/pr_monitor.py:573, src/devops_cli/commands/pr.py:771, src/devops_cli/commands/pr.py:800]
  • Where should the monitor's terminal result come from?: From the monitor's own result. The command prints result.message and skips the check-count status line and the READY line for a terminal status, and the markdown state line says merged for a merged result instead of Ready for Merging. (best practice) [sources: src/devops_cli/commands/pr.py:800, src/devops_cli/commands/pr.py:609, src/devops_cli/github/pr_monitor.py:571]
    • Chosen: Print the result message for a terminal state. The monitor already builds the merged message and exit code; the command throws it away on exit 0.
    • Rejected: Keep the READY line and add a merged note. A merged pull request is not ready for merging, so the READY claim stays false.
  • Should the merged result name the checks that still run?: No. A merged pull request is terminal, so the poll returns before it reads any check, and the message names the merge only. A check that still runs after the merge cannot change a merged pull request, and the issue asks for no check count and no READY line. (best practice) [sources: src/devops_cli/github/pr_monitor.py:539, src/devops_cli/github/pr_monitor.py:655]
    • Chosen: Read no checks and name none. The merged poll already returns before the check read, so the result is one request and the message states the state.
    • Rejected: Read and name the running checks. It adds check and status reads to a terminal poll for checks that cannot change the outcome, and it keeps a check count in the merged output.
  • What exit code should a closed unmerged pull request return?: Return exit code 2, the monitor's code for a blocker that is not a failed or unread check and not the timeout. A closed unmerged pull request cannot become ready, so it is neither a success (0) nor a check failure (1) nor a timeout (3). (best practice) [sources: src/devops_cli/github/pr_monitor.py:100, src/devops_cli/github/pr_monitor.py:587]
    • Chosen: Exit code 2. It matches the existing code for another blocker.
    • Rejected: Exit code 0. It would report a closed unmerged pull request as success.
    • Rejected: Exit code 1. It would report a check failure that did not occur.
    • Rejected: Exit code 3. It would report a timeout that did not occur.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. Two incorrect outputs in pr check-readiness and pr monitor are reported as defects with reproduction steps.
    • Priority: P2-Medium. A false readiness blocker can delay a merge, and a false READY line misleads a person, but neither breaks the build.
    • Value: Medium. Developers who use pr check-readiness and pr monitor get wrong verdicts that block or mislead merge decisions.
    • Effort: Medium. Two separate code paths need fixes: the file-list source in check-readiness and the merged-state handling in pr monitor.
    • Related: refactor(github): pr ready and pr monitor read the merge-readiness verdict, and pr monitor waits until the checks settle and names every blocker #2443, which asks for a different change. Both touch pr monitor behaviour, but 2443 refactors it to read a shared verdict and wait for checks, while the candidate fixes it to report a merged PR as merged instead of READY.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 0f7bc26 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Which file holds the check-readiness file-list logic? (missing verified source)
    • Which file holds the pr monitor reporting logic? (missing verified source)
  5. added
    scope/github
    on Oct 30, 2026
  6. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    Evidence from pull request #3496 (issue #3226), which is still a draft.

    • The pull request base SHA is 46cf288. It was set when the plan pull request was first opened. Current origin/main is d254410.
    • The pull request files API lists 500 files. Most of them are archived changes that main gained after 46cf288, such as openspec/changes/archive/2026-11-04-2131-one-devops-command-fetches-the/.
    • The diff of the head branch against current origin/main has 17 files, all from issue fix(roadmap): the task renderer adds steps a plan does not need #3226.
    • devops pr monitor 3496 reports: "PR fix(roadmap): render only the steps a plan needs #3496 is not grounded: it changes openspec/changes/archive/2026-11-04-2131-one-devops-command-fetches-the/.openspec.yaml ...".
    • devops pr edit 3496 --base main was denied by the permission check, so the base SHA is not refreshed. The base SHA has not changed after new pushes either.

    This matches the squash merge base problem of this issue. The check reads files from the stale base, not from the current main.

  7. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at d254410 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Which file holds the check-readiness file-list logic? (missing verified source)
    • Which file holds the pr monitor reporting logic? (missing verified source)
  8. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 66a8a63 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • The proposal has no problem statement, no acceptance criterion with its requirement, scenario, WHEN and THEN, or no answer to the existing-tool question. State the problem, the requirements with their scenarios, and the open tool that covers the need or the cost of building it.
  9. changed the title [-]fix(github): pr check-readiness reads the files of the squash merge base, and pr monitor reports a merged pull request as merged[/-] [+]fix(github): Fix check-readiness base and monitor merged state[/+] on Nov 6, 2026
  10. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 115 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(github): pr check-readiness reads the files of the squash merge base, and pr monitor reports a merged pull request as merged
    • After: fix(github): Fix check-readiness base and monitor merged state
    • Source of the summary: the background model
  11. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: Every web search I ran failed, so I read the facts of the GitHub client that the project's session already uses (ADR 0006): gidgethub reaches both endpoints the fix needs, the compare endpoint for the merge base and file list and the pull request endpoint for state/merged. It only supplies the API access; it does not change which endpoint the code reads or how the monitor reports a merged pull request, so it covers a part of the need and the rest stays a code change in the CLI.

    Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub)

    • License: Apache-2.0
    • Last activity: 2026-09-25
    • Maintained: yes

    Covers:

    • One HTTP client for the GitHub REST API, the session chosen in ADR 0006
    • Can call the compare endpoint for the base and head, which returns the merge base and its file list
    • Can call the single pull request endpoint, which returns state and merged
    • No new dependency or second client is needed for either call

    Lacks:

    • Does not make check-readiness read the file list from the compare endpoint instead of the stale pulls files endpoint
    • Does not page or otherwise lift the compare endpoint's 300-file limit on its file list
    • Does not change pr monitor to report a merged or closed pull request as merged or closed, without a check count and without the READY line

    Tools considered:

    Searches run:

    • GitHub REST API compare two commits merge base file list 300 files, results: 0
    • GitHub REST API get a pull request merged state field, results: 0
    • github compare two commits api merge base files, results: 0
    • GitHub REST compare commits, results: 0
    • github rest api pull request files, results: 0
    • GitHub REST API, results: 0
    • compare two commits github docs, results: 0
    • gidgethub, results: 0

    Sources:

    Checked on 2026-11-07. A person decides what this means for the item. The check changes no label and closes no issue.

  12. 34 remaining items

  13. added
    status/in-review
    and removed
    status/in-progress
    on Nov 13, 2026
  14. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Pull request #4980 is ready for review. The checks passed.

    Spend: 258 model requests, 18717634 input tokens, 82719 output tokens.

  15. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261112-233112-c39b ended: succeeded.
    Image digest: sha256:48c1346d3854aabc64be1705e3205335f2d935136ec26d6d8e1e2858a3ca0a78

    The last lines of its log:

    Tool call: edit_file, ok.
    Tool call: run_command, started: uv run devops ci test tests/commands/test_pr_dry_run.py
    Tool call: run_command, program uv, ok.
    Tool call: run_command, started: grep -rn pulls/.*/files tests --include=<masked> | ...
    Tool call: run_command, started: uv run ruff check src/devops_cli/github/pr_plans.py tests/commands/test_pr_dry_run.py
    Tool call: run_command, program grep, ok.
    Tool call: run_command, program uv, ok.
    Tool call: run_command, started: uv run mypy --strict src/devops_cli/github/pr_plans.py
    Tool call: run_command, program uv, ok.
    Tool call: run_command, started: grep -rn check-readiness tests/golden tests/fixtures docs ...
    Tool call: run_command, program grep, ok.
    Tool call: run_command, started: grep -rn <masked> tests --include=<masked> | ...
    Tool call: run_command, program grep, ok.
    Tool call: read_file, retry (Offset 60 exceeds file length (59 lines). Path: openspec/changes/2530-fix-check-readiness-base-and-monitor/tasks.md).
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: run_command, started: uv run devops pr check-readiness 42 ...
    Tool call: run_command, started: uv run devops openspec check
    Tool call: run_command, program uv, ok.
    Tool call: run_command, program uv, ok.
    Tool call: run_command, started: git status --short
    Tool call: run_command, started: git diff
    Tool call: run_command, program git, ok.
    Tool call: run_command, program git, ok.
    Tool call: run_command, started: git log --oneline -2
    Tool call: run_command, started: grep -n compare/ src/devops_cli/github/pr_plans.py
    Tool call: run_command, program grep, ok.
    Tool call: run_command, program git, ok.
    Formatted: tests/commands/test_pr_dry_run.py
    The checks of pull request #4980 still run after 39 s.
    The checks of pull request #4980 still run after 79 s.
    The checks of pull request #4980 still run after 119 s.
    The checks of pull request #4980 still run after 159 s.
    The checks of pull request #4980 still run after 199 s.
    The checks of pull request #4980 still run after 239 s.
    The checks of pull request #4980 still run after 280 s.
    The checks of pull request #4980 still run after 320 s.
    ✓ Took 1 item(s) to a ready pull request, stopped 0.
    Elapsed: 58m 39s
    
  16. removed
    owner/service
    on Nov 13, 2026
  17. added
    owner/agent
    on Nov 13, 2026
  18. removed
    status/in-review
    owner/agent
    on Nov 13, 2026
  19. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor
  20. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-13 04:03 UTC

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/mediumpriority/p2-mediumscope/githubsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions