fix(graph): surface instantiates edges in callers/callees (#774)#801
Closed
maxmilian wants to merge 1 commit into
Closed
fix(graph): surface instantiates edges in callers/callees (#774)#801maxmilian wants to merge 1 commit into
maxmilian wants to merge 1 commit into
Conversation
…ry#774) Resolution promotes a class-instantiation `calls` ref (e.g. Python `Foo()`) to an `instantiates` edge, but getCallers/getCallees whitelisted only ['calls','references','imports'] — so once the promotion ran, `callers <Class>` and `codegraph_callers` returned no callers even though the instantiation edge existed. impact already traverses instantiates (it walks all incoming edges except contains), so callers was the inconsistent one. Add 'instantiates' to both the incoming whitelist in getCallersRecursive and the symmetric outgoing whitelist in getCalleesRecursive, so an instantiation site is reported as a caller of the class and the class as a callee of the site. Regression test extends the existing calls->instantiates resolution fixture to assert the traversal.
Contributor
Author
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.
Fixes #774.
The actual gap (reframed)
#774 asks for class instantiation (
Foo()) to count as a caller edge into the class. The extraction/resolution half already ships:resolveReferences()promotes acallsref to aninstantiatesedge when the target resolves to a class (src/resolution/index.ts, covered by the existing test "promotes calls→instantiates when target resolves to a class (Python)"). Andimpactalready surfaces it —getImpactRecursivewalks every incoming edge exceptcontains.The residual bug is in traversal:
getCallersRecursiveandgetCalleesRecursivewhitelisted only['calls', 'references', 'imports'], omittinginstantiates. So after promotion, the edge exists in the graph but:callers <Class>/codegraph_callersreturns "No callers found" even though the class is instantiated, andcallees <site>omits the class the site constructs.callerswas the one inconsistent traversal (impact already included instantiation sites).The fix
Add
'instantiates'to the edge-kind whitelist in bothgetCallersRecursive(incoming) andgetCalleesRecursive(outgoing), so an instantiation site is reported as a caller of the class and the class as a callee of the site — matching whatimpactalready does.Test
Extends the existing
calls→instantiatesPython fixture (UserService+bootstrap) in__tests__/resolution.test.tsto assert the traversal:getCallers(UserService)now returnsbootstrapvia aninstantiatesedge, andgetCallees(bootstrap)returnsUserService. Red before the change, green after.Validation
npm run build— clean.main, green on this branch.npm test— no new failures. Two pre-existing worker-exit flakes (inresolution.test.ts's real-SQLite/wasm run) reproduce identically on cleanmain, so they're unrelated to this change; all callers/callees/impact suites (foundation,explore-blast-radius,object-literal-methods) pass.The reporter's original evidence was against v0.9.5 (before the
calls→instantiatespromotion landed in #134), so the symptom they saw was broader; on currentmainthis traversal whitelist is the remaining piece.