SKY-A102 · AI-code defects
High-risk change without tests
SKY-A102 notices when a change touches code in a sensitive area, such as authentication, billing, payments, tokens or webhooks, judged by the file path, and no test file in the same change gains an assertion. It is a nudge to add or update a test, reported on line 1 of each such file.
- Languages
- Python, TypeScript, JavaScript, Go, Java, Kotlin, C#, PHP, Rust, Dart
- Turned on by
skylos . --ai-defects(or-a) on a Git checkout with uncommitted changes; in a--diffscan only when line 1 of the file changed- Quality gate
- counted toward the gate limits (full and diff scans). Counts toward
max_ai_defects; LOW, so it never fails the gate on its own. The finding is marked as a signal to review, not a defect. - Finding type
- review
Why it matters
A coding agent can change a tax rate, a permission check or a token expiry and report success because the existing tests still pass. In these areas a silent behaviour change costs money or opens access, so the change should come with a test that pins the new behaviour.
What Skylos flags
"""Invoice maths for the checkout service.""" Removed: TAX_RATE = 0.2Added: TAX_RATE = 0.25 def calculate_total(items): subtotal = sum(item["price"] * item["qty"] for item in items) return round(subtotal * (1 + TAX_RATE))1 committed file the change leaves alone
from billing.invoices import calculate_total def test_total_includes_tax(): items = [{"price": 1000, "qty": 2}] total = calculate_total(items) assert total == 2400What Skylos leaves alone
"""Invoice maths for the checkout service.""" Removed: TAX_RATE = 0.2Added: TAX_RATE = 0.25 def calculate_total(items): subtotal = sum(item["price"] * item["qty"] for item in items) return round(subtotal * (1 + TAX_RATE))from billing.invoices import calculate_total def test_total_includes_tax(): items = [{"price": 1000, "qty": 2}] total = calculate_total(items) Removed: assert total == 2400Added: assert total == 2500Why Skylos leaves it alone
The same billing change now comes with a test edit that adds an assertion. Skylos does not check that the test covers the changed line, only that some test file in the change gained an assertion.
More languages
TypeScript
Flagged
Removed: export const MAX_REFUND_DAYS = 30;Added: export const MAX_REFUND_DAYS = 60; export function canRefund(daysSincePurchase: number): boolean { return daysSincePurchase <= MAX_REFUND_DAYS;}1 committed file the change leaves alone
import { canRefund } from "./refunds"; test("refunds are allowed inside the window", () => { expect(canRefund(30)).toBe(true);});Not flagged
Removed: export const MAX_REFUND_DAYS = 30;Added: export const MAX_REFUND_DAYS = 60; export function canRefund(daysSincePurchase: number): boolean { return daysSincePurchase <= MAX_REFUND_DAYS;}import { canRefund } from "./refunds"; test("refunds are allowed inside the window", () => {Removed: expect(canRefund(30)).toBe(true);Added: expect(canRefund(60)).toBe(true);Added: expect(canRefund(61)).toBe(false);});Why Skylos leaves it alone
The refund window change comes with new expect(...) checks in refunds.test.ts, a file named like a test, so the change counts as tested.
How Skylos decides
- Runs with
--ai-defectswhen there is a change: in a full scan of a Git checkout whose tracked files have uncommitted or staged changes, or in a diff scan (--diffor--diff-base, where untracked files count too). A diff scan keeps only findings on changed lines, so there the finding survives only when line 1 of the file is part of the change. - Sorts the changed files into tests and source. Test files are those in a
testortestsfolder, namedtest_*, or ending in_test.py,_test.go,.test.ts,.spec.js,Test.java,Tests.csand similar. - If any changed test file gains an assertion (
assert,expect(,self.assertEqual(,pytest.raises(,t.Errorf(,assertThat(and others, outside strings and comments), the change counts as tested and nothing is reported. A new test file with no diff is read whole. - Otherwise reports each changed source file (
.py,.ts,.js,.go,.java,.kt,.cs,.php,.rs,.dart) whose path contains a high-risk word:auth,login,password,token,jwt,session,permission,policy,csrf,billing,checkout,invoice,payment,subscription,tax,tenant,security,validation,webhookorrate_limit. At most ten files are reported, each on line 1.
How to fix it
Add or update a test in the same change that checks the new behaviour, ideally at the boundary that moved (the new tax amount, day 60 and day 61 of the refund window). If behaviour did not change, say so in the pull request.
def test_total_includes_tax(): items = [{"price": 1000, "qty": 2}] total = calculate_total(items) assert total == 2500When it can be wrong
- A pure refactor, a renamed variable or an added log line in a file whose path holds a high-risk word is reported. The rule reads paths, not what the change did.
- Any assertion added to any test file clears the whole change, even a test of something unrelated. Do not read a missing SKY-A102 as proof that the risky change is tested.
- Words are matched inside longer names too:
tokenizer.pyandtaxonomy.pycount as high-risk.
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
[tool.skylos] ignore = ["SKY-A102"]turns the rule off for the project.An inline comment does not silence it in Skylos 5.6.0. The finding names its file by a relative path, which the inline-comment lookup does not match, so this line is still reported:
Python """Invoice maths for the checkout service.""" # skylos: ignore[SKY-A102] rate only