mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-04 10:48:20 +00:00
fix: address self-review findings — keep node_degree CALLS-only
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>
This commit is contained in:
2 files changed
+7
-12
No files matched your search
+2
-4
@@ -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) {
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in new issue
Block a user