Skip to content

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.

Merge origin/main into fix/java-record-accessor-calls

Martin Vogel2aaef231114a
diff --cc src/pipeline/pass_calls.c
index c4c14df99,b9cc89c5b..1df1fe155
--- a/src/pipeline/pass_calls.c
+++ b/src/pipeline/pass_calls.c
@@@ -868,6 -875,198 +875,203 @@@ static const cbm_gbuf_node_t *calls_fin
return src;
}
+ static CBMCallEvidence *calls_evidence_at(CBMCallEvidence *evidence, int index,
+ CBMCallEvidence *fallback) {
+ if (evidence) {
+ return &evidence[index];
+ }
+ return fallback;
+ }
+
+ static CBMCallEvidence *calls_evidence_new(cbm_pipeline_t *pipeline, const CBMFileResult *result) {
+ CBMCallEvidence *evidence =
+ cbm_calloc(CBM_MEM_CLASS_RESOLVE, (size_t)result->calls.count * sizeof(*evidence));
+ if (!evidence) {
+ cbm_pipeline_mark_unresolved_capture_failed(pipeline);
+ }
+ return evidence;
+ }
+
+ /* Report whether a service spelling handled this call, independently of
+ * whether its classified edge is CALLS and therefore covers the occurrence. */
+ static bool calls_emit_service_call(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
+ const cbm_gbuf_node_t *source_node, cbm_svc_kind_t svc,
+ const cbm_resolution_t *resolved, CBMCallEvidence *evidence) {
+ if (svc != CBM_SVC_HTTP && svc != CBM_SVC_ASYNC) {
+ return false;
+ }
+ const char *url = call->first_string_arg;
+ if (!url || !url[0]) {
+ return false;
+ }
+ bool has_url_or_topic = url[0] == '/' || strstr(url, "://") != NULL ||
+ (svc == CBM_SVC_ASYNC && strlen(url) > PAIR_LEN);
+ if (!has_url_or_topic) {
+ return false;
+ }
+ cbm_resolution_t fallback = {.qualified_name = call->callee_name,
+ .confidence = PC_SVC_PATTERN_CONF,
+ .strategy = "service_pattern",
+ .candidate_count = 0};
+ const cbm_resolution_t *res = resolved ? resolved : &fallback;
+ evidence->calls_emitted |= emit_http_async_edge(ctx, call, source_node, NULL, res, svc, false);
+ return true;
+ }
+
+ /* Route registration counts as handled even when its edge is not CALLS. */
+ static bool calls_emit_route_call(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
+ const cbm_gbuf_node_t *source_node, const char *module_qn,
+ const char **imp_keys, const char **imp_vals, int imp_count,
+ const char *route_mount, CBMLanguage lang,
+ CBMCallEvidence *evidence) {
+ if (cbm_service_pattern_route_method(call->callee_name) == NULL || !call->first_string_arg ||
+ call->first_string_arg[0] != '/') {
+ return false;
+ }
+ evidence->calls_emitted |= handle_route_registration(
+ ctx, call, source_node, module_qn, imp_keys, imp_vals, imp_count, route_mount, lang);
+ return true;
+ }
+
+ /* An external callee can still register a route or address an HTTP/async service. */
+ static int calls_emit_unresolved_service(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
+ const cbm_gbuf_node_t *source_node, const char *module_qn,
+ const char **imp_keys, const char **imp_vals,
+ int imp_count, const char *route_mount, CBMLanguage lang,
+ CBMCallEvidence *evidence) {
+ if (calls_emit_route_call(ctx, call, source_node, module_qn, imp_keys, imp_vals, imp_count,
+ route_mount, lang, evidence)) {
+ return SKIP_ONE;
+ }
+ cbm_svc_kind_t svc = cbm_service_pattern_match(call->callee_name);
+ if (svc == CBM_SVC_NONE && cbm_service_pattern_is_global_fetch(call->callee_name)) {
+ svc = CBM_SVC_HTTP;
+ }
+ return calls_emit_service_call(ctx, call, source_node, svc, NULL, evidence);
+ }
+
+ /* Apply the field-call policy after a registry target has been found. */
+ static const cbm_gbuf_node_t *calls_field_target(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
+ const CBMResolvedCallArray *lsp_calls,
+ CBMLanguage lang, const char *rel,
+ const cbm_gbuf_node_t *source_node,
+ const cbm_gbuf_node_t *target_node,
+ bool arrow_bound, cbm_resolution_t *res) {
+ switch (cbm_call_onto_field_policy(lang, call->callee_name, target_node->label,
+ target_node->file_path)) {
+ case CBM_FIELD_CALL_DROP:
+ return NULL;
+ case CBM_FIELD_CALL_BY_OWNER:
+ /* An arrow call was already bound this way by registry resolution. */
+ if (!arrow_bound) {
+ target_node = cbm_pipeline_c_member_call_resolve(
+ lsp_calls, NULL, ctx->gbuf, ctx->registry, ctx->project_name,
+ call->enclosing_func_qn, call->callee_name, cbm_c_member_rule_file(lang, rel), res);
+ }
+ if (!target_node || source_node->id == target_node->id) {
+ return NULL;
+ }
+ break;
+ case CBM_FIELD_CALL_KEEP:
+ break;
+ }
+ return target_node;
+ }
+
+ static bool calls_emit_lsp_target(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
+ const CBMResolvedCall *lsp, bool allow_tail, CBMLanguage lang,
+ const CBMImportArray *imports, const cbm_gbuf_node_t *source_node,
+ const char *module_qn, const char **imp_keys,
+ const char **imp_vals, int imp_count, const char *route_mount,
+ CBMCallEvidence *evidence) {
+ if (!lsp) {
+ return false;
+ }
+ bool exact_external_target =
+ call->requires_lsp_resolution && cbm_pipeline_kotlin_external_target(lang, lsp->callee_qn);
+ const cbm_gbuf_node_t *target_node =
+ exact_external_target ? cbm_pipeline_lsp_target_node_strict(ctx->gbuf, ctx->project_name,
+ lsp->callee_qn, allow_tail)
+ : cbm_pipeline_lsp_target_node(ctx->gbuf, ctx->project_name,
+ lsp->callee_qn, allow_tail);
+ if (!target_node || source_node->id == target_node->id) {
+ return false;
+ }
++ /* LSP textual fallbacks can also name data, as with static imports. The
++ * call is handled: no edge, and no registry fallback after it. */
++ if (cbm_java_suppress_call_to_data_member(lang == CBM_LANG_JAVA, target_node->label)) {
++ return true;
++ }
+ cbm_resolution_t res = {0};
+ /* Keep the canonical graph QN, including project prefixes added by fallback. */
+ res.qualified_name = target_node->qualified_name;
+ res.confidence = lsp->confidence;
+ res.strategy = lsp->strategy;
+ res.candidate_count = PC_SINGLE_CANDIDATE_COUNT;
+ evidence->candidate_qn = target_node->qualified_name;
+ /* Synthetic builtins can still denote a spawn; keep the parallel pass policy. */
+ cbm_pipeline_spawn_t spawn;
+ if (cbm_pipeline_spawn_site(ctx->gbuf, lang, call, imports, &res, &spawn)) {
+ cbm_pipeline_emit_spawn(ctx->gbuf, source_node, call, &spawn);
+ return true;
+ }
+ evidence->calls_emitted |=
+ emit_classified_edge(ctx, call, source_node, target_node, &res, module_qn, imp_keys,
+ imp_vals, imp_count, false, route_mount, lang);
+ return true;
+ }
+
+ /* Vendor receivers and cross-language name guesses cannot bind project calls.
+ * Keep the registry policy shared with the parallel resolver. */
+ static cbm_resolution_t calls_registry_resolution(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
+ const char *module_qn, const char **imp_keys,
+ const char **imp_vals, int imp_count,
+ CBMLanguage lang, bool rust_external,
+ bool php_vendor_call) {
+ cbm_resolution_t res = {0};
+ if (!rust_external && !php_vendor_call) {
+ /* Python LEGB fallback first (MUST match pass_parallel.c). */
+ res =
+ cbm_registry_resolve_call_scoped(ctx->registry, call->callee_name, module_qn, imp_keys,
+ imp_vals, imp_count, lang, call->enclosing_func_qn);
+ /* Cross-language veto: a name-only guess never binds another
+ * language's symbol (a JS app.get must not become Python's
+ * builtins.dict.get). The vetoed answer becomes EMPTY here, before
+ * the fallbacks below, so the route/HTTP classification still runs.
+ * MUST match pass_parallel.c. */
+ if (cbm_registry_name_guess_vetoed(ctx->registry, lang, &res)) {
+ res = (cbm_resolution_t){0};
+ }
+ }
+ return res;
+ }
+
+ static int calls_emit_import_service(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
+ const cbm_gbuf_node_t *source_node, const char *rel,
+ CBMLanguage lang, const CBMImportArray *imports,
+ cbm_external_import_index_t *ext_imports,
+ CBMCallEvidence *evidence) {
+ /* A callee an import binds to an external client library
+ * (`send` under `from paho.mqtt import publish as send`): spelled
+ * through its import, then classified. MUST match pass_parallel.c. */
+ char spelled[CBM_SZ_512];
+ cbm_svc_kind_t isvc =
+ cbm_pipeline_external_import_service(ext_imports, ctx->gbuf, ctx->project_name, rel, lang,
+ imports, call, spelled, sizeof(spelled));
+ if (isvc != CBM_SVC_NONE) {
+ CBMCall through = *call;
+ through.callee_name = spelled;
+ cbm_resolution_t imp_res = {.qualified_name = spelled,
+ .confidence = PC_SVC_PATTERN_CONF,
+ .strategy = "import_binding",
+ .candidate_count = 0};
+ evidence->calls_emitted |=
+ emit_http_async_edge(ctx, &through, source_node, NULL, &imp_res, isvc, false);
+ return SKIP_ONE;
+ }
+ return 0;
+ }
+
/* Resolve one call and emit the appropriate edge. Returns 1 if resolved, 0 if not. */
static int resolve_single_call(cbm_pipeline_ctx_t *ctx, CBMCall *call, const CBMFileResult *result,
const char *rel, const char *module_qn, const char **imp_keys,
@@@ -1236,22 -1330,13 +1335,19 @@@
* unresolved-callee fallback above mints, and nothing else. Dropping
* the whole call lost every GET registration in a mixed-language repo
* while POST (no `post` to collide with) survived. */
- if (cbm_service_pattern_route_method(call->callee_name) != NULL && call->first_string_arg &&
- call->first_string_arg[0] == '/') {
- handle_route_registration(ctx, call, source_node, module_qn, imp_keys, imp_vals,
- imp_count, route_mount, lang);
- return SKIP_ONE;
- }
- return 0;
+ return calls_emit_route_call(ctx, call, source_node, module_qn, imp_keys, imp_vals,
+ imp_count, route_mount, lang, evidence);
}
+ /* A Java call never targets data — see cbm_java_suppress_call_to_data_member.
+ * The language gate lives here, as with the guards above, and MUST match
+ * pass_parallel.c exactly or the two resolvers diverge. */
+ if (cbm_java_suppress_call_to_data_member(lang == CBM_LANG_JAVA, target_node->label)) {
+ return 0;
+ }
- emit_classified_edge(ctx, call, source_node, target_node, &res, module_qn, imp_keys, imp_vals,
- imp_count, drop_plain_call, route_mount, lang);
+ evidence->candidate_qn = target_node->qualified_name;
+ evidence->calls_emitted |=
+ emit_classified_edge(ctx, call, source_node, target_node, &res, module_qn, imp_keys,
+ imp_vals, imp_count, drop_plain_call, route_mount, lang);
return SKIP_ONE;
}
diff --cc src/pipeline/pass_parallel.c
index 597e9ebb6,cc37e7d9b..f69ee219b
--- a/src/pipeline/pass_parallel.c
+++ b/src/pipeline/pass_parallel.c
@@@ -3588,17 -3613,11 +3618,17 @@@ static void resolve_file_calls(resolve_
/* #725: same guard as pass_calls.c — do not emit a suffix_match
* CALLS edge across a language boundary. A route registration
* behind the refused binding still gets its Route. */
- emit_xlang_refused_route(ws->local_edge_buf, source_node, call, module_qn, rc->registry,
- rc->main_gbuf, imp_keys, imp_vals, imp_count, route_mount,
- lang);
+ site_evidence->calls_emitted |= emit_xlang_refused_route(
+ ws->local_edge_buf, source_node, call, module_qn, rc->registry, rc->main_gbuf,
+ imp_keys, imp_vals, imp_count, route_mount, lang);
continue;
}
+ if (target_node && source_node->id != target_node->id &&
+ cbm_java_suppress_call_to_data_member(lang == CBM_LANG_JAVA, target_node->label)) {
+ /* Same guard as pass_calls.c — a Java call never targets a
+ * Variable or a Field. */
+ continue;
+ }
if (!target_node || source_node->id == target_node->id) {
/* HTTP/ASYNC calls to an EXTERNAL client library (`requests.get(url)`)
* resolve to an unindexed QN (target_node == NULL), but their edge