Skip to content

fix(roadmap): stage verifies round-trip readability before push #3966

Closed as not planned

Description

@dan-petty

Problem Description

The stage job commits and pushes change files without verifying that the plan reader can read them.

In src/devops_cli/roadmap/stage/stage.py, render_change generates the files of an OpenSpec change (proposal.md, design.md, tasks.md, spec deltas). The stage job runs validate_change to check the OpenSpec schema. It also checks secret redaction with redact_text. It does not call read_change(files) from src/devops_cli/roadmap/plan_read.py.

When tasks.md has a formatting or structural defect (such as an unparsable task line, missing command markers, or group validation failures), stage does not detect the defect. The stage job commits the files, pushes the branch to origin, and opens a draft pull request. The pull request then fails CI Plan Check.

Reproduction Steps

  1. Generate a proposal where tasks.md contains a syntax or structure that breaks read_change (for example, a Verification: line without a command marker or a group kind mismatch).
  2. Run devops roadmap stage on the item.
  3. Observe that stage completes, commits to git, and pushes the draft pull request.
  4. Run devops roadmap plan-check <pr> and see PlanReadError or validation error.

Expected vs Actual Behavior

Expected: stage calls read_change(files) before making a git commit. If PlanReadError or ValidationError occurs, stage refuses the proposal and asks the planner model again.
Actual: stage pushes the broken change files to origin, and the draft pull request fails CI.

Proposed Solution

In src/devops_cli/roadmap/stage/stage.py, call read_change(files) in _validate (or in _settle).
When read_change raises PlanReadError, return _Refused with the read error message.

Target Subsystem

Roadmap Automation & Planning

Proposed design

Problem statement

The stage job writes and pushes a change without checking that read_change can parse it. A broken tasks.md reaches origin and fails CI Plan Check. The fix adds a round-trip read before any git write and returns the read problem to the planner.

Acceptance criteria

Requirement: Round-trip read before git write

The stage job SHALL call read_change(files) with the rendered file mapping before it makes a branch, commit, push, or draft pull request.

Scenario: A tasks.md that read_change refuses

  • WHEN render_change writes a tasks.md that read_change refuses with PlanReadError.
  • THEN The stage job returns _Refused with the read error message and makes no git commit and no push.

Requirement: Validation error refuses the reply

The stage job SHALL return _Refused with the error message when read_change(files) raises a pydantic ValidationError.

Scenario: A spec delta that fails model validation

  • WHEN read_change(files) raises ValidationError for a rendered spec delta.
  • THEN The stage job returns _Refused and gives the error message to the planner.

Requirement: Read failure returns to the planner once

The stage job SHALL send a plan that fails read_change back to the planner once and SHALL stop the item on a second failed reply.

Scenario: Two replies fail the read

  • WHEN The first and second replies of one item both make read_change raise PlanReadError.
  • THEN The stage job raises RoadmapStageError for the item and makes no git write.

Requirement: Readable plan proceeds

The stage job SHALL continue to the OpenSpec validation and the StagedChange result when read_change(files) succeeds.

Scenario: A readable change folder

  • WHEN read_change(files) returns a StageProposal for the rendered files.
  • THEN The stage job returns a StagedChange that holds the same files.

Requirement: Read check without OpenSpec

The stage job SHALL run the read_change(files) check even when the OpenSpec binary is not on PATH.

Scenario: No OpenSpec binary

  • WHEN self._tool is None and read_change(files) raises PlanReadError.
  • THEN The stage job returns _Refused with the read error message.

Existing Tool Considered

No alternatives check has run. The OpenSpec CLI is the existing open tool for change validation, and it lacks a round-trip reader for tasks.md. The project already holds read_change in src/devops_cli/roadmap/plan_read.py; the change reuses it and builds no new parser. The build cost is zero tokens and zero elapsed time.

Key questions

  • Where does the stage job call read_change(files)?: Call it in _settle, after the secret redaction and before _validate, so it runs even when the OpenSpec binary is absent. _validate returns None when self._tool is None. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/plan_read.py]
    • Rejected: In _validate. It mixes the round-trip gate with the OpenSpec schema gate and risks a skip when the binary is absent.
    • Chosen: In _settle before _validate. It always runs, and it can return _Refused before any git write.
    • Rejected: In both. It duplicates the read and can report the same defect twice.
  • Does the check compare the parsed proposal with the original proposal?: No. Check only that read_change(files) does not raise. The writer drops the group kind, the estimated lines, and builds_own, so equality would fail for a valid plan. (best practice) [sources: src/devops_cli/roadmap/plan_read.py]
    • Rejected: Require equality. The reader documents facts that it cannot recover, so a valid plan would fail.
    • Chosen: Check readability only. It matches the defect: a plan that the reader cannot parse must not reach origin.
    • Rejected: Check equality for tasks.md only. The reader still loses the group kind and the estimated lines in tasks.md.
  • What does the stage job do when read_change(files) raises?: Return _Refused with the error message. The existing _gated path sends the plan back to the planner once and stops the item on a second refusal. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/plan_read.py]
    • Rejected: Stop the item at once. The planner gets no chance to repair a formatting defect.
    • Chosen: Return _Refused and use the existing one-return path. It reuses the refusal path and prevents the push.
    • Rejected: Log a warning and push. The broken change still fails CI Plan Check.
  • Which exceptions does the stage job catch?: Catch PlanReadError and pydantic ValidationError. read_change converts most pydantic errors to PlanReadError, but a validation error from a model can still escape. (best practice) [sources: src/devops_cli/roadmap/plan_read.py, src/devops_cli/roadmap/stage/stage.py]
    • Rejected: Catch only PlanReadError. A pydantic ValidationError from a spec model would stop the item as an internal failure.
    • Chosen: Catch PlanReadError and ValidationError. Both are plan-form failures, and both can return _Refused with the message.
    • Rejected: Catch every exception. It would hide defects in the job, such as a TypeError.

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 pushes broken change files and fails CI, but it does not block other work.
    • Value: Medium. The change stops broken draft pull requests and saves a CI cycle.
    • Effort: Low. The change adds one read_change call in _validate and returns _Refused on error.
    • Related: fix(roadmap): the stage job refuses a plan that names a path that does not exist #3010, which asks for a different change. Both items make stage refuse a bad plan before the push; this item adds a read_change check and #3010 adds a missing-path check.
  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: The searches surfaced the OpenSpec CLI, which the project already uses (ADR 0010) for change-schema validation, but it validates OpenSpec's own proposal/delta schema rather than the project's tasks.md grammar (command markers, group kinds) that read_change parses, so it cannot catch the defects the issue describes. No open library implements that reader grammar; the fix is the in-repo read_change call before the git write, not an external tool.

    Tool: none found

    Lacks:

    • No external tool parses the project's tasks.md grammar (task lines, command markers, group kinds) the way read_change does
    • No external tool raises the project's PlanReadError or maps a pydantic ValidationError from its spec models to a _Refused reply
    • No external tool gates the commit/push/draft-PR sequence on a round-trip read of the rendered file mapping
    • OpenSpec validation does not run when the OpenSpec binary is absent, and the issue requires the read check to run regardless

    Tools considered:

    Searches run:

    • OpenSpec CLI validate change proposal tasks.md structure, results: 5
    • python library parse markdown tasks checklist validate structure, results: 5
    • "openspec" spec-driven development tool GitHub, results: 5
    • OpenSpec Fission-AI openspec validate command change, results: 5
    • markdown-it-py parse task list items, results: 5
    • openspec, results: 5
    • mdformat CommonMark formatter round-trip parse render, results: 5
    • markdown-it-py GitHub repository Python Markdown parser, results: 5
    • OpenSpec openspec validate strict tasks.md parsing tool, results: 5
    • OpenSpec CLI commands validate show archive documentation, 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 14, 2026

    @dan-petty
    OwnerAuthor

    Replaced by #5416 (commit 4c3de9d): _settle now calls _file_findings -> _plan_check -> staged_problems -> folder_problems, and folder_problems calls read_change(files) and maps PlanReadError to a PLAN_CHECK_GATE finding before any branch, commit, push or draft PR. read_change converts a pydantic ValidationError to PlanReadError, so both refused forms go back to the planner through the existing one-return path. The check runs even when the OpenSpec binary is absent because it is separate from _validate. Tests: tests/roadmap/stage/test_roadmap_stage_plan_check.py. No code change is needed; close as not planned.

  8. added
    status/new
    and removed
    status/ready
    on Nov 14, 2026
  9. dan-petty commented on Nov 17, 2026

    @dan-petty
    OwnerAuthor

    The premise is obsolete. Newer commits already resolved this item.

    Commit a13a1c5 (PR #5851, closing #5214) added read_change(files) to _file_findings in src/devops_cli/roadmap/stage/stage.py. Commit 167451f (PR #5957, closing #5952) improved the read-back gate.

    The stage job now calls read_change(files) before it makes any git commit or push. A PlanReadError returns a refusal through the READ_GATE.

    Closing as not planned per AGENTS.md Rule 2.

  10. removed
    status/new
    on Nov 17, 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