Skip to content

feat(roadmap): scaffold makes, resumes or adopts the item branch #5499

Description

@dan-petty

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

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.py creates the plan branch ref.
  • A test: --dry-run sends 0 requests.
  • docs/roadmap/stage.md and docs/ROADMAP_WORKFLOW.md state 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, resumed or adopted).

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>.candidates is 1 for all jobs. This item builds only this form.
  • When roadmap.<job>.candidates is above 1, candidate i works 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, writes scaffold.branch and writes the result created

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>.candidates is 1 and the change folder is add-the-widget
  • THEN the branch name is <type>/<issue>-add-the-widget, built by branch_form.branch_name, and branch_form.py, parse_branch and worktree_add.py are 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/main has the App author, and the record holds that branch
  • THEN the step writes the result resumed, keeps scaffold.branch and 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 adopted and records the branch name in scaffold.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/main whose author is not the App
  • THEN the step writes the result held with 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=scaffold and result=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/ and src/devops_cli/roadmap/steps/
  • THEN no module other than steps/scaffold.py calls the client method that posts to POST /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.pending mark 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.md and docs/ROADMAP_WORKFLOW.md
  • THEN each document names the four results created, resumed, adopted and held, and docs/ROADMAP_WORKFLOW.md lists the record key scaffold.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.py and the command devops 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 kind delivery comes 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; the roadmap step group 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.
  • 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 with branch_name (src/devops_cli/git/branch_form.py:54) and reads the slug of an existing branch with parse_branch (src/devops_cli/git/branch_form.py:59). Do not change branch_form.py, parse_branch or worktree_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>.candidates is 1 for all jobs, and branch_name already 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.
  • 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 past origin/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 add reports.
  • How does the step create a branch with no commit?: Post {"ref": "refs/heads/<branch>", "sha": <head of origin/main>} to POST /repos/{owner}/{repo}/git/refs through the GitHub session, with one new create_ref method on GitHubClient that wraps rest("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 holds contents write, 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/refs with a refs/heads/<branch> ref and the sha of origin/main creates the ref at that commit and adds no commit (GitHub docs, fetched 2026-11-14; the createRef reference gives the route and the ref and sha parameters), 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.
  • 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 are tests/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.pending delete of an App-only branch?: Remove the delete of an App-only branch of a Ready item from the orphan cleanup, with no shim. _orphans removes 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]
  • 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.

Dependencies

#4957, #5020, #5026

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/high
    effort/high
    on Nov 13, 2026
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p1-high
    on Nov 13, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    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.

    • Who gives the live proof of the scaffold result lines after the merge and the release? (a person decides)
  6. added
    status/in-progress
    and removed
    status/new
    on Nov 15, 2026
  7. added
    status/in-review
    and removed
    status/in-progress
    on Nov 15, 2026
  8. removed
    status/in-review
    on Nov 15, 2026
  9. added a commit that references this issue on Nov 15, 2026
  10. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-15 12:41 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/highpriority/p1-highscope/roadmapsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions