Repository navigation
Conversation
…test-xdist The test.yml matrix keeps all five Python versions on ubuntu (the ruleset's required checks) and runs macOS and Windows on the oldest and newest Python only, 9 jobs instead of 15. No test is gated on a Python version, so every OS-specific test still runs on the OS it targets. The 100% coverage gate runs on ubuntu py3.14, where coverage's sys.monitoring core costs almost nothing; the other jobs pass --no-cov, dropping the ctrace overhead on 3.10-3.13 (211s vs 157s locally). pytest-xdist 3.8.0 is pinned in the dev extra and the pre-push pytest hook. CI runs `-n auto`; the hook keeps the full suite (the delivery skills use it as the one full local run) and runs `-n 4`, 157s to 87s locally. Refs #787
…st loadfile
Under pytest-xdist the suite flaked on wall-clock limits, not on behaviour.
Fix the causes instead of tuning worker counts:
- Raise subprocess hang guards in tests (timeout=10/15/30, the
run_handshake deadline of 5s, the post-kill proc.wait of 2s) to 60s.
The terminate grace waits (timeout=2, escalating to kill) stay as they are.
- Load a Hypothesis profile with deadline=None from the root conftest.
- Keep the ReDoS wall-clock guards with a 2s budget (10s for the node
check, which includes node startup), and grow inputs so quadratic and
exponential backtracking still blow the budget.
- Run xdist with --dist loadfile in CI and the pre-push hook so
module-scoped fixtures (the wheel build, the MCP server spawns) run once
per module. The hook uses -n auto capped at 4 workers.
- Define the coverage job once via a `cov: true` matrix property and a
single pytest step; required check names are unchanged.
- Require the pytest-xdist mirror between pyproject and the pytest hook.
Local pre-push hook timings (10-core Mac, full suite at 100% coverage):
before: serial 157s; -n 4 87s; -n auto timed out two 10s subprocess tests
after: -n auto --maxprocesses 4 --dist loadfile 68.8s and 69.9s
(two back-to-back runs, 5050 passed); --dist load 90.6s
Refs #787
… server reads The ReDoS guards now take inputs on which a regressed matcher fails the 2.0s budget by a wide margin, measured against deliberately vulnerable variants (macOS, single process): - status markers, "[DONE] " x 16_000: real 0.017s; per-marker line rescan 35.0s (x 8_000: real 0.011s, rescan 9.6s). - next_action keys, 6_000 repetitions for all three inputs: real 0.070s; per-key skill-key rescan 6.2s, per-key brace walk to the end 18.4s (at the old 4_000/3_000: rescan 2.4s, barely over the budget). - _blank_string_values, n=28: real <0.0001s; backslash-ambiguous exponential pattern 22.3s (n=26: 5.0s). - JS blankStringValues, n=31: exponential pattern 21.6s against the 10s budget (n=34 extrapolates to minutes before the post-hoc check fails). The MCP initialize e2e tests and the tools/list contract fixture read responses through the installer's stdout reader thread with a 60s deadline instead of a bare readline, tear down through the installer's _terminate, and send stderr to DEVNULL instead of an undrained pipe, so a stalled server fails the test instead of hanging the xdist worker.
…CP read helpers - JS blankStringValues guard back at n=34, with the node child killed at 30s and reported as "ReDoS: node did not finish in 30s", so a vulnerable pattern fails fast on any machine and a fast runner cannot slip under the 10s budget. Real matcher: 0.04s; backslash-ambiguous pattern fails at the 30s timeout. - MCP initialize e2e tests share one 60s deadline per test across reads, fail with the request id and deadline on a stall, and fail on any stdout line that is not the awaited response. - tools/list contract read names the request id on a stall. - Both spawn the server with inherited stderr, so a crash traceback shows in pytest's captured output without an undrained pipe. - next_action guard inputs 6_000 -> 9_000 and trailing-space guard 40_000 -> 60_000 (macOS, single process): next_action real 0.099s for all three inputs, per-key skill-key rescan 9.1s, per-key brace walk 70.9s; trailing space real 0.010s, ambiguous line-end tail 9.8s.
install_external_skill read the lock for its fail-fast check outside _lock_guard. On Windows that open read handle made a concurrent install's os.replace onto external-skills.lock.json fail with WinError 5. The fail-fast read now takes the guard, still before any fetch. The other readers (_merge_into_lock, _find_record via _locate_verified) already run under the guard.
…and MCP read guards - test.yml sets SUMO_QA_REQUIRE_TREESITTER=1 and tests/test_repo_map_imports.py asserts TREESITTER_AVAILABLE under it, so a broken tree-sitter wheel on one OS or Python fails the job instead of silently skipping the tree-sitter tests there. - Trailing-space guard input 60_000 -> 150_000 (macOS, single process): real matcher 0.026s; quadratic ' +\n' scan 9.27s against the 2.0s budget (60_000: 1.48s, under the budget). - The Python _blank_string_values exponential guard runs the call in a child killed at 30s and reports the child's own timing, so a regression fails with a ReDoS message instead of blocking the xdist worker. A backslash-ambiguous pattern fails with "took 20.0s"; the real matcher passes in 0.05s. - The tools/list contract read fails on non-protocol stdout lines, as the e2e initialize test does; the e2e tests drop the response id asserts the id-filtering reader makes unfalsifiable.
… guard The install fail-fast pre-check took the guard unconditionally, creating .sumo-qa and its guard file (in $HOME for a global install) before a fetch that could fail, and waiting behind another install with nothing to read. It now takes the guard only when a lock file exists, and reads it there. Execute's unlocked attempt (no lock folder) still read the lock through _find_record, so a lock created by a concurrent install could be held open while that install replaced it (fatal on Windows). The lock is now read only under the guard and passed into verification; an unlocked attempt has no lock to read and is discarded for a locked retry if one appears. Tests assert every lock read happens under the guard and that a failed install leaves no .sumo-qa behind.
The ReDoS guard for _blank_string_values spawns python -c importing sumo_qa.conformance, which imports the mutated knowledge_loaders, so under mutmut its child would crash the trampoline. It moves to its own module carrying the mutmut-subprocess-spawning marker and an --ignore entry, so the validator module keeps its mutation kills. The exclusion guard missed this shape: a -c body importing a sumo_qa module that is not itself mutated. It now flags such a body when a static walk of src/'s imports reaches a mutated module from it.
…ies in the mutmut hazard classifier
…folder is refused on every Python
This was referenced Oct 2, 2026
sumithr
added a commit
that referenced
this pull request
Oct 2, 2026
…test-xdist (#813) ## Summary Cuts CI and pre-push test time while keeping platform coverage, the 100% coverage gate and the mutation gate. The suite now runs in parallel under pytest-xdist; the parallel flakiness that exposed (tight subprocess hang guards, a 200ms Hypothesis deadline, wall-clock ReDoS budgets, readline hangs, module fixtures duplicated per worker, an unguarded provenance-lock read) is fixed at the root rather than by tuning worker counts. ## Related issue Closes #787 ## Changes - `test.yml`: all 5 Pythons on ubuntu; macOS and Windows on 3.10 and 3.14 only (15 to 9 jobs). Required check names unchanged (`pytest (ubuntu-latest · py3.1x)`). The coverage gate runs once, on `ubuntu-latest · py3.14` with the `treesitter` extra (a `cov: true` matrix property); every other job runs `pytest -n auto --dist loadfile --no-cov`. Every job sets `SUMO_QA_REQUIRE_TREESITTER=1`, so a tree-sitter import failure fails that job (`tests/test_repo_map_imports.py`) instead of silently skipping the tree-sitter tests. - Pre-push `pytest` hook: still the full suite at 100% (the delivery skills' one full local run), now `pytest -n auto --maxprocesses 4 --dist loadfile`. `pytest-xdist==3.8.0` pinned in the dev extra and the hook, enforced by `test_toolchain_pin_lockstep.py` (`REQUIRED_MIRRORS` gains the row). - Mutmut hook: unchanged. With a warm cache an unrelated test-only change costs 0.1 to 0.3s (`--changed-only` reports nothing in scope), so the `files:` regex was left as is. - Flake root causes: subprocess hang guards raised to 60s; a suite Hypothesis profile with `deadline=None` (root `conftest.py`); ReDoS guards resized so each still fails a deliberately quadratic or exponential variant by 3x or more while the real matcher stays under 0.1s; the JS guard runs node with a 30s child timeout; MCP read helpers in two tests use the installer's reader with one shared deadline, inherited stderr and a stray-stdout check. - `src/sumo_qa/external_skills.py`: the provenance lock is read only under its guard, both in the install pre-check (only when a lock already exists, so a failed fetch leaves no `.sumo-qa` behind) and in `execute`. On Windows an open read handle made a concurrent install's `os.replace` onto the lock fail. The pre-check probes with `os.stat`, so an unsearchable lock folder is refused with the typed lock error on every Python. - The Python `_blank_string_values` ReDoS guard moved to `tests/test_conformance_redos_subprocess.py` (runs in a child killed at 30s) and is excluded from mutmut with the `mutmut-subprocess-spawning` marker; `conformance` is not a mutated module. The mutmut hazard classifier now follows a `-c` body's imports through `src/` (`from sumo_qa import conformance` reaches `knowledge_loaders`) and keeps the conservative `sumo_qa.<mutated>` substring check for dynamic imports. - `docs/DEVELOPMENT.md`: the hooks no longer claim to mirror `test.yml` exactly; the mutmut guard section describes the `-c` import walk and that no `sumo_qa.<sub>` entry point is exempt. ## How it was verified | Metric | Before | After | |---|---|---| | CI jobs per `test.yml` run | 15 | 9 | | CI runner-minutes, one run | 73.7 (run 37014740621, last green on main) | 21.6 (run 37058370119, this head); 20.7 (run 37057234383, previous head) | | CI wall-clock, first job start to last job end | 466s (slowest `windows · py3.11` 444s) | 208s (run 37058370119); 203s (run 37057234383) | | Pre-push hook stage, test-only change | 122.6 to 142.0s (042c013) | 58.5 to 60.8s | | Pre-push hook stage, `src/` change | 96.8s (042c013) | 29.8 to 31.6s | | Local full suite, coverage on (py3.14, treesitter) | 157s serial | 62 to 80s (`-n auto --maxprocesses 4 --dist loadfile`) | | `--dist load` vs `loadfile`, same machine | | 90.6s vs 68.8 to 69.9s | - Real pushes of this branch: pytest hook 61 to 65s, `5066 passed`, `Required test coverage of 100% reached`. - CI coverage job `pytest (ubuntu-latest · py3.14)` installs `.[dev,vertex,treesitter]`, sets `SUMO_QA_REQUIRE_TREESITTER=1` and prints `Required test coverage of 100% reached`. - Every OS-specific test still runs on its OS: Windows-only (`test_route_qa_runners.py` cmd.exe branch) on windows 3.10/3.14; POSIX-only tests on ubuntu and macOS; no macOS-only tests; no test is gated on a Python version. - Windows-only regression on a scratch draft PR (#817, `src/sumo_qa/installer.py` PATH split on `":"` instead of `os.pathsep`), run 37057716159: both windows pytest jobs failed (5 tests in `tests/test_installer_host_aware_claude_desktop.py`) and every ubuntu and macOS job passed, so the reduced matrix still catches it. #817 was closed unmerged and its branch deleted. - Mutation gate on this head: run 37058420037, success. - `actionlint` on `test.yml`: clean. Review: per-file sumo-qa review plus `/code-review` (high), 4 rounds and a comment-only fix round; the merge-boundary per-file pass found every file SAFE. ## Notes and decisions - Issue figures have drifted since 2026-10-01: about 5,066 tests run (not 4,746); the before-run above replaces `36857043731`; the serial local run is 157s with the treesitter extra (without it 213 tests skip and coverage stops at 93%). - Left as is: `--dist loadfile` rather than `loadgroup` (measured faster here); the suite-wide `deadline=None`; the repeated 60s literal; the duplicated MCP read helper in the two tests; `scripts/regen_tools_list_snapshot.py` still reads with a blocking, id-blind readline (pre-existing, not run in parallel). ## Checklist - [x] PR title follows Conventional Commits - [x] Tests pass locally and lint/type checks are green - [x] Added or updated tests covering the change - [x] Updated the relevant docs in this same PR - [x] No breaking changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Throwaway: proves the reduced test.yml matrix still catches a Windows-only break. Will be closed and deleted.