Repository navigation
Description
Problem
devops roadmap plan-recheck --confirm can mechanically rewrite plans on the default branch. It updates missing verification commands and applies syntactic fixes.
However, open plan pull requests live on feature branches. When project conventions change (such as adding the $ prefix to verification lines or moving files), open plan branches become invalid. Currently, no automated mechanism applies mechanical plan rewrites or cleanly rebases open plan branches. Engineers must manually checkout the branch, rebase, edit files, and push.
Proposed change
Add automated rebase and mechanical plan rewrite support for open plan branches.
- Allow
plan-recheck(or a dedicated command) to target open plan pull request branches. - Check whether the branch can be cleanly rebased onto the default branch.
- Apply mechanical rewrites from
plan_rewriteto updatetasks.mdformat and verification commands. - When the rewritten plan passes validation, commit and push the updated branch with lease protection.
- If merge conflicts occur, leave the branch unchanged and record the conflict reason.
Acceptance criteria
- A command or service row can evaluate and rewrite open plan pull request branches.
- The command cleanly rebases branches without conflicts onto the default branch.
- The command applies
plan_rewritetransformations totasks.md. - The updated branch is pushed and CI checks are triggered.
- Unit tests verify clean rebasing, mechanical rewriting, and conflict avoidance.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
No open tool combines git branch rebasing with custom OpenSpec syntactic plan repairs. Building this feature requires approximately 30,000 tokens to build and 6,000 tokens annually to maintain. Elapsed time is approximately 4 hours.
Proposed design
Problem statement
Open plan pull request branches become stale when project conventions change. Engineers must manually rebase, edit and push each branch. The change adds a plan-recheck --branches path that rebases open plan branches, applies mechanical plan rewrites, validates the result, and pushes with lease protection. It leaves conflicting branches unchanged and reports the reason.
Acceptance criteria
Requirement: Branch target option
The devops roadmap plan-recheck command SHALL accept a --branches option that processes open plan pull request branches.
Scenario: Select open plan branches
- WHEN A user runs devops roadmap plan-recheck --branches --confirm.
- THEN The command lists open plan pull request branches and processes each returned branch.
Requirement: Clean rebase
The command SHALL rebase each open plan branch onto the current default branch before it applies plan_rewrite.
Scenario: Rebase a clean branch
- WHEN The open plan branch has no conflicting changes with the default branch.
- THEN The command completes git rebase origin/<default> in a temporary worktree and the worktree has the default branch as its base.
Requirement: Mechanical plan rewrite
The command SHALL apply plan_rewrite to the tasks.md of each rebased plan branch.
Scenario: Rewrite tasks.md
- WHEN The rebased branch contains an OpenSpec change folder.
- THEN The command runs rewrite_plan on the folder and stages only the lines that the rewrite changes.
Requirement: Validation before push
The command MUST validate the rewritten plan before it commits or pushes the branch.
Scenario: Reject an invalid rewrite
- WHEN The rewritten plan fails the existing plan validation.
- THEN The command leaves the branch unchanged and reports the validation failure.
Requirement: Lease-protected push
The command SHALL commit the rewritten plan and push the branch with --force-with-lease.
Scenario: Push with lease
- WHEN The rewritten plan passes validation and the remote head still matches the fetched head.
- THEN The command pushes the commit with --force-with-lease.
Requirement: Conflict avoidance
The command MUST leave the branch unchanged when a rebase conflict occurs.
Scenario: Rebase conflict
- WHEN The branch conflicts with the default branch.
- THEN The command aborts the rebase and reports the conflict reason.
Requirement: CI trigger
The command SHALL dispatch the repository CI workflow for the new head branch after a successful push.
Scenario: Dispatch CI after push
- WHEN The command pushes the updated branch successfully.
- THEN The command dispatches the CI workflow for the new head branch.
Requirement: Unit test coverage
The change MUST include unit tests for clean rebase, mechanical rewrite, and conflict avoidance.
Scenario: Run roadmap unit tests
- WHEN The roadmap unit test suite runs.
- THEN The tests cover a clean rebase, a plan_rewrite update, and a conflict that leaves the branch unchanged.
Existing Tool Considered
No alternatives check has run. The issue body states that no open tool combines git branch rebasing with custom OpenSpec syntactic plan repairs. The written cost is approximately 30,000 tokens to build, 6,000 tokens annually to maintain, and 4 hours elapsed.
Key questions
- Which module applies mechanical plan rewrites?: src/devops_cli/roadmap/plan_rewrite.py holds rewrite_plan. src/devops_cli/roadmap/plan_recheck.py calls it. [sources: src/devops_cli/roadmap/plan_rewrite.py, src/devops_cli/roadmap/plan_recheck.py]
- How should the feature be exposed?: Extend devops roadmap plan-recheck with a --branches option. (best practice) [sources: src/devops_cli/commands/roadmap.py, src/devops_cli/roadmap/plan_recheck.py]
- Chosen: Extend plan-recheck with --branches. It reuses the existing rewrite, validation and confirm logic.
- Rejected: Add a new plan-rebase command. It duplicates command wiring and validation.
- Rejected: Add a service row only. It adds scheduling and runner work that this item does not need.
- Which open pull request branches are in scope?: Open draft pull requests with a docs(openspec) title that contain an OpenSpec change folder. (best practice) [sources: CONTEXT.md]
- Rejected: All open pull requests. Most open pull requests do not hold a plan.
- Chosen: Open docs(openspec) draft pull requests with a change folder. It matches the staging definition of a plan pull request.
- Rejected: Branches with a plan/ name. The repository does not define that branch name.
- How should the command rebase and rewrite a branch?: Use a temporary worktree. Rebase onto origin/<default> first. Then apply plan_rewrite and validate the result. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/plan_recheck.py, src/devops_cli/roadmap/plan_rewrite.py]
- Chosen: Temporary worktree, rebase then rewrite then validate. It leaves the user checkout untouched and validates the final tree.
- Rejected: In-place checkout, rewrite then rebase. It risks local state and can reintroduce old formatting.
- Rejected: GitHub merge API only. It cannot run local rewrite or validation.
- How should the command push the updated branch?: Commit the rewrite and push with --force-with-lease after fetching the remote head. (best practice) [sources: src/devops_cli/roadmap/plan_recheck.py]
- Chosen: --force-with-lease. It protects a concurrent push and meets the lease requirement.
- Rejected: Force push. It overwrites a concurrent push.
- Rejected: Normal push. It rejects the rewritten history.
- What should the command do when a rebase conflict occurs?: Abort the rebase. Leave the branch and pull request unchanged. Report the conflict reason. (best practice) [sources: src/devops_cli/roadmap/plan_recheck.py]
- Chosen: Abort and leave unchanged. It avoids a partial state and satisfies conflict avoidance.
- Rejected: Push conflict markers. It breaks the plan and CI.
- Rejected: Close the pull request. It discards work that a person can resolve.
- How should the command trigger CI after a push?: Dispatch ci.yml on the new head branch through the existing devops pr update --dispatch-ci path. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md]
- Chosen: Dispatch CI explicitly. ADR 0004 uses --dispatch-ci for unattended branch updates.
- Rejected: Rely on the push event only. The repository's unattended path does not rely on it.
- Should a roadmap service row schedule the command?: No. This item adds the command only. A schedule is a separate item. (best practice) [sources: CONTEXT.md, src/devops_cli/commands/roadmap.py]
- Chosen: Command only. It meets the command-or-service-row criterion and keeps one pull request.
- Rejected: New service row. It adds scheduling, runner and budget work beyond this item.
- Rejected: Both command and service row. It increases the size and risk of the pull request.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-09: partly.
Tool: cli/cli (https://github.com/cli/cli), MIT, last activity 2026-11-07, maintained.
Activity
dan-petty commentedon Nov 7, 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.(roadmap)scope of the title gives the scope.It removes manual rebase work for engineers but does not block delivery or fix a defect.It saves repeated manual checkout, rebase, edit, and push cycles for each stale open plan branch.The body estimates about 4 hours and 30,000 tokens, covering rebase logic, rewrite application, lease push, and unit tests.Both address open plan PRs becoming stale after default-branch changes, but #3968 detects the drift while the candidate rebases and rewrites the branch to fix it.devops-cli-service commentedon Nov 8, 2026
Status set to Ready at 1f03ee3 (see proposed design in issue body).
devops-cli-service commentedon Nov 9, 2026
Alternatives check: partly
Reason: The searches turned up no open tool that combines rebasing open plan branches with this project's OpenSpec
plan_rewrite/validation, so the bespoke part of the item stays. The GitHub CLI (gh, withgh pr update-branchover the update-branch API) does cover the branch side: it selects open pull requests, updates their branch from the default branch, fails on a conflicting update, and pushes the new head so CI runs.Tool: cli/cli (https://github.com/cli/cli)
Covers:
gh pr list.gh pr update-branch, without checking the branch out locally.Lacks:
rewrite_planover thetasks.mdof an OpenSpec change folder.--force-with-leaseagainst the fetched remote head.Tools considered:
Searches run:
Sources:
Checked on 2026-11-09. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 11, 2026
Scope from the iteration lane plan (2026-11-11)
This issue is child 5 of #4667. The scope adds one rule.
main. A branch whose plan does not change gets no push.Acceptance:
Depends on: #4670.
dan-petty commentedon Nov 11, 2026
Scope from the hooks review plan (2026-11-11)
This issue is also child 3 of #4771 (hooks item P03). The scope comment of the iteration lane above holds the same change: the command pushes only when the plan rewrite changes the plan, and it pushes through
push_branchof #4670.The hooks plan adds one acceptance criterion:
tasks.md.Depends on: #4670.
16 remaining items
feat(roadmap): Rebase, validate and push a rewritten plan branch (#3969)
wip: 1 of 2 tasks of group 3, Add the branches option to plan-recheck (…
feat(roadmap): Select the open plan branches and compute the mechanic…
feat(roadmap): Rebase, validate and push a rewritten plan branch (#3969)
feat(roadmap): Add the branches option to plan-recheck (#3969)
feat(roadmap): Document the branches pass (#3969)
docs(openspec): archive the change (#3969)
devops-cli-service commentedon Nov 18, 2026
Pull request #6310 is ready for review. The checks passed.
Spend: 431 model requests, 52740004 input tokens, 178531 output tokens.
devops-cli-service commentedon Nov 18, 2026
Released in v0.178.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.178.0
devops-cli-service commentedon Nov 18, 2026
Live since 2026-11-18 17:44 UTC