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.

fix(pipeline): give sequential service edges the parallel args shape

Martin Vogela7016270077f
diff --git a/src/pipeline/pass_calls.c b/src/pipeline/pass_calls.c
index 0675e9420..0be448885 100644
--- a/src/pipeline/pass_calls.c
+++ b/src/pipeline/pass_calls.c
@@ -457,10 +457,11 @@ static int64_t create_svc_route_node(cbm_pipeline_ctx_t *ctx, const char *url, c
/* Insert an edge, splicing the call-site line (,"line":N) in before the closing
* brace when one was captured. Mirrors finalize_and_emit() on the parallel path
- * so CALLS edges carry their source line regardless of resolution path. Restricted
- * to CALLS: route/config edge props feed full-only predump passes
- * (create_route_nodes/create_data_flows), so altering them desyncs full vs
- * incremental indexing. */
+ * so CALLS edges carry their source line regardless of resolution path. Line and
+ * args here are restricted to CALLS; HTTP_CALLS / ASYNC_CALLS props are finished
+ * by the parallel formatter itself (emit_http_async_edge), because route/service
+ * edge props feed full-only predump passes (create_route_nodes /
+ * create_data_flows) and must not differ between the two passes. */
/* Append a ,"args":[{"i":0,"e":"<expr>","v":"<value>"},...] field onto a CALLS
* edge's JSON props (the props buffer ends in '}'). The sequential pass omitted
* this, so data_flow mode had no argument expressions to surface for small
@@ -585,8 +586,10 @@ static void emit_http_async_edge(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
* emit_http_async_service_edge: the old single format string closed the
* method value's quote but not the broker's, emitting
* "broker":"bullmq} on EVERY brokered ASYNC_CALLS edge — and its fixup
- * only handled truncation, which never fires in the normal case (#898). */
- char props[CBM_SZ_512];
+ * only handled truncation, which never fires in the normal case (#898).
+ * The call's args and the closing brace come from the parallel path's own
+ * formatter, so a service edge is byte-identical whichever pass emits it. */
+ char props[CBM_SZ_2K];
int n = snprintf(props, sizeof(props), "{\"callee\":\"%s\",\"url_path\":\"%s\"", esc_callee,
esc_url);
if (method && n > 0 && (size_t)n < sizeof(props)) {
@@ -595,11 +598,8 @@ static void emit_http_async_edge(cbm_pipeline_ctx_t *ctx, const CBMCall *call,
if (broker && n > 0 && (size_t)n < sizeof(props)) {
n += snprintf(props + n, sizeof(props) - (size_t)n, ",\"broker\":\"%s\"", broker);
}
- if (n > 0 && (size_t)n < sizeof(props) - 1) {
- props[n] = '}';
- props[n + 1] = '\0';
- }
- calls_emit_edge(ctx->gbuf, source->id, route_id, edge_type, props, sizeof(props), call);
+ cbm_pipeline_close_call_props(props, n, call, false);
+ cbm_gbuf_insert_edge(ctx->gbuf, source->id, route_id, edge_type, props);
}
/* Classify a resolved call and emit the appropriate edge. */
diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.c
index ec4845cc6..8cdfb80e8 100644
--- a/src/pipeline/pass_parallel.c
+++ b/src/pipeline/pass_parallel.c
@@ -2248,13 +2248,13 @@ static const char *find_route_path_in_args(const CBMCall *call, const char **out
return found;
}
-/* Build props JSON, append args, close brace, emit edge. */
-static void finalize_and_emit(cbm_gbuf_t *gbuf, int64_t src_id, int64_t tgt_id,
- const char *edge_type, char *props, int n, const CBMCall *call) {
+/* Append the call's args (and, for CALLS, its line) to props and close the
+ * brace. Shared with the sequential pass, whose service edges must carry the
+ * same bytes (pass_calls.c emit_http_async_edge). */
+void cbm_pipeline_close_call_props(char *props, int n, const CBMCall *call, bool with_line) {
if (n > 0 && (size_t)n < CBM_SZ_2K - PP_ESC_SPACE) {
size_t pos = append_args_json(props, CBM_SZ_2K, (size_t)n, call);
- if (call->start_line > 0 && strcmp(edge_type, "CALLS") == 0 &&
- pos < CBM_SZ_2K - PP_LINE_MARGIN) {
+ if (with_line && call->start_line > 0 && pos < CBM_SZ_2K - PP_LINE_MARGIN) {
int ln = snprintf(props + pos, CBM_SZ_2K - pos, ",\"line\":%d", call->start_line);
if (ln > 0) {
pos += (size_t)ln;
@@ -2265,6 +2265,12 @@ static void finalize_and_emit(cbm_gbuf_t *gbuf, int64_t src_id, int64_t tgt_id,
props[pos + SKIP_ONE] = '\0';
}
}
+}
+
+/* Build props JSON, append args, close brace, emit edge. */
+static void finalize_and_emit(cbm_gbuf_t *gbuf, int64_t src_id, int64_t tgt_id,
+ const char *edge_type, char *props, int n, const CBMCall *call) {
+ cbm_pipeline_close_call_props(props, n, call, strcmp(edge_type, "CALLS") == 0);
cbm_gbuf_insert_edge(gbuf, src_id, tgt_id, edge_type, props);
}
diff --git a/src/pipeline/pipeline_internal.h b/src/pipeline/pipeline_internal.h
index 385627d0e..eb5ec8df4 100644
--- a/src/pipeline/pipeline_internal.h
+++ b/src/pipeline/pipeline_internal.h
@@ -663,6 +663,12 @@ bool cbm_pipeline_http_client_call_url(const cbm_gbuf_t *gbuf, const char *proje
const char **imp_vals, int imp_count, const CBMCall *call,
char *out, size_t out_sz);
+/* Finish a call edge's props: `props` is a CBM_SZ_2K buffer holding `n` bytes
+ * of an unclosed JSON object. Appends the call's ,"args":[...] (and, when
+ * `with_line`, its ,"line":N), then the closing brace. The one formatter
+ * behind both passes' HTTP_CALLS / ASYNC_CALLS props (pass_parallel.c). */
+void cbm_pipeline_close_call_props(char *props, int n, const CBMCall *call, bool with_line);
+
/* A spawn site (pass_spawns.c): the API the call names and the program it
* starts (CBM_SPAWN_DYNAMIC when not a literal). */
typedef struct {