feat(kon): add core crate — types, traits, hardware, model registry, recommendation

- Value objects: ModelId, EngineName, Megabytes, AudioSamples, Segment, Transcript
- KonError enum with thiserror
- Constants centralised: audio pipeline, VAD, RAM thresholds, inference threading
- SpeechToText and TextProcessor provider traits with ProviderRegistry
- Unified model registry (Whisper tiny/base/small/medium + Parakeet CTC int8)
- Hardware detection: probe_ram, probe_cpu, probe_gpu (stub), probe_os
- Recommendation engine: score_model (pure function), rank_recommendations (sorted)
- 5 tests passing, clippy clean

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jake
2026-03-16 20:27:27 +00:00
parent 9926a42b7a
commit 6588130e36
9 changed files with 786 additions and 2 deletions

107
crates/core/src/hardware.rs Normal file
View File

@@ -0,0 +1,107 @@
use sysinfo::System;
use crate::types::Megabytes;
/// Detected system capabilities.
#[derive(Debug, Clone)]
pub struct SystemProfile {
pub ram: Megabytes,
pub cpu: CpuInfo,
pub gpu: Option<GpuInfo>,
pub os: Os,
}
#[derive(Debug, Clone)]
pub struct CpuInfo {
pub core_count: usize,
pub brand: String,
}
#[derive(Debug, Clone)]
pub struct GpuInfo {
pub vendor: GpuVendor,
pub vram: Megabytes,
pub acceleration: GpuAcceleration,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GpuVendor {
Nvidia,
Amd,
Intel,
Apple,
Unknown,
}
#[derive(Debug, Clone)]
pub struct GpuAcceleration {
pub cuda: bool,
pub metal: bool,
pub vulkan: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Os {
Windows,
Linux,
MacOs,
Ios,
Android,
}
pub fn probe_ram() -> Megabytes {
let sys = System::new_all();
let total_bytes = sys.total_memory();
Megabytes(total_bytes / (1024 * 1024))
}
pub fn probe_cpu() -> CpuInfo {
let sys = System::new_all();
CpuInfo {
core_count: sys.cpus().len(),
brand: sys
.cpus()
.first()
.map(|c| c.brand().to_string())
.unwrap_or_default(),
}
}
pub fn probe_gpu() -> Option<GpuInfo> {
// GPU detection via wgpu or platform-specific APIs.
// Placeholder: returns None until wgpu or nvml integration is added.
None
}
pub fn probe_os() -> Os {
#[cfg(target_os = "windows")]
{
Os::Windows
}
#[cfg(target_os = "linux")]
{
Os::Linux
}
#[cfg(target_os = "macos")]
{
Os::MacOs
}
#[cfg(target_os = "ios")]
{
Os::Ios
}
#[cfg(target_os = "android")]
{
Os::Android
}
}
/// Composes the individual probes. No logic here — just assembly.
pub fn probe_system() -> SystemProfile {
SystemProfile {
ram: probe_ram(),
cpu: probe_cpu(),
gpu: probe_gpu(),
os: probe_os(),
}
}