From 0714e4634672cc7945d3931b963caad8202259ba Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Tue, 23 Jun 2026 04:03:10 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20address=20self-review=20findings=20?= =?UTF-8?q?=E2=80=94=20keep=20node=5Fdegree=20CALLS-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cbm_store_node_degree backs the MCP get_code_snippet callers/callees counts and the Cypher in_degree/out_degree virtual property, which are deliberately CALLS-scoped. Restore it to CALLS-only and scope the INHERITS/IMPLEMENTS broadening to cbm_store_search alone, which is the search_graph surface issue #558 is about. Adjust the new tests so node_degree assertions expect CALLS-only counts while the search_graph result assertions expect the broadened structural degree. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> --- src/store/store.c | 6 ++---- tests/test_store_search.c | 13 +++++-------- 2 files changed, 7 insertions(+), 12 deletions(-) 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};