Skip to content

fix(roadmap): the final push of the implement Job can miss the latest main #4957

Closed

Description

@dan-petty

Problem Description

The final push of the implement Job does not fetch and rebase right before the push. So the pushed head can miss commits that main got during the scoped checks. This breaks the owner rule of 2026-11-11: each push to GitHub holds the current origin/main and merges cleanly (docs/SDLC.md, "Current Branch at Every Push").

In ImplementRun._push (src/devops_cli/roadmap/implement/implement_run.py, at f55a20b9):

  1. self._sync() fetches main and rebases.
  2. self._scoped_checks() runs the pre-push stage, devops ci --check --only constructs,docs,openspec and devops ci test. A failed check starts a fix step of the model, up to roadmap.implement.repair_rounds times.
  3. self._publish() or self._push_with_lease() pushes self._head(). No fetch and no rebase run between step 2 and this push.

The Job installs no git hook (install_hook_environments runs pre-commit install-hooks only), so the pre-push hook branch-current of #4670 does not catch this push.

#4670 named this problem ("main gets 2.5 merges an hour, so the pushed head often does not hold main"). Its acceptance criteria said: "main moves with no conflict during the scoped checks. The Job pushes a head that holds the new main". #4670 is closed, and no open issue covers the final push. #4713 covers only the wip: and checkpoint pushes.

The design of #4670 (openspec/changes/archive/2026-11-12-4670-push-gate/design.md) rejected a second rebase in _push, because "the Job would push a head that its checks did not see". But docs/ROADMAP_WORKFLOW.md says that the required checks of the pull request are the gate, and that the scoped checks only filter what the Job pushes. The pull_request checks test the merge with main.

docs/SDLC.md now says that the Job "rebases before each push". For the final push, this statement is not correct.

Reproduction Steps

  1. Start an implement run of a Ready item.
  2. While devops ci test of the scoped checks runs, merge a pull request into main that does not conflict with the branch.
  3. Let the run finish and push.
  4. Run git merge-base --is-ancestor origin/main <pushed head>.

Expected vs Actual Behavior

Expected: the pushed head holds the main of the time of the push. A rebase conflict at that time stops the item with nothing pushed, as the other push sites do since #4670.

Actual: the pushed head holds the main of the start of _push. Step 4 exits 1.

The Time section of docs/ROADMAP_WORKFLOW.md gives about 35 s for the first two scoped checks and at most about 3.5 minutes for the tests, so about 4 minutes with no fix step. At 2.5 merges an hour, main moves in that window in about 15 % of the runs (1 - e^(-2.5 x 4 / 60)). Each fix step makes the window longer.

Environment Diagnostics

devops-cli at origin/main 1260bb51 (2026-11-12). Found by review of PR #4879.

Logs, Traces, or Terminal Output

_push: _sync() -> _scoped_checks() [minutes, fix steps] -> _publish() / _push_with_lease()   # no fetch or rebase here

Proposed fix

In _push, after the scoped checks and before _publish or _push_with_lease, take the tip with self._current_tip(in_step=False). It fetches, rebases, and on a conflict stops with push=False. Push that tip and set published_sha to it. A clean rebase that changed the head pushes a head that the scoped checks did not see; the required checks of the pull request stay the gate. An option: run the scoped checks again, at most once, only when the rebase changed the head.

Test first: main gains a commit with no conflict during the devops ci test call of the scoped checks (a program answer that calls advance_main of tests/support/roadmap_implement.py). Assert that the pushed head holds the new commit of main and that the item does not stop. A second test with move_main_when (a conflict) asserts that the Job pushes nothing.

Related: #4670, #4667, #4713, #4380.

Owner decision 2026-11-13

The approved pipeline split (tracker #5482) makes this item the push module of every producer unit. Stage pushes each checked plan revision as a checkpoint through it. Fix units push with --force-with-lease on the head that they read. It goes in Phase 1, before #5020 and #4559.

  • Live proof: after the merge and the release, the implement Job and the stage row push as the App. A comment gives two pushes where the head holds the latest origin/main.

Alternatives check of 2026-11-15: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    on Nov 12, 2026
  2. added
    value/medium
    effort/low
    on Nov 12, 2026
  3. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

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

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The pushed head can miss main in about 15 % of runs, but the pull request checks still gate the merge.
    • Value: Medium. The change keeps each pushed head current and stops the item on a conflict, which prevents stale branches.
    • Effort: Low. The fix adds one tip call in '_push' and two focused tests.
    • Related: fix(roadmap): rebase the branch before its first push #4380, which asks for a different change. Both add a rebase before a push of the implement Job, but #4380 covers the first push and the candidate covers the final push after the scoped checks.
  4. removed
    effort/low
    on Nov 12, 2026
  5. added
    priority/p2-medium
    effort/low
    on Nov 12, 2026
  6. dan-petty commented on Nov 12, 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. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It breaks the owner rule of 2026-11-11 in about 15% of runs but the PR checks still gate the merge.
    • Value: Medium. The pushed head misses main in a non-trivial share of runs, causing later merge friction.
    • Effort: Low. The fix is one rebase call in _push plus two test cases.
    • Related: feat(roadmap): the implement Job opens its PR at the end #4713, which asks for a different change. Both concern the final push of the implement Job, but #4713 changes when the PR opens while this candidate adds a rebase before that push.
  7. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Scope update from the Service step jobs plan (#5014).

    The owner asked on 2026-11-12 for a separate job for each step that the Service jobs run the same way every time. This issue is the push-step item of that plan. The plan is extract-first: each repeated step becomes one module and one command (devops roadmap step <name>) that every caller uses, and then the steps that cost most move to their own Jobs.

    Proposed title: fix(roadmap): one push step holds main at every push

    Problem (plan evidence)

    Five copies rebase or push a roadmap branch, each with its own abort code: stage.py:2411 and :2425; implement_run.py:789, :795, :1153, :1187, :1258, :1342, :1356, :1377, the push part of :1398 and :1909; and the inline shell of the pre-push hook branch-current (.pre-commit-config.yaml:102, #4879). The runner Job runs no git hook, so its pushes skip the predicate, and its final push can miss the latest main (#4957). Stage pushes with no lease and records nothing at a conflict.

    Added scope

    Widen #4957 to one push step for every caller, and add the step contract with it.

    1. Contract: package src/devops_cli/roadmap/steps/ with a pydantic request and result for each step. The result is the one JSON result line of feat(roadmap): log one result line for each roadmap job attempt #4845 (job_result.py of PR feat(roadmap): log one result line for each roadmap job attempt #4966: outcome, marks, failure_class, next, evidence); add no second format. Exit codes: 0 done or nothing to do, 1 typed stop, 75 try again later. --dry-run sends 0 requests and returns the would-be requests in the same result type. GitHub state (the remote head SHA) is the first idempotency marker; record keys hold only what GitHub cannot show. Metrics by OTLP: devops_cli_step_result_total{step,outcome} and devops_cli_step_duration_seconds{step}.
    2. steps/rebase.py: rebase_onto_default(path) returns Clean, Conflict (at most 20 paths) or NotStarted.
    3. steps/push.py: fetch; rebase only when the push carries new content; check git merge-base --is-ancestor origin/<default> HEAD and git merge-tree --write-tree; refuse a push that only catches up; skip when the remote head equals the local head; push with --force-with-lease on the tip that the caller saw; set push.pending before the push, and push.sha and push.base after it. Results: pushed, same_head, refused_behind, refused_catch_up, conflict, failed.
    4. CLI: devops roadmap step push (arguments only, --check, --dry-run, --json) in its own command module, added with one add_typer line.
    5. Callers in the same pull request: stage and every push site of the implement Job. The hook calls devops roadmap step push --check only when that takes 2 s or less warm (lane plan W2 limit). Else the hook keeps its two git commands, and a test holds that the hook and the step run the same predicate.

    Open tool: git (--force-with-lease, merge-base --is-ancestor, merge-tree --write-tree; git 2.47 is in both images). Edit stage.py only at :2396-:2452, away from the hunks of PR #4966 and PR #4983. Timeouts: fetch 30 s < rebase 120 s < merge-tree 30 s < push 60 s < step 300 s, inside the limit of the caller.

    Cost: about 1.5M tokens and 1.5 agent-days.

    Added acceptance

    • Tests in a temporary git repository: a head 5 commits behind main is refused; a rebased head is pushed; a catch-up-only push is refused; a conflict-resolution push is accepted; the same head makes no push; a moved tip makes the lease refuse.
    • uv run devops ci fail-to-pass --base origin/main shows that the fix(roadmap): the final push of the implement Job can miss the latest main #4957 test fails before the change and passes after it.
    • A dry-run test sees 0 requests.
    • A structural test fails when a module under src/devops_cli/roadmap other than steps/push.py runs git push.
    • The stage and implement tests stay green.

    Merge first

    Coordination

    #4076 (rebase the staged branch before implement) can call steps/rebase.py when it is built. #4969 (the branch-current hook refuses a push on a slow fetch) changes the hook; the parity test of this item then holds the hook and the step to the same predicate. Coordinate with #4845 (PR #4966) and do not take it over.

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

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches turned up only Git Town (a standalone developer CLI that syncs a branch with its parent) and git itself; neither is an embeddable push step. The need is an in-process change to ImplementRun._push that fetches and rebases onto origin/main after the scoped checks, stops with nothing pushed on a conflict, records the published SHA, and (per the scope update) returns one typed step result with --check, --dry-run and metrics — git only supplies the primitives (fetch, rebase, merge-base --is-ancestor, merge-tree, push --force-with-lease) that the issue already plans to call, so no open tool covers it.

    Tool: none found

    Lacks:

    • a push step that fetches and rebases onto origin/main after the scoped checks and before the publish, inside the implement Job
    • a conflict stop that pushes nothing and reports it through the Job's result (push=False / a typed result line)
    • the typed step contract: exit codes 0/1/75, --check, --dry-run and OTLP step metrics
    • the recorded markers (push.pending, push.sha, push.base, published_sha) and one shared step used by stage, the implement Job and the branch-current hook
    • tests in the project's temporary git repository for the moved-main and conflict cases

    Tools considered:

    Searches run:

    • keep git branch up to date with main rebase before push open source CLI, results: 5
    • tool that automatically rebases branch onto main before push, results: 5
    • git push --force-with-lease rebase before push script library, results: 5
    • git-town sync rebase feature branch onto main automatically, results: 5
    • "force-with-lease" "merge-base --is-ancestor" push gate CI tool, results: 5
    • git-town, results: 5
    • gitup git sync rebase onto upstream before push command line tool github, results: 5
    • git-town sync command rebase parent branch and push documentation, results: 5
    • python library rebase branch onto main and push with force-with-lease before CI push, results: 5

    Sources:

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

  9. added
    status/in-review
    and removed
    status/new
    on Nov 15, 2026
  10. removed
    status/in-review
    on Nov 15, 2026
  11. devops-cli-service commented on Nov 15, 2026

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

    @devops-cli-service
    Contributor

    Live since 2026-11-15 15:09 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/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions