Skip to content

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.

fix: address self-review findings — keep node_degree CALLS-only

Matt Van Horn0714e4634672
diff --git a/src/store/store.c b/src/store/store.c
index c644390fe..995f6e85c 100644
--- a/src/store/store.c
+++ b/src/store/store.c
@@ -1789,8 +1789,7 @@ void cbm_store_node_degree(cbm_store_t *s, int64_t node_id, int *in_deg, int *ou
*in_deg = 0;
*out_deg = 0;
- const char *in_sql = "SELECT COUNT(*) FROM edges WHERE target_id = ?1 AND "
- "type IN ('CALLS', 'USAGE', 'INHERITS', 'IMPLEMENTS')";
+ const char *in_sql = "SELECT COUNT(*) FROM edges WHERE target_id = ?1 AND type = 'CALLS'";
sqlite3_stmt *stmt = NULL;
if (sqlite3_prepare_v2(s->db, in_sql, CBM_NOT_FOUND, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_int64(stmt, SKIP_ONE, node_id);
@@ -1800,8 +1799,7 @@ void cbm_store_node_degree(cbm_store_t *s, int64_t node_id, int *in_deg, int *ou
sqlite3_finalize(stmt);
}
- const char *out_sql = "SELECT COUNT(*) FROM edges WHERE source_id = ?1 AND "
- "type IN ('CALLS', 'USAGE', 'INHERITS', 'IMPLEMENTS')";
+ const char *out_sql = "SELECT COUNT(*) FROM edges WHERE source_id = ?1 AND type = 'CALLS'";
if (sqlite3_prepare_v2(s->db, out_sql, CBM_NOT_FOUND, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_int64(stmt, SKIP_ONE, node_id);
if (sqlite3_step(stmt) == SQLITE_ROW) {
diff --git a/tests/test_store_search.c b/tests/test_store_search.c
index fc8bff561..5cbf1a199 100644
--- a/tests/test_store_search.c
+++ b/tests/test_store_search.c
@@ -274,8 +274,7 @@ TEST(store_search_degree_counts_inherits) {
ASSERT_GT(parent_id, 0);
const char *child_names[] = {"AttachmentDtoA", "AttachmentDtoB", "AttachmentDtoC"};
- const char *child_qns[] = {"test.AttachmentDtoA", "test.AttachmentDtoB",
- "test.AttachmentDtoC"};
+ const char *child_qns[] = {"test.AttachmentDtoA", "test.AttachmentDtoB", "test.AttachmentDtoC"};
for (int i = 0; i < 3; i++) {
cbm_node_t child = {.project = "test",
.label = "Class",
@@ -283,17 +282,15 @@ TEST(store_search_degree_counts_inherits) {
.qualified_name = child_qns[i]};
int64_t child_id = cbm_store_upsert_node(s, &child);
ASSERT_GT(child_id, 0);
- cbm_edge_t edge = {.project = "test",
- .source_id = child_id,
- .target_id = parent_id,
- .type = "INHERITS"};
+ cbm_edge_t edge = {
+ .project = "test", .source_id = child_id, .target_id = parent_id, .type = "INHERITS"};
ASSERT_GT(cbm_store_insert_edge(s, &edge), 0);
}
int in_deg = 0;
int out_deg = 0;
cbm_store_node_degree(s, parent_id, &in_deg, &out_deg);
- ASSERT_EQ(in_deg, 3);
+ ASSERT_EQ(in_deg, 0);
ASSERT_EQ(out_deg, 0);
cbm_search_params_t params = {
@@ -345,7 +342,7 @@ TEST(store_search_degree_calls_plus_inherits_no_double_count) {
int out_deg = 0;
cbm_store_node_degree(s, child_id, &in_deg, &out_deg);
ASSERT_EQ(in_deg, 0);
- ASSERT_EQ(out_deg, 2);
+ ASSERT_EQ(out_deg, 1);
cbm_search_params_t params = {
.project = "test", .label = "Class", .min_degree = -1, .max_degree = -1};