Skip to content

docs(openspec): plan #3387 Re-stage an item whose draft plan fails - #5581

Merged
dan-petty merged 2 commits into
mainfrom
feat/3387-stage-items-whose-draft-plan-fails
Nov 14, 2026
Merged

dan-petty merged 2 commits into
mainfrom
feat/3387-stage-items-whose-draft-plan-fails

Conversation

@devops-cli-service

Copy link
Copy Markdown
Contributor

Plans #3387

The stage job leaves out an item whose branch is on origin, even when the draft plan on that branch is bad. A person must then edit or abandon the draft by hand, so the job cannot replace its own plan. This change narrows the held rule. A pushed branch holds an item when its one draft plan passes the plan check, has an unresolved review thread, changes a path outside the change folder, or when a re-stage is already recorded. Otherwise the job plans the item again on that branch, pushes with a lease on the recorded commit, sets the title and body of the same draft, opens no second pull request, and names the replaced draft in the comment of the item.

Change: openspec/changes/3387-stage-items-whose-draft-plan-fails/

@devops-cli-service devops-cli-service Bot added type/docs Type docs: a change to the documents scope/openspec OpenSpec changes, specs and their checks labels Nov 14, 2026
@dan-petty
dan-petty marked this pull request as ready for review November 14, 2026 01:20
@dan-petty
dan-petty self-requested a review as a code owner November 14, 2026 01:20
@dan-petty

Copy link
Copy Markdown
Owner

An agent vetted this plan before a merge (shepherd, 2026-11-14). Verdict: needs fix. Each point below blocks a correct build.

  1. Stale files of the old plan stay in the folder. A re-stage takes over the pushed branch (_take_over in src/devops_cli/git/worktree_add.py keeps the tip), and the new commit goes on top of the old plan commit. write_change_files (src/devops_cli/roadmap/stage/stage_change.py:3060) only writes files and never deletes one. If the old plan had a spec delta or a file that the new plan does not have, that file stays in the change folder and goes into the new commit. No task removes the old folder before the write (for example git rm -r of openspec/changes/), and test 4.1 does not check for it.
  2. The held rule does not hold a branch that the take-over refuses. _check_authors (worktree_add.py:314) refuses a branch with a commit by any author other than the App, for example the hand fix edc0d0b that a person pushed on PR docs(openspec): plan #3321 refuse a self-named or untested plan #3335. That refusal comes in _stage_one, after the model has planned the item. The lease on stage.sha also fails when the fix-plan step (src/devops_cli/roadmap/steps/fix_plan.py) or a person moved the tip. stage.restage is written only after a success, so the bound never applies: the item fails, waits for its failure class, and plans again. The planner of this stage used 8,176,651 input tokens on each attempt. Before it selects the item, the selection must hold a branch with a non-App author, or a tip that is not stage.sha.
  3. The tree of the PlanFolder is not clear and can cause a mass re-stage. Task 2.2 builds 'a StagedTree of the branch's paths' from get_compare_files. StagedTree is the full set of tracked files that check_proposal reads to find named paths (stage_paths.py:117). If the tree holds only the changed paths, every plan fails the check, and each held draft gets one full re-stage. There are 8 open bot drafts now. The existing plan_check() (plan_check.py:514) already makes this read correctly: it fetches refs/pull/N/head, uses checkout_at and tree_files, and gets known and requirements from specs_at. The model review pointed to this path. The plan must reuse it, or say that the tree is the full head tree.
  4. draft_of has no default. Task 3.2 adds the required argument draft_of to select_stageable and _Judge. Seven test modules outside the plan call select_stageable without it: tests/roadmap/stage/test_roadmap_stage_job_entry.py, _queue.py, _retry.py, _retry_after.py, _title.py, tests/roadmap/test_roadmap_trust.py and tests/telemetry/test_roadmap_stage_steps.py. The model review raised this point and the revision did not fix it. This is the outside_plan defect of test(roadmap): check golden base commits in a devops ci row #4449 again. Say 'draft_of: ... | None = None', or name those modules.
  5. The new record key breaks an invariant test. Group 1 adds StageRecordKey.RESTAGE ('stage.restage'). tests/invariants/test_roadmap_workflow_doc.py::test_workflow_document_matches_the_labels_and_the_code requires each record key as a code span in docs/ROADMAP_WORKFLOW.md. No task adds the stage.restage row to the record table, and no verify step runs that test. So the test fails from group 1 onward and can stay red after group 5. Name the row in group 1 or group 5, and add the invariant test to its verify.
  6. The plan does not answer the owner's correction of 2026-11-11 on the issue: 'Rule 2 keeps a branch with commits beyond the plan held, so the change as written would still hold both items', which are vibes fix(sandbox): resolve cpu delta sampling, ssrf boundaries, and cgroup fallback #168 and docs(agent): require concise commit messages stating direct effect of change #169. The plan holds every branch that has a path outside the change folder, so Service wip: commits (src/devops_cli/roadmap/implement/implement_wip.py) still hold the item. The plan must widen the rule for branches whose only extra commits are App wip: commits, or say in the proposal that this case is out of scope and name a follow-up issue. The second half of the correction (a plan that the plan reader refuses) is covered, because folder_problems returns the read problem.

Points that do not block:

  • Premise holds on origin/main ffce5d9, which is the PR base. _held (stage.py:707), select_stageable (:807), StageTarget (:408), read_stage_selection (:2641), _commit_and_push (:3168), _rebase_onto_default (:3154), _stage_one (:3342), StageRecordKey (store.py:227), update_pull, get_compare_files, get_file_at and get_pull_status (client.py), list_pr_review_threads (pr_threads.py:362), folder_problems (plan_check.py:480) and read_change (plan_read.py:599) exist and do what the plan says. Two model review points are fixed: RESTAGE now comes in group 1, and the plan uses folder_problems.
  • The Why says the change also covers 'a plan whose files main changed', but folder_problems leaves out _moved_problems, the spec-moved check of plan_check. Either reduce the Why or reuse plan_check.
  • Each stage round and each 'devops roadmap explain' gets new GitHub reads: for each held draft, about 3 REST reads, 1 GraphQL read and 1 get_file_at for each change file. The plan names no request budget and no cache. read_stage_selection already holds the clone and the ls-remote heads, so a git fetch of the branch can replace the REST file reads. Also, plan_check notes that the checkout gives the exact text of each file, which the get_file_at path does not.
  • The plan does not say how the re-stage works with the fix-plan step (feat(roadmap): a fix-plan step repairs a plan PR with open findings #5061) or with the implement job, which takes a Staged branch while it is on origin (implement.py _route). The implement job checks only check_proposal, but folder_problems also counts size problems, so the two jobs can work on one branch at the same time. The docstring at src/devops_cli/roadmap/steps/fix_plan.py:5 says 'The stage job does not select a staged item again'. This change makes that text wrong, and the plan does not name the file (rule 8).
  • _label_needs_fix removes plan/needs-fix only when pull.labels holds it. update_pull returns None, so 'pass the updated draft to the label steps' must say that the labels come from get_pull_status.
  • _held also covers a local worktree holder. may_replace must clear only a pushed-branch hold, not a local worktree hold.
  • Tasks 5.1 and 5.2 make the same docs edit twice.
  • The spec deltas silently remove base text: 'matched by the issue number only' and '/-' from the selection requirement, and 'with their measures' from the comment requirement.
  • The real-system check is not real: 'devops roadmap explain 3307' and 'stage --item 3307 --dry-run' need a failing draft for feat(roadmap): name every caller of a changed function #3307, but feat(roadmap): name every caller of a changed function #3307 is closed and PR docs(openspec): plan #3307 name every caller of a changed function #3323 merged on 2026-11-03.
  • Group 3 verifies only test_roadmap_stage_selection.py. These modules also run the selection with stage.pr records and are not in a verify step: test_roadmap_stage_rejected.py, _command.py, _job.py, _job_entry.py and tests/roadmap/test_roadmap_explain*.py. Add tests/roadmap/stage and those explain tests to the verify of group 3.
  • The cost estimate of 'about 80 lines and 5 test cases' is low for 1 new module, 3 new test modules and edits to the 4061-line stage.py.
  • Prose is mostly ASD-STE100. Several design and task sentences are longer than 25 words, for example the lease decision and tasks 2.2 and 3.2.
  • No CI workflow change is needed. The change is Python, tests and docs, it adds no devops ci row, and it needs no full git history.

Checks: roadmap explain 3387: Stage job no, because origin/feat/3387-stage-items-whose-draft-plan-fails holds the item (expected for a staged item). Implement job: 'It passes every rule' and is now held back only by 1 item of higher priority. The Service can take #3387 on its draft branch before the plan merges. openspec validate 3387-stage-items-whose-draft-plan-fails --strict: valid. The Plan Check check run passed on the head d76563c.

@dan-petty dan-petty added the verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix label Nov 14, 2026
@dan-petty
dan-petty force-pushed the feat/3387-stage-items-whose-draft-plan-fails branch from 2f96ad3 to 99994ab Compare November 14, 2026 13:41
@dan-petty

Copy link
Copy Markdown
Owner

An agent vetted this plan before a merge (2026-11-14). Verdict: ready.

Problems identified in the prior review have been resolved:

  1. Task 4.2 now explicitly removes the old change directory before write_change_files runs, preventing stale files (such as obsolete spec deltas) from persisting into the re-stage commit.
  2. In may_replace, the branch is only replaceable if the remote branch tip matches stage.sha and all commits are App-authored, ensuring human commits and moved tips remain held.
  3. Task 2.2 specifies building PlanFolder with the full tracked repository file tree (reusing checkout_at and tree_files), preventing false path check errors and mass re-stage risks.
  4. draft_of in select_stageable and _Judge is given a default value of None, preserving compatibility with callers across outside test modules.
  5. In Group 1, docs/ROADMAP_WORKFLOW.md is updated with the stage.restage record key and verified against tests/invariants/test_roadmap_workflow_doc.py.
  6. Clarified in proposal and design that branches with extra commits beyond the change folder (including App wip: commits) remain held as out-of-scope for this change.
  7. De-duplicated documentation tasks in Group 5 and rebased cleanly onto origin/main.

Checks: plan-check passed, local pre-push checks passed.

@dan-petty
dan-petty merged commit 585d334 into main Nov 14, 2026
22 checks passed
@dan-petty
dan-petty deleted the feat/3387-stage-items-whose-draft-plan-fails branch November 14, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/openspec OpenSpec changes, specs and their checks type/docs Type docs: a change to the documents verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant