Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
# The pytest hook uses `language: python` with explicit
# `additional_dependencies` (pre-commit's hook venvs can only install
# from PyPI, so the `.[dev]` shortcut doesn't work — versions are
# duplicated from `pyproject.toml.dependencies` and kept in sync by
# hand). This decouples the hook from whatever `python` happens to be
# on the user's PATH (pyenv / multiple Pythons / system vs venv).
# duplicated from pyproject.toml's dependencies and extras, and
# tests/test_toolchain_pin_lockstep.py fails CI when any duplicated
# specifier disagrees). This decouples the hook from whatever `python`
# happens to be on the user's PATH (pyenv / multiple Pythons / system vs
# venv).
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Keep in lockstep with the `ruff==` pin in pyproject.toml's dev extras.
# Keep in lockstep with the `ruff==` pin in pyproject.toml's dev extras
# (enforced by tests/test_toolchain_pin_lockstep.py).
rev: v0.16.8
hooks:
- id: ruff-check
Expand Down Expand Up @@ -240,16 +243,14 @@ repos:
additional_dependencies:
- "hypothesis>=6,<7"
- "mcp>=2,<3"
# >=3.7,<3.8 mirrors the pyproject dev pin: 3.6.0 resolved relative
# source_paths against the live cwd (chdir-ing tests crashed the
# stats-collection run), 3.7 fixed that but changed pragma
# placement and the mutant set, so the baseline is per-minor. See
# the pin comment in pyproject.toml [project.optional-dependencies].
# Mirrors the mutmut pin in pyproject.toml's dev extra; the reasons
# for its floor and per-minor ceiling live in that pin's comment.
# tests/test_toolchain_pin_lockstep.py fails CI if the two disagree.
- "mutmut>=3.8,<3.9"
- "pydantic>=2.8,<3"
- "PyYAML>=6,<7"
- "pytest>=8.4,<10"
- "pytest-cov>=6,<7"
- "pytest-cov>=6,<8"
# tomllib stdlib backport for Python 3.10 (used by
# plugin_packaging.canonical + tests/test_plugin_metadata.py).
# 3.11+ ignores this via the marker.
Expand All @@ -271,9 +272,9 @@ repos:
#
# `additional_dependencies` lists the runtime deps explicitly
# because pre-commit's hook venvs can only install from PyPI;
# the `.[dev]` editable-install trick doesn't work here. Keep
# this list in sync with the `dependencies` block in
# pyproject.toml when bumping versions.
# the `.[dev]` editable-install trick doesn't work here. Every
# entry pyproject.toml also declares must carry the same specifier
# (tests/test_toolchain_pin_lockstep.py), so bump both together.
#
# pytest picks up `pythonpath = ["src"]` from pyproject.toml's
# `[tool.pytest.ini_options]`, so `import sumo_qa.*` resolves
Expand All @@ -286,7 +287,7 @@ repos:
- "pydantic>=2.8,<3"
- "PyYAML>=6,<7"
- "pytest>=8.4,<10"
- "pytest-cov>=6,<7"
- "pytest-cov>=6,<8"
# Build backend — tests/test_wheel_packaging.py builds the wheel via
# `pip wheel --no-build-isolation` to assert it ships py.typed.
- "hatchling>=1.25"
Expand All @@ -303,7 +304,8 @@ repos:
# Floored at 1.12.5 like pyproject (#491): the adapter targets the
# upstream binding that release introduced, and bumping the dep string
# also re-keys pre-commit's cached hook venv past any 1.12.2 install.
# tests/test_treesitter_pins.py fails if these drift from pyproject.
# tests/test_treesitter_pins.py and tests/test_toolchain_pin_lockstep.py
# fail if these drift from pyproject.
- "tree-sitter>=0.25,<0.27"
- "tree-sitter-language-pack>=1.12.5,!=1.14.1,!=1.14.2,<2"
# Conditional via PEP 508 marker: only installed on Windows hooks.
Expand Down
90 changes: 70 additions & 20 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ The full suite covers:
- `test_standards.py`, `test_rules.py`: file loading
- `test_debug_capture.py`: `SUMO_QA_DEBUG_DIR` capture
- `test_conformance_transcript_validator.py`: deterministic, no-LLM cross-model conformance (issue #214). Scores a captured host/tool-call transcript against machine-readable fixtures (`tests/scenarios/conformance/scenarios.yaml`, seeded from `SCENARIOS.md` + `TOOL-SELECTION.md`) via `src/sumo_qa/conformance.py`, and proves a synthetic bad transcript fails on each contract axis: wrong skill routing, missing required tool call, forbidden tool call, forbidden output claim. See `tests/scenarios/CONFORMANCE.md`. Complements `test_skill_triggering.py` (trigger-phrase presence) by checking what the host actually did across the turn
- `test_toolchain_pin_lockstep.py`: fails when any pre-commit hook `additional_dependencies` entry, or the ruff-pre-commit `rev:`, disagrees with the matching `pyproject.toml` declaration (see [Toolchain pin lockstep](#toolchain-pin-lockstep))
- `test_mutmut_subprocess_exclusions.py`: loud guard that every subprocess-spawning test which imports a mutated module is excluded from the mutation gate and marked (see [Mutation testing](#mutation-testing)). Runs in the ordinary suite, so it fails at the PR that introduces an unmarked/unignored test, not later against an unrelated change

## Type checking
Expand Down Expand Up @@ -224,21 +225,27 @@ mutmut's `.meta` files, never from `mutmut run`'s exit status: mutmut exits
0 even when mutants survive, so a bare `mutmut run` hook can never fail on
a survivor-introducing push (root-caused 2026-07-13).

mutmut is version-capped (`>=3.7,<3.8`, pinned in both `pyproject.toml`'s dev
extra and the pre-push hook's `additional_dependencies`; keep the two in
lockstep). The floor excludes 3.6.0, whose `record_trampoline_hit` resolved
its relative `source_paths` against the live cwd with `strict=True`, so any
test that `chdir`s away and then calls a mutated-module function crashed the
stats-collection run and zero mutants executed ("failed to collect stats");
3.7.0 resolves `source_paths` once at config load. The ceiling is per-minor
because mutmut minors move the mutant set and the pragma rules (see below), so
a bump is a re-run-the-gate-and-ratchet-the-baseline task, not a range edit.
mutmut is pinned to one minor in both `pyproject.toml`'s dev
extra and the pre-push hook's `additional_dependencies`; the two must stay in
lockstep (see [Toolchain pin lockstep](#toolchain-pin-lockstep)). The floor is
the minor whose mutant set the committed `mutmut-baseline.json` was generated
from: an older engine generates fewer mutants, so a range spanning two minors
would let it resolve and report a DROP even with every mutant killed. The
ceiling keeps one minor per baseline, because mutmut minors move the mutant
set and the pragma rules (see below), so a bump is a
re-run-the-gate-and-re-baseline task that moves floor and ceiling together,
not a range edit. Versions below 3.7 must never be admitted: 3.6.0's
`record_trampoline_hit` resolved its relative `source_paths` against the live
cwd with `strict=True`, so any test that `chdir`s away and then calls a
mutated-module function crashed the stats-collection run and zero mutants
executed ("failed to collect stats").

`tree-sitter-language-pack` (the `[treesitter]` extra) follows the same
lockstep rule: `pyproject.toml` and the pre-push `pytest` hook's
`additional_dependencies` carry identical pins, and
`tests/test_treesitter_pins.py` fails if they differ (Dependabot only edits
`pyproject.toml`). The range excludes 1.14.1 and 1.14.2, which shipped without
`additional_dependencies` carry identical pins, and both
`tests/test_treesitter_pins.py` and the general
[Toolchain pin lockstep](#toolchain-pin-lockstep) guard fail if they differ
(Dependabot only edits `pyproject.toml`). The range excludes 1.14.1 and 1.14.2, which shipped without
the `windows-x86_64` prebuilt parsers, so every repo-map test failed on Windows
with `DownloadError: No pre-built parsers available for platform
'windows-x86_64'` (#595). 1.14.3 restored them
Expand All @@ -247,14 +254,15 @@ so this is a point exclusion rather than a ceiling: later releases resolve
normally. Windows `pytest` is not a required check, so a red Windows leg on
every PR is a signal to read, not background noise.

**Pragma placement (mutmut 3.7).** `# pragma: no mutate` is read only as a
trailing comment on a *statement* or a compound-statement header (`with …:`,
`if …:`, `def …:`); it suppresses the mutants whose node starts on that
statement's first line. A pragma on a continuation line inside an expression
(a comprehension clause, a kwarg line of a multi-line call) is ignored. For a
multi-line call whose Call-level mutants (kwarg→None, kwarg-drop) are
equivalent, put the pragma after the closing paren: it silences the Call
node's mutants and leaves the inner kwarg-value mutants live. Pair every
**Pragma placement.** Under the pinned mutmut, `# pragma: no mutate` is read
only as a trailing comment on a *statement* or a compound-statement header
(`with …:`, `if …:`, `def …:`); it suppresses the mutants whose node starts on
that statement's first line. A pragma on a continuation line inside an
expression (a comprehension clause, a kwarg line of a multi-line call) is
ignored. For a multi-line call whose Call-level mutants (kwarg→None,
kwarg-drop) are equivalent, put the pragma after the closing paren: it
silences the Call node's mutants and leaves the inner kwarg-value mutants
live. Pair every
pragma with a one-line rationale naming why the mutation is equivalent.


Expand Down Expand Up @@ -356,6 +364,48 @@ shell-string forms), so `-m sumo_qa.installer --help` style spawns stay
unflagged. Its classifications are pinned by real fixture meta-tests in
`tests/fixtures/mutmut_guard/`.

## Toolchain pin lockstep

pre-commit hook venvs install from PyPI, so a hook that needs project
dependencies repeats them in its `additional_dependencies`, and ruff is pinned
both as `ruff==X` in the dev extra and as the ruff-pre-commit `rev: vX`.
Dependabot only edits `pyproject.toml`, so each bump it raises for a package a
hook also lists is half a change until the hook moves too.

`tests/test_toolchain_pin_lockstep.py` runs in the required pytest jobs and
enforces these rules:

- **Which entries.** A hook with an inline `language` other than `python`
(`system`, `node`, ...) is skipped. Every other hook, including a
remote-repo hook whose manifest declares its language, has each
`additional_dependencies` entry checked on its own: an entry that does not
parse as a PEP 508 requirement is skipped, and a parsed entry is compared
only when `pyproject.toml` declares its package.
- **Same pin.** Every compared entry whose package `pyproject.toml` also
declares carries the same specifier set and the same direct-reference URL.
Environment markers and extras are ignored, since a marker says where a
dependency installs rather than which versions it allows. Hook entries for
packages `pyproject.toml` does not declare are out of scope.
- **Source precedence.** Hooks mirror the dev tooling, so an entry is compared
first with the optional-extra sources: `[project.optional-dependencies]`
groups, PEP 735 `[dependency-groups]` (string entries; `include-group`
tables are ignored) and `[tool.uv].dev-dependencies`. Only a package none of
those declare falls back to `[project].dependencies`. Different specifiers
across the optional sources fail as ambiguous, as do two different
`[project].dependencies` pins under the same environment marker. In the
fallback, entries under different markers (a marker split) are all
candidates, and the hook entry passes when it matches any one of them.
- **Required mirrors.** `REQUIRED_MIRRORS` in the test names the pairs that
must exist, so deleting one side cannot turn the check into a silent pass:
`mutmut` must be declared exactly once in `pyproject.toml` and exactly once
in the `mutmut` hook. A new must-exist mirror is one row in that table.
- **ruff.** Exactly one ruff-pre-commit repo entry must exist, its `rev:` must
be a `v<version>` tag, and that version must equal the `ruff==` pin.

The test hard-codes no version and lists every mismatch in one failure,
naming both files, the hook id, the hook value and every candidate
`pyproject.toml` declaration, so a bump edits the pins and nothing else.

## Branch workflow

Feature work goes on a feature branch off `main`. Don't push without explicit
Expand Down
37 changes: 17 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,20 @@ dev = [
# dev host regardless of the interpreter version — hence unconditional
# here, while the wheel keeps the conditional runtime declaration above.
"tomli>=2,<3",
# >=3.7: mutmut 3.6.0 (2026-06-06) resolved relative Config.source_paths
# against the live cwd with strict=True inside record_trampoline_hit, so any
# test that monkeypatch.chdir()s away and then calls a mutated-module
# function crashed the stats-collection run and zero mutants executed
# (nightly gate red 2026-06-07 → 2026-07-13). 3.7.0 resolves source_paths
# once at config load (resolved_mutated_source_paths), verified by a full
# green gate run on 2026-09-03 (#580). No fixed 3.6.x exists, so the floor
# is 3.7, never a bare `<3.8` (which would admit 3.6.0).
# <3.8: mutmut 3.7 changed `# pragma: no mutate` to a STATEMENT-level /
# compound-header comment (mutmut/mutation/pragma_handling.py) and added
# kwarg→None / kwarg-drop Call mutants, which moved the baseline; a minor
# bump must re-run the gate and ratchet mutmut-baseline.json, not just
# widen the range. The floor moves WITH the ceiling for that reason: the
# committed floors come from ONE minor's mutant set, so a range spanning
# two minors lets an older engine resolve and fail the gate impossibly
# (3.7 generates 491 knowledge_loaders mutants against a 497 floor, so
# killing every one of them still reports a DROP). Keep in lockstep with .pre-commit-config.yaml.
# One minor per baseline. The per-module floors in mutmut-baseline.json were
# generated from mutmut 3.8's mutant set, and every minor moves that set
# (3.8 added a ternary-condition mutator; 3.7 changed `# pragma: no mutate`
# to statement-level and added kwarg Call mutants), so the gate is only
# meaningful against the minor it was baselined on.
# >=3.8: the floor is that baselined minor. An older engine generates fewer
# mutants (3.7 makes 491 knowledge_loaders mutants against a 497 floor), so
# killing every one of them still reports a DROP. Nothing below 3.7 may ever
# be admitted: 3.6.0 resolved relative source_paths against the live cwd,
# so a test that chdir-s away crashed stats collection and no mutant ran.
# <3.9: a new minor is a re-run-the-gate-and-re-baseline task that moves
# floor and ceiling together, never a range widening.
# Mirrored by the mutmut hook in .pre-commit-config.yaml (enforced by
# tests/test_toolchain_pin_lockstep.py).
"mutmut>=3.8,<3.9",
# NOTE: CVE-2025-71176 (local tmpdir symlink, fixed in pytest 9.0.3) cannot be
# remediated by upgrading while pytest-check-links is a dev dep — its latest
Expand Down Expand Up @@ -152,7 +149,7 @@ dev = [
# the ruff-pre-commit hook needs, so the open `>=0.5,<1` had CI, pre-commit
# and a synced venv all running different ruff versions at once. Bump this and
# `rev:` in .pre-commit-config.yaml together, in one commit, reformatting in
# the same change.
# the same change; tests/test_toolchain_pin_lockstep.py fails CI otherwise.
"ruff==0.16.8",
# Static type checking — see [tool.mypy]. mypy is pure-Python (no Node
# toolchain), matching the project's Python-only CI. types-PyYAML supplies
Expand Down Expand Up @@ -367,8 +364,8 @@ also_copy = [
# push whose delta touches any test file (the hook's regex matches all
# of `tests/*.py`). Same root-level-resource pattern as `.claude/`.
"release-please-config.json",
# tests/test_treesitter_pins.py (#595) compares the [treesitter] extra with
# the pre-push pytest hook's pins via `Path(__file__).resolve().parents[1] /
# tests/test_treesitter_pins.py (#595) and tests/test_toolchain_pin_lockstep.py
# compare pyproject pins with the pre-commit hooks' pins via `Path(__file__).resolve().parents[1] /
# ".pre-commit-config.yaml"`, which under mutmut becomes
# `mutants/.pre-commit-config.yaml`. Without this entry the test
# FileNotFoundErrors, mutmut's `-x` aborts stats collection, and the pre-push
Expand Down
Loading
Loading