ftui-harness 0.4.0

Test harness and reference fixtures for FrankenTUI.
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
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
#![forbid(unsafe_code)]

//! Render equivalence, replay, and tail-latency gauntlet (bd-40lhe).
//!
//! The standing safety net for render performance work. Every render optimization
//! must pass this gauntlet before graduating to production. The gauntlet integrates:
//!
//! - **Fixture suite** (`fixture_suite`): canonical, challenge, and negative-control workloads
//! - **Render certificates** (`render_certificate`): skip-safety verification
//! - **Presenter equivalence** (`presenter_equivalence`): ANSI output identity checks
//! - **Layout reuse** (`layout_reuse`): cache correctness verification
//! - **Cost surface** (`cost_surface`): stage-level regression detection
//! - **Baseline capture** (`baseline_capture`): latency percentile comparison
//!
//! # Gauntlet structure
//!
//! ```text
//! GauntletSuite
//! ├── EquivalenceGate    — visible output must match baseline
//! ├── ReplayGate         — deterministic replay produces identical checksums
//! ├── TailLatencyGate    — p95/p99 must not regress beyond threshold
//! ├── CertificateGate    — skip decisions must not produce stale frames
//! ├── ChallengeGate      — adversarial fixtures must not crash or corrupt
//! └── NegativeControlGate — no-change fixtures must remain unchanged
//! ```
//!
//! # Usage
//!
//! ```ignore
//! use ftui_harness::render_gauntlet::*;
//!
//! let config = GauntletConfig::default_strict();
//! let suite = GauntletSuite::new(config);
//! let report = suite.run_all();
//! assert!(report.passed(), "gauntlet failed: {}", report.summary());
//! ```

use crate::baseline_capture::FixtureFamily;
use crate::fixture_suite::SuitePartition;

// ============================================================================
// Gauntlet Gates
// ============================================================================

/// Individual gates in the gauntlet, each testing a different correctness property.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum GauntletGate {
    /// Visible output must match baseline (ANSI byte identity or equivalence-class match).
    Equivalence,
    /// Deterministic replay with same seed must produce identical frame checksums.
    Replay,
    /// Tail latency (p95/p99) must not regress beyond configured threshold.
    TailLatency,
    /// Certificate skip decisions must not produce visibly different output.
    Certificate,
    /// Adversarial fixtures must complete without panic, corruption, or resource leak.
    Challenge,
    /// Negative-control fixtures must produce unchanged output.
    NegativeControl,
}

impl GauntletGate {
    #[must_use]
    pub const fn label(&self) -> &'static str {
        match self {
            Self::Equivalence => "equivalence",
            Self::Replay => "replay",
            Self::TailLatency => "tail-latency",
            Self::Certificate => "certificate",
            Self::Challenge => "challenge",
            Self::NegativeControl => "negative-control",
        }
    }

    /// Whether this gate blocks promotion (true) or is informative (false).
    #[must_use]
    pub const fn is_gating(&self) -> bool {
        match self {
            Self::Equivalence => true,
            Self::Replay => true,
            Self::TailLatency => true,
            Self::Certificate => true,
            Self::Challenge => true,
            Self::NegativeControl => true,
        }
    }

    /// Which fixture partitions feed this gate.
    #[must_use]
    pub const fn fixture_partitions(&self) -> &'static [SuitePartition] {
        match self {
            Self::Equivalence => &[SuitePartition::Canonical],
            Self::Replay => &[SuitePartition::Canonical],
            Self::TailLatency => &[SuitePartition::Canonical],
            Self::Certificate => &[SuitePartition::Canonical, SuitePartition::Challenge],
            Self::Challenge => &[SuitePartition::Challenge],
            Self::NegativeControl => &[SuitePartition::NegativeControl],
        }
    }

    /// What failure artifacts this gate produces on failure.
    #[must_use]
    pub const fn failure_artifacts(&self) -> &'static [&'static str] {
        match self {
            Self::Equivalence => &[
                "ansi_diff.txt",
                "baseline_transcript.jsonl",
                "current_transcript.jsonl",
                "mismatch_cell_report.json",
            ],
            Self::Replay => &[
                "replay_checksums.json",
                "divergence_frame_index.json",
                "replay_input_sequence.jsonl",
            ],
            Self::TailLatency => &[
                "latency_histogram.json",
                "p99_regression_detail.json",
                "stage_breakdown.json",
            ],
            Self::Certificate => &[
                "certificate_decision_log.jsonl",
                "shadow_comparison.json",
                "stale_frame_evidence.json",
            ],
            Self::Challenge => &[
                "challenge_results.json",
                "panic_backtrace.txt",
                "resource_leak_report.json",
            ],
            Self::NegativeControl => &[
                "control_diff.json",
                "unexpected_change_cells.json",
            ],
        }
    }

    pub const ALL: &'static [GauntletGate] = &[
        Self::Equivalence,
        Self::Replay,
        Self::TailLatency,
        Self::Certificate,
        Self::Challenge,
        Self::NegativeControl,
    ];
}

// ============================================================================
// Gate Result
// ============================================================================

/// Outcome of a single gate in the gauntlet.
#[derive(Debug, Clone)]
pub struct GateResult {
    /// Which gate was evaluated.
    pub gate: GauntletGate,
    /// Whether the gate passed.
    pub passed: bool,
    /// Number of fixtures tested.
    pub fixtures_tested: u32,
    /// Number of fixtures that passed.
    pub fixtures_passed: u32,
    /// Summary of what was verified.
    pub summary: String,
    /// Failure details (empty if passed).
    pub failures: Vec<GateFailure>,
    /// Wall-clock time for this gate in milliseconds.
    pub duration_ms: u64,
}

impl GateResult {
    /// Create a passing result.
    #[must_use]
    pub fn pass(gate: GauntletGate, fixtures: u32, summary: &str, duration_ms: u64) -> Self {
        Self {
            gate,
            passed: true,
            fixtures_tested: fixtures,
            fixtures_passed: fixtures,
            summary: summary.to_string(),
            failures: Vec::new(),
            duration_ms,
        }
    }

    /// Create a failing result.
    #[must_use]
    pub fn fail(
        gate: GauntletGate,
        fixtures_tested: u32,
        fixtures_passed: u32,
        failures: Vec<GateFailure>,
        duration_ms: u64,
    ) -> Self {
        let summary = format!(
            "{}/{} fixtures passed, {} failure(s)",
            fixtures_passed,
            fixtures_tested,
            failures.len()
        );
        Self {
            gate,
            passed: false,
            fixtures_tested,
            fixtures_passed,
            summary,
            failures,
            duration_ms,
        }
    }
}

/// Details of a single fixture failure within a gate.
#[derive(Debug, Clone)]
pub struct GateFailure {
    /// Fixture that failed.
    pub fixture_id: String,
    /// What went wrong.
    pub reason: String,
    /// Failure category for triage.
    pub category: FailureCategory,
    /// Artifacts produced for diagnosis.
    pub artifacts: Vec<String>,
}

/// Categories of gauntlet failure for triage.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum FailureCategory {
    /// Visible output differs from baseline.
    SemanticRegression,
    /// Logging or metrics are missing or malformed.
    ObservabilityGap,
    /// Optimization only helps curated benchmarks, not challenge fixtures.
    BenchmarkOverfit,
    /// Challenge fixture showed graceful fallback (expected, not a failure).
    ExpectedFallback,
    /// Certificate issued incorrect skip decision.
    StaleCertificate,
    /// Cache returned stale data.
    StaleCache,
    /// Tail latency regressed beyond threshold.
    TailRegression,
    /// Resource leak detected (memory, handles, threads).
    ResourceLeak,
    /// Panic or crash during fixture execution.
    Crash,
}

impl FailureCategory {
    #[must_use]
    pub const fn label(&self) -> &'static str {
        match self {
            Self::SemanticRegression => "semantic-regression",
            Self::ObservabilityGap => "observability-gap",
            Self::BenchmarkOverfit => "benchmark-overfit",
            Self::ExpectedFallback => "expected-fallback",
            Self::StaleCertificate => "stale-certificate",
            Self::StaleCache => "stale-cache",
            Self::TailRegression => "tail-regression",
            Self::ResourceLeak => "resource-leak",
            Self::Crash => "crash",
        }
    }

    /// Whether this category indicates a real problem (vs expected behavior).
    #[must_use]
    pub const fn is_real_failure(&self) -> bool {
        !matches!(self, Self::ExpectedFallback)
    }
}

// ============================================================================
// Gauntlet Configuration
// ============================================================================

/// Configuration for the render gauntlet.
#[derive(Debug, Clone)]
pub struct GauntletConfig {
    /// Maximum allowed p95 regression percentage (e.g., 10.0 = 10%).
    pub p95_regression_threshold_pct: f64,
    /// Maximum allowed p99 regression percentage.
    pub p99_regression_threshold_pct: f64,
    /// Whether to run challenge fixtures.
    pub run_challenges: bool,
    /// Whether to run negative controls.
    pub run_negative_controls: bool,
    /// Whether certificate shadow-run comparison is required.
    pub require_certificate_shadow: bool,
    /// Which fixture family to scope to (None = all render fixtures).
    pub family_filter: Option<FixtureFamily>,
    /// Maximum wall-clock seconds for the entire gauntlet.
    pub timeout_secs: u32,
}

impl GauntletConfig {
    /// Default strict: all gates enabled, 10% p95/p99 threshold.
    #[must_use]
    pub const fn default_strict() -> Self {
        Self {
            p95_regression_threshold_pct: 10.0,
            p99_regression_threshold_pct: 15.0,
            run_challenges: true,
            run_negative_controls: true,
            require_certificate_shadow: true,
            family_filter: None,
            timeout_secs: 300,
        }
    }

    /// Fast mode: skip challenges and shadow runs for quick iteration.
    #[must_use]
    pub const fn fast() -> Self {
        Self {
            p95_regression_threshold_pct: 15.0,
            p99_regression_threshold_pct: 20.0,
            run_challenges: false,
            run_negative_controls: true,
            require_certificate_shadow: false,
            family_filter: None,
            timeout_secs: 60,
        }
    }
}

// ============================================================================
// Gauntlet Suite
// ============================================================================

/// The complete render gauntlet suite.
#[derive(Debug, Clone)]
pub struct GauntletSuite {
    /// Configuration.
    pub config: GauntletConfig,
}

impl GauntletSuite {
    /// Create a new gauntlet suite.
    #[must_use]
    pub fn new(config: GauntletConfig) -> Self {
        Self { config }
    }

    /// Which gates are active given the current configuration.
    #[must_use]
    pub fn active_gates(&self) -> Vec<GauntletGate> {
        let mut gates = vec![
            GauntletGate::Equivalence,
            GauntletGate::Replay,
            GauntletGate::TailLatency,
        ];

        if self.config.require_certificate_shadow {
            gates.push(GauntletGate::Certificate);
        }

        if self.config.run_challenges {
            gates.push(GauntletGate::Challenge);
        }

        if self.config.run_negative_controls {
            gates.push(GauntletGate::NegativeControl);
        }

        gates
    }

    /// Number of active gates.
    #[must_use]
    pub fn gate_count(&self) -> usize {
        self.active_gates().len()
    }
}

// ============================================================================
// Gauntlet Report
// ============================================================================

/// Complete gauntlet execution report.
#[derive(Debug, Clone)]
pub struct GauntletReport {
    /// Per-gate results.
    pub gate_results: Vec<GateResult>,
    /// Total wall-clock time in milliseconds.
    pub total_duration_ms: u64,
    /// Configuration used.
    pub config: GauntletConfig,
}

impl GauntletReport {
    /// Whether all gating gates passed.
    #[must_use]
    pub fn passed(&self) -> bool {
        self.gate_results
            .iter()
            .filter(|r| r.gate.is_gating())
            .all(|r| r.passed)
    }

    /// Number of gates that passed.
    #[must_use]
    pub fn gates_passed(&self) -> usize {
        self.gate_results.iter().filter(|r| r.passed).count()
    }

    /// Number of gates that failed.
    #[must_use]
    pub fn gates_failed(&self) -> usize {
        self.gate_results.iter().filter(|r| !r.passed).count()
    }

    /// All failures across all gates.
    #[must_use]
    pub fn all_failures(&self) -> Vec<&GateFailure> {
        self.gate_results
            .iter()
            .flat_map(|r| r.failures.iter())
            .collect()
    }

    /// Real failures (excluding expected fallback).
    #[must_use]
    pub fn real_failures(&self) -> Vec<&GateFailure> {
        self.all_failures()
            .into_iter()
            .filter(|f| f.category.is_real_failure())
            .collect()
    }

    /// Human-readable summary.
    #[must_use]
    pub fn summary(&self) -> String {
        let status = if self.passed() { "PASSED" } else { "FAILED" };
        let real = self.real_failures().len();
        format!(
            "Gauntlet {}: {}/{} gates passed, {} real failure(s), {}ms",
            status,
            self.gates_passed(),
            self.gate_results.len(),
            real,
            self.total_duration_ms,
        )
    }

    /// Serialize to JSON.
    #[must_use]
    pub fn to_json(&self) -> String {
        let gates: Vec<String> = self
            .gate_results
            .iter()
            .map(|r| {
                let failure_entries: Vec<String> = r
                    .failures
                    .iter()
                    .map(|f| {
                        let arts: Vec<String> =
                            f.artifacts.iter().map(|a| format!("\"{a}\"")).collect();
                        format!(
                            r#"        {{
          "fixture_id": "{}",
          "reason": "{}",
          "category": "{}",
          "artifacts": [{}]
        }}"#,
                            f.fixture_id,
                            f.reason.replace('"', "\\\""),
                            f.category.label(),
                            arts.join(", "),
                        )
                    })
                    .collect();

                format!(
                    r#"    {{
      "gate": "{}",
      "passed": {},
      "fixtures_tested": {},
      "fixtures_passed": {},
      "duration_ms": {},
      "summary": "{}",
      "failures": [
{}
      ]
    }}"#,
                    r.gate.label(),
                    r.passed,
                    r.fixtures_tested,
                    r.fixtures_passed,
                    r.duration_ms,
                    r.summary.replace('"', "\\\""),
                    failure_entries.join(",\n"),
                )
            })
            .collect();

        format!(
            r#"{{
  "schema_version": 1,
  "passed": {},
  "gates_passed": {},
  "gates_failed": {},
  "real_failures": {},
  "total_duration_ms": {},
  "summary": "{}",
  "gates": [
{}
  ]
}}"#,
            self.passed(),
            self.gates_passed(),
            self.gates_failed(),
            self.real_failures().len(),
            self.total_duration_ms,
            self.summary().replace('"', "\\\""),
            gates.join(",\n"),
        )
    }
}

// ============================================================================
// Tests
// ============================================================================

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn all_gates_labeled() {
        for gate in GauntletGate::ALL {
            assert!(!gate.label().is_empty());
            assert!(!gate.failure_artifacts().is_empty());
        }
        assert_eq!(GauntletGate::ALL.len(), 6);
    }

    #[test]
    fn all_gates_are_gating() {
        for gate in GauntletGate::ALL {
            assert!(gate.is_gating(), "{} should be gating", gate.label());
        }
    }

    #[test]
    fn gates_have_fixture_partitions() {
        for gate in GauntletGate::ALL {
            assert!(
                !gate.fixture_partitions().is_empty(),
                "{} has no fixture partitions",
                gate.label()
            );
        }
    }

    #[test]
    fn challenge_gate_uses_challenge_partition() {
        let partitions = GauntletGate::Challenge.fixture_partitions();
        assert!(partitions.contains(&SuitePartition::Challenge));
    }

    #[test]
    fn negative_control_gate_uses_negative_partition() {
        let partitions = GauntletGate::NegativeControl.fixture_partitions();
        assert!(partitions.contains(&SuitePartition::NegativeControl));
    }

    #[test]
    fn default_strict_config() {
        let config = GauntletConfig::default_strict();
        assert!((config.p95_regression_threshold_pct - 10.0).abs() < 0.01);
        assert!(config.run_challenges);
        assert!(config.run_negative_controls);
        assert!(config.require_certificate_shadow);
    }

    #[test]
    fn fast_config_skips_challenges() {
        let config = GauntletConfig::fast();
        assert!(!config.run_challenges);
        assert!(!config.require_certificate_shadow);
    }

    #[test]
    fn strict_suite_has_all_gates() {
        let suite = GauntletSuite::new(GauntletConfig::default_strict());
        assert_eq!(suite.gate_count(), 6);
    }

    #[test]
    fn fast_suite_has_fewer_gates() {
        let suite = GauntletSuite::new(GauntletConfig::fast());
        assert!(suite.gate_count() < 6);
        assert!(suite.gate_count() >= 3); // equivalence, replay, tail-latency always active
    }

    #[test]
    fn passing_report() {
        let report = GauntletReport {
            gate_results: vec![
                GateResult::pass(GauntletGate::Equivalence, 4, "All equivalent", 100),
                GateResult::pass(GauntletGate::Replay, 4, "All deterministic", 200),
            ],
            total_duration_ms: 300,
            config: GauntletConfig::default_strict(),
        };
        assert!(report.passed());
        assert_eq!(report.gates_passed(), 2);
        assert_eq!(report.gates_failed(), 0);
        assert!(report.all_failures().is_empty());
        assert!(report.summary().contains("PASSED"));
    }

    #[test]
    fn failing_report() {
        let report = GauntletReport {
            gate_results: vec![
                GateResult::pass(GauntletGate::Equivalence, 4, "OK", 100),
                GateResult::fail(
                    GauntletGate::TailLatency,
                    4,
                    3,
                    vec![GateFailure {
                        fixture_id: "render_pipeline_full_200x60".to_string(),
                        reason: "p99 regressed 25% (threshold 15%)".to_string(),
                        category: FailureCategory::TailRegression,
                        artifacts: vec!["latency_histogram.json".to_string()],
                    }],
                    200,
                ),
            ],
            total_duration_ms: 300,
            config: GauntletConfig::default_strict(),
        };
        assert!(!report.passed());
        assert_eq!(report.gates_failed(), 1);
        assert_eq!(report.real_failures().len(), 1);
        assert!(report.summary().contains("FAILED"));
    }

    #[test]
    fn expected_fallback_not_real_failure() {
        let failure = GateFailure {
            fixture_id: "challenge_resize_storm".to_string(),
            reason: "Fell back to full render under resize storm".to_string(),
            category: FailureCategory::ExpectedFallback,
            artifacts: vec![],
        };
        assert!(!failure.category.is_real_failure());
    }

    #[test]
    fn failure_categories_labeled() {
        for cat in [
            FailureCategory::SemanticRegression,
            FailureCategory::ObservabilityGap,
            FailureCategory::BenchmarkOverfit,
            FailureCategory::ExpectedFallback,
            FailureCategory::StaleCertificate,
            FailureCategory::StaleCache,
            FailureCategory::TailRegression,
            FailureCategory::ResourceLeak,
            FailureCategory::Crash,
        ] {
            assert!(!cat.label().is_empty());
        }
    }

    #[test]
    fn only_expected_fallback_is_not_real() {
        for cat in [
            FailureCategory::SemanticRegression,
            FailureCategory::ObservabilityGap,
            FailureCategory::BenchmarkOverfit,
            FailureCategory::StaleCertificate,
            FailureCategory::StaleCache,
            FailureCategory::TailRegression,
            FailureCategory::ResourceLeak,
            FailureCategory::Crash,
        ] {
            assert!(cat.is_real_failure(), "{} should be a real failure", cat.label());
        }
        assert!(!FailureCategory::ExpectedFallback.is_real_failure());
    }

    #[test]
    fn report_to_json_valid() {
        let report = GauntletReport {
            gate_results: vec![GateResult::pass(
                GauntletGate::Equivalence,
                3,
                "All OK",
                50,
            )],
            total_duration_ms: 50,
            config: GauntletConfig::default_strict(),
        };
        let json = report.to_json();
        assert!(json.contains("\"schema_version\": 1"));
        assert!(json.contains("\"passed\": true"));
        assert!(json.contains("\"gates_passed\": 1"));
        assert!(json.contains("\"gate\": \"equivalence\""));
    }

    #[test]
    fn report_json_with_failures() {
        let report = GauntletReport {
            gate_results: vec![GateResult::fail(
                GauntletGate::Certificate,
                2,
                1,
                vec![GateFailure {
                    fixture_id: "test".to_string(),
                    reason: "stale frame".to_string(),
                    category: FailureCategory::StaleCertificate,
                    artifacts: vec!["shadow.json".to_string()],
                }],
                100,
            )],
            total_duration_ms: 100,
            config: GauntletConfig::default_strict(),
        };
        let json = report.to_json();
        assert!(json.contains("\"passed\": false"));
        assert!(json.contains("\"stale-certificate\""));
        assert!(json.contains("\"shadow.json\""));
    }

    #[test]
    fn gate_result_pass_constructor() {
        let r = GateResult::pass(GauntletGate::Replay, 5, "All good", 42);
        assert!(r.passed);
        assert_eq!(r.fixtures_tested, 5);
        assert_eq!(r.fixtures_passed, 5);
        assert_eq!(r.duration_ms, 42);
        assert!(r.failures.is_empty());
    }

    #[test]
    fn gate_result_fail_constructor() {
        let r = GateResult::fail(GauntletGate::TailLatency, 5, 3, vec![], 100);
        assert!(!r.passed);
        assert_eq!(r.fixtures_tested, 5);
        assert_eq!(r.fixtures_passed, 3);
        assert!(r.summary.contains("3/5"));
    }
}