Skip to content

fix: extract JS/TS object-literal shorthand methods - #2433

Open
aryanbonigala wants to merge 1 commit into
Graphify-Labs:v8from
aryanbonigala:fix/2419-object-literal-methods
Open

fix: extract JS/TS object-literal shorthand methods#2433
aryanbonigala wants to merge 1 commit into
Graphify-Labs:v8from
aryanbonigala:fix/2419-object-literal-methods

Conversation

@aryanbonigala

Copy link
Copy Markdown

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:

export const Service = create({
    methods: {
        run() {},
        async refresh() {},
    },
});

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_definition nodes under object literals were never visited.

Implementation

  • Scan an already-confirmed module-level binding initializer for shorthand method_definition nodes.
  • Stop at function, callback, method-body, and class ownership boundaries.
  • Reuse Graphify's existing method IDs, labels, method edges, callable registration, local-binding registration, and deferred function-body processing.
  • Preserve the existing generic walker and _js_extra_walk() return contract.
  • Prevent duplicate nodes and ownership edges under Graphify's existing flattened binding/member ID model.

Safety

Regression coverage verifies:

  • Top-level object-literal methods
  • Nested factory-style methods
  • Async shorthand methods
  • JavaScript and TypeScript parity
  • Correct const ownership
  • Correct method-body call attribution
  • No local-object leakage
  • No callback-body leakage
  • No class-expression misclassification
  • No duplicate method nodes or ownership edges
  • Existing module-level arrow behavior remains unchanged

Verification

  • 336 passed in tests/test_languages.py
  • 3980 passed, 3 skipped in the full suite
  • Focused final review: 8 passed, 328 deselected
  • Ruff passed
  • git diff --check passed

Deferred scope

This PR intentionally does not add support for function-valued property pairs such as:

{
    handler: function () {},
    callback: () => {},
}

It also does not change god-node ranking or class-expression extraction.

@aryanbonigala
aryanbonigala deleted the fix/2419-object-literal-methods branch August 3, 2026 20:26
@aryanbonigala
aryanbonigala restored the fix/2419-object-literal-methods branch August 3, 2026 20:27
@aryanbonigala aryanbonigala reopened this Aug 3, 2026

@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.

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).

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.

JS/TS: object-literal shorthand methods are never extracted, so factory/singleton-style modules yield only a file + const node

1 participant