Repository navigation
Description
Problem or Motivation
Part 3 of 6 of #1335. It starts after part 2, which edits the same files.
TESTING.md says a package is tested in one file per behaviour, named for the behaviour, and a test name never lists branches. Four roadmap test files hold many behaviours. Measured at origin/main 29309f0:
| File | Lines | Tests |
|---|---|---|
tests/roadmap/test_roadmap_refine.py |
4,163 | 135 |
tests/roadmap/test_roadmap_run.py |
3,010 | 70 |
tests/roadmap/test_roadmap_intake.py |
2,505 | 100 |
tests/roadmap/test_roadmap_github_store.py |
1,730 | 87 |
Smaller files of the same family are already split by behaviour, for example test_roadmap_refine_trust.py, test_roadmap_refine_deferred.py and test_roadmap_stage_*.py. These four are the exceptions.
test_roadmap_store_contract.py (1,252 lines) is one contract suite with one subject. It stays.
A test file must not import another test file or a conftest (TESTING.md). Shared helpers and fixtures go to a module of tests/support/. Every module there is registered as a plugin, so a fixture added there needs no conftest edit. Do not add tests/roadmap/conftest.py. An edit of any conftest.py makes the narrowed test run cover the whole suite (TESTING.md).
Proposed Solution & Architectural Design
This part is a pure move. It changes no assertion and no production code.
- Group the tests of each file by the behaviour they check, in the glossary terms of CONTEXT.md. Name each new file after its behaviour, for example
test_roadmap_run_schedule.pyortest_roadmap_intake_duplicates.py. Do not name a file after an issue or a pull request. - Move each test with
git mvfor the first file and copy for the others, so the review shows the move. Keep the test bodies unchanged. - Move a helper that two or more new files use to a module of
tests/support/, for exampletests/support/roadmap_refine.py. A helper that one new file uses stays in that file. - If a test name lists branches or names a helper, rename it after the behaviour. Rename only when the name is wrong. List each rename in the pull request comment.
- Do not split a file that holds one behaviour only because it is long. If the grouping finds fewer than two behaviours in
test_roadmap_github_store.py, report that and leave the file.
Order: this part comes last in the roadmap series, so the earlier parts do not conflict with the moves.
Acceptance criteria
- The set of test node names after the change equals the set before. Only the file part of the id and the listed renames differ. The pull request comment shows both lists from
uv run pytest --collect-only -q tests/roadmapand their diff. - No file of
tests/roadmap/that this part touches holds more than one behaviour. Each new file name states its behaviour. - No new test file imports another test file or a conftest. No helper is copied twice. The import check of the full gate passes.
-
git diff -M --statshows the moves as renames. -
git diff -M origin/main -- tests/roadmap | grep '^[+-][^+-]'shows only import lines, moved helpers and listed renames. - No
conftest.pychanges in this part. -
uv run devops cipasses.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
pytest --collect-only and git diff -M check the move. No open tool groups tests by behaviour, because that needs a reader who knows the glossary. The cost to build is about 200,000 tokens, most of it to read 11,408 lines. It costs about 5,000 tokens a year to keep. The work takes about 1 day.
Strategic alignment: child of #1335. Parent #1307. Starts after part 2 of #1335. Related: #1336.
Proposed design
Problem statement
The four largest roadmap test files mix many behaviours in one file: test_roadmap_run.py, test_roadmap_refine.py, test_roadmap_intake.py and test_roadmap_github_store.py. This change moves their tests into files named for one behaviour each, with no change to an assertion or to production code. test_roadmap_store_contract.py is one contract suite for one subject and stays. The change is part 3 of 6 of #1335; part 2 (#3746) is merged, so it starts from the current subpackage paths.
Acceptance criteria
Requirement: Collected test node names stay the same
The change SHALL keep the multiset of collected test names equal to the base, and the collected test node ids SHALL differ only in the file part and the listed renames.
Scenario: Compare the collected node names
- WHEN
uv run pytest --collect-only -q tests/roadmapruns on the base commit and on the changed tree - THEN The diff of the two lists shows only file-path changes and the listed renames, and the pull request comment shows both lists and their diff.
Requirement: Each new test file holds one behaviour
Each new test file under tests/roadmap/ SHALL hold the tests of one behaviour and SHALL be named after that behaviour.
Scenario: Check the file names against the glossary
- WHEN A new test file is added under
tests/roadmap/ - THEN Its file name and its module docstring state the same one behaviour from
CONTEXT.md, and neither lists two branches or two behaviours.
Requirement: Shared helpers live in tests/support
A helper used by two or more new test files SHALL move to one tests/support/ module, and no helper SHALL be copied twice.
Scenario: Shared helper is imported once
- WHEN Two or more new test files use the same helper
- THEN Each file imports it from the same
tests/support/module, and no file defines a second copy.
Requirement: No test file imports another test file or a conftest
No new test file SHALL import another test file or a conftest.
Scenario: The module-independence check passes
- WHEN The
test-treerow ofuv run devops ciruns overtests/roadmap/ - THEN
tests/gate/tree_checks/module_independence.pyreports no import of atests/roadmap/test_*.pymodule and no import of a conftest.
Requirement: Git shows the moves as renames or copies
The change SHALL record each old test file's move with git mv so that git diff -M -C --stat shows it as a rename or a copy source.
Scenario: Rename and copy detection on the diff
- WHEN
git diff -M -C --statruns against the base commit - THEN Each of the four old test files appears as a rename or a copy source for the new files that hold its tests.
Requirement: Only imports, helper moves and listed renames differ
The content diff of tests/roadmap SHALL show no edited assertion or test body; every removed test body SHALL appear unchanged in a new file, except import lines, moved helpers and the listed renames.
Scenario: Content diff is limited
- WHEN
git diff -M -C origin/main -- tests/roadmap | grep '^[+-][^+-]'runs and each removed test body is compared with its new file - THEN Every changed line is an import line, a moved helper definition, a listed rename, or a test body that is identical in its new file.
Requirement: No conftest changes
The change SHALL NOT modify any conftest.py.
Scenario: Conftest files stay unchanged
- WHEN
git diff -M -C origin/main -- '**/conftest.py'runs - THEN It prints no changes.
Requirement: CI gate passes
The change SHALL pass uv run devops ci.
Scenario: Full CI gate passes
- WHEN
uv run devops ciruns on the pull request - THEN It exits with status 0.
Requirement: Single-behaviour store file stays
If grouping finds fewer than two behaviours in test_roadmap_github_store.py, the change SHALL leave that file in place and report the finding.
Scenario: Store file stays when it holds one behaviour
- WHEN Grouping finds fewer than two behaviours in
test_roadmap_github_store.py - THEN The file remains unchanged and the pull request comment states that it holds one behaviour.
Existing Tool Considered
pytest --collect-only, git mv, git diff -M -C and ruff check --select I --fix are open, maintained tools that do the mechanical part: pytest lists the node ids before and after, git records each move as a rename or a copy, and ruff rewrites the import lines. None of them groups tests by behaviour, because that needs a reader who knows the CONTEXT.md glossary, and the project's module-grouping change recorded that no open tool decides a grouping (openspec/changes/archive/2026-11-06-3187-group-the-job-modules-in-subpackages/proposal.md:45). A grouper built for this repository would cost about 200,000 tokens to build, most of it to read the four files, about 5,000 tokens a year to keep, and about 1 day of work.
Key questions
- Which test names should change?: Rename only a test whose name breaks
docs/TESTING.md: it names a helper, a private function or a double, lists two branches or behaviours, or uses a word thatCONTEXT.mdlists under Avoid. Rename it after the one behaviour it checks, in glossary terms, and list every rename in the pull request comment. Every other test keeps its name, so the collected node ids change only in the file part and the listed renames. (best practice) [sources: docs/TESTING.md:101, CONTEXT.md, openspec/changes/archive/2026-10-28-2545-security-tests-by-behaviour/proposal.md:18]- Chosen: Rename only the names that break the rule. docs/TESTING.md:101 names the rule, and the earlier behaviour split kept the moved tests' names and listed each renamed test (2545 proposal.md:18).
- Rejected: Rename every moved test to a new scheme. It changes node ids beyond the file part, makes the before-and-after node-name comparison unreadable, and adds churn that hides the move.
- Rejected: Keep every name, including the wrong ones. docs/TESTING.md:101 forbids a name that names a helper, a private function, a double or an Avoid word.
- Which test files does this part split, and where are they at the start commit?: The four files are
tests/roadmap/test_roadmap_run.py,tests/roadmap/refine/test_roadmap_refine.py,tests/roadmap/intake/test_roadmap_intake.pyandtests/roadmap/stores/test_roadmap_github_store.py. The refine, intake and store tests sit in the job subpackages that refactor(roadmap): group the job modules in subpackages #3187 made; the run tests stay at the top oftests/roadmap/. [sources: tests/roadmap/test_roadmap_run.py:1, tests/roadmap/refine/test_roadmap_refine.py:1, tests/roadmap/intake/test_roadmap_intake.py:1, tests/roadmap/stores/test_roadmap_github_store.py:1, openspec/changes/archive/2026-11-06-3187-group-the-job-modules-in-subpackages/tasks.md:35] - Does
test_roadmap_github_store.pyhold more than one behaviour, and does the store contract suite stay?:test_roadmap_github_store.pyholds several behaviours: recorded listings, paging, early stops, failed pages, milestone and issue writes, and the lock. It is split.test_roadmap_store_contract.pyis one contract suite for one subject, theRoadmapStorepromises, so it stays whole. [sources: tests/roadmap/stores/test_roadmap_github_store.py:1, tests/roadmap/stores/test_roadmap_github_store.py:159, tests/roadmap/stores/test_roadmap_store_contract.py:1] - Where should shared helpers and fixtures live?: Put a helper that two or more new test files use in one module under
tests/support/, for exampletests/support/roadmap_refine.py. Keep a helper used by one file in that file. Do not addtests/roadmap/conftest.py: a conftest change makes a narroweddevops ci testrun the whole suite, while everytests/support/module is registered as a plugin and needs no conftest edit. (best practice) [sources: docs/TESTING.md:94, docs/TESTING.md:96, docs/TESTING.md:159, tests/support/roadmap_trust.py:1]- Chosen: Move shared helpers to tests/support. docs/TESTING.md:94 and :96 put shared helpers and fixtures there, and a support module is a plugin with no conftest edit.
- Rejected: Add tests/roadmap/conftest.py. docs/TESTING.md:159 makes any conftest change run the whole suite, and the issue forbids a new roadmap conftest.
- Rejected: Copy the helper into each file. The issue forbids a helper copied twice, and a copy drifts from the original.
- How should the moves be recorded so the review shows them?: For each old file,
git mvit to the new file that keeps most of its tests, then copy that file for the other behaviour files and delete the tests that do not belong. Check withgit diff -M -C --stat:-Mfinds the rename and-Cfinds the copies.-Malone pairs only one deleted file with one added file by a similarity guess, so a split into several files does not show as renames. (best practice) [sources: openspec/changes/archive/2026-11-06-3187-group-the-job-modules-in-subpackages/design.md:8, openspec/changes/archive/2026-10-31-1313-tests-mirror-source-tree/proposal.md:35, openspec/changes/archive/2026-10-30-2804-step-keeps-existing-tests/design.md:21]- Chosen: git mv to the primary file, then copies, checked with git diff -M -C. 3187 design.md:8 records a move with
git mvso git shows a rename, and 2804 design.md:21 shows that-Malone pairs one deleted file with one added file by a similarity guess, so a split needs-Cfor the copies. - Rejected: Delete each old file and add every new file. It loses the rename and copy evidence, so the review cannot see the move.
- Rejected: Check only git diff -M. 2804 design.md:21:
-Mpairs a deleted file with an added file by a similarity guess, so the other files of a split show as new files.
- Chosen: git mv to the primary file, then copies, checked with git diff -M -C. 3187 design.md:8 records a move with
- Should this part use one pull request?: Use one pull request. The change is a pure move with no assertion or production-code change, and earlier behaviour splits of this size used one pull request. (best practice) [sources: openspec/changes/archive/2026-10-28-2545-security-tests-by-behaviour/proposal.md:26, openspec/changes/archive/2026-11-06-3765-mcp-test-files-by-behavior/proposal.md:30]
- Chosen: One pull request for the four files. 2545 proposal.md:26 and 3765 proposal.md:30 each put a behaviour split of several test files in one pull request, and the node-name and rename review belong together.
- Rejected: One pull request per test file. It repeats the same checks four times and adds coordination without reducing the move risk.
- Does this part still wait on part 2 of test(infra): infrastructure tests run on edge fakes #1335?: No. Part 2 is test(roadmap): roadmap tests take their store from one hook #3746, and its change folder is archived; its tasks name part 3 as the next step. The dependency is done, so
dependenciesis empty. [sources: openspec/changes/archive/2026-11-07-3746-roadmap-tests-install-store-hook/proposal.md:5, openspec/changes/archive/2026-11-07-3746-roadmap-tests-install-store-hook/tasks.md:39] - Does an open, maintained tool group tests by behaviour?: No. The project's module-grouping change recorded that no open tool decides a grouping, because that is a person's judgement;
pytest --collect-only,git mv,git diff -M -Candruff check --select I --fixcover only the mechanical checks. A grouper built for this repository would cost about 200,000 tokens to build, about 5,000 tokens a year to keep, and about 1 day of work. [sources: openspec/changes/archive/2026-11-06-3187-group-the-job-modules-in-subpackages/proposal.md:45, openspec/changes/archive/2026-11-06-3765-mcp-test-files-by-behavior/proposal.md:52, docs/TESTING.md:101]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(roadmap)scope of the title gives the scope.It improves test maintainability but changes no behaviour and is one part of a six-part series.It makes four large test files easier to read and change, which helps all roadmap test work.It requires reading and moving roughly 11,400 lines across four files, splitting helpers, and verifying no assertion changes.Both organize roadmap code by logical group, but #3187 groups source modules into subpackages while the candidate splits test files by behaviour.devops-cli-service commentedon Nov 7, 2026
Status set to Ready at 72c52c6 (see proposed design in issue body).
test(infra): infrastructure tests run on edge fakes (#4283)