Skip to content

fix(roadmap): Name the test case that a change invalidates #3443

Open

Description

@dan-petty

Problem

A stage plan can name the test module that a change updates and still omit the existing test case whose assertion the change breaks. The stage path check only confirms that a named path exists, and #3414 requires a named test file, so the plan passes both while its task list leaves out the failing case. The implementer finds the case only when the group's verification command runs the module.

Evidence

The plan of #3415 (PR #3437) names tests/roadmap/test_roadmap_stage_probe.py. It adds git ls-tree to the probe, and test_every_command_reads_and_the_checkout_does_not_change asserts the exact set of command names {"cat-file", "grep", "log"}, so the change fails that case. The plan as staged did not name the case. A reviewer had to prototype the change and run the module to find it. The plan names the case only after review.

The same plan first read the staged tree at the start of every run. That choice also changes two tests that pin the probe command count. The plan avoided the change only when the review chose a lazy tree read, and it did not state that constraint.

Suggestion

A behavior group that changes a source file and names an existing test module SHALL name each test case in that module whose assertion the change invalidates, or state that it updates no existing case. The stage context SHALL list the test cases of a named test module that reference a symbol, message or constant of the changed source file, so the planner reads them before it writes the group.

Related: #3414 requires the existing test file; this item requires the existing test case inside that file. #3389 names the test module for a changed function.

Source: #3437

Source: #3437

Dependencies

Proposed design

Problem statement

A stage plan names the test module that a change updates. It can still omit the test case whose assertion the change breaks. The path check passes because the path exists. The implementer finds the failing case only when the module runs. The stage context must list the test cases that reference the changed source. The plan must name each invalidated case.

Acceptance criteria

Requirement: Group names the invalidated test case

A behavior group that changes a source file and names an existing test module SHALL name each test case whose assertion the change invalidates.

Scenario: The probe change breaks a pinned command set

  • WHEN A group adds git ls-tree to the stage probe and names tests/roadmap/test_roadmap_stage_probe.py.
  • THEN The task list of the group names test_every_command_reads_and_the_checkout_does_not_change and the command-name set that this case asserts.

Requirement: Group states that it invalidates no case

A group that names an existing test module and invalidates no assertion in it SHALL state that it updates no existing test case.

Scenario: A group only adds a test case

  • WHEN A group adds a case to tests/roadmap/test_roadmap_stage_probe.py and changes no existing assertion.
  • THEN The task list of the group states that it updates no existing test case.

Requirement: Context lists the referencing test cases

The stage context SHALL list each test case of a named test module that references a symbol, message or constant of the changed source file.

Scenario: A constant of the changed source file

  • WHEN The plan cites tests/roadmap/test_roadmap_stage_probe.py and the changed file defines CONST_ROADMAP_STAGE_PROBE_MAX_COMMANDS.
  • THEN The context lists test_the_probe_stops_at_the_bound_and_lists_the_items_it_skipped as a case that references the constant.

Requirement: Context reports the cases that the bound cuts off

The stage context SHALL name each referencing test case that the probe command bound leaves unlisted.

Scenario: The command bound is reached

  • WHEN The listing of referencing test cases reaches the bound of CONST_ROADMAP_STAGE_PROBE_MAX_COMMANDS.
  • THEN The context names the unlisted cases in the line that reports the reached bound.

Requirement: The plan snapshot holds the rule

The rendered stage plan instructions SHALL contain the rule that a group names the invalidated test case.

Scenario: The rendered instructions of a group

  • WHEN The stage plan renders the instructions for a behavior group.
  • THEN The rendered text contains the rule, and tests/roadmap/__snapshots__/test_roadmap_stage_plan.ambr records it.

Existing Tool Considered

No check has run. git grep, which the stage probe already runs, finds a symbol in a test module. The dynamic contexts of coverage.py (--context) map each test case to the lines that it runs. Neither states which assertion a change invalidates, so the plan instructions must require that statement. A custom detector would cost about 80k tokens to build, 20k tokens each month to keep and fix, and 5 days of elapsed time.

Key questions

  • Which existing test case does a change to the stage probe invalidate?: test_every_command_reads_and_the_checkout_does_not_change in tests/roadmap/test_roadmap_stage_probe.py asserts the exact command-name set {"cat-file", "grep", "log"}, so a new command breaks it. The plan of fix(roadmap): the stage probe names the files of a cited bare name #3415 named this case only after review. [sources: tests/roadmap/test_roadmap_stage_probe.py:117, openspec/changes/3415-the-stage-probe-names-the-files/tasks.md]
  • What does the stage context pack for a step?: The instructions of the group, the AGENTS.md of the repository, the routed sections of its documents, the item, the change folder and the packed files of the group. The context has no test-case listing now. [sources: CONTEXT.md]
  • How does the stage context find the test cases that reference a symbol, message or constant of the changed source file?: Reuse the git grep of the stage probe on the named test module, and list the matching cases in the context. (best practice) [sources: CONTEXT.md, tests/roadmap/test_roadmap_stage_probe.py]
    • Chosen: Reuse the probe's git grep on the named test module. The probe already runs bounded read-only grep, so the listing adds no tool and stays inside the bound.
    • Rejected: Add a planner tool that lists test cases. CONTEXT.md fixes the planner toolset, and a new tool spends the token budget of the step.
    • Rejected: Ask the model to recall the test module. The plan of fix(roadmap): the stage probe names the files of a cited bare name #3415 missed the case until review, so recall is no evidence.
  • Where does the rule that a group names the invalidated test case live?: In the stage plan instructions, checked by the stage plan snapshot test. (best practice) [sources: tests/roadmap/snapshots/test_roadmap_stage_plan.ambr, openspec/changes/3415-the-stage-probe-names-the-files/design.md]
    • Chosen: The stage plan instructions, checked by the plan snapshot. The plan renders from instructions, and the snapshot test already pins the rendered text.
    • Rejected: A validator over the prose of tasks.md. The plan is free text, so a validator over its prose is brittle.
  • How does the context report a referencing test case that the command bound cuts off?: Name the case in the line that reports the reached bound. (best practice) [sources: tests/roadmap/test_roadmap_stage_probe.py, CONTEXT.md]
    • Chosen: Name the case in the line that reports the reached bound. The probe already lists skipped items when it reaches the bound, so the planner sees the omission.
    • Rejected: Raise the bound. The bound keeps the inputs of a step inside its token budget.
    • Rejected: Leave the case out silently. A silent omission repeats the failure of fix(roadmap): the stage probe names the files of a cited bare name #3415.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-07: partly.
Tool: tarpas/pytest-testmon (https://github.com/tarpas/pytest-testmon), MIT, last activity 2026-11-02, maintained.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 4, 2026
  2. dan-petty commented on Nov 4, 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. A real gap in stage plan validation that delayed a review, but it affects planning tooling, not user-facing output.
    • Value: Medium. Prevents implementers from discovering failing test cases only at run time and removes a class of review rework.
    • Effort: Medium. Requires a new validation rule for test-case naming plus a stage-context change that lists cases referencing changed symbols.
    • Related: fix(roadmap): refuse a behavior group that omits a test it changes #3414, which asks for a different change. Both require a stage plan to name an existing test its change breaks, but #3414 stops at the file level while the candidate goes to the individual test case level.
  3. added
    priority/p2-medium
    on Nov 4, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 4, 2026
  5. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 53cffca (see proposed design in issue body).

  6. changed the title [-]fix(roadmap): the stage plan names the existing test case that pins a changed output[/-] [+]fix(roadmap): Name the test case that a change invalidates[/+] 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 70 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(roadmap): the stage plan names the existing test case that pins a changed output
    • After: fix(roadmap): Name the test case that a change invalidates
    • Source of the summary: the background model
  8. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: The web searches errored out, so the check rests on the package and repository facts: pytest-testmon records which test cases exercise which lines and, after a change, names the cases a source change affects, which is the "list the referencing test cases" half of the need. It does not say which assertion a change invalidates, does not list cases by symbol, message or constant reference in a named module, and does not feed the stage plan's task list, so the plan-instruction rule the issue asks for stays needed.

    Tool: tarpas/pytest-testmon (https://github.com/tarpas/pytest-testmon)

    • License: MIT
    • Last activity: 2026-11-02
    • Maintained: yes

    Covers:

    • Records per-test coverage and, after a source change, names the test cases that the change affects
    • Works with the repository's pytest suite and runs only the affected cases, so it can be run over the named test module

    Lacks:

    • Does not state which assertion of a test case the change invalidates
    • Does not list the test cases of a named module that reference a symbol, message or constant of the changed source file
    • Does not report the referencing cases that the stage probe's command bound cuts off
    • Does not put the invalidated case into the stage plan's task list or render the rule in the plan instructions

    Tools considered:

    Searches run:

    • tool that finds which test cases a source code change affects test impact analysis Python, results: 0
    • pytest-testmon select tests affected by code changes, results: 0
    • pytest-testmon, results: 0
    • test impact analysis python tool, results: 0
    • pytest testmon, results: 0
    • coverage.py dynamic contexts map tests to lines, results: 0
    • testmon, results: 0
    • python test selection tool changed code, results: 0
    • pytest-testmon github repository, results: 0
    • test impact analysis, results: 0

    Sources:

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

  9. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/3443-name-the-test-case-that-a, draft pull request #4352. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:

    1. List the referencing test cases in the probe: 33056 tokens
    2. State the invalidated test case in the planner prompt: 32824 tokens

    A model review of the plan found these open findings. The stage keeps this pull request a draft with the label plan/needs-fix until a later round clears them:

    • criterion_dropped at group 1: Group 1 lists the cases only of test modules that the issue cites. The plan of fix(roadmap): the stage probe names the files of a cited bare name #3415 named tests/roadmap/test_roadmap_stage_probe.py, and issue fix(roadmap): the stage probe names the files of a cited bare name #3415 cites no test module, so the probe still omits the case that the change breaks, and no task delivers the criterion for a test module that a group names. Evidence: "The stage context SHALL list each test case of a named test module that references a symbol, message or constant of the changed source file."
    • criterion_dropped at group 1 and specs: The group's second case and the added requirement name only the test module and the source file in the bound line, not each referencing test case that the bound leaves unlisted, so the issue's criterion has no task and the spec delta narrows it. Evidence: "The stage context SHALL name each referencing test case that the probe command bound leaves unlisted."

    The runs of the planner and the review made 82 model request(s), and used 6083405 input tokens and 132185 output tokens. The tool calls, in order:

    1. list_files({"directory":"src/devops_cli/roadmap/stage"})
    2. list_files({"directory":"tests/roadmap/stage"})
    3. file_symbols({"path":"src/devops_cli/roadmap/stage/stage_probe.py"})
    4. file_symbols({"path":"src/devops_cli/roadmap/stage/stage_context_facts.py"})
    5. read_file({"path":"src/devops_cli/roadmap/stage/stage_probe.py","start_line":1,"end_line":130})
    6. read_file({"path":"src/devops_cli/roadmap/stage/stage_probe.py","start_line":230,"end_line":400})
    7. file_symbols({"path":"src/devops_cli/roadmap/stage/stage_request.py"})
    8. search_code({"text":"probe_premise("})
    9. read_file({"path":"src/devops_cli/roadmap/stage/stage.py","start_line":1290,"end_line":1420})
    10. search_code({"text":"roadmap_stage_plan"})
    11. search_code({"text":"roadmap_stage_"})
    12. list_files({"directory":"src/devops_cli/ai/tasks"})
    13. read_file({"path":"docs/roadmap/stage.md","start_line":1,"end_line":45})
    14. search_code({"text":"test module"})
    15. search_code({"text":"existing test"})
    16. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":1,"end_line":90})
    17. search_code({"text":"behavior group"})
    18. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":24,"end_line":120})
    19. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":37,"end_line":80})
    20. search_code({"text":"def collect_context"})
    21. search_code({"text":"CONST_ROADMAP_STAGE_PROBE_MAX_COMMANDS"})
    22. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_probe.py","start_line":1,"end_line":200})
    23. search_code({"text":"roadmap_stage_change"})
    24. list_files({"directory":"tests/roadmap/stage/__snapshots__"})
    25. read_file({"path":"tests/roadmap/stage/__snapshots__/test_roadmap_stage_plan.ambr","start_line":1,"end_line":80})
    26. file_symbols({"path":"tests/roadmap/stage/test_roadmap_stage_plan.py"})
    27. search_code({"text":"The stage counts 32 tokens"})
    28. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_prompt_rules.py","start_line":1,"end_line":70})
    29. search_code({"text":"load_task_prompt"})
    30. read_file({"path":"openspec/changes/3428-the-stage-context-names-the-plan/proposal.md","start_line":1,"end_line":40})
    31. search_code({"text":"test module"})
    32. search_code({"text":"STAGE_EVAL_TRIGGER_PATHS"})
    33. search_code({"text":"roadmap eval stage --replay"})
    34. file_symbols({"path":"src/devops_cli/roadmap/stage/stage_form.py"})
    35. read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":240,"end_line":300})
    36. read_file({"path":"src/devops_cli/roadmap/stage/stage_form.py","start_line":40,"end_line":160})
    37. read_file({"path":"src/devops_cli/roadmap/stage/stage_form.py","start_line":240,"end_line":300})
    38. list_files({"directory":"tests/fixtures/roadmap_eval/stage"})
    39. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_plan.py","start_line":75,"end_line":215})
    40. read_file({"path":"openspec/changes/3428-the-stage-context-names-the-plan/tasks.md"})
    41. file_symbols({"path":"src/devops_cli/roadmap/stage/stage_probe.py"})
    42. search_code({"text":"_Run"})
    43. callers({"symbol":"_Run"})
    44. read_file({"path":"src/devops_cli/roadmap/stage/stage_probe.py","start_line":90,"end_line":200})
    45. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_probe.py","start_line":100,"end_line":180})
    46. read_file({"path":"src/devops_cli/roadmap/stage/stage_probe.py","start_line":280,"end_line":380})
    47. search_code({"text":"stage_probe_skipped"})
    48. list_files({"directory":"src/devops_cli/ai/tasks"})
    49. search_code({"text":"behavior"})
    50. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_prompt_rules.py","start_line":1,"end_line":80})
    51. search_code({"text":"behavior group"})
    52. read_spec({"capability":"roadmap-stage","requirement":"A task group names its files"})
    53. read_spec({"capability":"roadmap-stage"})
    54. search_code({"text":"test case"})
    55. search_code({"text":"invalidat"})
    56. search_code({"text":"pair that"})
    57. read_file({"path":"docs/roadmap/stage.md","start_line":1,"end_line":60})
    58. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":1,"end_line":70})
    59. read_file({"end_line":120,"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":24})
    60. search_code({"text":"tests/"})
    61. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_probe.py","start_line":1,"end_line":60})
    62. search_code({"text":"tests/roadmap"})
    63. search_code({"text":"probe.commands"})
    64. read_file({"path":"src/devops_cli/config/constants.py","start_line":3270,"end_line":3280})
    65. list_files({"directory":"tests/support"})
    66. search_code({"text":"MESSAGES_FILE"})
    67. file_symbols({"path":"tests/roadmap/stage/test_roadmap_stage_plan.py"})
    68. file_symbols({"path":"src/devops_cli/ai/task_loader.py"})
    69. search_code({"text":"def git_result"})
    70. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_plan.py","start_line":182,"end_line":212})
    71. read_file({"path":"src/devops_cli/roadmap/stage/stage_probe.py","start_line":180,"end_line":460})
    72. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_probe.py","start_line":120,"end_line":300})
    73. read_file({"path":"src/devops_cli/roadmap/stage/stage_probe.py","start_line":342,"end_line":430})
    74. read_file({"path":"docs/roadmap/stage.md","start_line":1,"end_line":50})
    75. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_plan.py","start_line":180,"end_line":225})
    76. search_code({"text":"docs/roadmap/stage.md"})
    77. search_code({"text":"A 'behavior' group"})
    78. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":30,"end_line":110})
    79. search_code({"text":"'kind'"})
    80. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":1,"end_line":30})
    81. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":58,"end_line":140})
    82. read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_change.md","start_line":23,"end_line":32})
    83. search_code({"text":"kind of a group"})
    84. read_file({"path":"tests/support/roadmap_stage.py","start_line":190,"end_line":300})
    85. read_file({"path":"tests/support/roadmap_stage.py","start_line":100,"end_line":190})
    86. read_spec({"capability":"roadmap-stage"})
    87. read_spec({"capability":"roadmap-stage","requirement":"The probes are bounded and read-only"})
    88. read_spec({"capability":"roadmap-stage","requirement":"The job probes the premise at the staging commit"})
    89. read_file({"path":"src/devops_cli/config/constants.py","start_line":3272,"end_line":3280})
    90. read_file({"path":"src/devops_cli/lang/en/messages.py","start_line":3590,"end_line":3600})
    91. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_plan.py","start_line":90,"end_line":105})
    92. file_symbols({"path":"src/devops_cli/roadmap/refine/refine.py"})
    93. file_symbols({"path":"src/devops_cli/ai/task_loader.py"})
    94. list_files({"directory":"tests/roadmap/stage/__snapshots__"})
    95. list_files({"directory":"openspec/changes/archive/2026-11-04-3415-the-stage-probe-names-the-files"})
    96. search_code({"text":"class _Run"})
    97. read_file({"path":"src/devops_cli/roadmap/stage/stage_probe.py","start_line":100,"end_line":180})
    98. read_file({"path":"src/devops_cli/roadmap/refine/refine.py","start_line":685,"end_line":740})
    99. read_file({"path":"src/devops_cli/roadmap/refine/refine.py","start_line":770,"end_line":800})
    100. search_code({"text":"ast.parse"})
    101. read_file({"path":"src/devops_cli/roadmap/stage/stage_context_facts.py","start_line":1,"end_line":170})
    102. read_file({"path":"src/devops_cli/roadmap/implement/implement_test_names.py","start_line":1,"end_line":80})
    103. search_code({"text":"defined_tests"})
    104. search_code({"text":"test cases"})
    105. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_prompt_rules.py","start_line":200,"end_line":400})
    106. search_code({"text":"_DOCUMENTS"})
    107. search_code({"text":"test_the_prompt_names_the_test_case_that_a_change_invalidates"})
    108. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_prompt_rules.py","start_line":400,"end_line":560})
    109. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_prompt_rules.py","start_line":560,"end_line":660})
    110. git_log({"path":"tests/roadmap/stage/test_roadmap_stage_probe.py"})
    111. git_log({"path":"src/devops_cli/roadmap/stage/stage_probe.py"})
    112. git_log({"path":"openspec/changes/archive/2026-11-04-3415-the-stage-probe-names-the-files/tasks.md"})
    113. read_file({"path":"src/devops_cli/lang/en/messages.py","start_line":3576,"end_line":3592})
    114. callers({"symbol":"probe_premise"})
    115. search_code({"text":"stage_probe_skipped"})
    116. list_files({"directory":"tests/roadmap/stage"})
    117. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_probe.py","start_line":239,"end_line":400})
    118. search_code({"text":"stage-eval"})
    119. search_code({"text":"probes"})
    120. read_file({"path":"tests/roadmap/stage/test_roadmap_stage_eval_cases.py","start_line":1,"end_line":80})
    121. search_code({"text":"roadmap/stage/eval"})
    122. search_code({"text":"CASES_DIRECTORY"})
    123. read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_cases.py","start_line":60,"end_line":200})
    124. search_code({"text":"files: Mapping[str, str]"})
    125. search_code({"text":"class StagedChange"})
    126. read_issue({"number":3415})
    127. read_file({"path":"openspec/changes/archive/2026-11-04-3415-the-stage-probe-names-the-files/proposal.md","start_line":1,"end_line":80})
    128. read_file({"path":"openspec/changes/archive/2026-11-04-3415-the-stage-probe-names-the-files/tasks.md","start_line":1,"end_line":40})
    129. read_file({"path":"src/devops_cli/roadmap/refine/refine.py","start_line":660,"end_line":690})
    130. search_code({"text":"scenario names"})
    131. search_code({"text":"has no behavior test"})

    Tool calls: callers=2 (empty=0), file_symbols=10 (empty=0), git_log=3 (empty=0), list_files=10 (empty=0), read_file=55 (empty=0), read_issue=1 (empty=0), read_spec=5 (empty=0), search_code=45 (empty=3)

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

  10. 1 remaining item

  11. added
    status/in-progress
    and removed
    status/ready
    on Nov 10, 2026
  12. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Stopped at group 1.

    Failure class: limit_reached.
    Action taken: none.
    Action left: raise_limit: raise the limit that the run went over.

    Step Status Attempts Tokens in/out Last failing command
    group 1 stopped 1 8050668/43618 -

    Reason:

    LimitReached: The step spent its budget `roadmap.implement.step_token_budget=8000000`.
    Refused commands: cat 1. Other retries: 0.
    

    Last message of the agent (a claim that no check verified): Now the pairing in probe_premise:

    The job discarded this work. Read it before you retry:

    diff --git a/src/devops_cli/lang/en/messages.py b/src/devops_cli/lang/en/messages.py
    index a1cf41ea..5c636526 100644
    --- a/src/devops_cli/lang/en/messages.py
    +++ b/src/devops_cli/lang/en/messages.py
    @@ -3594,6 +3594,12 @@ class RoadmapMessages:
         stage_probe_touched: str = "Commit {commit} last added or removed its text."
         stage_probe_name_never: str = "No commit in the history added or removed its text."
         stage_probe_skipped: str = "Not probed, the bound of {bound} commands is reached: {items}"
    +    stage_probe_cases: str = (
    +        "The test module `{module}` holds these cases that name a symbol of `{source}`: {cases}"
    +    )
    +    stage_probe_cases_none: str = (
    +        "The test module `{module}` holds no case that names a symbol of `{source}`."
    +    )
         stage_kept_reason: str = (
             "The branch holds {count} commit(s) by another author past the default branch, so the "
             "job keeps the branch and its draft."
    diff --git a/src/devops_cli/roadmap/stage/stage_probe.py b/src/devops_cli/roadmap/stage/stage_probe.py
    index 91ff58c3..398cc1fb 100644
    --- a/src/devops_cli/roadmap/stage/stage_probe.py
    +++ b/src/devops_cli/roadmap/stage/stage_probe.py
    @@ -23,12 +23,21 @@ with a `--` before every path, so the probe changes nothing. A cited path that e
     gets one line. For a bare name with no root file, the probe reads the tree once and names the files
     under a folder that have the same name, so the model reads a file that exists. It lists the items
     that the bound left out.
    +
    +A cited test module and a cited source file form a pair (#3443). For each pair that the commit
    +holds, the probe names the cases of the module whose body holds a name that the source binds, or
    +says that the module holds no such case. The planner reads the case that its change invalidates
    +before it writes a group. Each file of a pair is read once with `git cat-file -p` and kept for the
    +rest of the run, so a pair adds no command kind. The line that reports the bound names the pairs
    +that the bound left unlisted.
     """
     
     from __future__ import annotations
     
    +import ast
     import re
     from dataclasses import dataclass, field
    +from fnmatch import fnmatchcase
     from pathlib import PurePosixPath
     from typing import TYPE_CHECKING, Final
     
    @@ -48,7 +57,7 @@ from devops_cli.roadmap.stage.stage_models import parse_class_fields
     from devops_cli.roadmap.stage.stage_paths import StagedTree
     
     if TYPE_CHECKING:
    -    from collections.abc import Iterable, Iterator, Mapping
    +    from collections.abc import Iterable, Iterator, Mapping, Sequence
         from pathlib import Path
     
     _LOG_FORMAT: Final[str] = "--format=%h %as %s"
    @@ -84,6 +93,14 @@ _FIELD_WORDS: Final[frozenset[str]] = frozenset(
             "the",
         }
     )
    +# The pair of a change (#3443): a test module under `tests/`, and a source file under `src/`.
    +_TESTS_DIR: Final[str] = "tests/"
    +_SRC_DIR: Final[str] = "src/"
    +_PYTHON_SUFFIX: Final[str] = ".py"
    +_TEST_MODULE_PATTERNS: Final[tuple[str, ...]] = ("test_*.py", "*_test.py")
    +# The prefix of a test case, and the words of a case body.
    +_CASE_PREFIX: Final[str] = "test_"
    +_WORDS: Final[re.Pattern[str]] = re.compile(r"[A-Za-z_]\w*")
     
     
     @dataclass(frozen=True)
    @@ -114,7 +131,8 @@ class Probe:
     
     @dataclass
     class _Run:
    -    """The state of one probe: its checkout and commit, and the commands it has left."""
    +    """The state of one probe: its checkout and commit, the cited files that it found, the text
    +    that it read of them, and the commands it has left."""
     
         source: Path
         sha: str
    @@ -124,8 +142,10 @@ class _Run:
         skipped: list[str] = field(default_factory=list)
         false_premises: list[str] = field(default_factory=list)
         absent: frozenset[tuple[str, str]] = frozenset()
    +    present: set[str] = field(default_factory=set)
         _tree: StagedTree | None = None
         _surfaces: dict[str, tuple[str, dict[str, int]] | None] = field(default_factory=dict)
    +    _texts: dict[str, str] = field(default_factory=dict)
     
         def git(self, source: Path, *args: str) -> tuple[int, str]:
             """Run one command of the budget in `source`, which is the checkout of the run."""
    @@ -192,6 +212,59 @@ class _Run:
             code, out = self.git(self.source, "log", "-n1", _LOG_FORMAT, *args)
             return out.strip() if code == 0 else ""
     
    +    def cited_text(self, path: str) -> str | None:
    +        """The text of the cited file `path` at the staging commit, read once with `cat-file -p`
    +        and kept for the rest of the run, or None when no command is left or the read fails."""
    +        if path in self._texts:
    +            return self._texts[path]
    +        if self.left < 1:
    +            return None
    +        code, out = self.git(self.source, "cat-file", "-p", f"{self.sha}:{path}")
    +        if code != 0:
    +            return None
    +        self._texts[path] = out
    +        return out
    +
    +    def cases(self, module: str, source: str) -> bool:
    +        """List the cases of the test module `module` whose body names a name that the source file
    +        `source` binds, or say that the module holds none. False when no command is left to read
    +        one of the two files."""
    +        module_text = self.cited_text(module)
    +        if module_text is None:
    +            return False
    +        source_text = self.cited_text(source)
    +        if source_text is None:
    +            return False
    +        texts = MESSAGES.roadmap
    +        found = _named_cases(module_text, _bound_names(source_text))
    +        if found:
    +            line = texts.stage_probe_cases.format(
    +                module=module,
    +                source=source,
    +                cases=", ".join(f"`{case}`" for case in found),
    +            )
    +        else:
    +            line = texts.stage_probe_cases_none.format(module=module, source=source)
    +        self.lines.append(line)
    +        return True
    +
    +    def pairs(self, modules: Sequence[str], sources: Sequence[str]) -> None:
    +        """List the cases of each cited test module that name a name of each cited source file. When
    +        no command is left for a pair, name the test module and the source files that stay
    +        unlisted, and stop the pairing."""
    +        for index, module in enumerate(modules):
    +            for offset, source in enumerate(sources):
    +                if self.cases(module, source):
    +                    continue
    +                self._skip_cases(module, sources[offset:])
    +                for later in modules[index + 1 :]:
    +                    self._skip_cases(later, sources)
    +                return
    +
    +    def _skip_cases(self, module: str, sources: Sequence[str]) -> None:
    +        """List the test module and the source files whose cases the bound left unlisted."""
    +        self.skipped.append(f"{module} and {', '.join(sources)}")
    +
         def path_or_field(self, name: str) -> None:
             """Probe `name` as a class field when the staging commit defines the class of its left
             part, and as a path otherwise (#3406). A class that no command can confirm stays a path."""
    @@ -236,6 +309,7 @@ class _Run:
             texts = MESSAGES.roadmap
             code, _ = self.git(self.source, "cat-file", "-e", f"{self.sha}:{name}")
             if code == 0:
    +            self.present.add(name)
                 self.lines.append(texts.stage_probe_path_present.format(path=name))
                 return
             self.missing.append(name)
    @@ -294,6 +368,65 @@ def _is_probed_path(path: str) -> bool:
         return len(suffix) > 1 and suffix[1].isalpha()
     
     
    +def _is_test_module(path: str) -> bool:
    +    """Whether `path` is a test module under `tests/`."""
    +    name = PurePosixPath(path).name
    +    return (
    +        path.startswith(_TESTS_DIR)
    +        and path.endswith(_PYTHON_SUFFIX)
    +        and any(fnmatchcase(name, pattern) for pattern in _TEST_MODULE_PATTERNS)
    +    )
    +
    +
    +def _is_source_file(path: str) -> bool:
    +    """Whether `path` is a Python source file under `src/`."""
    +    return path.startswith(_SRC_DIR) and path.endswith(_PYTHON_SUFFIX)
    +
    +
    +def _bound_names(text: str) -> frozenset[str]:
    +    """The names that `text` binds: its functions, its classes and its assignment targets, read
    +    with `ast`. A text that is no Python module binds no name."""
    +    try:
    +        tree = ast.parse(text)
    +    except SyntaxError:
    +        return frozenset()
    +    names: set[str] = set()
    +    for node in ast.walk(tree):
    +        match node:
    +            case ast.FunctionDef() | ast.AsyncFunctionDef() | ast.ClassDef():
    +                names.add(node.name)
    +            case ast.Name() if isinstance(node.ctx, ast.Store):
    +                names.add(node.id)
    +    return frozenset(names)
    +
    +
    +def _test_cases(text: str) -> list[tuple[str, str]]:
    +    """Each `def test_...` case of a test module with the text of its body, in the order of the
    +    module. A text that is no Python module holds no case."""
    +    try:
    +        tree = ast.parse(text)
    +    except SyntaxError:
    +        return []
    +    cases: list[tuple[str, str]] = []
    +    for node in tree.body:
    +        if not isinstance(node, ast.FunctionDef) or not node.name.startswith(_CASE_PREFIX):
    +            continue
    +        body = "\n".join(
    +            segment
    +            for statement in node.body
    +            if (segment := ast.get_source_segment(text, statement)) is not None
    +        )
    +        cases.append((node.name, body))
    +    return cases
    +
    +
    +def _named_cases(module: str, names: frozenset[str]) -> tuple[str, ...]:
    +    """The cases of the test module `module` whose body holds one of `names` as a word."""
    +    return tuple(
    +        case for case, body in _test_cases(module) if set(_WORDS.findall(body)) & names
    +    )
    +
    +
     def _tokens(segment: str) -> Iterator[str]:
         """Each backticked span or bare word of `segment`, in the order of the text."""
         for match in _TOKEN.finditer(segment):
    @@ -335,8 +468,9 @@ def _absence_pairs(body: str) -> tuple[tuple[str, str], ...]:
     def probe_premise(source: Path, sha: str, body: str) -> Probe:
         """Probe each path, class field and identifier that `body` cites at commit `sha` of the
         checkout `source`. The paths come first, then the fields that an absence statement names, then
    -    the identifiers, each in the order of the text. An item for which no command is left is listed
    -    as skipped."""
    +    the identifiers, each in the order of the text. The test cases of each cited test module that
    +    name a name of a cited source file come last. An item for which no command is left is listed as
    +    skipped."""
         run = _Run(source, sha)
         absent = _absence_pairs(body)
         run.absent = frozenset(absent)
    @@ -360,6 +494,10 @@ def probe_premise(source: Path, sha: str, body: str) -> Probe:
                 run.field(name)
             else:
                 run.identifier(name)
    +    run.pairs(
    +        [path for path in paths if path in run.present and _is_test_module(path)],
    +        [path for path in paths if path in run.present and _is_source_file(path)],
    +    )
         commands = CONST_ROADMAP_STAGE_PROBE_MAX_COMMANDS - run.left
         return Probe(
             tuple(run.lines),
    diff --git a/tests/roadmap/stage/test_roadmap_stage_probe.py b/tests/roadmap/stage/test_roadmap_stage_probe.py
    index eed2fad5..535c65ae 100644
    --- a/tests/roadmap/stage/test_roadmap_stage_probe.py
    +++ b/tests/roadmap/stage/test_roadmap_stage_probe.py
    @@ -22,6 +22,27 @@ LIVE_SOURCE = "def keep_comment(comments):\n    return comments[:-1]\n\nLIMIT =
     GONE_SOURCE = "def validate_url(url):\n    return url\n"
     MODEL = "src/devops_cli/model.py"
     MODEL_SOURCE = "class PullStatus:\n    labels: tuple[str, ...] = ()\n    state: str = ''\n"
    +# A cited source file and the test module of its behaviour (#3443).
    +PROBE = "src/devops_cli/roadmap/stage/stage_probe.py"
    +PROBE_TEST = "tests/roadmap/stage/test_roadmap_stage_probe.py"
    +PROBE_SOURCE = (
    +    "def probe_premise(source, sha, body):\n"
    +    "    return body\n\n\n"
    +    "def blocked_by(missing, creators):\n"
    +    "    return ()\n"
    +)
    +PATHS = "src/devops_cli/roadmap/stage/stage_paths.py"
    +PATHS_SOURCE = "def same_name(path):\n    return path\n"
    +MODELS = "src/devops_cli/roadmap/stage/stage_models.py"
    +MODELS_SOURCE = "def parse_class_fields(text):\n    return {}\n"
    +PROBE_TEST_SOURCE = (
    +    "def test_missing_path_an_open_plan_creates_is_a_dependency():\n"
    +    "    assert blocked_by([], {}) == ()\n\n\n"
    +    "def test_the_probe_stops_at_the_bound_and_lists_the_items_it_skipped():\n"
    +    "    assert 1 + 1 == 2\n"
    +)
    +# The paths that the bound leaves no command for after the pair of `PROBE` and `PROBE_TEST`.
    +DOCS = tuple(f"docs/sample_{index}.md" for index in range(9))
     
     
     @pytest.fixture
    @@ -38,6 +59,14 @@ def _probe(repo: StageRepo, body: str) -> stage_probe.Probe:
         return probe_premise(repo.clone, repo.git("rev-parse", "HEAD"), body)
     
     
    +def _case_line(probe: stage_probe.Probe, module: str) -> str:
    +    """The probe line that lists the cases of the test module `module`."""
    +    (line,) = [
    +        found for found in probe.lines if found.startswith(f"The test module `{module}`")
    +    ]
    +    return line
    +
    +
     def test_a_present_path_and_a_defined_identifier_are_confirmed(repo: StageRepo) -> None:
         probe = _probe(repo, f"Change `{LIVE}` and `keep_comment`.")
     
    @@ -237,3 +266,44 @@ def test_the_field_probe_counts_its_commands_and_leaves_the_checkout(
     
         assert probe.commands == 2
         assert repo.git("status", "--porcelain") == ""
    +
    +
    +def test_the_probe_lists_the_test_cases_that_name_a_symbol_of_a_cited_source_file(
    +    repo: StageRepo,
    +) -> None:
    +    repo.track({PROBE: PROBE_SOURCE, PROBE_TEST: PROBE_TEST_SOURCE})
    +
    +    probe = _probe(repo, f"Change `{PROBE}` and `{PROBE_TEST}`.")
    +
    +    line = _case_line(probe, PROBE_TEST)
    +    assert PROBE in line
    +    assert "test_missing_path_an_open_plan_creates_is_a_dependency" in line
    +    assert "test_the_probe_stops_at_the_bound_and_lists_the_items_it_skipped" not in line
    +    assert probe.skipped == ()
    +
    +
    +def test_the_probe_says_when_the_test_module_names_no_symbol_of_the_source(
    +    repo: StageRepo,
    +) -> None:
    +    repo.track({PATHS: PATHS_SOURCE, MODELS: MODELS_SOURCE, PROBE_TEST: PROBE_TEST_SOURCE})
    +
    +    probe = _probe(repo, f"Change `{PATHS}`, `{MODELS}` and `{PROBE_TEST}`.")
    +
    +    assert f"holds no case that names a symbol of `{PATHS}`" in probe.text
    +    assert f"holds no case that names a symbol of `{MODELS}`" in probe.text
    +
    +
    +def test_the_bound_names_the_test_module_and_the_source_it_left_unlisted(
    +    repo: StageRepo,
    +) -> None:
    +    repo.track({PROBE: PROBE_SOURCE, PROBE_TEST: PROBE_TEST_SOURCE})
    +    repo.track({path: "# Sample\n" for path in DOCS})
    +    body = " ".join(f"`{path}`" for path in (PROBE, PROBE_TEST, *DOCS))
    +
    +    probe = _probe(repo, body)
    +
    +    assert probe.commands == CONST_ROADMAP_STAGE_PROBE_MAX_COMMANDS
    +    (bound,) = [line for line in probe.text.splitlines() if line.startswith("Not probed")]
    +    assert PROBE_TEST in bound
    +    assert PROBE in bound
    +    assert "test_missing_path_an_open_plan_creates_is_a_dependency" not in probe.text

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

  13. added
    status/blocked
    and removed
    status/in-progress
    on Nov 10, 2026
  14. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261110-105724-b626 ended: succeeded.
    Image digest: sha256:4e4c13460c63a1974b17116e0ca085e2079ee8a31822b89c86b41990fa1659cc

    The last lines of its log:

    Tool call: shell, started: uv run devops ci test tests/roadmap/stage
    Tool call: shell, program uv, ok.
    Tool call: shell, started: git diff
    Tool call: shell, program git, ok.
    Tool call: read_file, ok.
    Tool call: grep, ok.
    Tool call: read_file, ok.
    Tool call: grep, ok.
    Tool call: grep, ok.
    Tool call: shell, started: tail -20 /home/devops/.data/agent/worktrees/w-3443/.pydantic-ai-harness/shell/e3c2adec05e447df9c5a2281aad5be4a/output.log
    Tool call: shell, program tail, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: read_file, ok.
    Tool call: read_file, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: uv run devops openspec check
    Tool call: shell, program uv, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: tail -5 /home/devops/.data/agent/worktrees/w-3443/.pydantic-ai-harness/shell/e3c2adec05e447df9c5a2281aad5be4a/output.log
    Tool call: shell, program tail, ok.
    Tool call: shell, started: uv run ruff check tests/roadmap/stage/test_roadmap_stage_probe.py src/devops_cli/roadmap/stage/stage_probe.py ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci --help
    Tool call: shell, program uv, ok.
    Tool call: read_file, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: tail -3 /home/devops/.data/agent/worktrees/w-3443/.pydantic-ai-harness/shell/e3c2adec05e447df9c5a2281aad5be4a/output.log
    Tool call: shell, program tail, ok.
    Tool call: read_file, ok.
    Tool call: read_file, ok.
    Tool call: grep, ok.
    Tool call: read_file, ok.
    Tool call: grep, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: tail -3 /home/devops/.data/agent/worktrees/w-3443/.pydantic-ai-harness/shell/e3c2adec05e447df9c5a2281aad5be4a/output.log
    Tool call: shell, program tail, ok.
    Failure class limit_reached. Action left: raise_limit.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 18m 20s
    
  15. removed
    owner/service
    on Nov 10, 2026
  16. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    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.

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/agentstatus/blockedtype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions