Repository navigation
Description
Problem or Motivation
A Ready item waits until an agent session starts it. The session then makes the worktree and the branch, writes the OpenSpec change (proposal, spec deltas, design and tasks.md) and opens the draft pull request, each time by hand, with the whole repository in its context. The task groups it writes are sized by habit, not by a budget, so a later implementation step may not fit a model's context window. The owner asked on 2026-10-29 that the Service stage issue branches for open issues from a label filter, by default the Ready P0 and P1 bugs, and that implementation be broken into discrete steps that work in a 128k context window.
Proposed Solution & Architectural Design
A new roadmap job, stage, takes each item that the filter names and makes it Staged: the branch <type>/<issue>-<slug> at the fetched origin/main, the change folder openspec/changes/<issue>-<slug>/ written from the refined body with its tasks.md in groups that each fit one context budget, one commit by the App, a push, and a draft pull request whose body says Plans #<issue> and no closing keyword. The job never marks a pull request ready and never changes the item's Status. The staged branch and the draft are the record, and the implement job (a separate item) or an agent completes them.
The work is three items, each one pull request:
devops roadmap stage: the selection by label filter, the structured plan call, the group sizing, the writes, and the reconcile of staged branches whose items closed.devops repos worktrees addtakes over a staged branch instead of refusing it.- The Service row on the model lane, its settings, and the pinned OpenSpec in the Service image so that
openspec validateruns before the push.
This issue is delivered by its sub-issues.
Target Subsystem
SDLC, Git & PR Governance.
Existing Tool Considered
- OpenSpec (
openspec validate, the change schema and theopenspec-proposeskill): the job is the headless form of what an agent runs by hand, and the change is OpenSpec's. devops repos worktrees add,git/branch_form.pyanddevops pr create: the job reuses them for the branch and the pull request.- tiktoken, a dependency, measures each group's inputs against the budget.
- GitHub Copilot coding agent ("assign to Copilot") is rejected. chore(github): Turn off AI Scan for pull requests to save allowance #1496 keeps the Copilot allowance for the month, it writes no OpenSpec change, and it cannot run the gateway's local models.
Related
- feat(repos): add devops repos worktrees add that refuses an issue another agent already holds #2337 delivered
worktrees addand its held-issue rule, which the stage job applies. - feat(roadmap): split unworkable or unanswered scope during refine into separate issues #2423 (refine splits unworkable scope): a staged item is one that refine set Ready, so a split happens before staging.
- ADR 0010 (OpenSpec is the change layer) and ADR 0015 (the App identity, with Contents and Pull requests write).
Proposed design
Problem statement
The stage job automates branch creation, OpenSpec change writing, and draft PR opening for each Ready P0 and P1 bug. Today, an agent session does this by hand with the whole repository in its context. Task groups are sized by habit, not by a token budget, so a later step may exceed the model context window. The owner asked for this automation on 2026-10-29.
Acceptance criteria
Requirement: Select by label filter
The stage job SHALL select only issues with status/ready, priority/p0 or priority/p1, and type bug.
Scenario: A Ready P0 bug is selected
- WHEN An issue has labels status/ready, priority/p0, and type bug
- THEN The stage job includes the issue in its work list
Requirement: Create branch at origin/main
The stage job SHALL create a branch named /- at the commit of origin/main.
Scenario: Branch is created at the correct base
- WHEN The stage job processes issue 1234 with slug fix-login and type bug
- THEN A branch bug/1234-fix-login exists at the commit of origin/main
Requirement: Write OpenSpec change folder
The stage job SHALL write the OpenSpec change folder openspec/changes/-/ with proposal, spec deltas, design, and tasks.md.
Scenario: All four artifacts are present
- WHEN The stage job processes a Ready item
- THEN The folder contains proposal.md, spec delta files, design.md, and tasks.md
Requirement: Size task groups by token budget
Each task group in tasks.md SHALL fit within the 128k token context budget as measured by tiktoken.
Scenario: A group exceeds the budget
- WHEN A set of tasks has combined inputs exceeding 128k tokens
- THEN The tasks are split into groups that each fit within 128k tokens
Requirement: Commit by App identity
The stage job SHALL make one commit using the GitHub App identity.
Scenario: Commit author is the App
- WHEN The stage job commits the change folder
- THEN The commit author is the GitHub App identity
Requirement: Push the branch
The stage job SHALL push the branch to the remote after the commit.
Scenario: Branch is pushed to remote
- WHEN The stage job completes the commit
- THEN The branch exists on the remote
Requirement: Open draft PR with correct body
The stage job SHALL open a draft pull request whose body contains Plans # and no closing keyword.
Scenario: PR body is correct
- WHEN The stage job opens the draft PR for issue 1234
- THEN The PR body contains Plans fix(github): pr monitor reports copilot as idle or completed when its timeline or reviews read fails (#806) #1234 and does not contain Closes, Fixes, or Resolves
Requirement: Do not change Status
The stage job SHALL NOT change the item's Status label.
Scenario: Status label is unchanged
- WHEN The stage job completes processing a Ready item
- THEN The item's status/ready label is still present
Requirement: Do not mark PR ready
The stage job SHALL NOT mark the draft pull request as ready.
Scenario: PR remains in draft state
- WHEN The stage job opens the draft PR
- THEN The PR is in draft state
Requirement: Reconcile closed staged items
The stage job SHALL delete the branch and close the draft PR of a staged item whose issue is closed.
Scenario: A staged item is closed
- WHEN An issue with a staged branch is closed
- THEN The stage job deletes the branch and closes the draft PR
Existing Tool Considered
OpenSpec (openspec validate, change schema), devops repos worktrees add, devops pr create, and tiktoken cover the individual steps. They lack the headless orchestration: label-based selection, plan generation from the refined body, group sizing by token budget, and the commit-push-PR sequence. The stage job builds this orchestration. It is approximately 600 lines of Python plus 300 lines of tests. The written cost is roughly 12k tokens to build and 4k tokens per maintenance cycle.
Key questions
- What labels does the stage job filter on?: status/ready, priority/p0 or priority/p1, and type bug. [sources: CONTEXT.md]
- How are task groups sized to fit the context budget?: Each group's inputs are measured with tiktoken against a 128k token budget. A group is the largest set of tasks whose combined inputs fit within 128k tokens. (best practice) [sources: CONTEXT.md]
- Chosen: tiktoken measurement against 128k budget. The body specifies tiktoken and a 128k context window. tiktoken is already a dependency. It is deterministic and fast.
- Rejected: Fixed number of tasks per group. Rejected because it does not account for the size of each task's inputs.
- Rejected: Model-based estimation of group size. Rejected because it is non-deterministic and adds a model call to every staging run.
- What is the branch naming convention?: /- at the commit of origin/main. [sources: CONTEXT.md]
- What is the draft PR body format?: Plans # with no closing keyword such as Closes, Fixes, or Resolves. (best practice) [sources: CONTEXT.md]
- Chosen: Plans #. Links the PR to the item without closing it. The item is not done when the PR merges; the implement job or an agent completes it.
- Rejected: Closes #. Rejected because it would close the item when the PR merges, but the item is not done at that point.
- What identity does the commit use?: The GitHub App identity per ADR 0015, with Contents and Pull requests write. [sources: docs/adr/0002-roadmap-jobs-act-as-a-machine-account.md]
- What validates the OpenSpec change before the push?: openspec validate runs before the push. The Service image pins OpenSpec so the command is available. [sources: CONTEXT.md]
- Does the stage job change the item's Status?: No. The job never changes Status. The staged branch and the draft PR are the record. [sources: CONTEXT.md]
- What happens to staged branches whose items are closed?: The stage job reconciles them: it deletes the branch and closes the draft PR. [sources: CONTEXT.md]
Fit
Needs splitting into 3 items:
- devops roadmap stage: selection by label filter, structured plan call, group sizing, writes, and reconcile of staged branches whose items closed
- devops repos worktrees add takes over a staged branch instead of refusing it
- Service row on the model lane, its settings, and the pinned OpenSpec in the Service image so that openspec validate runs before the push
Suspected block
None.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
A new 'devops roadmap stage' job adds a feature that automates branch, OpenSpec change, and draft PR creation.The owner explicitly requested this automation on 2026-10-29 for all Ready P0 and P1 bugs.It removes manual, context-heavy staging work for every Ready P0 and P1 bug in the pipeline.It spans three pull requests covering the stage job, a worktrees add change, and a Service row with pinned OpenSpec.Both items work in the roadmap pipeline; #2423 splits scope during refine, while this candidate stages already-Ready items into branches and draft PRs.devops-cli-service commentedon Oct 29, 2026
The proposal at ec2f7f7 needs splitting into 3 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.
dan-petty commentedon Oct 29, 2026
Done. All three sub-issues are merged: #2654 (the
devops roadmap stagecommand, PR 2686), #2657 (worktrees addtakes over a staged branch, PR 2675) and #2659 (the Service row, the filter settings and OpenSpec in the Service image, PR 2691).