Skip to content

fix(roadmap): the module-test problem names an unrelated test #4519

Closed

Description

@dan-petty

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

  1. Give the stage gates a behavior group that changes src/devops_cli/lang/en/messages.py and names only a test that it creates.
  2. Read the problem that existing_test_problems returns.

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

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.py holds tests/lang/en/test_messages.py and tests/ai/mcp/test_ai_benchmark_mcp_tool.py, and only the second imports devops_cli.lang.
  • THEN record_module_tests returns tests/lang/en/test_messages.py before tests/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.py holds two tests, and only the first imports devops_cli.lang.en.messages while the second imports devops_cli.lang.
  • THEN record_module_tests returns the test that imports devops_cli.lang.en.messages before the test that imports devops_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.py and names no test of it, and the record of the module starts with tests/lang/en/test_messages.py.
  • THEN The problem sentence holds tests/lang/en/test_messages.py and 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.py imports devops_cli.lang, and no test is the mirror test.
  • THEN record_module_tests returns 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.py and src/devops_cli/roadmap/step_files.py, and the record of stage_paths.py holds a test that imports devops_cli.roadmap.stage.stage_paths and a test that imports only devops_cli.roadmap.step_files.
  • THEN record_module_tests lists the test of stage_paths.py first.

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_test keeps tests[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.
  • 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.py mirrors to tests/lang/en/test_messages.py. [sources: src/devops_cli/lang/en/messages.py]
  • How does the check know which names a test imports?: _importing_tests builds the import graph of the candidate tests with build_import_graph and 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>.py as its mirror. The project names no such mirror path, and a test at the root of tests/ mirrors no folder.
  • Does the problem sentence change?: No. stage_problem_missing_module_test keeps 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

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The wrong test name causes model confusion and repeated refusals, but the stage job can still complete after a retry.
    • Value: Medium. Accurate test names in the problem message reduce model retries and improve plan quality.
    • Effort: Low. The fix changes the selection logic in one function from tests[0] to a relevance-based pick.
    • Related: fix(roadmap): the module-test and caller gates refuse correct plans #4467, which asks for a different change. 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.
  3. added
    priority/p2-medium
    on Nov 11, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 5f75d25 (see proposed design in issue body).

  6. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 11, 2026
  7. removed
    status/in-progress
    owner/agent
    on Nov 11, 2026
  8. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 19:36 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions