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
Generalized route registration + infra binding bridge
Martin Vogelafba50e018ca
diff --git a/internal/cbm/cbm.c b/internal/cbm/cbm.cindex f8b8aea5e..70db0ce4d 100644--- a/internal/cbm/cbm.c+++ b/internal/cbm/cbm.c@@ -129,6 +129,11 @@ void cbm_stringref_push(CBMStringRefArray *arr, CBMArena *a, CBMStringRef sr) {arr->items[arr->count++] = sr;}+void cbm_infrabinding_push(CBMInfraBindingArray *arr, CBMArena *a, CBMInfraBinding ib) {+ GROW_ARRAY(arr, a);+ arr->items[arr->count++] = ib;+}+void cbm_impltrait_push(CBMImplTraitArray *arr, CBMArena *a, CBMImplTrait it) {GROW_ARRAY(arr, a);arr->items[arr->count++] = it;diff --git a/internal/cbm/cbm.h b/internal/cbm/cbm.hindex 8049598c0..46f135ba6 100644--- a/internal/cbm/cbm.h+++ b/internal/cbm/cbm.h@@ -177,6 +177,15 @@ typedef struct {CBMStringRefKind kind; // URL, CONFIG} CBMStringRef;+/* Infrastructure binding: topic/queue → endpoint URL.+ * Extracted from YAML/HCL/JSON subscription/scheduler configs.+ * Used by pass_route_nodes to connect async Route nodes to handler services. */+typedef struct {+ const char *source_name; // topic, queue, or schedule name+ const char *target_url; // push_endpoint, uri, or http_target URL+ const char *broker; // "pubsub", "cloud_tasks", "cloud_scheduler", "sqs", "kafka"+} CBMInfraBinding;+// Rust: impl Trait for Structtypedef struct {const char *trait_name; // trait name (raw text)@@ -259,6 +268,12 @@ typedef struct {int cap;} CBMStringRefArray;+typedef struct {+ CBMInfraBinding *items;+ int count;+ int cap;+} CBMInfraBindingArray;+typedef struct {CBMImplTrait *items;int count;@@ -281,6 +296,7 @@ typedef struct {CBMImplTraitArray impl_traits; // Rust: impl Trait for Struct pairsCBMResolvedCallArray resolved_calls; // LSP-resolved calls (high confidence)CBMStringRefArray string_refs; // URL/config string literals from AST+ CBMInfraBindingArray infra_bindings; // topic→URL pairs from IaC configsconst char *module_qn; // module qualified nameconst char **exports; // NULL-terminated (NULL if none)@@ -391,6 +407,7 @@ void cbm_typerefs_push(CBMTypeRefArray *arr, CBMArena *a, CBMTypeRef tr);void cbm_envaccess_push(CBMEnvAccessArray *arr, CBMArena *a, CBMEnvAccess ea);void cbm_typeassign_push(CBMTypeAssignArray *arr, CBMArena *a, CBMTypeAssign ta);void cbm_stringref_push(CBMStringRefArray *arr, CBMArena *a, CBMStringRef sr);+void cbm_infrabinding_push(CBMInfraBindingArray *arr, CBMArena *a, CBMInfraBinding ib);void cbm_impltrait_push(CBMImplTraitArray *arr, CBMArena *a, CBMImplTrait it);void cbm_resolvedcall_push(CBMResolvedCallArray *arr, CBMArena *a, CBMResolvedCall rc);diff --git a/internal/cbm/extract_unified.c b/internal/cbm/extract_unified.cindex a967eca03..4a50faa13 100644--- a/internal/cbm/extract_unified.c+++ b/internal/cbm/extract_unified.c@@ -336,6 +336,171 @@ static void walk_yaml_mapping(CBMExtractCtx *ctx, TSNode node, const char *prefi}}+/* ── Infrastructure binding extraction ─────────────────────────────+ * Scan YAML/JSON/HCL list items for topic→URL pairs.+ * Patterns detected:+ * YAML: {topic: X, config: {push_endpoint: URL}} (Pub/Sub subscription)+ * YAML: {uri: URL, body: ...} (Cloud Scheduler)+ * YAML: {queue: X, uri: URL} (Cloud Tasks)+ * HCL: resource "google_pubsub_subscription" { topic=X, push_config{push_endpoint=URL} }+ *+ * Works by collecting key-value pairs in each mapping, then checking for+ * known source+target patterns. Language-agnostic: the key names are the signal. */++/* Source key names (topic/queue/schedule identifier) */+static int is_source_key(const char *key) {+ return (strcmp(key, "topic") == 0 || strcmp(key, "queue") == 0 ||+ strcmp(key, "queue_name") == 0 || strcmp(key, "subscription") == 0 ||+ strcmp(key, "subject") == 0 || strcmp(key, "channel") == 0 ||+ strcmp(key, "stream") == 0);+}++/* Target key names (endpoint URL) */+static int is_target_key(const char *key) {+ return (strcmp(key, "push_endpoint") == 0 || strcmp(key, "uri") == 0 ||+ strcmp(key, "url") == 0 || strcmp(key, "endpoint") == 0 ||+ strcmp(key, "http_target") == 0 || strcmp(key, "target_url") == 0 ||+ strcmp(key, "webhook_url") == 0 || strcmp(key, "callback_url") == 0);+}++/* Infer broker type from surrounding context */+static const char *infer_broker(const char *file_path, const char *source_key) {+ if (strstr(file_path, "pubsub") || strstr(file_path, "pub-sub") ||+ strstr(file_path, "pub_sub")) {+ return "pubsub";+ }+ if (strstr(file_path, "scheduler") || strstr(file_path, "schedule") ||+ strstr(file_path, "cron")) {+ return "cloud_scheduler";+ }+ if (strstr(file_path, "task") || strcmp(source_key, "queue") == 0 ||+ strcmp(source_key, "queue_name") == 0) {+ return "cloud_tasks";+ }+ if (strstr(file_path, "kafka") || strcmp(source_key, "stream") == 0) {+ return "kafka";+ }+ if (strstr(file_path, "sqs") || strstr(file_path, "sns")) {+ return "sqs";+ }+ return "async";+}++/* Scan a YAML mapping for source+target key pairs.+ * Collects all key-value pairs at this level and one level deep (for nested config:). */+static void scan_mapping_for_bindings(CBMExtractCtx *ctx, TSNode mapping) {+ const char *sources[8] = {NULL};+ const char *source_keys[8] = {NULL};+ int n_sources = 0;+ const char *targets[8] = {NULL};+ int n_targets = 0;++ uint32_t nc = ts_node_named_child_count(mapping);+ for (uint32_t i = 0; i < nc; i++) {+ TSNode pair = ts_node_named_child(mapping, i);+ if (strcmp(ts_node_type(pair), "block_mapping_pair") != 0) {+ continue;+ }+ TSNode key = ts_node_child_by_field_name(pair, "key", 3);+ TSNode val = ts_node_child_by_field_name(pair, "value", 5);+ if (ts_node_is_null(key) || ts_node_is_null(val)) {+ continue;+ }+ char *k = cbm_node_text(ctx->arena, key, ctx->source);+ if (!k) {+ continue;+ }++ /* Check if this is a source or target key with a scalar value */+ const char *vtype = ts_node_type(val);+ if (strcmp(vtype, "block_node") != 0 && strcmp(vtype, "block_mapping") != 0) {+ char *v = cbm_node_text(ctx->arena, val, ctx->source);+ if (v && v[0]) {+ /* Strip quotes */+ int vlen = (int)strlen(v);+ if (vlen >= 2 && (v[0] == '"' || v[0] == '\'')) {+ v = cbm_arena_strndup(ctx->arena, v + 1, (size_t)(vlen - 2));+ }+ if (is_source_key(k) && n_sources < 8) {+ sources[n_sources] = v;+ source_keys[n_sources] = k;+ n_sources++;+ }+ if (is_target_key(k) && n_targets < 8 && v && strstr(v, "://")) {+ targets[n_targets++] = v;+ }+ }+ } else {+ /* Nested mapping (e.g., config: {push_endpoint: URL}) — scan one level */+ uint32_t vnc = ts_node_named_child_count(val);+ for (uint32_t vi = 0; vi < vnc; vi++) {+ TSNode vc = ts_node_named_child(val, vi);+ const char *vck = ts_node_type(vc);+ if (strcmp(vck, "block_mapping") == 0) {+ /* Scan nested mapping for target keys */+ uint32_t mnc = ts_node_named_child_count(vc);+ for (uint32_t mi = 0; mi < mnc; mi++) {+ TSNode mp = ts_node_named_child(vc, mi);+ if (strcmp(ts_node_type(mp), "block_mapping_pair") != 0) {+ continue;+ }+ TSNode mk = ts_node_child_by_field_name(mp, "key", 3);+ TSNode mv = ts_node_child_by_field_name(mp, "value", 5);+ if (ts_node_is_null(mk) || ts_node_is_null(mv)) {+ continue;+ }+ char *mktext = cbm_node_text(ctx->arena, mk, ctx->source);+ if (mktext && is_target_key(mktext) && n_targets < 8) {+ char *mvtext = cbm_node_text(ctx->arena, mv, ctx->source);+ if (mvtext && mvtext[0]) {+ int mvlen = (int)strlen(mvtext);+ if (mvlen >= 2 && (mvtext[0] == '"' || mvtext[0] == '\'')) {+ mvtext = cbm_arena_strndup(ctx->arena, mvtext + 1,+ (size_t)(mvlen - 2));+ }+ if (mvtext && strstr(mvtext, "://")) {+ targets[n_targets++] = mvtext;+ }+ }+ }+ }+ }+ }+ }+ }++ /* Emit bindings for each source × target pair */+ for (int si = 0; si < n_sources; si++) {+ for (int ti = 0; ti < n_targets; ti++) {+ if (!sources[si] || !targets[ti]) {+ continue;+ }+ CBMInfraBinding ib = {+ .source_name = sources[si],+ .target_url = targets[ti],+ .broker = infer_broker(ctx->rel_path, source_keys[si]),+ };+ cbm_infrabinding_push(&ctx->result->infra_bindings, ctx->arena, ib);+ }+ }+}++/* Walk a YAML block_sequence looking for list items with infra bindings */+static void scan_yaml_for_infra_bindings(CBMExtractCtx *ctx, TSNode node) {+ const char *kind = ts_node_type(node);++ /* List items are block_sequence → block_sequence_item → block_mapping */+ if (strcmp(kind, "block_mapping") == 0) {+ scan_mapping_for_bindings(ctx, node);+ }++ /* Recurse into children */+ uint32_t nc = ts_node_named_child_count(node);+ for (uint32_t i = 0; i < nc; i++) {+ scan_yaml_for_infra_bindings(ctx, ts_node_named_child(node, i));+ }+}+/* Handle YAML files: walk top-level block_mapping recursively */static void handle_yaml_nested(CBMExtractCtx *ctx, TSNode node) {if (ctx->language != CBM_LANG_YAML) {@@ -393,6 +558,15 @@ void cbm_extract_unified(CBMExtractCtx *ctx) {handle_string_refs(ctx, node, &state);handle_yaml_nested(ctx, node);+ /* Scan YAML/JSON for infra bindings (topic→URL pairs) */+ if (ctx->language == CBM_LANG_YAML || ctx->language == CBM_LANG_JSON) {+ const char *nk = ts_node_type(node);+ if (strcmp(nk, "block_sequence") == 0 || strcmp(nk, "block_mapping") == 0 ||+ strcmp(nk, "array") == 0 || strcmp(nk, "document") == 0) {+ scan_yaml_for_infra_bindings(ctx, node);+ }+ }+// 4. Push scope markers for boundary nodesif (spec->function_node_types && cbm_kind_in_set(node, spec->function_node_types)) {const char *fqn = compute_func_qn(ctx, node, spec, &state);diff --git a/internal/cbm/service_patterns.c b/internal/cbm/service_patterns.cindex 649de9ef6..eebaeda0d 100644--- a/internal/cbm/service_patterns.c+++ b/internal/cbm/service_patterns.c@@ -393,6 +393,16 @@ static const method_suffix_t route_reg_suffixes[] = {{".MapPost", "POST"},{".MapPut", "PUT"},{".MapDelete", "DELETE"},+ /* Router mounting / prefix registration (any method) */+ {".include_router", "ANY"},+ {".mount", "ANY"},+ {".add_url_rule", "ANY"},+ {".register_blueprint", "ANY"},+ {".use", "ANY"},+ {".register", "ANY"},+ {".add_route", "ANY"},+ {".add_api_route", "ANY"},+ {".add_api_websocket_route", "ANY"},{NULL, NULL},};diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.cindex d9fd961c4..845c33d9a 100644--- a/src/pipeline/pass_parallel.c+++ b/src/pipeline/pass_parallel.c@@ -764,33 +764,102 @@ static void emit_service_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source,cbm_svc_kind_t svc = cbm_service_pattern_match(res->qualified_name);const char *arg = call->first_string_arg;- if (svc == CBM_SVC_ROUTE_REG && arg != NULL && arg[0] == '/') {- const char *method = cbm_service_pattern_route_method(call->callee_name);- char route_qn[CBM_ROUTE_QN_SIZE];- snprintf(route_qn, sizeof(route_qn), "__route__%s__%s", method ? method : "ANY", arg);- char route_props[256];- snprintf(route_props, sizeof(route_props), "{\"method\":\"%s\"}", method ? method : "ANY");- int64_t route_id =- cbm_gbuf_upsert_node(gbuf, "Route", arg, route_qn, "", 0, 0, route_props);- char props[512];- snprintf(props, sizeof(props),- "{\"callee\":\"%s\",\"url_path\":\"%s\",\"via\":\"route_registration\"}",- call->callee_name, arg);- cbm_gbuf_insert_edge(gbuf, source->id, route_id, "CALLS", props);- if (call->second_arg_name != NULL && call->second_arg_name[0] != '\0') {- cbm_resolution_t hres = cbm_registry_resolve(registry, call->second_arg_name, module_qn,- imp_keys, imp_vals, imp_count);- if (hres.qualified_name != NULL && hres.qualified_name[0] != '\0') {- const cbm_gbuf_node_t *handler =- cbm_gbuf_find_by_qn(main_gbuf, hres.qualified_name);- if (handler != NULL) {- char hprops[256];- snprintf(hprops, sizeof(hprops), "{\"handler\":\"%s\"}", hres.qualified_name);- cbm_gbuf_insert_edge(gbuf, handler->id, route_id, "HANDLES", hprops);+ /* Also detect route registration by callee name suffix alone (handles unresolved+ * local variables like app.include_router where QN resolution fails). */+ if (svc == CBM_SVC_NONE && cbm_service_pattern_route_method(call->callee_name) != NULL) {+ svc = CBM_SVC_ROUTE_REG;+ }++ if (svc == CBM_SVC_ROUTE_REG) {+ /* Generalized route registration: find URL path from ANY argument.+ * Handles: router.GET("/path", handler), app.include_router(r, prefix="/path"),+ * app.add_url_rule("/path", view_func=h), app.mount("/path", sub_app), etc.+ * Language-agnostic: any call to a router framework with a path arg. */+ const char *route_path = NULL;+ const char *handler_ref = NULL;++ /* 1. Check first_string_arg (covers router.GET("/path", handler)) */+ if (arg != NULL && arg[0] == '/') {+ route_path = arg;+ handler_ref = call->second_arg_name;+ }++ /* 2. Scan keyword args for path-like values (prefix=, path=, route=, pattern=) */+ if (!route_path) {+ static const char *path_keywords[] = {"prefix", "path", "route", "pattern",+ "url", "endpoint", "rule", "mount_path",+ "route_path", "url_path", NULL};+ for (int ai = 0; ai < call->arg_count && !route_path; ai++) {+ const CBMCallArg *ca = &call->args[ai];+ const char *val = ca->value ? ca->value : ca->expr;+ if (!val || val[0] != '/') {+ continue;+ }+ if (ca->keyword) {+ for (const char **kw = path_keywords; *kw; kw++) {+ if (strcmp(ca->keyword, *kw) == 0) {+ route_path = val;+ break;+ }+ }+ } else if (ca->index == 0) {+ /* First positional arg starting with / is likely a path */+ route_path = val;}}}- return;++ /* 3. Find handler reference from args (first identifier/attribute arg) */+ if (!handler_ref) {+ for (int ai = 0; ai < call->arg_count && !handler_ref; ai++) {+ const CBMCallArg *ca = &call->args[ai];+ if (!ca->expr || ca->expr[0] == '/' || ca->expr[0] == '"' || ca->expr[0] == '\'') {+ continue;+ }+ /* Skip known non-handler keywords */+ if (ca->keyword &&+ (strcmp(ca->keyword, "prefix") == 0 || strcmp(ca->keyword, "name") == 0 ||+ strcmp(ca->keyword, "tags") == 0)) {+ continue;+ }+ handler_ref = ca->expr;+ }+ }++ if (route_path) {+ const char *method = cbm_service_pattern_route_method(call->callee_name);+ char route_qn[CBM_ROUTE_QN_SIZE];+ snprintf(route_qn, sizeof(route_qn), "__route__%s__%s", method ? method : "ANY",+ route_path);+ char route_props[256];+ snprintf(route_props, sizeof(route_props), "{\"method\":\"%s\"}",+ method ? method : "ANY");+ int64_t route_id =+ cbm_gbuf_upsert_node(gbuf, "Route", route_path, route_qn, "", 0, 0, route_props);+ char props[512];+ snprintf(props, sizeof(props),+ "{\"callee\":\"%s\",\"url_path\":\"%s\",\"via\":\"route_registration\"}",+ call->callee_name, route_path);+ cbm_gbuf_insert_edge(gbuf, source->id, route_id, "CALLS", props);++ /* Resolve handler and create HANDLES edge */+ if (handler_ref && handler_ref[0]) {+ cbm_resolution_t hres = cbm_registry_resolve(registry, handler_ref, module_qn,+ imp_keys, imp_vals, imp_count);+ if (hres.qualified_name != NULL && hres.qualified_name[0] != '\0') {+ const cbm_gbuf_node_t *handler =+ cbm_gbuf_find_by_qn(main_gbuf, hres.qualified_name);+ if (handler != NULL) {+ char hprops[256];+ snprintf(hprops, sizeof(hprops), "{\"handler\":\"%s\"}",+ hres.qualified_name);+ cbm_gbuf_insert_edge(gbuf, handler->id, route_id, "HANDLES", hprops);+ }+ }+ }+ return;+ }+ /* No path found — fall through to normal CALLS edge */}int has_url = (arg != NULL && arg[0] != '\0' && (arg[0] == '/' || strstr(arg, "://") != NULL));@@ -927,6 +996,17 @@ static void resolve_worker(int worker_id, void *ctx_ptr) {cbm_resolution_t res = cbm_registry_resolve(rc->registry, call->callee_name, module_qn,imp_keys, imp_vals, imp_count);if (!res.qualified_name || res.qualified_name[0] == '\0') {+ /* Unresolved call — still check for route registration by callee suffix.+ * Handles patterns like app.include_router(r, prefix="/path") where+ * "app" is a local variable that the resolver can't follow. */+ if (cbm_service_pattern_route_method(call->callee_name) != NULL) {+ cbm_resolution_t fake_res = {.qualified_name = call->callee_name,+ .confidence = 0.5,+ .strategy = "callee_suffix"};+ emit_service_edge(ws->local_edge_buf, source_node, source_node, call, &fake_res,+ module_qn, rc->registry, rc->main_gbuf, imp_keys, imp_vals,+ imp_count);+ }continue;}diff --git a/src/pipeline/pass_route_nodes.c b/src/pipeline/pass_route_nodes.cindex 371f22573..e4780438b 100644--- a/src/pipeline/pass_route_nodes.c+++ b/src/pipeline/pass_route_nodes.c@@ -155,14 +155,41 @@ static const char *extract_service_name(const char *url, char *buf, int bufsz) {memcpy(tmp, host_start, (size_t)hlen);tmp[hlen] = '\0';- /* Cloud Run hostname format: service-name-REVHASH-LOCHASH.region.run.app- * Strip last two dash-separated segments (revision + location hashes).- * Hash segments are typically 2-12 alphanumeric characters. */+ /* Cloud Run hostname formats:+ * Old: service-name-REVHASH-LOCHASH.region.run.app (strip 2 segments)+ * New: service-name-PROJECTNUM.region.run.app (strip 1 segment)+ * Hash/project-num segments: short alphanumeric or all-numeric.+ * Never strip a segment that looks like a meaningful word (>3 chars, has letters). */for (int strip = 0; strip < 2; strip++) {char *last_dash = strrchr(tmp, '-');- if (last_dash && strlen(last_dash + 1) <= 12) {- *last_dash = '\0';+ if (!last_dash) {+ break;}+ const char *seg = last_dash + 1;+ size_t slen = strlen(seg);+ if (slen > 12 || slen == 0) {+ break;+ }+ /* Check if segment is all-numeric (GCP project number) or short alphanumeric (hash) */+ int all_alnum = 1;+ int has_letter = 0;+ for (size_t si = 0; si < slen; si++) {+ if (!((seg[si] >= '0' && seg[si] <= '9') || (seg[si] >= 'a' && seg[si] <= 'z'))) {+ all_alnum = 0;+ break;+ }+ if (seg[si] >= 'a' && seg[si] <= 'z') {+ has_letter = 1;+ }+ }+ if (!all_alnum) {+ break;+ }+ /* Don't strip meaningful words (>=3 chars with letters like "api", "endpoint") */+ if (has_letter && slen >= 3) {+ break;+ }+ *last_dash = '\0';}snprintf(buf, (size_t)bufsz, "%s", tmp);@@ -201,13 +228,25 @@ static void match_infra_routes(cbm_gbuf_t *gb) {* and whose route path matches the infra URL path */for (int j = 0; j < route_count; j++) {const cbm_gbuf_node_t *handler_route = all_routes[j];- /* Skip infra routes */- if (handler_route->qualified_name &&- strncmp(handler_route->qualified_name, "__route__", 9) == 0) {+ /* Skip infra/async/broker Route nodes — match only handler/prefix Routes */+ const char *hqn = handler_route->qualified_name;+ if (hqn &&+ (strstr(hqn, "__route__infra__") == hqn ||+ strstr(hqn, "__route__pubsub__") == hqn ||+ strstr(hqn, "__route__cloud_tasks__") == hqn ||+ strstr(hqn, "__route__async__") == hqn ||+ strstr(hqn, "__route__cloud_scheduler__") == hqn ||+ strstr(hqn, "__route__kafka__") == hqn || strstr(hqn, "__route__sqs__") == hqn)) {continue;}- /* Handler route must be in the matching service directory */- if (!handler_route->file_path || !strstr(handler_route->file_path, svc_name)) {+ /* Handler route must be in the matching service directory.+ * Prefix Routes from include_router have no file_path — match by path only. */+ int file_matches = (handler_route->file_path != NULL &&+ strstr(handler_route->file_path, svc_name) != NULL);+ int is_prefix_route =+ (handler_route->qualified_name != NULL &&+ strncmp(handler_route->qualified_name, "__route__ANY__", 14) == 0);+ if (!file_matches && !is_prefix_route) {continue;}@@ -223,14 +262,27 @@ static void match_infra_routes(cbm_gbuf_t *gb) {continue;}- /* Match: infra path starts with handler path or handler path contains infra path */- if (strstr(infra_path, handler_path) != NULL ||- strstr(handler_path, infra_path) != NULL) {- /* Create HANDLES edge: infra Route → handler Route (connecting them) */- cbm_gbuf_insert_edge(gb, infra->id, handler_route->id, "HANDLES",- "{\"source\":\"infra_match\"}");+ /* Match: infra path contains handler path, handler path contains infra path,+ * OR handler is root "/" and service name matches (microservice pattern:+ * each service has one handler at "/", differentiated by hostname). */+ int path_match =+ (strlen(handler_path) > 1 && (strstr(infra_path, handler_path) != NULL ||+ strstr(handler_path, infra_path) != NULL));+ int root_svc_match = (strcmp(handler_path, "/") == 0);+ if (path_match || root_svc_match) {+ /* Find the handler Function that HANDLES this decorator Route */+ const cbm_gbuf_edge_t **fn_handles = NULL;+ int fn_hcount = 0;+ cbm_gbuf_find_edges_by_target_type(gb, handler_route->id, "HANDLES", &fn_handles,+ &fn_hcount);+ for (int fh = 0; fh < fn_hcount; fh++) {+ /* Create HANDLES: handler Function → infra Route+ * This bridges the gap so DATA_FLOWS can find the handler */+ cbm_gbuf_insert_edge(gb, fn_handles[fh]->source_id, infra->id, "HANDLES",+ "{\"source\":\"infra_match\"}");+ }matched++;- break; /* One match per infra route is enough */+ break;}}}@@ -342,12 +394,33 @@ static void create_data_flows(cbm_gbuf_t *gb) {n_callers++;}- /* Collect handler nodes (HANDLES → Route) */+ /* Collect handler nodes: direct HANDLES → Route, plus HANDLES on+ * endpoint Routes reachable via INFRA_MAPS (topic → endpoint → handler) */const cbm_gbuf_edge_t **handles_edges = NULL;int handles_count = 0;cbm_gbuf_find_edges_by_target_type(gb, route->id, "HANDLES", &handles_edges,&handles_count);+ /* Also follow INFRA_MAPS: topic Route → endpoint Route → HANDLES+ * This bridges async topic Routes to their push endpoint handlers. */+ const cbm_gbuf_edge_t **infra_edges = NULL;+ int infra_count = 0;+ cbm_gbuf_find_edges_by_source_type(gb, route->id, "INFRA_MAPS", &infra_edges, &infra_count);++ /* Extra handlers found via INFRA_MAPS chain */+ int64_t extra_handlers[32];+ int n_extra = 0;+ for (int ie = 0; ie < infra_count; ie++) {+ int64_t endpoint_id = infra_edges[ie]->target_id;+ /* Find HANDLES edges on the endpoint Route */+ const cbm_gbuf_edge_t **ep_handles = NULL;+ int ep_hcount = 0;+ cbm_gbuf_find_edges_by_target_type(gb, endpoint_id, "HANDLES", &ep_handles, &ep_hcount);+ for (int eh = 0; eh < ep_hcount && n_extra < 32; eh++) {+ extra_handlers[n_extra++] = ep_handles[eh]->source_id;+ }+ }+for (int ci = 0; ci < n_callers; ci++) {for (int hi = 0; hi < handles_count; hi++) {int64_t caller_id = caller_edges[ci].source_id;@@ -411,6 +484,58 @@ static void create_data_flows(cbm_gbuf_t *gb) {cbm_gbuf_insert_edge(gb, caller_id, handler_id, "DATA_FLOWS", props);flows++;}++ /* Also check handlers found via INFRA_MAPS chain */+ for (int xi = 0; xi < n_extra; xi++) {+ int64_t caller_id = caller_edges[ci].source_id;+ int64_t handler_id = extra_handlers[xi];+ if (caller_id == handler_id) {+ continue;+ }+ if (has_direct_call(gb, caller_id, handler_id)) {+ skipped++;+ continue;+ }+ const char *args_json = find_args_in_props(caller_edges[ci].props);+ const cbm_gbuf_node_t *handler_node = cbm_gbuf_find_by_id(gb, handler_id);+ char handler_params[512];+ extract_param_names(handler_node, handler_params, sizeof(handler_params));++ char props[2048];+ int n = snprintf(props, sizeof(props),+ "{\"via\":\"%s\",\"route\":\"%s\",\"edge_type\":\"%s\","+ "\"via_infra\":true",+ route->name ? route->name : "",+ route->qualified_name ? route->qualified_name : "",+ caller_edges[ci].edge_type);+ if (n > 0 && (size_t)n < sizeof(props) - 100) {+ size_t pos = (size_t)n;+ if (handler_params[0]) {+ int w = snprintf(props + pos, sizeof(props) - pos,+ ",\"handler_params\":[%s]", handler_params);+ if (w > 0) {+ pos += (size_t)w;+ }+ }+ if (args_json) {+ int w = snprintf(props + pos, sizeof(props) - pos, ",\"caller_args\":[%.*s",+ 400, args_json);+ if (w > 0) {+ pos += (size_t)w;+ char *close = strchr(props + (pos - (size_t)w) + 14, ']');+ if (close && close < props + sizeof(props) - 2) {+ pos = (size_t)(close - props) + 1;+ }+ }+ }+ if (pos < sizeof(props) - 1) {+ props[pos] = '}';+ props[pos + 1] = '\0';+ }+ }+ cbm_gbuf_insert_edge(gb, caller_id, handler_id, "DATA_FLOWS", props);+ flows++;+ }}}diff --git a/src/pipeline/pipeline.c b/src/pipeline/pipeline.cindex c88bcb051..4e2ce5b24 100644--- a/src/pipeline/pipeline.c+++ b/src/pipeline/pipeline.c@@ -326,6 +326,53 @@ static void *gh_compute_thread_fn(void *arg) {/* Extract Route nodes from URL strings found in config files (YAML, HCL, TOML).* These are infrastructure-defined endpoints (Cloud Scheduler, Terraform). */+/* Process infra bindings: topic→URL pairs from IaC configs.+ * Creates Route nodes for endpoints and HANDLES edges linking+ * topic Routes to endpoint Routes (bridging the gap). */+static void cbm_pipeline_process_infra_bindings(cbm_gbuf_t *gbuf, const cbm_file_info_t *files,+ CBMFileResult **result_cache, int file_count) {+ int bindings = 0;+ for (int i = 0; i < file_count; i++) {+ if (!result_cache[i]) {+ continue;+ }+ for (int bi = 0; bi < result_cache[i]->infra_bindings.count; bi++) {+ const CBMInfraBinding *ib = &result_cache[i]->infra_bindings.items[bi];+ if (!ib->source_name || !ib->target_url) {+ continue;+ }++ /* Create or find the endpoint Route node */+ char url_route_qn[CBM_ROUTE_QN_SIZE];+ snprintf(url_route_qn, sizeof(url_route_qn), "__route__infra__%s", ib->target_url);+ int64_t url_route_id =+ cbm_gbuf_upsert_node(gbuf, "Route", ib->target_url, url_route_qn, files[i].rel_path,+ 0, 0, "{\"source\":\"infra\"}");++ /* Find the topic/queue Route node created by code-side ASYNC_CALLS */+ char topic_route_qn[CBM_ROUTE_QN_SIZE];+ snprintf(topic_route_qn, sizeof(topic_route_qn), "__route__%s__%s",+ ib->broker ? ib->broker : "async", ib->source_name);+ const cbm_gbuf_node_t *topic_route = cbm_gbuf_find_by_qn(gbuf, topic_route_qn);++ if (topic_route) {+ /* Bridge: topic Route → endpoint Route via INFRA_MAPS edge */+ char props[512];+ snprintf(props, sizeof(props),+ "{\"broker\":\"%s\",\"topic\":\"%s\",\"endpoint\":\"%s\"}",+ ib->broker ? ib->broker : "async", ib->source_name, ib->target_url);+ cbm_gbuf_insert_edge(gbuf, topic_route->id, url_route_id, "INFRA_MAPS", props);+ bindings++;+ }+ }+ }+ if (bindings > 0) {+ char buf[16];+ snprintf(buf, sizeof(buf), "%d", bindings);+ cbm_log_info("pass.infra_bindings", "linked", buf);+ }+}+static void cbm_pipeline_extract_infra_routes(cbm_gbuf_t *gbuf, const cbm_file_info_t *files,CBMFileResult **result_cache, int file_count) {for (int i = 0; i < file_count; i++) {@@ -567,6 +614,9 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {/* Create Route nodes from infrastructure config URLs */cbm_pipeline_extract_infra_routes(p->gbuf, files, result_cache, file_count);+ /* Process infra bindings: link topic Routes to endpoint URLs */+ cbm_pipeline_process_infra_bindings(p->gbuf, files, result_cache, file_count);+/* Free cached extraction results */for (int i = 0; i < file_count; i++) {if (result_cache[i]) {