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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-14
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Design

## Decisions

**The rule applies to a scenario that names no code.** The rule of #3321 already judges a scenario that names code, and a plan that satisfies it is accepted. A second refusal for the same scenario would add noise. A scenario whose only code spans are commands or untouched data files is judged by the new rule.

**A base-spec scenario is exempt.** A MODIFIED requirement restates the scenarios of the base requirement, and those scenarios have tests in the merged change. A caller that gives no base scenario names skips the new rule, as a caller that gives no requirement texts skips the rule of #3287.

**The base spec reader carries the scenario names.** `BaseSpec` gains a tuple of the scenario names of the file, and `scenario_names_at` reads the same files for the commands that read a commit rather than a checkout. A second parser of the spec text would drift.

**The gate is `SPEC_DELTA`.** The rule judges the spec delta, like #3321, so a person reads it under that gate.

## Rejected alternatives

- **A separate module `stage_scenarios.py`.** The existing `_scenario_problems` is the one place of the scenario rules, and the new rule is ten lines beside it.
- **A count of behavior groups against scenarios.** A plan can cover several scenarios with one test module, and a count would refuse it.
- **A new setting.** The rule follows the same failure model as the other plan rules: a refusal goes back to the model with the problem.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Proposal: #3423

## Why

A spec delta can add a scenario that no task tests, and the plan still passes. The plan of PR #3400 adds the scenario `A What Changes line below the least length` to a MODIFIED requirement, and no task adds a test for it, yet `devops openspec check` and every check of the pull request pass. The rule of #3321 refuses only a scenario that names code, so a scenario that names a field still passes. Closes #3423.

## What Changes

- `check_proposal` pairs each scenario of an added or modified requirement that names no code with a `behavior` group: the group's `test` names the scenario or the requirement, or its `verify` runs a test module that the group changes or creates. A plan with no such group is refused, with the scenario and its requirement in the problem.
- A scenario whose name the base spec of the capability already holds is exempt. The stage job, `devops roadmap plan-check` and `devops roadmap plan-recheck` give the base scenario names, as they give the base requirement names.
- The stage prompt states the rule.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-stage/spec-delta`: A scenario that names no code needs a behavior task.

## Impact

- Code: `src/devops_cli/roadmap/stage/stage_change.py`, `src/devops_cli/roadmap/stage/stage_specs.py`, `src/devops_cli/roadmap/stage/stage.py`, `src/devops_cli/roadmap/stage/stage_request.py`, `src/devops_cli/roadmap/plan_read.py`, `src/devops_cli/roadmap/plan_check.py`, `src/devops_cli/roadmap/plan_recheck.py`, `src/devops_cli/lang/en/messages.py`
- Prompt: `src/devops_cli/ai/tasks/roadmap_stage_change.md`
- Tests: `tests/roadmap/stage/test_roadmap_stage_scenario_evidence.py`, `tests/roadmap/stage/test_roadmap_stage_prompt_rules.py`, `tests/roadmap/stage/test_roadmap_stage_plan.py`, `tests/roadmap/stage/test_roadmap_stage_plan_check.py`

## Feasibility

Read on 2026-11-14 against `origin/main` at `04107728d`.

- The code rule sits beside the existing one: `src/devops_cli/roadmap/stage/stage_change.py:1049:_scenario_problems` and `src/devops_cli/roadmap/stage/stage_change.py:1082:stage_scenario_untested_code`.
- The base spec reader holds the requirement names: `src/devops_cli/roadmap/stage/stage_specs.py:29:class BaseSpec`; it does not hold scenario names yet.
- The gates take the base data from their callers: `src/devops_cli/roadmap/stage/stage_request.py:65:def gate_arguments` and `src/devops_cli/roadmap/plan_read.py:734:def specs_at`.
- The failing case of the issue is the plan of PR #3400: its scenario names only a field, and its task tests another rule. The test of the branch builds that plan and the refusal.

## Existing Tool Considered

No open, maintained tool covers this repository-specific plan rule. The change extends `check_proposal` and its base-spec reader, adopts no new dependency, and builds about 150 lines with about 200 lines of tests.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## ADDED Requirements

### Requirement: A scenario that names no code has a behavior task
`check_proposal` SHALL refuse a scenario of an added or modified requirement that names no code in a code span when no behavior group covers it. A behavior group covers a scenario when its `test` holds the scenario name or the requirement name, or when its `verify` runs a test module that the group changes or creates. A scenario whose name the base spec of the capability already holds SHALL be exempt. The problem SHALL name the scenario and the requirement.

#### Scenario: A scenario that names only a field
- **WHEN** a plan modifies a requirement, adds the scenario `A What Changes line below the least length`, and its only behavior group tests another rule
- **THEN** `check_proposal` returns one problem that names the scenario and the requirement

#### Scenario: A task that names the scenario
- **WHEN** a behavior group's `test` text holds the name of the scenario or of its requirement
- **THEN** `check_proposal` returns no problem for the scenario

#### Scenario: A verify command that runs the changed test module
- **WHEN** a behavior group changes or creates a test module under `tests/` and its `verify` runs that module
- **THEN** `check_proposal` returns no problem for the scenario

#### Scenario: A scenario of the base spec
- **WHEN** a plan restates in a MODIFIED requirement a scenario that the base spec of the capability already holds
- **THEN** `check_proposal` returns no problem for that scenario

### Requirement: The stage prompt asks for a behavior task for each new scenario
The stage prompt SHALL tell the planner that each scenario of an added or modified requirement that names no code needs a behavior group whose `test` names the scenario or the requirement, or whose `verify` runs a changed or created test module, and that a base-spec scenario is exempt.

#### Scenario: The prompt holds the rule
- **WHEN** a test reads the text of `roadmap_stage_change.md`
- **THEN** the text holds the sentence of the rule
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Tasks

## 1. Refuse a new scenario that no behavior task covers

Kind: behavior. Reads: `src/devops_cli/roadmap/stage/stage_change.py`, `src/devops_cli/roadmap/stage/stage_specs.py`, `src/devops_cli/roadmap/stage/stage.py`, `src/devops_cli/roadmap/stage/stage_request.py`, `src/devops_cli/roadmap/plan_read.py`, `src/devops_cli/roadmap/plan_check.py`, `src/devops_cli/roadmap/plan_recheck.py`. Changes: the same paths, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/stage/test_roadmap_stage_scenario_evidence.py`.

- [x] 1.1 Add the scenario names to `BaseSpec` and to the callers of the gates in the stage job, `plan-check` and `plan-recheck`
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_scenario_evidence.py` passes
- [x] 1.2 Refuse a scenario that names no code and no behavior group covers, with the scenario and its requirement in the problem, and exempt a base-spec scenario
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_scenario_evidence.py` passes
- [x] 1.3 Keep the existing plan tests true, where the new rule refuses a plan that another rule already refuses
- Verification: `$ uv run devops ci test tests/roadmap/stage tests/roadmap/test_roadmap_plan_check.py tests/roadmap/test_roadmap_plan_recheck.py` passes

## 2. State the rule in the stage prompt

Kind: other. Reads: `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `tests/roadmap/stage/test_roadmap_stage_prompt_rules.py`. Changes: the same paths.

- [x] 2.1 Add the sentence of the rule to the prompt, beside the rule of #3321
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_prompt_rules.py` passes

## 3. Run the gates

Kind: other. Reads: `tests/roadmap/`. Changes: none.

- [x] 3.1 Run the gate of the branch
- Verification: `$ uv run devops ci --check --only lint,format,typecheck` passes
- Verification: `$ uv run devops ci docs` passes
26 changes: 26 additions & 0 deletions openspec/specs/roadmap-stage/spec-delta/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,29 @@ The review prompt `src/devops_cli/ai/tasks/roadmap_stage_verify.md` SHALL make a
#### Scenario: The prompts state the rename rule
- **WHEN** a test reads the review prompt and the stage prompt
- **THEN** the review prompt names a modified requirement whose name no longer fits its text under `spec_delta_wrong`, and the stage prompt names `renamed`, `removed`, `to_name` and the name of the `modified` entry

### Requirement: A scenario that names no code has a behavior task
`check_proposal` SHALL refuse a scenario of an added or modified requirement that names no code in a code span when no behavior group covers it. A behavior group covers a scenario when its `test` holds the scenario name or the requirement name, or when its `verify` runs a test module that the group changes or creates. A scenario whose name the base spec of the capability already holds SHALL be exempt. The problem SHALL name the scenario and the requirement.

#### Scenario: A scenario that names only a field
- **WHEN** a plan modifies a requirement, adds the scenario `A What Changes line below the least length`, and its only behavior group tests another rule
- **THEN** `check_proposal` returns one problem that names the scenario and the requirement

#### Scenario: A task that names the scenario
- **WHEN** a behavior group's `test` text holds the name of the scenario or of its requirement
- **THEN** `check_proposal` returns no problem for the scenario

#### Scenario: A verify command that runs the changed test module
- **WHEN** a behavior group changes or creates a test module under `tests/` and its `verify` runs that module
- **THEN** `check_proposal` returns no problem for the scenario

#### Scenario: A scenario of the base spec
- **WHEN** a plan restates in a MODIFIED requirement a scenario that the base spec of the capability already holds
- **THEN** `check_proposal` returns no problem for that scenario

### Requirement: The stage prompt asks for a behavior task for each new scenario
The stage prompt SHALL tell the planner that each scenario of an added or modified requirement that names no code needs a behavior group whose `test` names the scenario or the requirement, or whose `verify` runs a changed or created test module, and that a base-spec scenario is exempt.

#### Scenario: The prompt holds the rule
- **WHEN** a test reads the text of `roadmap_stage_change.md`
- **THEN** the text holds the sentence of the rule
1 change: 1 addition & 0 deletions src/devops_cli/ai/tasks/roadmap_stage_change.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The rules of the project:
- A task group must not change or create a file under `openspec/specs/`, in `changes` or in `creates`. `openspec archive` writes the living specs from the spec delta of the change folder.
- A group must not change or create `openspec/changes` or a path under it, because the job writes the change folder before the groups run. The check refuses a `changes` or `creates` path that is `openspec/changes` or sits under it. A group must not change or create a path of the plan's own change folder under `openspec/changes/`, and no task code span may name it. The check refuses a group or a task that names the own change folder.
- A spec scenario that names a function or a file in a code span must have a behavior test that names it in `test` or `verify`, unless the scenario names a command. The check refuses a scenario that names code with no behavior test.
- A scenario of an added or modified requirement that names no code in a code span must have a behavior group whose `test` names the scenario or the requirement, or whose `verify` runs a test module that the group changes or creates. A scenario that the base spec of the capability already holds is exempt. The check refuses a scenario that no behavior group covers.
- When `feasibility` quotes a `References to` search answer, each file it lists outside `openspec/changes/archive/` must appear in a group's `changes` or in a design decision. The check refuses a file from a quoted search that no group or decision covers.
- The job checks every path against the files of the staged commit, and a path that is no file there is a fault. A path is a file of the commit, or a path that this group or an earlier group lists in `creates`. The check covers `reads`, `changes`, each path in a code span of a task, and each path in `verify`. Write every path of a task in a code span. Take a path from the `context` or from the issue only when the inputs show it exists: the issue can cite files of an older commit. When `problem` lists files with the same name, use one of them. A second reply with a missing path stops the item.
- When `what_changes`, the paths of a group or the text of a task name a security trigger, give a non-blank `security` text. The security trigger paths are `SECURITY.md`, `pyproject.toml` and paths under `k8s/`. The security trigger words are `sanitizer`, `credential`, `keyring`, `egress`, `admission policy`, `networkpolicy`, `rbac`, `new host`, `loosen`, `loosened` and `loosening`. The `security` text answers what crosses a trust boundary, what a person must confirm, and what test fails if the rule breaks. The job renders that text as the `## Security` section of `design.md`. When the plan names no security trigger, set `security` to an empty string.
Expand Down
3 changes: 3 additions & 0 deletions src/devops_cli/lang/en/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4622,6 +4622,9 @@ class RoadmapMessages:
stage_scenario_untested_code: str = (
"Scenario '{scenario}' names `{code}` with no behavior test."
)
stage_scenario_no_behavior_task: str = (
"Scenario '{scenario}' of requirement '{requirement}' has no behavior task."
)
stage_reference_uncovered_file: str = (
"The quoted search lists `{path}`. Add a task group or a design decision for it."
)
Expand Down
5 changes: 5 additions & 0 deletions src/devops_cli/roadmap/plan_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
change_root,
files_at,
read_change,
scenario_names_at,
specs_at,
tree_files,
)
Expand Down Expand Up @@ -164,6 +165,7 @@ class PlanFolder:
tree: StagedTree
known: Collection[str]
requirements: Mapping[str, Collection[str]]
base_scenarios: Mapping[str, Collection[str]]
item_title: str
item_body: str
budget: int
Expand Down Expand Up @@ -425,6 +427,7 @@ def _gate_problems(proposal: StageProposal, folder: PlanFolder) -> list[PlanProb
folder.known,
folder.tree,
requirements=folder.requirements,
base_scenarios=folder.base_scenarios,
issue_body=folder.item_body,
registry=folder.registry,
)
Expand Down Expand Up @@ -556,6 +559,7 @@ def plan_check(
planned = reads.get_issue(repo, issue)
body, _ = split_record(planned.body or "", issue=f"#{issue}")
known, requirements = specs_at(source, base_rev, operation=GIT_OPERATION)
base_scenarios = scenario_names_at(source, base_rev, operation=GIT_OPERATION)
# The files of the folder come from the checkout, not from `git show`, which strips the end of
# a text: they are then the files that the stage job wrote, and the measure is its figure.
with checkout_at(source, head, operation=GIT_OPERATION) as tree:
Expand All @@ -569,6 +573,7 @@ def plan_check(
tree=StagedTree(files),
known=known,
requirements=requirements,
base_scenarios=base_scenarios,
item_title=planned.title,
item_body=body,
budget=load_settings().roadmap.stage.step_tokens,
Expand Down
16 changes: 16 additions & 0 deletions src/devops_cli/roadmap/plan_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,22 @@ def tasks_at(source: Path, rev: str, issue: int, *, operation: str) -> str:
return files_at(source, rev, [path], operation=operation)[path]


def scenario_names_at(
source: Path, rev: str, *, operation: str, files: Sequence[str] | None = None
) -> dict[str, tuple[str, ...]]:
"""The name of each scenario of the base spec of each capability at commit `rev` (#3423).
`files` is the paths of `rev` when the caller listed them already."""
if not rev:
return {}
scenarios: dict[str, tuple[str, ...]] = {}
for path in tree_files(source, rev, operation=operation) if files is None else files:
match = _SPEC_FILE.match(path)
if match is not None:
text = files_at(source, rev, [path], operation=operation)[path]
scenarios[match["capability"]] = read_spec(text).scenarios
return scenarios


def specs_at(
source: Path, rev: str, *, operation: str, files: Sequence[str] | None = None
) -> tuple[frozenset[str], dict[str, tuple[str, ...]]]:
Expand Down
5 changes: 5 additions & 0 deletions src/devops_cli/roadmap/plan_recheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
created_paths,
files_at,
read_change,
scenario_names_at,
specs_at,
tree_files,
)
Expand Down Expand Up @@ -246,6 +247,7 @@ class _Pass:
tree: StagedTree
known: frozenset[str]
requirements: dict[str, tuple[str, ...]]
base_scenarios: dict[str, tuple[str, ...]]
open_items: dict[int, Item]
closed: frozenset[int]
tool: OpenSpecTool
Expand Down Expand Up @@ -361,6 +363,7 @@ def _record(shared: _Pass, issue: int, folder: str) -> PlanRecord:
shared.known,
shared.tree,
requirements=shared.requirements,
base_scenarios=shared.base_scenarios,
issue_body=held.body if held is not None else "",
manifest_references=record_test_references(proposal.groups, shared.test_search),
module_tests=record_module_tests(proposal.groups, shared.tree, shared.test_search),
Expand Down Expand Up @@ -401,6 +404,7 @@ def _judge(
"""The record of each active folder of `planned`, judged on the tree at `rev`."""
paths = tree_files(source, rev, operation=GIT_OPERATION)
known, requirements = specs_at(source, rev, operation=GIT_OPERATION)
base_scenarios = scenario_names_at(source, rev, operation=GIT_OPERATION)
shared = _Pass(
source=source,
rev=rev,
Expand All @@ -409,6 +413,7 @@ def _judge(
tree=StagedTree(paths, reader=_file_reader(source, rev)),
known=known,
requirements=requirements,
base_scenarios=base_scenarios,
open_items=open_items,
closed=closed,
tool=tool,
Expand Down
5 changes: 5 additions & 0 deletions src/devops_cli/roadmap/stage/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,9 @@ def __init__(
# that removes a command needs a `modified` requirement for each base requirement that
# names it (#3287).
self._requirement_texts = {name: dict(spec.statements) for name, spec in specs.items()}
# The name of each scenario of the base spec of a capability (#3423): a modified
# requirement that restates one needs no new behavior task.
self._base_scenarios = {name: spec.scenarios for name, spec in specs.items()}
self._tree = tree
self._budget = budget
self._window = window
Expand Down Expand Up @@ -2238,6 +2241,7 @@ def _gate_problems(
known=self._known,
requirements=self._requirements,
requirement_texts=self._requirement_texts,
base_scenarios=self._base_scenarios,
search_evidence=evidence,
manifest_references=manifest_references,
module_tests=module_tests,
Expand Down Expand Up @@ -2358,6 +2362,7 @@ def _plan_check(
tree=self._tree.with_files(files),
known=self._known,
requirements=self._requirements,
base_scenarios=self._base_scenarios,
item_title=target.item.title,
item_body=target.item.body,
budget=self._budget,
Expand Down
Loading