Skip to content

feat(roadmap): Name the test module for a changed function #3389

Closed

Description

@dan-petty

Problem or Motivation

The plan in PR #3330 (for #3309) put its comment assertion in tests/roadmap/test_roadmap_stage_plan.py. plan_stage writes no comment. The comment is written by _stage_one in apply_stage, and tests/roadmap/test_roadmap_stage_apply.py already covers it. The stage path check accepted the test path because the file exists, and the model review of the plan did not catch the mismatch.

When a plan changes a function that writes an output, the test of its group must name the module that exercises that output. Otherwise the implementer writes a test that cannot fail on the base, or has to find the right module alone.

Proposed Solution & Architectural Design

  • Add one rule to the stage prompt src/devops_cli/ai/tasks/roadmap_stage_change.md: before it writes the test of a behavior group, call references for the function whose behavior the group changes, and put the test in the test module that the answer lists.
  • Name the test module in the stage context for the functions that the issue cites, so the planner has the map before its first reply.
  • Add a test to tests/roadmap/test_roadmap_stage_prompt_rules.py that asserts the prompt names references and the test module of a changed function.

Target Subsystem

src/devops_cli/ai/tasks/roadmap_stage_change.md, src/devops_cli/roadmap/stage.py (collect_context), tests/roadmap/test_roadmap_stage_prompt_rules.py.

Acceptance criteria

  • The stage prompt asks the planner to call references for a changed function and to use the test module that the answer lists.
  • The stage context names the test modules that reference each function the issue cites.
  • A prompt rule test fails when either text is absent.

Source: #3330

Proposed design

Problem statement

A stage plan put its comment test in tests/roadmap/test_roadmap_stage_plan.py. plan_stage writes no comment. _stage_one in apply_stage writes it, and tests/roadmap/test_roadmap_stage_apply.py covers it. The path check accepted the test path because the file exists, and the model review missed the mismatch. The stage request and the stage prompt must name the test module that exercises a changed function.

Acceptance criteria

Requirement: The stage prompts name the test module of a changed function

The stage prompts SHALL tell the planner to call references for the function that a behavior group changes and to write the test in a test module that the answer lists.

Scenario: The prompt rule test reads the sentence

  • WHEN the prompt rule test loads roadmap_stage_change.md and roadmap_stage_split.md
  • THEN each prompt holds a sentence that names references and the test module that the answer lists.

Requirement: The rule names the fallback for the base toolset

The stage prompts SHALL name the test modules of probes as the source when references is not among the planner's tools.

Scenario: The sentence names the fallback

  • WHEN the prompt rule test reads the sentence that names references
  • THEN the sentence names probes as the source of the test module when references is not offered.

Requirement: The stage request names the test module of each cited function

The stage request SHALL name, in probes, each test module that holds the name of a function that the issue cites.

Scenario: A cited function has a test module

  • WHEN the issue cites _stage_one and tests/roadmap/test_roadmap_stage_apply.py holds that name
  • THEN the probes text holds a line that names tests/roadmap/test_roadmap_stage_apply.py for _stage_one.

Requirement: The stage request states a cited function with no test module

The stage request SHALL state, in probes, that no test module holds the name of a cited function when none does.

Scenario: A cited function has no test module

  • WHEN the issue cites gone_function and no test module holds that name
  • THEN the probes text holds a line that says that no test module names gone_function.

Requirement: The prompt rule test guards the sentence

The prompt rule test SHALL fail when a stage prompt lacks the sentence that names references and the test module that the answer lists.

Scenario: A prompt drops the sentence

  • WHEN a stage prompt lacks the sentence
  • THEN the prompt rule test fails with the name of that prompt.

Existing Tool Considered

No alternatives check has run. coverage.py with dynamic_context = test_function covers the mapping at run time and is open and maintained, but it needs a full test run, gives no static answer, and cannot run inside the planner's read-only, offline budget. The change builds its own code instead: about 60k tokens to build, keep and fix it, and about 4 hours.

Key questions

  • Where is collect_context defined?: collect_context is defined in src/devops_cli/roadmap/refine.py. src/devops_cli/roadmap/stage.py imports it from there. Refine and stage both call it, so a change to it changes both inputs. [sources: src/devops_cli/roadmap/refine.py, src/devops_cli/roadmap/stage.py]
  • Where does the test-module map go?: The map goes in probes. probe_premise already resolves each cited identifier from read-only git commands at the staged commit. probes is stage-only, so refine keeps its input. (best practice) [sources: src/devops_cli/roadmap/stage.py, src/devops_cli/roadmap/stage_probe.py, src/devops_cli/ai/tasks/roadmap_stage_change.md]
    • Chosen: probes from stage_probe.py. It is stage-only, and it already holds the lines of each cited identifier.
    • Rejected: context from collect_context. Refine shares the function, so refine's input and snapshot change too.
    • Rejected: A new request key test_modules. It needs a new prompt section and a new schema rule.
  • Is references always among the planner's tools?: No. The toolset base offers no references tool. A test sets the toolset to base and asserts that the planner gets none of read_issue, find_issues and references. [sources: tests/roadmap/test_roadmap_stage_plan.py, src/devops_cli/roadmap/stage.py]
  • Which prompts get the rule?: roadmap_stage_change.md and roadmap_stage_split.md. The split reply writes new groups, and each behavior group has a test. (best practice) [sources: tests/roadmap/test_roadmap_stage_prompt_rules.py, src/devops_cli/ai/tasks/roadmap_stage_split.md]
    • Chosen: Both stage prompts. The split reply writes new behavior groups with tests.
    • Rejected: roadmap_stage_change.md only. A split group then gets no rule for its test module.
  • How does the job find the test modules of a cited function?: A word search of the identifier in tests/ at the staged commit. It reuses the text search that the references tool uses. The line lists the test modules in the order of their path. (best practice) [sources: src/devops_cli/roadmap/stage_probe.py, tests/roadmap/test_roadmap_stage_tools.py]
    • Chosen: A word search at the staged commit. It uses the same match as the references tool and needs no test run.
    • Rejected: A coverage run with dynamic_context. It needs a full test run and cannot run in the planner's read-only budget.
    • Rejected: An import graph. A test imports a module, not a function, so the graph names no test.
  • How does the rule read when references is not offered?: One conditional sentence. It says to call references when the tool is offered, and to use the test modules of probes when it is not. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_stage_change.md, tests/roadmap/test_roadmap_stage_plan.py]
    • Chosen: One conditional sentence. One text holds both cases, so the two toolsets cannot drift.
    • Rejected: A prompt for each toolset. Two texts must stay in step, and the rule is short.
    • Rejected: No fallback. The base toolset then gets no rule.
  • Does plan_stage write the comment?: No. _stage_one writes the comment in apply_stage. tests/roadmap/test_roadmap_stage_apply.py covers it, and tests/roadmap/test_roadmap_stage_plan.py does not. [sources: src/devops_cli/roadmap/stage.py, tests/roadmap/test_roadmap_stage_apply.py, tests/roadmap/test_roadmap_stage_plan.py]
  • Which test asserts the text of probes?: test_the_model_input_holds_the_probe_of_each_cited_path_and_identifier in tests/roadmap/test_roadmap_stage_plan.py asserts the lines of probes. The change adds the new lines there. [sources: tests/roadmap/test_roadmap_stage_plan.py]
  • Where does the mapping code live?: In src/devops_cli/roadmap/stage_probe.py, beside probe_premise. That function already resolves each cited identifier and builds the probes text. (best practice) [sources: src/devops_cli/roadmap/stage_probe.py, src/devops_cli/roadmap/stage.py]
    • Chosen: stage_probe.py, beside probe_premise. The identifier list and the git reads are already there.
    • Rejected: A new module. It adds a module for a function that belongs beside probe_premise.
    • Rejected: refine.py. Refine needs no test-module map, so its input would grow for nothing.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-06: partly.
Tool: coverage (https://pypi.org/project/coverage), Apache-2.0, last activity 2026-11-04, maintained.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 3, 2026
  2. dan-petty commented on Nov 3, 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/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It prevents implementer rework by fixing test-module routing in generated plans, but does not block current work.
    • Value: Medium. Each misnamed test module causes a failed test or an orphaned assertion, so the rule saves repeated rework across plans.
    • Effort: Medium. It requires editing the stage prompt, extending collect_context, and adding a prompt-rule test across three files.
    • Related: feat(roadmap): the stage probe routes prompt changes to prompt rule tests #3347, which asks for a different change. Both items ensure the plan names the correct test module in stage planning, but #3347 covers prompt-text changes while the candidate covers function-behavior changes.
  3. added
    priority/p2-medium
    on Nov 3, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 3, 2026
  5. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 6c86ec9 (see proposed design in issue body).

  6. changed the title [-]feat(roadmap): the stage context names the test module that exercises a changed function[/-] [+]feat(roadmap): Name the test module for a changed function[/+] on Nov 6, 2026
  7. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 73 characters, and the limit is 60. The type and the scope stay.

    • Before: feat(roadmap): the stage context names the test module that exercises a changed function
    • After: feat(roadmap): Name the test module for a changed function
    • Source of the summary: the background model
  8. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Tool: coverage (https://pypi.org/project/coverage)

    • License: Apache-2.0
    • Last activity: 2026-11-04
    • Maintained: yes

    Covers:

    • Maps an executed line or function to the test that ran it, through dynamic contexts set with dynamic_context = test_function, which is the function-to-test-module mapping the issue asks the planner for.

    Lacks:

    • Answers only after a full test run, so it gives no static answer inside the planner's read-only, offline budget.
    • Reports the tests that executed code, not the test module to name in the test of a behavior group for a function that the plan changes before that change exists.
    • Its output is not a word search over tests/ at the staged commit, so it cannot supply the probes lines for a cited function without running the suite.

    Searches run:

    • coverage.py dynamic_context test_function map which test covers a function
    • find which test module covers a python function without running tests static tool
    • coverage.py dynamic_context test_function
    • pytest test impact analysis tool
    • coverage dynamic contexts
    • coverage.py
    • dynamic_context test_function coverage report which tests executed a line
    • pytest-testmon

    Sources:

    Checked on 2026-11-06. A person decides what this means for the item. The check changes no label and closes no issue.

  9. added
    owner/service
    on Nov 14, 2026
  10. 1 remaining item

  11. removed
    owner/service
    on Nov 14, 2026
  12. added 2 commits that reference this issue on Nov 14, 2026
  13. added
    status/planned
    and removed
    status/ready
    on Nov 14, 2026
  14. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/planned
    status/in-progress
    on Nov 16, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 16, 2026
  16. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-16 03:02 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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions