MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / named_edge_count

Function named_edge_count

tests/test_pipeline.c:1095–1120  ·  view source on GitHub ↗

Count only edges of `edge_type` between the exact named source/target nodes. * The parity and incremental guards deliberately use unique symbol names, so * this canonicalizes across independent stores without depending on node IDs * or project-prefixed qualified names. */

Source from the content-addressed store, hash-verified

1093 * this canonicalizes across independent stores without depending on node IDs
1094 * or project-prefixed qualified names. */
1095static int named_edge_count(cbm_store_t *s, const char *project, const char *edge_type,
1096 const char *source_name, const char *target_name) {
1097 cbm_edge_t *edges = NULL;
1098 int edge_count = 0;
1099 if (cbm_store_find_edges_by_type(s, project, edge_type, &edges, &edge_count) != CBM_STORE_OK) {
1100 return -1;
1101 }
1102
1103 int matches = 0;
1104 for (int i = 0; i < edge_count; i++) {
1105 cbm_node_t source = {0};
1106 cbm_node_t target = {0};
1107 int source_ok = cbm_store_find_node_by_id(s, edges[i].source_id, &source) == CBM_STORE_OK;
1108 int target_ok = cbm_store_find_node_by_id(s, edges[i].target_id, &target) == CBM_STORE_OK;
1109 if (source_ok && target_ok && source.name && target.name &&
1110 strcmp(source.name, source_name) == 0 && strcmp(target.name, target_name) == 0) {
1111 matches++;
1112 }
1113 cbm_node_free_fields(&source);
1114 cbm_node_free_fields(&target);
1115 }
1116 if (edges) {
1117 cbm_store_free_edges(edges, edge_count);
1118 }
1119 return matches;
1120}
1121
1122/* Like named_edge_count, but distinguish same-named targets by their source
1123 * file. Semantic-control fixtures intentionally keep the exported short name

Callers 3

observe_named_edgeFunction · 0.85
test_pipeline.cFile · 0.85

Calls 4

cbm_node_free_fieldsFunction · 0.85
cbm_store_free_edgesFunction · 0.85

Tested by

no test coverage detected