fixed dangerous states to be applied

This commit is contained in:
2026-02-27 00:59:36 +01:00
parent 4ed7228355
commit 4c4026a600
9 changed files with 116 additions and 29 deletions

View File

@@ -12,6 +12,7 @@ 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, SafetyStatus};
use crate::sal::heuristic::discovery::SystemFactSheet;
@@ -40,6 +41,8 @@ pub struct BenchmarkOrchestrator {
profile: ThermalProfile,
/// Mathematics engine for data smoothing and optimization.
engine: OptimizerEngine,
/// CLI override for the configuration output path.
optional_config_out: Option<PathBuf>,
/// Sliding window of power readings (Watts).
history_watts: VecDeque<f32>,
@@ -67,6 +70,7 @@ impl BenchmarkOrchestrator {
workload: Box<dyn Workload>,
telemetry_tx: mpsc::Sender<TelemetryState>,
command_rx: mpsc::Receiver<UiCommand>,
optional_config_out: Option<PathBuf>,
) -> Self {
let mut sys = System::new_all();
sys.refresh_all();
@@ -92,6 +96,7 @@ impl BenchmarkOrchestrator {
total_ram_gb,
emergency_abort: Arc::new(AtomicBool::new(false)),
emergency_reason: Arc::new(Mutex::new(None)),
optional_config_out,
}
}
@@ -222,12 +227,18 @@ impl BenchmarkOrchestrator {
trip_temp: res.max_temp_c.max(95.0),
};
if let Some(throttled_path) = self.facts.paths.configs.get("throttled") {
crate::engine::formatters::throttled::ThrottledTranslator::save(throttled_path, &config)?;
self.log(&format!("✓ Saved '{}' (merged).", throttled_path.display()))?;
res.config_paths.insert("throttled".to_string(), throttled_path.clone());
// 1. Throttled (Merged if exists)
// PRIORITY: optional_config_out > facts discovery > fallback
let throttled_path = self.optional_config_out.clone()
.or_else(|| self.facts.paths.configs.get("throttled").cloned());
if let Some(path) = throttled_path {
crate::engine::formatters::throttled::ThrottledTranslator::save(&path, &config)?;
self.log(&format!("✓ Saved '{}'.", path.display()))?;
res.config_paths.insert("throttled".to_string(), path.clone());
}
// 2. i8kmon
if let Some(i8k_path) = self.facts.paths.configs.get("i8kmon") {
let i8k_config = crate::engine::formatters::i8kmon::I8kmonConfig {
t_ambient: self.profile.ambient_temp,