Skip to content

feat(roadmap): surface scoped tests in plan reads #3993

Closed

Description

@dan-petty

Problem Description

When stage creates task groups for an item, it generates Reads: and Changes: lists for each group. During implement, the job calculates scoped tests dynamically with plan_tests() based on changed source files. If the tests selected by plan_tests() are not included in Reads:, the implement model does not have them in its initial context. Moreover, if any of those scoped tests fail on the base commit or are sensitive to the runner environment, stage does not detect the issue, leading to wasted implement turns and budget exhaustion.

Proposed Solution

  1. When stage plans an item, run plan_tests() against the planned Changes: list.
  2. Include the identified test modules in Reads: so the implement model has full context on tests that will gate the commit.
  3. Validate that the identified scoped tests pass on the base commit before opening the staging pull request.

Expected vs Actual Behavior

Expected: The plan explicitly identifies which existing test modules cover the changed files, surfaces them in Reads:, and verifies they pass on the base commit.
Actual: stage only checks that file paths exist, leaving implement to discover and run tests that the model was never shown.

Environment Diagnostics

  • DevOps CLI Version: 0.77.2
  • Python Version: 3.14.10
  • Execution Environment: Roadmap Service (Stage & Implement jobs)

Proposed design

Problem statement

Stage plans do not show the scoped tests that implement will run. The implement model must discover those tests, and a scoped test that fails on the base commit wastes implement turns. The change surfaces the scoped tests in each group's Reads list.

Acceptance criteria

Requirement: Scoped tests in plan reads

When stage plans a task group, it SHALL run plan_tests() against the group's planned Changes: list and add each selected test module to the group's Reads: list.

Scenario: Source change selects a test

  • WHEN Stage plans a group whose Changes: list contains a source file that plan_tests() maps to a test module.
  • THEN The group's Reads: list contains that test module.

Requirement: Existing reads preserved

Stage MUST keep every file that it already puts in a group's Reads: list and MUST add each scoped test module once.

Scenario: Scoped test is already in reads

  • WHEN A test module selected by plan_tests() is already in the group's Reads: list.
  • THEN The group's Reads: list contains that module once and keeps the other files.

Requirement: No scoped tests

When plan_tests() returns no test module for a group, stage MUST leave the group's Reads: list unchanged.

Scenario: No test covers the change

  • WHEN Stage plans a group whose Changes: list yields no test module from plan_tests().
  • THEN The group's Reads: list has the same files as before the scoped-test step.

Requirement: Missing scoped test path

When plan_tests() returns a test path that does not exist, stage MUST omit the path from Reads: and MUST record a warning in the plan.

Scenario: Scoped test path is missing

  • WHEN plan_tests() returns a test path that does not exist in the repository.
  • THEN The group's Reads: list does not contain that path, and the plan records a warning that names the path.

Existing Tool Considered

No alternatives check has run. No external tool covers the stage plan Reads: integration. The change reuses the existing plan_tests() function and adds a small adapter. pytest-testmon is an open, maintained library that selects tests affected by code changes, but it lacks stage plan Reads: integration and needs coverage instrumentation. The adapter costs one function and its tests; it builds no new selector.

Key questions

  • Which test-selection function should stage use?: Stage should reuse the existing plan_tests() function that the implement job uses. Stage must not add a second selector. (best practice) [sources: tests/roadmap/implement/test_roadmap_implement_job_scoped.py]
    • Chosen: Reuse plan_tests(). It keeps stage and implement on one selector and adds no new code to maintain.
    • Rejected: Build a stage selector. It duplicates the implement selector and can disagree with it.
    • Rejected: Adopt pytest-testmon. It needs coverage instrumentation and lacks the plan Reads: integration.
  • Which task group receives a scoped test module?: The group whose Changes: list causes plan_tests() to return the module. Each group gets only its own scoped tests. (best practice) [sources: CONTEXT.md]
    • Chosen: Per group. The group is the unit of a step, and its inputs must fit the token budget.
    • Rejected: All groups. It repeats the same test in every group and can exceed the step budget.
    • Rejected: Item level only. It loses the link between a change and the test that covers it.
  • What should stage do when plan_tests() returns a test path that does not exist?: Stage should omit the path from Reads: and record a plan warning. Stage should not fail for an advisory selection result. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md]
    • Chosen: Omit and warn. The plan stays buildable and the missing test stays visible.
    • Rejected: Fail staging. A stale test mapping stops an otherwise valid plan.
    • Rejected: Add the path. A missing file gives the implement model no context.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-09: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 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 reduces wasted implement turns and budget burn but does not block a broken pipeline.
    • Value: Medium. It saves model calls and prevents budget exhaustion on every stage that touches tested code.
    • Effort: Medium. It requires wiring plan_tests() into stage, editing Reads generation, and adding a pre-PR validation step.
    • Related: fix(roadmap): stage includes perimeter tests for network policies #3972, which asks for a different change. Both concern stage including test files in the plan, but #3972 fixes a specific omitted test in Changes while the candidate generalizes via plan_tests() into Reads and adds a base-commit pass check.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 8, 2026
  5. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 1f03ee3 (see proposed design in issue body).

    Moved to new items: #4145.

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

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The need is internal wiring. Stage's plan Reads: lists must include the test modules that the project's own plan_tests() selects, with a warning for missing paths and a base-commit check. My one web search found nothing relevant. pytest-testmon is open and maintained, but it selects tests from coverage data. It does not know the stage plan format, and it would add a second selector that could disagree with plan_tests(). No ADR rejects it by name.

    Tool: none found

    Covers:

    • pytest-testmon selects tests affected by code changes

    Lacks:

    • Integration with stage plan Reads: lists
    • Reuse of the project's existing plan_tests() selector
    • Warnings for missing test paths in the plan
    • Needs coverage instrumentation

    Tools considered:

    Searches run:

    • select tests affected by changed source files pytest, results: 5

    Sources:

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

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

    @devops-cli-service
    Contributor
  10. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-16 06:35 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