auditmysite 1.7.3

Resource-efficient WCAG 2.2 AA Accessibility Checker in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
//! Module-level score and context derivation helpers (accessibility, performance, SEO, security, mobile).

use crate::audit::NormalizedReport;
use crate::output::localized::is_english;
use crate::wcag::Severity;

use crate::i18n::I18n;

// ─── Accessibility ───────────────────────────────────────────────────────────

pub(super) fn derive_accessibility_lever(i18n: &I18n, normalized: &NormalizedReport) -> String {
    if let Some(finding) = normalized
        .findings
        .iter()
        .max_by_key(|f| f.occurrence_count)
    {
        // Stored title is canonical English (#406); re-derive the localized
        // taxonomy title for non-English reports.
        let title = if is_english(i18n) {
            finding.title.clone()
        } else {
            crate::taxonomy::RuleLookup::by_id(&finding.rule_id)
                .map(|r| r.title.to_string())
                .unwrap_or_else(|| finding.title.clone())
        };
        i18n.t_args(
            "lever-accessibility-biggest",
            &[("finding", title.as_str())],
        )
    } else {
        i18n.t("lever-accessibility-default")
    }
}

pub(super) fn derive_accessibility_context(i18n: &I18n, normalized: &NormalizedReport) -> String {
    let high = normalized
        .findings
        .iter()
        .filter(|f| matches!(f.severity, Severity::High | Severity::Critical))
        .count();
    let total = normalized.findings.len();
    if total == 0 {
        return i18n.t("context-accessibility-none");
    }
    i18n.t_args(
        "context-accessibility-summary",
        &[("total", total.to_string()), ("high", high.to_string())],
    )
}

pub(super) fn derive_accessibility_card_context(
    i18n: &I18n,
    normalized: &NormalizedReport,
) -> String {
    let high = normalized
        .findings
        .iter()
        .filter(|f| matches!(f.severity, Severity::High | Severity::Critical))
        .count();
    if high == 0 {
        i18n.t("card-accessibility-none")
    } else {
        i18n.t_args("card-accessibility-summary", &[("high", high.to_string())])
    }
}

// ─── Performance ─────────────────────────────────────────────────────────────

pub(super) fn derive_performance_lever(
    i18n: &I18n,
    perf: &crate::audit::PerformanceResults,
) -> String {
    if let Some(dom_nodes) = perf.vitals.dom_nodes {
        if dom_nodes > 1500 {
            return i18n.t_args(
                "lever-performance-dom",
                &[("dom_nodes", dom_nodes.to_string())],
            );
        }
    }
    if let Some(load) = perf.vitals.load_time {
        if load > 2_500.0 {
            return i18n.t_args(
                "lever-performance-load",
                &[("load", format!("{:.0}", load))],
            );
        }
    }
    i18n.t("lever-performance-default")
}

pub(super) fn derive_performance_context(
    i18n: &I18n,
    perf: &crate::audit::PerformanceResults,
) -> String {
    let fcp_good = perf
        .vitals
        .fcp
        .as_ref()
        .map(|v| v.rating == "good")
        .unwrap_or(false);
    let lcp_good = perf
        .vitals
        .lcp
        .as_ref()
        .map(|v| v.rating == "good")
        .unwrap_or(false);
    let vitals_measured = perf.vitals.fcp.is_some() || perf.vitals.lcp.is_some();
    let high_dom = perf.vitals.dom_nodes.map(|n| n > 1500).unwrap_or(false);
    let has_blocking = perf
        .render_blocking
        .as_ref()
        .map(|rb| rb.has_blocking())
        .unwrap_or(false);

    // If user-perceived vitals are good but overall score is dragged down by complexity, say so.
    if vitals_measured
        && (fcp_good || lcp_good)
        && perf.score.overall < 75
        && (high_dom || has_blocking)
    {
        let fcp_str = perf
            .vitals
            .fcp
            .as_ref()
            .map(|v| format!("FCP {:.0} ms", v.value))
            .unwrap_or_else(|| "FCP n/a".to_string());
        return i18n.t_args("context-performance-good-vitals", &[("fcp", fcp_str)]);
    }

    let fcp = perf
        .vitals
        .fcp
        .as_ref()
        .map(|v| format!("FCP {:.0} ms", v.value))
        .unwrap_or_else(|| "FCP n/a".to_string());
    let ttfb = perf
        .vitals
        .ttfb
        .as_ref()
        .map(|v| format!("TTFB {:.0} ms", v.value))
        .unwrap_or_else(|| "TTFB n/a".to_string());
    let dom = perf
        .vitals
        .dom_nodes
        .map(|n| i18n.t_args("context-performance-dom-nodes", &[("n", n.to_string())]))
        .unwrap_or_else(|| i18n.t("context-performance-dom-na"));
    i18n.t_args(
        "context-performance-summary",
        &[("fcp", fcp), ("ttfb", ttfb), ("dom", dom)],
    )
}

pub(super) fn derive_performance_card_context(
    i18n: &I18n,
    perf: &crate::audit::PerformanceResults,
) -> String {
    if let Some(dom_nodes) = perf.vitals.dom_nodes {
        return i18n.t_args(
            "card-performance-dom",
            &[("dom_nodes", dom_nodes.to_string())],
        );
    }
    if let Some(load) = perf.vitals.load_time {
        return i18n.t_args("card-performance-load", &[("load", format!("{:.0}", load))]);
    }
    i18n.t("card-performance-default")
}

/// Build a `(name, formatted_value, rating)` vitals list from a PerformanceResults.
/// Used for both desktop and mobile viewport presentations.
///
/// Estimated lab metrics (INP, TTI, Speed Index) carry a localized "(lab
/// estimate)" suffix so they cannot be mistaken for directly measured — or, more
/// importantly, real field/RUM — values (#262). All values are local headless
/// lab data.
pub(super) fn build_vitals_list(
    p: &crate::audit::PerformanceResults,
    i18n: &I18n,
) -> Vec<(String, String, String)> {
    let estimated_suffix = i18n.t("perf-lab-estimate-suffix");
    let label = |base: &str, m: &crate::performance::VitalMetric| {
        if m.is_estimated() {
            format!("{base}{estimated_suffix}")
        } else {
            base.to_string()
        }
    };

    let mut vitals = Vec::new();
    if let Some(ref lcp) = p.vitals.lcp {
        vitals.push((
            label("LCP", lcp),
            format!("{:.0}ms", lcp.value),
            lcp.rating.clone(),
        ));
    }
    if let Some(ref fcp) = p.vitals.fcp {
        vitals.push((
            label("FCP", fcp),
            format!("{:.0}ms", fcp.value),
            fcp.rating.clone(),
        ));
    }
    if let Some(ref cls) = p.vitals.cls {
        vitals.push((
            label("CLS", cls),
            format!("{:.3}", cls.value),
            cls.rating.clone(),
        ));
    }
    if let Some(ref ttfb) = p.vitals.ttfb {
        vitals.push((
            label("TTFB", ttfb),
            format!("{:.0}ms", ttfb.value),
            ttfb.rating.clone(),
        ));
    }
    if let Some(ref tbt) = p.vitals.tbt {
        vitals.push((
            label("TBT", tbt),
            format!("{:.0}ms", tbt.value),
            tbt.rating.clone(),
        ));
    }
    if let Some(ref tti) = p.vitals.tti {
        vitals.push((
            label("TTI", tti),
            format!("{:.0}ms", tti.value),
            tti.rating.clone(),
        ));
    }
    if let Some(ref inp) = p.vitals.inp {
        vitals.push((
            label("INP", inp),
            format!("{:.0}ms", inp.value),
            inp.rating.clone(),
        ));
    }
    if let Some(ref si) = p.vitals.speed_index {
        vitals.push((
            label("Speed Index", si),
            format!("{:.0}ms", si.value),
            si.rating.clone(),
        ));
    }
    vitals
}

pub(super) fn derive_performance_recommendations(
    i18n: &I18n,
    perf: &crate::audit::PerformanceResults,
) -> Vec<String> {
    let mut recommendations = Vec::new();

    if let Some(lcp) = &perf.vitals.lcp {
        if lcp.value > 2500.0 {
            recommendations.push(i18n.t("recommendation-performance-lcp"));
        }
    }

    if let Some(fcp) = &perf.vitals.fcp {
        if fcp.value > 1800.0 {
            recommendations.push(i18n.t("recommendation-performance-fcp"));
        }
    }

    if let Some(interactivity) = perf.vitals.tbt.as_ref() {
        if interactivity.value > 200.0 {
            recommendations.push(i18n.t("recommendation-performance-tbt"));
        }
    }

    if let Some(cls) = &perf.vitals.cls {
        if cls.value > 0.1 {
            recommendations.push(i18n.t("recommendation-performance-cls"));
        }
    }

    if let Some(dom_nodes) = perf.vitals.dom_nodes {
        if dom_nodes > 1200 {
            recommendations.push(i18n.t("recommendation-performance-dom"));
        }
    }

    if let Some(load_time) = perf.vitals.load_time {
        if load_time > 3000.0 {
            recommendations.push(i18n.t("recommendation-performance-load"));
        }
    }

    if recommendations.is_empty() {
        recommendations.push(i18n.t("recommendation-performance-default"));
    }

    recommendations.truncate(3);
    recommendations
}

// ─── Security ────────────────────────────────────────────────────────────────

pub(super) fn derive_security_lever(
    i18n: &I18n,
    sec: &crate::security::SecurityAnalysis,
) -> String {
    let missing_headers = sec.headers.content_security_policy.is_none() as usize
        + sec.headers.strict_transport_security.is_none() as usize
        + sec.headers.permissions_policy.is_none() as usize
        + sec.headers.referrer_policy.is_none() as usize;
    if missing_headers > 0 {
        return i18n.t_args(
            "lever-security-headers",
            &[("missing_headers", missing_headers.to_string())],
        );
    }
    i18n.t("lever-security-default")
}

pub(super) fn derive_security_context(
    i18n: &I18n,
    sec: &crate::security::SecurityAnalysis,
) -> String {
    let present_headers = [
        sec.headers.content_security_policy.is_some(),
        sec.headers.strict_transport_security.is_some(),
        sec.headers.x_content_type_options.is_some(),
        sec.headers.x_frame_options.is_some(),
        sec.headers.referrer_policy.is_some(),
        sec.headers.permissions_policy.is_some(),
        sec.headers.cross_origin_opener_policy.is_some(),
        sec.headers.cross_origin_resource_policy.is_some(),
    ]
    .into_iter()
    .filter(|p| *p)
    .count();
    if sec.ssl.https {
        i18n.t_args(
            "context-security-summary-https",
            &[("present_headers", present_headers.to_string())],
        )
    } else {
        i18n.t_args(
            "context-security-summary-nohttps",
            &[("present_headers", present_headers.to_string())],
        )
    }
}

pub(super) fn derive_security_card_context(
    i18n: &I18n,
    sec: &crate::security::SecurityAnalysis,
) -> String {
    let present_headers = [
        sec.headers.content_security_policy.is_some(),
        sec.headers.strict_transport_security.is_some(),
        sec.headers.x_content_type_options.is_some(),
        sec.headers.x_frame_options.is_some(),
        sec.headers.referrer_policy.is_some(),
        sec.headers.permissions_policy.is_some(),
        sec.headers.cross_origin_opener_policy.is_some(),
        sec.headers.cross_origin_resource_policy.is_some(),
    ]
    .into_iter()
    .filter(|p| *p)
    .count();
    i18n.t_args(
        "card-security-summary",
        &[("present_headers", present_headers.to_string())],
    )
}

pub(super) fn derive_security_recommendations(
    i18n: &I18n,
    sec: &crate::security::SecurityAnalysis,
) -> Vec<String> {
    let mut recommendations = Vec::new();

    if !sec.ssl.https {
        recommendations.push(i18n.t("recommendation-security-https"));
    }

    if sec.headers.content_security_policy.is_none() {
        recommendations.push(i18n.t("recommendation-security-csp"));
    }

    if sec.headers.strict_transport_security.is_none() && sec.ssl.https {
        recommendations.push(i18n.t("recommendation-security-hsts"));
    }

    if sec.headers.cross_origin_opener_policy.is_none() {
        recommendations.push(i18n.t("recommendation-security-coop"));
    }

    if sec.headers.cross_origin_resource_policy.is_none() {
        recommendations.push(i18n.t("recommendation-security-corp"));
    }

    if sec.headers.permissions_policy.is_none() {
        recommendations.push(i18n.t("recommendation-security-permissions"));
    }

    if sec.headers.referrer_policy.is_none() {
        recommendations.push(i18n.t("recommendation-security-referrer"));
    }

    // Issue-driven recommendations. Testing only for *absent* headers left a
    // present-but-misconfigured header with nothing to say: on casoon.de
    // (2026-09-19) a High "CSP allows unsafe-inline scripts without nonce/hash
    // protection" produced no recommendation at all, so the list fell through
    // to `recommendation-security-default` — whose text asserts the headers
    // are cleanly set, directly below the finding (plan 33).
    //
    // Keyed on `SecurityIssueKind` rather than on the message text, so a
    // reworded finding cannot silently drop its recommendation.
    for issue in &sec.issues {
        let Some(kind) = issue.kind() else { continue };
        use crate::security::SecurityIssueKind;
        let key = match kind {
            SecurityIssueKind::CspUnsafeInlineScript | SecurityIssueKind::CspUnsafeInlineStyle => {
                "recommendation-security-csp-unsafe-inline"
            }
            SecurityIssueKind::CspUnsafeEvalScript => "recommendation-security-csp-unsafe-eval",
            SecurityIssueKind::CspWildcardScriptSource | SecurityIssueKind::CspWildcardSource => {
                "recommendation-security-csp-wildcard"
            }
            SecurityIssueKind::CspMissingDirective => "recommendation-security-csp-directive",
            SecurityIssueKind::CorsWildcardCredentials => {
                "recommendation-security-cors-credentials"
            }
            SecurityIssueKind::PermissionsPolicyPermissive => {
                "recommendation-security-permissions-permissive"
            }
            SecurityIssueKind::PublicSourceMap => "recommendation-security-sourcemap",
            SecurityIssueKind::HstsPreloadIneligible => "recommendation-security-hsts-preload",
            // Missing headers are already covered by the checks above; adding
            // them here would duplicate every entry.
            _ => continue,
        };
        let text = i18n.t(key);
        if !recommendations.contains(&text) {
            recommendations.push(text);
        }
    }

    // The default text states that the basic headers are cleanly set, so it
    // may only appear when there is genuinely nothing to report.
    if recommendations.is_empty() && sec.issues.is_empty() {
        recommendations.push(i18n.t("recommendation-security-default"));
    }

    recommendations.truncate(4);
    recommendations
}

// ─── Mobile ──────────────────────────────────────────────────────────────────

pub(super) fn derive_mobile_lever(
    i18n: &I18n,
    mobile: &crate::mobile::MobileFriendliness,
) -> String {
    if mobile.touch_targets.small_targets > 0 {
        return i18n.t_args(
            "lever-mobile-small",
            &[(
                "small_targets",
                mobile.touch_targets.small_targets.to_string(),
            )],
        );
    }
    if mobile.touch_targets.crowded_targets > 0 {
        return i18n.t_args(
            "lever-mobile-crowded",
            &[(
                "crowded_targets",
                mobile.touch_targets.crowded_targets.to_string(),
            )],
        );
    }
    i18n.t("lever-mobile-default")
}

pub(super) fn derive_mobile_context(
    i18n: &I18n,
    mobile: &crate::mobile::MobileFriendliness,
) -> String {
    if mobile.viewport.is_properly_configured {
        i18n.t_args(
            "context-mobile-proper",
            &[
                (
                    "small_targets",
                    mobile.touch_targets.small_targets.to_string(),
                ),
                (
                    "crowded_targets",
                    mobile.touch_targets.crowded_targets.to_string(),
                ),
            ],
        )
    } else {
        i18n.t_args(
            "context-mobile-improper",
            &[
                (
                    "small_targets",
                    mobile.touch_targets.small_targets.to_string(),
                ),
                (
                    "crowded_targets",
                    mobile.touch_targets.crowded_targets.to_string(),
                ),
            ],
        )
    }
}

pub(super) fn derive_mobile_card_context(
    i18n: &I18n,
    mobile: &crate::mobile::MobileFriendliness,
) -> String {
    if mobile.touch_targets.small_targets > 0 {
        i18n.t_args(
            "card-mobile-small",
            &[(
                "small_targets",
                mobile.touch_targets.small_targets.to_string(),
            )],
        )
    } else if mobile.touch_targets.crowded_targets > 0 {
        i18n.t_args(
            "card-mobile-crowded",
            &[(
                "crowded_targets",
                mobile.touch_targets.crowded_targets.to_string(),
            )],
        )
    } else if mobile.viewport.is_properly_configured {
        i18n.t("card-mobile-proper")
    } else {
        i18n.t("card-mobile-improper")
    }
}

// ─── Tracking ────────────────────────────────────────────────────────────────

pub(super) fn build_tracking_summary_text(
    i18n: &I18n,
    technical: &crate::seo::technical::TechnicalSeo,
) -> String {
    if technical.zaraz.detected {
        if technical.tracking_cookies.is_empty()
            && technical.tracking_signals.is_empty()
            && technical.storage_items.is_empty()
        {
            return i18n.t("tracking-summary-zaraz-clean");
        }
        return i18n.t("tracking-summary-zaraz-signals");
    }

    if technical.uses_remote_google_fonts {
        return i18n.t("tracking-summary-fonts");
    }

    if !technical.tracking_cookies.is_empty()
        || !technical.tracking_signals.is_empty()
        || !technical.storage_items.is_empty()
    {
        return i18n.t("tracking-summary-signals");
    }

    i18n.t("tracking-summary-clean")
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::security::{
        HeaderTier, ProtectionDetection, SecurityAnalysis, SecurityHeaders, SecurityIssue,
        SourceMapLeakAudit, SslInfo,
    };
    use crate::taxonomy::Severity;

    fn analysis(headers: SecurityHeaders, issues: Vec<SecurityIssue>) -> SecurityAnalysis {
        SecurityAnalysis {
            score: 95,
            grade: "A".to_string(),
            headers,
            ssl: SslInfo {
                https: true,
                ..Default::default()
            },
            issues,
            recommendations: Vec::new(),
            protection: ProtectionDetection::default(),
            sourcemap_leaks: SourceMapLeakAudit::default(),
        }
    }

    fn all_headers_present() -> SecurityHeaders {
        SecurityHeaders {
            content_security_policy: Some("default-src 'self'; script-src 'unsafe-inline'".into()),
            strict_transport_security: Some("max-age=31536000".into()),
            x_content_type_options: Some("nosniff".into()),
            x_frame_options: Some("SAMEORIGIN".into()),
            referrer_policy: Some("strict-origin".into()),
            permissions_policy: Some("camera=()".into()),
            cross_origin_opener_policy: Some("same-origin".into()),
            cross_origin_resource_policy: Some("cross-origin".into()),
            ..Default::default()
        }
    }

    fn csp_issue(issue_type: &str, severity: Severity) -> SecurityIssue {
        SecurityIssue {
            header: "Content-Security-Policy".to_string(),
            issue_type: issue_type.to_string(),
            message: "canonical english message".to_string(),
            severity,
            tier: HeaderTier::Baseline,
            values: Default::default(),
        }
    }

    /// Plan 33: every header present but the CSP misconfigured. The old
    /// derivation only tested for *absent* headers, produced nothing, and fell
    /// through to the default text — which asserts the headers are cleanly
    /// set, directly below the finding. Confirmed live on casoon.de
    /// (2026-09-19).
    #[test]
    fn misconfigured_header_produces_a_recommendation_not_the_all_clear() {
        let i18n = I18n::new("de").expect("locale loads");
        let sec = analysis(
            all_headers_present(),
            vec![
                csp_issue("unsafe_inline_script", Severity::High),
                csp_issue("unsafe_inline_style", Severity::Medium),
                csp_issue("missing_frame-ancestors", Severity::Medium),
            ],
        );

        let recs = derive_security_recommendations(&i18n, &sec);

        assert!(!recs.is_empty(), "a misconfigured CSP must yield an action");
        let default = i18n.t("recommendation-security-default");
        assert!(
            !recs.contains(&default),
            "the all-clear text must not appear next to open issues: {recs:#?}",
        );
        assert!(
            recs.iter().any(|r| r.contains("unsafe-inline")),
            "expected the unsafe-inline remediation: {recs:#?}",
        );
    }

    /// The all-clear stays available when it is true.
    #[test]
    fn clean_security_analysis_keeps_the_default_recommendation() {
        let i18n = I18n::new("de").expect("locale loads");
        let sec = analysis(all_headers_present(), Vec::new());

        let recs = derive_security_recommendations(&i18n, &sec);
        assert_eq!(recs, vec![i18n.t("recommendation-security-default")]);
    }

    /// Missing headers must not be reported twice now that issues also feed
    /// the list.
    #[test]
    fn missing_header_recommendations_are_not_duplicated() {
        let i18n = I18n::new("de").expect("locale loads");
        let sec = analysis(
            SecurityHeaders::default(),
            vec![SecurityIssue {
                header: "Content-Security-Policy".to_string(),
                issue_type: "missing_header".to_string(),
                message: "Content-Security-Policy header is missing".to_string(),
                severity: Severity::High,
                tier: HeaderTier::Baseline,
                values: Default::default(),
            }],
        );

        let recs = derive_security_recommendations(&i18n, &sec);
        let csp = i18n.t("recommendation-security-csp");
        assert_eq!(
            recs.iter().filter(|r| **r == csp).count(),
            1,
            "missing-CSP recommendation duplicated: {recs:#?}",
        );
    }
}