Skip to content

fix(devtools): preserve testmon affected selection - #1550

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/testmon-default-selection
May 25, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/testmon-default-selection

Conversation

@Sinity

@Sinity Sinity commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

Make the default devtools verify path actually preserve pytest-testmon affected-test selection instead of silently expanding through Polylogue's own invalidator or pytest marker selection behavior.

Problem

While validating #1548, devtools verify widened a narrow branch into a 9,513-test run. There were two separate causes:

  1. devtools/verify.py carried a hand-maintained changed-file invalidator list that forced --testmon-noselect for config and tests/infra/ paths.
  2. Even after removing that list, the default pytest step still passed -m not scale_medium and not scale_large. Pytest-testmon documents that ordinary pytest selectors such as -m deactivate selection unless --testmon-forceselect is supplied, so the default command still ran effectively all tests.

Solution

  • Remove the homegrown global invalidator path from devtools verify.
  • Keep explicit full collection only under --seed-testmon and --all / --full.
  • Add --testmon-forceselect to the default affected-test step because the command always uses marker filters for scale tiers.
  • Run default affected-testmon single-process (-n 0) to avoid xdist collection skew with forced testmon selection; seed/full diagnostics keep worker pools.
  • Update tests and workflow docs to describe the real mechanism.

Closes #1549

Verification

  • pytest -q tests/unit/devtools/test_verify.py --tb=short -> 32 passed in 5.16s
  • ruff format --check devtools/verify.py tests/unit/devtools/test_verify.py && ruff check devtools/verify.py tests/unit/devtools/test_verify.py -> all checks passed
  • python -m mypy devtools/verify.py tests/unit/devtools/test_verify.py -> success
  • devtools render-all -> regenerated AGENTS/docs surfaces
  • devtools verify --json -> exit 0, pytest step pytest testmon, pytest_workers: 0, pytest_selection: testmon, count: 32, total 42.67s
  • pre-push devtools verify --quick -> exit 0, total 33.08s

Problem: the default devtools verify path still contained a hand-maintained global invalidator and always passed marker filters to pytest. Pytest-testmon disables selection when ordinary pytest selectors such as -m are present unless --testmon-forceselect is supplied, so the default path could silently expand to nearly the whole suite.\n\nWhat changed: remove the custom changed-file invalidator, always use pytest-testmon as the default selector after the seed preflight, pass --testmon-forceselect with the scale marker filter, and run affected testmon single-process by default to avoid xdist collection skew. Seed and explicit full diagnostics keep their worker pools. Update tests and docs to match the new model.\n\nCloses #1549
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 6 minutes and 13 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8bfc8d1f-5a99-4205-984e-94f3b48bb309

📥 Commits

Reviewing files that changed from the base of the PR and between 8c0abd3 and 6bfee11.

📒 Files selected for processing (6)
  • AGENTS.md
  • CONTRIBUTING.md
  • TESTING.md
  • devtools/verify.py
  • docs/plans/mk3-execution-log.md
  • tests/unit/devtools/test_verify.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/testmon-default-selection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit a2e3bda into master May 25, 2026
5 checks passed
@Sinity
Sinity deleted the feature/fix/testmon-default-selection branch May 25, 2026 05:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6bfee111e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/verify.py Resolved
Sinity added a commit that referenced this pull request May 26, 2026
## Summary

PR #1550 silently ran ~9,500 tests instead of the affected subset for a
full week before being caught — a marker filter (\`-m not scale_*\`)
deactivated pytest-testmon affected selection, with no failing test to
surface the regression. This adds two unit tests pinning the
marker+\`--testmon-forceselect\` pairing invariant so the footgun cannot
re-land silently. Closes #1632.

## Problem

Per pytest-testmon docs, any non-trivial \`-m\` marker selection
deactivates testmon's affected-test selection unless
\`--testmon-forceselect\` is also passed. PR #1550 added the flag; this
PR makes sure it stays there.

The existing tests assert specific marker tokens are present (\`not
scale_medium\`, \`not scale_large\`), so a future change that swaps the
marker vocabulary could pass those tests while still removing
\`--testmon-forceselect\`. The new tests assert the conditional
invariant directly: **IF \`-m\` is in the command THEN
\`--testmon-forceselect\` is also in the command** — independent of the
marker tokens themselves.

## Solution

Two focused unit tests under \`tests/unit/devtools/test_verify.py\`:

- \`test_default_testmon_step_pairs_marker_filter_with_forceselect\` —
the default lane (no flags).
- \`test_skip_slow_testmon_step_keeps_forceselect_with_compound_marker\`
— \`--skip-slow\` composes the marker; the pairing must hold.

The assertion message in both tests names #1550 and #1632 so any future
failure trace points directly at the regression history.

This matches the recommended Option 3 from #1632:
> A meta-test under \`tests/unit/devtools/\` that constructs the same
pytest argv \`devtools verify\` uses and asserts
\`--testmon-forceselect\` is present whenever \`-m\` markers are
present.

## Verification

\`\`\`
$ pytest tests/unit/devtools/test_verify.py
36 passed (2 new)

$ devtools verify --quick
"exit_code": 0
\`\`\`

Both new tests pass against current code. To verify they actually catch
the regression, I locally deleted the
\`pytest_cmd.append("--testmon-forceselect")\` line in
\`devtools/verify.py:384\` — both new tests fail with the named
assertion message, the existing tests fail too.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Added regression tests to enforce consistent test execution behavior
with marker filtering options.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Sinity/polylogue/pull/1648?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 54.F054 / P1: Fix and current-source recheck assigned to polylogue-t5jl2; not claimed fixed. Non-Python pytest configuration changes still map to affected mode rather than a broad-change refusal or full-collection request (devtools/verify.py:397). The graph environment key contains installed packages and Python only (devtools/testmon_provision.py:95), while the closed-world overrides do not neutralize filterwarnings (devtools/pytest_invocation.py:137).

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make devtools verify rely on pytest-testmon for affected selection

1 participant