Repository navigation
Description
Problem or Motivation
The owner requirement of 2026-11-11 makes the push the check point. Each push to GitHub must hold the current origin/main and merge cleanly. Between pushes, an open pull request gets no catch-up update (docs/SDLC.md Phase 5).
No check enforces this today:
- The pre-push stage of
.pre-commit-config.yamlruns only lint, format and the workflow rows. No hook checks that a branch holdsorigin/main. - In the census week (2026-11-04 to 2026-11-11), 19 force pushes reached a pull request that had a conflict and started no run. 21 rebase-only pushes with no conflict started runs (about 832 runner-minutes). There were 9 local merges of
mainwith no own change. - The implement Job rebases in
_push(src/devops_cli/roadmap/implement/implement_run.py). Then it runs the scoped checks with up to 3 repair rounds, each command with a limit of up to 1,800 s, and then it pushes.maingets 2.5 merges an hour, so the pushed head often does not holdmain. After a rebase conflict,_current_tippushes a head that does not holdmain, and a stop pushes the passed commits (push_on_conflict=True). 5 implement stops in 14 days had the classconflict. - The stage job rebases before its push (
_commit_and_pushinsrc/devops_cli/roadmap/stage/stage.py), but it runsgit pushdirectly. 9git pushsites insrchave no shared check.
Proposed Solution & Architectural Design
One module, src/devops_cli/git/push_gate.py.
check_push(path, tip, branch, remote, default):
- Run
git fetch <remote> <default> <branch>with a 10 s limit and one retry, because a parallel fetch in another worktree can hold the ref lock. When the remote branch is missing, the push is a first push. - Refuse the push when
git merge-base --is-ancestor <remote>/<default> <tip>fails. Name the conflict files fromgit merge-tree --write-tree --name-only --no-messages. - When the remote branch exists and is not equal to the tip, refuse a catch-up-only push. A push is catch-up-only when both conditions are true: the patch-id of the own change of the tip (
git diff -U0 <merge-base>..<sha> | git patch-id --stable) is equal to that of the fetched remote tip, andgit merge-treeof the remote tip with<default>exits 0.
Use the fetched remote tip, not PRE_COMMIT_FROM_REF. For a new branch, or for a remote head that is not in the local objects, pre-commit sets from_ref to a parent commit (_pre_push_ns in pre-commit hook_impl.py). In a test, that let a catch-up push overwrite a merge that GitHub made.
The refusal message points to docs/SDLC.md Phase 5, and to devops pr update <n> for a failed required check whose fix is on main.
push_branch() fetches, rebases onto <remote>/<default> right before the push, runs check_push, then runs git push --force-with-lease=<branch>:<fetched tip> (with -u on a first push). A rebase conflict aborts the rebase, names the files and pushes nothing. delete_branch() pushes a delete with no check.
Two commands in the existing devops branches group.
check-pushreadsPRE_COMMIT_TO_REF,PRE_COMMIT_REMOTE_NAMEandPRE_COMMIT_REMOTE_BRANCHthrough Typer envvar options. WhenPRE_COMMIT_REMOTE_BRANCHis not set, the run is not a git push, so the command passes and prints a note. Tags and other refs pass.pushrunspush_branchfor the current branch.
One hook. branch-current runs first in the pre-push stage, with language: unsupported, always_run, pass_filenames: false, require_serial and fail_fast: true (a per-hook key of pre-commit 4.6.2). A refused push then costs about 2 s, and the other rows do not run.
The implement and stage jobs push through the gate. The Job runs pre-commit with --from-ref/--to-ref, which sets no PRE_COMMIT_REMOTE_*, so a hook alone does not cover the Job.
push_branchreplaces the pushes in_publish,_push_with_leaseand_withdrawof the implement Job, and in_commit_and_pushof the stage job.delete_branchreplaces the branch deletes inimplement_run.pyandstage.py.- Final push:
push_branchrebases right before the push. When the-U0patch-id of the own change is different after that rebase, the Job runs the scoped checks once more, at most once for each push, and does not loop onchecked_sha. Then it pushes the rebased head. - A rebase conflict at any push, a checkpoint too, stops the item at once. The stop names the conflict files and pushes nothing, so at most one task group stays only in the Pod.
- A catch-up-only result pushes nothing and sets
published_shaand the watched sha to the remote tip, so_watchreads a sha that GitHub has. _withdrawrebases the restored base first. A conflict there makes the item Blocked with the files. This is a new path, and the docs state it.request_plan.pylists the fetch of the gate in the dry-run plan.- An ast-grep rule refuses a
git pushinsrcoutsidepush_gate.py. Its patterns areself._git("push", ...),_git($P, "push", ...),git($P, "push", ...)andgit_result($P, "push", ...). Today it finds exactly the 9 sites and notrequest_plan.py.
Telemetry. A counter devops_cli_git_push_gate_total, with result = passed, behind, conflict, catch_up or fetch_failed, goes through the existing telemetry.
In the same pull request:
docs/SDLC.mdPhase 5 says "before each push" in place of "before the first push".CONTRIBUTING.mdlists the hook and says "push one branch at a time", because pre-commit checks only the first ref of a push.- Update the local-runs line of ADR 0014.
- Update
docs/ROADMAP_WORKFLOW.md(Checkpoints, Before the push). - The
devops-pr-ciskill (source and copies) says to push withdevops branches push.
This issue is the one push gate of the iteration lane and of the hooks review of 2026-11-11 (owner decision of 2026-11-11). The module and the hook can merge in a first task group, and the job push sites in a second.
Target Subsystem
SDLC, Git & PR Governance (src/devops_cli/git/, the devops branches group, the pre-push hook, the push sites of the implement and stage jobs).
Existing Tool Considered
git covers each check: merge-base --is-ancestor, merge-tree --write-tree and patch-id. The pre-commit pre-push stage and its documented PRE_COMMIT_* variables run the hook. ast-grep holds the push-site rule. No open hook checks "holds origin/main" or "catch-up only", so one thin module joins the git checks. The ruleset setting "require branches to be up to date" acts only at the merge, and the owner keeps it off. Cost (estimate): about 800,000 tokens and 2 days to build (the module and the hook, then the job push sites), near 0 to keep, about 30,000 tokens to fix.
Acceptance Criteria
Tests on a temporary bare origin:
- A new branch behind
mainis refused, with no conflict and with a conflict. The conflict case names the file. - A rebased branch passes.
- A rebase-only push of an existing pull request with no conflict is refused.
- A rebase plus an own change passes.
- A push that resolves a conflict passes.
- A catch-up-only
--forcepush over a GitHub merge that is not fetched locally is refused. - A delete and a tag pass.
check-pushpasses whenPRE_COMMIT_REMOTE_BRANCHis not set.
Tests with doubles at the git edge of the jobs:
mainmoves with no conflict during the scoped checks. The Job pushes a head that holds the newmainand does not stop.- The move changes the context of the own change. The scoped checks run once more, then the Job pushes.
- A conflict at a checkpoint stops the item at once, names the files and pushes nothing.
- A catch-up-only push sets
published_shato the remote tip, and_watchreads that sha. - A conflict in the
_withdrawrebase ends Blocked with the files. - The stage job pushes through
push_branch. - The rule test fails on a new
git pushoutsidepush_gate.py.
Other criteria:
devops branches pushon a branch 5 commits behindmainrebases and pushes. On a conflict it pushes nothing and names the files.- The hook takes at most 2 s warm at a load under 5 (1.6 s measured).
- The counter has only the 5 result values.
docs/SDLC.mdPhase 5 says "before each push".- One week after the merge: 0 pushed bot heads that do not hold
origin/mainat push time (check withgit merge-base --is-ancestoron the pushed heads), and 0 implement stops caused by a move ofmainwith no conflict.
Dependencies
None.
Source: #4667
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(git)scope of the title gives the scope.It prevents broken pushes and wasted runner time but the system functions without it.It stops 19 force pushes per week from reaching PRs with conflicts and saves about 832 runner-minutes.It adds a new module, two CLI commands, a pre-push hook, and rewires two jobs to use the gate.Both ensure a branch holds main before push, but 4380 fixes the rebase timing in the implement job while the candidate adds a refusal gate that blocks any push not holding origin/main.dan-petty commentedon Nov 11, 2026
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.
src/devops_cli/roadmap/implement/implement_run.py:790-793fetches and rebases onto the default branch at the start of each run, andsrc/devops_cli/roadmap/stage/stage.py:2358-2379rebases a staged branch.origin/mainand 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 withorigin/main.git merge-tree --write-treereports a conflict with no checkout.dan-petty commentedon Nov 12, 2026
Smaller scope after the owner feedback of 2026-11-12
The owner said of the first build of #4879: "pr 4879 seems like a really complicated alternative to the precommit hook check-merge-conflict". That build had a module of 551 lines, two
devopscommands, a patch-id check of catch-up pushes, an ast-grep rule, a counter and about 1,800 lines of JSON fixtures.#4879 now holds the smallest form that meets the rule "each push holds the latest
origin/mainand merges cleanly". A branch that holdsorigin/mainalways merges cleanly intomain, so nomerge-treeand no patch-id check is necessary.In scope:
branch-currentin.pre-commit-config.yaml: a few lines ofshthat fetchmainoforiginand refuse the push whengit merge-base --is-ancestor FETCH_HEAD <pushed commit>fails. The message namesgit fetch origin && git rebase origin/main. A fetch failure has its own message. A tag, a delete and a run of the stage that is nogit pushpass.check-merge-conflictstays: it finds conflict markers in files, not a branch behindmain.push_on_conflictand the conflict push of_current_tipare removed). The rebases before each push stay.docs/SDLC.md,CONTRIBUTING.md, ADR 0014,docs/ROADMAP_WORKFLOW.md, the skilldevops-pr-ci.Out of scope (dropped from the body above):
push_gate.py, the commandsdevops branches check-pushanddevops branches push, the catch-up-only refusal, the ast-grep rule over the push sites, the counterdevops_cli_git_push_gate_total, the changes to_publish,_withdrawand the stage job, and the second run of the scoped checks after a late rebase.devops pr update, their main source.The acceptance criteria in the body that name the dropped parts no longer apply. The criteria that stay: a branch behind
mainis refused, a rebased branch passes, a tag and a delete pass, a conflict in the implement Job pushes nothing, anddocs/SDLC.mdPhase 5 says "before each push".chore(main): release 0.117.0 (#4944)
devops-cli-service commentedon Nov 12, 2026
Released in v0.117.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.117.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 07:00 UTC