Skip to content

fix(extract): add calls edges for JSX component usage (#3854) - #3855

Closed
sinangumuskabak-sys wants to merge 3 commits into
Graphify-Labs:v8from
sinangumuskabak-sys:fix/tsx-jsx-component-usage-edges
Closed

sinangumuskabak-sys wants to merge 3 commits into
Graphify-Labs:v8from
sinangumuskabak-sys:fix/tsx-jsx-component-usage-edges

Conversation

@sinangumuskabak-sys

@sinangumuskabak-sys sinangumuskabak-sys commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3854

JSX usages like <Bubble /> and <Card>...</Card> now produce calls edges in .tsx and .jsx files (plain .ts is unchanged).

The two JSX element types are added to call_types, and in the generic walk_calls path the callee is read from the name field. Only bare identifiers are handled. Tags starting with a lowercase letter are intrinsic elements and are skipped, same rule as the JSX transform, so <div> never binds to a local div(), while <_Row /> still counts as a component. Member tags (<icons.Close>, <props.Comp>, <Ctx.Provider>) are skipped: resolving them by the property name binds to unrelated local functions (plain icons.Close() already does this today). Namespaced tags and fragments are ignored, closing tags aren't counted.

One thing this doesn't cover: JSX at the top level of a module (e.g. root.render(<App />)) still gets no edge, same as a plain top-level call does today.

Tests are in tests/test_jsx_component_usage_calls.py. The same-file, cross-file, .jsx and _Row cases fail without the change; the <div>, <motion.div>, <Theme.Provider> and <icons.Close> / <props.Comp> ones guard against false edges.

I ran the full suite on Windows 11 before and after: 41 failed / 5835 passed before, 41 failed / 5843 passed after. It is the same 41 failing tests in both runs (Windows-specific ones: Erlang, hooks, install paths, watch); the +8 are the new tests. ruff is clean, and pyright reports the same 152 existing errors in the two touched files before and after.

<Comp /> and <Comp>...</Comp> are parsed as jsx_self_closing_element /
jsx_opening_element with the tag in the `name` field, and neither type was
in call_types, so components that are only rendered got no incoming edge.

Add both types to the JS and TSX call_types and read the callee from
`name`. Tags starting with a lowercase letter are intrinsic elements and
are skipped; for member tags the last part decides, so <div> and
<motion.div> don't bind to a local div(). Namespaced tags and fragments
are ignored.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Adds JSX/TSX element usage to call extraction so rendering a component (<Comp /> or <Comp>...</Comp>) emits a calls edge to it, resolving the case where a component only ever rendered previously looked unused. Reads the tag from the element's name field and skips it as an intrinsic DOM element when the deciding segment starts with a lowercase letter (<div>, <motion.div>), so those never bind to a same-named local function, while member tags fall back to their last segment and fragments/namespaced tags are ignored.

Worth a look

  • Member tag JSX binds by last segment, causing false-positive calls to unrelated functions — graphify/extractors/engine.py:6455 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Lowercase JSX member components are skipped even though JSX treats member expressions as values — graphify/extractors/engine.py:6458 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2445 functions depend on the 501 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 713 callers, 48 callees
  • new: _rebuild_code() — 144 callers, 55 callees
  • new: _extract_generic() — 18 callers, 29 callees
  • new: extract_js() — 87 callers, 4 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: main() — 98 callers, 3 callees
  • new: dispatch_command() — 2 callers, 125 callees
  • new: extract_objc() — 27 callers, 9 callees
  • …and 44 more — each is listed as a finding

Verification — 2445 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: 2270 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

129 of 303 test file(s) selected (43%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_astro_import_ids.py — impact
  • tests/test_build.py — impact
  • tests/test_builtin_global_type_refs.py — impact
  • tests/test_case_sensitive_resolution.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_cobol_extractor.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_cpp_objc_cross_file_calls.py — impact
  • tests/test_cross_extension_reexport_self_cycle.py — impact
  • tests/test_cross_language_call_resolution.py — impact
  • tests/test_cross_repo_external_call_guards.py — impact
  • tests/test_cross_repo_member_calls.py — impact
  • tests/test_csharp_call_site_generic_args.py — impact
  • tests/test_csharp_enum_members.py — impact
  • tests/test_csharp_field_generic_args.py — impact
  • tests/test_csharp_generic_callsites.py — impact
  • tests/test_csharp_interface_dispatch.py — impact
  • tests/test_csharp_member_calls.py — impact
  • tests/test_csharp_member_nodes.py — impact
  • tests/test_csharp_object_creation.py — impact
  • tests/test_csharp_partial_classes.py — impact
  • tests/test_csharp_type_resolution.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_detect.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_duplicate_annotation_edges.py — impact
  • tests/test_elixir_import_resolution.py — impact
  • tests/test_erlang_extractor.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_cache_location.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_file_label_disambiguation.py — impact
  • tests/test_file_node_id_spec.py — impact
  • tests/test_forwarding_review_findings.py — impact
  • tests/test_go_builtin_call_targets.py — impact
  • tests/test_go_import_repoint.py — impact
  • tests/test_go_interface_methods.py — impact
  • tests/test_go_qualified_resolution.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_import_self_loops.py — impact
  • tests/test_imported_export_forwarding.py — impact
  • tests/test_incremental.py — impact
  • tests/test_indirect_call_arrow_single_param_shadow.py — impact
  • tests/test_indirect_call_block_scoped_shadow.py — impact
  • tests/test_indirect_call_catch_binding_shadow.py — impact
  • tests/test_indirect_call_external_import_shadow.py — impact
  • tests/test_indirect_call_for_of_binding_shadow.py — impact
  • tests/test_indirect_call_function_expression_shadow.py — impact
  • tests/test_indirect_call_nested_closure_shadow.py — impact
  • … and 79 more

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 \_extract\_generic.

The verifier did not have enough to check \_extract\_generic, 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: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set

· 52 more finding(s) on lines outside this diff (see the check run).

@sinangumuskabak-sys

Copy link
Copy Markdown
Contributor Author

Checked both findings against the same cases written as plain calls.

  1. Member tags binding by last segment: I couldn't reproduce it for member tags that actually get an edge. <Theme.Provider /> with an unrelated local function Provider() gives no edge, and same when Provider lives in another file. Plain Theme.Provider() behaves the same way. The case that does mis-bind is a lowercase receiver: plain motion.div() next to a local function div() produces an edge to div() today. That's exactly why lowercase member tags are skipped. Pushed a test for the Theme.Provider case so it stays that way.

  2. Lowercase member tags skipped: right, <motion.div> is a value in JSX, not an intrinsic. Skipping it is on purpose, since going through the member-call path would bind it to a local div() as above. What's lost is an edge to framer-motion's motion.div, which has no node in the graph to point at anyway. Happy to change it if you'd rather handle those through a receiver-aware path.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Adds JSX component usage as calls edges: <Comp /> and <Comp>…</Comp> in .jsx/.tsx now resolve to the rendered component via the tag's name field, so components that are only rendered no longer look unused. Tags starting with a lowercase letter (<div>) are treated as intrinsic DOM elements and won't bind to a same-named local function, and member tags resolve by their last segment (<motion.div> isn't a local div), while fragments and namespaced tags are skipped.

Worth a look

  • JSX member tags can bind to unrelated local property-name functions — graphify/extractors/engine.py:6458 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • extract() now reports JSX render tags as calls edges — graphify/extractors/engine.py:6448 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2446 functions depend on the 502 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 713 callers, 48 callees
  • new: _rebuild_code() — 144 callers, 55 callees
  • new: _extract_generic() — 18 callers, 29 callees
  • new: extract_js() — 87 callers, 4 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: main() — 98 callers, 3 callees
  • new: dispatch_command() — 2 callers, 125 callees
  • new: extract_objc() — 27 callers, 9 callees
  • …and 44 more — each is listed as a finding

Verification — 2446 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: 2271 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

129 of 303 test file(s) selected (43%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_astro_import_ids.py — impact
  • tests/test_build.py — impact
  • tests/test_builtin_global_type_refs.py — impact
  • tests/test_case_sensitive_resolution.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_cobol_extractor.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_cpp_objc_cross_file_calls.py — impact
  • tests/test_cross_extension_reexport_self_cycle.py — impact
  • tests/test_cross_language_call_resolution.py — impact
  • tests/test_cross_repo_external_call_guards.py — impact
  • tests/test_cross_repo_member_calls.py — impact
  • tests/test_csharp_call_site_generic_args.py — impact
  • tests/test_csharp_enum_members.py — impact
  • tests/test_csharp_field_generic_args.py — impact
  • tests/test_csharp_generic_callsites.py — impact
  • tests/test_csharp_interface_dispatch.py — impact
  • tests/test_csharp_member_calls.py — impact
  • tests/test_csharp_member_nodes.py — impact
  • tests/test_csharp_object_creation.py — impact
  • tests/test_csharp_partial_classes.py — impact
  • tests/test_csharp_type_resolution.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_detect.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_duplicate_annotation_edges.py — impact
  • tests/test_elixir_import_resolution.py — impact
  • tests/test_erlang_extractor.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_cache_location.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_file_label_disambiguation.py — impact
  • tests/test_file_node_id_spec.py — impact
  • tests/test_forwarding_review_findings.py — impact
  • tests/test_go_builtin_call_targets.py — impact
  • tests/test_go_import_repoint.py — impact
  • tests/test_go_interface_methods.py — impact
  • tests/test_go_qualified_resolution.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_import_self_loops.py — impact
  • tests/test_imported_export_forwarding.py — impact
  • tests/test_incremental.py — impact
  • tests/test_indirect_call_arrow_single_param_shadow.py — impact
  • tests/test_indirect_call_block_scoped_shadow.py — impact
  • tests/test_indirect_call_catch_binding_shadow.py — impact
  • tests/test_indirect_call_external_import_shadow.py — impact
  • tests/test_indirect_call_for_of_binding_shadow.py — impact
  • tests/test_indirect_call_function_expression_shadow.py — impact
  • tests/test_indirect_call_nested_closure_shadow.py — impact
  • … and 79 more

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 \_extract\_generic.

The verifier did not have enough to check \_extract\_generic, 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: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set

· 52 more finding(s) on lines outside this diff (see the check run).

With a lowercase receiver, <icons.Close /> and <props.Comp /> resolved by the
property name and bound to unrelated local Close() / Comp() functions. None
of the member tags tried produced a correct edge, so only bare identifiers
are handled now.
@sinangumuskabak-sys

Copy link
Copy Markdown
Contributor Author

Good catch on the first one, my earlier check only covered capitalized receivers. With a lowercase receiver it does happen: <icons.Close /> and <props.Comp /> both bound to an unrelated local Close() / Comp(). Plain icons.Close() has the same problem today, but JSX would make it a lot more common.

None of the member tags I tried (<Theme.Provider>, <Ui.Row>, <Foo.Bar>) ever produced a correct edge either, so I dropped member tags completely. Only bare identifiers like <Bubble /> are handled now. Added a test for the icons.Close / props.Comp case (fails on the previous commit).

On the second one: yes, that's the intent. <Comp /> compiles to a call of Comp, so a calls edge seemed like the natural fit and keeps affected / query working without a new relation. If you'd prefer a separate relation like renders, I can switch it.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).


Graphify review — findings

Extracts JSX component usage (<Comp />, <Comp>...</Comp>) as calls edges by adding jsx_opening_element and jsx_self_closing_element to the JS and TSX call_types and reading the component from the tag's name field in _extract_generic. Binds only bare identifiers, treating a leading-lowercase tag (<div>) as an intrinsic DOM element and skipping member tags (<motion.div>, <Theme.Provider>, <icons.Close>) so they never resolve to a same-named or last-segment local function; <_Row> still counts as a component.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2447 functions depend on the 503 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 713 callers, 48 callees
  • new: _rebuild_code() — 144 callers, 55 callees
  • new: _extract_generic() — 18 callers, 29 callees
  • new: extract_js() — 87 callers, 4 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: main() — 98 callers, 3 callees
  • new: dispatch_command() — 2 callers, 125 callees
  • new: extract_objc() — 27 callers, 9 callees
  • …and 44 more — each is listed as a finding

Verification — 2447 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: 2272 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

129 of 303 test file(s) selected (43%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_astro_import_ids.py — impact
  • tests/test_build.py — impact
  • tests/test_builtin_global_type_refs.py — impact
  • tests/test_case_sensitive_resolution.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_cobol_extractor.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_cpp_objc_cross_file_calls.py — impact
  • tests/test_cross_extension_reexport_self_cycle.py — impact
  • tests/test_cross_language_call_resolution.py — impact
  • tests/test_cross_repo_external_call_guards.py — impact
  • tests/test_cross_repo_member_calls.py — impact
  • tests/test_csharp_call_site_generic_args.py — impact
  • tests/test_csharp_enum_members.py — impact
  • tests/test_csharp_field_generic_args.py — impact
  • tests/test_csharp_generic_callsites.py — impact
  • tests/test_csharp_interface_dispatch.py — impact
  • tests/test_csharp_member_calls.py — impact
  • tests/test_csharp_member_nodes.py — impact
  • tests/test_csharp_object_creation.py — impact
  • tests/test_csharp_partial_classes.py — impact
  • tests/test_csharp_type_resolution.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_detect.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_duplicate_annotation_edges.py — impact
  • tests/test_elixir_import_resolution.py — impact
  • tests/test_erlang_extractor.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_cache_location.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_file_label_disambiguation.py — impact
  • tests/test_file_node_id_spec.py — impact
  • tests/test_forwarding_review_findings.py — impact
  • tests/test_go_builtin_call_targets.py — impact
  • tests/test_go_import_repoint.py — impact
  • tests/test_go_interface_methods.py — impact
  • tests/test_go_qualified_resolution.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_import_self_loops.py — impact
  • tests/test_imported_export_forwarding.py — impact
  • tests/test_incremental.py — impact
  • tests/test_indirect_call_arrow_single_param_shadow.py — impact
  • tests/test_indirect_call_block_scoped_shadow.py — impact
  • tests/test_indirect_call_catch_binding_shadow.py — impact
  • tests/test_indirect_call_external_import_shadow.py — impact
  • tests/test_indirect_call_for_of_binding_shadow.py — impact
  • tests/test_indirect_call_function_expression_shadow.py — impact
  • tests/test_indirect_call_nested_closure_shadow.py — impact
  • … and 79 more

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.

· 52 more finding(s) on lines outside this diff (see the check run).

safishamsi added a commit that referenced this pull request Sep 27, 2026
Security: close the Fortran cpp #include arbitrary-file-read
(GHSA-pcc4-rvhr-2pr8), the last Aider/Devin monolith --watch shell sink
(#3852), and terraform name/value secret redaction (#3870). Plus Windows
watch rebuild locking (#3883), C# tuple element-name refs (#3877), JSX
component-usage calls (#3855), and nested scan-root Python import
projection (#3867).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.70 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @sinangumuskabak-sys! JSX component usage now emits calls edges; DOM and member tags conservatively skipped.

Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.70

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.

TSX/JSX: components used as <Comp /> get no incoming edge

2 participants