Skip to content

ci(toolchain): guard pre-commit hook dependency pins against pyproject (#714) - #751

Merged
sumithr merged 4 commits into
mainfrom
ci/issue-714-toolchain-pin-lockstep
Sep 29, 2026
Merged

sumithr merged 4 commits into
mainfrom
ci/issue-714-toolchain-pin-lockstep

Conversation

@sumithr

@sumithr sumithr commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Dependabot only edits pyproject.toml, so every bump to a tool or package that .pre-commit-config.yaml also pins has been half a change. #709 (ruff) and #708 (mutmut) both passed all checks with the second site left stale. This PR adds a required-CI guard that fails when the two files disagree, and realigns the pins that had already drifted.

Review widened the scope beyond the ruff and mutmut pair the issue names. A hand-kept pair list already had holes: pytest-cov (<8 vs <7 in both hooks) and tree-sitter (<0.27 vs <0.26) had drifted unnoticed.

Related issue

Closes #714

Changes

  • New tests/test_toolchain_pin_lockstep.py, run by the required pytest jobs:
    • The check covers every hook that does not declare an inline non-python language. Each additional_dependencies entry that parses as PEP 508 and names a package declared in pyproject must match one of that package's pins, by specifier and URL. Markers and extras are ignored on purpose; tomli differs only by marker.
    • Pins are looked up in [project.optional-dependencies], [dependency-groups] and [tool.uv].dev-dependencies first, then [project].dependencies. Marker-split runtime declarations are all candidates.
    • REQUIRED_MIRRORS makes mutmut exist on both sides. Removing either pin fails instead of silently skipping.
    • ruff-pre-commit rev: vX must match dev ruff==X. A rev that is not a v<version> tag (a frozen SHA, or a YAML float) fails with a clear message.
    • Every mismatch is reported in one failure. Each names both files, the hook id and both values. Nothing is hard-coded to a version.
  • .pre-commit-config.yaml: pytest-cov is >=6,<8 in the mutmut and pytest hooks, and tree-sitter is >=0.25,<0.27 in the pytest hook, both matching pyproject. The "kept in sync by hand" comments now point at the guard.
  • pyproject.toml: the mutmut pin comment describes the current >=3.8,<3.9 pin. The committed baseline's minor sets the floor, and the ceiling allows one minor per baseline. .pre-commit-config.yaml is added to [tool.mutmut].also_copy so the test can read it from the mutants/ copy.
  • docs/DEVELOPMENT.md: the mutmut section is rewritten to current state, and a new "Toolchain pin lockstep" section states the rules.

How it was verified

  • Red, on main's config: the guard failed and named all 3 real drifts (pytest-cov in the mutmut and pytest hooks, tree-sitter in the pytest hook), each with both files and values.
  • Red, deliberate desyncs on scratch copies:
    • ruff rev: v0.16.7 failed with ruff pins disagree: ... 'ruff==0.16.8' ... 'v0.16.7'.
    • Deleting mutmut from the dev extra failed with mutmut must be declared exactly once in pyproject.toml to anchor its mirror ...; found 0.
    • A marker-split runtime pair against hook demo==99 failed; demo==2 passed.
    • A remote hook mixing a URL entry with a stale pytest-cov failed and named pytest-cov.
  • Green:
    • tests/test_toolchain_pin_lockstep.py: 29 passed.
    • Full uv run pytest: 4461 passed, 7 skipped, 1 xfailed, 100.00% coverage.
    • ruff check, ruff format --check and mypy are clean.
  • Pre-merge, on the real files at d15cf4c: each desync was applied to the real pyproject.toml or .pre-commit-config.yaml in a throwaway worktree and reverted. The guard failed on a ruff rev: one patch behind, a mutmut hook ceiling of <3.10, a pyproject-only ruff bump, a pyproject-only mutmut bump and a pyproject-only pytest-cov bump, naming both files and both values each time. Moving both sites together to unseen versions passed, and adding one REQUIRED_MIRRORS row made removing that package from its hook fail.
  • CI: all 33 checks pass. The required pytest jobs collect the new file through testpaths, and the scoped Linux mutation gate on the branch passed with 0 survivors in every module.
  • Hook environments: pre-commit run --hook-stage pre-push --all-files passed. The rebuilt hook venvs resolved pytest-cov 7.1.0, tree-sitter 0.26.0 and mutmut 3.8.0. The push's own pre-push run (mutmut gate, pytest, plugin drift) passed on every commit.
  • Review:
    • A per-file sumo-qa review, then 3 adversarial rounds. Codex was over its usage limit for rounds 1 and 2, so those used the built-in /code-review. The final codex pass on d15cf4c found nothing material, and its probes caught all 20 hook-pin drifts, a ruff rev bump and removal of either mutmut mirror.
    • Declined: declaring packaging directly (pytest requires it), and replacing the hook copies with uv run hooks (a design change outside this issue's scope).
    • Accepted trade-off: an npm-style entry in a remote hook with no inline language that shares a name with a pyproject package fails loudly.

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
  • Updated the relevant docs in this same PR
  • No breaking changes (or they are called out above)

…nd pre-commit (#714)

tests/test_toolchain_pin_lockstep.py compares each tool pinned in both
pyproject.toml and .pre-commit-config.yaml (ruff: dev extra vs the
ruff-pre-commit rev; mutmut: dev extra vs the mutmut hook's
additional_dependencies) and fails in the required pytest jobs when a pair
disagrees, naming both files and both values. Version-agnostic; pairs live in
a LOCKSTEP_PAIRS table so another pair is one row.

.pre-commit-config.yaml joins [tool.mutmut].also_copy so the test resolves
under the mutants/ mirror. Stale mutmut version literals in the hook comment
and docs/DEVELOPMENT.md are replaced with version-free wording, and the
mechanism is documented in DEVELOPMENT.md.
…fix drifted pins (#714)

Generalise tests/test_toolchain_pin_lockstep.py from a hand-maintained
ruff/mutmut pair list to a rule: every pre-commit hook
additional_dependencies entry whose package pyproject.toml also declares
must carry an equal specifier set, plus the ruff-pre-commit rev vs ruff==
special case. Markers and extras are ignored, ambiguous pyproject
declarations fail, non-tag ruff revs fail with a clear message, and every
mismatch is reported in one failure.

Align the drifted hook pins the generalised guard found: pytest-cov
>=6,<8 in the mutmut and pytest hooks, tree-sitter >=0.25,<0.27 in the
pytest hook. Rewrite the mutmut pin rationale in pyproject.toml and
docs/DEVELOPMENT.md to describe the current >=3.8,<3.9 pin.
…d to python hooks (#714)

Require mutmut to be declared once in both pyproject and the mutmut hook,
compare only Python hooks, prefer optional extras (including PEP 735
dependency-groups and tool.uv dev-dependencies) over runtime dependencies
as the source of truth, tolerate marker-split runtime entries, compare
direct-reference URLs, and name hooks that lack an id.
…idate (#714)

A hook is skipped only when its inline language is not python; every other
hook has each additional_dependencies entry checked on its own, so one
direct-URL or unparseable entry no longer hides its declared siblings.
Marker-split [project].dependencies entries are all candidates, and a hook
pin must match one of them, instead of dropping the package from comparison.
@sumithr
sumithr force-pushed the ci/issue-714-toolchain-pin-lockstep branch from d15cf4c to fd6c2e5 Compare September 29, 2026 21:25
@sumithr
sumithr merged commit 121dc0e into main Sep 29, 2026
34 checks passed
@sumithr
sumithr deleted the ci/issue-714-toolchain-pin-lockstep branch September 29, 2026 21:44
sumithr added a commit that referenced this pull request Sep 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.67.0](v0.66.1...v0.67.0)
(2026-09-30)


### Features

* **review:** probe mirrored dependency constraints across manifests,
hooks, CI, and images
([#493](#493))
([#772](#772))
([dd04c23](dd04c23))


### Documentation

* **contributing:** define the QA tool preflight and source-tree
degraded mode ([#745](#745))
([2eb9de0](2eb9de0))


### Miscellaneous Chores

* **pre-commit:** install the pre-push hooks by default and always run
pytest ([#775](#775))
([135cbf6](135cbf6))


### Continuous Integration

* **toolchain:** guard pre-commit hook dependency pins against pyproject
([#714](#714))
([#751](#751))
([121dc0e](121dc0e))

---
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.

[Task]: guard the pyproject <-> pre-commit toolchain pin lockstep in CI

2 participants