BarrierLab

audit-score

Opt-in scoring over a11y-report: profiles, a score and a coverage that are never merged, a full breakdown, and a CI gate.

An opt-in layer (L2) on top of a11y-report for hosts that need a single number. It only computes; the finding model stays untouched.

Status

New, unreleased. Depends only on a11y-report and serde; builds for wasm32-unknown-unknown.

Why a separate crate

a11y-report deliberately has no score: one percentage would flatten Fail, Review, Pass and Untested, and hide whether a rule ran at all. a11y-report stays score-free. audit-score is where the number lives, and it keeps the honesty by returning two numbers that are never merged:

FieldMeaning
score0.0..=100.0, one decimal. 100 minus the capped deductions of all findings.
coverage0.0..=1.0. executed / (executed + not_run) over Report::rule_runs.

A report with no deductions and half its rules not run is score 100.0, coverage 0.5. An empty report has coverage 0.0 (not NaN).

How the report maps

a11y-reportEffect
Outcome::Faildeduction from fail_penalties[severity]; counted in fail_counts
Outcome::Reviewdeduction from review_penalties[severity]; counted in open_reviews
Outcome::Review with Basis::BestPracticenever a deduction; counted in best_practice_notes
Outcome::Passnothing
Outcome::Untestedno deduction (no judgement was made); counted in untested_findings
RuleRun rancounts as executed
NotRun::CapabilityMissing, Disabled, Errored (and future variants)coverage gap
NotRun::NotApplicablenothing to check: neither executed nor a gap; not_applicable_rules

Severity has four levels (Low, Medium, High, Critical), so SeverityWeights has four fields. Rule runs are keyed per (rule_id, viewport) in the report, so a rule that ran on desktop but not on mobile counts once on each side.

Calculation

Per finding: weight(severity) * prefix_weight(rule_id), floored at 0 (a negative or NaN weight never gives points back). Per rule the deductions are summed (raw_deduction), then limited by max_penalty_per_rule (capped_deduction). score = round1(clamp(100 - sum(capped), 0, 100)).

Prefix weights: the longest matching prefix wins; with identical prefixes the first entry wins. The empty prefix "" matches every rule and so acts as the default weight. No match means 1.0.

breakdown lists rules with a deduction above zero, sorted by capped deduction descending, then rule id ascending. raw_deduction > capped_deduction means the cap applied.

Profiles

ProfileFail crit/high/med/lowReview crit/high/med/lowCap per rulePrefix weights
wcag_strict20 / 10 / 5 / 1050none
balanced (default)10 / 5 / 2 / 0.52 / 1 / 0.5 / 015none
visual_focusas balancedas balanced15visual/ 1.5, everything else 0.75

wcag_strict makes a violation hurt and treats a heuristic suspicion as not yet a violation. balanced is about half as strict; reviews cost at most a fifth of a confirmed fail. visual_focus shifts weight towards rules under visual/ without hiding the rest. Custom profiles are plain data (ScoringProfile, serde-capable); ..ScoringProfile::balanced() derives one.

CI gate

GatePolicy::decide(&ScoreResult) -> GateResult returns Pass, Warn or Fail plus the reasons (check, level, actual, threshold). Each threshold is optional.

  • min_score / min_coverage: Fail if the value is strictly below. A value exactly on the threshold passes.
  • warn_score / warn_coverage: same, but Warn.
  • max_blocking_fails with blocking_severity: Fail if the number of Outcome::Fail findings at that severity or higher is greater than the maximum. Some(0) with High means “no critical or high fail”.

GatePolicy::default(): fail below score 70 or coverage 0.5 or with any critical/high fail; warn below score 90 or coverage 0.8.

Not in scope

No HTML or other formatting, no history across builds (that belongs to a host), no I/O and no clock.

Edit this page on GitHub