audit fix and code stability improvement

This commit is contained in:
2026-02-26 16:09:44 +01:00
parent 07ccf7ccc7
commit f76acd6256
5 changed files with 53 additions and 21 deletions

View File

@@ -7,7 +7,6 @@ use sysinfo::System;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::path::PathBuf;
use crate::sal::traits::{PlatformSal, AuditStep, SafetyStatus};
use crate::sal::heuristic::discovery::SystemFactSheet;
@@ -80,6 +79,21 @@ impl BenchmarkOrchestrator {
// Start Watchdog Monitor
let _watchdog_handle = self.spawn_watchdog_monitor();
// Use a closure to ensure cleanup always runs
let result = self.execute_benchmark();
// --- MANDATORY CLEANUP ---
self.log("Benchmark sequence finished. Restoring hardware defaults...")?;
let _ = self.workload.stop();
if let Err(e) = self.sal.restore() {
anyhow::bail!("CRITICAL: Failed to restore hardware state: {}", e);
}
self.log("✓ Hardware state restored.")?;
result
}
fn execute_benchmark(&mut self) -> Result<OptimizationResult> {
// Phase 1: Audit & Baseline
self.phase = BenchmarkPhase::Auditing;
for step in self.sal.audit() {
@@ -208,9 +222,6 @@ impl BenchmarkOrchestrator {
res.config_paths.insert("i8kmon".to_string(), i8k_path.clone());
}
self.sal.restore()?;
self.log("✓ Environment restored.")?;
Ok(res)
}
@@ -228,9 +239,7 @@ impl BenchmarkOrchestrator {
abort.store(true, Ordering::SeqCst);
break;
}
Ok(SafetyStatus::Warning(_msg)) | Ok(SafetyStatus::Critical(_msg)) => {
// Send warning log to UI
}
Ok(SafetyStatus::Warning(_msg)) | Ok(SafetyStatus::Critical(_msg)) => {}
Ok(SafetyStatus::Nominal) => {}
Err(e) => {
*reason_store.lock().unwrap() = Some(format!("Watchdog Sensor Failure: {}", e));