fix(a11y): contrast --fail-only reports failure count as total, add sampled field - #167
Merged
Merged
Conversation
…ampled Under --fail-only the envelope's top-level `total` reported the JS `summary.total` sample size (e.g. 4 or 500) instead of the actual number of returned failures (0 or 447), so any consumer asserting "page has N contrast failures" got a lie. The `total_count.max(total)` conflation in a11y_contrast::run mixed two populations (sampled elements vs returned failures). - `total` now counts returned results: post-filter/pre-limit failures under --fail-only, all checks otherwise. A --limit truncates `results` but `total` still reports the full count (with truncated: true). - New top-level `sampled` field carries the JS sample size (elements examined), so total == sampled without --fail-only and the shape stays stable across flag combinations. meta.summary is untouched. - Extracted apply_fail_only_filter as a pure, testable helper. - Help text (args.rs) documents total vs sampled with a backward-compat note that total previously reported the sample size. Tests: unit tests pinning sampled=4/failures=0 -> total=0 and sampled=500/failures=447 -> total=447; e2e parity test for total==sampled without --fail-only; three live AC tests (live_a11y_contrast_fail_only_total_zero, live_a11y_contrast_fail_only_total_counts_failures, live_a11y_contrast_limit_keeps_total) all PASS against real Firefox. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
total: under--fail-only, the a11y contrast envelope's top-leveltotalreported the in-page JSsummary.totalsample size (e.g. 4 or 500) instead of the number of returned failures (0 or 447). Thetotal_count.max(total)conflation ina11y_contrast::runmixed two populations (sampled elements vs returned failures).totalnow counts returned results: post-filter/pre-limit failures under--fail-only, all checks otherwise.--limitno longer shrinkstotal: a--limittruncatesresults(withtruncated: true) buttotalstill reports the full failure count.sampledfield: the JS sample size (elements examined) moves to its own top-levelsampledkey, sototal == sampledwithout--fail-onlyand the envelope shape stays stable across flag combinations.meta.summary(aa_pass/aa_fail/capped) is untouched.apply_fail_only_filteras a pure, testable helper; help text (args.rs) documentstotalvssampledwith a backward-compat note thattotalpreviously reported the sample size.Discovered in dogfooding-session-61; plan:
kb/iterations/iteration-127-a11y-contrast-fail-only-total.md.Test plan
fail_only_all_passing_reports_zero_total_and_sample_size(sampled=4, failures=0 →total==0,results==[],sampled==4)fail_only_reports_failure_count_not_sample_size(sampled=500, failures=447 →total==447,sampled==500)without_fail_only_total_equals_sampled,fail_only_filter_uses_large_threshold_for_large_texta11y_contrast_fail_only_filters_passing_checksupdated (total==0,sampled==2); newa11y_contrast_without_fail_only_total_equals_sampledlive_a11y_contrast_fail_only_total_zero,live_a11y_contrast_fail_only_total_counts_failures,live_a11y_contrast_limit_keeps_totalcargo fmt/cargo clippy --workspace --all-targets -- -D warnings/cargo test --workspace -qcleancargo run -p xtask -- check-iteration-ready10/10 PASS🤖 Generated with Claude Code## Claims vs code
<generated 2026-07-19T16:16:44Z by ralph-loop>
No claims extracted from commit messages.