Skip to content

fix(mcp): trace_path cross_service follows CROSS_* edges (#522) - #538

Merged
DeusData merged 1 commit into
DeusData:mainfrom
kirilklein:fix/issue-522-cross-service-trace
Jun 22, 2026
Merged

fix(mcp): trace_path cross_service follows CROSS_* edges (#522)#538
DeusData merged 1 commit into
DeusData:mainfrom
kirilklein:fix/issue-522-cross-service-trace

Conversation

@kirilklein

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #522trace_path with mode=cross_service did not follow cross-repo edges, so cross-service traces silently dropped every cross hop even when the edge existed and was visible via query_graph.

Root cause. resolve_trace_edge_types() in src/mcp/mcp.c resolved the cross_service default edge-type list to {HTTP_CALLS, ASYNC_CALLS, DATA_FLOWS, CALLS} — none of the CROSS_* types the cross-repo pass actually writes. cbm_store_bfs filters edges with an exact WHERE e.type IN (...) clause, so any CROSS_HTTP_CALLS / CROSS_ASYNC_CALLS / … hop was filtered out. The traversal engine was fine; the defaults list was just missing the cross types.

Fix. Add the six CROSS_* types (CROSS_HTTP_CALLS, CROSS_ASYNC_CALLS, CROSS_CHANNEL, CROSS_GRPC_CALLS, CROSS_GRAPHQL_CALLS, CROSS_TRPC_CALLS) to the cross_service default list — exactly the set pass_cross_repo.c emits and cross_repo_delete_edges() cleans up. The count is now derived from the array size (sizeof) so it can't drift; the now-dead MCP_N_DEFAULTS_4 constant is removed. The trace_path tool description is updated to match.

Before / after (repro from the issue)

  • Before: query_graph returns the CROSS_HTTP_CALLS edge, but trace_path(mode=cross_service) from the source function returns only in-repo callees.
  • After: trace_path(mode=cross_service) surfaces the cross hop; query_graph still returns the edge.

Test

Adds integ_mcp_trace_path_cross_service: seeds a CROSS_HTTP_CALLS edge between two indexed functions that have no CALLS relationship, then asserts cross_service surfaces the hop while calls mode does not (proving the cross edge specifically is what's followed). Verified to fail before the fix and pass after.

Checklist

  • Every commit is signed off (git commit -s)
  • Tests pass locally (make -f Makefile.cbm test) — 5609 passed
  • Lint passes — clang-format --dry-run --Werror clean on changed files (full lint-ci deferred to CI)
  • New behavior is covered by a test (reproduce-first)

🤖 Generated with Claude Code

trace_path mode=cross_service resolved its default edge-type list to
{HTTP_CALLS, ASYNC_CALLS, DATA_FLOWS, CALLS} — none of the CROSS_* edge
types the cross-repo pass actually writes. Since cbm_store_bfs filters
edges with an exact `WHERE e.type IN (...)` clause, cross-service traces
silently skipped every cross hop even when the edge was present and
visible via query_graph.

Add the six CROSS_* types (CROSS_HTTP_CALLS, CROSS_ASYNC_CALLS,
CROSS_CHANNEL, CROSS_GRPC_CALLS, CROSS_GRAPHQL_CALLS, CROSS_TRPC_CALLS)
to the cross_service default list — exactly the set pass_cross_repo.c
emits and cross_repo_delete_edges() cleans up. The count is now computed
from the array size (sizeof) so it can't drift; the dead MCP_N_DEFAULTS_4
constant is removed. Tool description updated to match.

Adds integ_mcp_trace_path_cross_service: seeds a CROSS_HTTP_CALLS edge
between two indexed functions with no CALLS relationship and asserts
cross_service surfaces the hop while calls mode does not.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: kirilklein <kikl@di.ku.dk>
@azuttre

azuttre commented Jun 20, 2026

Copy link
Copy Markdown

Built this branch on macOS (arm64) and tested it: with a node reachable only through a CROSS_HTTP_CALLS edge, trace_path cross_service returns 0 callees on main and 1 on this branch. Confirmed working. Thanks for the quick turnaround.

@prakashelango

Copy link
Copy Markdown

I have a kinesis stream for eventing and it couldn't recognize the cross service calls from upstream and downstream, by any chance will this change include the kinesis too?

@DeusData
DeusData merged commit df8bc92 into DeusData:main Jun 22, 2026
13 checks passed
@kirilklein
kirilklein deleted the fix/issue-522-cross-service-trace branch July 13, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trace_path mode=cross_service does not traverse CROSS_* edges

4 participants