Repository navigation
Conversation
… or class (Graphify-Labs#2810) The Python collision pre-scan (Graphify-Labs#3302) recorded module-level functions and class methods but not module-level class names, so a class sharing an id with a function or another class after normalization still lost one declaration to first-wins add_node: - `class Session` / `def session()` (requests/sessions.py): session() is absent from the graph, and which one survives depends on declaration order - `class Foo` / `class FOO`, `class Pair` / `class _Pair` Record module-level classes in the same scope as functions and salt the class id with the existing _underscore_salted_nid rule. Methods of a salted class are minted under the salted id, so the pre-scan now keys their groups under the class's resolved id; keying them under the plain one would drop the existing `_get`/`get` protection inside that class. Same-file base-class references go through the same salt (as C# already does), so `class Sub(Session)` binds to the real class instead of minting a sourceless `Session` stub. The pre-scan also looks through decorated_definition, so `@dataclass class Session` and the `_x` / `@property x` method idiom are covered too. Ids change only for files that contain such a collision; cached AST results for them keep the collapsed ids until the AST cache schema is bumped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the pull request, @hementhu. 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 2 changed function(s) (2 not verified).
Formal verification. PR-changed functions: 0/2 verified (0 proven, 0 may-equivalent, 0 distinguished) · 2 not verified (1 vacuous, 1 unsupported).
Not verified on this run: \_extract\_generic (unsupported), \_python\_pre\_scan\_underscore\_collisions (vacuous: never exercised).
Graphify review — findings
Fixes silent node loss in the Python extractor when a module-level class collides on an id with a function or another class (Session / session(), Foo / FOO, Pair / _Pair). Previously first-wins add_node dropped one declaration, and which one survived depended on source order. The underscore/case collision pre-scan now records module-level class names alongside functions, sees through @decorator wrappers, and keys each class's methods under the class's resolved (possibly salted) id so _get/get inside a salted class stay distinct. Class and function id minting applies the same salting, so the public member keeps its plain id and the colliding one gets a salted id. Adds tests for order independence, constructor-call and subclass edges landing on the salted class (no phantom stub), cross-file import resolution, and decorated classes.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 952 functions depend on the 381 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, 42 callees (high)extract_js()— 93 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 — 952 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: 841 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
37 of 422 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_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_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— impact, changed-testtests/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.
Docs that may be stale (advisory)
ARCHITECTURE.md§ Edge direction in graph.json (lines 67-72): references changed symbolsgetARCHITECTURE.md§ Testing (lines 100-133): references changed symbolsFooCHANGELOG.md§ 0.9.86 (2026-10-11) (lines 99-120): references changed symbolsFooCHANGELOG.md§ 0.9.78 (2026-10-06) (lines 222-237): references changed symbolsFooCHANGELOG.md§ 0.9.66 (2026-09-22) (lines 400-414): references changed symbolsFooCHANGELOG.md§ 0.9.65 (2026-09-20) (lines 415-427): references changed symbolsFooCHANGELOG.md§ 0.9.64 (2026-09-18) (lines 428-439): references changed symbolsFooCHANGELOG.md§ 0.9.63 (2026-09-16) (lines 440-447): references changed symbolsFooCHANGELOG.md§ 0.9.58 (2026-09-10) (lines 490-507): references changed symbolsFooCHANGELOG.md§ 0.9.56 (2026-09-07) (lines 516-528): references changed symbolsget
…and 10 more.
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
Could not verify: Could not verify \_python\_pre\_scan\_underscore\_collisions.
The verifier did not have enough to check \_python\_pre\_scan\_underscore\_collisions, 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 253 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)
|
Full suite on this branch, per the checklist above:
Ids are minted from the source alone (sha1 of the declared name, same |
|
Landed in 0.9.92 (authorship-preserving cherry-pick, so it shows on your contributions). Thanks @hementhu! Released to PyPI: https://pypi.org/project/graphifyy/0.9.92/ · https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.92 |
|
Thanks @safishamsi, and thanks for the quick turnaround! Glad |
What broke
ids.pycasefolds and strips_, so distinct Python declarations in one module can mint the same node id. #3302 added a pre-scan that salts colliding module-level functions and class methods, but module-level class names were never recorded in it. So:class Session+def session()Sessionsession()class Foo+class FOOFooclass Pair+class _PairPairkeeps its plain idrequests/sessions.py(2.32)session()Which declaration survives depends on declaration order.
explain sessionthen answers with the class.Fix
In
_python_pre_scan_underscore_collisions:_underscore_salted_nidrule (a unique public member keeps the plain id, others get a stable hash suffix, independent of order)._get/getprotection inside that class.decorated_definition, so@dataclass class Sessionand the_x/@property xmethod idiom are covered. The second one was also missed by Python: methods differing only by a leading underscore collide on node id — the public one is silently dropped from the graph #3302.ensure_named_nodeapplies the same salt for Python, as it already does for C#, soclass Sub(Session)in the same file binds to the real class instead of minting a sourcelessSessionstub.Tests
Ten tests are added to
tests/test_python_underscore_resolution.py. Eight fail onv8. The other two (methods inside a salted class keep their protection; a same-file subclass binds to the salted class) guard against regressions a naive fix introduces.They also cover: order independence, the constructor call
session()→Session, and a cross-filefrom sessions import Session, sessionresolving to both.uv run pytest tests/: 8059 passed, 15 skippeduv run ruff check .: cleanuv run pyright: 642 errors, the same as unmodifiedv8Notes
_AST_CACHE_SCHEMAis bumped. I left that to the release bump, as with Python: methods differing only by a leading underscore collide on node id — the public one is silently dropped from the graph #3302.🤖 Generated with Claude Code