Skip to content

fix(roadmap): stage gates task groups against empty packed files #3965

Closed as not planned

Description

@dan-petty

Problem Description

The stage job pushes change branches with task groups that pack no files.

In src/devops_cli/roadmap/stage/stage.py, the _settle method measures the task groups with measure_groups. The method checks if any group exceeds roadmap.stage.step_tokens. It does not check if a group packs zero files.

In contrast, devops roadmap plan-check enforces the group-no-files gate in src/devops_cli/roadmap/plan_check.py:392-394. A group that changes existing files without citing them in code spans packs zero files. The stage job creates a draft pull request that immediately fails CI Plan Check. Also, the implement job then starts the step without the files that the task changes.

Reproduction Steps

  1. Create a plan proposal where a task group changes an existing file without naming that file in a backticked code span in the task text.
  2. Run devops roadmap stage on the item.
  3. Observe that stage commits and pushes the branch and opens a draft pull request.
  4. Run devops roadmap plan-check <pr> or observe the CI Plan Check job.
  5. See group-no-files error on that group.

Expected vs Actual Behavior

Expected: stage refuses the proposal during gating when a group has zero packed files and changes existing files. The job asks the planner model again to cite the files.
Actual: stage accepts the proposal, pushes the branch, and opens a pull request that fails CI.

Proposed Solution

In src/devops_cli/roadmap/stage/stage.py, add a gate check in _settle (and _fit):
Refuse the proposal when any measured group satisfies item.files == 0 and not set(item.group.changes) <= set(item.group.creates). Return _Refused with texts.plan_check_group_no_files to prompt the model to cite the files in task code spans.

Environment Diagnostics

  • DevOps CLI Version: 0.79.0
  • Python Version: 3.14.10
  • Execution Environment: Roadmap Service / CI

Proposed design

Problem statement

The stage job measures task groups but does not enforce the group-no-files gate. A group can change an existing file without citing it in a code span. Stage then pushes a draft pull request that fails CI Plan Check. The implement job also starts without the files that the task changes. The fix refuses that proposal during stage gating and asks the planner to cite the files.

Acceptance criteria

Requirement: Refuse a group that packs no existing file

The stage job SHALL refuse a measured group when files == 0 and its changes are not a subset of its creates.

Scenario: Existing file not cited

  • WHEN a measured group has files == 0 and changes a path that it does not create.
  • THEN _settle returns _Refused with MESSAGES.roadmap.plan_check_group_no_files.

Requirement: Accept a group that only creates files

The stage job SHALL accept a measured group when files == 0 and every changed path is also a created path.

Scenario: Pure create group

  • WHEN a measured group has files == 0 and set(group.changes) <= set(group.creates).
  • THEN _settle does not return _Refused for the no-files rule.

Requirement: Refuse before a split

The stage job SHALL refuse a no-files group in _fit before it asks for a split.

Scenario: No-files group also over budget

  • WHEN a measured group has files == 0, changes an existing file, and exceeds the budget.
  • THEN _fit returns _Refused before it calls ask_split.

Requirement: Check the groups that a split returns

The stage job SHALL apply the no-files gate to the final measured groups after a split.

Scenario: Split group changes an existing file

  • WHEN _fit replaces the groups and a returned group has files == 0 and changes a path that it does not create.
  • THEN _settle returns _Refused with MESSAGES.roadmap.plan_check_group_no_files.

Requirement: Return the refusal to the planner once

The stage job SHALL send one no-files refusal back to the planner and stop on a second refusal.

Scenario: Second no-files reply

  • WHEN the planner returns a second proposal with a group that has files == 0 and changes a path that it does not create.
  • THEN _gated raises RoadmapStageError and writes no branch.

Requirement: Use the plan-check rule and message

The stage job SHALL use the same no-files predicate and message as devops roadmap plan-check.

Scenario: Plan-check and stage agree

  • WHEN plan-check and stage judge the same group with files == 0 and changes outside its creates.
  • THEN both report MESSAGES.roadmap.plan_check_group_no_files.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers this need: group-no-files is an internal invariant of this project, already enforced by src/devops_cli/roadmap/plan_check.py:392-394. The change reuses that rule and its message. It builds no new checker, so there is no build cost.

Key questions

  • Which existing gate does plan-check enforce for a group that packs no files?: Plan-check enforces group-no-files at src/devops_cli/roadmap/plan_check.py:392-394 and reports MESSAGES.roadmap.plan_check_group_no_files. [sources: src/devops_cli/roadmap/plan_check.py:392-394]
  • Where does the stage job measure the final task groups?: _Planner._settle calls _fit; _fit calls _build, which calls measure_groups, and it returns the final measured groups after any split. [sources: src/devops_cli/roadmap/stage/stage.py]
  • Which condition identifies a group that packs no files and changes an existing file?: The condition is measured.files == 0 and not set(measured.group.changes) <= set(measured.group.creates). [sources: src/devops_cli/roadmap/plan_check.py:392-394, src/devops_cli/roadmap/stage/stage_change.py]
  • Where should the stage job check the no-files condition?: Check in _fit after the first measure and before a split, and check the final measured groups in _settle after _fit. The first check avoids a split that cannot add a citation, and the second check covers the groups that a split returns. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/plan_check.py:392-394]
    • Chosen: Before a split in _fit and after _fit in _settle. The first check avoids a split that cannot fix the citation, and the second check covers split groups.
    • Rejected: Only after _fit in _settle. A group that is also over budget gets a split call before the refusal.
    • Rejected: Only before the split in _fit. A split can return a zero-file group that would escape the gate.
  • Should stage and plan-check share the no-files predicate?: Put the predicate in one helper in stage_change.py and call it from both stage and plan-check. Use MESSAGES.roadmap.plan_check_group_no_files for both. (best practice) [sources: src/devops_cli/roadmap/stage/stage_change.py, src/devops_cli/roadmap/plan_check.py:392-394]
    • Chosen: One shared helper in stage_change.py. One condition and one message cannot drift between the two gates.
    • Rejected: Duplicate the predicate in stage.py. Two copies can diverge when either gate changes.
    • Rejected: Keep plan-check unchanged and add a separate stage check. It creates a second copy of the same rule.
  • How does a stage refusal reach the planner?: _gated sends one _Refused reply back to the model with the problem, and a second refusal raises RoadmapStageError. [sources: src/devops_cli/roadmap/stage/stage.py]
  • Which tests cover the stage measure and the plan-check gate?: tests/roadmap/stage/test_roadmap_stage_measure.py covers measure_groups, and tests/roadmap/test_roadmap_plan_check.py covers the plan-check gate. [sources: tests/roadmap/stage/test_roadmap_stage_measure.py, tests/roadmap/test_roadmap_plan_check.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-09: none.
Tool: none found.

Activity

  1. added
    type/bug
    source/agent
    scope/roadmap
    on Nov 7, 2026
  2. added
    status/new
    value/medium
    effort/low
    on Nov 7, 2026
  3. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Priority: P2-Medium. The defect wastes CI runs and breaks the implement step, but it has a workaround and no data loss.
    • Value: Medium. The gate stops broken draft pull requests and empty implement steps for one plan defect.
    • Effort: Low. The change adds one check and one refusal text in two methods of one file.
    • Related: feat(roadmap): the stage job refuses a task path that no group lists #3446, which asks for a different change. Both add a stage gate on the files that a task group names, but item 3446 checks the group lists and the candidate checks zero packed files.
  4. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  5. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 682d206 (see proposed design in issue body).

  6. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches for an external plan-validation or lint tool that checks whether a plan's task groups cite the files they change returned only unrelated validation and file-API pages. The closest maintained candidate, OpenSpec, is the project's own spec/change-proposal layer and validates proposal structure only, so nothing outside this repository enforces the group-no-files rule that plan_check.py already implements and that stage must reuse.

    Tool: none found

    Lacks:

    • No searched tool enforces a group-no-files rule that a task group changing an existing file must cite it in a code span
    • OpenSpec validates change-proposal structure and does not read task prose for cited file paths
    • The gate must share the predicate and plan_check_group_no_files message with this repository's plan_check.py, which is internal code

    Tools considered:

    Searches run:

    • OpenSpec validate change proposal tasks file references check, results: 5
    • spec-driven development plan validation gate task group must cite files in code spans, results: 5
    • OpenSpec Fission-AI github spec change proposal validator, results: 5
    • lint tool checks that implementation plan tasks reference the files they modify, results: 5

    Sources:

    Checked on 2026-11-09. A person decides what this means for the item. The check changes no label and closes no issue.

  7. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Closed as superseded by #5416 (feat(roadmap): run the plan checks before the stage push, release v0.129.0, live on the roadmap Service since 2026-11-13 14:23Z).

    The stage job now runs all the rules of devops roadmap plan-check on the files that it writes, before the push (_file_findings and _plan_check in src/devops_cli/roadmap/stage/stage.py). The rule group-no-files is one of these rules. A plan that a rule refuses goes back to the planner model, as a refusal of any other gate does. So the stage job no longer pushes a plan that CI Plan Check refuses for group-no-files.

    If a plan PR from the stage job fails Plan Check with group-no-files after v0.129.0, file a new bug and link that PR.

  8. removed
    status/ready
    on Nov 13, 2026
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/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions