inferno-ai 0.10.3

Enterprise AI/ML model runner with automatic updates, real-time monitoring, and multi-interface support
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
//! # Platform-Specific Upgrade Handlers
//!
//! Platform abstraction layer for handling upgrades across different operating systems
//! with native installation methods and system integration.

use super::{UpgradeConfig, UpgradeError, UpgradeResult};
use anyhow::Result;
use std::path::PathBuf;
use std::process::Command;
use tracing::{debug, info, warn};

/// Platform detection utilities
pub struct PlatformInfo {
    pub os: String,
    pub arch: String,
    pub version: String,
    pub distribution: Option<String>, // For Linux distributions
}

impl PlatformInfo {
    /// Detect current platform information
    pub fn detect() -> Result<Self> {
        let os = std::env::consts::OS.to_string();
        let arch = std::env::consts::ARCH.to_string();

        let version = Self::get_os_version()?;
        let distribution = Self::get_distribution();

        Ok(Self {
            os,
            arch,
            version,
            distribution,
        })
    }

    /// Get OS version string
    fn get_os_version() -> Result<String> {
        #[cfg(target_os = "macos")]
        {
            let output = Command::new("sw_vers").arg("-productVersion").output()?;

            if output.status.success() {
                Ok(String::from_utf8(output.stdout)?.trim().to_string())
            } else {
                Ok("unknown".to_string())
            }
        }

        #[cfg(target_os = "linux")]
        {
            // Try to get kernel version
            let output = Command::new("uname").arg("-r").output()?;

            if output.status.success() {
                Ok(String::from_utf8(output.stdout)?.trim().to_string())
            } else {
                Ok("unknown".to_string())
            }
        }

        #[cfg(target_os = "windows")]
        {
            // Use PowerShell to get Windows version
            let output = Command::new("powershell")
                .args(&[
                    "-Command",
                    "(Get-CimInstance Win32_OperatingSystem).Version",
                ])
                .output()?;

            if output.status.success() {
                Ok(String::from_utf8(output.stdout)?.trim().to_string())
            } else {
                Ok("unknown".to_string())
            }
        }

        #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
        {
            Ok("unknown".to_string())
        }
    }

    /// Get Linux distribution name
    fn get_distribution() -> Option<String> {
        #[cfg(target_os = "linux")]
        {
            // Try to read /etc/os-release
            if let Ok(content) = std::fs::read_to_string("/etc/os-release") {
                for line in content.lines() {
                    if line.starts_with("ID=") {
                        return Some(line.trim_start_matches("ID=").trim_matches('"').to_string());
                    }
                }
            }

            // Fallback to lsb_release
            if let Ok(output) = Command::new("lsb_release").arg("-si").output() {
                if output.status.success() {
                    return Some(String::from_utf8(output.stdout).ok()?.trim().to_string());
                }
            }
        }

        None
    }

    /// Check if the platform supports a specific installation method
    pub fn supports_installation_method(&self, method: &InstallationMethod) -> bool {
        match method {
            InstallationMethod::SelfExtractor => true, // All platforms support this
            InstallationMethod::SystemPackage => match self.os.as_str() {
                "linux" => true,
                "macos" => true,
                "windows" => true,
                _ => false,
            },
            InstallationMethod::AppBundle => self.os == "macos",
            InstallationMethod::MSI => self.os == "windows",
            InstallationMethod::DEB => {
                self.os == "linux"
                    && self
                        .distribution
                        .as_ref()
                        .is_some_and(|d| d.contains("ubuntu") || d.contains("debian"))
            }
            InstallationMethod::RPM => {
                self.os == "linux"
                    && self.distribution.as_ref().is_some_and(|d| {
                        d.contains("fedora") || d.contains("centos") || d.contains("rhel")
                    })
            }
            InstallationMethod::Snap => self.os == "linux",
            InstallationMethod::Flatpak => self.os == "linux",
            InstallationMethod::Homebrew => self.os == "macos" || self.os == "linux",
            InstallationMethod::Winget => self.os == "windows",
        }
    }
}

/// Available installation methods
#[derive(Debug, Clone)]
pub enum InstallationMethod {
    /// Self-extracting archive (works on all platforms)
    SelfExtractor,
    /// Native system package
    SystemPackage,
    /// macOS App Bundle
    AppBundle,
    /// Windows MSI installer
    MSI,
    /// Debian/Ubuntu package
    DEB,
    /// Red Hat/Fedora package
    RPM,
    /// Snap package (Linux)
    Snap,
    /// Flatpak (Linux)
    Flatpak,
    /// Homebrew (macOS/Linux)
    Homebrew,
    /// Windows Package Manager
    Winget,
}

/// Base platform upgrade handler with common functionality
pub struct BasePlatformHandler {
    pub config: UpgradeConfig,
    pub platform_info: PlatformInfo,
    pub preferred_methods: Vec<InstallationMethod>,
}

impl BasePlatformHandler {
    /// Create a new base platform handler
    pub fn new(config: &UpgradeConfig) -> Result<Self> {
        let platform_info = PlatformInfo::detect()?;
        let preferred_methods = Self::get_preferred_installation_methods(&platform_info);

        Ok(Self {
            config: config.clone(),
            platform_info,
            preferred_methods,
        })
    }

    /// Get preferred installation methods for the current platform
    fn get_preferred_installation_methods(platform_info: &PlatformInfo) -> Vec<InstallationMethod> {
        match platform_info.os.as_str() {
            "macos" => vec![
                InstallationMethod::AppBundle,
                InstallationMethod::Homebrew,
                InstallationMethod::SelfExtractor,
            ],
            "linux" => {
                let mut methods = vec![];

                // Add distribution-specific methods first
                if let Some(distro) = &platform_info.distribution {
                    if distro.contains("ubuntu") || distro.contains("debian") {
                        methods.push(InstallationMethod::DEB);
                    } else if distro.contains("fedora")
                        || distro.contains("centos")
                        || distro.contains("rhel")
                    {
                        methods.push(InstallationMethod::RPM);
                    }
                }

                // Add universal Linux methods
                methods.extend([
                    InstallationMethod::Snap,
                    InstallationMethod::Flatpak,
                    InstallationMethod::Homebrew,
                    InstallationMethod::SelfExtractor,
                ]);

                methods
            }
            "windows" => vec![
                InstallationMethod::MSI,
                InstallationMethod::Winget,
                InstallationMethod::SelfExtractor,
            ],
            _ => vec![InstallationMethod::SelfExtractor],
        }
    }

    /// Check if the platform supports seamless upgrades
    pub fn supports_seamless_upgrade(&self) -> bool {
        // Most platforms support some form of seamless upgrade
        match self.platform_info.os.as_str() {
            "macos" | "linux" | "windows" => true,
            _ => false,
        }
    }

    /// Get installation directory for the current platform
    pub fn get_installation_directory(&self) -> PathBuf {
        match self.platform_info.os.as_str() {
            "macos" => PathBuf::from("/Applications/Inferno.app"),
            "linux" => PathBuf::from("/usr/local/bin"),
            "windows" => PathBuf::from("C:\\Program Files\\Inferno"),
            _ => std::env::current_exe()
                .map(|exe| exe.parent().unwrap_or(&exe).to_path_buf())
                .unwrap_or_else(|_| PathBuf::from(".")),
        }
    }

    /// Get backup directory for the current platform
    pub fn get_backup_directory(&self) -> PathBuf {
        match self.platform_info.os.as_str() {
            "macos" => dirs::home_dir()
                .unwrap_or_else(|| PathBuf::from("/tmp"))
                .join("Library/Application Support/Inferno/Backups"),
            "linux" => dirs::home_dir()
                .unwrap_or_else(|| PathBuf::from("/tmp"))
                .join(".local/share/inferno/backups"),
            "windows" => dirs::data_dir()
                .unwrap_or_else(|| PathBuf::from("C:\\ProgramData"))
                .join("Inferno\\Backups"),
            _ => PathBuf::from("./backups"),
        }
    }

    /// Check if administrator/root privileges are required
    pub fn requires_elevated_privileges(&self) -> bool {
        let installation_dir = self.get_installation_directory();

        // Check if we can write to the installation directory
        match std::fs::metadata(&installation_dir) {
            Ok(_) => {
                // Try to create a test file
                let test_file = installation_dir.join(".write_test");
                std::fs::write(&test_file, "test").is_err()
            }
            Err(_) => {
                // Directory doesn't exist, check parent
                if let Some(parent) = installation_dir.parent() {
                    let test_file = parent.join(".write_test");
                    std::fs::write(&test_file, "test").is_err()
                } else {
                    true // Conservative assumption
                }
            }
        }
    }

    /// Stop application services before upgrade
    pub async fn stop_services(&self) -> UpgradeResult<Vec<String>> {
        info!("Stopping application services");

        let mut stopped_services = vec![];

        // Stop any running instances of the application
        if let Err(e) = self.stop_running_instances().await {
            warn!("Failed to stop some running instances: {}", e);
        } else {
            stopped_services.push("inferno-instances".to_string());
        }

        // Platform-specific service stopping
        match self.platform_info.os.as_str() {
            "macos" => {
                if let Ok(services) = self.stop_macos_services().await {
                    stopped_services.extend(services);
                }
            }
            "linux" => {
                if let Ok(services) = self.stop_linux_services().await {
                    stopped_services.extend(services);
                }
            }
            "windows" => {
                if let Ok(services) = self.stop_windows_services().await {
                    stopped_services.extend(services);
                }
            }
            _ => {}
        }

        Ok(stopped_services)
    }

    /// Start application services after upgrade
    pub async fn start_services(&self, stopped_services: &[String]) -> UpgradeResult<()> {
        info!("Starting application services");

        // Platform-specific service starting
        match self.platform_info.os.as_str() {
            "macos" => self
                .start_macos_services(stopped_services)
                .await
                .map_err(|e| UpgradeError::Internal(e.to_string()))?,
            "linux" => self
                .start_linux_services(stopped_services)
                .await
                .map_err(|e| UpgradeError::Internal(e.to_string()))?,
            "windows" => self
                .start_windows_services(stopped_services)
                .await
                .map_err(|e| UpgradeError::Internal(e.to_string()))?,
            _ => {}
        }

        Ok(())
    }

    /// Stop running application instances
    async fn stop_running_instances(&self) -> Result<()> {
        use sysinfo::{ProcessExt, System, SystemExt};

        let mut system = System::new_all();
        system.refresh_all();

        let current_pid = sysinfo::get_current_pid().unwrap();

        for (pid, process) in system.processes() {
            if *pid != current_pid && process.name().to_lowercase().contains("inferno") {
                info!("Stopping process: {} (PID: {})", process.name(), pid);

                #[cfg(unix)]
                {
                    let _ = Command::new("kill")
                        .arg("-TERM")
                        .arg(pid.to_string())
                        .output();
                }

                #[cfg(windows)]
                {
                    let _ = Command::new("taskkill")
                        .args(&["/PID", &pid.to_string(), "/F"])
                        .output();
                }
            }
        }

        // Wait a moment for processes to stop gracefully
        tokio::time::sleep(std::time::Duration::from_secs(2)).await;

        Ok(())
    }

    // Platform-specific service management methods
    #[cfg(target_os = "macos")]
    async fn stop_macos_services(&self) -> Result<Vec<String>> {
        let mut stopped = vec![];

        // Check for launchd services
        if let Ok(output) = Command::new("launchctl").args(["list"]).output() {
            let output_str = String::from_utf8_lossy(&output.stdout);
            for line in output_str.lines() {
                if line.contains("inferno") {
                    let parts: Vec<&str> = line.split_whitespace().collect();
                    if parts.len() >= 3 {
                        let service_name = parts[2];
                        debug!("Stopping macOS service: {}", service_name);

                        let _ = Command::new("launchctl")
                            .args(["unload", service_name])
                            .output();

                        stopped.push(service_name.to_string());
                    }
                }
            }
        }

        Ok(stopped)
    }

    #[cfg(not(target_os = "macos"))]
    async fn stop_macos_services(&self) -> Result<Vec<String>> {
        Ok(vec![])
    }

    #[cfg(target_os = "linux")]
    async fn stop_linux_services(&self) -> Result<Vec<String>> {
        let mut stopped = vec![];

        // Check for systemd services
        if let Ok(output) = Command::new("systemctl")
            .args(&["list-units", "--type=service", "--state=active"])
            .output()
        {
            let output_str = String::from_utf8_lossy(&output.stdout);
            for line in output_str.lines() {
                if line.contains("inferno") {
                    let parts: Vec<&str> = line.split_whitespace().collect();
                    if !parts.is_empty() {
                        let service_name = parts[0];
                        debug!("Stopping Linux service: {}", service_name);

                        let _ = Command::new("systemctl")
                            .args(&["stop", service_name])
                            .output();

                        stopped.push(service_name.to_string());
                    }
                }
            }
        }

        Ok(stopped)
    }

    #[cfg(not(target_os = "linux"))]
    async fn stop_linux_services(&self) -> Result<Vec<String>> {
        Ok(vec![])
    }

    #[cfg(target_os = "windows")]
    async fn stop_windows_services(&self) -> Result<Vec<String>> {
        let mut stopped = vec![];

        // Check for Windows services
        if let Ok(output) = Command::new("sc")
            .args(&["query", "state=", "all"])
            .output()
        {
            let output_str = String::from_utf8_lossy(&output.stdout);
            for line in output_str.lines() {
                if line.contains("inferno") && line.contains("SERVICE_NAME:") {
                    if let Some(service_name) = line.split(':').nth(1) {
                        let service_name = service_name.trim();
                        debug!("Stopping Windows service: {}", service_name);

                        let _ = Command::new("sc").args(&["stop", service_name]).output();

                        stopped.push(service_name.to_string());
                    }
                }
            }
        }

        Ok(stopped)
    }

    #[cfg(not(target_os = "windows"))]
    async fn stop_windows_services(&self) -> Result<Vec<String>> {
        Ok(vec![])
    }

    #[cfg(target_os = "macos")]
    async fn start_macos_services(&self, stopped_services: &[String]) -> Result<()> {
        for service in stopped_services {
            if service != "inferno-instances" {
                debug!("Starting macOS service: {}", service);
                let _ = Command::new("launchctl").args(["load", service]).output();
            }
        }
        Ok(())
    }

    #[cfg(not(target_os = "macos"))]
    async fn start_macos_services(&self, _stopped_services: &[String]) -> Result<()> {
        Ok(())
    }

    #[cfg(target_os = "linux")]
    async fn start_linux_services(&self, stopped_services: &[String]) -> Result<()> {
        for service in stopped_services {
            if service != "inferno-instances" {
                debug!("Starting Linux service: {}", service);
                let _ = Command::new("systemctl").args(&["start", service]).output();
            }
        }
        Ok(())
    }

    #[cfg(not(target_os = "linux"))]
    async fn start_linux_services(&self, _stopped_services: &[String]) -> Result<()> {
        Ok(())
    }

    #[cfg(target_os = "windows")]
    async fn start_windows_services(&self, stopped_services: &[String]) -> Result<()> {
        for service in stopped_services {
            if service != "inferno-instances" {
                debug!("Starting Windows service: {}", service);
                let _ = Command::new("sc").args(&["start", service]).output();
            }
        }
        Ok(())
    }

    #[cfg(not(target_os = "windows"))]
    async fn start_windows_services(&self, _stopped_services: &[String]) -> Result<()> {
        Ok(())
    }

    /// Extract and install from a self-extracting archive
    pub async fn install_self_extractor(&self, package_path: &PathBuf) -> UpgradeResult<()> {
        info!(
            "Installing from self-extracting archive: {:?}",
            package_path
        );

        // Extract to temporary directory
        let temp_dir = tempfile::TempDir::new()
            .map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        // Extract the archive
        self.extract_archive(package_path, temp_dir.path()).await?;

        // Find the main executable in the extracted content
        let executable = self.find_main_executable(temp_dir.path())?;

        // Install the executable
        self.install_executable(&executable).await?;

        Ok(())
    }

    /// Extract archive to destination
    async fn extract_archive(
        &self,
        archive_path: &PathBuf,
        dest_dir: &std::path::Path,
    ) -> UpgradeResult<()> {
        use flate2::read::GzDecoder;
        use std::fs::File;
        use tar::Archive;

        let file =
            File::open(archive_path).map_err(|e| UpgradeError::InvalidPackage(e.to_string()))?;

        let decoder = GzDecoder::new(file);
        let mut archive = Archive::new(decoder);

        archive
            .unpack(dest_dir)
            .map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        Ok(())
    }

    /// Find the main executable in extracted content
    fn find_main_executable(&self, dir: &std::path::Path) -> UpgradeResult<PathBuf> {
        for entry in
            std::fs::read_dir(dir).map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?
        {
            let entry = entry.map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;
            let path = entry.path();

            if path.is_file() {
                let filename = path.file_name().and_then(|n| n.to_str()).unwrap_or("");

                if filename.starts_with("inferno") {
                    return Ok(path);
                }
            }
        }

        Err(UpgradeError::InstallationFailed(
            "Main executable not found in package".to_string(),
        ))
    }

    /// Install executable to the appropriate location
    async fn install_executable(&self, source_exe: &PathBuf) -> UpgradeResult<()> {
        let current_exe =
            std::env::current_exe().map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        // Create backup of current executable
        let backup_exe = current_exe.with_extension("exe.backup");
        std::fs::copy(&current_exe, &backup_exe)
            .map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        // Replace current executable
        std::fs::copy(source_exe, &current_exe)
            .map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        // Set executable permissions on Unix
        #[cfg(unix)]
        {
            use std::os::unix::fs::PermissionsExt;
            let mut perms = std::fs::metadata(&current_exe)
                .map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?
                .permissions();
            perms.set_mode(0o755);
            std::fs::set_permissions(&current_exe, perms)
                .map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;
        }

        Ok(())
    }

    /// Verify installation by checking executable
    pub async fn verify_installation(&self) -> UpgradeResult<bool> {
        let current_exe =
            std::env::current_exe().map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        // Try to run the executable with --version
        let output = Command::new(&current_exe)
            .arg("--version")
            .output()
            .map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        Ok(output.status.success())
    }

    /// Clean up temporary files after upgrade
    pub async fn cleanup_after_upgrade(&self) -> UpgradeResult<()> {
        info!("Cleaning up after upgrade");

        // Remove backup executable if it exists
        let current_exe =
            std::env::current_exe().map_err(|e| UpgradeError::InstallationFailed(e.to_string()))?;

        let backup_exe = current_exe.with_extension("exe.backup");
        if backup_exe.exists() {
            if let Err(e) = std::fs::remove_file(&backup_exe) {
                warn!("Failed to remove backup executable: {}", e);
            }
        }

        // Platform-specific cleanup
        match self.platform_info.os.as_str() {
            "macos" => self.cleanup_macos().await?,
            "linux" => self.cleanup_linux().await?,
            "windows" => self.cleanup_windows().await?,
            _ => {}
        }

        Ok(())
    }

    #[cfg(target_os = "macos")]
    async fn cleanup_macos(&self) -> UpgradeResult<()> {
        // Clean up any macOS-specific temporary files
        Ok(())
    }

    #[cfg(not(target_os = "macos"))]
    async fn cleanup_macos(&self) -> UpgradeResult<()> {
        Ok(())
    }

    #[cfg(target_os = "linux")]
    async fn cleanup_linux(&self) -> UpgradeResult<()> {
        // Clean up any Linux-specific temporary files
        Ok(())
    }

    #[cfg(not(target_os = "linux"))]
    async fn cleanup_linux(&self) -> UpgradeResult<()> {
        Ok(())
    }

    #[cfg(target_os = "windows")]
    async fn cleanup_windows(&self) -> UpgradeResult<()> {
        // Clean up any Windows-specific temporary files
        Ok(())
    }

    #[cfg(not(target_os = "windows"))]
    async fn cleanup_windows(&self) -> UpgradeResult<()> {
        Ok(())
    }
}

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

    #[test]
    fn test_platform_detection() {
        let platform = PlatformInfo::detect().unwrap();
        println!("Detected platform: {:?}", platform.os);
        println!("Architecture: {}", platform.arch);
        println!("Version: {}", platform.version);
        if let Some(distro) = &platform.distribution {
            println!("Distribution: {}", distro);
        }

        assert!(!platform.os.is_empty());
        assert!(!platform.arch.is_empty());
    }

    #[test]
    fn test_installation_methods() {
        let platform = PlatformInfo::detect().unwrap();
        let methods = BasePlatformHandler::get_preferred_installation_methods(&platform);

        assert!(!methods.is_empty());
        println!("Preferred installation methods: {:?}", methods);
    }

    #[tokio::test]
    async fn test_base_handler_creation() {
        let config = UpgradeConfig::default();
        let handler = BasePlatformHandler::new(&config);
        assert!(handler.is_ok());

        let handler = handler.unwrap();
        assert!(handler.supports_seamless_upgrade());
    }
}