From 1c6d9cfd62eddd6e7028b37c52c5f92ad1555437 Mon Sep 17 00:00:00 2001 From: Aditya Mukhopadhyay Date: Tue, 13 Oct 2026 11:25:29 +0530 Subject: [PATCH] test(index): cover lookup_vaet_ref with a fixed unit test Only proptest-generated queries reached lookup_vaet_ref, when one happened to plan [?e ?a ] first. On runs where none did, src/storage/index.rs fell to 88% lines against its 92% floor, failing the coverage gate on a corpus-only PR (#563). A unit test now checks that the VAET lookup returns exactly the refs to its target. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0182dkj73849VS8eeGFFHXbW --- CLAUDE.md | 2 +- README.md | 2 +- docs/TEST_COVERAGE.md | 2 +- src/storage/index.rs | 44 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index d14476e071..627a89d63b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -174,7 +174,7 @@ Auto-migrates v1/v2/v3/v4/v5/v6 → v7 on open/checkpoint. ## Test Coverage -**1250 tests** (1241 passing, 9 ignored; unit + integration + doc). +**1251 tests** (1242 passing, 9 ignored; unit + integration + doc). See `docs/TEST_COVERAGE.md` for the full per-file breakdown. **Testing conventions** — see the Testing Conventions section below before writing any tests. diff --git a/README.md b/README.md index 9232f34a50..3171f0c592 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ let r2 = pq.execute(&[("tx", BindValue::TxCount(2)), ("entity", BindValue::Entit ```bash cargo run # interactive Datalog REPL -cargo test # run 1250 tests +cargo test # run 1251 tests cargo run < demos/demo_recursive.txt # recursive rules demo ``` diff --git a/docs/TEST_COVERAGE.md b/docs/TEST_COVERAGE.md index 8ef6a1a4c2..b7d09c5ede 100644 --- a/docs/TEST_COVERAGE.md +++ b/docs/TEST_COVERAGE.md @@ -4,7 +4,7 @@ **Verified**: 2026-10-11 with `cargo test` -**Result**: 1,241 passing tests and 9 ignored tests (1,250 total), including the golden-file corpus (#391) +**Result**: 1,242 passing tests and 9 ignored tests (1,251 total), including the golden-file corpus (#391) For v2.0.5, `tests/edge_cases_test.rs` checks that a file of 1 to 4,095 bytes is `STG-045`, unchanged and with no WAL, when it is a database cut below one page or foreign bytes, and opens as a new database that takes a write and reads it back after reopen when it is a prefix of the initial header or all zeros (#506). diff --git a/src/storage/index.rs b/src/storage/index.rs index 26047cd0ca..0ccff43e16 100644 --- a/src/storage/index.rs +++ b/src/storage/index.rs @@ -467,6 +467,50 @@ mod tests { assert_eq!(indexes.vaet.len(), 1); } + /// `lookup_vaet_ref` was covered only when a proptest query happened to + /// plan `[?e ?a ]` first, so the coverage gate flaked (#563). + #[test] + fn test_lookup_vaet_ref_returns_only_refs_to_target() { + let alice = Uuid::new_v4(); + let bob = Uuid::new_v4(); + let target = Uuid::new_v4(); + let other = Uuid::new_v4(); + let mut indexes = Indexes::new(); + let facts = [ + (alice, ":friend", target, 1), + (bob, ":manager", target, 2), + (alice, ":friend", other, 3), + ]; + for (source, attr, ref_target, page_id) in facts { + let fact = Fact::with_valid_time( + source, + attr.to_string(), + Value::Ref(ref_target), + 0, + page_id, + 0, + VALID_TIME_FOREVER, + ); + indexes.insert( + &fact, + FactRef { + page_id, + slot_index: 0, + }, + ); + } + + let mut pages: Vec = indexes + .lookup_vaet_ref(target) + .iter() + .map(|r| r.page_id) + .collect(); + pages.sort_unstable(); + assert_eq!(pages, vec![1, 2]); + assert_eq!(indexes.lookup_vaet_ref(other).len(), 1); + assert!(indexes.lookup_vaet_ref(Uuid::new_v4()).is_empty()); + } + #[test] fn test_indexes_insert_populates_all_four() { let entity = Uuid::new_v4();