Repository navigation
fix(csharp): label C# methods with their owning type (#4883) - #4889
safishamsi merged 1 commit into
Conversation
) Every C# method was labeled `.Name()`, so an interface method and each of its implementations printed identically (`.Build()` x3) and only the line told them apart. The graph build now assigns C# methods an `Owner.Name()` display label, taken from the source of the method's `method` edge, as the last step of build_from_json and in both --no-cluster writers (same placement as the Graphify-Labs#2032 file-label disambiguation). Ids and edges are unchanged, and a method with zero or several owners keeps its bare label. Extraction keeps emitting the bare `.Name()` form that call resolution, interface dispatch, and the method-ghost index match on. Readers of a persisted graph normalize back to it: incremental resolution context in extract(), the build method-ghost and old-stem alias indexes, and the analyze method-stub predicate. Fixes Graphify-Labs#4883 Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: Syed Fahad <[email protected]>
|
Thanks for the pull request, @SyedFahad7. 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 6 changed function(s) (1 sampled, not proven, 5 not verified).
Formal verification. PR-changed functions: 1/6 verified (0 proven, 1 may-equivalent, 0 distinguished) · 5 not verified (3 vacuous, 2 unsupported).
Not verified on this run: \_is\_file\_node (vacuous: never exercised), \_alias\_index (unsupported), build\_from\_json (vacuous: never exercised), dispatch\_command (vacuous: never exercised), \_rebuild\_code (unsupported).
Graphify review — findings
Adds owner-qualified display labels for C# methods (Owner.Name() instead of bare .Name()), applied as a final pass in build_from_json and in the --no-cluster writer path. Ids and edges stay unchanged, and a method with no owner, several distinct owners, or a non-plain owner name keeps its bare label. Resolvers, the method-ghost alias index, and the analyze file-node check all go through bare_csharp_method_label, so they still recognise the qualified form. extract reverts persisted labels to the bare form before using them as resolution context, so incremental runs match fresh extractions.
No blocking issues surfaced. 5 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 5157 functions depend on the 738 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1059 callers, 63 callees - worse:
_rebuild_code()— 209 callers, 66 callees - worse:
build_from_json()— 277 callers, 22 callees - worse:
dispatch_command()— 5 callers, 136 callees - worse:
finalize_raw_graph_endpoints()— 11 callers, 4 callees - new:
csharp_method_label_reassignments()— 5 callers, 3 callees - worse:
_alias_index()— 2 callers, 7 callees
Verification — 5157 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: 4887 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
352 of 470 test file(s) selected (75%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_affected_overrides.py— impacttests/test_affected_path_file_node.py— impacttests/test_agents_platform.py— impacttests/test_alias_folding.py— impacttests/test_analyze.py— impacttests/test_astro_extraction.py— impacttests/test_astro_import_ids.py— impacttests/test_atomic_canvas_export.py— impacttests/test_atomic_writes.py— impacttests/test_backend_opt_in.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.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_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_stale_import_target.py— impacttests/test_carried_hyperedge_remap.py— impacttests/test_case_sensitive_resolution.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_claude_cli_backend.py— impacttests/test_cli_export.py— impacttests/test_cloud_cta.py— impacttests/test_cluster.py— impacttests/test_cobol_extractor.py— impacttests/test_codebuddy.py— impacttests/test_community_labels_skill.py— impacttests/test_compact_graph_json.py— impacttests/test_confidence.py— impacttests/test_corrupt_graph_json.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_template_type_params.py— impacttests/test_cpp_type_alias.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_cross_language_call_resolution.py— impacttests/test_cross_repo_external_call_guards.py— impacttests/test_cross_repo_member_calls.py— impacttests/test_csharp_call_site_generic_args.py— impacttests/test_csharp_delegate_declarations.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.
Formal verification
Could not verify: Could not verify \_is\_file\_node.
The verifier did not have enough to check \_is\_file\_node, 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 \_alias\_index.
The verifier did not have enough to check \_alias\_index, 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 `nodes` is annotated `'Iterable[tuple[str, dict]]'` — outside the synthesizable primitive/collection set
Could not verify: Could not verify build\_from\_json.
The verifier did not have enough to check build\_from\_json, 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 11 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous
Could not verify: Could not verify dispatch\_command.
The verifier did not have enough to check dispatch\_command, 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 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)
No difference found (not proven): No behavior difference found in extract (not a proof).
The verifier ran both versions of extract on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
Could not verify: Could not verify \_rebuild\_code.
The verifier did not have enough to check \_rebuild\_code, 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: nondeterministic output (both versions disagreed with themselves on the witness) — not a behaviour change; a function whose output is not a function of its inputs (random / time / uuid / os.urandom, or state carried across calls) cannot be soundly distinguished by execution, so this tier abstains for the whole function
· 1 grounded finding(s) anchored inline below; 6 more finding(s) on lines outside this diff (see the check run).
| return out | ||
|
|
||
|
|
||
| def csharp_method_label_reassignments( |
There was a problem hiding this comment.
csharp_method_label_reassignments()
high coupling complexity (Ca·Ce = 15).
Grounded coupling-delta finding (deterministic), not an LLM guess.
…els, path weakest-hop confidence, Type.Member path endpoints Covers the SyedFahad7 batch: #4891 and #4889 merged on GitHub; #4892 and #4893 landed via authorship-preserving cherry-pick (their CI matrix was gated pending first-contributor approval, so brought in through the local gate instead). Credit by GitHub PR-author login @SyedFahad7. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…4888) #4888 was built on 0.9.97, before #4881 (path weakest-hop refactor), #4889 (qualified C# method labels) and #4891 (also_seen) landed. Its cherry-pick dropped the merge commit that reconciled expectations. Update the per-hop confidence assertions to carry scores ([INFERRED 0.85]) and the C# path/explain/neighbor labels to their owner-qualified form (Exporter.Run, IReport.Build) - the correct composed output of all four features. Resolved the serve.py conflict by keeping #4881's _path_weakest/ _path_confidence_line and adding only #4888's _confidence_tag, applied over edge_evidence so parallel/also_seen evidence keeps its scores. Co-Authored-By: Claude Opus 4.8 <[email protected]>
What does this PR do?
Every C# method node was labeled
.Name(), so on the #4883 repro the interface method and both implementations all printed as.Build()and only the line number told them apart:After this change (
graphify update .thengraphify explain report_ireport_build):Node IDs and edges are unchanged; only the display label changes.
Where the label is assigned. The
.Name()shape is load-bearing during extraction: the direct-call label index, the C# member-call resolvers, interface dispatch (interface_dispatch.method_label), and the build method-ghost passes all match on it. So extraction still emits.Name(). The owner-qualified label is applied as the last step ofbuild_from_jsonand in both--no-clusterwriters (watch._rebuild_code,cli). This is the same placement and contract as the #2032 file-label disambiguation. The owner comes from the source of the method'smethodedge, read through_src/_tgton undirected graphs.Reading persisted labels back. Code that reads labels from an existing
graph.jsonnow convertsOwner.Name()back to.Name()through one helper,bare_csharp_method_label:extract()normalizesresolution_context_nodeson intake. The caller's dicts are copied, never mutated. Without this, an incremental rebuild of only the caller loses thecallsedge into an unchanged file.build._alias_index(the<stem>_<method>alias) and the extraction-spec method IDs omit the class segment the AST extractor emits, so method nodes never dedupe #3705 method-ghost index inbuild_from_json.analyze._is_file_node, so C# methods stay out of god nodes and knowledge-gap reporting.The issue's refs (
extractors/csharp.py~49/~126) are the type-def index and namespace lookup. Both already reject dotted labels and never see method labels, so they need no change.Fixes #4883
Type of change
Verification & Invariants
Invariants protected:
extract()output.extract()still returns.Name()for C# methods.callsanddispatches_toedges and the labels match a full rebuild.PdfReport.PdfReport.Build()..Name().effective_suffixis.cs. Java and Swift labels are unchanged (tested).Persisted state: existing graphs pick up the new C# labels on the next build. Extraction output and the per-file AST cache are unchanged, so no cache schema bump is needed. Community names derived from C# method labels (for example in
GRAPH_REPORT.mdor the wiki) may change text accordingly.Each added piece was shown to be necessary by reverting it on its own and re-running
tests/test_csharp_method_owner_labels.py:--no-cluster, incremental, context normalization, god nodes, ghost collapse).extract()context normalization reverted: 2 tests fail (incremental rebuild, context normalization).analyzepredicate reverted: 1 test fails (god nodes).Limitations / unsupported cases
protocol Report,PdfReport,CsvReportall show.build()). It is not changed here. Swift needs the same treatment plus its own checks: extension members merged across files by_merge_swift_extensions, and the Swift member-call and protocol-dispatch resolvers reading context labels. The helpers here are suffix-gated, so a follow-up can extend them, but that is a separate concern with its own tests..razor/.cshtml) methods keep.Name(). Only.cs(including rcfile-mapped suffixes) is relabeled.Inner.Deep(), notOuter.Inner.Deep()).How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no skill fragments touched)