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

Function pick_resolved_node

src/mcp/mcp.c:9161–9192  ·  view source on GitHub ↗

Pick the best-resolving node among name matches. Sets *ambiguous when the * matches can't be reduced to one logical symbol, so resolution never silently * traces (or conflates) the wrong same-named node: * 1. the top score is shared by >1 candidate (a genuine rank/span tie), or * 2. two or more *real* callable definitions share the name — distinct * implementations, not a definition

Source from the content-addressed store, hash-verified

9159 * unioned by bfs_union_same_name (#546) into one confidently-conflated answer.
9160 * Body-less .d.ts stubs still union with their implementation (#650). */
9161static int pick_resolved_node(const cbm_node_t *nodes, int count, bool *ambiguous) {
9162 *ambiguous = false;
9163 if (count <= 1) {
9164 return 0;
9165 }
9166 int best = 0;
9167 long best_score = node_resolution_score(&nodes[0]);
9168 for (int i = 1; i < count; i++) {
9169 long s = node_resolution_score(&nodes[i]);
9170 if (s > best_score) {
9171 best_score = s;
9172 best = i;
9173 }
9174 }
9175 int top_count = 0;
9176 int real_def_count = 0;
9177 for (int i = 0; i < count; i++) {
9178 if (node_resolution_score(&nodes[i]) == best_score) {
9179 top_count++;
9180 }
9181 if (node_is_real_callable_def(&nodes[i])) {
9182 real_def_count++;
9183 }
9184 }
9185 if (real_def_count > 1) {
9186 *ambiguous = true;
9187 }
9188 if (top_count > 1) {
9189 *ambiguous = true;
9190 }
9191 return best;
9192}
9193
9194static int node_hop_cmp_hop_id(const void *pa, const void *pb) {
9195 const cbm_node_hop_t *a = (const cbm_node_hop_t *)pa;

Callers 2

handle_trace_call_pathFunction · 0.85
snippet_from_tierFunction · 0.85

Calls 2

node_resolution_scoreFunction · 0.85

Tested by

no test coverage detected