SkillSpector icon indicating copy to clipboard operation
SkillSpector copied to clipboard

Coverage is computed but never affects the exit code: a partially-blind scan is indistinguishable from a complete one in CI

Open Mark2Mac opened this issue 3 months ago • 3 comments

Summary

analysis_completeness already carries everything needed to know how much of a skill was inspected: coverage_percent, is_complete, ledger_exceptions with reason codes. It is a good design and it is why the numbers below exist at all.

But it stops at the JSON boundary. skillspector scan exits 1 only when risk_score > RISK_THRESHOLD, and 2 on error. A scan that inspected 86 % of the components exits 0 exactly like one that inspected 100 %. In CI, where the exit code is the whole interface, the two are indistinguishable.

Measured

91 reports, Claude Code skill marketplaces on one workstation:

is_complete: false 88 / 91
worst coverage_percent 86.4 %
reasons binary_content 665, llm_batch_failed 344, size_limit 91, syntax_error 1

The size_limit bucket is the one that changes conclusions: 73 distinct .js files above MAX_FILE_CHARS were never opened by any static analyzer. They are executable files inside installed skills. The ledger records this correctly — nothing is hidden — but no automated gate can act on it.

Padding a payload past 1 000 000 characters is not a sophisticated evasion.

Suggestion

Two opt-in flags, so nothing changes for existing users:

--min-coverage FLOAT     non-zero exit if coverage_percent < FLOAT
--fail-on-incomplete     non-zero exit if is_complete is false

A distinct exit code (say 3) would keep "risk found" and "could not look" separable — they lead to different actions.

One caveat from having built this in a wrapper: an absolute threshold fires on 88 reports out of 91 on day one, and then gets switched off. Accepting the current coverage into a baseline and failing on regression proved far more durable. That may be more than SkillSpector wants to own; a plain --min-coverage already unblocks the CI case.

Happy to send a PR.

Environment

SkillSpector 2.5.1 and main @ 2.9.5, Linux, Python 3.13.

Mark2Mac avatar Aug 18 '26 00:08 Mark2Mac

Half of this landed with --fail-on-incomplete in #393 — thank you. Re-measured what is left on main at d3a849a, so the remainder is concrete rather than a re-reading of the original report.

Fixture: a skill whose SKILL.md says nothing interesting, plus one 1.5 MB .js of harmless comment lines, scanned with --no-llm.

coverage_percent: 50.0   is_complete: false   no findings
scan …                          -> exit 0
scan … --fail-on-incomplete     -> exit 1

Two gaps remain, both from the original suggestion:

  1. The exit code does not separate "found something" from "could not look". --fail-on-incomplete and risk_score > RISK_THRESHOLD both raise typer.Exit(1) (cli.py:703-706). In CI those lead to different actions — one is triage a finding, the other is fix the scan — and a distinct code (the report suggested 3) is the only thing that tells them apart from a wrapper.

  2. No --min-coverage. At 50 % coverage there is currently no way to say "fail under 80 %" without parsing the JSON. is_complete is all-or-nothing, and in practice almost nothing is complete: 88 of the 91 reports in the original measurement had is_complete: false, so a boolean gate is one that gets switched off on day one, while a threshold can be tightened over time.

I am happy to send a PR, but the exit-code half is your call and not mine to make unilaterally: changing --fail-on-incomplete from 1 to 3 would break anyone already relying on it after #393. The alternatives I can see are a new --coverage-exit-code INT (default 1, so nothing changes), or leaving the code alone and adding only --min-coverage. Tell me which shape you want and I will build that one.

Mark2Mac avatar Aug 31 '26 16:08 Mark2Mac

The remaining configurable coverage gate is in progress in PR #423, adding --min-coverage while preserving the existing --fail-on-incomplete behavior. Keeping this issue open until the PR merges and recursive/output/exit-code precedence is verified.

rng1995 avatar Sep 16 '26 23:09 rng1995

Merge-state update checked on 2026-10-06: PR #423 has merged, and GitHub automatically closed this issue as completed.

The opt-in --min-coverage threshold now gives CI a failing exit status when inspection coverage is below the selected threshold, including recursive scans.

rng1995 avatar Oct 04 '26 10:10 rng1995