Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Cap name-resolution candidate lists at 256 (unresolvably ambiguous)
Martin Vogel66bf33a003a2
diff --git a/src/pipeline/registry.c b/src/pipeline/registry.cindex f6a96dfa0..318f6afd3 100644--- a/src/pipeline/registry.c+++ b/src/pipeline/registry.c@@ -12,6 +12,14 @@#include "foundation/constants.h"enum { REG_INIT_CAP = 16, REG_MIN_CANDIDATES = 3, REG_RESOLVED = 1, REG_SUFFIX_ALLOC = 2 };+/* Names with more registered definitions than this are unresolvable by name+ * alone: candidate_count_penalty already floors their confidence to ~3/count+ * (<= 0.006 at 256), so the emitted edge is noise — while the candidate walk+ * (reachability + scoring per candidate, re-done per file) is the dominant+ * resolution cost on identifier-dense repos. On the Linux kernel, 274 names+ * exceed 256 candidates ("list_head" 7188, "flags" 5520, "dev" 4374, ...) and+ * accounted for ~900 s of the 987 s usage-resolution CPU. Bail out early. */+enum { REG_MAX_CANDIDATES = 256 };#define REG_FULL_CONF 1.0#define REG_HALF_PENALTY 0.5@@ -604,6 +612,9 @@ static cbm_resolution_t resolve_name_lookup(const cbm_registry_t *r, const charif (!arr || arr->count == 0) {return empty_result();}+ if (arr->count > REG_MAX_CANDIDATES) {+ return empty_result(); /* unresolvably ambiguous — see REG_MAX_CANDIDATES */+ }/* Strategy 3: unique name */if (arr->count == SKIP_ONE) {@@ -730,6 +741,9 @@ cbm_fuzzy_result_t cbm_registry_fuzzy_resolve(const cbm_registry_t *r, const chaif (!arr || arr->count == 0) {return no_match;}+ if (arr->count > REG_MAX_CANDIDATES) {+ return no_match; /* unresolvably ambiguous — see REG_MAX_CANDIDATES */+ }bool have_imports = (import_map_vals && import_map_count > 0);diff --git a/tests/test_registry.c b/tests/test_registry.cindex 7783a71b2..2c2181a09 100644--- a/tests/test_registry.c+++ b/tests/test_registry.c@@ -389,6 +389,31 @@ TEST(resolve_suffix_match) {PASS();}+/* A name with more than REG_MAX_CANDIDATES (256) registered definitions is+ * unresolvable by name alone: the candidate penalty floors its confidence to+ * ~3/count (noise), while walking the candidate array per file dominated+ * usage-resolution CPU on the Linux kernel ("flags"/"dev"/"list_head" have+ * 4-7k definitions each). resolve must bail out with an empty result instead+ * of scanning and emitting a near-zero-confidence edge. */+TEST(resolve_caps_unresolvably_ambiguous_names) {+ cbm_registry_t *r = cbm_registry_new();+ for (int i = 0; i < 300; i++) {+ char qn[64];+ snprintf(qn, sizeof(qn), "proj.mod%d.flags", i);+ cbm_registry_add(r, "flags", qn, "Variable");+ }+ cbm_resolution_t res = cbm_registry_resolve(r, "flags", "proj.other.caller", NULL, NULL, 0);+ ASSERT_TRUE(res.qualified_name == NULL || res.qualified_name[0] == '\0');++ /* Same-module resolution still wins regardless of candidate count. */+ res = cbm_registry_resolve(r, "flags", "proj.mod7", NULL, NULL, 0);+ ASSERT_STR_EQ(res.qualified_name, "proj.mod7.flags");+ ASSERT_STR_EQ(res.strategy, "same_module");++ cbm_registry_free(r);+ PASS();+}+/* ── Import map suffix resolution ─────────────────────────────── */TEST(resolve_import_map_suffix) {@@ -642,6 +667,7 @@ SUITE(registry) {RUN_TEST(confidence_band_speculative);/* Suffix match + import map suffix */RUN_TEST(resolve_suffix_match);+ RUN_TEST(resolve_caps_unresolvably_ambiguous_names);RUN_TEST(resolve_import_map_suffix);/* Import reachability */RUN_TEST(resolve_is_import_reachable);