From e41c4909f145fa5ac3377d2a7fb3377f72c621fa Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Mon, 20 Apr 2026 12:08:11 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20validate=20OFI=20data=20content,=20not?= =?UTF-8?q?=20just=20has=5Fofi=20flag=20=E2=80=94=20v2=20cache=20had=20all?= =?UTF-8?q?-zero=20OFI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The v2 fxcache on PVC passed has_ofi=true validation (mbp10_dir was present when built) but contained all-zero OFI data. The old binary set the flag based on directory existence, not actual computed values. Now counts non-zero OFI rows before accepting a cache — forces rebuild when MBP-10 data is available but OFI content is all zeros. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/ml/examples/precompute_features.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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");