Skip to content

test(lint): drop the toolchain-pin guard - #577

Merged
sumithr merged 2 commits into
mainfrom
chore/drop-toolchain-pins-test
Aug 3, 2026
Merged

sumithr merged 2 commits into
mainfrom
chore/drop-toolchain-pins-test

Conversation

@sumithr

@sumithr sumithr commented Aug 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Removes tests/test_toolchain_pins.py, the guard added in #570, and the block of prose in .pre-commit-config.yaml that was standing in for it. The ruff hooks are executable: the way to know they are right is to run them, not to read an essay about them or a test asserting their shape.

The guard cost more defects than it caught. Successive review passes found a hole in it every round, and never once found a hole in the config it guarded:

Round Hole in the guard
1 repo root resolved into mutmut's mutants/ copy, raising FileNotFoundError, tripping -x and reporting all six modules as 0 killed
2 imported identify and shelled out to ruff, neither of which exists in the isolated pre-push hook environments
3 probed the first tracked .toml, which is pyproject.toml, the one name ruff special-cases, so it could not detect the over-selection it existed to catch
4 allowlisted hook keys but left permitted VALUES unchecked, so args: [--exit-zero] passed every assertion

One comment line survives, on rev:, because nothing executable covers it: the required ruff check + format job installs ruff from pyproject.toml and never opens .pre-commit-config.yaml, so a rev that drifts from the pin puts contributors on a different formatter and stays quiet until an unrelated PR goes red.

What stays

Nothing that fixed a real problem is removed. The config is untouched apart from the comments:

  • ruff==0.16.1 in pyproject.toml and the matching rev: v0.16.1, which is what turned the required check green on main
  • types_or: [python, pyi, jupyter, markdown] on ruff-format, so a drifting Markdown fence is caught at commit time
  • the files-scoped ruff-check-config entry, so an invalid ruff config fails at commit time instead of in CI

How it was verified

Each behaviour the deleted prose described, confirmed by running the hook against a real file rather than asserting it:

pre-commit run ruff-check-config --files pyproject.toml ruff.toml
  ->  ruff check (ruff config files)...Passed

pre-commit run ruff-check-config --files tests/fixtures/repo_map/rust_context_crate/Cargo.toml
  ->  ruff check (ruff config files)...(no files to check)Skipped

pre-commit run ruff-format --files tests/scenarios/CONFORMANCE.md
  ->  ruff format...Passed

and each one failing on an injected defect, so the passes above are not vacuous:

# `select = [..., "NOT-A-RULE"]` in ruff.toml
pre-commit run ruff-check-config --files ruff.toml
  ->  Failed, exit code 2
      Cause: Unknown rule selector `NOT-A-RULE` in `select` from ruff.toml

# `x   =    1` added to a Python fence in CONFORMANCE.md
pre-commit run ruff-format --files tests/scenarios/CONFORMANCE.md
  ->  Failed, files were modified by this hook
      1 file reformatted

That second one is the whole reason ruff-format overrides types_or: with the upstream python/pyi/jupyter list the same file reports (no files to check)Skipped.

Both injections were reverted, confirmed by git status.

Full gates, on the pinned ruff 0.16.1 (rebased onto #582, which bumped the pin from 0.16.0; the conflict was in the comment this PR deletes, resolved by keeping the new rev):

  • uv run ruff check .: All checks passed
  • uv run ruff format --check .: 335 files already formatted (252 .py + 83 .md, one fewer .py after the deletion)
  • uv run mypy: no issues in 74 source files
  • uv run pytest -q: 100% coverage held; only test_built_wheel_contains_py_typed_marker fails, the known No module named pip in a uv venv, which the CI pip install jobs cover
  • pre-commit validate-config: exit 0
  • No dangling references to the deleted module remain (grep -rn toolchain_pins is empty)

Mutation gate, dispatched on this branch because the diff touches tests/**/*.py (run 30819133472, Linux, 4m27s):

| Module            | Baseline killed | Current killed | Survivors | Verdict |
| knowledge_loaders | 472             | 472            | 0         | OK      |
| rules             | 41              | 41             | 0         | OK      |
| standards         | 25              | 25             | 0         | OK      |
| tdm_validation    | 203             | 203            | 0         | OK      |
| coverage_models   | 87              | 87             | 0         | OK      |
| report_builder    | 793             | 793            | 0         | OK      |
All modules: kill counts >= baseline and 0 survivors. Strict gate passed.

Residual risk, accepted deliberately

Stated plainly rather than buried, because it is the whole trade this PR makes.

Nothing now compares pyproject.toml's ruff== pin with .pre-commit-config.yaml's rev:. Verified by injecting rev: v0.15.0 and running every gate: the full suite passes, pre-commit validate-config exits 0, no test reads rev: at all, and the required lint job runs python -m ruff installed from pyproject.toml without ever opening the config. A one-sided bump reaches main silently and surfaces later as a red required check on somebody's unrelated PR. That is the #570 failure, and it is now guarded by a comment instead of a test.

The trade is accepted because the guard cost four rounds of its own defects and caught none in the config, and because the real bump path already does the right thing: #582 bumped ruff to 0.16.1 and synced the rev: in one commit, touching exactly pyproject.toml and .pre-commit-config.yaml.

Two related notes from the adversarial pass, neither a defect in this PR:

  • Weakening a different hook property (types_or: [python] on ruff-format, or stages: [manual]) is not caught by CI at the moment of weakening either. CI catches the drifting file it lets through, on the next push. The deleted test never asserted hook shapes, so this is unchanged by this PR.
  • tests/test_mutmut_subprocess_exclusions.py:274 globs every tests/test_*.py, so deleting one changes its parametrize set. Inert here: the deleted module was never in the mutmut --ignore list, all six ignore paths still resolve, and the module runs 148 passed / 0 failed on this branch.

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally (pytest) and lint/type checks are green (pre-commit run --all-files, python -m mypy)
  • Added or updated tests covering the change (n/a: this PR REMOVES a test; the hook behaviours are verified by executing the hooks, above, and enforced by the required ruff check + format job)
  • Updated the relevant docs in this same PR
  • No breaking changes (or they are called out above)

sumithrjl and others added 2 commits August 3, 2026 15:23
The guard added in #570 cost more defects than it caught. Successive review
passes found a hole in it every round - a repo-root that resolved into mutmut's
mutants/ copy and aborted the mutation run, imports absent from the isolated
pre-push hook environments, a probe that picked the one special-cased filename
and so could not detect the over-selection it existed to catch, an allowlist
that still left permitted VALUES unchecked - while never once finding a hole in
the config it guarded.

What it protected is a stale `rev:`, which the `ruff check + format` job cannot
see because it installs ruff from pyproject.toml and never opens
.pre-commit-config.yaml. That risk is real but narrow, and it is now carried by
a comment at the pin itself rather than by a test module that has to be right
about pre-commit's filter semantics to be worth anything.

Everything the guard actually fixed stays: the exact ruff==0.16.0 pin, the
matching rev, the markdown types_or on ruff-format, and the files-scoped
ruff-check-config entry that catches an invalid ruff config at commit time.
Those are enforced by CI running the real commands over the real tree.
The hooks are verifiable by running them, so the essay explaining them was
load-bearing for nothing. Each behaviour it described is confirmed by
executing the hook against a real file:

  ruff-check-config  pyproject.toml + ruff.toml         Passed
  ruff-check-config  fixtures/.../Cargo.toml            Skipped
  ruff-format        tests/scenarios/CONFORMANCE.md     Passed

and each fails on an injected defect: a `NOT-A-RULE` selector in ruff.toml
gives "Unknown rule selector ... in `select`", and a drifting Python fence in
CONFORMANCE.md gives "1 file reformatted" where the upstream types_or would
have skipped the file.

One line survives, on `rev:`, because nothing executable covers it: the
required `ruff check + format` job installs ruff from pyproject.toml and never
reads this file.
@sumithr
sumithr force-pushed the chore/drop-toolchain-pins-test branch from 261110c to d2f2277 Compare August 3, 2026 13:29
@sumithr
sumithr merged commit 9d7f42d into main Aug 3, 2026
34 checks passed
@sumithr
sumithr deleted the chore/drop-toolchain-pins-test branch August 3, 2026 14:01
sumithr added a commit that referenced this pull request Aug 3, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.60.4](v0.60.3...v0.60.4)
(2026-08-03)


### Tests

* **lint:** drop the toolchain-pin guard
([#577](#577))
([9d7f42d](9d7f42d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
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.

2 participants