Skip to content

feat(pr): pr create gates the change and pushes once #4708

Open

Description

@dan-petty

Problem or Motivation

In the census week (2026-11-04 to 2026-11-11), 843 topic pushes started runs on open pull requests: 1.86 for each merged pull request. 119 of 851 pull request CI runs (14 %) failed. The owner decided on 2026-11-11 that every push to GitHub follows a passing gate, the first push of a pull request too (OD6 a).

Proposed Solution & Architectural Design

  1. devops pr create rebases onto origin/main. It checks the gate record, or runs the gate of feat(ci): devops ci --remote runs the gate in the cluster #4698. Then it pushes one time and opens the draft.
  2. The push gate of feat(git): refuse a push that does not hold origin/main #4670 needs a passing record when the remote branch exists and the gate is on. An unavailable record lets the push go the GitHub-only way.
  3. The patch-id carry rule: a clean rebase keeps the record. After 2 conflict rounds, GitHub decides.
  4. In the same pull request, change AGENTS.md rule 6, docs/SDLC.md Phase 5 and 6, CONTRIBUTING.md and the devops-pr-ci skill. The skill runs the gate as a background command.

Target Subsystem

SDLC, Git & PR Governance (src/devops_cli/commands/pr.py).

Existing Tool Considered

git patch-id, the gate of #4698 and the existing devops pr create cover the need. Cost (estimate): about 250,000 tokens and 4 hours to build, about 8,000 tokens a month to keep, about 30,000 tokens to fix.

Acceptance Criteria

  • Tests cover each path: a passing record pushes, no record runs the gate, an unavailable record pushes, and 2 conflict rounds push.
  • One week after the merge, topic pushes for each merged workstation pull request are at most 1.35.
  • The fallback rate is under 20 %.
  • No work is lost.

Dependencies

#4670, #4685, #4698.

Source: #4667

Alternatives check of 2026-11-26: partly.
Tool: git-town/git-town (https://github.com/git-town/git-town), MIT, last activity 2026-11-20, maintained.
Reason: Searches returned little usable, but the fact read found Git Town, which fetches, rebases onto main, pushes once and opens a draft pull request, yet reads no gate record, carries no patch-id and has no unavailable fallback.

Covers:

  • Fetches origin and rebases the branch onto main
  • Pushes the branch once, with lease on a pushed branch
  • Opens or updates the draft pull request
  • Stops on rebase conflicts and can abort cleanly

Lacks:

  • No gate record check or gate run before push
  • No patch-id carry rule across a clean rebase
  • No unavailable record fallback path
  • No two-round conflict stop policy with named files

Proposed design

Problem statement

Make devops pr create fetch origin, rebase the branch onto origin/<base>, check or run the gate of #4698, push one time through the hooks and open the draft. In the census week, 843 topic pushes started runs on open pull requests, 1.86 for each merged pull request, and 119 of 851 pull request CI runs failed. The owner decided on 2026-11-11 that every push to GitHub follows a passing gate, the first push too (OD6 a). Today devops pr create pushes nothing: it opens the draft from a branch already on origin and prints git push -u origin HEAD on the must-first-push error. The GitHub-decides fallback after two conflict rounds and the one-week metrics are deferred.

Acceptance criteria

Requirement: Rebase before the first push

devops pr create SHALL fetch origin and rebase the checkout branch onto origin/<base> before it pushes, where <base> is --base or the default branch.

Scenario: A branch behind origin/main

  • WHEN the checkout branch is behind origin/main and the rebase has no conflict
  • THEN the command rebases onto origin/main, pushes one time and opens the draft pull request

Requirement: Gate runs when no record exists

devops pr create SHALL run the gate of #4698 when the gate is enabled and the gate record holds no entry for the patch-id of the branch.

Scenario: No gate record

  • WHEN the gate is enabled and the gate record holds no entry for the patch-id of the branch
  • THEN the command runs the gate and pushes only after the gate writes a passing record

Requirement: A passing record pushes with no gate run

devops pr create SHALL push with no new gate run when the gate record of the patch is passing.

Scenario: Passing record

  • WHEN the gate record holds a passing entry for the patch-id of the branch
  • THEN the command starts no gate run, pushes one time and opens the draft pull request

Requirement: An unavailable record pushes the GitHub-only way

devops pr create SHALL push and open the draft when the gate record of the patch is unavailable.

Scenario: Unavailable record

  • WHEN the gate record holds an unavailable entry for the patch-id of the branch
  • THEN the command starts no gate run, pushes one time, opens the draft and prints that the checks of the pull request are the only gate

Requirement: A clean rebase keeps the record

devops pr create SHALL keep the gate record when the patch-id of the branch is the same before and after the rebase.

Scenario: Clean rebase onto a new origin/main

  • WHEN the rebase onto origin/main has no conflict and git patch-id --stable of the branch gives the same id as before
  • THEN the command pushes with no new gate run

Requirement: Two conflict rounds stop the push

devops pr create SHALL abort the rebase and push nothing after two rounds of rebase conflicts.

Scenario: Second conflict round

  • WHEN the rebase conflicts for the second time in one devops pr create run
  • THEN the command aborts the rebase, pushes nothing, and names the conflicting files and the fix

Requirement: No work is lost on a conflict stop

devops pr create SHALL leave the branch and the working tree unchanged when it aborts a conflicted rebase.

Scenario: A stopped rebase

  • WHEN the second conflict round stops the command
  • THEN the command runs git rebase --abort, and the branch points at its pre-rebase commit with no uncommitted conflict files

Requirement: The push runs the hooks

devops pr create MUST push through the pre-push hooks and MUST NOT pass --no-verify.

Scenario: A failing pre-push hook

  • WHEN the command pushes the branch and the branch-current hook refuses it
  • THEN the push command holds no --no-verify, and the command stops with the message of the hook and opens no pull request

Requirement: The first push sets the upstream, a rebase uses a lease

devops pr create SHALL push with -u when origin has no branch of that name and with --force-with-lease when it does.

Scenario: A branch that origin already holds

  • WHEN the branch of the checkout exists on origin and the rebase succeeds
  • THEN the command pushes it one time with --force-with-lease

Requirement: Another repository with --head pushes nothing

devops pr create SHALL push nothing when --head is given, because the head may be a branch of another checkout.

Scenario: A pull request in another repository

  • WHEN the command runs with --repo owner/repo --head branch
  • THEN the command rebases nothing, pushes nothing and opens the draft as before

Requirement: The dry run names the new steps and runs none

devops pr create --dry-run SHALL name the fetch, the rebase, the gate check and the push in its plan and SHALL run none of them.

Scenario: A dry run of the new flow

  • WHEN the command runs with --dry-run
  • THEN the plan names the fetch, the rebase, the gate check and the push, and the checkout and origin do not change

Requirement: Documents and skill copies agree

The change SHALL update AGENTS.md rule 6, docs/SDLC.md Phase 5 and Phase 6, CONTRIBUTING.md section 4 and each of the three devops-pr-ci skill copies.

Scenario: The three skill copies

  • WHEN the test compares the three devops-pr-ci skill files
  • THEN each file states the rebase, the gate check, the one push and the gate run as a background command, and the three files are identical

Requirement: The new rule is recorded without editing ADR 0014

The change MUST NOT change the body of ADR 0014 and SHALL record the new rule in a new ADR and a dated Status History line of ADR 0014.

Scenario: The body hash of ADR 0014

  • WHEN the test reads ADR 0014 after the change
  • THEN its body-hash is unchanged and its Status History holds the dated line that names the new ADR

Existing Tool Considered

No open, maintained tool covers the need: the alternatives check of 2026-11-20 in the issue body gives verdict none and names no tool. The change builds the flow inside the existing devops pr create and the gate of #4698. Written cost: about 250,000 tokens and 4 hours to build, about 8,000 tokens a month to keep, and about 30,000 tokens to fix.

Key questions

  • Does devops pr create push the branch today?: No. The command opens the draft from a branch that is already on origin. On the must-first-push error it prints git push -u origin HEAD. [sources: src/devops_cli/commands/pr.py, src/devops_cli/github/pr_plans.py, CONTRIBUTING.md]
  • Which checks run at the pre-push hook today?: The hook runs branch-current, which refuses a branch that does not hold origin/main. It then runs the fast static checks: lint, format, domain, actionlint and zizmor. It runs no full gate and keeps no gate record. ADR 0014 keeps the required checks as the merge gate. [sources: .pre-commit-config.yaml, CONTRIBUTING.md, docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md]
  • Did feat(git): refuse a push that does not hold origin/main #4670 deliver a push gate that reads a passing record?: No. feat(git): refuse a push that does not hold origin/main #4670 delivered only the branch-current pre-push hook. The owner rejected the first build, and the gate record and its states are feat(ci): devops ci --remote runs the gate in the cluster #4698's. [sources: openspec/changes/archive/2026-11-12-4670-push-gate/design.md, openspec/changes/archive/2026-11-12-4670-push-gate/proposal.md, .pre-commit-config.yaml]
  • Which dependencies are done, and which does the change still wait on?: feat(git): refuse a push that does not hold origin/main #4670 and feat(repos): the claim sets In Progress #4685 are done: their changes are archived on main. feat(ci): devops ci --remote runs the gate in the cluster #4698 is not in this checkout: no change folder and no gate record code name it. The change waits on feat(ci): devops ci --remote runs the gate in the cluster #4698. [sources: openspec/changes/archive/2026-11-12-4670-push-gate/proposal.md, openspec/changes/archive/2026-11-12-4685-the-claim-sets-in-progress/proposal.md]
  • Does the first push of a pull request follow the gate?: Yes. The owner decided on 2026-11-11 that every push follows a passing gate, the first push included (OD6 a). docs/SDLC.md puts the first push under the rebase rule. AGENTS.md rule 6 opens every pull request as a draft. (best practice) [sources: docs/SDLC.md, AGENTS.md]
    • Chosen: Gate every push, the first push included. The first push starts the CI runs that failed in 14 % of the census week.
    • Rejected: Gate only the pushes after the first. The first push starts the runs, so the gate would come after the cost.
  • How does the change keep one gate implementation?: devops pr create reads the gate record of feat(ci): devops ci --remote runs the gate in the cluster #4698 and runs the gate of feat(ci): devops ci --remote runs the gate in the cluster #4698 as one module. The change adds no second gate and no new hook. feat(git): refuse a push that does not hold origin/main #4670 delivered only branch-current, so the record gate is feat(ci): devops ci --remote runs the gate in the cluster #4698's. (best practice) [sources: docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md, AGENTS.md, src/devops_cli/commands/pr.py, openspec/changes/archive/2026-11-12-4670-push-gate/design.md]
    • Chosen: Read the record and run the existing gate. One implementation, and AGENTS.md rule 3 puts an open tool before new code.
    • Rejected: Run the gate in the pre-push hook. ADR 0014 limits the pre-push hook to the fast static checks.
    • Rejected: Add a separate devops pr gate command. A second entry point that an agent must remember.
  • How does the gate record survive a rebase?: Key the record by git patch-id --stable of the branch diff, git diff origin/<base>...HEAD. A clean rebase that leaves the same patch-id keeps the record. A rebase that changes the diff runs the gate again. Do not use the devops ci workspace fingerprint: it hashes the whole tree, so a new origin/main changes it. (best practice) [sources: openspec/changes/archive/2026-11-12-4674-devops-pr-update-acts-only-on/proposal.md, src/devops_cli/ci/cache.py]
    • Chosen: git patch-id --stable of the branch diff. The project already uses patch-id to identify a patch across a rebase, and it ignores line numbers.
    • Rejected: The existing compute_workspace_fingerprint. It is content-addressed over the whole tree, so a new origin/main changes it and the record never carries.
    • Rejected: The head commit SHA. A rebase writes new commits, so every record would miss.
    • Rejected: The branch name. A force-push with a new diff would read an old record.
  • Which push form does the command use?: git push -u origin HEAD when origin has no branch of that name. git push --force-with-lease origin HEAD when it does. The first push sets the upstream. A rebase of a pushed branch is not a fast-forward and needs a lease. (best practice) [sources: CONTRIBUTING.md, docs/SDLC.md]
    • Chosen: Choose by the remote branch. The first push sets the upstream, and a rebase of a pushed branch needs a lease.
    • Rejected: Always --force-with-lease. A lease on a branch that origin does not hold is not the first push, and the branch gets no upstream.
    • Rejected: Always -u. A rebase of a pushed branch is not a fast-forward, so -u does not push it.
    • Rejected: --force. It can overwrite another session's push; the docs ask for --force-with-lease.
  • How does pr create behave when --head names a branch?: It pushes nothing and rebases nothing. It opens the draft as today. The new path applies only to the branch of the checkout. --head may name a branch of another checkout, and --repo may name another repository. (best practice) [sources: src/devops_cli/commands/pr.py, CONTRIBUTING.md, openspec/changes/archive/2026-11-12-3767-pr-create-fits-a-repository-without/tasks.md]
    • Chosen: Push only the branch of the checkout, and only with no --head. The command has no worktree for another branch, and it must not break the existing --repo with --head flow.
    • Rejected: Push --head. --head may be a branch of another checkout or another repository, so this checkout cannot rebase or push it.
    • Rejected: Refuse --head. Existing callers use it to open a pull request in another repository.
  • What does the command do after two rounds of rebase conflicts?: It aborts the rebase and pushes nothing. It names the conflicting files and the fix. The original GitHub decides push is deferred: branch-current refuses a branch that does not hold origin/main, and AGENTS.md rule 5 forbids --no-verify. (best practice) [sources: .pre-commit-config.yaml, AGENTS.md, docs/SDLC.md]
    • Chosen: Stop and push nothing. It keeps the owner rule that every push follows a passing gate and keeps the branch-current hook.
    • Rejected: Push with --no-verify. AGENTS.md rule 5 forbids --no-verify.
    • Rejected: Push with a lease and let the hook refuse. The hook refuses the push, so no pull request opens.
    • Rejected: Add an exception to branch-current. It weakens the owner rule; it waits on an owner decision and is deferred.
  • How does the dry run show the new steps?: The dry run names the fetch, the rebase, the gate check and the push in its plan and runs none of them. The plan keeps the existing gh pr create request and adds the steps before it. (best practice) [sources: src/devops_cli/commands/pr.py, src/devops_cli/github/pr_plans.py, tests/commands/test_pr_dry_run.py]
    • Chosen: Plan the new steps and run none. The dry run stays safe and shows the new flow.
    • Rejected: Leave the dry run as the gh request only. The operator cannot see the rebase, the gate or the push that the command will run.
  • How does the skill run a gate that takes minutes?: The skill starts the full gate as a background command and waits for its result before devops pr create. The command then reads the record and pushes. The 120 s default limit of the agent shell does not hold the gate. (best practice) [sources: docs/SDLC.md, docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md, CONTRIBUTING.md]
    • Chosen: Run the gate as a background command. The full run takes 2.5 to 15 minutes, over the 120 s limit of the agent shell.
    • Rejected: Run the gate in the same shell step as the push. A gate over 120 s stops the shell step.
  • Can the pull request check the outcome targets of 1.35 topic pushes and a fallback rate under 20 %?: No. The targets need one week of pushes after the merge. A test runs inside the hermetic floor and reads no GitHub history. The targets move to a follow-up measurement issue. The pull request checks only the gate paths. (best practice) [sources: docs/TESTING.md]
    • Rejected: Keep the targets in this pull request. No test checks them offline, and the merge comes first.
    • Chosen: Defer the targets to a measurement issue. The data exists only after one week of pushes, and a scheduled job can read it.
  • Which documents change, and how is ADR 0014 kept true?: AGENTS.md rule 6, docs/SDLC.md Phase 5 and Phase 6, CONTRIBUTING.md section 4, the three copies of the devops-pr-ci skill, and a new ADR that amends ADR 0014. ADR 0014 gains amended-by and a dated Status History line. Its body and body-hash do not change. Use the next free ADR number; ADR 0026 is already GitHub settings as OpenTofu code. (best practice) [sources: AGENTS.md, docs/SDLC.md, CONTRIBUTING.md, .claude/skills/devops-pr-ci/SKILL.md, tests/invariants/test_skills.py, docs/adr/README.md, docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md, tests/invariants/test_adr_records.py]
    • Chosen: A new ADR amends 0014, and 0014 keeps its body. The README allows an amendment and a dated Status History line, and the body-hash test fails on an edit of the body.
    • Rejected: Edit ADR 0014's body. An accepted record's body does not change; the test fails when its body-hash differs.
    • Rejected: Add no ADR. ADR 0014 says no push depends on a cached verdict, and this change makes that false; AGENTS.md rule 8 fixes the document in the same pull request.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4698

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/pr
    status/new
    value/medium
    effort/medium
    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/feature. The feat prefix of the title gives the type.
    • Scope: scope/pr. The (pr) scope of the title gives the scope.
    • Priority: P2-Medium. It reduces CI waste and streamlines the PR flow but does not block a release or fix a defect.
    • Value: Medium. It cuts redundant CI runs and enforces a passing gate before the first push, saving compute and time.
    • Effort: Medium. The body estimates about 4 hours of build work plus documentation updates across four files.
    • Related: fix(pr): pr create fits a repository without openspec #3767, which asks for a different change. Both modify devops pr create, but 3767 removes OpenSpec requirements while the candidate adds a gate-and-push-once flow.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches for a push-gating tool found only generic git-hook runners (lefthook, pre-commit), which run commands before a push but provide none of what this issue needs: a gate record keyed by patch-id, an unavailable fallback, or a rebase-then-push-once-and-open-draft flow inside devops pr create. The work is an in-repo change to the project's own CLI and gate (#4670/#4698), and ADR 0014 already limits the pre-push hook to the fast static checks, so no external tool covers it.

    Tool: none found

    Lacks:

    • A gate record that a push reads, with passing and unavailable states (the gate of feat(ci): devops ci --remote runs the gate in the cluster #4698 and the push gate of feat(git): refuse a push that does not hold origin/main #4670)
    • The patch-id carry rule that keeps a record across a clean rebase and falls back to GitHub after 2 conflict rounds
    • devops pr create rebasing onto origin/main, running or checking the gate, pushing once and opening the draft
    • The one-push-per-PR metric and the fallback-rate target (1.35 topic pushes per merged PR, under 20 % fallback)
    • The documentation and skill changes (AGENTS.md rule 6, docs/SDLC.md, CONTRIBUTING.md, the devops-pr-ci skill)

    Tools considered:

    Searches run:

    • git pre-push hook manager run checks before push lefthook pre-commit, results: 5
    • skip CI checks when patch unchanged git patch-id cache tool, results: 5
    • lefthook fast git hooks manager pre-push, results: 5
    • pre-commit framework run checks before git push github, results: 5
    • husky git hooks, results: 5
    • run tests automatically before git push tool, results: 5
    • pre-commit.com framework, results: 5
    • git patch-id documentation, results: 5
    • pre-commit pypi package git hooks, results: 5

    Sources:

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

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

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 0820a64 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

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

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  8. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: none, no tool. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • graphite cli gt submit rebase restack push create draft pull request, results: 5
    • tool gate git push requires passing tests record pre-push open source, results: 5
    • git-town create pull request rebase onto main push once, results: 5
    • withgraphite graphite-cli github, results: 5
    • git-town github repository, results: 5
    • "git town" sync restack push pull request tool, results: 5
    • "graphite" CLI stacked diffs rebase submit pull request, results: 5
    • git town offline install git-town.com, results: 5
    • git-town sync command documentation rebase push, results: 5
    • git-town, results: 5

    Sources:

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/prsource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions