trustformers-core 0.2.1

Core traits and utilities for TrustformeRS
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
// Copyright (c) 2025-2026 COOLJAPAN OU (Team KitaSan)
// SPDX-License-Identifier: Apache-2.0

//! Hardware monitoring and health checking components
//!
//! This module provides performance monitoring, anomaly detection, and health checking
//! capabilities for hardware devices in the TrustformeRS ecosystem.

use super::config::OperationStats;
use super::{HardwareMetrics, HardwareResult};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::time::{Duration, Instant, SystemTime};

/// Performance monitor for tracking hardware metrics and efficiency
#[derive(Debug, Clone)]
pub struct PerformanceMonitor {
    /// Performance history for each device
    pub history: HashMap<String, Vec<(SystemTime, HardwareMetrics)>>,
    /// Operation statistics per device
    pub operation_stats: HashMap<String, OperationStats>,
    /// Device efficiency scores
    pub efficiency_scores: HashMap<String, f64>,
    /// Anomaly detector instance
    pub anomaly_detector: AnomalyDetector,
}

/// Anomaly detector for identifying unusual hardware behavior
#[derive(Debug, Clone)]
pub struct AnomalyDetector {
    /// Anomaly detection thresholds
    pub thresholds: HashMap<String, f64>,
    /// Detected anomalies history
    pub anomalies: Vec<Anomaly>,
    /// Active detection algorithms
    pub algorithms: Vec<AnomalyAlgorithm>,
}

/// Anomaly information
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Anomaly {
    /// Device ID where anomaly was detected
    pub device_id: String,
    /// Type of anomaly
    pub anomaly_type: AnomalyType,
    /// Severity level
    pub severity: AnomalySeverity,
    /// Detection timestamp
    pub timestamp: SystemTime,
    /// Anomaly score (0.0 - 1.0)
    pub score: f64,
    /// Additional details
    pub details: String,
    /// Affected metrics
    pub affected_metrics: Vec<String>,
}

/// Types of hardware anomalies
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AnomalyType {
    /// High latency detected
    HighLatency,
    /// Low throughput detected
    LowThroughput,
    /// High memory usage detected
    HighMemoryUsage,
    /// High temperature detected
    HighTemperature,
    /// High power consumption detected
    HighPowerConsumption,
    /// Frequent errors detected
    FrequentErrors,
    /// Device unavailable
    DeviceUnavailable,
    /// Performance degradation detected
    PerformanceDegradation,
}

/// Anomaly severity levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AnomalySeverity {
    /// Low severity - informational
    Low,
    /// Medium severity - attention needed
    Medium,
    /// High severity - action required
    High,
    /// Critical severity - immediate action required
    Critical,
}

/// Anomaly detection algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AnomalyAlgorithm {
    /// Statistical outlier detection
    StatisticalOutlier,
    /// Moving average based detection
    MovingAverage,
    /// Exponential smoothing
    ExponentialSmoothing,
    /// Isolation forest algorithm
    IsolationForest,
    /// One-class SVM
    OneClassSVM,
    /// LSTM autoencoder
    LSTMAutoencoder,
}

/// Health checker for device health monitoring
#[derive(Debug, Clone)]
pub struct HealthChecker {
    /// Health check results per device
    pub results: HashMap<String, HealthCheckResult>,
    /// Health check schedules per device
    pub schedule: HashMap<String, Duration>,
    /// Health check policies per device
    pub policies: HashMap<String, HealthCheckPolicy>,
}

/// Health check result
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HealthCheckResult {
    /// Device ID
    pub device_id: String,
    /// Overall health status
    pub status: HealthStatus,
    /// Check timestamp
    pub timestamp: SystemTime,
    /// Response time in milliseconds
    pub response_time: f64,
    /// Health score (0.0 = unhealthy, 1.0 = perfect health)
    pub health_score: f64,
    /// Issues found during check
    pub issues: Vec<HealthIssue>,
    /// Recommendations for improvement
    pub recommendations: Vec<String>,
}

/// Health status enumeration
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum HealthStatus {
    /// Device is healthy
    Healthy,
    /// Device has warnings
    Warning,
    /// Device has critical issues
    Critical,
    /// Device is unhealthy
    Unhealthy,
    /// Health status unknown
    Unknown,
}

/// Health issue details
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HealthIssue {
    /// Type of issue
    pub issue_type: HealthIssueType,
    /// Issue severity
    pub severity: AnomalySeverity,
    /// Human-readable description
    pub description: String,
    /// Components affected by this issue
    pub affected_components: Vec<String>,
    /// Potential root causes
    pub potential_causes: Vec<String>,
    /// Suggested fixes
    pub suggested_fixes: Vec<String>,
}

/// Types of health issues
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum HealthIssueType {
    /// Performance degradation
    PerformanceDegradation,
    /// Memory leak detected
    MemoryLeak,
    /// High temperature
    HighTemperature,
    /// Power-related issues
    PowerIssues,
    /// Communication errors
    CommunicationErrors,
    /// Driver issues
    DriverIssues,
    /// Hardware faults
    HardwareFaults,
    /// Configuration issues
    ConfigurationIssues,
}

/// Health check policy configuration
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HealthCheckPolicy {
    /// Check interval
    pub interval: Duration,
    /// Timeout for health checks
    pub timeout: Duration,
    /// Number of retries on failure
    pub retry_count: u32,
    /// Failure threshold before marking unhealthy
    pub failure_threshold: u32,
    /// Recovery threshold before marking healthy
    pub recovery_threshold: u32,
    /// Enable detailed diagnostics
    pub detailed_diagnostics: bool,
}

impl PerformanceMonitor {
    /// Create a new performance monitor
    pub fn new() -> Self {
        Self {
            history: HashMap::new(),
            operation_stats: HashMap::new(),
            efficiency_scores: HashMap::new(),
            anomaly_detector: AnomalyDetector::new(),
        }
    }

    /// Update metrics for a device
    pub fn update_metrics(&mut self, device_id: &str, metrics: &HardwareMetrics) {
        let entry = self.history.entry(device_id.to_string()).or_default();
        entry.push((SystemTime::now(), metrics.clone()));

        // Keep only last 1000 entries to prevent memory growth
        if entry.len() > 1000 {
            entry.drain(..500);
        }

        // Update anomaly detector
        self.anomaly_detector.check_anomalies(device_id, metrics);
    }

    /// Analyze performance for all devices
    pub fn analyze_performance(&mut self, device_metrics: &HashMap<String, HardwareMetrics>) {
        for (device_id, metrics) in device_metrics {
            let efficiency = self.calculate_efficiency_score(metrics);
            self.efficiency_scores.insert(device_id.clone(), efficiency);
        }
    }

    /// Calculate efficiency score for a device
    pub fn calculate_efficiency_score(&self, metrics: &HardwareMetrics) -> f64 {
        // Calculate utilization score (higher is better)
        let utilization_score = (metrics.utilization / 100.0).min(1.0);

        // Calculate latency score (lower is better)
        let latency_score = (1.0 / (1.0 + metrics.latency / 100.0)).min(1.0);

        // Calculate throughput score (higher is better, normalized)
        let throughput_score = (metrics.throughput / 1000.0).min(1.0);

        // Weighted average
        utilization_score * 0.4 + latency_score * 0.3 + throughput_score * 0.3
    }

    /// Get top performing devices
    pub fn get_top_performers(&self, count: usize) -> Vec<(String, f64)> {
        let mut performers: Vec<_> =
            self.efficiency_scores.iter().map(|(id, score)| (id.clone(), *score)).collect();

        performers.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(::std::cmp::Ordering::Equal));
        performers.truncate(count);
        performers
    }
}

impl AnomalyDetector {
    /// Create a new anomaly detector
    pub fn new() -> Self {
        Self {
            thresholds: [
                ("high_latency".to_string(), 100.0),
                ("low_throughput".to_string(), 10.0),
                ("high_temperature".to_string(), 80.0),
                ("high_power".to_string(), 200.0),
                ("high_utilization".to_string(), 95.0),
            ]
            .into(),
            anomalies: Vec::new(),
            algorithms: vec![
                AnomalyAlgorithm::StatisticalOutlier,
                AnomalyAlgorithm::MovingAverage,
            ],
        }
    }

    /// Check for anomalies in device metrics
    pub fn check_anomalies(&mut self, device_id: &str, metrics: &HardwareMetrics) {
        // Check for high latency
        if metrics.latency > *self.thresholds.get("high_latency").unwrap_or(&100.0) {
            self.add_anomaly(
                device_id,
                AnomalyType::HighLatency,
                AnomalySeverity::High,
                metrics.latency / 100.0,
                "Latency exceeds threshold",
            );
        }

        // Check for low throughput
        if metrics.throughput < *self.thresholds.get("low_throughput").unwrap_or(&10.0) {
            self.add_anomaly(
                device_id,
                AnomalyType::LowThroughput,
                AnomalySeverity::Medium,
                1.0 - (metrics.throughput / 100.0),
                "Throughput below threshold",
            );
        }

        // Check for high temperature
        if let Some(temp) = metrics.temperature {
            if temp > *self.thresholds.get("high_temperature").unwrap_or(&80.0) {
                self.add_anomaly(
                    device_id,
                    AnomalyType::HighTemperature,
                    AnomalySeverity::Critical,
                    temp / 100.0,
                    "Temperature exceeds safe limits",
                );
            }
        }

        // Check for high power consumption
        if metrics.power_consumption > *self.thresholds.get("high_power").unwrap_or(&200.0) {
            self.add_anomaly(
                device_id,
                AnomalyType::HighPowerConsumption,
                AnomalySeverity::Medium,
                metrics.power_consumption / 300.0,
                "Power consumption is high",
            );
        }

        // Check for high utilization
        if metrics.utilization > *self.thresholds.get("high_utilization").unwrap_or(&95.0) {
            self.add_anomaly(
                device_id,
                AnomalyType::HighMemoryUsage,
                AnomalySeverity::Low,
                metrics.utilization / 100.0,
                "Utilization is very high",
            );
        }

        // Trim old anomalies to prevent memory growth
        if self.anomalies.len() > 1000 {
            self.anomalies.drain(..500);
        }
    }

    /// Add a new anomaly
    fn add_anomaly(
        &mut self,
        device_id: &str,
        anomaly_type: AnomalyType,
        severity: AnomalySeverity,
        score: f64,
        details: &str,
    ) {
        let anomaly = Anomaly {
            device_id: device_id.to_string(),
            anomaly_type,
            severity,
            timestamp: SystemTime::now(),
            score,
            details: details.to_string(),
            affected_metrics: vec!["latency".to_string(), "throughput".to_string()],
        };
        self.anomalies.push(anomaly);
    }

    /// Get recent anomalies for a device
    pub fn get_recent_anomalies(&self, device_id: &str, duration: Duration) -> Vec<&Anomaly> {
        let threshold = SystemTime::now() - duration;
        self.anomalies
            .iter()
            .filter(|a| a.device_id == device_id && a.timestamp >= threshold)
            .collect()
    }
}

impl HealthChecker {
    /// Create a new health checker
    pub fn new() -> Self {
        Self {
            results: HashMap::new(),
            schedule: HashMap::new(),
            policies: HashMap::new(),
        }
    }

    /// Perform a real health check on a device from its current metrics.
    ///
    /// `metrics` should be the device's live `HardwareMetrics` (e.g. from
    /// `HardwareManager::get_device_metrics`). This diagnoses the real
    /// thermal, error-rate and utilization signals already carried on
    /// `HardwareMetrics` against fixed safety thresholds, rather than
    /// fabricating a constant 0.95/`Healthy` verdict regardless of device
    /// state. When no live telemetry is available for the device
    /// (`metrics` is `None`), the honest result is `HealthStatus::Unknown`
    /// -- a monitoring API must not report a device it cannot see as
    /// healthy.
    pub async fn check_device(
        &mut self,
        device_id: &str,
        metrics: Option<&HardwareMetrics>,
    ) -> HardwareResult<()> {
        let start_time = Instant::now();

        let (status, health_score, issues, recommendations) = match metrics {
            None => (
                HealthStatus::Unknown,
                0.0,
                Vec::new(),
                vec!["No telemetry available for this device".to_string()],
            ),
            Some(metrics) => Self::diagnose(metrics),
        };

        let result = HealthCheckResult {
            device_id: device_id.to_string(),
            status,
            timestamp: SystemTime::now(),
            response_time: start_time.elapsed().as_millis() as f64,
            health_score,
            issues,
            recommendations,
        };

        self.results.insert(device_id.to_string(), result);
        Ok(())
    }

    /// Threshold-based diagnosis of a real `HardwareMetrics` snapshot.
    /// Fixed, documented thresholds stand in for a device-specific policy
    /// until `HealthCheckPolicy` grows dedicated threshold fields; they are
    /// applied to the same real numbers `PerformanceMonitor` records, not
    /// to invented data.
    fn diagnose(metrics: &HardwareMetrics) -> (HealthStatus, f64, Vec<HealthIssue>, Vec<String>) {
        const TEMP_WARNING_C: f64 = 80.0;
        const TEMP_CRITICAL_C: f64 = 90.0;
        const ERROR_RATE_WARNING: f64 = 0.01;
        const ERROR_RATE_CRITICAL: f64 = 0.05;
        const UTILIZATION_SATURATED: f64 = 95.0;

        let mut issues = Vec::new();
        let mut recommendations = Vec::new();
        let mut score = 1.0f64;

        if let Some(temp) = metrics.temperature {
            if temp >= TEMP_CRITICAL_C {
                score -= 0.5;
                issues.push(HealthIssue {
                    issue_type: HealthIssueType::HighTemperature,
                    severity: AnomalySeverity::Critical,
                    description: format!(
                        "Temperature {temp:.1}\u{b0}C is at or above the critical threshold \
                         of {TEMP_CRITICAL_C:.1}\u{b0}C"
                    ),
                    affected_components: vec!["thermal".to_string()],
                    potential_causes: vec![
                        "Inadequate cooling".to_string(),
                        "Sustained heavy load".to_string(),
                    ],
                    suggested_fixes: vec![
                        "Reduce load immediately".to_string(),
                        "Improve cooling".to_string(),
                    ],
                });
                recommendations.push("Reduce load or improve cooling immediately".to_string());
            } else if temp >= TEMP_WARNING_C {
                score -= 0.2;
                issues.push(HealthIssue {
                    issue_type: HealthIssueType::HighTemperature,
                    severity: AnomalySeverity::Medium,
                    description: format!(
                        "Temperature {temp:.1}\u{b0}C is at or above the warning threshold \
                         of {TEMP_WARNING_C:.1}\u{b0}C"
                    ),
                    affected_components: vec!["thermal".to_string()],
                    potential_causes: vec!["Sustained heavy load".to_string()],
                    suggested_fixes: vec!["Monitor temperature".to_string()],
                });
                recommendations.push("Monitor temperature".to_string());
            }
        }

        if metrics.error_rate >= ERROR_RATE_CRITICAL {
            score -= 0.5;
            issues.push(HealthIssue {
                issue_type: HealthIssueType::HardwareFaults,
                severity: AnomalySeverity::Critical,
                description: format!(
                    "Error rate {:.4} is at or above the critical threshold of {ERROR_RATE_CRITICAL:.4}",
                    metrics.error_rate
                ),
                affected_components: vec!["compute".to_string()],
                potential_causes: vec![
                    "Hardware fault".to_string(),
                    "Driver instability".to_string(),
                ],
                suggested_fixes: vec![
                    "Reset the device".to_string(),
                    "Inspect driver logs".to_string(),
                ],
            });
            recommendations.push("Investigate elevated error rate".to_string());
        } else if metrics.error_rate >= ERROR_RATE_WARNING {
            score -= 0.15;
            issues.push(HealthIssue {
                issue_type: HealthIssueType::HardwareFaults,
                severity: AnomalySeverity::Medium,
                description: format!(
                    "Error rate {:.4} is at or above the warning threshold of {ERROR_RATE_WARNING:.4}",
                    metrics.error_rate
                ),
                affected_components: vec!["compute".to_string()],
                potential_causes: vec!["Transient faults".to_string()],
                suggested_fixes: vec!["Continue monitoring error rate".to_string()],
            });
            recommendations.push("Continue monitoring error rate".to_string());
        }

        if metrics.utilization >= UTILIZATION_SATURATED {
            recommendations
                .push("Utilization is near saturation; consider load balancing".to_string());
        }

        let score = score.clamp(0.0, 1.0);
        let status = if issues.iter().any(|i| i.severity == AnomalySeverity::Critical) {
            HealthStatus::Critical
        } else if !issues.is_empty() {
            HealthStatus::Warning
        } else {
            HealthStatus::Healthy
        };

        if recommendations.is_empty() {
            recommendations.push("No action required".to_string());
        }

        (status, score, issues, recommendations)
    }

    /// Get health status for a device
    pub fn get_health_status(&self, device_id: &str) -> Option<HealthStatus> {
        self.results.get(device_id).map(|result| result.status)
    }

    /// Set health check policy for a device
    pub fn set_policy(&mut self, device_id: &str, policy: HealthCheckPolicy) {
        self.policies.insert(device_id.to_string(), policy);
    }

    /// Get health check results for all devices
    pub fn get_all_results(&self) -> &HashMap<String, HealthCheckResult> {
        &self.results
    }
}

impl Default for HealthCheckPolicy {
    fn default() -> Self {
        Self {
            interval: Duration::from_secs(60),
            timeout: Duration::from_secs(10),
            retry_count: 3,
            failure_threshold: 3,
            recovery_threshold: 2,
            detailed_diagnostics: true,
        }
    }
}

impl Default for PerformanceMonitor {
    fn default() -> Self {
        Self::new()
    }
}

impl Default for AnomalyDetector {
    fn default() -> Self {
        Self::new()
    }
}

impl Default for HealthChecker {
    fn default() -> Self {
        Self::new()
    }
}

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

    fn healthy_metrics() -> HardwareMetrics {
        HardwareMetrics {
            ops_per_second: 1_000_000.0,
            memory_bandwidth: 10e9,
            utilization: 20.0,
            power_consumption: 65.0,
            temperature: Some(45.0),
            error_rate: 0.0,
            latency: 1.0,
            throughput: 1000.0,
        }
    }

    /// Regression test: `check_device` used to always insert a hardcoded
    /// `health_score = 0.95` / `HealthStatus::Healthy` result regardless of
    /// device state -- a monitoring API that could never detect a fault.
    /// With normal metrics the device really is healthy, so this alone does
    /// not distinguish old from new behavior; the overheating/error-rate
    /// tests below do.
    #[tokio::test]
    async fn test_check_device_reports_healthy_for_normal_metrics() {
        let mut checker = HealthChecker::new();
        checker
            .check_device("dev0", Some(&healthy_metrics()))
            .await
            .expect("check failed");

        let result = checker.get_all_results().get("dev0").expect("missing result");
        assert_eq!(result.status, HealthStatus::Healthy);
        assert!(result.issues.is_empty());
    }

    /// Regression test: an overheating device must be flagged, not silently
    /// reported healthy with a fixed 0.95 score.
    #[tokio::test]
    async fn test_check_device_flags_critical_temperature() {
        let mut checker = HealthChecker::new();
        let mut metrics = healthy_metrics();
        metrics.temperature = Some(95.0); // above the 90C critical threshold

        checker.check_device("hot-dev", Some(&metrics)).await.expect("check failed");

        let result = checker.get_all_results().get("hot-dev").expect("missing result");
        assert_eq!(result.status, HealthStatus::Critical);
        assert!(!result.issues.is_empty());
        assert!(
            result.health_score < 0.95,
            "score must reflect the fault, not stay at 0.95"
        );
        assert_eq!(
            checker.get_health_status("hot-dev"),
            Some(HealthStatus::Critical)
        );
    }

    /// Regression test: an elevated error rate must be flagged as a
    /// warning, not silently reported healthy.
    #[tokio::test]
    async fn test_check_device_flags_elevated_error_rate() {
        let mut checker = HealthChecker::new();
        let mut metrics = healthy_metrics();
        metrics.error_rate = 0.02; // above the 0.01 warning threshold

        checker.check_device("flaky-dev", Some(&metrics)).await.expect("check failed");

        let result = checker.get_all_results().get("flaky-dev").expect("missing result");
        assert_eq!(result.status, HealthStatus::Warning);
        assert!(!result.issues.is_empty());
    }

    /// Regression test: a device with no telemetry must be reported
    /// `Unknown`, never fabricated as `Healthy`.
    #[tokio::test]
    async fn test_check_device_without_metrics_is_unknown() {
        let mut checker = HealthChecker::new();
        checker.check_device("ghost-dev", None).await.expect("check failed");

        assert_eq!(
            checker.get_health_status("ghost-dev"),
            Some(HealthStatus::Unknown)
        );
    }
}