Repository navigation
Description
Problem
A test command that Refactron cannot parse but which carries positional arguments narrows the suite and still reaches SAFE. This is the same defect as #110, surviving under a runner the classifier does not recognise.
Reproduction
Executed against main at 83bf98e (after #112 and #113 merged), via verifyDiff. Same repo, same diff (return x * 2 → return x * 3), two unittest test modules: test_scale executes the changed line without pinning its value, test_report pins it and fails. Only the command differs.
python3 -m unittest discover -s tests -> UNSAFE
python3 -m unittest tests.test_scale -> SAFE
testScope = {"scope":"unknown","source":"override",
"signals":["python3 is not a recognised test runner, so the scope is unknown"]}
coverage = coverage.py {"total":1,"covered":1}
The second command runs one test, misses the one that catches the change, measures full statement coverage of the changed line, and earns SAFE.
Django's python3 tests/runtests.py auth is the same shape.
Why this was left open
ADR-12 (dev-docs/decisions/12-narrowed-testcmd-policy.md) decided that unknown does not floor the verdict, and recorded this exact hole as Alternative C. That decision was correct for the reason given: most unknown commands are a full suite carrying a plugin flag we do not recognise (pytest --doctest-modules), and flooring them would turn every unrecognised flag in the wild into a SAFE-killer fixable only by a PR to us.
The deferral was on risk, not merit: #112 already shipped one change to what SAFE means and a third heuristic in the same PR compounded risk on the one verdict we cannot get wrong.
Direction
unknown is not one situation, it is three. Only the third is dangerous:
| Bucket | Example | Reaches SAFE today | Action |
|---|---|---|---|
| 1. Unrecognised runner, no positional args | make test, tox |
No — toCoverageRunArgs declines it, so coverage is unknown and the verdict is already UNPROVEN |
Leave |
| 2. Recognised runner, unrecognised flag | pytest --doctest-modules |
Yes, and it is a full suite | Must not floor |
| 3. Unrecognised runner with positional args | python -m unittest tests.test_scale, python3 tests/runtests.py auth |
Yes, and it is narrowed | Floor at UNPROVEN |
Flooring only bucket 3 closes the reproduction, leaves bucket 2 untouched, and degrades with a named reason rather than a guess — the house doctrine everywhere else in this engine.
The care this needs
The failure mode of getting bucket 3 wrong is a user losing a deserved SAFE, so what counts as a "positional argument" has to be right:
python3 -m unittest discover -s testsis a full suite.discoveris a subcommand, the way vitest'srunalready is insrc/verify/test-scope.ts.python3 tests/runtests.pywith no arguments is a full suite; withauthit is narrowed.-s testsis a flag with a value, not a filter.
Acceptance criteria
- Red-first. An integration test reproducing the case above, proven failing against
main(where it returnsSAFE), assertingUNPROVENafter. Use the two-module fixture so the full-suite control returnsUNSAFEon the identical diff. - A unit table in
tests/unit/verify/test-scope.test.tscovering:python -m unittest tests.test_foo→ narrowed;python -m unittest discover→ full;python -m unittest discover -s tests→ full;python3 tests/runtests.py auth→ narrowed;python3 tests/runtests.py→ full. - Negative, non-negotiable: bucket 2 is untouched.
pytest --doctest-modules,pytest -q --forkedstayunknownand stay able to reachSAFE. - Negative: bucket 1 is untouched.
make test,npm test,tox,./run-tests.shstayunknownand unfloored. - Every newly floored command carries a signal string naming why.
- ADR-12 updated: Alternative C moves from "deferred" to the implemented decision, with the reproduction recorded.
npm run prepublishOnlygreen.
Verdict integrity
- Verdict at risk:
SAFE, and it is going wrong today on a shipped release, reachable through the unauthenticated MCP tool. - Direction is fail-safe: this can only move
SAFE→UNPROVEN. - The risk this change introduces is the opposite one — a false
narrowedcosting a legitimateSAFE— which criteria 3 and 4 exist to pin.
Non-goals
- Making the floor adversary-proof.
sh -c "pytest tests/x.py"still lands inunknown. This is a mistake-catcher, not an adversary-stopper, and ADR-12 says so. Tracked separately. - Narrowing configured outside the command string (
pytest.iniaddopts, exportedPYTEST_ADDOPTS, vitestinclude). Separate issue. - Adding
unittestorruntests.pyas fully-parsed runners with their own flag tables. The point is to detect arguments, not to model every runner's CLI.
Activity