Skip to content

[Feature] AST-Based Call Graph Traversal & Relationship Tracing (trace_path MCP Tool) - #7

Merged
spelech merged 2 commits into
mainfrom
feature/ast-call-graph-trace-path-14592028422703187058
Aug 25, 2026
Merged

[Feature] AST-Based Call Graph Traversal & Relationship Tracing (trace_path MCP Tool)#7
spelech merged 2 commits into
mainfrom
feature/ast-call-graph-trace-path-14592028422703187058

Conversation

@spelech

@spelech spelech commented Aug 25, 2026

Copy link
Copy Markdown
Owner

This change extends ContextCortex with AST-based call graph relationship extraction and the trace_path MCP tool for BFS call graph traversal.

Key additions:

  • Extended SQLite relational schema in app/services/db.py with indexed ast_relationships table and ON DELETE CASCADE foreign key constraints.
  • Updated Tree-sitter parsing in app/services/chunker.py and models in app/models/schemas.py to extract CALLS, IMPORTS, INHERITS, and IMPLEMENTS relationships across supported programming languages.
  • Updated ingestion and deletion pipelines in app/services/indexer.py to store and purge ast_relationships records linked to symbol IDs.
  • Implemented trace_symbol_path BFS graph traversal engine in app/services/search.py with cycle/recursion protection, direction filtering, depth clamping, limit truncation, and Markdown tree output with permalinks.
  • Registered trace_path MCP tool in app/mcp/tools.py and app/mcp/mcp_server.py.
  • Added comprehensive unit and integration tests in tests/backend/test_ast_relationships.py and tests/backend/test_trace_path.py.

Fixes #1


PR created automatically by Jules for task 14592028422703187058 started by @spelech

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@spelech spelech left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: AST Call Graph Traversal & Relationship Tracing (PR #7)

✅ Verification & Findings:

  • AST Relationship Extraction: Extracts CALLS, IMPORTS, INHERITS, and IMPLEMENTS edges across Python, JS/TS, Go, Rust, C#, and Java into indexed SQLite ast_relationships table.
  • Cycle-Protected BFS Traversal: trace_symbol_path handles recursive and mutually recursive calls cleanly, with direction filtering (callers, callees, both), depth clamping (1-5), limit truncation, and markdown tree rendering.
  • FastMCP Tool: Registered trace_path on FastMCP server.
  • Test Suite Verification: All 264 unit, integration, and regression tests passing.

Ready for merge once CI checks finish.

@spelech
spelech merged commit 662adf7 into main Aug 25, 2026
2 checks passed
@spelech
spelech deleted the feature/ast-call-graph-trace-path-14592028422703187058 branch August 25, 2026 04:49
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.

[Feature] AST-Based Call Graph Traversal & Relationship Tracing (trace_path MCP Tool)

1 participant