From eb1d1e5dbda9ca31aeb300fd3012fc722bca84e7 Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Sat, 6 Jun 2026 19:25:43 -0300 Subject: [PATCH 1/2] test(wseg-build): roaring fixture generator for the Zig reader's golden tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a gated dev-only test (RUN_ROARING_FIXTURES) that regenerates the hybrid-posting fixtures the wormdb-domain-atomicassets roaring deep-walk is golden-tested against (src/testdata/roaring_{sparse,dense}.bin — array-container + bitmap-container cases). Only the bytes ship (committed in the domain repo); rerun this after any change to the roaring serialization (e.g. a `roaring` crate bump) so the Rust writer ↔ Zig reader byte contract stays pinned. --- crates/wseg-build/src/aa_binfmt.rs | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/wseg-build/src/aa_binfmt.rs b/crates/wseg-build/src/aa_binfmt.rs index e46e780..7ef982e 100644 --- a/crates/wseg-build/src/aa_binfmt.rs +++ b/crates/wseg-build/src/aa_binfmt.rs @@ -616,3 +616,38 @@ mod tests { assert!(decode_config(&blob[..3]).is_none()); } } + +#[cfg(test)] +mod roaring_fixtures { + use super::*; + /// Regenerates the hybrid-posting fixtures the Zig reader's roaring walk is golden-tested against + /// (`wormdb-domain-atomicassets/src/testdata/roaring_*.bin`). Dev tool, gated behind + /// `RUN_ROARING_FIXTURES` so it's a no-op in CI; only the bytes ship (the Zig side recomputes the + /// expected id set). Run after any change to the roaring serialization (e.g. a `roaring` crate bump): + /// RUN_ROARING_FIXTURES=1 ROARING_FIXTURE_DIR=/src/testdata cargo test -p wseg-build write_roaring_fixtures + #[test] + fn write_roaring_fixtures() { + if std::env::var("RUN_ROARING_FIXTURES").is_err() { + return; + } + let dir = std::env::var("ROARING_FIXTURE_DIR") + .unwrap_or_else(|_| "P:/wormdb-domain-atomicassets/src/testdata".to_string()); + std::fs::create_dir_all(&dir).unwrap(); + let base = 1_099_511_627_776u64; // 2^40 + // (A) sparse → array containers, multiple high-32 keys: base + i*9_000_000, i in 0..600. + let mut a: Vec = (0..600u64).map(|i| base + i * 9_000_000).collect(); + std::fs::write( + format!("{dir}/roaring_sparse.bin"), + encode_posting_hybrid(&mut a), + ) + .unwrap(); + // (B) dense → a bitmap container (>4096 ids in one 16-bit block): base + i, i in 0..6000. + let mut b: Vec = (0..6000u64).map(|i| base + i).collect(); + std::fs::write( + format!("{dir}/roaring_dense.bin"), + encode_posting_hybrid(&mut b), + ) + .unwrap(); + eprintln!("wrote roaring fixtures to {dir}"); + } +} From 71331416076c1746316f5830f1595fa219d06e1b Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Sat, 6 Jun 2026 20:07:23 -0300 Subject: [PATCH 2/2] =?UTF-8?q?fix(wseg-build):=20address=20PR=20#9=20revi?= =?UTF-8?q?ew=20=E2=80=94=20portable=20fixture=20dir=20(no=20hardcoded=20p?= =?UTF-8?q?ath)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The roaring-fixture dev tool defaulted ROARING_FIXTURE_DIR to a hardcoded `P:/...` Windows path (Gemini + Copilot), which fails / creates stray dirs on other hosts. Require the env var instead (.expect with a usage hint) — the test is already gated behind RUN_ROARING_FIXTURES so it stays a no-op in CI. --- crates/wseg-build/src/aa_binfmt.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/wseg-build/src/aa_binfmt.rs b/crates/wseg-build/src/aa_binfmt.rs index 7ef982e..36bf331 100644 --- a/crates/wseg-build/src/aa_binfmt.rs +++ b/crates/wseg-build/src/aa_binfmt.rs @@ -623,15 +623,18 @@ mod roaring_fixtures { /// Regenerates the hybrid-posting fixtures the Zig reader's roaring walk is golden-tested against /// (`wormdb-domain-atomicassets/src/testdata/roaring_*.bin`). Dev tool, gated behind /// `RUN_ROARING_FIXTURES` so it's a no-op in CI; only the bytes ship (the Zig side recomputes the - /// expected id set). Run after any change to the roaring serialization (e.g. a `roaring` crate bump): + /// expected id set). The output dir is taken from `ROARING_FIXTURE_DIR` (required when running — no + /// host-specific default) so it's portable. Run after any change to the roaring serialization + /// (e.g. a `roaring` crate bump): /// RUN_ROARING_FIXTURES=1 ROARING_FIXTURE_DIR=/src/testdata cargo test -p wseg-build write_roaring_fixtures #[test] fn write_roaring_fixtures() { if std::env::var("RUN_ROARING_FIXTURES").is_err() { return; } - let dir = std::env::var("ROARING_FIXTURE_DIR") - .unwrap_or_else(|_| "P:/wormdb-domain-atomicassets/src/testdata".to_string()); + let dir = std::env::var("ROARING_FIXTURE_DIR").expect( + "set ROARING_FIXTURE_DIR=/src/testdata to regenerate the roaring fixtures", + ); std::fs::create_dir_all(&dir).unwrap(); let base = 1_099_511_627_776u64; // 2^40 // (A) sparse → array containers, multiple high-32 keys: base + i*9_000_000, i in 0..600.