Skip to main content

SKY-A102 · AI-code defects

High-risk change without tests

Low

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 --diff scan 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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

billing/invoices.py · Python · changed
"""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
tests/test_invoices.py · Python
from billing.invoices import calculate_total  def test_total_includes_tax():    items = [{"price": 1000, "qty": 2}]    total = calculate_total(items)     assert total == 2400

What Skylos leaves alone

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

billing/invoices.py · Python · changed
"""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))
tests/test_invoices.py · Python · changed
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 == 2500

Why 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

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

src/payments/refunds.ts · TypeScript · changed
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
src/payments/refunds.test.ts · TypeScript
import { canRefund } from "./refunds"; test("refunds are allowed inside the window", () => {  expect(canRefund(30)).toBe(true);});

Not flagged

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

src/payments/refunds.ts · TypeScript · changed
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;}
src/payments/refunds.test.ts · TypeScript · changed
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

  1. Runs with --ai-defects when 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 (--diff or --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.
  2. Sorts the changed files into tests and source. Test files are those in a test or tests folder, named test_*, or ending in _test.py, _test.go, .test.ts, .spec.js, Test.java, Tests.cs and similar.
  3. 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.
  4. 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, webhook or rate_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.

Fix · Python
def test_total_includes_tax():    items = [{"price": 1000, "qty": 2}]    total = calculate_total(items)     assert total == 2500

When 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.py and taxonomy.py count 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

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.