fix: extract JS/TS object-literal shorthand methods - #2433
Conversation
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
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
This PR adds extraction support for shorthand methods defined inside module-level object-literal initializers in JavaScript/TypeScript (referenced as issue #2419). In graphify/extractors/engine.py, it introduces a new helper _js_object_literal_methods (plus a _JS_OBJECT_SCAN_STOP_TYPES frozenset) that walks a const binding's initializer to collect method_definition nodes, stopping at function-value and class-related node types. The const-handling branch of _js_extra_walk is extended to emit method nodes, method ownership edges, and register method bodies for call attribution. The tests/test_languages.py changes add several new tests covering object-literal method ownership by the const, TypeScript parity, scope/execution boundary behavior, class-expression exclusion, and duplicate-name collapsing, along with an _owner_of test helper.
No blocking issues surfaced. 3 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 816 functions depend on the 616 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_js_extra_walk()— 2 callers, 7 callees
Verification — 816 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: 774 function(s) in the blast radius were not formally verified this run
· 1 more finding(s) on lines outside this diff (see the check run).
Fixes #2419
Summary
Extract JavaScript and TypeScript object-literal shorthand methods from module-level binding initializers.
This covers module-object and factory-style patterns such as:
The extracted methods are owned by the enclosing module-level binding and their body calls are attributed to the method nodes.
Root cause
The JS/TS module-level const path emitted the binding node and returned before the generic walker entered the initializer subtree. As a result,
method_definitionnodes under object literals were never visited.Implementation
method_definitionnodes.methodedges, callable registration, local-binding registration, and deferred function-body processing._js_extra_walk()return contract.Safety
Regression coverage verifies:
Verification
336 passedintests/test_languages.py3980 passed, 3 skippedin the full suite8 passed, 328 deselectedgit diff --checkpassedDeferred scope
This PR intentionally does not add support for function-valued property pairs such as:
It also does not change god-node ranking or class-expression extraction.