SkillSpector icon indicating copy to clipboard operation
SkillSpector copied to clipboard

fix(scoring): document confidence scaling, sort by severity within rule bucket

Open mimran-khan opened this issue 5 months ago • 2 comments

Summary

Follow-up to #139 addressing non-blocking review feedback from @rng1995:

  1. Confidence scaling documented — _compute_risk_score docstring now explicitly states that each finding's contribution is scaled by its confidence value (clamped to [0,1]) and that zero-confidence findings are skipped without consuming a weight slot.

  2. Severity sort within rule bucket — Findings are now sorted by (rule_id, severity DESC) before applying diminishing weights, ensuring the highest-severity occurrence of each rule always receives the full weight regardless of input order.

Test plan

  • [x] All 38 existing test_report.py tests pass (scoring, bands, edge cases, real-world scenarios)
  • [x] test_same_rule_mixed_severities validates the sort ensures CRITICAL gets full weight

Closes review feedback on #139.

mimran-khan avatar Jun 22 '26 20:06 mimran-khan

Thanks for review, will work on this and add it.

mimran-khan avatar Jun 23 '26 08:06 mimran-khan

Addressed — pushed the regression test:

test_same_rule_low_before_critical_sorted_correctly: feeds [LOW, CRITICAL] for the same rule_id and asserts score 52. Without the severity sort the score would be 30 (LOW gets full weight at 51.0=5, CRITICAL gets diminished at 500.5=25). With the sort it's 52 (CRITICAL first at 501.0=50, LOW second at 50.5=2.5).

Branch rebased on latest main (5 PRs merged upstream today).

mimran-khan avatar Jun 23 '26 09:06 mimran-khan