Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/ROADMAP_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ uv run devops roadmap eval stage --replay

- **The live run** plans each case with the real stage planner and a checkout of the commit the plan was staged on. The planner has the read-only toolbox of the job (#3037): it reads the files of that commit, searches them, reads the git log and the base specs, and then gives its plan. It prints one row for each type of defect, and a score. It stores the report as JSON under the data directory, in `roadmap_eval/stage/`. `--no-toolbox` plans with one call and no tool, as the job did before the toolbox. Both modes print the same table and store a report of the same shape.
- **How to read the score.** The planner sends a refused reply back, so the plan it ends with always passes the gates. The score therefore judges the first reply of the model. For a type of defect that a gate catches, `Cases` counts the plans that had it, `Avoided` counts the first replies that passed the gate, `Caught` counts the first replies that the gate refused, and `Rate` is `Avoided` over `Cases`. A type that no gate judges yet shows its count and a dash, because only a reviewer can judge it. `Score` is the share of avoided defects over all scored rows. A first reply that breaks the schema is sent back inside the client, so the run cannot see it. The `kind` row therefore shows its count and a dash too, and the replay measures that gate. A case whose model breaks the schema twice ends `failed`, and it counts as neither avoided nor caught.
- **The replay** calls no model and reads no git. It runs the recorded plans through the gates and lists, for each gate, the known defects it catches. The `paths` gate is `check_proposal`, the check that the job runs on a reply: the path rule and the rules of the spec delta, with the capabilities of the case. All recorded plans passed the spec rules when they were staged, so these rules fail the replay only when they refuse a good plan. It exits 1 when a gate stops refusing a known-bad plan, or refuses a good plan. The test suite runs it on the whole set. A defect for a gate that does not exist yet is marked `pending`: the replay lists it and fails nothing. When the gate lands, its pull request sets the gate in the case files, and the replay checks it from then on.
- **The replay** calls no model and reads no git. It runs the recorded plans through the gates and lists, for each gate, the known defects it catches. The `paths` gate is `check_proposal`, the check that the job runs on a reply: the path rule and the rules of the spec delta, with the capabilities of the case. All recorded plans passed the spec rules when they were staged, so these rules fail the replay only when they refuse a good plan. The `criteria` gate (#3019) checks that the `criteria` list of the reply maps each acceptance criterion of the issue to a group or to `pending-person`. An acceptance criterion is a top-level item of the list under the heading `Acceptance criteria` in the text that a person wrote, before the refine block; an issue with no such list has none. The check reads the whole issue body, and a refused reply names the exact text to copy. A recorded plan has no `criteria` list, so the replay does not judge it, and its dropped-criterion defects have the gate `none`; the run of the model judges the gate on the first reply. It exits 1 when a gate stops refusing a known-bad plan, or refuses a good plan. The test suite runs it on the whole set. A defect for a gate that does not exist yet is marked `pending`: the replay lists it and fails nothing. When the gate lands, its pull request sets the gate in the case files, and the replay checks it from then on.
- **The rule.** A pull request that changes the stage prompt (`roadmap_stage_change.md`) or a check of the stage job (`check_proposal` and the gates it calls) states the score of the same model before and after the change. Use one model for both runs, and say which. To measure the toolbox, run the same model with and without `--no-toolbox` on the whole set, and state both scores.

### Measure the verification pass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-02
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Design

## Decisions

- **The criteria come from one list: the top-level items under a heading `Acceptance criteria` in the part of the issue body before the refine block.**: A person writes this list. The refine block holds the same criteria again in other forms (`- Criterion N: ... Verification: ...`, `### Requirement:`), and asking for each form would ask for one criterion two or three times. A body with no such heading has no criterion, and the check finds no problem.
- **The parser is `markdown-it-py`, not a regular expression.**: CONTRIBUTING.md asks for a standard parser. A nested item is no criterion.
- **A criterion is the source text of its item, with the task-list mark removed and the white space collapsed to single spaces. An entry matches when its text, collapsed the same way, is equal.**: Code spans and links stay as written, so the model copies them from the issue. The collapse removes line breaks of a wrapped item.
- **`criterion_problems(criteria, issue_body, group_count)` is a pure function that `check_proposal` appends to its problems, with `issue_body` as a keyword with an empty default.**: It follows `path_problems` (#3010). The default keeps every other caller working, and an empty body has no criterion.
- **The job passes the whole `item.body`.**: The body sent to the model is cut to a token limit, and the check must not depend on the cut.
- **A problem quotes the exact text to copy.**: A reply goes back once. The retry then copies the text instead of guessing it.
- **Each entry holds `criterion`, `group` and `reason`. `group` is a number from 1 or `pending-person`. `reason` is required and not blank for `pending-person`, and optional for a number.**: The schema refuses the entry with no reason, as the client sends a reply that breaks the schema back before the checks. A number above the count of groups is a problem of the check.
- **`criteria` defaults to an empty list.**: An issue with no list needs no entry.
- **A split gives the `criteria` again, and the job checks them after the split.**: A split replaces groups and moves the numbers of the later ones, so the numbers of the first reply are stale.
- **`tasks.md` gets a `## Criteria` section before `## Workflow follow-up`, as plain bullets with no box.**: It is no group (`parse_task_groups` ignores a heading that is not `<n>. <title>`) and no task, so archive has nothing to tick. A plan with no criterion has no section.
- **The replay gate `criteria` judges a plan only when its `criteria` key is present. The dropped-criterion defects of the recorded cases get the gate `none`.**: A recorded plan was never asked for the mapping. Adding a hand-written `criteria` list to a recorded plan would test the list and not the plan. The run of the model (`devops roadmap eval stage`) passes the issue body, so the gate judges every first reply of the model there.

## Rejected alternatives

- **Fuzzy or semantic matching of criterion text.**: The text comes from the same issue body, so a similarity library or a model call adds cost and a source of drift that an exact match avoids.
- **Match by index, first criterion to first entry.**: The model may reorder or skip entries, and an index cannot tell a skip from a reorder.
- **Annotate each group's task list with its criteria instead of a separate section.**: It clutters the task list and hides which tasks belong to which criterion.
- **Read the refine block as the source of the criteria.**: It has two forms and a `Verification:` line in each entry, so no exact text is stable. The human list is the one list that the issue template asks for.
- **Add `criteria` to the recorded `plan.json` files so that the gate catches the dropped-criterion defects.**: The lists would be written by hand to fit the defects, and the replay would then test the hand-written list.
- **Make `issue_body` a required argument of `check_proposal`.**: It breaks every caller in `tests/roadmap/test_roadmap_stage_plan.py` for no gain.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Proposal

## Why

The stage job plans an item without mapping its acceptance criteria to task groups, so about 10 of 37 plans of 2026-11-01 drop at least one criterion (#3019). No rule asks the model for the mapping and no check refuses a reply that leaves a criterion out.

## What Changes

- Add `StageCriterion` and `criterion_problems` in the new module `src/devops_cli/roadmap/stage_criteria.py`, and a `criteria` list (default empty) on `StageProposal` and `StageSplit` in `src/devops_cli/roadmap/stage_change.py`.
- An acceptance criterion is a top-level item of a list under a heading `Acceptance criteria` in the text of the issue body that a person wrote. The parser (`markdown-it-py`, already a dependency) cuts off the refine block first, because that block has its own heading in another form. A body with no such heading has no criterion.
- `check_proposal` takes the issue body as the keyword `issue_body` (default empty) and refuses a reply with an unmapped criterion. The job passes the whole `item.body`, not the part cut for the model. A problem quotes the exact text to copy, so the one retry can copy it.
- Render a `## Criteria` section in `tasks.md`, before `## Workflow follow-up`, with one line for each criterion and its group or `pending-person` and reason.
- A split moves the numbers of the groups, so the split request holds the `criteria` and the split reply gives them again; the job checks them after a split.
- State the rule in the prompts `roadmap_stage_change.md` and `roadmap_stage_split.md`.
- Add the `criteria` gate to the golden-set replay: `GateName.CRITERIA`, one entry in `GATES`, no entry in `PENDING_GATES`. The recorded plans have no `criteria` list, so the gate judges only a plan that has one. The 11 case files with a dropped-criterion defect change their gate from `pending` to `none`.
- Document the rule in `docs/ROADMAP_WORKFLOW.md`.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-stage`: Criteria mapping in the stage reply, Criteria section in tasks.md, criteria gate in the replay

## Impact

- Code: `src/devops_cli/roadmap/stage_criteria.py` (new), `src/devops_cli/roadmap/stage_change.py`, `src/devops_cli/roadmap/stage.py`, `src/devops_cli/roadmap/stage_eval_gates.py`, `src/devops_cli/roadmap/stage_eval_cases.py`, `src/devops_cli/roadmap/stage_eval_run.py`, `src/devops_cli/lang/en/messages.py`
- Prompts and documents: `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `src/devops_cli/ai/tasks/roadmap_stage_split.md`, `docs/ROADMAP_WORKFLOW.md`
- Tests and data: `tests/roadmap/test_roadmap_stage_criteria.py` (new), `tests/roadmap/test_roadmap_stage_plan.py`, `tests/roadmap/test_roadmap_stage_eval_gates.py`, `tests/roadmap/test_roadmap_stage_eval_run.py`, `tests/roadmap/test_roadmap_stage_eval_command.py`, and 11 `tests/fixtures/roadmap_eval/stage/*/case.json` files
- Callers of `check_proposal`: `src/devops_cli/roadmap/stage.py` and `src/devops_cli/roadmap/stage_eval_gates.py` pass `issue_body`; the new keyword has a default, so the other callers in `tests/roadmap/test_roadmap_stage_plan.py` keep working.

## Feasibility

- `git grep -n "def check_proposal" src/` finds `src/devops_cli/roadmap/stage_change.py`, and `git grep -n "check_proposal(" src/` finds its two callers, `src/devops_cli/roadmap/stage.py` and `src/devops_cli/roadmap/stage_eval_gates.py`. The gate checks specs and paths only, and `StageProposal` has no `criteria` field, so the premise of the issue holds.
- `git grep -n "def path_problems" src/` finds `src/devops_cli/roadmap/stage_paths.py`, the pattern of a pure function of the reply that `check_proposal` appends.
- The fixtures show three forms of list in an issue body. Counting `### Acceptance criteria` headings before the refine marker in `tests/fixtures/roadmap_eval/stage/*/issue.txt` gives 15 issues with the heading and 25 without it, and the refine block adds a second heading of another form. The parser therefore reads only the part before the block, and a body without the heading has no criterion.
- The golden set holds 12 defects of the type `criterion_dropped` in 11 case files, all with the gate `pending` (`git grep -c '"criterion_dropped"' tests/fixtures/roadmap_eval/stage`). The recorded `plan.json` files have no `criteria` key, so a gate that demands the list would refuse the three `good` plans. The gate skips a plan with no list.
- First checks against the real system: `uv run devops ci test tests/roadmap/test_roadmap_stage_criteria.py tests/roadmap/test_roadmap_stage_plan.py tests/roadmap/test_roadmap_stage_eval_gates.py` for the refusal, the section and the gate, and `uv run devops roadmap eval stage --replay` for the replay of the whole set.
- Not verified: whether an exact text match raises the rate of replies that fail the one retry. The prompt tells the model to copy the text, and a refusal quotes it. A run of the model on the live cases would show the rate; the pull request states that no such run was made.

## Existing Tool Considered

`markdown-it-py`, which the project already uses (`refine.py`, `step_files.py`), parses the issue body. No open, maintained tool maps criteria to task groups: the mapping is a rule of this job's reply schema, so the change builds the rule: a pydantic model, a pure function, a section of `tasks.md`, two prompt paragraphs and a gate. Written cost is about 130 lines of source (roughly 1500 tokens) and about 200 lines of tests to build, a few tokens per schema change to keep, and one focused session of 30 to 60 minutes to fix. The change deletes no internal code except the `PENDING_GATES` entry for #3019.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## ADDED Requirements

### Requirement: Criteria mapping in the stage reply
The stage reply SHALL hold a `criteria` list in which each entry gives the text of one acceptance criterion of the issue and either the number of the group that delivers it or `pending-person` with a reason. An acceptance criterion SHALL be a top-level item of a list under a heading `Acceptance criteria` in the text of the issue body that a person wrote, before the block of the refine job. An issue with no such list SHALL have no criterion.

#### Scenario: Every criterion is mapped
- **WHEN** The issue has three acceptance criteria and the reply's `criteria` list holds an entry for each, with a group number or `pending-person` and a reason
- **THEN** `check_proposal` returns no problem for the criteria mapping

#### Scenario: The list of the refine block is not read
- **WHEN** The issue body holds a list under `Acceptance criteria` in the refine block as well, and the reply maps the items of the list that a person wrote
- **THEN** `check_proposal` returns no problem for the criteria mapping

#### Scenario: The issue has no acceptance list
- **WHEN** The issue body has no heading `Acceptance criteria` and the reply's `criteria` list is empty
- **THEN** `check_proposal` returns no problem for the criteria mapping

#### Scenario: A pending-person entry has no reason
- **WHEN** An entry of `criteria` gives `pending-person` and a blank reason
- **THEN** the reply breaks the schema and goes back to the model

### Requirement: An unmapped criterion is refused
`check_proposal` SHALL refuse a reply that leaves an acceptance criterion of the issue with no entry in `criteria`, and an entry that names a group the plan does not have. The problem SHALL quote the exact text of the criterion. The check SHALL read the whole body of the issue.

#### Scenario: One of three criteria is unmapped
- **WHEN** The issue has three acceptance criteria and the reply's `criteria` list maps only two
- **THEN** `check_proposal` returns a problem that quotes the text of the unmapped criterion

#### Scenario: The retry copies the text
- **WHEN** The first reply leaves a criterion out and the second reply maps it
- **THEN** the second request to the model holds the problem with the exact text, and the item is staged

#### Scenario: An entry names a group that does not exist
- **WHEN** An entry of `criteria` names group 3 and the plan has 2 groups
- **THEN** `check_proposal` returns a problem that names the criterion and the count of groups

### Requirement: Criteria section in tasks.md
The `tasks.md` of a staged plan SHALL hold a `## Criteria` section before `## Workflow follow-up`. It SHALL list each criterion with the number of the group that delivers it, or `pending-person` with the reason, as bullets with no checkbox.

#### Scenario: Staged plan shows the mapping
- **WHEN** A plan is rendered with criteria mapped to groups
- **THEN** `tasks.md` holds a `## Criteria` section with one line for each criterion and its delivering group number or `pending-person` with the reason

#### Scenario: A plan with no criterion has no section
- **WHEN** A plan is rendered with an empty `criteria` list
- **THEN** `tasks.md` holds no `## Criteria` section

### Requirement: A split moves the criteria with the groups
The split request SHALL hold the `criteria` list, the split reply SHALL give it again with the numbers of the new groups, and the job SHALL check it as it checks the first reply.

#### Scenario: A split renumbers the groups
- **WHEN** The model splits a group and gives the criteria with the new group numbers
- **THEN** `tasks.md` shows the new numbers

### Requirement: The replay judges the criteria gate on plans with a criteria list
The golden-set replay SHALL run the `criteria` gate on a plan that has a `criteria` list, and SHALL not judge a recorded plan that has none.

#### Scenario: A plan leaves a criterion out
- **WHEN** The replay runs a plan with a `criteria` list that leaves one criterion of its issue out
- **THEN** the `criteria` gate refuses the plan

#### Scenario: A recorded plan has no list
- **WHEN** The replay runs a recorded plan with no `criteria` key
- **THEN** the `criteria` gate finds no problem
Loading
Loading