fix: validate OFI data content, not just has_ofi flag — v2 cache had all-zero OFI
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user