fix(kon): harden core crate — shared System instance, accurate CPU field, serialisable errors

- Share single System::new_all() in probe_system() instead of calling it twice
- Rename CpuInfo::core_count to logical_processors (sys.cpus().len() returns logical, not physical)
- Add fallback arm to probe_os() for unsupported cfg targets
- Add serde::Serialize to KonError for structured frontend error reporting
- Annotate dead code (ProviderRegistry, TranscriptMetadata) with #[allow(dead_code)] + TODO comments
- Update downstream references in recommendation tests and tauri hardware command

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jake
2026-03-17 00:19:04 +00:00
parent 4fa20255ae
commit 95c8d490c3
6 changed files with 60 additions and 49 deletions

View File

@@ -1,7 +1,5 @@
use crate::hardware::SystemProfile;
use crate::model_registry::{
all_models, AccuracyTier, Engine, ModelEntry, SpeedTier,
};
use crate::model_registry::{all_models, AccuracyTier, Engine, ModelEntry, SpeedTier};
use crate::types::Megabytes;
/// A model's suitability score for a given system. Higher is better.
@@ -14,10 +12,7 @@ pub struct ScoredModel {
/// Scores a single model against a system profile.
/// Pure function, no side effects.
pub fn score_model(
model: &'static ModelEntry,
profile: &SystemProfile,
) -> Option<ScoredModel> {
pub fn score_model(model: &'static ModelEntry, profile: &SystemProfile) -> Option<ScoredModel> {
if model.ram_required > profile.ram {
return None;
}
@@ -41,9 +36,7 @@ pub fn score_model(
if let Some(gpu) = &profile.gpu {
let has_accel = match model.engine {
Engine::Whisper => {
gpu.acceleration.metal
|| gpu.acceleration.vulkan
|| gpu.acceleration.cuda
gpu.acceleration.metal || gpu.acceleration.vulkan || gpu.acceleration.cuda
}
Engine::Parakeet | Engine::Moonshine => {
gpu.acceleration.cuda || gpu.acceleration.vulkan
@@ -55,8 +48,7 @@ pub fn score_model(
}
}
let headroom =
Megabytes(profile.ram.0.saturating_sub(model.ram_required.0));
let headroom = Megabytes(profile.ram.0.saturating_sub(model.ram_required.0));
if headroom > Megabytes::from_gb(4.0) {
score += 10.0;
}
@@ -99,7 +91,7 @@ mod tests {
SystemProfile {
ram,
cpu: CpuInfo {
core_count: 8,
logical_processors: 8,
brand: "Test CPU".into(),
},
gpu: None,
@@ -111,7 +103,7 @@ mod tests {
SystemProfile {
ram,
cpu: CpuInfo {
core_count: 8,
logical_processors: 8,
brand: "Test CPU".into(),
},
gpu: Some(GpuInfo {
@@ -157,14 +149,12 @@ mod tests {
.find(|m| m.engine == Engine::Parakeet)
.expect("need a Parakeet model");
let gpu_score =
score_model(model, &profile_with_gpu(Megabytes(16384)))
.unwrap()
.score;
let cpu_score =
score_model(model, &profile_with_ram(Megabytes(16384)))
.unwrap()
.score;
let gpu_score = score_model(model, &profile_with_gpu(Megabytes(16384)))
.unwrap()
.score;
let cpu_score = score_model(model, &profile_with_ram(Megabytes(16384)))
.unwrap()
.score;
assert!(gpu_score > cpu_score);
}