Skip to content

fix(roadmap): the module-test and caller gates refuse correct plans #4467

Closed

Description

@dan-petty

Problem Description

Two stage plan gates refuse correct plans. The refusals stop the stage job for items that have a correct plan.

  1. The module-test gate (fix(roadmap): refuse a behavior group that omits a test it changes #3414, PR fix(roadmap): refuse a behavior group that omits a test it changes #4356, live since 0.107.2) finds the tests of a changed module with grep_at in src/devops_cli/roadmap/stage/stage_overlap.py. grep_at runs git grep -w -e <name>, so each dot of the dotted module name is a regex wildcard. devops_cli.lang.en.messages then matches the path text devops_cli/lang/en/messages in tests/commands/test_new.py and in fixtures. A plan that changes src/devops_cli/lang/en/messages.py must then name tests/commands/test_new.py, which does not import the module. A test that holds the name of the module in a string or a path is no test of the module either.
  2. The caller gate (feat(roadmap): name every caller of a changed function #3307) reads a function name from each task text of the form Add ... to name``. The match runs across sentences and also takes a class (an enum member, a field, a property) as a function. StagedTree.callers then runs `git grep -F "name("` with no word boundary, so `_fix(` matches `scan_fix(` and `TaskGroup(` matches `asyncio.TaskGroup(`.

Reproduction Steps

  1. Read the refused replies of the stage job (<n>.refused.json, written at src/devops_cli/roadmap/stage/stage.py:1258) for the items of 2026-11-10 and 2026-11-11.
  2. Count the problems "names no existing test of that module" and "which calls it".
  3. Compare each problem with the import lines of the named test and with the call sites of the named function at the staged commit.

Expected vs Actual Behavior

Expected: a test counts for a changed module only when it imports that module. The caller gate reads only a parameter that a task adds to a function, and it names only a file that calls that function.

Actual: in 36 refused replies, 18 of 34 module-test problems and 22 of 26 caller problems are false. The module-test gate was in all 4 stage row errors after 17:44Z on 2026-11-10, and in 7 of the last 12 stage failures.

Environment Diagnostics

  • DevOps CLI Version: 0.110.0
  • Execution Environment: Service (the stage job in the cluster)

Logs, Traces, or Terminal Output

Group 1 changes `src/devops_cli/lang/en/messages.py` and names no existing test of that module. Add `tests/commands/test_new.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.
The plan changes `TaskGroup` and leaves out `src/devops_cli/ai/review/pool.py`, which calls it.
The plan changes `_fix` and leaves out `src/devops_cli/commands/scan.py`, which calls it.

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

Two stage plan gates refuse correct plans. The module-test gate searches a dotted module name as a regular expression. A dot then matches a slash, so a path in a test file counts as a test of the module.

The caller gate reads a function name across sentences. It takes a class or a field as a function. It matches a longer identifier that ends with the name. The fix searches the module name as a literal string and keeps only tests that import the module. It reads callers from the syntax tree of the staged files.

Acceptance criteria

Requirement: A path in a string is no test of the module

The module-test gate SHALL NOT count a file as a test of a changed module when the file holds the module path as text and imports no part of the module.

Scenario: A test holds the module path in a string

  • WHEN a plan changes src/devops_cli/lang/en/messages.py and tests/commands/test_new.py holds src/devops_cli/lang/en/messages.py with no import of the module
  • THEN the gate reports no problem for that group

Requirement: The gate names the importing test

The module-test gate SHALL report a problem that names a test file that imports the changed module, when the plan leaves that file out.

Scenario: The plan leaves out the importing test

  • WHEN a test file holds from devops_cli.lang.en.messages import MESSAGES and the plan that changes the module does not name it
  • THEN the gate reports a problem that names that test file

Requirement: The module name is a fixed string

grep_at SHALL pass -F to git grep, so the name is a fixed string and no dot of it matches another character.

Scenario: A module name with dots

  • WHEN grep_at searches for devops_cli.lang.en.messages at the staged commit
  • THEN the search returns the files that hold that literal text and no file that holds only devops_cli/lang/en/messages

Requirement: The caller gate reads one task

The caller gate SHALL read a function name only from a task whose whole text has the form Add &lt;parameter> to <name>`` and SHALL read no name from a task that holds more text.

Scenario: A task holds a second sentence

  • WHEN a task holds the words Add the field to and the code span TaskGroup, then a second sentence
  • THEN the gate reads no function name from that task

Requirement: A class or a field is no function

The caller gate SHALL ignore a name that the staged commit defines as a class, an enum member, a field or a property, and SHALL read only a function or a method.

Scenario: A task names an enum member

  • WHEN a task holds the words Add a member to and the code span Status, and Status is a class at the staged commit
  • THEN the gate reports no missing caller

Requirement: A longer name is no caller

The caller gate SHALL count a call only when the called name is the whole identifier, so a longer identifier that ends with the name is no call.

Scenario: A longer function name holds the name

  • WHEN the plan changes _fix and src/devops_cli/commands/scan.py holds def scan_fix( with no call to _fix
  • THEN the gate names no file for _fix

Requirement: A call of another module is no caller

The caller gate SHALL count a call only in a file that imports the function from the module that defines it, so a call of the same short name from another module is no caller.

Scenario: The same short name in another module

  • WHEN the plan changes the TaskGroup of the stage plan and src/devops_cli/ai/review/pool.py calls asyncio.TaskGroup with no import of the stage module
  • THEN the gate names no caller in src/devops_cli/ai/review/pool.py

Requirement: The metric senders keep their files

The fixed-string search SHALL return the same files for a metric name of INSTRUMENTS as the word search returned.

Scenario: A metric name with no dot

  • WHEN metric_senders searches for a name of INSTRUMENTS at the staged commit
  • THEN the search returns each file that holds the name as a whole word

Existing Tool Considered

No alternatives check has run. The ast module of the Python standard library covers the need: it reads the imports and the calls of a Python file, so the gate keeps a test that imports the module and a file that calls the function. It lacks a repository-wide search, so the gate still takes its candidate files from git grep -F.

Key questions

  • Which tool reads the imports and the calls of a staged Python file?: The ast module of the Python standard library. It parses a file into Import, ImportFrom and Call nodes, and the gate reads them without a run of the code. (best practice) [sources: src/devops_cli/roadmap/stage/stage_overlap.py:204]
    • Chosen: ast of the Python standard library. It reads the imports and the calls of a file with no dependency and no run of the code.
    • Rejected: tree-sitter-python. It adds a parser and a grammar to the path, and ast reads the same Python with no extra dependency.
    • Rejected: A regular expression over the file text. A string, a comment and a longer identifier match, which is the defect of this issue.
  • How does grep_at keep a dotted module name literal?: It passes -F to git grep and keeps -w, so the name is a fixed string and a whole word. metric_senders keeps its result, because a metric name holds no dot. (best practice) [sources: src/devops_cli/roadmap/stage/stage_overlap.py:204, src/devops_cli/roadmap/stage/stage_overlap.py]
    • Rejected: Escape the name with re.escape before git grep. grep_at promises the files that hold a name, and a regex escape still matches a comment or a string that holds the name.
    • Chosen: Pass -F to git grep. The name is a literal, and -F removes the wildcard dot for the module gate and keeps the metric search exact.
    • Rejected: Keep -w -e and filter the hits in the module gate. The wildcard still returns the path hits, and the gate drops them only by a second text rule.
  • Which test files count as the tests of a changed module?: The files under tests/ that the fixed-string search returns and that import the module. The gate reads each candidate with ast and keeps import &lt;module>, from &lt;module> import &lt;name> and from &lt;package> import &lt;module name>. (best practice) [sources: tests/commands/test_new.py]
    • Rejected: Keep the text hit. A path or a string that holds the name counts as a test, which is the defect of this issue.
    • Chosen: Read the candidates with ast and keep the importing files. An import line is the one evidence that a test reads the module.
    • Rejected: Import each candidate module at runtime. It runs the code and needs the fixtures and the dependencies of the test.
  • How does the caller gate read a function name from a task?: It matches the whole task text against ^Add .+ to <name>$, so a second sentence gives no name. It then reads the definition of &lt;name> in the staged tree with ast. (best practice) [sources: src/devops_cli/lang/en/messages.py]
    • Rejected: Search the whole task text for Add ... to and a code span. The match runs across a sentence break, which is the defect of this issue.
    • Chosen: Match the whole task text against ^Add .+ to <name>$. A second sentence then gives no name, and the task form stays the one that the gate documents.
    • Rejected: Take the last code span of the task. A task holds a path or a command in a code span, so the last span is often no function.
  • Which names does the caller gate accept as a function?: Only a FunctionDef or an AsyncFunctionDef at the staged commit, at module level or in a class body. A ClassDef, an enum member, an AnnAssign and a property give no caller problem. (best practice) [sources: src/devops_cli/lang/en/messages.py]
    • Rejected: Take every name as a function. The issue shows an enum member and a field that the gate took as a function.
    • Chosen: Look the name up with ast and accept only a function or a method. The staged commit holds the definition, so the gate reads the real kind of the name.
    • Rejected: Keep a list of the known classes and fields. The list goes stale with the next class that a change adds.
  • Which files does the caller gate name as callers?: The files that hold a Call node whose name is the function, and that import the function from its defining module. A longer identifier and a call of the same short name from another module give no caller. (best practice) [sources: src/devops_cli/ai/review/pool.py, src/devops_cli/commands/scan.py]
    • Rejected: git grep -F "name(". _fix( matches scan_fix(, and TaskGroup( matches asyncio.TaskGroup(.
    • Rejected: git grep -F -w "name(". A word boundary still matches asyncio.TaskGroup, because the short name is the same.
    • Chosen: git grep -F -l for candidates, then ast calls that import the name from the defining module. The search bounds the files to read, and the syntax tree and the import prove that the file calls this function.
  • Does the fixed-string search keep the metric senders?: Yes. metric_senders passes a name of INSTRUMENTS, which holds letters, digits and underscores and no dot, so -F -w returns the same files as -w -e. [sources: src/devops_cli/roadmap/stage/stage_overlap.py]
  • Where do the tests of the two gates go?: tests/roadmap/stage/test_roadmap_stage_paths.py holds the tests of grep_at, and the new tests of the two gates go beside it in tests/roadmap/stage/. [sources: tests/roadmap/stage/test_roadmap_stage_paths.py]
  • Where do the import and call readers go?: A new module src/devops_cli/roadmap/stage/stage_symbols.py holds the three ast readers: the imports of a file, the definition of a name, and the calls of a name. The two gates call it, so each rule has one implementation and one test module. (best practice) [sources: src/devops_cli/roadmap/stage/stage_overlap.py:204, src/devops_cli/roadmap/stage/stage.py:1258]
    • Rejected: Put the readers in stage_overlap.py. That module names open plans and metric senders, and the readers serve two other gates.
    • Rejected: Put the readers in stage.py. The stage job module is already large, and it holds the job and not a file reader.
    • Chosen: A new stage_symbols.py. One module holds the three readers, and each gate imports it.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/medium
    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: P1-High. The gates block correct plans and caused 7 of the last 12 stage failures.
    • Value: High. Correct plans are rejected, stopping the stage job for valid work.
    • Effort: Medium. Two grep calls need literal matching and word-boundary fixes in one file.
    • Related: fix(roadmap): refuse a behavior group that omits a test it changes #3414, which asks for a different change. Both concern the module-test gate, but #3414 adds the gate while the candidate fixes its false-positive grep matching.
  3. added
    priority/p1-high
    owner/agent
    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 54743c4 (see proposed design in issue body).

  6. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Service data, 48 hours to 2026-11-10T23:45Z: the module-test gate

    Count: 7 item refusals with "names no existing test of that module" in the 4 failed stage rounds after the gate went live (#4356, released in 0.107.2, live at 14:35Z on 2026-11-10). The rounds were at 17:44, 18:33, 20:24 and 21:11Z, with 12 item failures in all.

    Item Module Suggested test
    #3389 lang/en/messages.py tests/commands/test_new.py
    #4401 lang/en/help.py tests/commands/test_new.py
    #3398 lang/en/messages.py tests/commands/test_new.py
    #3407 roadmap/plan_check.py tests/invariants/test_workflow_contracts.py
    #4028 lang/en/messages.py tests/commands/test_new.py
    #4043 lang/en/messages.py tests/commands/test_new.py
    #3447 github/client.py tests/ai/client/test_batch_2_review_defects.py

    First and last: 17:44Z on 2026-11-10, and 03:06:45Z on 2026-11-11 (#4028 again, after the window). Still occurring: yes.

    Cost: only #4043 had this refusal as its single problem after the second try. The other 6 items also had other refusals (What Changes, Feasibility cite, callers, test path, self-acceptance), so no round failed for this gate alone. The repair round of #4043 did not add the suggested test, also when it was the single problem. 5 of the 14 stage results in the window (12 failures and 2 staged plans) touched messages.py or help.py, so the gate is a latent blocker for each of those plans.

    Root cause, with a correction to the fix of this issue. There are two separate causes:

    1. Regex match (5 of 7 refusals). grep_at (src/devops_cli/roadmap/stage/stage_overlap.py:204) runs git grep -w -l -e <name> with no -F. record_module_tests (src/devops_cli/roadmap/stage/stage_paths.py:377) adds each test that the search returns. _unnamed_module_test (stage_paths.py:405) suggests tests[0] in sort order.
    2. A shared module gets every test that imports it. I ran record_module_tests at HEAD with the live grep_at and with git grep -w -F (script: .data/agent/scratch/svc48/t2_module_tests.py):
    Module Regex: count, first test -F: count, first test
    lang/en/messages.py 8, tests/commands/test_new.py 1, tests/roadmap/implement/test_roadmap_implement_amend.py
    lang/en/help.py 2, tests/commands/test_new.py 0
    roadmap/plan_check.py 5, test_workflow_contracts.py 2, test_workflow_contracts.py
    github/client.py 17, test_batch_2_review_defects.py 14, test_batch_2_review_defects.py

    So -F alone removes only the help.py refusal. test_roadmap_implement_amend.py really has from devops_cli.lang.en.messages import MESSAGES on line 5, so an "imports the module" rule also keeps it, and the messages.py plans stay refused with an unrelated suggestion. Most tests (48) import the registry as from devops_cli.lang import MESSAGES, which neither search finds. For a text registry (lang/en/messages.py, lang/en/help.py), the fix must leave it out of the gate or require a more specific match. The plan_check.py and github/client.py refusals are the gate working as designed (the plans named no importing test), with a poor suggestion: tests[0], not the most specific test.

    Two smaller defects:

    • The stem match at stage_paths.py:395-398 takes a test file name from any folder, so github/client.py also gets tests/cloudflare/test_client.py.
    • The live search and the replay search differ. plan_recheck.py:282-296 searches with -F and no -w, so a plan_recheck replay does not reproduce the live test_new.py suggestion. Make the two searches the same before a replay measures the fix.

    Priority: P1 fits the evidence.

    Queries:

    Loki: {namespace="devops", app_kubernetes_io_name="roadmap-service"} |= "the stage job failed for"   (2026-11-10T14:39Z to 2026-11-11T03:15Z)
    Prometheus: devops_cli_roadmap_stage_gate_refusals_total{gate="paths"}   (it does not split by problem kind)
    uv run python .data/agent/scratch/svc48/t2_module_tests.py
    
  7. removed
    status/ready
    owner/agent
    on Nov 11, 2026
  8. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor
  9. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 14:13 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/p1-highscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions