From a9c4423b8218040757d6838d96cfa4bdaf947ca8 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 29 Apr 2026 09:50:58 +0000 Subject: [PATCH] Strengthen cleanup-then-optimize sequencing test with postconditions Reviewer feedback on PR #62: the original `cleanup_then_optimize_succeed_in_sequence` only unwrapped both calls and asserted nothing, so it didn't validate the claimed sequencing behavior. The concern that motivates the test is that cleanup destroys version history and optimize on a freshly-cleaned table could trip on dropped fragment refs or stale manifests. Rename to `cleanup_then_optimize_preserves_rows_and_table_remains_writable` and add three concrete postconditions: row counts in both Person and Company tables survive the sequence; the head remains readable; and a subsequent merge load still succeeds. --- crates/omnigraph/tests/maintenance.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/omnigraph/tests/maintenance.rs b/crates/omnigraph/tests/maintenance.rs index 8bbbe52..6bb81f2 100644 --- a/crates/omnigraph/tests/maintenance.rs +++ b/crates/omnigraph/tests/maintenance.rs @@ -123,10 +123,21 @@ async fn cleanup_older_than_zero_preserves_head() { } #[tokio::test] -async fn cleanup_then_optimize_succeed_in_sequence() { +async fn cleanup_then_optimize_preserves_rows_and_table_remains_writable() { + // Cleanup destroys version history; the concern is that subsequent + // optimize on a freshly-cleaned table could trip over dropped fragment + // refs or stale manifests. Assert the sequence preserves row content, + // leaves head readable, and doesn't break a subsequent write. let dir = tempfile::tempdir().unwrap(); let mut db = init_and_load(&dir).await; + let people_before = count_rows(&db, "node:Person").await; + let companies_before = count_rows(&db, "node:Company").await; + assert!( + people_before > 0 && companies_before > 0, + "fixture should seed both Person and Company rows" + ); + db.cleanup(CleanupPolicyOptions { keep_versions: Some(1), older_than: None, @@ -134,4 +145,12 @@ async fn cleanup_then_optimize_succeed_in_sequence() { .await .unwrap(); db.optimize().await.unwrap(); + + // Head is preserved through both ops. + assert_eq!(count_rows(&db, "node:Person").await, people_before); + assert_eq!(count_rows(&db, "node:Company").await, companies_before); + + // Table is still writable after the cleanup+optimize sequence. + load_jsonl(&mut db, TEST_DATA, LoadMode::Merge).await.unwrap(); + assert_eq!(count_rows(&db, "node:Person").await, people_before); }