Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(dump): detect sparse absolute persistence loss
Martin Vogelffc29f73bb27
diff --git a/src/foundation/dump_verify.c b/src/foundation/dump_verify.cindex c4275592f..1b3ed7c25 100644--- a/src/foundation/dump_verify.c+++ b/src/foundation/dump_verify.c@@ -17,12 +17,15 @@ bool cbm_dump_verify_is_degraded(int committed_nodes, int persisted_nodes, doublif (committed_nodes < 0) {return false;}- if (committed_nodes <= min_floor) {- return false;- }if (persisted_nodes < 0) {return true;}+ if (committed_nodes > 0 && persisted_nodes == 0) {+ return true;+ }+ if (committed_nodes <= min_floor) {+ return false;+ }return (double)persisted_nodes < (double)committed_nodes * ratio;}diff --git a/src/foundation/dump_verify.h b/src/foundation/dump_verify.hindex 8b7f67571..f5ab8f8e7 100644--- a/src/foundation/dump_verify.h+++ b/src/foundation/dump_verify.h@@ -20,7 +20,8 @@ enum { CBM_DUMP_VERIFY_MIN_FLOOR = 50 };* True when persisted_nodes is implausibly below committed_nodes.** Returns false when ratio <= 0 (gate disabled), committed_nodes < 0 (no dump),- * committed_nodes <= min_floor (sparse repo), or persisted >= committed * ratio.+ * or persisted >= committed * ratio. Sparse repositories skip the ratio gate,+ * but complete persistence loss is degraded for every positive committed count.* Returns true when persisted_nodes < 0 (count error).*/bool cbm_dump_verify_is_degraded(int committed_nodes, int persisted_nodes, double ratio,diff --git a/tests/test_dump_verify.c b/tests/test_dump_verify.cindex 9b4ad98f3..b907f3557 100644--- a/tests/test_dump_verify.c+++ b/tests/test_dump_verify.c@@ -22,6 +22,11 @@ TEST(dump_verify_sparse_at_floor) {PASS();}+TEST(dump_verify_sparse_zero_persisted) {+ ASSERT_TRUE(cbm_dump_verify_is_degraded(12, 0, 0.5, CBM_DUMP_VERIFY_MIN_FLOOR));+ PASS();+}+TEST(dump_verify_shortfall_below_ratio) {ASSERT_TRUE(cbm_dump_verify_is_degraded(1000, 400, 0.5, CBM_DUMP_VERIFY_MIN_FLOOR));PASS();@@ -54,6 +59,7 @@ TEST(dump_verify_count_error) {TEST(dump_verify_ratio_zero_disables) {ASSERT_FALSE(cbm_dump_verify_is_degraded(1000, 10, 0.0, CBM_DUMP_VERIFY_MIN_FLOOR));+ ASSERT_FALSE(cbm_dump_verify_is_degraded(12, 0, 0.0, CBM_DUMP_VERIFY_MIN_FLOOR));PASS();}@@ -76,6 +82,7 @@ TEST(dump_verify_edges_shrank_nodes_ok) {SUITE(dump_verify) {RUN_TEST(dump_verify_no_baseline);RUN_TEST(dump_verify_sparse_at_floor);+ RUN_TEST(dump_verify_sparse_zero_persisted);RUN_TEST(dump_verify_shortfall_below_ratio);RUN_TEST(dump_verify_just_above_ratio);RUN_TEST(dump_verify_just_below_ratio);