Skip to content

fix(roadmap): the implement step runs the type check of the gate, not strict mypy on every file #3090

Description

@dan-petty

What happened

The implement step runs mypy --strict on each Python file it changed, and the Job stops when mypy reports an error. mypy also reports the errors of the files that the checked file imports. MYPYPATH=src mypy --strict tests gives 739 errors in 220 files. So a step that changes one test file stops on old errors that it did not cause. Live stops of 2026-11-01: #2116 (tests/security/test_scanner_tool_executor.py, import-untyped), #2491 (tests/support/fakes/process.py:310, Too many arguments for "object"), #2166 (tests/core/test_process.py:570, set_process_runner argument type).

The first version of this issue named the --no-editable install and a missing py.typed as the cause. That was wrong: a non-editable install and the editable install of a workstation both give the same 48 errors on the two files (reproduced with a scratch venv; mypy 2.3.1). mypy_path = "src" removes only the import-untyped errors and leaves 10 real, old errors in those files.

The project gate does not check test files with strict mypy: devops ci runs mypy --strict src only. The step checks more than CI does, and it stops on what CI would pass.

What should happen

The step runs the checks of the gate, not stricter ones. It runs mypy --strict on the changed files under src/ and no type check on test files, exactly as devops ci does (read the list of files from the same constant or command that the gate uses, so that a change of the gate changes the step). It runs ruff and the formatter on every changed file, as the pre-commit hooks do.

Acceptance criteria

  • A step that changes tests/security/test_scanner_tool_executor.py does not stop on mypy errors of that file.
  • A step that changes a file under src/ still stops on a new mypy --strict error in that file.
  • The step takes the file set of the type check from the gate's own definition, and a test fails if the two differ.
  • The decision (the gate's rule, not a baseline) and its reason are in the proposal.

Related: #3027, #3072, #3043.

Proposed design

Problem statement

The implement step runs mypy --strict on every changed Python file, including test files. Mypy reports errors from imported files, so a step that changes one test file stops on pre-existing errors it did not cause. The CI gate runs mypy --strict on src/ only and does not type-check test files. The step checks more than the gate and stops on what the gate passes.

Acceptance criteria

Requirement: No mypy on test files

The implement step SHALL NOT run mypy on files under tests/.

Scenario: Step changes a test file

  • WHEN A step changes tests/security/test_scanner_tool_executor.py
  • THEN The step does not stop on mypy errors of that file

Requirement: Mypy on src files

The implement step SHALL run mypy --strict on changed files under src/ and stop on a new error in that file.

Scenario: Step changes a src file with a type error

  • WHEN A step changes a file under src/ that has a new mypy --strict error
  • THEN The step stops on that error

Requirement: File set from gate definition

The implement step SHALL read the mypy file set from the same definition that the CI gate uses, and a test SHALL fail if the two differ.

Scenario: Gate and step file sets differ

  • WHEN The gate's mypy file set and the step's mypy file set differ
  • THEN A test fails

Requirement: Ruff and formatter on all changed files

The implement step SHALL run ruff and the formatter on every changed file, as the pre-commit hooks do.

Scenario: Step changes any file

  • WHEN A step changes any file in the repository
  • THEN Ruff and the formatter run on that file

Existing Tool Considered

mypy (already in use by the project) covers the type-checking need. The project's devops ci command already defines the correct file set (src/). No new tool or library is needed. The change is in how the project's implement step code invokes mypy: it must read the file set from the gate's own definition instead of hard-coding a broader set.

Key questions

  • Where does the CI gate define its mypy file set?: The gate runs mypy --strict src. The definition lives in the devops ci command implementation. The step must read the file set from that same source. [sources: docs/adr/0004-ci-is-the-authoritative-gate.md]
  • Should the step type-check only the changed files under src/, or the whole src/ directory?: The step type-checks only the changed files under src/. This matches the gate's scope (src/) while limiting the check to files the step actually modified. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md]
    • Chosen: Type-check only changed files under src/. Matches the gate's scope and limits the check to files the step modified. A new error in an unchanged file is not the step's fault.
    • Rejected: Type-check the whole src/ directory. Catches errors in any src file, but stops the step on pre-existing errors it did not cause. This is the current broken behavior.
    • Rejected: Type-check all changed files including tests/. This is the current behavior. It stops the step on test-file errors and imported-file errors that the gate does not check.
  • How does the step stay in sync with the gate's file set?: The step reads the mypy file set from the same constant or command that the gate uses. A change of the gate changes the step automatically. A test asserts the two are equal. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md]
    • Chosen: Read from the gate's own constant or command. A change of the gate changes the step automatically. No duplication. A test can assert equality.
    • Rejected: Duplicate the file list in the step. The step and gate can drift apart. A change to the gate does not update the step. This is the current source of the bug.
  • Should the step run ruff and the formatter on every changed file?: Yes. The step runs ruff and the formatter on every changed file, as the pre-commit hooks do. This is separate from the mypy check and applies to all file types. (proposed)
    • Chosen: Run ruff and formatter on every changed file. Matches the pre-commit hooks. Catches style and format issues in any file the step changes.
    • Rejected: Run ruff and formatter only on src/ files. Leaves test files and other files unchecked. Inconsistent with the pre-commit hooks.

Open questions

  • Where is the implement step's current mypy invocation? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/high
    effort/medium
    on Nov 1, 2026
  2. dan-petty commented on Nov 1, 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: none. The title has the scope runner, and .github/labels.yml declares no scope/runner label. Add the label to the file to give the scope to this item.
    • Priority: P1-High. CI runner jobs are stopping on false mypy errors, blocking merges for at least 3 of 13 runs on one day.
    • Value: High. Developers cannot merge code while CI reports false type errors on correct code.
    • Effort: Medium. Setting mypy_path is a one-line config change, but the build check step needs design and verification against mypy search-order docs.
    • Related: fix(devcontainer): the devops on PATH is the editable install of the checkout, not a copy the image built #2449, which asks for a different change. Both fix a tool resolving to the installed copy instead of the checkout, but #2449 fixes PATH for the devops binary in devcontainer while this sets mypy_path for type checking in the runner image.
  3. added
    priority/p1-high
    owner/agent
    on Nov 1, 2026
  4. dan-petty commented on Nov 1, 2026

    @dan-petty
    OwnerAuthor

    The item cannot be built as written. The premise is false, and the acceptance criteria cannot pass with mypy_path = "src". I changed no code.

    Evidence (commit 0dbd092, mypy 2.3.1, run in a worktree):

    1. The stated cause is wrong. I built a venv with uv sync --locked --no-editable (as the Dockerfile does). mypy --strict -- tests/security/test_scanner_tool_executor.py tests/support/fakes/process.py gives 48 errors, most of them import-untyped. The normal editable environment (uv run mypy, same command) gives the same 48 errors. An editable install adds src through a .pth file. Mypy reads that path as an installed package, and the package has no py.typed marker. So a workstation does not differ from the runner. devops ci does not show it, because it runs mypy --strict src only: no test file is type-checked in CI.

    2. mypy_path = "src" works as the issue says for the import. The mypy source (mypy/modulefinder.py, compute_search_paths and _find_module) searches python_path and mypy_path before the installed packages. With MYPYPATH=src the import-untyped errors go away in both environments.

    3. The acceptance criteria still fail. The same command then gives 10 real errors in 5 files. Examples: tests/security/test_scanner_tool_executor.py:222 (Item "None" of "Path | None" has no attribute "is_relative_to"), :656 (base_revision type), tests/support/fakes/process.py:310 and :399 (Too many arguments for "object", the error of fix(github): a refused JWT exchange of the GitHub App names GitHub's reason, not a gh login #2491), tests/support/git_recording.py:156 (set_process_runner argument, the error of refactor(security): the unused run_subprocess re-import in security/ruff.py and the private _prepare_cmd alias go, and a ci row fails on a new noqa F401 re-import in src #2166), tests/support/fakes/model.py:302. The error of fix(github): a refused JWT exchange of the GitHub App names GitHub's reason, not a gh login #2491 is not caused by the shadowing.

    4. The test code is not clean under mypy --strict. MYPYPATH=src mypy --strict tests gives 739 errors in 220 files. The implement step runs mypy --strict on each changed Python file, and mypy also reports errors in the files that it imports. So a step that changes a test file fails on old errors that it did not cause, with or without mypy_path.

    The fix needs a different decision: type-clean tests, or a check in the step that fails only on errors that the step added (a baseline), or no mypy --strict of test files in the step. A person must choose. A mypy_path change alone, with a test and a Dockerfile check, would not make one run pass, and the Dockerfile check on tests/security/test_scanner_tool_executor.py would itself fail on the 10 old errors.

  5. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 0dbd092 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Does mypy_path take priority over site-packages in mypy's module search order? (missing verified source)
    • What is the build time cost of the image check in seconds? (missing verified source)
  6. changed the title [-]fix(runner): mypy in the runner Job resolves devops_cli to the installed copy, so strict checks fail on correct code[/-] [+]fix(roadmap): the implement step runs the type check of the gate, not strict mypy on every file[/+] on Nov 1, 2026
  7. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at ae2d8e1 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Where is the implement step's current mypy invocation? (missing verified source)
  8. dan-petty commented on Nov 1, 2026

    @dan-petty
    OwnerAuthor

    Verified sources for the refine question "Where is the implement step's current mypy invocation?" (read on origin/main, 2026-11-01):

    • The step: src/devops_cli/roadmap/implement_step.py, function _static_failure. It builds [BIN_UV, "run", BIN_MYPY, "--strict", "--", *files] with files = _python_files(changed), the Python files that the step changed (source and tests), after ruff check.
    • The gate: src/devops_cli/commands/ci.py, the check spec named typecheck (title mypy (py314 strict), around lines 750 to 766). It type-checks src/ only, as the command typecheck says: "Run mypy static type-checker strictly targeting Python 3.14 over src/."

    The fix takes the file set and options of the step from the typecheck spec of the gate.

  9. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 1, 2026
  10. removed
    status/in-review
    owner/agent
    on Nov 1, 2026
  11. added a commit that references this issue on Nov 1, 2026
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-highsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions