Repository navigation
Description
Problem or Motivation
Stage makes its branch, worktree and change folder on the Service volume. Since 2026-11-07, 53 of 71 Service restarts stopped a running stage round, and a killed round loses its checked plan. The stage.pending rule deletes an App-only branch after 1 hour, so a plan that passed its checks can be lost. The approved pipeline split design (tracker #5482, D1) makes scaffold a step module with its own command and result line. It runs first in the stage unit (kind plan) and later in the tests unit (kind delivery). It makes no placeholder commit.
Proposed Solution & Architectural Design
- Add
src/devops_cli/roadmap/steps/scaffold.pyanddevops roadmap step scaffold --item <n> --kind plan. An agent or a person can run it alone. - Apply the resume rule in this order:
- A branch on origin names the issue, and only the App wrote past
origin/main: resume on it. - The branch holds a commit of a person or an agent: the item is held. Skip it and write nothing (
issue_holder). - The branch is App-only, and the record does not name it: adopt it and record it.
- No branch: create the ref at the latest
origin/mainhead with the git refs API, with no commit.
- A branch on origin names the issue, and only the App wrote past
- The branch form stays
<type>/<issue>-<slug>(branch_form.py), and the slug is the change-folder slug. No-nsuffix (D2). Do not changebranch_form.py,parse_branchorworktree_add.py. - Write
scaffold.branch. A trial arm, when one runs, uses thetrialfield of feat(roadmap): trial a model tier on a share of a job's attempts #5177. - Stage pushes each checked plan revision as a checkpoint through the push step (fix(roadmap): the final push of the implement Job can miss the latest main #4957). A resumed round starts from the branch head and makes no new planner call for a pushed plan. Use the checkpoint and resume code of the implement Job again (
implement_run._checkpoint, feat(roadmap): checkpoint each passed group on origin #3677, feat(roadmap): a stopped step keeps its work and the next attempt resumes from it #3054). - The stage entry point of feat(roadmap): add the stage Job template and one-item entry point #5483 and the stage row call scaffold first, before the plan.
- Delete the
stage.pendingdelete of an App-only branch of a Ready item (no shim). Cleanup (refactor(roadmap): run the stage cleanup in the status lane #5026) keeps the delete for closed items and for empty App-only branches of items that are not Ready. - Write one result line
job=scaffoldwith the resultcreated,resumed,adoptedorheld. Exit codes: 0 done, 1 typed stop, 75 retry.--dry-runmakes zero requests. - If the estimate goes above 1 day, move the stage checkpoint and resume part to a separate sub-issue (delivery rule).
Target Subsystem
Roadmap Service and roadmap jobs (src/devops_cli/roadmap/steps/, src/devops_cli/roadmap/stage/).
Acceptance Criteria
- Test first: one test for each of the 4 resume cases, with the fake GitHub. The tests fail on the base.
- A test: a create makes a ref and no commit.
- A test: a stage round that is killed after a checkpoint push resumes with 0 planner calls.
- A structural test: no stage module other than
steps/scaffold.pycreates the plan branch ref. - A test:
--dry-runsends 0 requests. -
docs/roadmap/stage.mdanddocs/ROADMAP_WORKFLOW.mdstate the resume rule. - Live proof: after the merge and the release, the stage row runs scaffold as the App on the next Ready items and on one App-only branch of an open plan PR. A comment on this issue gives the result lines (
created,resumedoradopted).
Existing Tool Considered
The GitHub git refs API creates a ref with no commit. git, issue_holder, branch_form.py and the implement checkpoint code exist. No open tool applies this resume rule. Build: 200,000 to 350,000 agent tokens and 0.5 to 1 day.
Related
Tracker #5482, Phase 1. Depends on #4957 (push step), #5020 (open step) and #5026 (cleanup). #5483 (the stage Job entry point) calls it first. #5518 adds the kind delivery. #5501 tests the guide text. #5177 (trials).
Source: #5482
Owner decision 2026-11-13: candidate branches
The owner set the branch form for the candidates of a job (tracker #5482, D2; #5533):
- With 1 candidate, the branch is the plain form
<type>/<issue>-<slug>, with no suffix. This is the default:roadmap.<job>.candidatesis 1 for all jobs. This item builds only this form. - When
roadmap.<job>.candidatesis above 1, candidateiworks on<type>/<issue>-<slug>-<i>, and the judge writes the refined result on the plain branch. feat(roadmap): a job can run candidates and a judge #5533 adds this form to scaffold and keeps the resume rule of this item on the plain branch.
Proposed design
Problem statement
A Service restart stops a running stage round, and the round loses its checked plan. The branch, the worktree and the change folder live on the Service volume, and the stage.pending rule deletes an App-only branch after 1 hour. The scaffold step makes the item branch first. It resumes, adopts, holds or creates the branch, so a checked plan stays on origin and a new round starts from it.
Acceptance criteria
Requirement: Create the item branch with no commit
The scaffold step SHALL create the item branch ref at the head of origin/main and add no commit when no branch names the item.
Scenario: No branch names the item
- WHEN the item has no branch on origin and the record holds no branch
- THEN the step creates one ref at the head of
origin/main, writesscaffold.branchand writes the resultcreated
Requirement: The plain branch form with the change-folder slug
The scaffold step SHALL name the branch <type>/<issue>-<slug> with the slug of the change folder and no -<i> suffix.
Scenario: One candidate makes the branch
- WHEN
roadmap.<job>.candidatesis 1 and the change folder isadd-the-widget - THEN the branch name is
<type>/<issue>-add-the-widget, built bybranch_form.branch_name, andbranch_form.py,parse_branchandworktree_add.pyare unchanged
Requirement: Resume on an App-only branch that the record names
The scaffold step SHALL resume on a branch that names the item when only the App wrote to it past origin/main and the record names that branch.
Scenario: The record names an App-only branch
- WHEN a branch names the item, each commit past
origin/mainhas the App author, and the record holds that branch - THEN the step writes the result
resumed, keepsscaffold.branchand creates no ref
Requirement: Adopt an App-only branch that the record does not name
The scaffold step SHALL adopt an App-only branch that names the item when the record holds no branch, and write that branch to scaffold.branch.
Scenario: An App-only branch with no record entry
- WHEN an App-only branch names the item and the record holds no
scaffold.branch - THEN the step writes the result
adoptedand records the branch name inscaffold.branch
Requirement: Hold a branch that a person or an agent wrote
The scaffold step SHALL write the result held and change nothing when the branch holds a commit of a person or an agent past origin/main.
Scenario: The branch holds a commit of a person
- WHEN the branch holds a commit past
origin/mainwhose author is not the App - THEN the step writes the result
heldwith the holder, writes no record key and makes no git or GitHub write
Requirement: One result line with the four results
The scaffold step MUST write one JSON result line with job=scaffold and one result of created, resumed, adopted or held.
Scenario: A held branch ends the run
- WHEN the step ends with the result
held - THEN the line holds
job=scaffoldandresult=held, and the step exits 0
Requirement: A dry run sends no request
The scaffold step MUST send no request to GitHub or git when it runs with --dry-run.
Scenario: A dry run on an item with no branch
- WHEN the step runs with
--dry-run - THEN the fake GitHub client counts zero requests, the step writes no record key and the step creates no ref
Requirement: Only the scaffold module creates the plan branch ref
No module of the roadmap stage SHALL create the plan branch ref other than src/devops_cli/roadmap/steps/scaffold.py.
Scenario: The structural test reads the stage modules
- WHEN the test reads each module under
src/devops_cli/roadmap/stage/andsrc/devops_cli/roadmap/steps/ - THEN no module other than
steps/scaffold.pycalls the client method that posts toPOST /repos/{owner}/{repo}/git/refs
Requirement: The orphan cleanup keeps an App-only branch of a Ready item
The stage job MUST NOT delete an App-only branch of a Ready item when it judges a stage.pending mark.
Scenario: An orphan mark on a Ready item with an App-only branch
- WHEN a Ready item holds a
stage.pendingmark older than 1 hour and its branch holds only App commits - THEN the job makes no delete of the branch
Requirement: The documents state the resume rule
docs/roadmap/stage.md and docs/ROADMAP_WORKFLOW.md SHALL state the resume rule of the scaffold step.
Scenario: A test reads the two documents
- WHEN the test reads
docs/roadmap/stage.mdanddocs/ROADMAP_WORKFLOW.md - THEN each document names the four results
created,resumed,adoptedandheld, anddocs/ROADMAP_WORKFLOW.mdlists the record keyscaffold.branch
Existing Tool Considered
No alternatives check has run (alternatives is null). The open, maintained tool that covers the need is the GitHub git refs API: POST /repos/{owner}/{repo}/git/refs takes a fully qualified ref (refs/heads/<branch>) and the sha of the base head, and creates the branch with no commit (checked 2026-11-14); it refuses a ref on a repository with no branches, which this target is not. The repository already carries the request path: the GitHub session sends a write through rest("POST", path, body=...) (src/devops_cli/github/client.py:446), as ADR 0006 requires, and the App's installation token holds contents write (docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md:20). What the API lacks: it creates or moves one ref and applies no resume, adopt or hold rule; that rule is this item's code. The repository already holds the rest: issue_holder (src/devops_cli/git/worktree_add.py:550), branch_form.py and the checkpoint and resume code of the implement Job (implement_run._checkpoint, src/devops_cli/roadmap/implement/implement_run.py:1156). Build the rest: 200,000 to 350,000 agent tokens and 0.5 to 1 day.
Key questions
- Which module and command hold the scaffold step?: Add
src/devops_cli/roadmap/steps/scaffold.pyand the commanddevops roadmap step scaffold --item <n> --kind plan. The step writes one JSON result line. It exits 0 for a result, 1 for a typed stop and 75 for retry. It sends no request with--dry-run. The kinddeliverycomes with feat(roadmap): scaffold makes the delivery branch and its stubs #5518. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:233, docs/commands/roadmap.md:588, docs/CLI_REFERENCE.md:312, CONTEXT.md:165]- Chosen: A new roadmap step module with its own command. ADR 0021 section 8 makes each step one module and one command,
devops roadmap step <name>, with one JSON result line, the exits 0/1/75 and no request under--dry-run; theroadmap stepgroup already exists (docs/commands/roadmap.md:588), so a person or an agent can run it alone. - Rejected: A function inside
roadmap/stage/stage.py. A person or an agent could not run it alone, and the tests unit of feat(roadmap): scaffold makes the delivery branch and its stubs #5518 would copy it. - Rejected: A flag of
devops roadmap stage. It puts the scaffold work and the plan work in one command and one result line.
- Chosen: A new roadmap step module with its own command. ADR 0021 section 8 makes each step one module and one command,
- Which branch form does the scaffold step make, and where does the slug come from?: Make the plain form
<type>/<issue>-<slug>, with the slug of the change folder and no-<i>suffix, as the owner decided on 2026-11-13 (D2, feat(roadmap): a job can run candidates and a judge #5533). The stage job makes the branch before it writes the change, so it holds the slug at that point and gives it to the step. The step builds the name withbranch_name(src/devops_cli/git/branch_form.py:54) and reads the slug of an existing branch withparse_branch(src/devops_cli/git/branch_form.py:59). Do not changebranch_form.py,parse_branchorworktree_add.py. (best practice) [sources: src/devops_cli/git/branch_form.py:1, src/devops_cli/git/branch_form.py:54, src/devops_cli/git/branch_form.py:59]- Chosen: The plain form with the change-folder slug. The owner decision sets it as the default for one candidate,
roadmap.<job>.candidatesis 1 for all jobs, andbranch_namealready builds exactly<type>/<issue>-<slug>. - Rejected: The numbered form
-<i>now. feat(roadmap): a job can run candidates and a judge #5533 adds it to scaffold and keeps the resume rule of this item on the plain branch. - Rejected: A change to
branch_form.py. Other callers use the module, and the plain form already gives the branch name.
- Chosen: The plain form with the change-folder slug. The owner decision sets it as the default for one candidate,
- How does the step tell a branch that a person or an agent holds?: Call
issue_holder(src/devops_cli/git/worktree_add.py:550), which the stage job (src/devops_cli/roadmap/stage/stage.py:2674) and the implement job (src/devops_cli/roadmap/implement/implement.py:388) call today, to find a commit of a person or an agent pastorigin/main. (best practice) [sources: src/devops_cli/git/worktree_add.py:550, src/devops_cli/roadmap/stage/stage.py:2674, src/devops_cli/roadmap/implement/implement.py:388]- Chosen: Reuse
issue_holder. The function exists and the stage and implement jobs use it, so the step adds no second author rule. - Rejected: A new author check in the step. It copies a tested rule and can disagree with the holder that
devops repos worktrees addreports.
- Chosen: Reuse
- How does the step create a branch with no commit?: Post
{"ref": "refs/heads/<branch>", "sha": <head of origin/main>}toPOST /repos/{owner}/{repo}/git/refsthrough the GitHub session, with one newcreate_refmethod onGitHubClientthat wrapsrest("POST", path, body=payload)(src/devops_cli/github/client.py:446), as ADR 0006 requires. The endpoint creates the reference at that commit and adds no commit; it refuses a repository with no branches, which this target is not, and the App's installation token holdscontentswrite, the permission the endpoint needs. (best practice) [sources: https://docs.github.com/en/rest/git/refs, https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/master/docs/git/createRef.md, src/devops_cli/github/client.py:446, docs/adr/0006-github-session-requests-go-through-gidgethub.md:11, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md:20]- Chosen: The GitHub git refs API through the session. One
POST /repos/{owner}/{repo}/git/refswith arefs/heads/<branch>ref and theshaoforigin/maincreates the ref at that commit and adds no commit (GitHub docs, fetched 2026-11-14; the createRef reference gives the route and therefandshaparameters), and the session already sends writes that way. - Rejected: A placeholder commit. The issue forbids it, and it adds a commit that no plan wrote.
- Rejected:
git push origin <sha>:refs/heads/<branch>. It needs a clone and a local write, and the issue names the git refs API; the refs API gives the same ref in one request.
- Chosen: The GitHub git refs API through the session. One
- How does a resumed stage round start from the branch head with no planner call?: The stage job pushes each checked plan revision as a checkpoint through the push step (fix(roadmap): the final push of the implement Job can miss the latest main #4957). A resumed round starts from the branch head and makes no planner call for a plan that is on the branch. Reuse the checkpoint and resume code of the implement Job (
_checkpoint,src/devops_cli/roadmap/implement/implement_run.py:1156, feat(roadmap): checkpoint each passed group on origin #3677, feat(roadmap): a stopped step keeps its work and the next attempt resumes from it #3054), whose tests aretests/roadmap/implement/test_roadmap_implement_checkpoint.py. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:1156, tests/roadmap/implement/test_roadmap_implement_checkpoint.py, docs/roadmap/stage.md]- Chosen: Reuse the implement checkpoint and resume code. The code has tests and keeps each passed group across a kill, so the stage job adds no second resume rule.
- Rejected: The kept-plan file only. A Service restart loses the file on the volume, which is the defect this item fixes.
- Rejected: A new checkpoint path in the stage job. It duplicates tested code and gives two resume rules.
- What happens to the
stage.pendingdelete of an App-only branch?: Remove the delete of an App-only branch of a Ready item from the orphan cleanup, with no shim._orphansremoves a branch when every commit past the default branch is the clone identity's (src/devops_cli/roadmap/stage/stage.py:2551), which is the delete that loses a checked plan (docs/roadmap/stage.md:132). The cleanup (refactor(roadmap): run the stage cleanup in the status lane #5026) keeps the delete for closed items and for empty App-only branches of items that are not Ready. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py:2551, docs/roadmap/stage.md:132, docs/ROADMAP_WORKFLOW.md:139]- Chosen: Remove the delete for a Ready item. The delete removes the branch that scaffold must resume, and refactor(roadmap): run the stage cleanup in the status lane #5026 owns the delete for closed items.
- Rejected: Keep the delete. It loses a checked plan after 1 hour, which is the defect this item fixes.
- Rejected: Remove the whole orphan cleanup. refactor(roadmap): run the stage cleanup in the status lane #5026 keeps the delete for closed items and for empty branches of items that are not Ready.
- Who gives the live proof of the scaffold result lines after the merge and the release?: The owner runs the stage row after the release and comments the result lines on this issue, for the next Ready items and for one App-only branch of an open plan pull request. Recommend the first stage round after the release rolls. (a person decides)
Open questions
- Who gives the live proof of the scaffold result lines after the merge and the release? (a person decides)
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 13, 2026
53 of 71 Service restarts lost a running stage round and its checked plan, so this prevents data loss.Both are in the stage pipeline, but #2654 is the full stage command and the candidate is the scaffold sub-step that handles branch creation, resume, and adoption.feat(roadmap): run each stage item in its own Job (#5559)
devops-cli-service commentedon Nov 14, 2026
Refine cannot set this item to Ready at ffce5d9 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
test(roadmap): cover scaffold error paths and branch plan recovery (#…
chore(main): release 0.152.0 (#5822)
devops-cli-service commentedon Nov 15, 2026
Released in v0.152.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.152.0
devops-cli-service commentedon Nov 15, 2026
Live since 2026-11-15 12:41 UTC