Repository navigation
Conversation
A closure passed in a module-level call statement is walked under the file node (Graphify-Labs#3124), but its params and locals were never registered for that walk. A parameter passed on as a call argument then resolved against the corpus-wide label index and produced an indirect_call to any function with the same name, including module-private ones in other packages. Record the closure's bindings in closure_locals_by_body, the same way the Graphify-Labs#2568 branch already does for const-assigned closures.
|
Thanks for the pull request, @bercedev. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).
Not verified on this run: \_js\_extra\_walk (vacuous: never exercised).
Graphify review — findings
Fixes file-scope anonymous callbacks (items.forEach(function (value) { s.on(value) }), .controller(...), it(...)) leaking their own params and locals into corpus-wide call resolution. The #3124 branch of _js_extra_walk now records each closure's bound names as that body's extra locals, so a parameter like value no longer becomes an indirect_call to an unrelated same-named function. Names that the callback doesn't bind, including a sibling callback's param, still resolve as before, and a new test file covers member, bare, arrow, nested, and describe/it cases.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 921 functions depend on the 342 functions this change touches.
Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
_extract_generic()— 20 callers, 41 callees (high)extract_js()— 91 callers, 7 callees (high)extract_objc()— 25 callers, 13 callees (high)extract_xaml()— 19 callers, 17 callees (high)extract_php()— 38 callers, 5 callees (high)extract_cpp()— 37 callers, 5 callees (high)extract_julia()— 22 callers, 8 callees (high)extract_svelte()— 14 callers, 8 callees (high)- …and 2 more
Verification — 921 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 810 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
37 of 419 test file(s) selected (9%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_csharp_partial_classes.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_extract.py— impacttests/test_extract_php_closures.py— impacttests/test_import_extension_resolution.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_indirect_call_file_scope_callback_shadow.py— impact, changed-testtests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_java_member_calls.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_languages.py— impacttests/test_multilang.py— impacttests/test_php_unparsed_casts.py— impacttests/test_python_inherited_method_calls.py— impacttests/test_python_property_reads.py— impacttests/test_python_underscore_resolution.py— impacttests/test_rationale.py— impacttests/test_ruby_resolution.py— impacttests/test_scala_context_bounds.py— impacttests/test_scala_given_instances.py— impacttests/test_scala_self_type.py— impacttests/test_scala_top_level_binding.py— impacttests/test_scala_type_definition.py— impacttests/test_svelte_extraction.py— impacttests/test_swift_computed_properties.py— impacttests/test_swift_protocol_requirements.py— impacttests/test_trailing_newline_not_a_syntax_error.py— impacttests/test_ts_new_expression_calls.py— impacttests/test_typescript_module_extensions.py— impacttests/test_vue_extraction.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify \_js\_extra\_walk.
The verifier did not have enough to check \_js\_extra\_walk, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 264 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)
Eight community PRs: Windows MCP-stdio hang (#4441), Rust use->declaration (#4443), JS/TS file-scope callback param shadowing (#4457), sibling-file-id symbol retention (#4452), TS class-field receiver scoping (#4297), Ollama /api/chat num_ctx (#4414), cluster label retention on majority overlap (#4451), and an ingest symlink test fix (#4442). AST cache schema bumped to 16. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in 0.9.91 as 1af5104 (cherry-picked with your authorship preserved, so it shows on your contributions). Thanks @bercedev! Released to PyPI: https://pypi.org/project/graphifyy/0.9.91/ |
What does this PR do?
Fixes #4448.
A closure passed in a module-level call statement (
items.forEach(function (value) { ... }), the AngularJS.controller('X', function ($scope) { ... })shape, a test'sit('...', () => { ... })) is walked under the file node since #3124. That walk never got the closure's own parameters and locals. So a parameter passed on as a call argument was looked up in the corpus-wide label index, anda.jsgot anindirect_callto any function with the same name, even a module-private one in another package.Inside a named function this was already right (#2241, #2568). The fix records the closure's bindings in
closure_locals_by_bodyat the #3124 site, the same three lines the #2568 branch uses for const-assigned closures.walk_callsthen gets them asextra_localsfor that body only.Before:
a.js --indirect_call [argument]--> value(). After: no edge.Type of change
Verification & Invariants
Invariant: the only edges that go away are
indirect_calledges whose argument is a binding of the anonymous closure it sits in.I compared
extract()output fromv8and this branch on three private JS/TS codebases I work on (563 files, React/Vite frontends and Node backends):Both removed edges come from one test file (checked out twice in that repo):
confighere is the arrow's own parameter, and the old edge pointed at an unrelatedconfigfunction in a vendored bundle. That inner arrow is also an expression statement, so the #3124 branch tracks it on its own and the closure-descend path inwalk_callsnever adds its params. This fix covers that case too.One of the codebases has Playwright's minified bundles inside a checked-in virtualenv. There the branch removes 29 more
indirect_calledges of the same kind (single-letter callback params pointing at single-letter functions in other bundles). One of those pairs now shows up once as acollectionedge instead of anargumentedge.Limitations:
let/constinside the closure body keep their block scoping (JS/TS: block-scoped let/const bindings suppress genuine indirect_call edges outside their scope #2822) and go through the existing block/loop folding, as in named functions.walk_callssuppresses, not in the cached AST shape. Tell me if you want one anyway so cached graphs drop the bad edges without--force.How was this tested?
tests/test_indirect_call_file_scope_callback_shadow.pycovers the issue's table: member and bare calls, a nested file-scope callback, arrows with and without parentheses, avarlocal. It also covers two cases that must still resolve: an unbound name inside the callback, and a sibling closure in the same call whose own param does not shadow. One more test is thedescribe/it/ inner-arrow shape from the codebase above.I also ran the issue's AngularJS + TypeScript repro (
legacy/controller.jsandapp/src/transport.ts): noindirect_callon this branch.Linux, Python from the repo's
uv.lock.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.Note: I used Claude Code while working on this fix. I reviewed and ran all of it myself.