SKY-A120 · AI-code defects
Changed line not checked by tests
A changed line in non-test Python code that no test runs, or that tests run without noticing when it is wrong. Skylos traces the test run to see which tests execute each changed line, then changes the line on purpose (a mutation, such as >= to >) and reruns those tests: if they all still pass, no test checks that line.
- Languages
- Python (pytest)
- Turned on by
skylos done(compares uncommitted changes withHEAD) orskylos done --base origin/mainfor a pull request; it needs the test run, so not with--no-tests- Quality gate
- not checked (full and diff scans). Only
skylos donereports it, in itschanged_lines_checkedcheck, which advises by default: the finding is shown but does not fail the verdict. Withchanged_lines_checked = "block"in[tool.skylos.done.checks]it blocks. The check runs only after the blocking checks pass and the tests pass. - Finding type
- review
Why it matters
Coverage alone says a line ran, not that a test would catch a mistake in it. A coding agent can change a boundary or a condition, see the suite pass, and ship a change no test actually pins down.
What Skylos flags
"""Volume discounts for wholesale orders.""" def bulk_discount(quantity):Removed: if quantity >= 10:Added: if quantity >= 12: return 0.1 return 0.02 committed files the change leaves alone
[project]name = "shop"version = "0.3.0" [tool.pytest.ini_options]testpaths = ["tests"]from shop.pricing import bulk_discount def test_large_order_gets_discount(): assert bulk_discount(50) == 0.1 def test_single_item_pays_full_price(): assert bulk_discount(1) == 0.0What Skylos leaves alone
"""Volume discounts for wholesale orders.""" def bulk_discount(quantity):Removed: if quantity >= 10:Added: if quantity >= 12: return 0.1 return 0.0from shop.pricing import bulk_discount def test_large_order_gets_discount(): assert bulk_discount(50) == 0.1 def test_single_item_pays_full_price(): assert bulk_discount(1) == 0.0Added: Added: Added: def test_discount_starts_at_twelve():Added: assert bulk_discount(12) == 0.1Added: assert bulk_discount(11) == 0.01 committed file the change leaves alone
Why Skylos leaves it alone
The same threshold change, but a new test checks both sides of it. When Skylos turns >= into >, bulk_discount(12) returns 0.0 and the test fails, so the line is checked.
How Skylos decides
- Runs in
skylos done, after the blocking checks and thetests_passcheck. It needs pytest, and every test must have run and passed; with--no-tests, another test command or failing tests the check is skipped. - Picks the changed lines in non-test Python files (not
test_*.py,*_test.py,conftest.pyor files undertest,testsortestingfolders, and not migrations), anchored to their statement or condition. Logging calls, imports, docstrings, type hints and module-level code are skipped. - Uses the trace of the test run to find which tests execute each line. A line no test runs is reported once per function ("No test runs ...").
- For a line that tests run, makes one mutation chosen by what the line does (flip a comparison, negate a condition, change a return value, a number, an operator or an argument, or drop a call), loads it in memory inside the test process and reruns only the tests that run the line. If all of them still pass, it reports "No test fails if ...". The working tree is never modified.
- At most 20 mutants run, within
changed_lines_budget_seconds(120 by default). Lines past either limit are counted as not checked, never as passing.
How to fix it
Add a test that would fail if the changed line were wrong. For a threshold, check the values just on each side of it.
def test_discount_starts_at_twelve(): assert bulk_discount(12) == 0.1 assert bulk_discount(11) == 0.0When it can be wrong
- Some lines are not worth a test, such as a changed default log level or a message string; the finding is advice for that reason.
- A mutation that does not change behaviour (an equivalent mutant) is reported even though no test could catch it.
- Only Python run under pytest is checked. Changed lines in other languages, or in projects whose
test_commandis not pytest, are not checked.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
skylos donefindings ignore# skylos: ignore[...]comments and the[tool.skylos] ignorelist. The check only advises by default; to turn it off, commit the mode to the base branch first (the change under review cannot change its own check):TOML [tool.skylos.done.checks]changed_lines_checked = "off"