Repository navigation
Conversation
An `include`/`prepend` inside a `class << self` block injects the module's instance methods as the enclosing class's own singleton (class) methods — the very mixin relationship `extend <Mod>` expresses in the class body, which the extractor already captures (Graphify-Labs#1668). The mixin scan only walked the class/module body's direct children, so the `class << self` form was silently dropped and emitted no `mixes_in` edge. Scan `class << self` blocks as well, reusing the existing constant-argument filter and the single-owner resolver guard. Only `self` counts: `class << other` opens a different object's singleton, not the enclosing class's, so an include there stays unlinked. Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for the pull request, @Synvoya. 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.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review completed · a82f30f1c57f
Tip
Merge confidence: 5/5 · Looks safe to merge · 🟠 High impact
No issues reported
The extractor now scans direct statements inside class << self when collecting Ruby mixin relationships.
Full summary
The extractor now scans direct statements inside class << self when collecting Ruby mixin relationships. A regression test checks that this adds a mixes_in edge while class << obj does not.
Code graph and static checks · 4380 functions depend on this change
Impact & health
Impact — 4380 functions depend on the 572 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1284 callers, 78 callees
Formal checks — 4380 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 2561 function(s) in the blast radius were not formally verified this run
Test selection
52 of 593 test file(s) selected (9%) via static blast radius.
tests/test_4992_ts_import_types.py— impacttests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_alias_member_resolution.py— impacttests/test_cpp_conditional_initializers.py— impacttests/test_cpp_inherited_member_resolution.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_csharp_extension_calls.py— impacttests/test_csharp_extension_metadata.py— impacttests/test_csharp_extension_resolution.py— impacttests/test_csharp_partial_classes.py— impacttests/test_dart.py— impacttests/test_dart_typedef.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_ext_tagged_id_clash.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_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_java_member_calls.py— impacttests/test_java_nested_type_identity.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_js_member_collisions.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_injected_factory_calls.py— impacttests/test_python_property_reads.py— impacttests/test_python_pytest_fixture_receivers.py— impacttests/test_python_subscript_type_refs.py— impacttests/test_python_underscore_resolution.py— impacttests/test_rationale.py— impacttests/test_ruby_resolution.py— impact, changed-testtests/test_scala_context_bounds.py— impacttests/test_scala_extension_methods.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— impact- … and 2 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.
Every flagged function
extract()ingraphify/extract.py:11742· 1284 callers, 78 callees: fans out to 78 callees (efferent coupling); 1284 callers depend on it (afferent coupling)
What does this PR do?
Re-submission of #1816, rebased onto current v8 (340268a), which supersedes it.
An
include/prependinside aclass << selfblock injects the module's instance methods as the enclosing class's own singleton (class) methods, the same relationshipextend Modexpresses in the class body, which the extractor already captures asmixes_in(#1668). The Ruby mixin scan only walked the class/module body's direct children, so the nested form produced no edge:The scan now also iterates the statements of
class << selfblocks in the body, reusing the existing constant-argument filter and the single-owner resolver guard. Onlyselfcounts:class << otheropens a different object's singleton class, so anincludethere stays unlinked.Type of change
Verification & Invariants
Invariant: a module mixed into a class's singleton class is a
mixes_inof that class, however it is written. The negative test coversclass << obj, which must not produce an edge.Limitation: only
class << selfblocks directly in the class/module body are scanned; one nested inside a method or a conditional is not.Cached Ruby extractions need a schema bump to pick this up. I left
_AST_CACHE_SCHEMAalone, since recent fixes have it folded into your combined bump; happy to add it here instead.How was this tested?
Python 3.11.16 on macOS, environment from
uv sync --all-extras, branch based on v8 340268a.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (No skill sources touched.)AI disclosure: drafted with help from Claude Code and reviewed before posting; the commit carries a
Co-Authored-Bytrailer.