Repository navigation
Description
Problem or Motivation
81 groups (199 tests) run one identical job scenario and check different facts. The tests have the same arrange, the same run lines and the same branch arcs (measured from coverage contexts). For example, tests/roadmap/implement/test_roadmap_implement_job.py:278, 307, 439, 524 and 545 all run job_world.run(two_groups()).
One run per group saves 499.3 s in a local full run with per-test coverage contexts, which is 60-140 s of CI worker time before the registry fix (estimated). Changed-Test Independence runs each changed file 3 times, so it gains 3 times as much.
Saving: 60-140 s of CI worker time before the registry fix (estimated). The saving is smaller after it.
Found by the CI and test audit of 2026-11-11. The account runs at most 20 hosted jobs at one time (measured), so each job that does no work makes the queue of each pull request longer.
Proposed Solution & Architectural Design
- After perf(test): stage gate tests parse every test file per call #4509, measure the groups again and report the saving in this issue.
- In each group, one test runs the scenario and checks each fact in a
subtests.test('<behaviour>')block. - Fold a test that shares only a prefix of the scenario only after you read it.
Risk: Low. Test ids change. The reviewer must accept the subtest form (docs/TESTING.md allows consecutive asserts).
Target Subsystem
SDLC, Git & PR Governance (tests/roadmap/implement/).
Existing Tool Considered
The subtests fixture, built into pytest (9.2.0 is the pinned version). It works under xdist (measured: the report names a failing subtest). No new tool. Cost: about 60,000 tokens and 4 hours.
Acceptance Criteria
- This issue holds the saving measured after perf(test): stage gate tests parse every test file per call #4509.
- Each folded fact keeps its behaviour name as a subtest label.
- The changed files run faster by the measured saving.
Dependencies
Depends on #4509.
Alternatives check of 2026-11-30: not-applicable.
Class: test, no model call.
Tool: none found.
Proposed design
Problem statement
The change folds each implement test group into one scenario run with pytest subtests. The package has 81 groups of 199 tests. Each group runs the same job scenario and checks different facts. One run per group saves 499.3 s in a local full run with per-test coverage contexts, and 60-140 s of CI worker time before the registry fix. The change depends on #4509 for the measurement. A test-tree check holds the run count and the subtest form.
Acceptance criteria
Requirement: Folded modules pass
Each folded test module of tests/roadmap/implement/ MUST pass after the fold.
Scenario: The implement test package passes
- WHEN
uv run pytest tests/roadmap/implement/ -qruns - THEN the run exits 0 and reports no failure.
Requirement: Run count held at the recorded ceiling
The test-tree check SHALL hold the count of job_world.run( calls in each module of tests/roadmap/implement/ at or below the count in tests/gate/tree_checks/implement_scenario_runs.toml.
Scenario: The check prints the run count of each module
- WHEN
uv run devops ci --check --only test-treeruns - THEN the check passes and prints the count of
job_world.run(calls of each module oftests/roadmap/implement/.
Requirement: The check refuses a count above the ceiling
The check MUST fail when a module holds more job_world.run( calls than its recorded count.
Scenario: A small tree above the ceiling fails the check
- WHEN a test of the check gives it a small tree with a count above the recorded count
- THEN the check fails and names the module and the two counts.
Requirement: Each folded fact is a subtest
Each assert that follows the run call of a test SHALL sit inside a with subtests.test('<behaviour>') block.
Scenario: An assert outside a subtest block fails the check
- WHEN a test of the check gives it a small tree whose assert after the run call sits outside a
with subtests.test(block - THEN the check fails and names the file and the line of the assert.
Requirement: Subtest label is a literal
Each subtests.test( call of a folded test MUST take a literal string label.
Scenario: A label that is a variable fails the check
- WHEN a test of the check gives it a small tree whose
subtests.test(call takes a variable - THEN the check fails and names the file and the line of the call.
Requirement: Pending a person after the merge
The issue MUST hold the saving measured after #4509 lands.
Scenario: The measured saving is recorded
- WHEN the change merges after perf(test): stage gate tests parse every test file per call #4509 lands
- THEN the issue body holds the measured saving and the command that measured it.
Existing Tool Considered
The alternatives check of 2026-11-30 in the issue body gives not-applicable: class test, no model call, and no tool found. The subtests fixture of pytest (pinned 9.2.0) covers the need; the issue body records that it works under xdist. It lacks a stable per-fact test id, so test ids change. The change keeps the behaviour name as the literal subtest label. No new dependency. The issue body gives the cost as about 60,000 tokens and 4 hours.
Key questions
- Which mechanism folds the identical implement job scenarios?: Use the
subtestsfixture of pytest. Onewith subtests.test('<behaviour>')block checks each fact after one scenario run. (best practice) [sources: docs/TESTING.md, tests/roadmap/implement/test_roadmap_implement_job.py]- Chosen:
subtestsfixture. Each fact keeps its own label, a failing fact names itself, and the body records that it works under xdist. - Rejected: Consecutive asserts.
docs/TESTING.mdallows them, but the first failure hides the later facts and the report names no fact. - Rejected: Parametrized tests. Each case runs the scenario again, so the change saves no run time.
- Chosen:
- How is the saving measured after perf(test): stage gate tests parse every test file per call #4509 lands?: Measure the count of
job_world.run(calls and the CPU time of the package with per-test coverage contexts on pinned CPUs. Record the numbers in the issue. Never bound elapsed time in a test. (best practice) [sources: docs/TESTING.md]- Chosen: Pinned-CPU run with per-test coverage contexts. The count of runs is deterministic, and
docs/TESTING.mdrefuses a test that bounds elapsed time from above. - Rejected: Wall time of a shared host. A loaded host varies more than the change.
- Rejected: A test that bounds the run time. The
test-elapsed-upper-boundrule anddocs/TESTING.mdrefuse it.
- Chosen: Pinned-CPU run with per-test coverage contexts. The count of runs is deterministic, and
- Should a
test-treecheck hold the run count and the subtest form?: Yes. Acheck_*function intests/gate/tree_checks/holds the count ofjob_world.run(calls per module and refuses an assert after the run that sits outside asubtests.test(block. (best practice) [sources: AGENTS.md, docs/TESTING.md, tests/gate/tree_checks/config_values.py]- Chosen: Add the
test-treecheck.AGENTS.mdrule 11 asks for a check that fails if the problem returns, and thetest-treerow holds the invariants overtests/. - Rejected: Review only. A later test can add a second run with no check to refuse it.
- Rejected: No guard. The fold would regress with no signal.
- Chosen: Add the
- Does the fold add a test?: No.
docs/TESTING.mdgives no new test to an edit of tests only, so the run of the changed modules is the proof. The new check gets a test of its logic with a small tree. [sources: docs/TESTING.md] - Which tests fold first?: Fold the exact
two_groups()group oftests/roadmap/implement/test_roadmap_implement_job.pyfirst, then the other exact groups of the package. Fold a test that shares only a prefix after you read it. (best practice) [sources: tests/roadmap/implement/test_roadmap_implement_job.py]- Chosen: Exact groups first. The issue names these tests, and they share the same arrange, run lines and branch arcs.
- Rejected: Every prefix group at once. The issue says to fold a test that shares only a prefix after you read it.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 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.Saves 60-140 s of CI time but depends on #4509 and does not fix a defect.Reduces CI worker time and queue length without changing test coverage.81 groups to refactor with a mechanical subtests pattern, estimated at about 4 hours.Both reorganize roadmap test files, but #3748 splits large files by behaviour while the candidate folds redundant scenario runs into subtests.devops-cli-service commentedon Nov 14, 2026
Alternatives check: not-applicable
Class: test. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
Status set to Ready at a8a99cb (see proposed design in issue body).
dan-petty commentedon Nov 20, 2026
Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.
devops-cli-service commentedon Nov 26, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
devops-cli-service commentedon Dec 1, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.