Repository navigation
fix(swift): keep _name/name member twins apart in node ids - #5204
rohit-jsfreaky wants to merge 1 commit into
Conversation
…ode ids make_id strips a leading `_` and folds case, so the methods of one Swift type `_flatMap()` / `flatMap()` or `hexdumpDetailed()` / `hexDumpDetailed()` minted ONE id. add_node kept the first declaration and dropped the second: the method vanished, the calls it makes were credited to its twin, and calls to it landed on the twin. Apply the Python/C#/Solidity/Java rule (Graphify-Labs#3302, Graphify-Labs#4415, Graphify-Labs#5058, Graphify-Labs#5151): a type's id is its file stem plus its name, so its class body and every same-file `extension` share one id space; group the methods of all of them by the id they would get and run each through `_underscore_salted_nid`. The one public name keeps the plain id, every other spelling is salted. Members that collide with nothing keep their ids; overloads share one name, so they are not a collision. The cross-file member-call pass indexed methods by a folded key, so with both twins present `foo.bar()` from another file bound to whichever came last. It now binds the exact spelling first and falls back to the folded key only when the type has no member so named. Measured on Alamofire, swift-nio and swift-collections: 117 colliding groups, 137 methods that had no node on v8 now do, and 354 call edges that v8 credited to a twin now hit the right method. One v8 id changed, inside a case-only group where both names are public. The resolver change also re-points 7 test calls from `_append`/`_insert`/... to the public `append`/`insert`/... they name. Bump _AST_CACHE_SCHEMA to 46 so cached Swift extractions re-run. Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for the pull request, @rohit-jsfreaky. 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: \_resolve\_swift\_member\_calls (vacuous: never exercised), \_extract\_generic (unsupported).
Graphify review — findings
Bumps the AST cache schema to 45 so cached C#, Java and SQL extractions re-run. C# fields and primary-constructor parameters with non-capitalised type names (_Pair, pair, bool) now enter the receiver table, and a member call on an undeclared receiver is tagged receiver_undeclared, so _Pair.Make() binds as a static call. A Java call through a class-qualified static field resolves via the field's declared type, SQL routine bodies keep comma joins and @dblink suffixes, and Swift typed receivers bind to the exact underscore-twin across files, though Swift collision groups are keyed on the simple name and can merge distinct types that share one.
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 5638 functions depend on the 942 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
walk()— 1 callers, 93 callees
Verification — 5638 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: 4938 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
352 of 565 test file(s) selected (62%) via static blast radius.
tests/test_4874_jvm_resolution.py— impacttests/test_4978_reconcile_cost.py— impacttests/test_4992_ts_import_types.py— impacttests/test_affected_overrides.py— impacttests/test_alias_folding.py— impacttests/test_analyze.py— impacttests/test_astro_extraction.py— impacttests/test_astro_import_ids.py— impacttests/test_binary_media_words.py— impacttests/test_blade_extractor.py— impacttests/test_build.py— impacttests/test_build_located_semantic_identity.py— impacttests/test_build_merge_dedup_scope.py— impacttests/test_build_merge_ghost_fold_4955.py— impacttests/test_build_merge_hyperedges_and_prune.py— impacttests/test_build_merge_shrink_guard.py— impacttests/test_builtin_global_type_refs.py— impacttests/test_c_include_resolution.py— impacttests/test_cache.py— impacttests/test_cache_long_paths.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cache_windows_case_4925.py— impacttests/test_carried_hyperedge_remap.py— impacttests/test_case_only_decl_ids_4904.py— impacttests/test_case_sensitive_resolution.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_cli_export.py— impacttests/test_cluster.py— impacttests/test_cobol_extractor.py— impacttests/test_code_only_scope_4923.py— impacttests/test_confidence.py— impacttests/test_confidence_score_output.py— impacttests/test_corrupt_graph_json.py— impacttests/test_cpp_alias_member_resolution.py— impacttests/test_cpp_anonymous_namespace_receivers.py— impacttests/test_cpp_conditional_initializers.py— impacttests/test_cpp_forward_declarations.py— impacttests/test_cpp_forward_receiver_completion.py— impacttests/test_cpp_inherited_member_resolution.py— impacttests/test_cpp_local_callable_shadowing.py— impacttests/test_cpp_member_call_by_receiver_type.py— impacttests/test_cpp_member_declaration_identity.py— impacttests/test_cpp_method_declarations.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cpp_receiver_chains.py— impacttests/test_cpp_receiver_parameters.py— impacttests/test_cpp_split_header_owner.py— impact- … and 302 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.
Docs that may be stale (advisory)
.github/PULL_REQUEST_TEMPLATE.md§ Graphify-specific checklist (lines 33-39): references changed symbolsrunARCHITECTURE.md§ Confidence labels (lines 122-240): references changed symbolsRunBENCHMARKS.md§ Reproducing (lines 190-203): references changed symbolsrunCHANGELOG.md§ 0.9.108 (2026-11-12) (lines 5-19): references changed symbolsotherCHANGELOG.md§ 0.9.107 (2026-11-11) (lines 20-35): references changed symbolsRun,bar,runCHANGELOG.md§ 0.9.101 (2026-11-02) (lines 163-186): references changed symbolshelperCHANGELOG.md§ 0.9.98 (2026-10-30) (lines 223-242): references changed symbolsRunCHANGELOG.md§ 0.9.97 (2026-10-27) (lines 243-268): references changed symbolsrunCHANGELOG.md§ 0.9.96 (2026-10-25) (lines 269-299): references changed symbolsrun,useCHANGELOG.md§ 0.9.95 (2026-10-23) (lines 300-325): references changed symbolsother
…and 10 more.
Formal verification
Could not verify: Could not verify \_resolve\_swift\_member\_calls.
The verifier did not have enough to check \_resolve\_swift\_member\_calls, 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: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous
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
· 1 more finding(s) on lines outside this diff (see the check run).
|
Landed on v8 as e68e728 via authorship-preserving cherry-pick, released in graphify 0.9.109. Thanks @rohit-jsfreaky. |
Closes #5203
What does this PR do?
Swift members whose names differ only by a leading
_or by case now get separate node ids, the same way as Python and C# (#3302, #4415), Solidity (#5058) and Java (#5152): the one public name keeps its id and the others get a salted id._underscore_salted_nid._AST_CACHE_SCHEMA45 -> 46 (Swift output changes).Numbers
The answer key is a separate tree-sitter scan that counts declarations per class/type.
hexdumpDetailed/hexDumpDetailed)append/insert/... instead of_append/...; 6 v8 guesses that only worked because a twin had vanished are gone; 1 correct edge was lost (BigString.append -> _appendis now ambiguous with_Chunk._append); 1 call now goes to the wrong method (s.index()lands on_index), becauseTreeSet.indexitself collides with the nested typeTreeSet.Index, a separate existing bug ([Bug]: Swift: same-named nested types in one file collapse into one node (e.g. twoCodingKeysenums) #4575 is a related nested-type one).Repro
._bar()node;.bar()calls bothhelperandother.foo_foo_bar_2c4c06(._bar()) exists and every call lands on the right method.Type of change
Verification & Invariants
Invariant: every Swift member declaration gets its own node, and a call is credited to the member it is written in. Ids outside a colliding group are unchanged. Persisted state: the AST cache is bumped, so cached Swift extractions re-run.
How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.