Skip to content

Commit 98974c8

Browse files
committed
osint: fix p1 synth_codebook temp-path race (codex P2 #624)
Both tests in p1_distance_identity run concurrently under the parallel harness and each removes its codebook file after loading; the pid+len-only temp path collided, so one test could truncate the other's load mid-read (intermittent load_binary failure). Add a per-call AtomicU64 sequence to the filename so each call gets a unique path. Deterministic content unchanged; 2 tests still green. Addresses codex review comment on PR #624. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 20b5d0d commit 98974c8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

crates/lance-graph-osint/tests/p1_distance_identity.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ fn synth_codebook() -> Codebook {
5252
let v = ((splitmix64(&mut s) >> 40) as f32) / (1u64 << 24) as f32;
5353
bytes.extend_from_slice(&v.to_le_bytes());
5454
}
55+
// Unique per call: both tests in this binary run concurrently under the
56+
// parallel harness and each removes its file after loading; a pid+len-only
57+
// path collides and one test can truncate the other's load mid-read.
58+
static CODEBOOK_SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
59+
let seq = CODEBOOK_SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
5560
let path = std::env::temp_dir().join(format!(
56-
"p1_osint_codebook_{}_{}.bin",
61+
"p1_osint_codebook_{}_{}_{}.bin",
5762
std::process::id(),
63+
seq,
5864
bytes.len()
5965
));
6066
std::fs::write(&path, &bytes).expect("write synthetic codebook");

0 commit comments

Comments
 (0)