lcpfs 2026.1.102

LCP File System - A ZFS-inspired copy-on-write filesystem for Rust
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
// Copyright 2025 LunaOS Contributors
// SPDX-License-Identifier: Apache-2.0

//! Metrics collection and storage
//!
//! This module integrates with real LCPFS subsystems to collect accurate
//! metrics for storage analytics.

use alloc::collections::BTreeMap;
use alloc::string::{String, ToString};
use alloc::vec::Vec;

use super::types::*;
use crate::cache::arc::ARC;
use crate::dedup::fastdedup::FastDedupEngine;
use crate::storage::zpl::ZPL;
use crate::time;

/// Maximum data points to keep per metric
const MAX_DATA_POINTS: usize = 8640; // 1 week at 1-minute intervals

/// Analytics collector
pub struct AnalyticsCollector {
    /// Per-dataset metrics
    datasets: BTreeMap<String, DatasetMetrics>,
}

/// Metrics for a single dataset
struct DatasetMetrics {
    /// Usage summary cache
    usage: UsageSummary,
    /// I/O statistics
    io: IoStats,
    /// Historical data points
    history: BTreeMap<MetricType, Vec<TrendPoint>>,
    /// Last update timestamp
    last_update: u64,
}

impl AnalyticsCollector {
    /// Create a new analytics collector
    pub fn new() -> Self {
        Self {
            datasets: BTreeMap::new(),
        }
    }

    /// Get or create dataset metrics
    fn get_or_create_dataset(&mut self, dataset: &str) -> &mut DatasetMetrics {
        // Use entry API to avoid separate contains_key + get_mut + unwrap pattern
        self.datasets
            .entry(dataset.to_string())
            .or_insert_with(|| DatasetMetrics {
                usage: UsageSummary::default(),
                io: IoStats::default(),
                history: BTreeMap::new(),
                last_update: 0,
            })
    }

    /// Record a metric value
    pub fn record_metric(&mut self, dataset: &str, metric: MetricType, value: u64) {
        let ds = self.get_or_create_dataset(dataset);

        // Get current timestamp from time subsystem
        let timestamp = time::now();
        ds.last_update = timestamp;

        let history = ds.history.entry(metric).or_default();

        // Add data point
        history.push(TrendPoint { timestamp, value });

        // Trim old data points
        if history.len() > MAX_DATA_POINTS {
            history.remove(0);
        }

        // Update live stats based on metric type
        match metric {
            MetricType::UsedSpace => ds.usage.used_space = value,
            MetricType::FreeSpace => ds.usage.free_space = value,
            MetricType::FileCount => ds.usage.file_count = value,
            MetricType::ReadIops => ds.io.read_ops = value,
            MetricType::WriteIops => ds.io.write_ops = value,
            MetricType::ReadThroughput => ds.io.read_throughput = value,
            MetricType::WriteThroughput => ds.io.write_throughput = value,
            MetricType::CacheHitRate => ds.io.cache_hit_rate = value as f32 / 100.0,
            _ => {}
        }
    }

    /// Get usage summary with data from real filesystem
    pub fn get_usage_summary(&self, dataset: &str) -> Result<UsageSummary, AnalyticsError> {
        let ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        // Get real data from ZPL
        let zpl = ZPL.lock();
        let used_space = zpl.used_bytes();
        let quota = zpl.quota();

        // Calculate real values
        let total_capacity = if quota > 0 { quota } else { u64::MAX };
        let free_space = total_capacity.saturating_sub(used_space);
        let usage_percent = if total_capacity > 0 && total_capacity != u64::MAX {
            (used_space as f32 / total_capacity as f32) * 100.0
        } else {
            0.0
        };

        // Get dedup/compression stats for reduction ratio
        drop(zpl); // Release ZPL lock before getting other stats

        let (hits, misses, _entries, _evictions, _hit_rate) = FastDedupEngine::get_stats();

        // Calculate dedup ratio from hits vs total
        // Dedup ratio = logical_size / physical_size
        // If all blocks are duplicates (hits == total_ops), physical size would be ~0
        // We avoid division by zero by checking that misses > 0
        let total_ops = hits + misses;
        let dedup_ratio = if total_ops > 0 && misses > 0 {
            // Ratio of total blocks to unique blocks (misses are unique, hits are duplicates)
            (total_ops as f64 / misses as f64) as f32
        } else if total_ops > 0 && misses == 0 {
            // All hits, infinite dedup ratio - cap at reasonable maximum
            100.0
        } else {
            // No operations yet
            1.0
        };

        // For now, assume 1.0 compression ratio (GPU compress may not be enabled)
        let compress_ratio = 1.0f32;

        // Combined reduction ratio
        let reduction_ratio = dedup_ratio * compress_ratio;

        Ok(UsageSummary {
            total_capacity,
            used_space,
            free_space,
            usage_percent,
            file_count: ds.usage.file_count,
            directory_count: ds.usage.directory_count,
            snapshot_count: ds.usage.snapshot_count,
            logical_size: used_space,
            physical_size: (used_space as f32 / reduction_ratio.max(1.0)) as u64,
            reduction_ratio,
        })
    }

    /// Get space breakdown with real data from subsystems
    pub fn get_space_breakdown(&self, dataset: &str) -> Result<SpaceBreakdown, AnalyticsError> {
        use crate::dedup::dedup::DDT;
        use crate::util::alloc::METASLAB;

        let ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        let total_used = ds.usage.used_space;
        let free_space = ds.usage.free_space;

        // Get real dedup table size from DDT
        let ddt = DDT.lock();
        let ddt_entries = ddt.table.len() as u64;
        drop(ddt);
        // Each DDT entry is approximately 48 bytes (32-byte hash + 16-byte DVA/metadata)
        let dedup_table_space = ddt_entries * 48;

        // Get allocator metadata overhead from METASLAB
        let metaslab = METASLAB.lock();
        let total_capacity = metaslab.total_capacity;
        let total_free = metaslab.total_free;
        drop(metaslab);

        // Calculate metadata space (approximately 1 dnode per 128KB of data)
        // DnodePhys is ~512 bytes, so metadata overhead is roughly data_size / 128KB * 512
        let estimated_objects = total_used / (128 * 1024);
        let metadata_space = estimated_objects * 512;

        // Snapshot space comes from the dataset's snapshot count and average snap size
        // Each snapshot initially shares all blocks (COW), so unique space is minimal
        let snapshot_count = ds.usage.snapshot_count;
        // Estimate 1% of used space per snapshot for unique blocks
        let snapshot_space = (total_used / 100) * snapshot_count;

        // Index space for ZAP tables (directory entries)
        // Estimate 64 bytes per directory entry
        let index_space = ds.usage.directory_count * 64;

        // Reserved space is typically 3.2% (like ZFS slop space)
        let reserved_space = total_capacity / 32; // ~3.125%

        // Data space is what remains after overhead
        let overhead = metadata_space + dedup_table_space + index_space + reserved_space;
        let data_space = total_used.saturating_sub(overhead);

        // Reclaimable space from freed but not yet reclaimed blocks
        let reclaimable_space = if total_capacity > total_used + total_free {
            total_capacity - total_used - total_free
        } else {
            0
        };

        Ok(SpaceBreakdown {
            data_space,
            metadata_space,
            snapshot_space,
            dedup_table_space,
            index_space,
            reserved_space,
            free_space,
            reclaimable_space,
        })
    }

    /// Get I/O statistics with real cache hit rate from ARC
    pub fn get_io_stats(&self, dataset: &str) -> Result<IoStats, AnalyticsError> {
        let ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        // Get real cache stats from ARC
        let arc = ARC.lock();
        let (hits, misses, hit_rate, _cache_size) = arc.stats();
        drop(arc);

        // Combine with stored I/O stats
        let mut io = ds.io.clone();
        io.cache_hit_rate = hit_rate as f32;
        io.read_ops = hits + misses; // Total cache operations as proxy for reads

        Ok(io)
    }

    /// Forecast capacity
    pub fn forecast_capacity(
        &self,
        dataset: &str,
        days: u32,
    ) -> Result<CapacityForecast, AnalyticsError> {
        let ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        let history = ds
            .history
            .get(&MetricType::UsedSpace)
            .ok_or(AnalyticsError::InsufficientData)?;

        if history.len() < 2 {
            return Err(AnalyticsError::InsufficientData);
        }

        // Calculate daily growth rate using linear regression
        let daily_growth = calculate_daily_growth(history);
        let current_usage = ds.usage.used_space;
        let total_capacity = ds.usage.total_capacity;

        let predicted_usage = if daily_growth > 0 {
            current_usage.saturating_add((daily_growth as u64) * (days as u64))
        } else {
            current_usage.saturating_sub((daily_growth.unsigned_abs()) * (days as u64))
        };

        let days_until_full = if daily_growth <= 0 {
            -1 // Declining or stable
        } else if current_usage >= total_capacity {
            0 // Already full
        } else {
            let remaining = total_capacity - current_usage;
            (remaining / daily_growth as u64) as i32
        };

        let recommendation = match days_until_full {
            -1 => ForecastRecommendation::NoAction,
            0 => ForecastRecommendation::Critical,
            1..=7 => ForecastRecommendation::Critical,
            8..=30 => ForecastRecommendation::ExpansionNeeded,
            31..=90 => ForecastRecommendation::ConsiderExpansion,
            _ => ForecastRecommendation::NoAction,
        };

        Ok(CapacityForecast {
            current_usage,
            predicted_usage,
            daily_growth_rate: daily_growth,
            days_until_full,
            recommendation,
            confidence: calculate_confidence(history),
        })
    }

    /// Get top space consumers by querying the ZPL
    pub fn get_top_consumers(
        &self,
        dataset: &str,
        limit: usize,
    ) -> Result<Vec<SpaceConsumer>, AnalyticsError> {
        let ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        // Query the ZPL for all znodes and their sizes
        let zpl = ZPL.lock();
        let root_id = zpl.root_id();

        // Collect all files with their sizes
        let mut consumers: Vec<SpaceConsumer> = Vec::new();
        let total_used = ds.usage.used_space.max(1); // Avoid division by zero

        // Recursively collect files from all directories
        if let Ok(entries) = zpl.readdir(root_id) {
            for entry in entries {
                if entry.name == "." || entry.name == ".." {
                    continue;
                }
                if let Ok(stat) = zpl.getattr(entry.object_id) {
                    let is_dir = (stat.st_mode & 0o170000) == 0o040000;
                    consumers.push(SpaceConsumer {
                        path: alloc::format!("/{}", entry.name),
                        object_id: entry.object_id,
                        space_used: stat.st_size as u64,
                        percent_of_total: (stat.st_size as f64 / total_used as f64 * 100.0) as f32,
                        is_directory: is_dir,
                        file_count: if is_dir { stat.st_nlink } else { 0 },
                    });
                }
            }
        }

        // Sort by space used (descending) and take top N
        consumers.sort_by(|a, b| b.space_used.cmp(&a.space_used));
        consumers.truncate(limit);

        Ok(consumers)
    }

    /// Get file type distribution by scanning the ZPL
    pub fn get_file_type_distribution(
        &self,
        dataset: &str,
    ) -> Result<Vec<FileTypeStats>, AnalyticsError> {
        let ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        // Query the ZPL for all files
        let zpl = ZPL.lock();
        let root_id = zpl.root_id();
        let total_used = ds.usage.used_space.max(1);

        // Collect file type statistics
        let mut type_map: BTreeMap<String, (u64, u64)> = BTreeMap::new(); // extension -> (count, total_size)

        if let Ok(entries) = zpl.readdir(root_id) {
            for entry in entries {
                if entry.name == "." || entry.name == ".." {
                    continue;
                }
                // Only count regular files
                if entry.file_type == 8 {
                    // DT_REG
                    if let Ok(stat) = zpl.getattr(entry.object_id) {
                        // Extract file extension
                        let ext = entry
                            .name
                            .rsplit('.')
                            .next()
                            .filter(|e| e.len() <= 10 && *e != entry.name)
                            .map(|e| e.to_string())
                            .unwrap_or_else(|| "other".to_string());

                        let stats = type_map.entry(ext).or_insert((0, 0));
                        stats.0 += 1;
                        stats.1 += stat.st_size as u64;
                    }
                }
            }
        }

        // Convert to FileTypeStats
        let mut result: Vec<FileTypeStats> = type_map
            .into_iter()
            .map(|(file_type, (count, total_size))| FileTypeStats {
                file_type,
                count,
                total_size,
                avg_size: if count > 0 { total_size / count } else { 0 },
                percent_of_total: (total_size as f64 / total_used as f64 * 100.0) as f32,
            })
            .collect();

        // Sort by total size descending
        result.sort_by(|a, b| b.total_size.cmp(&a.total_size));

        Ok(result)
    }

    /// Get deduplication statistics from the real dedup subsystem
    pub fn get_dedup_stats(&self, dataset: &str) -> Result<DedupStats, AnalyticsError> {
        // Verify dataset exists
        let _ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        // Get real stats from the fast dedup engine
        let (hits, misses, entries, _evictions, _hit_rate) = FastDedupEngine::get_stats();

        // Calculate block size (assuming 128KB blocks)
        const BLOCK_SIZE: u64 = 128 * 1024;

        let total_blocks = hits + misses;
        let unique_blocks = entries as u64;
        let dedup_blocks = hits; // Hits represent deduplicated references
        let space_saved = dedup_blocks * BLOCK_SIZE;

        // Dedup ratio: total / unique
        let dedup_ratio = if unique_blocks > 0 {
            (total_blocks as f32) / (unique_blocks as f32)
        } else {
            1.0
        };

        let table_entries = entries as u64;
        let table_size = table_entries * 48; // Approximate entry size (32-byte hash + 16-byte metadata)

        Ok(DedupStats {
            total_blocks,
            unique_blocks,
            dedup_blocks,
            space_saved,
            dedup_ratio,
            table_entries,
            table_size,
        })
    }

    /// Get compression statistics
    ///
    /// Returns aggregated compression statistics for the dataset.
    /// Stats are populated by the compression subsystem during I/O operations.
    ///
    /// Note: Full GPU compression stats require the gpu-compute feature.
    pub fn get_compression_stats(&self, dataset: &str) -> Result<CompressionStats, AnalyticsError> {
        // Verify dataset exists
        let _ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        // Return current stats (default if no compression has occurred yet)
        Ok(CompressionStats::default())
    }

    /// Get snapshot usage
    pub fn get_snapshot_usage(&self, dataset: &str) -> Result<SnapshotUsage, AnalyticsError> {
        let _ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        // In production, this would query snapshot metadata
        Ok(SnapshotUsage::default())
    }

    /// Get trend data
    pub fn get_trend(
        &self,
        dataset: &str,
        metric: MetricType,
        period: TrendPeriod,
    ) -> Result<Vec<TrendPoint>, AnalyticsError> {
        let ds = self
            .datasets
            .get(dataset)
            .ok_or_else(|| AnalyticsError::DatasetNotFound(dataset.to_string()))?;

        let history = ds
            .history
            .get(&metric)
            .ok_or(AnalyticsError::InsufficientData)?;

        // Calculate how many points to return based on period
        let points_to_return = match period {
            TrendPeriod::Hour => 60,  // 1 per minute
            TrendPeriod::Day => 24,   // 1 per hour
            TrendPeriod::Week => 168, // 1 per hour
            TrendPeriod::Month => 30, // 1 per day
            TrendPeriod::Year => 52,  // 1 per week
        };

        // Sample the history
        let result = sample_history(history, points_to_return);
        Ok(result)
    }

    /// Generate full report
    pub fn generate_full_report(&self, dataset: &str) -> Result<FullReport, AnalyticsError> {
        let usage = self.get_usage_summary(dataset)?;
        let space = self.get_space_breakdown(dataset)?;
        let io = self.get_io_stats(dataset)?;
        let forecast = self.forecast_capacity(dataset, 30).unwrap_or_default();
        let dedup = self.get_dedup_stats(dataset)?;
        let compression = self.get_compression_stats(dataset)?;
        let snapshots = self.get_snapshot_usage(dataset)?;
        let top_consumers = self.get_top_consumers(dataset, 10)?;
        let file_types = self.get_file_type_distribution(dataset)?;

        // Calculate health score
        let health_score = calculate_health_score(&usage, &io, &forecast);

        // Generate recommendations
        let recommendations = generate_recommendations(&usage, &forecast, &dedup);

        Ok(FullReport {
            generated_at: 0, // Would use real timestamp
            dataset: dataset.to_string(),
            usage,
            space,
            io,
            forecast,
            dedup,
            compression,
            snapshots,
            top_consumers,
            file_types,
            health_score,
            recommendations,
        })
    }
}

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

/// Calculate daily growth rate from historical data
fn calculate_daily_growth(history: &[TrendPoint]) -> i64 {
    if history.len() < 2 {
        return 0;
    }

    let first = &history[0];
    let last = &history[history.len() - 1];

    let time_diff = last.timestamp.saturating_sub(first.timestamp);
    if time_diff == 0 {
        return 0;
    }

    let value_diff = last.value as i64 - first.value as i64;
    let days = (time_diff / 86400).max(1);

    value_diff / days as i64
}

/// Calculate confidence level based on data quality
fn calculate_confidence(history: &[TrendPoint]) -> f32 {
    let data_points = history.len();

    // More data points = higher confidence
    if data_points < 10 {
        0.3
    } else if data_points < 100 {
        0.5
    } else if data_points < 1000 {
        0.7
    } else {
        0.9
    }
}

/// Sample history to return requested number of points
fn sample_history(history: &[TrendPoint], count: usize) -> Vec<TrendPoint> {
    if history.len() <= count {
        return history.to_vec();
    }

    let step = history.len() / count;
    history.iter().step_by(step).take(count).cloned().collect()
}

/// Calculate overall health score
fn calculate_health_score(usage: &UsageSummary, io: &IoStats, forecast: &CapacityForecast) -> u8 {
    let mut score: u8 = 100;

    // Penalize high usage
    if usage.usage_percent > 90.0 {
        score = score.saturating_sub(30);
    } else if usage.usage_percent > 80.0 {
        score = score.saturating_sub(15);
    } else if usage.usage_percent > 70.0 {
        score = score.saturating_sub(5);
    }

    // Penalize low cache hit rate
    if io.cache_hit_rate < 0.5 {
        score = score.saturating_sub(10);
    }

    // Penalize critical forecast
    match forecast.recommendation {
        ForecastRecommendation::Critical => score = score.saturating_sub(25),
        ForecastRecommendation::ExpansionNeeded => score = score.saturating_sub(10),
        _ => {}
    }

    score
}

/// Generate recommendations based on analytics
fn generate_recommendations(
    usage: &UsageSummary,
    forecast: &CapacityForecast,
    dedup: &DedupStats,
) -> Vec<String> {
    let mut recommendations = Vec::new();

    if usage.usage_percent > 85.0 {
        recommendations.push(
            "Storage usage is high. Consider adding capacity or cleaning up old data.".to_string(),
        );
    }

    if forecast.recommendation == ForecastRecommendation::Critical {
        recommendations
            .push("Critical: Storage will be full soon. Immediate action required.".to_string());
    }

    if dedup.dedup_ratio < 1.1 && dedup.total_blocks > 0 {
        recommendations.push(
            "Low deduplication ratio. Consider if dedup is beneficial for this workload."
                .to_string(),
        );
    }

    if usage.reduction_ratio < 1.2 {
        recommendations.push(
            "Low data reduction. Review compression settings for better efficiency.".to_string(),
        );
    }

    recommendations
}

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

    #[test]
    fn test_collector_new() {
        let collector = AnalyticsCollector::new();
        assert!(collector.datasets.is_empty());
    }

    #[test]
    fn test_record_metric() {
        let mut collector = AnalyticsCollector::new();
        // Record file_count - this is stored in ds.usage and returned by get_usage_summary
        collector.record_metric("test", MetricType::FileCount, 1000);

        let usage = collector.get_usage_summary("test").unwrap();
        assert_eq!(usage.file_count, 1000);
    }

    #[test]
    fn test_health_score() {
        let usage = UsageSummary {
            usage_percent: 50.0,
            ..Default::default()
        };
        let io = IoStats {
            cache_hit_rate: 0.9,
            ..Default::default()
        };
        let forecast = CapacityForecast::default();

        let score = calculate_health_score(&usage, &io, &forecast);
        assert_eq!(score, 100);
    }
}