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
Expand Up @@ -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 <base>..HEAD).
29 changes: 29 additions & 0 deletions openspec/specs/roadmap-stage/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
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 @@ -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 <name> 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.
Expand Down
7 changes: 7 additions & 0 deletions src/devops_cli/lang/en/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
34 changes: 32 additions & 2 deletions src/devops_cli/roadmap/stage_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`."""
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
Expand Down
Loading
Loading