From 032f0408620abd199f761ed6e6f45c45c21f075e Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Sun, 15 Nov 2026 19:05:50 +0000 Subject: [PATCH 1/3] feat(roadmap): require the workflow contract test in the group that changes the workflow (#4083) --- .../.openspec.yaml | 3 ++ .../design.md | 27 ++++++++++ .../proposal.md | 42 +++++++++++++++ .../specs/roadmap-stage/paths-gate/spec.md | 27 ++++++++++ .../tasks.md | 7 +++ .../specs/roadmap-stage/paths-gate/spec.md | 26 +++++++++ .../ai/tasks/roadmap_stage_change.md | 1 + src/devops_cli/lang/en/messages.py | 5 ++ src/devops_cli/roadmap/stage/stage_paths.py | 21 ++++++++ .../roadmap/stage/test_roadmap_stage_paths.py | 53 +++++++++++++++++++ .../stage/test_roadmap_stage_prompt_rules.py | 14 ++++- 11 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/.openspec.yaml create mode 100644 openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md create mode 100644 openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md create mode 100644 openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md create mode 100644 openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/.openspec.yaml b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/.openspec.yaml new file mode 100644 index 0000000000..71884884ae --- /dev/null +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/.openspec.yaml @@ -0,0 +1,3 @@ +schema: spec-driven +created: 2026-11-15 +skip_specs: false diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md new file mode 100644 index 0000000000..030eb5b53d --- /dev/null +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md @@ -0,0 +1,27 @@ +# Design: #4083 + +## Context + +`path_problems` reads the groups and the staged tree and returns the problems of a plan. The stage +job passes it the tree at the staging commit; the eval replay passes it the tree of the case. A +workflow change is an `other` group, so it has no `test` field, but it can list any path in +`changes`. + +## Decisions + +- The rule lives in `workflow_contract_problems`, a new function that `path_problems` calls. The + function reads `changes` only, so a group that reads a workflow and changes no workflow needs no + contract test, and the `reads` of a group do not satisfy the rule. +- The workflow directory and the contract test path are module constants, + `WORKFLOW_DIRECTORY` and `WORKFLOW_CONTRACT_TEST`, so the prompt test reads the same text as the + rule. +- The message names the group, the workflow and the contract test, so one sentence is enough to + repair the plan. + +## Risks + +- A change that edits no contract test but is covered by an existing assertion in + `tests/invariants/test_workflow_contracts.py` still needs the file in `changes`. The prompt says + so, and a pin bump that an existing assertion holds fails the rule. The owner can relax the rule + if that case becomes common. +- The rule reads the suffix `.yml` only, as the repository holds no `.yaml` workflow. diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md new file mode 100644 index 0000000000..4f4438c2a1 --- /dev/null +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md @@ -0,0 +1,42 @@ +# Proposal: #4083 + +## Why + +The stage planner can put an edit of `.github/workflows/ci.yml` in one group and the workflow +contract test in a later group, or in no group. The group then verifies the workflow with +actionlint and zizmor, which pass on the base commit and read no step of the change. AGENTS.md +rule 4 asks for the test first, and the contract test is the executable test of a workflow +change. Closes #4083. + +## What Changes + +- `path_problems` in `src/devops_cli/roadmap/stage/stage_paths.py` reports a problem for each + `.github/workflows/*.yml` file that a group changes when the `changes` of that group holds no + `tests/invariants/test_workflow_contracts.py`. +- The stage planner prompt tells the model the same rule, so it writes the contract case in the + group that makes the change. +- A message, `roadmap.stage_problem_workflow_contract`, names the group, the workflow and the + contract test. + +## Capabilities + +`roadmap-stage/paths-gate`: a new requirement for the workflow contract rule, and one for the +prompt. + +## Impact + +The stage job and the stage eval replay. No command or option changes. The prompt gets one +instruction. The golden set holds no `good` plan that changes a workflow, so the replay still +passes. + +## Feasibility + +Premise checked on 2026-11-15 against `origin/main` (ca62d6a9f): `path_problems` holds no rule for +`.github/workflows/`, and the case `2163-coverage-measures-branches-and-ci-keeps` holds a group +that changes `.github/workflows/ci.yml` with no contract test. The new tests fail before the +change and pass after it. + +## Existing Tool Considered + +The rule extends `path_problems`, which the stage job already calls. actionlint and zizmor read +the syntax of the workflow only, so they cannot replace the contract test. No new tool. diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md new file mode 100644 index 0000000000..da640eedbf --- /dev/null +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md @@ -0,0 +1,27 @@ +## ADDED Requirements + +### Requirement: A workflow change carries its contract test in the same group +`path_problems` SHALL report a problem for each file under `.github/workflows/` with the suffix `.yml` that a group lists in `changes` when the `changes` of that group holds no `tests/invariants/test_workflow_contracts.py`. The problem SHALL name the group, the workflow and the contract test. The rule SHALL read `changes` only, so a group that reads a workflow and changes no workflow needs no contract test. + +#### Scenario: A workflow change without the contract test +- **WHEN** a group lists `.github/workflows/ci.yml` in `changes` and holds no `tests/invariants/test_workflow_contracts.py` +- **THEN** `path_problems` returns one problem, and it names the group, the workflow and the contract test + +#### Scenario: A workflow change with the contract test +- **WHEN** a group lists `.github/workflows/ci.yml` and `tests/invariants/test_workflow_contracts.py` in `changes` +- **THEN** `path_problems` returns no problem for the workflow contract rule + +#### Scenario: A source change that reads a workflow +- **WHEN** a group reads `.github/workflows/ci.yml` and changes only a file under `src/` +- **THEN** `path_problems` returns no problem for the workflow contract rule + +#### Scenario: Each workflow file of a group +- **WHEN** a group lists `.github/workflows/ci.yml` and `.github/workflows/release.yml` in `changes` and holds no contract test +- **THEN** `path_problems` returns one problem for each workflow file + +### Requirement: The stage prompt asks for the contract test of a workflow change +The stage prompt `src/devops_cli/ai/tasks/roadmap_stage_change.md` SHALL tell the model that a group that changes a file under `.github/workflows/` lists `tests/invariants/test_workflow_contracts.py` in `changes` in the same group. + +#### Scenario: The planner reads the prompt +- **WHEN** the stage planner prompt is read +- **THEN** it holds the workflow directory and the contract test path in one instruction diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md new file mode 100644 index 0000000000..8afdb96c4e --- /dev/null +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md @@ -0,0 +1,7 @@ +# Tasks: #4083 + +- [x] 1.1 Add `workflow_contract_problems` and its message, and call it from `path_problems`. +- [x] 1.2 Add the four tests of the rule to `tests/roadmap/stage/test_roadmap_stage_paths.py`. +- [x] 2.1 Add the rule to `src/devops_cli/ai/tasks/roadmap_stage_change.md`. +- [x] 2.2 Add the prompt test to `tests/roadmap/stage/test_roadmap_stage_prompt_rules.py`. +- [x] 3.1 Run the stage path, prompt and eval gate tests, and the static gate. diff --git a/openspec/specs/roadmap-stage/paths-gate/spec.md b/openspec/specs/roadmap-stage/paths-gate/spec.md index 62175b1b66..fc1eeb2d24 100644 --- a/openspec/specs/roadmap-stage/paths-gate/spec.md +++ b/openspec/specs/roadmap-stage/paths-gate/spec.md @@ -341,3 +341,29 @@ The stage job SHALL treat a Python module as moved only when a task group lists #### Scenario: A group moves a module into a sub-package - **WHEN** a group lists `src/devops_cli/roadmap/stage_probe.py` in `changes` and creates `src/devops_cli/roadmap/stage/probe.py`. - **THEN** the group moves `src/devops_cli/roadmap/stage_probe.py`, with the dotted name `devops_cli.roadmap.stage_probe`. + +### Requirement: A workflow change carries its contract test in the same group +`path_problems` SHALL report a problem for each file under `.github/workflows/` with the suffix `.yml` that a group lists in `changes` when the `changes` of that group holds no `tests/invariants/test_workflow_contracts.py`. The problem SHALL name the group, the workflow and the contract test. The rule SHALL read `changes` only, so a group that reads a workflow and changes no workflow needs no contract test. + +#### Scenario: A workflow change without the contract test +- **WHEN** a group lists `.github/workflows/ci.yml` in `changes` and holds no `tests/invariants/test_workflow_contracts.py` +- **THEN** `path_problems` returns one problem, and it names the group, the workflow and the contract test + +#### Scenario: A workflow change with the contract test +- **WHEN** a group lists `.github/workflows/ci.yml` and `tests/invariants/test_workflow_contracts.py` in `changes` +- **THEN** `path_problems` returns no problem for the workflow contract rule + +#### Scenario: A source change that reads a workflow +- **WHEN** a group reads `.github/workflows/ci.yml` and changes only a file under `src/` +- **THEN** `path_problems` returns no problem for the workflow contract rule + +#### Scenario: Each workflow file of a group +- **WHEN** a group lists `.github/workflows/ci.yml` and `.github/workflows/release.yml` in `changes` and holds no contract test +- **THEN** `path_problems` returns one problem for each workflow file + +### Requirement: The stage prompt asks for the contract test of a workflow change +The stage prompt `src/devops_cli/ai/tasks/roadmap_stage_change.md` SHALL tell the model that a group that changes a file under `.github/workflows/` lists `tests/invariants/test_workflow_contracts.py` in `changes` in the same group. + +#### Scenario: The planner reads the prompt +- **WHEN** the stage planner prompt is read +- **THEN** it holds the workflow directory and the contract test path in one instruction diff --git a/src/devops_cli/ai/tasks/roadmap_stage_change.md b/src/devops_cli/ai/tasks/roadmap_stage_change.md index 4e9c860fc7..fdb8918ae7 100644 --- a/src/devops_cli/ai/tasks/roadmap_stage_change.md +++ b/src/devops_cli/ai/tasks/roadmap_stage_change.md @@ -24,6 +24,7 @@ The rules of the project: - Put a change to a schema enum or constant in the same group as the prompt or document update that describes it, when an invariant test compares the two. A group that adds an enum value without its prompt text fails that test alone, and the step stops. - 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`, `manifest` 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 or case 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. +- A group that changes a file under `.github/workflows/` also lists `tests/invariants/test_workflow_contracts.py` in `changes`, because actionlint and zizmor pass without a test of the change, and the contract case belongs in the group that makes the change. Write the case first, and let the `verify` of the group run it. - 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. A `manifest` group creates or changes a rule file, a dashboard file or a case file. It has a `test` that names the failing case to write first, and its `verify` is `uv run devops ci test` followed by a path of the group or its folder. It has no `process`. A group that creates or changes a case path must use the `manifest` kind. 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 group gives one exact change: the planner names the failing test that the change updates in a code span, or it plans no group. A group never fixes a test only if it breaks. - 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/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 changes a `roadmap_stage_*.md` prompt lists `tests/roadmap/stage/test_roadmap_stage_prompt_rules.py` in `reads` or `changes` and gives it as `verify`. The check refuses a prompt change that cites no prompt-rule test. diff --git a/src/devops_cli/lang/en/messages.py b/src/devops_cli/lang/en/messages.py index 369cddb63a..73faf31331 100644 --- a/src/devops_cli/lang/en/messages.py +++ b/src/devops_cli/lang/en/messages.py @@ -5114,6 +5114,11 @@ class RoadmapMessages: "to `reads`, to the `Changes:` line or to a task of the group: the implement job cannot " "edit a test that the plan leaves out." ) + stage_problem_workflow_contract: str = ( + "Group {group} changes the workflow `{path}` and its `changes` holds no `{test}`. Add " + "the contract test to `changes`, and write its case in this group: actionlint and " + "zizmor pass without a test of the change." + ) stage_problem_constant_mismatch: str = ( "{constant} is {staged} in the staged tree, but the plan says {plan}." ) diff --git a/src/devops_cli/roadmap/stage/stage_paths.py b/src/devops_cli/roadmap/stage/stage_paths.py index 117898b3fa..07ee110ee1 100644 --- a/src/devops_cli/roadmap/stage/stage_paths.py +++ b/src/devops_cli/roadmap/stage/stage_paths.py @@ -660,6 +660,26 @@ def existing_test_problems( return problems +WORKFLOW_DIRECTORY = ".github/workflows/" +WORKFLOW_CONTRACT_TEST = "tests/invariants/test_workflow_contracts.py" + + +def workflow_contract_problems(groups: Sequence[StageGroup]) -> list[str]: + """One sentence for each workflow that a group changes without the contract test of + `tests/invariants/test_workflow_contracts.py` in the `changes` of the same group (#4083). + Actionlint and zizmor pass on a workflow that no contract test reads, and a later group + leaves the change with no test in the group that makes it.""" + return [ + MESSAGES.roadmap.stage_problem_workflow_contract.format( + group=number, path=path, test=WORKFLOW_CONTRACT_TEST + ) + for number, group in enumerate(groups, start=1) + if WORKFLOW_CONTRACT_TEST not in group.changes + for path in group.changes + if path.startswith(WORKFLOW_DIRECTORY) and path.endswith(".yml") + ] + + def path_problems( groups: Sequence[StageGroup], tree: StagedTree, @@ -699,6 +719,7 @@ def path_problems( reported.add(path) problems.append(_problem(number, place, path, tree, creators.get(path))) problems.extend(caller_problems(groups, tree)) + problems.extend(workflow_contract_problems(groups)) if references is not None: problems.extend(missing_reference_problems(groups, references)) return problems diff --git a/tests/roadmap/stage/test_roadmap_stage_paths.py b/tests/roadmap/stage/test_roadmap_stage_paths.py index 3e2b18714c..abc3086afb 100644 --- a/tests/roadmap/stage/test_roadmap_stage_paths.py +++ b/tests/roadmap/stage/test_roadmap_stage_paths.py @@ -67,6 +67,59 @@ def _problems(*groups: StageGroup, tree: StagedTree = TREE) -> list[str]: return path_problems(groups, tree) +WORKFLOW = ".github/workflows/sample.yml" +CONTRACT_TEST = "tests/invariants/test_workflow_contracts.py" +WORKFLOW_TREE = StagedTree( + [ + "README.md", + "src/devops_cli/sample.py", + "tests/test_sample.py", + ".github/workflows/sample.yml", + "tests/invariants/test_workflow_contracts.py", + ] +) + + +# ── A workflow change carries its contract test in the same group (#4083) ────── + + +def test_a_workflow_change_without_the_contract_test_is_a_problem() -> None: + group = _group(changes=[WORKFLOW], reads=[]) + + (problem,) = path_problems([group], WORKFLOW_TREE) + + assert (f"`{WORKFLOW}`" in problem, f"`{CONTRACT_TEST}`" in problem, "Group 1" in problem) == ( + True, + True, + True, + ) + + +def test_a_workflow_change_with_the_contract_test_passes() -> None: + group = _group(changes=[WORKFLOW, CONTRACT_TEST], reads=[]) + + assert path_problems([group], WORKFLOW_TREE) == [] + + +def test_group_that_reads_a_workflow_and_changes_no_workflow_needs_no_contract_test() -> None: + group = _group(reads=[WORKFLOW]) + + assert path_problems([group], WORKFLOW_TREE) == [] + + +def test_each_workflow_file_of_a_group_needs_the_contract_test() -> None: + workflows = [".github/workflows/ci.yml", ".github/workflows/release.yml"] + tree = StagedTree([*WORKFLOW_TREE.files, *workflows]) + group = _group(changes=workflows, reads=[]) + + problems = path_problems([group], tree) + + assert [any(workflow in problem for problem in problems) for workflow in workflows] == [ + True, + True, + ] + + # ── A path that is a file, or that a group creates ──────────────────────────── diff --git a/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py b/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py index 648d1fe55c..b87219d0bf 100644 --- a/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py +++ b/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py @@ -41,7 +41,11 @@ ) from devops_cli.roadmap.stage.stage_criteria import PENDING_PERSON, StageCriterion from devops_cli.roadmap.stage.stage_form import form_problems -from devops_cli.roadmap.stage.stage_paths import StagedTree +from devops_cli.roadmap.stage.stage_paths import ( + WORKFLOW_CONTRACT_TEST, + WORKFLOW_DIRECTORY, + StagedTree, +) from tests.support.builders import make_stage_proposal, stage_summary_limit from tests.support.paths import REPO_ROOT @@ -912,3 +916,11 @@ def test_the_stage_prompt_names_the_declared_dependencies() -> None: "issue_dependencies" in _PROMPT, "#: " in _PROMPT, ) == (True, True) + + +def test_the_prompt_asks_for_the_contract_test_of_a_workflow_change() -> None: + """A group that changes a workflow names the contract test in the same group (#4083).""" + assert ( + f"`{WORKFLOW_DIRECTORY}`" in _PROMPT, + f"`{WORKFLOW_CONTRACT_TEST}`" in _PROMPT, + ) == (True, True) From 11fb630c8d4750213fe6c23b45960e940c069238 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Sun, 15 Nov 2026 19:15:23 +0000 Subject: [PATCH 2/3] fix(roadmap): keep the workflow cases of the stage plan tests green (#4083) --- tests/roadmap/stage/test_roadmap_stage_form.py | 5 ++++- tests/roadmap/stage/test_roadmap_stage_plan.py | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/roadmap/stage/test_roadmap_stage_form.py b/tests/roadmap/stage/test_roadmap_stage_form.py index aea972d105..3271b9fbf4 100644 --- a/tests/roadmap/stage/test_roadmap_stage_form.py +++ b/tests/roadmap/stage/test_roadmap_stage_form.py @@ -408,8 +408,11 @@ def _example_paths(text: str) -> list[str]: def _mirrored(path: str) -> bool: - """Whether the folder of `path` sits under `tests/` and mirrors a package of `src/devops_cli`.""" + """Whether the folder of `path` sits under `tests/` and mirrors a package of `src/devops_cli`, + or is the acceptance folder of the invariants (#4083).""" folder = Path(path).parent + if folder == Path("tests/invariants"): + return True package = REPO_ROOT / "src" / "devops_cli" / folder.relative_to("tests") return folder != Path("tests") and package.is_dir() diff --git a/tests/roadmap/stage/test_roadmap_stage_plan.py b/tests/roadmap/stage/test_roadmap_stage_plan.py index ab9f353f1c..534758fd7e 100644 --- a/tests/roadmap/stage/test_roadmap_stage_plan.py +++ b/tests/roadmap/stage/test_roadmap_stage_plan.py @@ -62,7 +62,7 @@ ) from devops_cli.roadmap.stage.stage_criteria import StageCriterion from devops_cli.roadmap.stage.stage_left_out import LeftOutKind -from devops_cli.roadmap.stage.stage_paths import StagedTree +from devops_cli.roadmap.stage.stage_paths import WORKFLOW_CONTRACT_TEST, StagedTree from devops_cli.roadmap.stage.stage_plan_record import delete_plan_record, plan_record_path from devops_cli.roadmap.stage.stage_references import reference_answer, reference_files from devops_cli.roadmap.stage.stage_registry import RegistryCount, registry_table @@ -2151,10 +2151,16 @@ def _tree(*paths: str) -> StagedTree: def _changing(*paths: str) -> StageProposal: - """The sample proposal, with one group that changes only `paths`.""" + """The sample proposal, with one group that changes only `paths`. A workflow change also lists + the contract test that the path rule needs (#4083).""" + listed = ( + (*paths, WORKFLOW_CONTRACT_TEST) + if any(path.startswith(".github/workflows/") for path in paths) + else paths + ) return make_stage_proposal( - groups=[_changed("Change the paths", *paths)], - what_changes=[f"`{path}` changes." for path in paths], + groups=[_changed("Change the paths", *listed)], + what_changes=[f"`{path}` changes." for path in listed], ) @@ -2162,7 +2168,9 @@ def _changing(*paths: str) -> StageProposal: def test_a_spec_delta_on_a_change_of_tests_workflows_documents_or_plans_is_refused( path: str, ) -> None: - assert check_proposal(_changing(path), [], _tree(path), registry=()) == [NO_SPEC_PROBLEM] + assert check_proposal( + _changing(path), [], _tree(path, WORKFLOW_CONTRACT_TEST), registry=() + ) == [NO_SPEC_PROBLEM] def test_a_spec_delta_on_every_path_of_every_group_that_needs_none_is_refused() -> None: From aea1df120aaca8f8eec74bd019177661f9314dc7 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Sun, 15 Nov 2026 19:35:46 +0000 Subject: [PATCH 3/3] fix(roadmap): enforce the workflow contract test without a prompt edit (#4083) --- .../design.md | 9 ++++----- .../proposal.md | 8 ++------ .../specs/roadmap-stage/paths-gate/spec.md | 7 ------- .../tasks.md | 4 +--- src/devops_cli/ai/tasks/roadmap_stage_change.md | 1 - .../stage/test_roadmap_stage_prompt_rules.py | 14 +------------- 6 files changed, 8 insertions(+), 35 deletions(-) diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md index 030eb5b53d..1c29a2aff5 100644 --- a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/design.md @@ -13,15 +13,14 @@ workflow change is an `other` group, so it has no `test` field, but it can list function reads `changes` only, so a group that reads a workflow and changes no workflow needs no contract test, and the `reads` of a group do not satisfy the rule. - The workflow directory and the contract test path are module constants, - `WORKFLOW_DIRECTORY` and `WORKFLOW_CONTRACT_TEST`, so the prompt test reads the same text as the - rule. + `WORKFLOW_DIRECTORY` and `WORKFLOW_CONTRACT_TEST`, so the message and the rule read one text. - The message names the group, the workflow and the contract test, so one sentence is enough to repair the plan. ## Risks - A change that edits no contract test but is covered by an existing assertion in - `tests/invariants/test_workflow_contracts.py` still needs the file in `changes`. The prompt says - so, and a pin bump that an existing assertion holds fails the rule. The owner can relax the rule - if that case becomes common. + `tests/invariants/test_workflow_contracts.py` still needs the file in `changes`, and a pin bump + that an existing assertion holds fails the rule. The owner can relax the rule if that case + becomes common. - The rule reads the suffix `.yml` only, as the repository holds no `.yaml` workflow. diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md index 4f4438c2a1..4bf2638226 100644 --- a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/proposal.md @@ -13,20 +13,16 @@ change. Closes #4083. - `path_problems` in `src/devops_cli/roadmap/stage/stage_paths.py` reports a problem for each `.github/workflows/*.yml` file that a group changes when the `changes` of that group holds no `tests/invariants/test_workflow_contracts.py`. -- The stage planner prompt tells the model the same rule, so it writes the contract case in the - group that makes the change. - A message, `roadmap.stage_problem_workflow_contract`, names the group, the workflow and the contract test. ## Capabilities -`roadmap-stage/paths-gate`: a new requirement for the workflow contract rule, and one for the -prompt. +`roadmap-stage/paths-gate`: one new requirement for the workflow contract rule. ## Impact -The stage job and the stage eval replay. No command or option changes. The prompt gets one -instruction. The golden set holds no `good` plan that changes a workflow, so the replay still +The stage job and the stage eval replay. No command or option changes. The golden set holds no `good` plan that changes a workflow, so the replay still passes. ## Feasibility diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md index da640eedbf..1174ce6f81 100644 --- a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/specs/roadmap-stage/paths-gate/spec.md @@ -18,10 +18,3 @@ #### Scenario: Each workflow file of a group - **WHEN** a group lists `.github/workflows/ci.yml` and `.github/workflows/release.yml` in `changes` and holds no contract test - **THEN** `path_problems` returns one problem for each workflow file - -### Requirement: The stage prompt asks for the contract test of a workflow change -The stage prompt `src/devops_cli/ai/tasks/roadmap_stage_change.md` SHALL tell the model that a group that changes a file under `.github/workflows/` lists `tests/invariants/test_workflow_contracts.py` in `changes` in the same group. - -#### Scenario: The planner reads the prompt -- **WHEN** the stage planner prompt is read -- **THEN** it holds the workflow directory and the contract test path in one instruction diff --git a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md index 8afdb96c4e..cad8c33822 100644 --- a/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md +++ b/openspec/changes/archive/2026-11-15-4083-workflow-change-requires-contract-test/tasks.md @@ -2,6 +2,4 @@ - [x] 1.1 Add `workflow_contract_problems` and its message, and call it from `path_problems`. - [x] 1.2 Add the four tests of the rule to `tests/roadmap/stage/test_roadmap_stage_paths.py`. -- [x] 2.1 Add the rule to `src/devops_cli/ai/tasks/roadmap_stage_change.md`. -- [x] 2.2 Add the prompt test to `tests/roadmap/stage/test_roadmap_stage_prompt_rules.py`. -- [x] 3.1 Run the stage path, prompt and eval gate tests, and the static gate. +- [x] 2.1 Run the stage path, prompt and eval gate tests, and the static gate. diff --git a/src/devops_cli/ai/tasks/roadmap_stage_change.md b/src/devops_cli/ai/tasks/roadmap_stage_change.md index fdb8918ae7..4e9c860fc7 100644 --- a/src/devops_cli/ai/tasks/roadmap_stage_change.md +++ b/src/devops_cli/ai/tasks/roadmap_stage_change.md @@ -24,7 +24,6 @@ The rules of the project: - Put a change to a schema enum or constant in the same group as the prompt or document update that describes it, when an invariant test compares the two. A group that adds an enum value without its prompt text fails that test alone, and the step stops. - 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`, `manifest` 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 or case 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. -- A group that changes a file under `.github/workflows/` also lists `tests/invariants/test_workflow_contracts.py` in `changes`, because actionlint and zizmor pass without a test of the change, and the contract case belongs in the group that makes the change. Write the case first, and let the `verify` of the group run it. - 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. A `manifest` group creates or changes a rule file, a dashboard file or a case file. It has a `test` that names the failing case to write first, and its `verify` is `uv run devops ci test` followed by a path of the group or its folder. It has no `process`. A group that creates or changes a case path must use the `manifest` kind. 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 group gives one exact change: the planner names the failing test that the change updates in a code span, or it plans no group. A group never fixes a test only if it breaks. - 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/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 changes a `roadmap_stage_*.md` prompt lists `tests/roadmap/stage/test_roadmap_stage_prompt_rules.py` in `reads` or `changes` and gives it as `verify`. The check refuses a prompt change that cites no prompt-rule test. diff --git a/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py b/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py index b87219d0bf..648d1fe55c 100644 --- a/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py +++ b/tests/roadmap/stage/test_roadmap_stage_prompt_rules.py @@ -41,11 +41,7 @@ ) from devops_cli.roadmap.stage.stage_criteria import PENDING_PERSON, StageCriterion from devops_cli.roadmap.stage.stage_form import form_problems -from devops_cli.roadmap.stage.stage_paths import ( - WORKFLOW_CONTRACT_TEST, - WORKFLOW_DIRECTORY, - StagedTree, -) +from devops_cli.roadmap.stage.stage_paths import StagedTree from tests.support.builders import make_stage_proposal, stage_summary_limit from tests.support.paths import REPO_ROOT @@ -916,11 +912,3 @@ def test_the_stage_prompt_names_the_declared_dependencies() -> None: "issue_dependencies" in _PROMPT, "#: " in _PROMPT, ) == (True, True) - - -def test_the_prompt_asks_for_the_contract_test_of_a_workflow_change() -> None: - """A group that changes a workflow names the contract test in the same group (#4083).""" - assert ( - f"`{WORKFLOW_DIRECTORY}`" in _PROMPT, - f"`{WORKFLOW_CONTRACT_TEST}`" in _PROMPT, - ) == (True, True)