diff --git a/openspec/changes/3404-the-plan-check-requires-a-new/.openspec.yaml b/openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/.openspec.yaml
similarity index 100%
rename from openspec/changes/3404-the-plan-check-requires-a-new/.openspec.yaml
rename to openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/.openspec.yaml
diff --git a/openspec/changes/3404-the-plan-check-requires-a-new/design.md b/openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/design.md
similarity index 100%
rename from openspec/changes/3404-the-plan-check-requires-a-new/design.md
rename to openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/design.md
diff --git a/openspec/changes/3404-the-plan-check-requires-a-new/proposal.md b/openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/proposal.md
similarity index 100%
rename from openspec/changes/3404-the-plan-check-requires-a-new/proposal.md
rename to openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/proposal.md
diff --git a/openspec/changes/3404-the-plan-check-requires-a-new/specs/roadmap-stage/spec.md b/openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/specs/roadmap-stage/spec.md
similarity index 100%
rename from openspec/changes/3404-the-plan-check-requires-a-new/specs/roadmap-stage/spec.md
rename to openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/specs/roadmap-stage/spec.md
diff --git a/openspec/changes/3404-the-plan-check-requires-a-new/tasks.md b/openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/tasks.md
similarity index 67%
rename from openspec/changes/3404-the-plan-check-requires-a-new/tasks.md
rename to openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/tasks.md
index ee093bd405..9e6ffdce60 100644
--- a/openspec/changes/3404-the-plan-check-requires-a-new/tasks.md
+++ b/openspec/changes/archive/2026-11-05-3404-the-plan-check-requires-a-new/tasks.md
@@ -4,20 +4,27 @@
Reads: `src/devops_cli/roadmap/stage_change.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/test_roadmap_stage_content.py`. Changes: `src/devops_cli/roadmap/stage_change.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/test_roadmap_stage_content.py`.
-- [ ] 1.1 In `tests/roadmap/test_roadmap_stage_content.py`, write a test that builds a proposal with `make_stage_proposal` whose behavior group changes `src/devops_cli/roadmap/stage_change.py`, asserts that `content_problems` names `StageProposal` and `content_problems` for a test text with no such names, and asserts that `content_problems` returns no problem for a test text that builds the plan's own `StageProposal` and asserts no problem for `content_problems`
+- [x] 1.1 In `tests/roadmap/test_roadmap_stage_content.py`, write a test that builds a proposal with `make_stage_proposal` whose behavior group changes `src/devops_cli/roadmap/stage_change.py`, asserts that `content_problems` names `StageProposal` and `content_problems` for a test text with no such names, and asserts that `content_problems` returns no problem for a test text that builds the plan's own `StageProposal` and asserts no problem for `content_problems`
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_content.py` fails on the base
-- [ ] 1.2 Add the message text to `src/devops_cli/lang/en/messages.py` beside the other text problems of the roadmap stage messages, and add the rule to `content_problems` in `src/devops_cli/roadmap/stage_change.py`: when a behavior group changes `src/devops_cli/roadmap/stage_change.py` and no group test text holds `StageProposal`, `content_problems` and no problem, return one problem that names the symbols and the test that the plan must give
+- [x] 1.2 Add the message text to `src/devops_cli/lang/en/messages.py` beside the other text problems of the roadmap stage messages, and add the rule to `content_problems` in `src/devops_cli/roadmap/stage_change.py`: when a behavior group changes `src/devops_cli/roadmap/stage_change.py` and no group test text holds `StageProposal`, `content_problems` and no problem, return one problem that names the symbols and the test that the plan must give
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_content.py` passes
## 2. State the self-acceptance rule in the staging prompt
Reads: `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `tests/roadmap/test_roadmap_stage_prompt_rules.py`, `src/devops_cli/ai/task_loader.py`. Changes: `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `tests/roadmap/test_roadmap_stage_prompt_rules.py`.
-- [ ] 2.1 In `tests/roadmap/test_roadmap_stage_prompt_rules.py`, write a test that loads the prompt with `load_task_prompt` and asserts that it holds `StageProposal`, `content_problems` and the self-acceptance test rule
+- [x] 2.1 In `tests/roadmap/test_roadmap_stage_prompt_rules.py`, write a test that loads the prompt with `load_task_prompt` and asserts that it holds `StageProposal`, `content_problems` and the self-acceptance test rule
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_prompt_rules.py` fails on the base
-- [ ] 2.2 Add the self-acceptance test rule to `src/devops_cli/ai/tasks/roadmap_stage_change.md` beside the other checks of a plan: a behavior group that changes `src/devops_cli/roadmap/stage_change.py` needs a group test that builds the plan's own `StageProposal` and asserts that `content_problems` returns no problem for it
+- [x] 2.2 Add the self-acceptance test rule to `src/devops_cli/ai/tasks/roadmap_stage_change.md` beside the other checks of a plan: a behavior group that changes `src/devops_cli/roadmap/stage_change.py` needs a group test that builds the plan's own `StageProposal` and asserts that `content_problems` returns no problem for it
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_prompt_rules.py` passes
+## 3. Keep the recorded plans of the golden set accepted
+
+Reads: `tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/plan.json`. Changes: `tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/plan.json`, `tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/case.json`, `tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/plan.json`, `tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/case.json`.
+
+- [x] 3.1 Add the self-acceptance test to the group that changes `src/devops_cli/roadmap/stage_change.py` in both recorded plans of #3410, and note it in both cases, so that the replay of the good plan stays accepted and the dropped plan stays judged by no gate
+ - Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_criterion_dropped.py` passes
+
## Workflow follow-up
- Pending a person: review the diff in tuicr (tuicr -r ..HEAD).
diff --git a/openspec/specs/roadmap-stage/spec.md b/openspec/specs/roadmap-stage/spec.md
index e063353883..596d93dd30 100644
--- a/openspec/specs/roadmap-stage/spec.md
+++ b/openspec/specs/roadmap-stage/spec.md
@@ -2025,6 +2025,35 @@ The job SHALL start the branch of a staged item at the staged commit of its roun
- **WHEN** `origin/main` gains a commit after the round read it, and the job stages an item
- **THEN** the parent of the commit of the new branch is the staged commit of the round, and the new commit of `origin/main` is not an ancestor of the new branch
+### Requirement: A plan that adds a text rule carries its self-acceptance test
+A plan with a behavior group that changes `src/devops_cli/roadmap/stage_change.py` SHALL give a group test text that names `StageProposal`, `content_problems` and no problem, so the plan holds no text that its own rule refuses.
+
+#### Scenario: Plan without the test is refused
+- **WHEN** `check_proposal` receives a valid proposal with a behavior group that changes `src/devops_cli/roadmap/stage_change.py` and no group test text that names `StageProposal`, `content_problems` and no problem.
+- **THEN** `check_proposal` returns one problem that names `StageProposal` and `content_problems`.
+
+#### Scenario: Plan with the test is accepted
+- **WHEN** `check_proposal` receives a valid proposal with a behavior group that changes `src/devops_cli/roadmap/stage_change.py` and a group test text that names `StageProposal`, `content_problems` and no problem.
+- **THEN** `check_proposal` returns no self-acceptance problem.
+
+### Requirement: A plan that changes no plan check needs no self-acceptance test
+A plan whose groups change no path in `src/devops_cli/roadmap/stage_change.py` MUST NOT be refused by the self-acceptance rule.
+
+#### Scenario: Plan that changes another file is accepted
+- **WHEN** `check_proposal` receives a valid proposal whose groups change only `src/devops_cli/roadmap/stage.py`.
+- **THEN** `check_proposal` returns no self-acceptance problem.
+
+#### Scenario: Plan that only refactors the plan check is accepted
+- **WHEN** `check_proposal` receives a valid proposal with an other group that changes `src/devops_cli/roadmap/stage_change.py`.
+- **THEN** `check_proposal` returns no self-acceptance problem.
+
+### Requirement: The staging prompt states the self-acceptance test rule
+The staging prompt `src/devops_cli/ai/tasks/roadmap_stage_change.md` MUST state the self-acceptance test rule beside the other checks of a plan.
+
+#### Scenario: Prompt names the self-acceptance test
+- **WHEN** A test loads the prompt with `load_task_prompt`.
+- **THEN** The prompt text contains `StageProposal`, `content_problems` and the self-acceptance test rule.
+
### Requirement: The stage job checks each literal of a negative search
The stage job SHALL record the staged hits of each `-e` literal of a negative-search verify command, and check_proposal SHALL apply the rules of the negative search to each literal, the rule of the staged hit and the rule of the created module alike.
diff --git a/src/devops_cli/ai/tasks/roadmap_stage_change.md b/src/devops_cli/ai/tasks/roadmap_stage_change.md
index 5a13924106..d3b4c7b2c6 100644
--- a/src/devops_cli/ai/tasks/roadmap_stage_change.md
+++ b/src/devops_cli/ai/tasks/roadmap_stage_change.md
@@ -17,6 +17,7 @@ The rules of the project:
- Write `groups` in the order of the work. Each group holds the work of one step of an implementation, and fits in the `budget` with its files: a step reads the instructions of the group, the `AGENTS.md` of the repository and the sections of the documents that it routes the group to, the issue, the change and the files of the group. Keep each group small. A group has these keys: `title`; `kind`, `behavior` or `other`; `reads`, the repository paths that the step reads, an empty list when it reads none; `changes`, the repository paths that the step changes or creates, with at least one path, because every group changes a file; `creates`, the paths of `changes` that do not exist yet, an empty list when it creates none; `creates_lines`, an object that gives the estimated number of lines of each path in `creates`, such as `{"tests/roadmap/test_sample.py": 40}`; `test`, the failing test to write first, and `null` for an `other` group; `implementation`, the work of the step; `documentation`, one text that starts with an imperative verb, such as `Edit`, and names each document in a code span, or `null` when the step changes no document; `verify`, one command that checks the group and gives the same answer on each run, such as `uv run devops ci test tests/roadmap/test_feature.py`, or `null`; and `process`, the steps of a manual check, or `null`. Every task has a text: `title` and `implementation` are never blank, and no other key that you give is blank.
- The stage counts 32 tokens for each estimated line of a path in `creates_lines`, so the estimate of a new file counts toward the `budget` of the step. Give a whole number of lines of at least 1 for each path in `creates`. A path in `creates` with no estimate is refused.
- Choose the `kind` of each group by what the group does. A `behavior` group adds or changes what the code does. It changes a path under `src/`, it has a `test`, its `verify` runs that test, and it has no `process`. It is written test first. Write tests only for new behavior. Every other group is `other`: a document, a manifest, a workflow, a deletion or a refactor that keeps behavior, an edit of tests only, or data. An `other` group has no `test`, so set `test` to `null`. It has exactly one of `verify` and `process`. `verify` is one command that can run again, such as `uv run devops ci docs`, `uv run devops openspec check`, `! git grep -n src/ tests/` (a command that exits 0 when it finds nothing), or `uv run devops k8s image-pins`. A `verify` command starts with `uv run devops`, and the `! git grep` form is the one other form. The `! git grep` form is not a shell command: it takes the options `-n -I -F -i -w -l -c -q`, then one literal of letters, digits, spaces and the signs `_ . : / = @ + , # % ~ -`, then relative paths. Or it takes one or more `-e` options, each followed by its literal, then `--` before the relative paths. A literal after `-e` must not start with `-`. A pipe, `;`, `&&`, a redirect or any other option is refused. `uv run pytest` is refused. `process` is the steps of a repeatable manual check, and you write it only when no command exists. A reply that breaks these rules comes back to you with the problem.
+- A plan that adds a rule of the plan check gives the test that accepts its own plan. A `behavior` group that changes `src/devops_cli/roadmap/stage_change.py` needs a group test that builds the plan's own `StageProposal` and asserts that `content_problems` returns no problem for it, because the rule that the plan adds judges the plan itself. A plan with no such group needs no such test. The check refuses a reply that gives no such test.
- A group that moves a set of modules by name prefix lists every module of that prefix in `changes`, and not the entry module only. Its `verify` command covers the whole prefix: run the layout test of the plan, or search the dotted prefix with the separator (`devops_cli.roadmap.stage_`), and never one sampled module. Before you give a `! git grep` command, call `search_code` with its literal on the staged commit and quote the hit count in `feasibility`. A literal that the plan creates a module for, such as a bare package prefix or a name that no file holds, is no check: the search then proves nothing before the change or can never pass after it.
- A new test module in `creates` goes in the folder under `tests/` that mirrors the package of the code it tests, such as `tests/roadmap/test_feature.py` for code in `src/devops_cli/roadmap/`, or in `tests/invariants/`. The check refuses a new test module that sits flat under `tests/` when it tests code of a package.
- A path is relative to the repository root. It has no `..` and does not start with `/`. A sample file that a test writes at run time, and that no group creates, gets a bare name with no folder, such as `test_sample.py`. Put no folder before such a name: the check reads a name with a folder as a path of the repository.
diff --git a/src/devops_cli/lang/en/messages.py b/src/devops_cli/lang/en/messages.py
index b213a90813..ede1a2ddb4 100644
--- a/src/devops_cli/lang/en/messages.py
+++ b/src/devops_cli/lang/en/messages.py
@@ -3401,6 +3401,13 @@ class RoadmapMessages:
"A task text names `MESSAGES.roadmap`, and no group lists `{path}` in `changes`. Add the "
"message to that file, and list the file in the group that adds it."
)
+ # A plan that adds a rule of the plan check gives the test that accepts its own plan (#3404).
+ stage_problem_self_acceptance: str = (
+ "A behavior group changes `{path}`, and no group test builds the plan's own "
+ "`StageProposal` and asserts that `content_problems` returns no problem. Add a group test "
+ "that builds the plan's own `StageProposal` and asserts that `content_problems` returns "
+ "no problem for it, because the rule that the plan adds judges the plan itself."
+ )
# A plan states the work of each task once: a duplicate task spends the budget of the group on
# no change (#3456).
stage_group_one: str = "group {first}"
diff --git a/src/devops_cli/roadmap/stage_change.py b/src/devops_cli/roadmap/stage_change.py
index d7a07bab02..ad77a7f3dc 100644
--- a/src/devops_cli/roadmap/stage_change.py
+++ b/src/devops_cli/roadmap/stage_change.py
@@ -119,6 +119,15 @@
# in `changes`, so the stage check names it when no group lists it (#3405).
_MESSAGES_FILE: Final[str] = "src/devops_cli/lang/en/messages.py"
_MESSAGE_NAME: Final[re.Pattern[str]] = re.compile(r"\bMESSAGES\.roadmap\b")
+# The plan check itself. A plan that adds a rule of it writes the text that the new rule judges,
+# so the plan gives a group test that builds its own `StageProposal` and asserts that
+# `content_problems` returns no problem for it (#3404).
+_PLAN_CHECK_FILE: Final[str] = "src/devops_cli/roadmap/stage_change.py"
+_SELF_ACCEPTANCE_MARKS: Final[tuple[str, ...]] = (
+ "StageProposal",
+ "content_problems",
+ "no problem",
+)
_SENTENCE_END: Final[str] = f"{string.whitespace}."
REGENERATE_DOCUMENTS: Final[str] = "uv run devops docs generate --sync-readme"
# The stage prompt and each module that holds a check of `check_proposal` or of the gates it
@@ -586,6 +595,25 @@ def _message_file_problems(proposal: StageProposal) -> list[str]:
return [MESSAGES.roadmap.stage_problem_message_file.format(path=_MESSAGES_FILE)]
+def _adds_plan_rule(group: StageGroup) -> bool:
+ """Whether `group` adds or changes a rule of the plan check, which judges the plan that
+ proposes it (#3404). An `other` group refactors or documents a rule, so it adds none."""
+ return group.kind is GroupKind.BEHAVIOR and _PLAN_CHECK_FILE in group.changes
+
+
+def _self_acceptance_problems(proposal: StageProposal) -> list[str]:
+ """One problem for a plan that adds a rule of the plan check and gives no group test that
+ builds the plan's own `StageProposal` and asserts that `content_problems` returns no problem
+ (#3404). The rule that the plan adds does not exist when the stage job reads the plan, so no
+ check can run it on the plan: the plan gives the test itself, and the implement step runs it."""
+ if not any(_adds_plan_rule(group) for group in proposal.groups):
+ return []
+ tests = [group.test for group in proposal.groups if group.test is not None]
+ if any(all(mark in test for mark in _SELF_ACCEPTANCE_MARKS) for test in tests):
+ return []
+ return [MESSAGES.roadmap.stage_problem_self_acceptance.format(path=_PLAN_CHECK_FILE)]
+
+
def _plan_tasks(proposal: StageProposal) -> list[tuple[int, int, str]]:
"""The number of the group, the number of the task in it and the normalized work text of the
task, for each task of `proposal`, in the order of `tasks.md`."""
@@ -694,13 +722,15 @@ def content_problems(proposal: StageProposal, probes: Sequence[str] = ()) -> lis
short or a placeholder word (`is_placeholder` of the pull request form), a `feasibility` that
quotes no line of `probes` when there are some, a task text that names a `MESSAGES.roadmap`
entry while no group changes the message file (#3405), two tasks that state the same work
- (#3456), and a plan that builds its own code and gives no cost of tokens and time in
- `existing_tool`. The replay (`stage_eval_gates`) and the job both call this through
+ (#3456), a plan that builds its own code and gives no cost of tokens and time in
+ `existing_tool`, and a plan that adds a rule of the plan check and gives no test that accepts
+ its own plan (#3404). The replay (`stage_eval_gates`) and the job both call this through
`check_proposal`, so one rule set judges both."""
texts = MESSAGES.roadmap
problems = [p for field, text in _plan_texts(proposal) for p in _text_problems(field, text)]
problems.extend(_message_file_problems(proposal))
problems.extend(_duplicate_task_problems(proposal))
+ problems.extend(_self_acceptance_problems(proposal))
lines = [_squash(line) for line in probes if line.strip()]
if lines:
feasibility = _squash(" ".join(proposal.feasibility))
diff --git a/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/case.json b/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/case.json
index 1ab8ea4bf3..9701fa4914 100644
--- a/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/case.json
+++ b/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/case.json
@@ -18,6 +18,7 @@
"notes": [
"Synthetic case: the plan is the merged plan of #3435 with group 3 removed and the What Changes item of that group worded without the paths.",
"The last group has the task to run `uv run devops roadmap eval stage --replay` with the score before and after, which the rule of #3331 asks. The good twin has the same task.",
+ "Group 2 has the test that builds the plan's own `StageProposal` and asserts that `content_problems` returns no problem, which the rule of #3404 asks. The twin has the same test.",
"The scores are set by hand. No review scored this plan."
],
"defects": [
diff --git a/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/plan.json b/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/plan.json
index a239c82726..23d896e9c2 100644
--- a/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/plan.json
+++ b/tests/fixtures/roadmap_eval/stage/3410-the-eval-field-group-is-dropped/plan.json
@@ -202,7 +202,7 @@
],
"creates": [],
"creates_lines": {},
- "test": "Write tests/roadmap/test_roadmap_stage_plan.py first: check_proposal refuses a negative-search literal with no recorded hit, refuses a literal that a created source path keeps, and accepts a literal whose recorded hit survives the change",
+ "test": "Write tests/roadmap/test_roadmap_stage_plan.py first: check_proposal refuses a negative-search literal with no recorded hit, refuses a literal that a created source path keeps, and accepts a literal whose recorded hit survives the change, and the plan's own `StageProposal` gets no problem from `content_problems`",
"implementation": "Add the keyword search_evidence to check_proposal in src/devops_cli/roadmap/stage_change.py, with no record by default so plan_check keeps its behaviour, and call search_problems with the groups and the record. In src/devops_cli/roadmap/stage.py record the evidence in _Planner._settle from the search callable before check_proposal runs, and record it again for the groups that a split gives",
"documentation": null,
"verify": "uv run devops ci test tests/roadmap/test_roadmap_stage_plan.py",
diff --git a/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/case.json b/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/case.json
index 51dbe89b6e..9499840ca1 100644
--- a/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/case.json
+++ b/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/case.json
@@ -19,6 +19,7 @@
"notes": [
"Group 3, which adds the `search_evidence` field, is the group that the twin lacks.",
"The merged plan came before the rule of #3331. The last group has the added task to run `uv run devops roadmap eval stage --replay` with the score before and after, so that the gate `paths` accepts the plan. The twin has the same task.",
+ "Group 2 has the test that builds the plan's own `StageProposal` and asserts that `content_problems` returns no problem, which the rule of #3404 asks. The twin has the same test.",
"The scores are set by hand. No review scored this plan."
],
"defects": []
diff --git a/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/plan.json b/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/plan.json
index e75f270019..8fcad22127 100644
--- a/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/plan.json
+++ b/tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/plan.json
@@ -202,7 +202,7 @@
],
"creates": [],
"creates_lines": {},
- "test": "Write tests/roadmap/test_roadmap_stage_plan.py first: check_proposal refuses a negative-search literal with no recorded hit, refuses a literal that a created source path keeps, and accepts a literal whose recorded hit survives the change",
+ "test": "Write tests/roadmap/test_roadmap_stage_plan.py first: check_proposal refuses a negative-search literal with no recorded hit, refuses a literal that a created source path keeps, and accepts a literal whose recorded hit survives the change, and the plan's own `StageProposal` gets no problem from `content_problems`",
"implementation": "Add the keyword search_evidence to check_proposal in src/devops_cli/roadmap/stage_change.py, with no record by default so plan_check keeps its behaviour, and call search_problems with the groups and the record. In src/devops_cli/roadmap/stage.py record the evidence in _Planner._settle from the search callable before check_proposal runs, and record it again for the groups that a split gives",
"documentation": null,
"verify": "uv run devops ci test tests/roadmap/test_roadmap_stage_plan.py",
diff --git a/tests/roadmap/test_roadmap_stage_content.py b/tests/roadmap/test_roadmap_stage_content.py
index 39a501d5a0..bbe9a71b7d 100644
--- a/tests/roadmap/test_roadmap_stage_content.py
+++ b/tests/roadmap/test_roadmap_stage_content.py
@@ -1,6 +1,7 @@
"""`devops roadmap stage`: a plan holds no placeholder text, quotes its probe, gives the cost of
its own code, keeps its summary whole (#3200), names no What Changes path that no group lists
-(#3411) and states the work of each task once (#3456)."""
+(#3411), states the work of each task once (#3456) and gives the test that accepts its own plan
+when it adds a rule of the plan check (#3404)."""
from __future__ import annotations
@@ -26,6 +27,11 @@
PROBE = "def f(): pass"
TREE = StagedTree(["src/devops_cli/sample.py", "tests/test_sample.py"])
MESSAGES_FILE = "src/devops_cli/lang/en/messages.py"
+PLAN_CHECK_FILE = "src/devops_cli/roadmap/stage_change.py"
+SELF_ACCEPTANCE_TEST = (
+ "Write a test that builds the plan's own `StageProposal` and asserts that `content_problems` "
+ "returns no problem for it"
+)
LIVING_SPEC = "openspec/specs/roadmap-stage/spec.md"
LIVING_SPEC_TREE = TREE.with_files([LIVING_SPEC])
@@ -34,6 +40,14 @@ def _check(proposal: StageProposal, **keywords: Any) -> list[str]:
return check_proposal(proposal, ["comment-thread"], TREE, **keywords)
+def _plan_that_adds_a_rule(test: str) -> StageProposal:
+ sample = make_stage_proposal()
+ group = sample.groups[0].model_copy(
+ update={"changes": [*sample.groups[0].changes, PLAN_CHECK_FILE], "test": test}
+ )
+ return make_stage_proposal(groups=[group])
+
+
def _group(**updates: Any) -> StageGroup:
"""The sample group with `updates`, which the schema does not check again."""
return make_stage_proposal().groups[0].model_copy(update=updates)
@@ -244,6 +258,33 @@ def test_a_what_changes_folder_that_a_group_writes_under_is_accepted() -> None:
assert not any("src/devops_cli/sample/" in p for p in problems)
+def test_a_rule_of_the_plan_check_needs_its_self_acceptance_test() -> None:
+ plan = _plan_that_adds_a_rule(
+ "Write `test_the_rule_refuses_the_plan` in `tests/roadmap/test_roadmap_stage_content.py`"
+ )
+
+ problems = content_problems(plan)
+
+ assert any("StageProposal" in p and "content_problems" in p for p in problems)
+
+
+def test_a_rule_of_the_plan_check_with_its_self_acceptance_test_is_accepted() -> None:
+ assert content_problems(_plan_that_adds_a_rule(SELF_ACCEPTANCE_TEST)) == []
+
+
+def test_a_plan_check_change_of_another_kind_needs_no_self_acceptance_test() -> None:
+ sample = make_stage_proposal()
+ group = sample.groups[0].model_copy(
+ update={
+ "kind": "other",
+ "changes": [*sample.groups[0].changes, PLAN_CHECK_FILE],
+ "test": None,
+ }
+ )
+
+ assert content_problems(make_stage_proposal(groups=[group])) == []
+
+
def test_two_tasks_of_one_group_that_state_the_same_work_are_refused() -> None:
group = _group(documentation="Keep the last comment in `src/devops_cli/sample.py`")
diff --git a/tests/roadmap/test_roadmap_stage_form.py b/tests/roadmap/test_roadmap_stage_form.py
index 9f585814ca..0eec21685a 100644
--- a/tests/roadmap/test_roadmap_stage_form.py
+++ b/tests/roadmap/test_roadmap_stage_form.py
@@ -37,6 +37,9 @@
"Give a command of one of these forms."
)
+PLAN_CHECK_FILE = "src/devops_cli/roadmap/stage_change.py"
+SELF_ACCEPTANCE = "`StageProposal` gets no problem from `content_problems`"
+
def _plan(*changes: str, creates: tuple[str, ...] = (), verify: str | None = None) -> StageProposal:
"""The sample proposal, with one group that changes `changes` and creates `creates`."""
@@ -50,6 +53,9 @@ def _plan(*changes: str, creates: tuple[str, ...] = (), verify: str | None = Non
sourced = any(path.startswith("src/") for path in changes)
if not sourced:
update |= {"kind": "other", "test": None}
+ elif PLAN_CHECK_FILE in changes:
+ # A plan that changes the plan check gives the test that accepts its own plan (#3404).
+ update["test"] = f"{base['test']}, and the plan's own {SELF_ACCEPTANCE}"
if verify is not None:
update["verify"] = verify
group = StageGroup.model_validate({**base, **update})
diff --git a/tests/roadmap/test_roadmap_stage_prompt_rules.py b/tests/roadmap/test_roadmap_stage_prompt_rules.py
index 2d7e5143d9..23ec81b8c3 100644
--- a/tests/roadmap/test_roadmap_stage_prompt_rules.py
+++ b/tests/roadmap/test_roadmap_stage_prompt_rules.py
@@ -258,6 +258,22 @@ def test_the_prompt_forbids_a_group_writing_a_change_folder_path() -> None:
assert "refuses a `changes` or `creates` path" in _PROMPT
+# ── The self-acceptance test of a plan rule (#3404) ──────────────────────────
+
+
+def test_the_prompt_states_the_self_acceptance_rule_of_a_plan() -> None:
+ """A plan that adds a rule of the plan check gives the test that accepts its own plan (#3404).
+ The rule does not exist when the stage job reads the plan, so the plan gives the test itself,
+ and the implement step runs it."""
+ prompt = load_task_prompt(_CHANGE_PROMPT)
+
+ assert "`StageProposal`" in prompt
+ assert "`content_problems`" in prompt
+ assert "A `behavior` group that changes `src/devops_cli/roadmap/stage_change.py`" in prompt
+ assert "builds the plan's own `StageProposal`" in prompt
+ assert "asserts that `content_problems` returns no problem" in prompt
+
+
# ── The spec delta ────────────────────────────────────────────────────────────