Skip to content

fix(roadmap): a MODIFIED block that omits a scenario fails #4310

Closed

Description

@dan-petty

Problem

A reply whose MODIFIED requirement leaves out a scenario of the living spec fails the OpenSpec validation, and the model does not repair it in the one return that it gets.

The stage job checks a plan with openspec validate <change> --strict --json (validate_change in src/devops_cli/roadmap/stage/stage_validate.py). OpenSpec refuses a MODIFIED block that omits a scenario of the base requirement, because a MODIFIED requirement replaces the whole block. The model reads the requirement with read_spec and still writes a block with fewer scenarios.

Evidence: a live stage run on item #3599 with the live stage model (deepseek-v4.1-flash-1017), 2026-11-09. The second reply was refused, word for word: "roadmap-implement-job/spec.md: MODIFIED "The job rewrites the pull request after the push" omits scenario(s) the current spec still has: "A refused body stops the item". The modified block has 6 scenarios; the current spec has 5 scenarios. It adds 2 scenarios not in the current spec: "A refused body is rebuilt once", "A second refused body". Copy the omitted scenarios into the MODIFIED block (a MODIFIED requirement replaces the whole block, so archive refuses to drop them)." The item failed there. The stage job logs show the same problem for #3488 and #3478 on 2026-11-04.

Expected

  • The job repairs the mechanical part itself: for a MODIFIED requirement that omits scenarios of the base requirement, it adds each omitted scenario of the living spec to the block, with the text that openspec show <capability> --type spec --json gives, before it validates the change. Or the problem that goes back to the model holds the text of each omitted scenario.
  • A scenario that the reply drops on purpose is not possible: archive refuses it, so the repair loses nothing.

Acceptance criteria

  • A test builds a plan with a MODIFIED requirement that omits one base scenario, and shows that the change that the job writes holds all base scenarios. It fails today.
  • uv run devops roadmap eval stage --replay keeps its result.

Existing tool considered

openspec show <capability> --type spec --json (used by read_spec in src/devops_cli/roadmap/stage/stage_tools.py) already gives the name and the raw text of each scenario. No new parser is needed if the repair copies the raw text. Cost: about 40 000 tokens to build, 5 000 to keep, and 2 hours.

Proposed design

Problem statement

A MODIFIED requirement in a plan can leave out a scenario of the living spec. OpenSpec refuses that block, because a MODIFIED requirement replaces the whole block. The model gets one return to fix the block and often fails, so the item fails at the stage job (seen on #3599, #3488 and #3478). The omitted text is known, so the job can restore it with no model call.

Acceptance criteria

Requirement: Omitted scenario is restored

The stage job MUST add each scenario of the base requirement that a MODIFIED block omits to that block, with the raw text that openspec show <capability> --type spec --json gives, before it validates the change.

Scenario: One base scenario omitted

  • WHEN A plan holds a MODIFIED requirement that omits one scenario of the base requirement, and the base spec holds that scenario
  • THEN The change files that the job writes hold all base scenarios in the block, and validate_change returns None for them

Requirement: Scenarios of the reply stay

The repair SHALL keep every scenario that the reply holds in its own text and order, and SHALL append only the omitted scenarios after them.

Scenario: Reply adds and changes scenarios

  • WHEN A MODIFIED block has a changed scenario of the base and a new scenario, and omits a third base scenario
  • THEN The repaired block keeps the changed text and the new scenario, and ends with the omitted base scenario

Requirement: Complete block is unchanged

The repair MUST NOT change a file when each MODIFIED block holds every scenario of its base requirement.

Scenario: No scenario omitted

  • WHEN A plan holds MODIFIED blocks that name every base scenario
  • THEN The repaired files equal the input files byte for byte

Requirement: Other sections are left alone

The repair SHALL touch only requirements in the MODIFIED section of a delta, and SHALL NOT change an ADDED, REMOVED or RENAMED requirement.

Scenario: ADDED requirement with few scenarios

  • WHEN A delta holds an ADDED requirement and a base requirement of the same name has more scenarios
  • THEN The ADDED block is unchanged

Requirement: Missing base is left to OpenSpec

The repair SHALL NOT change a delta when the base spec or the base requirement does not exist, so OpenSpec reports that problem as before.

Scenario: MODIFIED of an unknown requirement

  • WHEN A MODIFIED block names a requirement that the base spec does not hold
  • THEN The files are unchanged and the validation problem still reaches the model

Requirement: Replay result is kept

The change MUST keep the result of uv run devops roadmap eval stage --replay.

Scenario: Replay after the change

  • WHEN The replay runs on the recorded cases
  • THEN The result equals the result before the change

Existing Tool Considered

OpenSpec already gives the raw text of each base scenario through openspec show <capability> --type spec --json, which read_spec in src/devops_cli/roadmap/stage/stage_tools.py uses. It has no command that repairs a MODIFIED block, and openspec validate only reports the problem. So the change builds a small repair that reads headings of the delta and copies the raw text from OpenSpec. Cost: about 40 000 tokens to build, 5 000 to keep, and 2 hours.

Key questions

  • Does the job repair the block itself, or does the problem that goes back to the model hold the omitted text?: The job repairs the block itself before it validates. A scenario cannot be dropped on purpose, because archive refuses it, so the repair loses nothing. It also saves the one return that the model gets. (best practice) [sources: src/devops_cli/roadmap/stage/stage_validate.py]
  • Where does the repair run?: A new function in stage_validate.py takes the tool, the checkout and the files of the change, and returns the repaired files. The planner uses the repaired files for both the validation and the files that it writes, so the two never differ. (best practice) [sources: src/devops_cli/roadmap/stage/stage_validate.py, src/devops_cli/roadmap/stage/stage_change.py]
    • Chosen: A function beside validate_change, which the planner calls first. The module already copies base specs and holds the OpenSpec tool, and the callers of validate_change stay unchanged.
    • Rejected: Repair inside validate_change. The function returns only a problem text, so it cannot hand back the repaired files that the job writes.
  • How does the repair match a base scenario to a scenario of the reply?: It matches by scenario name, after it strips the white space at each end. It reads the ### Requirement: and #### Scenario: headings of the MODIFIED section. It takes the raw text of each omitted scenario from openspec show and renders it in the form of _requirement_lines. (best practice) [sources: src/devops_cli/roadmap/stage/stage_tools.py]
    • Chosen: Match by name. OpenSpec compares scenarios by name, as its error message shows.
    • Rejected: Match by text. The reply may reword a scenario on purpose, and the repair would then add a duplicate.
  • Which base specs does the job have at the repair?: The job reads the base spec from the checkout, as _copy_base_specs does. A capability that the checkout does not hold is left alone. [sources: src/devops_cli/roadmap/stage/stage_validate.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Nov 10, 2026
  2. dan-petty commented on Nov 10, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P1-High. Recurring failure blocks items #3599, #3488, and #3478 from completing.
    • Value: High. Every affected item fails and wastes model calls; fixing it unblocks recurring work.
    • Effort: Medium. The body estimates 2 hours and about 40 000 tokens, a focused change to one repair step.
    • Related: fix(roadmap): the implement plan gate runs the OpenSpec validation too #3429, which asks for a different change. Both touch OpenSpec validation in the roadmap stage flow, but #3429 adds validation to a gate that lacks it, while the candidate repairs a specific validation failure before it occurs.
  3. added
    priority/p1-high
    on Nov 10, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 10, 2026
  5. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

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

  6. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 10, 2026
  7. added 2 commits that reference this issue on Nov 10, 2026
    118dc5a
    4d04cf0
  8. added
    status/in-review
    and removed
    status/in-progress
    on Nov 10, 2026
  9. added a commit that references this issue on Nov 10, 2026
    8bd434f
  10. removed
    status/in-review
    owner/agent
    on Nov 10, 2026
  11. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-10 06:39 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/mediumpriority/p1-highscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions