Repository navigation
feat(go): Add Phase 2 type tracking integration and MCP support (PR-16) - #539
Merged
Merged
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #539 +/- ##
==========================================
- Coverage 82.92% 82.90% -0.02%
==========================================
Files 139 139
Lines 16847 16892 +45
==========================================
+ Hits 13971 14005 +34
- Misses 2349 2356 +7
- Partials 527 531 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Feb 16, 2026
Owner
Author
Owner
Author
Merge activity
|
shivasurya
changed the base branch from
shiva/golang-pr15-variable-tracking
to
graphite-base/539
February 16, 2026 21:11
- Add GoTypeEngine field to CallGraph struct for Phase 2 type tracking - Add GoTypeProvider interface to avoid import cycles - Add GetGoTypeEngine() getter method - Field can be nil initially, will be populated during builder Pass 2a
- Add typeEngine parameter to BuildGoCallGraph function - Update comment to reflect 5-pass algorithm (was 3-pass) - Store typeEngine in CallGraph.GoTypeEngine for MCP access - Update all callers: serve.go, scan.go, ci.go - Initialize GoTypeInferenceEngine before building call graph - Update test to pass typeEngine parameter Passes 2a and 2b will be implemented in next commit.
- Pass 2a: Extract return types from indexed functions - Operates on callGraph.Functions (already indexed in Pass 1) - Stores return types in typeEngine - Pass 2b: Extract variable assignments (parallel) - Parallel extraction using worker pool pattern - Thread-safe via typeEngine mutex - Processes all .go source files - Update pass numbers in comments (3-pass → 5-pass) - Add required imports: extraction, sync, atomic - Both passes run only if typeEngine is not nil
- Add getReturnType() helper function - Checks node.ReturnType first (annotations) - Falls back to callGraph.GoTypeEngine for Go inferred types - Update GetCallees: add return_type to source object - Update GetCallers: add return_type to target and caller objects - Add core package import to mcp/tools.go - Return types now exposed for both Python and Go functions in MCP
- Verify all 5 passes execute without errors - Test Pass 1: Function indexing - Test Pass 2a: Return type extraction to GoTypeEngine - Test Pass 2b: Variable assignment tracking - Test Pass 3: Call site extraction - Test Pass 4: Call target resolution - Verify GoTypeEngine is attached to CallGraph - Verify return types are correctly stored and retrievable
shivasurya
force-pushed
the
shiva/golang-pr16-integration-mcp
branch
from
February 16, 2026 21:13
1d9997a to
d393b83
Compare
Code Pathfinder Security ScanNo security issues detected.
Powered by Code Pathfinder |
shivasurya
added a commit
that referenced
this pull request
Feb 16, 2026
…ype tracking (PR-17) (#540) ## Summary This PR implements **Pattern 1b: Variable-based method resolution** for Go call graphs. Method calls like `user.Save()` are now resolved using variable type information from the type inference engine (PR-14/PR-15/PR-16). ## Changes ### 1. Enhanced `resolveGoCallTarget` Function - **Updated signature**: Added `typeEngine` and `callGraph` parameters - **New Pattern 1b**: Variable method resolution - Looks up variable type from `typeEngine` scope - Handles pointer types (`*User` → `User`) - Verifies method exists in `callGraph.Functions` - Prioritizes import resolution over variable resolution **Resolution order**: 1. ✅ Import-based resolution (existing) 2. ✅ **Variable-based resolution (NEW)** 3. ✅ Same-package function calls 4. ✅ Builtin functions ### 2. Pointer Type Handling Correctly strips pointer prefix for method lookup: - Variable type: `*models.User` → Method FQN: `models.User.Save` - Variable type: `pkg.Config` → Method FQN: `pkg.Config.Validate` ### 3. Backward Compatibility - New parameters are optional (can be `nil`) - Falls back to previous behavior when `typeEngine` is not provided - All existing tests updated to pass `nil` for compatibility ## Testing ### Unit Tests (7 test cases) ```go TestResolveGoCallTarget_VariableMethod: ✅ Resolve user.Save() to User.Save ✅ Resolve pointer variable (*User).Save ✅ Fail when method doesn't exist ✅ Fail when variable not in scope ✅ Fallback to import when typeEngine is nil ✅ Prioritize import over variable ✅ Resolve config.Validate() with return type ``` ### Integration Test ```go TestBuildGoCallGraph_MethodResolution: ✅ End-to-end resolution through BuildGoCallGraph ✅ Variable bindings from PR-15 ✅ Method calls resolved correctly ✅ Edges and reverse edges created ✅ Uses all_type_patterns.go fixture ``` ## Quality Metrics - ✅ **Build**: `gradle buildGo` - SUCCESS - ✅ **Tests**: `gradle testGo` - ALL PASS (29 packages) - ✅ **Lint**: `gradle lintGo` - 0 issues - ✅ **Coverage**: No regression ## Impact **Before PR-17**: ```go user.Save() // ❌ Unresolved (import not found) config.Validate() // ❌ Unresolved (import not found) ``` **After PR-17**: ```go user.Save() // ✅ Resolved to models.User.Save config.Validate() // ✅ Resolved to pkg.Config.Validate ``` **Expected improvement**: 85-90% call resolution rate (as specified in PR-17 document) ## Dependencies - **Stacked on**: #539 (PR-16: Integration & MCP) - **Depends on**: #537 (PR-14), #538 (PR-15), #539 (PR-16) ## Code Quality - **LoC**: ~150 (as specified) - **Files changed**: 2 files (go_builder.go, go_builder_test.go) - No code bloat - focused, minimal changes - Comprehensive test coverage - Well-documented with clear comments 🤖 Generated with Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
This PR integrates Go Phase 2 type tracking (PR-14 and PR-15) into the call graph builder and exposes type information through MCP tools. The Go call graph builder now uses a 5-pass algorithm with full type inference support.
Changes
1. CallGraph Core Enhancement
GoTypeEnginefield toCallGraphstruct for storing Go type informationGoTypeProviderinterface to avoid import cyclesGetGoTypeEngine()getter method2. Builder Signature Update
BuildGoCallGraph()to accepttypeEngineparameterserve.go,scan.go,ci.goGoTypeInferenceEnginebefore building call graph3. 5-Pass Algorithm Implementation
Pass 1: Index functions from CodeGraph → populate
CallGraph.FunctionsPass 2a: Extract return types from all indexed Go functions
callGraph.Functions(already indexed)typeEnginePass 2b: Extract variable assignments (parallel)
typeEnginemutex.gosource filesPass 3: Extract call sites from
call_expressionnodesPass 4: Resolve call targets to FQNs → add edges to CallGraph
4. MCP Tool Enhancements
getReturnType()helper function:node.ReturnTypefirst (annotations)callGraph.GoTypeEnginefor Go inferred typesGetCallees: addreturn_typeto source objectGetCallers: addreturn_typeto target and caller objects5. Integration Test
TestBuildGoCallGraph_WithTypeTrackingTesting
Dependencies
Migration Notes
No breaking changes. The
typeEngineparameter is optional - ifnil, Passes 2a and 2b are skipped and the builder falls back to the previous 3-pass algorithm.🤖 Generated with Claude Code