diff --git a/crates/ml/examples/precompute_features.rs b/crates/ml/examples/precompute_features.rs index d6f1a5087..827b3caaa 100644 --- a/crates/ml/examples/precompute_features.rs +++ b/crates/ml/examples/precompute_features.rs @@ -217,12 +217,20 @@ async fn main() -> Result<()> { if early_check_path.exists() { match ml::fxcache::load_fxcache(&early_check_path) { Ok(cached) if cached.has_ofi || mbp10_dir.is_none() => { - let size_mb = std::fs::metadata(&early_check_path) - .map(|m| m.len() as f64 / 1_048_576.0) - .unwrap_or(0.0); - println!("Cache already exists: {} ({:.1} MB, has_ofi={}) — skipping extraction", - early_check_path.display(), size_mb, cached.has_ofi); - return Ok(()); + // has_ofi flag is necessary but not sufficient — verify actual OFI data is non-zero + let ofi_nonzero = cached.ofi.iter().filter(|r| r.iter().any(|&v| v != 0.0)).count(); + if mbp10_dir.is_some() && ofi_nonzero == 0 { + println!("Cache has_ofi=true but OFI data is all zeros ({} bars) — deleting stale cache", + cached.ofi.len()); + std::fs::remove_file(&early_check_path).ok(); + } else { + let size_mb = std::fs::metadata(&early_check_path) + .map(|m| m.len() as f64 / 1_048_576.0) + .unwrap_or(0.0); + println!("Cache already exists: {} ({:.1} MB, has_ofi={}, ofi_nonzero={}) — skipping extraction", + early_check_path.display(), size_mb, cached.has_ofi, ofi_nonzero); + return Ok(()); + } } Ok(_) => { println!("Cache exists but has_ofi=false while MBP-10 data available — deleting stale cache");