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

Function named_edge_count

tests/test_pipeline.c:1812–1837  ·  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

1810 * this canonicalizes across independent stores without depending on node IDs
1811 * or project-prefixed qualified names. */
1812static int named_edge_count(cbm_store_t *s, const char *project, const char *edge_type,
1813 const char *source_name, const char *target_name) {
1814 cbm_edge_t *edges = NULL;
1815 int edge_count = 0;
1816 if (cbm_store_find_edges_by_type(s, project, edge_type, &edges, &edge_count) != CBM_STORE_OK) {
1817 return -1;
1818 }
1819
1820 int matches = 0;
1821 for (int i = 0; i < edge_count; i++) {
1822 cbm_node_t source = {0};
1823 cbm_node_t target = {0};
1824 int source_ok = cbm_store_find_node_by_id(s, edges[i].source_id, &source) == CBM_STORE_OK;
1825 int target_ok = cbm_store_find_node_by_id(s, edges[i].target_id, &target) == CBM_STORE_OK;
1826 if (source_ok && target_ok && source.name && target.name &&
1827 strcmp(source.name, source_name) == 0 && strcmp(target.name, target_name) == 0) {
1828 matches++;
1829 }
1830 cbm_node_free_fields(&source);
1831 cbm_node_free_fields(&target);
1832 }
1833 if (edges) {
1834 cbm_store_free_edges(edges, edge_count);
1835 }
1836 return matches;
1837}
1838
1839/* HTTP_CALLS edges out of the function `source_name` whose Route target's
1840 * qualified name contains `route_qn_part` (e.g. "__route__GET__"). */

Callers 6

observe_xlang_routeFunction · 0.85
observe_named_edgeFunction · 0.85
test_pipeline.cFile · 0.85
observe_axios_wrapperFunction · 0.85

Calls 4

cbm_node_free_fieldsFunction · 0.85
cbm_store_free_edgesFunction · 0.85

Tested by

no test coverage detected