stygian-browser 0.14.1

Anti-detection browser automation library for Rust with CDP stealth features
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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
//! Scoring logic for [`TransportProfile`] × [`TransportObservation`].
//!
//! The [`score`] function is the single entry point that produces a
//! [`TransportRealismReport`] from a profile + observation pair. The
//! report carries a [`TransportCompatibility`] (the headline score,
//! confidence, and coverage markers) plus the structured mismatch
//! list the caller can attach to downstream telemetry.
//!
//! The function is fully deterministic — no I/O, no clock reads —
//! so unit tests can exercise the full state space without spinning
//! up a browser.

use serde::{Deserialize, Serialize};

use crate::tls_validation::compare_http2_settings;

use super::observations::{TransportObservation, compare_header_order};
use super::profile::TransportProfile;

/// Number of HTTP/2 checks the [`TransportProfile`][super::TransportProfile] supports.
///
/// Kept as a const so callers can pre-allocate fixed-size result
/// vectors and so the scoring function is easy to reason about.
pub const HTTP2_CHECK_KIND_COUNT: usize = 3;

/// Stable identifier for a single HTTP/2 check.
///
/// Used in the [`TransportCompatibility::checks`][super::TransportCompatibility::checks]
/// section so downstream telemetry can attribute scores to a
/// specific check kind without depending on enum-variant order.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Http2CheckKind {
    /// HTTP/2 SETTINGS frame fingerprint.
    Settings,
    /// HTTP/2 pseudo-header order (`:method`/`:authority`/`:scheme`/`:path`).
    PseudoHeaderOrder,
    /// HTTP/2 regular header order (after pseudo-headers).
    HeaderOrder,
}

impl Http2CheckKind {
    /// Stable string label.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Settings => "http2_settings",
            Self::PseudoHeaderOrder => "http2_pseudo_header_order",
            Self::HeaderOrder => "http2_header_order",
        }
    }
}

/// Per-check result attached to a [`TransportCompatibility`][super::TransportCompatibility].
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Http2CheckResult {
    /// Which check was evaluated.
    pub kind: Http2CheckKind,
    /// `true` when the observation matched the reference.
    pub matched: bool,
    /// Sub-score in `[0.0, 1.0]`. `0.0` when the observation was not
    /// supplied.
    pub score: f64,
    /// Number of items (settings / pseudo-headers / headers) the
    /// observation supplied.
    pub observed_count: usize,
    /// Number of items the reference carried.
    pub expected_count: usize,
    /// Stable position-match ratio in `[0.0, 1.0]`.
    pub position_match_ratio: f64,
}

/// Per-target compatibility score with confidence/coverage markers.
///
/// # Example
///
/// ```
/// use stygian_browser::transport_realism::{
///     score, TransportObservation, TransportProfile,
/// };
///
/// let profile = TransportProfile::default();
/// let observation = TransportObservation::chrome_136_reference();
/// let report = score(&profile, &observation);
/// assert!(report.compatibility.is_high_confidence());
/// assert!(report.compatibility.is_well_covered());
/// ```
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TransportCompatibility {
    /// Per-check breakdown.
    pub checks: Vec<Http2CheckResult>,
    /// Per-target compatibility score in `[0.0, 1.0]`.
    pub score: f64,
    /// Confidence marker in `[0.0, 1.0]`. Reflects how reliable
    /// the score is given the supplied observations and the
    /// profile's expectations. `0.0` when no HTTP/2 observations
    /// were available.
    pub confidence: f64,
    /// Coverage marker in `[0.0, 1.0]`. Reflects what fraction of
    /// the profile's expected checks were actually observed.
    /// `0.0` when no HTTP/2 observations were available.
    pub coverage: f64,
    /// Number of checks that matched the reference.
    pub matched_count: usize,
    /// Total number of checks the profile expected.
    pub total_checks: usize,
    /// Human-readable mismatch descriptions (empty when all checks
    /// matched).
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub mismatches: Vec<String>,
}

impl TransportCompatibility {
    /// `true` when coverage is at least `0.5` (i.e. the observation
    /// captured at least half of the expected HTTP/2 checks).
    #[must_use]
    pub fn is_well_covered(&self) -> bool {
        self.coverage >= 0.5
    }

    /// `true` when confidence is at least `0.5` (i.e. the score is
    /// derived from enough observation signal to trust).
    #[must_use]
    pub fn is_high_confidence(&self) -> bool {
        self.confidence >= 0.5
    }

    /// `true` when score is at least `0.95` — a strong match.
    #[must_use]
    pub fn is_strong_match(&self) -> bool {
        self.score >= 0.95
    }
}

/// Top-level transport-realism report attached to acquisition
/// results.
///
/// Carries the [`TransportCompatibility`] score plus the originating
/// [`TransportProfile`][super::TransportProfile] identity so
/// downstream policy mapping (T83 / T85 / T89 / T93) can attribute
/// the score to a specific profile without re-parsing the
/// `AcquisitionRequest`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TransportRealismReport {
    /// Profile name carried on the originating request (free-form).
    pub profile_name: String,
    /// Per-target compatibility score.
    pub compatibility: TransportCompatibility,
}

impl TransportRealismReport {
    /// `true` when the report represents a strong match against the
    /// profile.
    #[must_use]
    pub fn is_strong_match(&self) -> bool {
        self.compatibility.is_strong_match()
    }

    /// `true` when the report is derived from enough HTTP/2
    /// observation signal to be trusted.
    #[must_use]
    pub fn is_high_confidence(&self) -> bool {
        self.compatibility.is_high_confidence()
    }
}

/// Score the supplied `observation` against the `profile`.
///
/// Returns a deterministic [`TransportRealismReport`]. When `profile`
/// has at least one HTTP/2 expectation enabled and `observation`
/// carries no HTTP/2 signal, the function returns a report whose
/// `compatibility.score` is
/// [`super::DEFAULT_SCORE_WHEN_HTTP2_UNAVAILABLE`],
/// `compatibility.confidence` is
/// [`super::DEFAULT_CONFIDENCE_WHEN_HTTP2_UNAVAILABLE`], and
/// `compatibility.coverage` is
/// [`super::DEFAULT_COVERAGE_WHEN_HTTP2_UNAVAILABLE`]. The mismatch
/// list always carries a `"http2_observations_unavailable"` entry so
/// downstream automation can detect the "no signal" path
/// deterministically.
///
/// # Example
///
/// ```
/// use stygian_browser::transport_realism::{
///     score, TransportObservation, TransportProfile,
/// };
///
/// let profile = TransportProfile::default();
/// let observation = TransportObservation::chrome_136_reference();
/// let report = score(&profile, &observation);
/// assert!(report.compatibility.score > 0.95);
/// ```
#[must_use]
pub fn score(
    profile: &TransportProfile,
    observation: &TransportObservation,
) -> TransportRealismReport {
    let total_checks = profile.expected_http2_check_count();

    // Fast path: no HTTP/2 expectations enabled → report a perfect
    // score and full coverage (the profile explicitly opted out of
    // every check).
    if total_checks == 0 {
        return TransportRealismReport {
            profile_name: profile.name.clone(),
            compatibility: TransportCompatibility {
                checks: Vec::new(),
                score: 1.0,
                confidence: 1.0,
                coverage: 1.0,
                matched_count: 0,
                total_checks: 0,
                mismatches: Vec::new(),
            },
        };
    }

    // Fast path: no HTTP/2 observations were supplied at all. The
    // score collapses to the documented "no signal" defaults.
    if !observation.has_http2() {
        return TransportRealismReport {
            profile_name: profile.name.clone(),
            compatibility: TransportCompatibility {
                checks: Vec::new(),
                score: super::DEFAULT_SCORE_WHEN_HTTP2_UNAVAILABLE,
                confidence: super::DEFAULT_CONFIDENCE_WHEN_HTTP2_UNAVAILABLE,
                coverage: super::DEFAULT_COVERAGE_WHEN_HTTP2_UNAVAILABLE,
                matched_count: 0,
                total_checks,
                mismatches: vec!["http2_observations_unavailable".to_string()],
            },
        };
    }

    score_with_observations(profile, observation, total_checks)
}

/// Score when observations are available. Extracted so the top-level
/// `score` function stays under the clippy `too_many_lines` ceiling.
fn score_with_observations(
    profile: &TransportProfile,
    observation: &TransportObservation,
    total_checks: usize,
) -> TransportRealismReport {
    let mut state = ScoringState::default();

    if profile.expectations.contains(TransportProfile::SETTINGS) {
        score_settings_check(profile, observation, &mut state);
    }
    if profile
        .expectations
        .contains(TransportProfile::PSEUDO_HEADER_ORDER)
    {
        score_pseudo_header_check(profile, observation, &mut state);
    }
    if profile
        .expectations
        .contains(TransportProfile::HEADER_ORDER)
    {
        score_header_order_check(profile, observation, &mut state);
    }

    state.finalize(profile, total_checks)
}

/// Mutable accumulator for the scoring loop. Keeps `score` and its
/// helpers under the clippy line ceilings.
#[derive(Default)]
struct ScoringState {
    checks: Vec<Http2CheckResult>,
    mismatches: Vec<String>,
    observed_count: usize,
    matched_count: usize,
    sum_scores: f64,
    sum_weights: f64,
}

impl ScoringState {
    /// Record the SETTINGS-frame check result.
    fn record(&mut self, check: Http2CheckResult, weight: f64, observed: bool, matched: bool) {
        if observed {
            self.observed_count += 1;
        }
        if matched {
            self.matched_count += 1;
        }
        self.sum_scores = weight.mul_add(check.score, self.sum_scores);
        self.sum_weights += weight;
        self.checks.push(check);
    }

    /// Push a mismatch description.
    fn push_mismatch(&mut self, description: String) {
        self.mismatches.push(description);
    }

    /// Finalize the report.
    fn finalize(self, profile: &TransportProfile, total_checks: usize) -> TransportRealismReport {
        let observed_count = self.observed_count;
        let final_score = if self.sum_weights > 0.0 {
            (self.sum_scores / self.sum_weights).clamp(0.0, 1.0)
        } else {
            0.0
        };
        #[allow(clippy::cast_precision_loss)]
        let coverage = if total_checks == 0 {
            1.0
        } else {
            observed_count as f64 / total_checks as f64
        };
        let confidence = coverage.clamp(0.0, 1.0);

        let mut mismatches = self.mismatches;
        if profile.require_http2_observations && observed_count < total_checks {
            mismatches.push("require_http2_observations_unmet".to_string());
        }

        TransportRealismReport {
            profile_name: profile.name.clone(),
            compatibility: TransportCompatibility {
                checks: self.checks,
                score: round4(final_score),
                confidence: round4(confidence),
                coverage: round4(coverage),
                matched_count: self.matched_count,
                total_checks,
                mismatches,
            },
        }
    }
}

/// Score the HTTP/2 SETTINGS frame and push the result onto `state`.
fn score_settings_check(
    profile: &TransportProfile,
    observation: &TransportObservation,
    state: &mut ScoringState,
) {
    let (matched, check_score, observed_count_opt, position_ratio) =
        score_http2_settings(profile, observation);
    let observed = observed_count_opt.is_some();
    if !matched {
        state.push_mismatch(format!(
            "{}: fingerprint mismatch",
            Http2CheckKind::Settings.as_str()
        ));
    }
    state.record(
        Http2CheckResult {
            kind: Http2CheckKind::Settings,
            matched,
            score: check_score,
            observed_count: observed_count_opt.unwrap_or(0),
            expected_count: profile.expected_http2_settings.len(),
            position_match_ratio: position_ratio,
        },
        0.5,
        observed,
        matched,
    );
}

/// Score the HTTP/2 pseudo-header order and push the result.
fn score_pseudo_header_check(
    profile: &TransportProfile,
    observation: &TransportObservation,
    state: &mut ScoringState,
) {
    let Some(observed) = observation.http2_pseudo_header_order.as_deref() else {
        state.push_mismatch(format!(
            "{}: observation missing",
            Http2CheckKind::PseudoHeaderOrder.as_str()
        ));
        state.record(
            Http2CheckResult {
                kind: Http2CheckKind::PseudoHeaderOrder,
                matched: false,
                score: 0.0,
                observed_count: 0,
                expected_count: profile.expected_pseudo_header_order.len(),
                position_match_ratio: 0.0,
            },
            0.2,
            false,
            false,
        );
        return;
    };
    let m = compare_header_order(
        &profile
            .expected_pseudo_header_order
            .iter()
            .map(String::as_str)
            .collect::<Vec<_>>(),
        observed,
    );
    let matched = m.matched_positions == m.reference_length && m.reference_length > 0;
    let position_ratio = m.position_match_ratio();
    if !matched {
        state.push_mismatch(format!(
            "{}: order mismatch ({}/{} matched)",
            Http2CheckKind::PseudoHeaderOrder.as_str(),
            m.matched_positions,
            m.reference_length
        ));
    }
    state.record(
        Http2CheckResult {
            kind: Http2CheckKind::PseudoHeaderOrder,
            matched,
            score: position_ratio,
            observed_count: m.observed_length,
            expected_count: m.reference_length,
            position_match_ratio: position_ratio,
        },
        0.2,
        true,
        matched,
    );
}

/// Score the HTTP/2 regular header order and push the result.
fn score_header_order_check(
    profile: &TransportProfile,
    observation: &TransportObservation,
    state: &mut ScoringState,
) {
    let Some(observed) = observation.http2_header_order.as_deref() else {
        state.push_mismatch(format!(
            "{}: observation missing",
            Http2CheckKind::HeaderOrder.as_str()
        ));
        state.record(
            Http2CheckResult {
                kind: Http2CheckKind::HeaderOrder,
                matched: false,
                score: 0.0,
                observed_count: 0,
                expected_count: profile.expected_header_order.len(),
                position_match_ratio: 0.0,
            },
            0.3,
            false,
            false,
        );
        return;
    };
    let m = compare_header_order(
        &profile
            .expected_header_order
            .iter()
            .map(String::as_str)
            .collect::<Vec<_>>(),
        observed,
    );
    let matched = m.matched_positions == m.reference_length && m.reference_length > 0;
    let position_ratio = m.position_match_ratio();
    if !matched {
        state.push_mismatch(format!(
            "{}: order mismatch ({}/{} matched)",
            Http2CheckKind::HeaderOrder.as_str(),
            m.matched_positions,
            m.reference_length
        ));
    }
    state.record(
        Http2CheckResult {
            kind: Http2CheckKind::HeaderOrder,
            matched,
            score: position_ratio,
            observed_count: m.observed_length,
            expected_count: m.reference_length,
            position_match_ratio: position_ratio,
        },
        0.3,
        true,
        matched,
    );
}

/// Compare an observed HTTP/2 SETTINGS frame against the profile
/// reference and return `(matched, score, observed_count,
/// position_ratio)`.
///
/// The comparison delegates to the same logic
/// [`crate::tls_validation::compare_http2_settings`] uses for
/// matching the JA3 reference SETTINGS — this module reuses the
/// helper rather than duplicating the comparison rules.
fn score_http2_settings(
    profile: &TransportProfile,
    observation: &TransportObservation,
) -> (bool, f64, Option<usize>, f64) {
    let Some(observed) = observation.http2_settings.as_deref() else {
        return (false, 0.0, None, 0.0);
    };
    let (matched, issues) = compare_http2_settings(&profile.expected_http2_settings, observed);
    let position_ratio = if profile.expected_http2_settings.is_empty() {
        1.0
    } else {
        let expected_ids: std::collections::HashSet<u32> = profile
            .expected_http2_settings
            .iter()
            .map(|(id, _)| *id)
            .collect();
        let observed_ids: std::collections::HashSet<u32> =
            observed.iter().map(|(id, _)| *id).collect();
        let intersection = expected_ids.intersection(&observed_ids).count();
        #[allow(clippy::cast_precision_loss)]
        let ratio = intersection as f64 / expected_ids.len() as f64;
        ratio
    };
    let score = if matched {
        1.0
    } else {
        #[allow(clippy::cast_precision_loss)]
        let discount = (issues.len() as f64) * 0.1;
        (1.0 - discount).max(0.0)
    };
    (
        matched,
        round4(score),
        Some(observed.len()),
        round4(position_ratio),
    )
}

/// Round to 4 decimal places to keep JSON serialisation deterministic
/// across platforms (different IEEE-754 implementations can produce
/// different representations of the same f64 otherwise).
fn round4(v: f64) -> f64 {
    (v * 10_000.0).round() / 10_000.0
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::tls_validation::{CHROME_136_HTTP2_SETTINGS, CHROME_136_JA4};
    use crate::transport_realism::observations::{
        HEADER_ORDER_CHROME_136, PSEUDO_HEADER_ORDER_CHROME_136,
    };

    fn chrome_obs() -> TransportObservation {
        TransportObservation::chrome_136_reference()
    }

    fn approx_eq(a: f64, b: f64) -> bool {
        (a - b).abs() < 1e-9
    }

    #[test]
    fn chrome_136_observation_against_chrome_136_profile_scores_high() {
        let profile = TransportProfile::default();
        let report = score(&profile, &chrome_obs());
        assert!(
            report.compatibility.score > 0.95,
            "chrome 136 reference vs chrome 136 observation should be a strong match, got: {}",
            report.compatibility.score
        );
        assert_eq!(report.compatibility.matched_count, 3);
        assert_eq!(report.compatibility.total_checks, 3);
        assert!(report.compatibility.mismatches.is_empty());
        assert!(report.compatibility.is_high_confidence());
        assert!(report.compatibility.is_well_covered());
        assert!(report.is_strong_match());
    }

    #[test]
    fn mismatched_settings_score_below_one() {
        let profile = TransportProfile::default();
        let observed = TransportObservation {
            http2_settings: Some(vec![(1, 1), (2, 0)]),
            ..chrome_obs()
        };
        let report = score(&profile, &observed);
        assert!(
            report.compatibility.score < 1.0,
            "settings mismatch must reduce score, got: {}",
            report.compatibility.score
        );
        assert!(
            report
                .compatibility
                .mismatches
                .iter()
                .any(|m| m.contains(Http2CheckKind::Settings.as_str())),
            "settings mismatch must be reported, got: {:?}",
            report.compatibility.mismatches
        );
    }

    #[test]
    fn mismatched_header_order_reduces_score() {
        let profile = TransportProfile::default();
        let observed = TransportObservation {
            http2_header_order: Some(vec!["host".into(), "accept".into()]),
            ..chrome_obs()
        };
        let report = score(&profile, &observed);
        assert!(report.compatibility.score < 1.0);
        assert!(
            report
                .compatibility
                .mismatches
                .iter()
                .any(|m| m.contains(Http2CheckKind::HeaderOrder.as_str())),
            "header order mismatch must be reported"
        );
    }

    #[test]
    fn missing_http2_observations_uses_known_default_markers() {
        let profile = TransportProfile::default();
        let report = score(&profile, &TransportObservation::default());
        assert!(
            approx_eq(
                report.compatibility.score,
                super::super::DEFAULT_SCORE_WHEN_HTTP2_UNAVAILABLE
            ),
            "score default mismatch, got: {}",
            report.compatibility.score
        );
        assert!(
            approx_eq(
                report.compatibility.confidence,
                super::super::DEFAULT_CONFIDENCE_WHEN_HTTP2_UNAVAILABLE
            ),
            "confidence default mismatch, got: {}",
            report.compatibility.confidence
        );
        assert!(
            approx_eq(
                report.compatibility.coverage,
                super::super::DEFAULT_COVERAGE_WHEN_HTTP2_UNAVAILABLE
            ),
            "coverage default mismatch, got: {}",
            report.compatibility.coverage
        );
        assert!(
            report
                .compatibility
                .mismatches
                .iter()
                .any(|m| m == "http2_observations_unavailable"),
            "missing observations must emit the deterministic mismatch tag, got: {:?}",
            report.compatibility.mismatches
        );
        assert!(!report.is_strong_match());
    }

    #[test]
    fn require_http2_observations_surfaces_partial_observation() {
        let profile = TransportProfile::default().with_require_http2_observations(true);
        let observed = TransportObservation {
            http2_settings: Some(CHROME_136_HTTP2_SETTINGS.to_vec()),
            ..TransportObservation::default()
        };
        let report = score(&profile, &observed);
        assert!(
            report
                .compatibility
                .mismatches
                .iter()
                .any(|m| m == "require_http2_observations_unmet"),
            "partial observation must surface unmet requirement, got: {:?}",
            report.compatibility.mismatches
        );
        assert!(report.compatibility.coverage < 1.0);
    }

    #[test]
    fn profile_with_no_expectations_reports_perfect_score() {
        let profile = TransportProfile::default().with_expectation_bits(0);
        let report = score(&profile, &TransportObservation::default());
        assert!(approx_eq(report.compatibility.score, 1.0));
        assert!(approx_eq(report.compatibility.confidence, 1.0));
        assert!(approx_eq(report.compatibility.coverage, 1.0));
        assert_eq!(report.compatibility.total_checks, 0);
    }

    #[test]
    fn profile_name_is_propagated_to_report() {
        let profile = TransportProfile::default().with_name("firefox-130");
        let report = score(&profile, &chrome_obs());
        assert_eq!(report.profile_name, "firefox-130");
    }

    #[test]
    fn references_used_in_tests_are_stable() {
        // Surface unexpected removal of the references this module
        // depends on as a compile-time test failure.
        assert!(CHROME_136_JA4.starts_with('t'));
        assert!(CHROME_136_HTTP2_SETTINGS.iter().any(|(id, _)| *id == 4));
        assert!(HEADER_ORDER_CHROME_136.contains(&"host"));
        assert!(PSEUDO_HEADER_ORDER_CHROME_136.contains(&":method"));
    }

    #[test]
    fn per_check_kind_results_carry_kind_label() {
        let profile = TransportProfile::default();
        let report = score(&profile, &chrome_obs());
        for result in &report.compatibility.checks {
            assert!(!result.kind.as_str().is_empty());
        }
    }
}