Repository navigation
Description
Problem Description
The module-test problem of the stage job names the first test of the record in sort order, not the test that is nearest to the module. For src/devops_cli/lang/en/messages.py, the record holds about 56 tests that import the package devops_cli.lang, and the problem asks for tests/ai/mcp/test_ai_benchmark_mcp_tool.py. The model then reads or names a test that has no relation to its change, or it repeats the refusal. _unnamed_module_test in src/devops_cli/roadmap/stage/stage_paths.py returns tests[0].
Reproduction Steps
- Give the stage gates a behavior group that changes
src/devops_cli/lang/en/messages.pyand names only a test that it creates. - Read the problem that
existing_test_problemsreturns.
Expected vs Actual Behavior
Expected: the problem names the test that imports the module directly, or the test of the module in the mirror folder (tests/lang/ for src/devops_cli/lang/), before a test that reaches the module through a package.
Actual: the problem names tests/ai/mcp/test_ai_benchmark_mcp_tool.py, the first of the record in sort order.
Environment Diagnostics
- DevOps CLI Version: 0.110.0 with fix(roadmap): the module-test and caller gates refuse correct plans #4467
- Execution Environment: Service (the stage job)
Logs, Traces, or Terminal Output
Group 2 changes `src/devops_cli/lang/en/messages.py` and names no existing test of that module. Add `tests/ai/mcp/test_ai_benchmark_mcp_tool.py` 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.
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
The stage job's module-test problem names the first test of the record in path order. For src/devops_cli/lang/en/messages.py, the record holds about 56 tests that import devops_cli.lang, and the problem names tests/ai/mcp/test_ai_benchmark_mcp_tool.py. That test has no relation to the module. The model reads an unrelated test, or it repeats the refusal. The check must name the nearest test: the mirror test of the module, or a test that imports the module directly.
Acceptance criteria
Requirement: The record orders a module's tests nearest first
record_module_tests SHALL order the tests of each module by closeness: the mirror test, then a test that imports the module's dotted name, then a test in the module's mirror folder, then the rest, each group in path order.
Scenario: The mirror test comes first
- WHEN The record of
src/devops_cli/lang/en/messages.pyholdstests/lang/en/test_messages.pyandtests/ai/mcp/test_ai_benchmark_mcp_tool.py, and only the second importsdevops_cli.lang. - THEN
record_module_testsreturnstests/lang/en/test_messages.pybeforetests/ai/mcp/test_ai_benchmark_mcp_tool.py.
Requirement: A direct importer comes before a package importer
record_module_tests SHALL list a test that imports the module's dotted name before a test that reaches the module only through an exporting package.
Scenario: A direct import beats a package import
- WHEN The record of
src/devops_cli/lang/en/messages.pyholds two tests, and only the first importsdevops_cli.lang.en.messageswhile the second importsdevops_cli.lang. - THEN
record_module_testsreturns the test that importsdevops_cli.lang.en.messagesbefore the test that importsdevops_cli.lang.
Requirement: The problem names the nearest test
existing_test_problems SHALL name the first test of the record of the module in the problem sentence that it returns.
Scenario: The problem names the mirror test
- WHEN A behavior group changes
src/devops_cli/lang/en/messages.pyand names no test of it, and the record of the module starts withtests/lang/en/test_messages.py. - THEN The problem sentence holds
tests/lang/en/test_messages.pyand holds no later test of the record.
Requirement: Package importers keep path order and no test is lost
record_module_tests SHALL keep every test that imports the module or an exporting package, and SHALL list tests of equal closeness in path order.
Scenario: Package importers stay in path order
- WHEN Every test of the record of
src/devops_cli/lang/en/messages.pyimportsdevops_cli.lang, and no test is the mirror test. - THEN
record_module_testsreturns each test once, in path order.
Requirement: A test of another changed module ranks last
record_module_tests SHALL list a test of another module that the plan changes after a test that imports the changed module itself.
Scenario: The module's own test comes first
- WHEN A plan changes
src/devops_cli/roadmap/stage/stage_paths.pyandsrc/devops_cli/roadmap/step_files.py, and the record ofstage_paths.pyholds a test that importsdevops_cli.roadmap.stage.stage_pathsand a test that imports onlydevops_cli.roadmap.step_files. - THEN
record_module_testslists the test ofstage_paths.pyfirst.
Existing Tool Considered
No alternatives check has run. No open, maintained tool or library covers the need: the order comes from the import graph of this project, and no outside tool holds it. The change builds a small pure function in src/devops_cli/roadmap/stage/stage_paths.py instead. The cost is about 15k tokens to build, keep and fix that function, and about 1 hour of elapsed time.
Key questions
- Which test does the module-test problem name when the record of a module holds several?: The nearest test of the record: the mirror test, then a direct importer, then a test in the module's mirror folder, then the rest. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py:546, src/devops_cli/lang/en/messages.py]
- Chosen: Mirror test, direct importer, mirror folder, rest. The project's convention gives the mirror test to the module, and a direct import is the tightest coupling after it.
- Rejected: Direct importer first, then the mirror test. When the mirror test does not import the module, the convention still gives it to the module, so it stays first.
- Rejected: Path order, as today. That is the defect: the first path in sort order has no relation to the module.
- Where does the closeness order live?: In
record_module_tests, which returns the tests of each module nearest first._unnamed_module_testkeepstests[0]. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py]- Chosen: Order the record in
record_module_tests. One function orders the tests, and every consumer sees the nearest test first. - Rejected: Rank in
_unnamed_module_test. It holds no reader and no import graph, so it would rebuild both for each group. - Rejected: Add a second record of nearest tests. It changes the record type for every caller and keeps two records in step.
- Chosen: Order the record in
- What is the mirror path of a module under
src/?:tests/<folder of the module after src/devops_cli/>/test_<module>.py:src/devops_cli/lang/en/messages.pymirrors totests/lang/en/test_messages.py. [sources: src/devops_cli/lang/en/messages.py] - How does the check know which names a test imports?:
_importing_testsbuilds the import graph of the candidate tests withbuild_import_graphand reads the edges of each test, so it already holds the exporter names that each test imports. [sources: src/devops_cli/roadmap/stage/stage_paths.py] - What does the order do when the module has no mirror folder?: No test matches the mirror rank, so the order falls to a direct importer, then to the rest. A module at the top of the package has no mirror test. (best practice) [sources: src/devops_cli/lang/en/messages.py]
- Chosen: No mirror rank for that module. The project states that such a module has no test file of its own.
- Rejected: Treat
tests/test_<module>.pyas its mirror. The project names no such mirror path, and a test at the root oftests/mirrors no folder.
- Does the problem sentence change?: No.
stage_problem_missing_module_testkeeps its text, and only the test that it names changes. (best practice) [sources: src/devops_cli/lang/en/messages.py]- Chosen: Keep the sentence. The sentence already names a test and the group, and only the choice of test changes.
- Rejected: Add the reason for the choice. No reader needs the rank, and the sentence stays short.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
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.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.The wrong test name causes model confusion and repeated refusals, but the stage job can still complete after a retry.Accurate test names in the problem message reduce model retries and improve plan quality.The fix changes the selection logic in one function from tests[0] to a relevance-based pick.Both work on the module-test gate, but the candidate changes the test selection in the problem message while #4467 changes the gate matching logic.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 5f75d25 (see proposed design in issue body).
devops-cli-service commentedon Nov 11, 2026
Released in v0.112.3: https://github.com/dan-petty/devops-cli/releases/tag/v0.112.3
devops-cli-service commentedon Nov 11, 2026
Live since 2026-11-11 19:36 UTC