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: 2 additions & 0 deletions docs/roadmap/plan-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ commit, whatever the working tree of the checkout holds.
before an issue reference.
- The check `Semantic PR title`: it must exist and it must pass.
- A `MODIFIED` requirement whose text in the base spec changed, or went, since the plan commit.
For a requirement under the new name of a `RENAMED` entry, the command compares the base text
under the old name, because the archive renames before it modifies.

A pull request that the implement job has taken over is the delivery of the item: its body closes
the issue and holds no `Plans #<issue>` line. The command does not judge a delivery, so it prints
Expand Down
4 changes: 4 additions & 0 deletions docs/roadmap/stage.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ The toolset `research` adds one more tool to `extended`: `search_web`. It search

The trace gate refuses a Feasibility sentence that claims a read of the run for a path that the plan runs did not see. A read word (`read`, `reads`, `reading`, `ran`, or the tool `read_file`, also in a span `` `read_file path` ``) is a claim of the run when it has no subject (`` Read `x` ``, `the same read`, `` a quick read of `x` ``), when it is a passive or a participle (`` `x` was read ``, `` `x`, read at the base ``), or when its subject names the run or its author (`I`, `we`, `the run`, `the planner`). A verb of a list has the subject of the list, as in `` I listed `src/`, opened `x` and read `y` ``. A read whose subject is other words, such as `this plan`, `group 2`, `the probe` or `it`, says what the plan or the code does, and `read-only` is no read word. The gate judges the path that the read takes: the path of its `` `read_file path` `` span, the path before a participle, the subject of a passive, else the first path of its object, else the last path before it, else the first path of its result. The object ends at `;`, at a comma before a new clause, or at a verb of the result, such as `shows`, and a pronoun at its start, such as `it` or `that file`, makes the read take the path before it. So in "`read_file` on it showed the text `x.py`" the read takes the path before it, not `x.py`. A run saw a path that a tool call took as its argument. A `search_code` or `callers` match shows one line, so a read whose object is a citation of that line, `path:line` or `path:line:text`, counts as seen. `read_file`, a read that takes the line through a pronoun or from its result, and a claim of the whole file do not. A probe line is no read: it says only whether a path is a file.

## The spec delta

The spec of each capability in the reply has four lists, one for each delta kind of OpenSpec: `added`, `modified`, `renamed` and `removed` (#5340). A rename gives `from_name` and `to_name`, and the delta file writes it as a `- FROM:` line and a `- TO:` line under `## RENAMED Requirements`. A removal gives the name, the `reason` and an optional `migration`, and the delta file writes it as a requirement header with a `**Reason**:` line and a `**Migration**:` line under `## REMOVED Requirements`. The archive renames before it modifies, so a `modified` requirement whose text no longer fits its old name gets a `renamed` entry and takes the new name. The job copies the base scenarios that such a block omits from the old name. The gate refuses a rename or a removal on a new capability, a `from_name` or a removed name that the base spec does not have, and a `to_name` that the base spec has already. `openspec validate --strict` passes these names: it gives only the first rename that `openspec archive` refuses, as an INFO line, and no line for such a removal, which the archive skips with a warning. The review reports a `modified` requirement whose name no longer fits its text as `spec_delta_wrong`.

## The window of the plan run

The plan run reads the context window of the task `stage`. The task `stage` takes the fields that it does not set from the task `analysis` (the setting `ai.tasks.stage`, variable `DEVOPS_CLI_AI_TASK_STAGE_MODEL`). The Service sets both tasks, each with `context_window` 256,000 and the model `deepseek-v4.1-flash-1017`, in the keys `ai.tasks.analysis` and `ai.tasks.stage` of [k8s/devops/configmap.example.yaml](../../k8s/devops/configmap.example.yaml) (the owner decision of 2026-11-10, #4369, after the Sonnet trial of #4204). The model has `max_input_tokens` 1,048,576 in [k8s/llm/gateway/config.yaml](../../k8s/llm/gateway/config.yaml). The job uses the setting and not the larger value of the model. The variable `DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW` sets the window of the task `stage` alone.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-13
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Design

## Decisions

- **Write the OpenSpec form that the repository already uses.**: A rename is `- FROM: \`### Requirement: <old>\`` and `- TO: \`### Requirement: <new>\`` on two lines. A removal is a `### Requirement: <name>` header with a `**Reason**:` line and an optional `**Migration**:` line. The code spans keep a name that ends with a code span whole, because the FROM and TO pattern of OpenSpec strips one closing backtick.
- **Write REMOVED and RENAMED after ADDED and MODIFIED.**: The order of the OpenSpec template keeps the files of a plan with no rename and no removal the same as before. The archive applies the sections in its own order, so the order in the file changes nothing.
- **Name the fields `from_name` and `to_name`.**: `from` is a keyword of Python, and an alias makes the reply, the dump and the read differ.
- **Keep `migration` as an optional field.**: The hand-written plans of the repository give a `**Migration**:` line for each removal. Without the field, fix-plan would drop that line when it writes such a plan again.
- **Check in the gate only what `openspec validate` does not check.**: The validator refuses a MODIFIED block under the old name, a rename and a removal of one requirement, and a TO that collides with an ADDED requirement. With the base spec present, `validate --strict` still passes a FROM that the base spec does not have, a TO that it has, and a removed name that it does not have: it gives only the first rename that `openspec archive` refuses, as an INFO line, and no line for the removal, which the archive skips with a warning (live run of 2026-11-13). The stage and plan-check count each INFO line as a problem, so OpenSpec reports one refused rename for each try, and nothing reports the removal. So the gate checks the base names, and only when the caller gives the requirement names of the capability.
- **Let the review judge whether a name fits its text.**: No rule can see that a name says the opposite of its text. The review already sends a plan back for an open `spec_delta_wrong` finding, so the review prompt adds this case to that type, and the stage prompt tells the planner the fix (ADR 0020: a rule before a model, a model where no rule can decide).
- **Read the base scenarios and the base text under the old name.**: OpenSpec applies RENAMED before MODIFIED, so a MODIFIED block under the new name replaces the renamed base block. The scenario copy and the moved-spec check of plan-check follow the same map from the new name to the old name.
- **Deliver the reader part of #5256 here.**: Write, then read, must keep each fact of the files (#5205), and the property test of the reader generates every field of `StageSpec`. A writer change with no reader change breaks that contract.

## Rejected alternatives

- **Keep the old name and fix the name in the delivery pull request.**: The evidence is #5182 and #5336: the delivery merged the false name, and the living spec still holds it.
- **Detect a name that no longer fits with a word rule, such as a `not` in the name and none in the text.**: Such a rule refuses good plans and misses most bad ones. Only a reader of the meaning can judge it, and the review already reads the plan.
- **Write REMOVED with the bullet form `- \`### Requirement: <name>\``.**: The bullet form has no place for the reason, and the issue asks for a reason with each removal.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Proposal: #5340

## Why

The stage job cannot write a RENAMED or a REMOVED spec delta. `StageSpec` holds only `added` and `modified`, and `spec_file` writes only those two sections. So a plan that changes the meaning of a requirement keeps the old name above the new text. Plan #5182 (item #3785) did this, and its delivery #5336 merged a requirement whose name says the opposite of its text. The planner also wrote a false reason in its design: "a delta refuses a modified name". OpenSpec and `openspec/config.yaml` accept RENAMED and REMOVED.

Closes #5340.

## What Changes

- `StageSpec` gets `renamed` (pairs of `from_name` and `to_name`) and `removed` (`name`, `reason` and an optional `migration`). `spec_file` writes them as `## RENAMED Requirements` FROM and TO lines and `## REMOVED Requirements` blocks with `**Reason**:` and `**Migration**:` lines, the form of the OpenSpec documents and of the hand-written plans of this repository.
- The spec-delta gate refuses a rename or a removal on a new capability, a `from_name` or a removed `name` that the base spec does not have, and a `to_name` that the base spec has already.
- The job copies the base scenarios that a MODIFIED block omits also for a requirement under its new name: it reads them under the old name of the rename.
- The stale-command check accepts a removed base requirement, and a renamed base requirement that a MODIFIED block rewrites under its new name.
- The stage prompt tells the planner when to rename and when to remove. The review prompt makes a MODIFIED requirement whose name no longer fits its text a `spec_delta_wrong` finding, so the review gate sends such a plan back.
- The plan reader reads both sections back, so write, then read, keeps each fact (#5205), and fix-plan keeps a rename or a removal when it writes a plan again. Plan-check compares a MODIFIED requirement under a new name with the base text under its old name.
- The change fits one pull request.

## Capabilities

- Modified: `roadmap-stage/spec-delta` (the reply, the delta file, the gate, the scenario copy and the prompts).
- Modified: `roadmap-plan-check` (the plan reader and the moved-spec check).

## Impact

- `src/devops_cli/roadmap/stage/stage_change.py`, `src/devops_cli/roadmap/stage/stage_validate.py`, `src/devops_cli/roadmap/plan_read.py`, `src/devops_cli/roadmap/plan_check.py`, `src/devops_cli/lang/en/messages.py`.
- `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `src/devops_cli/ai/tasks/roadmap_stage_verify.md`.
- `docs/roadmap/stage.md`, `docs/roadmap/plan-check.md`.
- A plan with no rename and no removal gives the same files as before. The fix takes effect in the Service after a release and a new Service image.

## Feasibility

- Source at `origin/main` 54cf0a526: `StageSpec` in `src/devops_cli/roadmap/stage/stage_change.py` holds only `capability`, `purpose`, `added` and `modified`; `spec_file` writes only `## ADDED Requirements` and `## MODIFIED Requirements`; `_spec` of `src/devops_cli/roadmap/plan_read.py` reads only those two sections.
- Real plans: the spec deltas of the Service plan pull requests #5350, #5333, #5283 and #5182 (open or merged in the last 14 days) hold only ADDED and MODIFIED. #5182 modifies `The alloy-profiles pod does not run on the node ...` with a text that says that the pod runs on every node, and its `design.md` says that a delta refuses a modified name. #5336 archived that text into `openspec/specs/monitoring-collectors/spec.md`.
- Tool: `openspec --version` on `PATH` is 1.17.0. Its parser (`dist/core/parsers/requirement-blocks.js`) reads `- FROM: \`### Requirement: <name>\`` and `- TO: ...` pairs and `### Requirement: <name>` headers under REMOVED. Its validator refuses a MODIFIED block under the old name of a rename, and its archive (`dist/core/specs-apply.js`) applies RENAMED, then REMOVED, then MODIFIED, then ADDED, and refuses a FROM that the spec does not have or a TO that it has. It skips a removed name that the spec does not have, with a warning, and exits 0. A live run of `openspec validate --strict` on such a delta with the base spec gives `valid: true`, an INFO line `Archive would refuse this delta` for the first refused rename only, and no line for the removal. So the stage gate checks the three names.
- Hand-written plans of this repository use the same form, for example the archived changes of #5150 (RENAMED) and #4798 (REMOVED with `**Reason**:` and `**Migration**:`).
- The last `plan_defect` failure of the stage job (item #5118, plan #5350, 2026-11-13 03:40Z) is a `spec_delta_wrong` finding about a duplicated requirement, not about a rename. So this change does not fix that failure. It removes the cause of the false names that #5182 shows.
- #5256 asks for the reader part. The writer and the reader share one contract (#5205), so this change holds both.

## Existing Tool Considered

OpenSpec defines the delta form and validates it, and the job already runs `openspec validate --strict` on each plan. No tool writes the delta from the reply of the model, so the change extends the writer and the reader of the job. Cost to build: about 1.5M agent tokens and 3 hours. Keep: the two models and their render and read functions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## ADDED Requirements

### Requirement: The plan reader reads the RENAMED and REMOVED deltas
The plan reader SHALL read each FROM and TO pair of `## RENAMED Requirements` into `renamed`, and each requirement header of `## REMOVED Requirements` with its `**Reason**:` line and its optional `**Migration**:` line into `removed`. A FROM line with no TO line, a TO line with no FROM line, and a removal with no reason SHALL be a `PlanReadError` that names the spec file.

#### Scenario: A real RENAMED delta reads back
- **WHEN** the reader reads the spec delta of the archived change of #5150, which renames one requirement and modifies it under the new name
- **THEN** the spec holds the rename with both names, and the modified requirement under the new name

#### Scenario: A real REMOVED delta reads back
- **WHEN** the reader reads the spec delta of the archived change of #4798, which removes two requirements, each with a reason and a migration
- **THEN** the spec holds both removals with their names, reasons and migrations

#### Scenario: A FROM line with no TO line
- **WHEN** a RENAMED section holds a FROM line and no TO line after it
- **THEN** the reader raises `PlanReadError` that names the spec file

#### Scenario: A removal with no reason
- **WHEN** a REMOVED section holds a requirement header with no `**Reason**:` line
- **THEN** the reader raises `PlanReadError` that names the spec file

### Requirement: Plan-check compares a renamed requirement under its old name
The moved-spec check SHALL compare a MODIFIED requirement whose name is the `to_name` of a `renamed` entry with the base text under the `from_name`, at the plan commit and at the pull request base.

#### Scenario: A renamed and modified requirement with an unchanged base
- **WHEN** a plan renames a base requirement, modifies it under the new name, and the base spec does not change after the plan commit
- **THEN** plan-check reports no `spec-moved` problem

#### Scenario: The base text under the old name changed
- **WHEN** a plan renames and modifies a base requirement, and the base text under the old name changes after the plan commit
- **THEN** plan-check reports a `spec-moved` problem that names the old name
Loading