Skip to content

refactor(pr): devops pr update acts only on a failed check #4674

Closed

Description

@dan-petty

Problem or Motivation

devops pr update --all calls the GitHub update-branch API for every open pull request that is not a draft. It does not check for a conflict or for a failed check (update in src/devops_cli/commands/pr.py, src/devops_cli/github/branch_update.py). In the census week (2026-11-04 to 2026-11-11), update-branch merges of main with no conflict started 28 runs (about 1,208 runner-minutes). 17 of the 28 merges came in groups of 2 to 6 pull requests within 10 minutes, which is the pattern of --all. Each merge is a head that GitHub makes on the server, where no push check sees it. GitHub update-branch cannot update a branch that has a merge conflict (GitHub docs, "Keeping your pull request in sync with the base branch"), so an update of a dirty pull request cannot work.

The CI audit of 2026-11-11 found 13 topic pull request runs that came from a pure rebase: the base moved and the zero-context patch-id stayed the same. The 7 of them with job files used 571 runner-minutes. The strict up-to-date policy is off, and ADR 0014 asks for a rebase only on a conflict. Thus these runs do no work that the merge needs. The source of the 13 runs is not known.

docs/SDLC.md Phase 5 says that an open pull request needs no catch-up update. The devops-pr-ci skill has no rebase line, and 19 of 171 worktree branches fail the branch-name hook.

The owner decided on 2026-11-11 that the command stays only for a failed required check whose fix is on main. --all and catch-up updates go.

Proposed Solution & Architectural Design

Delete --all/-a and its loop.

devops pr update <n> reads mergeable_state of pulls/<n> and the required check runs of the head:

  • When the state is dirty, it prints the local recipe (git fetch origin main, git rebase origin/main, solve, devops branches push) and makes no API call.
  • It calls update-branch only when a required check failed on the head and the state is not dirty.
  • In all other cases, it prints the reason and changes nothing.

Find the source of the 13 pure-rebase runs first (AGENTS.md rule 2), from the push actors and the Service logs. The leads are devops pr update, the rebase at the start of each implement run (implement_run.py) and the rebase of a staged branch (stage.py). The push gate of #4670 refuses a catch-up-only push from the jobs. When the source is a path that this issue and #4670 do not cover, let that path rebase only on a conflict (git merge-tree --write-tree reports a conflict with no checkout), and push only when the tree changes.

Add these lines to the devops-pr-ci skill (source and the copies under .agents/, .claude/ and .kilocode/skills):

  1. Never push or update only to catch up (docs/SDLC.md Phase 5).
  2. On a rebase conflict in a generated document, run git checkout --ours <file> (in a rebase, "ours" is main), then uv run devops docs generate --sync-readme, git add and git rebase --continue.
  3. Start work with devops repos worktrees add <issue>, whose branch name passes the branch-name hook.

Generate the command documents again. Add no shim.

Target Subsystem

SDLC, Git & PR Governance (src/devops_cli/commands/pr.py, src/devops_cli/github/branch_update.py, the devops-pr-ci skill).

Existing Tool Considered

GitHub REST update-branch and mergeable_state cover the single update. git rebase and the push gate of #4670 cover a conflict. The change deletes the bulk path and adds no tool, so the keep cost falls. Cost (estimate): about 80,000 tokens and 1.5 hours to build.

Acceptance Criteria

  • --all is gone from --help and from the generated command documents.
  • A dirty pull request gets the recipe and 0 API writes.
  • A pull request that is behind main with green checks gets no update.
  • A pull request with a failed required check and no conflict gets exactly one update-branch call.
  • The pull request names the source of the pure-rebase runs, with evidence.
  • One week after the merge, a census finds at most 5 merges of main with the committer GitHub, and no group of 2 or more within 10 minutes.
  • Over one day, 0 topic pull request runs have a moved base and the same patch-id, except after a conflict (13 in the audit).

Dependencies

#4670.

Source: #4667

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/refactor
    scope/pr
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 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/refactor. The refactor prefix of the title gives the type.
    • Scope: scope/pr. The (pr) scope of the title gives the scope.
    • Priority: P2-Medium. An owner decision is made and CI cost is wasted weekly, but no user is blocked and no data is at risk.
    • Value: Medium. Saves roughly 1,208 runner-minutes per week and removes a path that cannot work on a dirty pull request.
    • Effort: Low. The body estimates about 1.5 hours and 80,000 tokens to build.
    • Related: feat(github): add integrations to keep pull requests up to date #258, which asks for a different change. Both target devops pr update; #258 added the command and the --all loop, while the candidate removes --all and restricts the command to a single failed-check case.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Scope from the CI audit (2026-11-11)

    Another workflow builds this item now. This comment only adds the measured cost of pure rebases and an acceptance criterion.

    • On 2026-11-11, 13 topic-PR runs came from a pure rebase: the base moved, and the zero-context patch-id stayed the same (measured). The 7 of them that changed job files used 571 runner-min. The strict policy is off, and ADR 0014 asks for a rebase only on a conflict. Thus these runs do no work that the merge needs.
    • The source is not confirmed. Leads that are not verified: src/devops_cli/roadmap/implement/implement_run.py:790-793 fetches and rebases onto the default branch at the start of each run, and src/devops_cli/roadmap/stage/stage.py:2358-2379 rebases a staged branch.
    • AGENTS.md rule 2 first: find the source from the push actors and the Service logs of these runs.
    • Owner rule of 2026-11-11: each push carries a branch that contains the current origin/main and merges cleanly, and an open PR gets no catch-up rebase when nothing else changes. So a path pushes only when the patch changes or the branch has a conflict with origin/main. git merge-tree --write-tree reports a conflict with no checkout.
    • Added acceptance (for refactor(pr): devops pr update acts only on a failed check #4674 and feat(git): refuse a push that does not hold origin/main #4670 together): the item names the source with evidence. Over one day, 0 topic-PR runs come from a push with a moved base and the same patch-id, except after a conflict (from 13).
    • Saving: 1,000-1,100 runner-min per day at the rate of 2026-11-11 (estimated).
  6. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Scope from the hooks review plan (2026-11-11)

    This issue is also child 5 of #4771 (hooks item P06). Owner decision OD1 (a) of 2026-11-11 applies: devops pr update <n> stays only for a failed required check whose fix is on main, and --all and every catch-up update go. The body already holds the design of both plans.

    The hooks plan adds one constraint:

    Two other children remove catch-up paths: #4027 (no update-branch for a clean branch that is behind main) and #3969 (no push when the plan does not change).

    No new acceptance criterion.

  7. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 12, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  9. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor
  10. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 12:40 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/lowpriority/p2-mediumscope/prsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions