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
Merge remote-tracking branch 'origin/main' into fix/c-typedefs-macros-enumerators
Martin Vogel1991bf109a17
diff --cc internal/cbm/cbm.hindex 4bb02a22a,dc89a6b2d..0058f0a51--- a/internal/cbm/cbm.h+++ b/internal/cbm/cbm.h@@@ -246,16 -246,10 +246,20 @@@ typedef struct* HTTP_CALLS edge to base + path. Tail fields: zero-init stays valid. */const char *http_client;const char *http_base_url;+ /* Set when this FILE holds two or more definitions with this QN and label+ * (`#if`/`#else` twins, a macro redefined per platform, overloads): the+ * graph keeps one node per QN, and this lists every one of those+ * definitions' line spans, the surviving one included, as a JSON array+ * sorted by start line: [{"start":10,"end":14},{"start":20,"end":26}].+ * Carried by the definition the graph keeps for the file (the last by+ * start line), which makes it the node's `variants` property. NULL on+ * every other definition, and in every language outside+ * cbm_is_c_preprocessor_lang. */+ const char *variants;+ /* Callable identity (#2061): offset of the signature suffix inside+ * qualified_name (base QN = the first qn_sig_off bytes); 0 = no suffix.+ * Always 0 until a language enables its callable_identity mode. */+ uint32_t qn_sig_off;} CBMDefinition;/* Argument captured from a call expression */diff --cc src/mcp/mcp.cindex c95cf5b12,aee17e797..1fe774c71--- a/src/mcp/mcp.c+++ b/src/mcp/mcp.c@@@ -12876,63 -13016,38 +13027,55 @@@ static char *handle_get_code_snippet(cbreturn result;}+ /* Tier 1b: a bare base QN names every signature-qualified overload of it+ * (#2061). Finds nothing for QNs without a callable identity suffix. */+ cbm_node_t *tier_nodes = NULL;+ int tier_count = 0;+ cbm_store_find_nodes_by_qn_base(store, effective_project, qn, false, &tier_nodes, &tier_count);+ char *result =+ snippet_from_tier(srv, tier_nodes, tier_count, qn, "base", include_neighbors, args);+/* Tier 2: Suffix match — handles partial QNs ("main.HandleRequest")* and short names ("ProcessOrder") via LIKE '%.X'. */- cbm_node_t *suffix_nodes = NULL;- int suffix_count = 0;- cbm_store_find_nodes_by_qn_suffix(store, effective_project, qn, &suffix_nodes, &suffix_count);+ if (!result) {+ tier_nodes = NULL;+ tier_count = 0;+ cbm_store_find_nodes_by_qn_suffix(store, effective_project, qn, &tier_nodes, &tier_count);+ result =+ snippet_from_tier(srv, tier_nodes, tier_count, qn, "suffix", include_neighbors, args);+ }++ /* Tier 2b: the partial/short form of Tier 1b ("Session.upload"). */+ if (!result) {+ tier_nodes = NULL;+ tier_count = 0;+ cbm_store_find_nodes_by_qn_base(store, effective_project, qn, true, &tier_nodes,+ &tier_count);+ result =+ snippet_from_tier(srv, tier_nodes, tier_count, qn, "suffix", include_neighbors, args);+ }++ /* Tier 3: the C-macro namespace. A macro's QN is `<module>.<NAME>#macro`+ * (CBM_MACRO_QN_SUFFIX), out of reach of '%.X'. Tried only when no+ * definition answered to the name above (tie rule), for a short name, a+ * partial QN, or the macro's plain QN. */- char macro_qn[CBM_SZ_512];- int macro_len = snprintf(macro_qn, sizeof(macro_qn), "%s" CBM_MACRO_QN_SUFFIX, qn);- if (suffix_count == 0 && macro_len > 0 && (size_t)macro_len < sizeof(macro_qn)) {- cbm_store_free_nodes(suffix_nodes, suffix_count);- suffix_nodes = NULL;- cbm_store_find_nodes_by_qn_suffix(store, effective_project, macro_qn, &suffix_nodes,- &suffix_count);- }-- if (suffix_count == SKIP_ONE) {- copy_node(&suffix_nodes[0], &node);- cbm_store_free_nodes(suffix_nodes, suffix_count);- char *result =- build_snippet_response(srv, &node, "suffix", include_neighbors, NULL, 0, args);- free_node_contents(&node);- free(qn);- free(project);- return result;- }-- if (suffix_count > SKIP_ONE) {- /* Prefer the real definition (a .c body over a .h declaration, a Function- * over a Module) so an unambiguous-by-preference match resolves directly- * instead of forcing a disambiguation round trip; only a genuine tie still- * returns suggestions. */- bool snip_ambiguous = false;- int ssel = pick_resolved_node(suffix_nodes, suffix_count, &snip_ambiguous);- if (!snip_ambiguous) {- copy_node(&suffix_nodes[ssel], &node);- cbm_store_free_nodes(suffix_nodes, suffix_count);- char *result =- build_snippet_response(srv, &node, "suffix", include_neighbors, NULL, 0, args);- free_node_contents(&node);- free(qn);- free(project);- return result;++ if (!result) {++ char macro_qn[CBM_SZ_512];++ int macro_len = snprintf(macro_qn, sizeof(macro_qn), "%s" CBM_MACRO_QN_SUFFIX, qn);++ if (macro_len > 0 && (size_t)macro_len < sizeof(macro_qn)) {++ tier_nodes = NULL;++ tier_count = 0;++ cbm_store_find_nodes_by_qn_suffix(store, effective_project, macro_qn, &tier_nodes,++ &tier_count);++ result = snippet_from_tier(srv, tier_nodes, tier_count, qn, "suffix", include_neighbors,++ args);+ }- char *result = snippet_suggestions(qn, suffix_nodes, suffix_count);- cbm_store_free_nodes(suffix_nodes, suffix_count);- free(qn);- free(project);- return result;+ }-- cbm_store_free_nodes(suffix_nodes, suffix_count);free(qn);free(project);+ if (result) {+ return result;+ }/* Nothing found — guide the caller toward search_graph */return cbm_mcp_text_result(diff --cc src/pipeline/registry.cindex 5b5e79df0,ff56a41ac..d07d2ccf7--- a/src/pipeline/registry.c+++ b/src/pipeline/registry.c@@@ -943,17 -960,24 +960,26 @@@ void cbm_registry_add(cbm_registry_t *r* their dotted form would only widen the bucket the scorer walks.** `name` is NULL or empty only for callers that have no symbol name to- * give; those have the derived key and nothing else. */+ * give; those have the derived key and nothing else.+ *+ * A signature-qualified callable (#2061) is indexed by its bare `name` in+ * place of the derived key, so every overload shares one bucket; any other+ * QN keeps its historical last-segment key. */const char *derived = simple_name(qualified_name);- index_under_name(r, derived, owned_qn);+ const char *primary =+ name && cbm_qn_callable_base_len_named(owned_qn, name) < strlen(owned_qn) ? name : derived;+ index_under_name(r, primary, owned_qn);/* '#' is a QN fence, and extract_defs.c's rust_cfg_qualified_name is the- * only thing in the tree that mints one today. A grammar that starts+ * only thing in the tree that mints one on a REGISTERED symbol today (a C+ * macro's QN ends in "#macro", but Macro is no registry label, so it never+ * gets here). A grammar that starts* minting a '#' opts into this second key by doing so, whatever it means by* the fence: its symbols become reachable under the passed name as well,- * and they share that name's bucket with everything else filed under it. */- if (name && name[0] && strchr(derived, '#') && strcmp(name, derived) != 0) {+ * and they share that name's bucket with everything else filed under it.+ * The passed name is compared with the key already written: a+ * signature-qualified callable is filed under `name` already, and its+ * capped suffix may carry a '#' of its own. */+ if (name && name[0] && strchr(derived, '#') && strcmp(name, primary) != 0) {index_under_name(r, name, owned_qn);}}