fix(scoring): document confidence scaling, sort by severity within rule bucket
Summary
Follow-up to #139 addressing non-blocking review feedback from @rng1995:
-
Confidence scaling documented —
_compute_risk_scoredocstring 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. -
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.pytests pass (scoring, bands, edge cases, real-world scenarios) - [x]
test_same_rule_mixed_severitiesvalidates the sort ensures CRITICAL gets full weight
Closes review feedback on #139.
Thanks for review, will work on this and add it.
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).