Skip to content

Cross-file inference creates false edges via common .NET method names #437

Open

Description

@V0v1kkk

Problem

The cross-file call resolution in extract.py matches unresolved callee names against any node label in the graph. Common .NET BCL method names (Contains, Equals, ToString, Where, Select, Add, Remove, etc.) match unintended nodes — for example, string.Contains() calls match F# union case EdgeRelation.Contains, or list.Add() matches a user-defined Add method in a completely unrelated module.

This creates hundreds of false INFERRED edges, pollutes community detection, and produces misleading god nodes.

Proposed Fix

Add a blocklist of ~120 common .NET BCL/framework method names that are skipped during cross-file call resolution. This is the same pattern used by the existing _SKIP_LABELS set but targeted at method names rather than module names.

Impact

Tested on a mixed F#/C#/Blazor project:

  • False INFERRED edges dropped from 538 to 362
  • Top hub changed from Contains (false positive) to BookService (correct)

I have a PR ready for this.

Activity

  1. singhsatyampratap commented on Aug 6, 2026

    @singhsatyampratap

    Confirming this on Python + JavaScript (0.9.34), and flagging that the proposed remedy — a
    ~120-name .NET BCL blocklist — would not have caught my case, because the colliding names are all
    user-defined.

    Corpus: a mixed Python/JS monorepo, three sibling applications under one directory, no shared code
    layer between them by design. Extraction: --code-only --no-cluster (no LLM), 527 files, 6831 nodes,
    15811 edges.

    Of the 40 edges the graph drew between the three applications, 37 were INFERRED and all 37
    were false
    . Representative, with names generalised:

    app_a/main.py            .update_file_list()  ->  .cmap()    [app_c/render.py]
    app_a/panels/nouns.py    make_tools_panel()   ->  .load()    [app_b/scripts/extract.py]
    app_a/types/raster.py    .plot()              ->  norm()     [app_b/scripts/extract.py]
    

    Verified mechanism on one of them: a function get_cmap_color(cmap_name) in app A was linked to a
    property def cmap(self) in app C. The only thing they share is the string cmap. Same for .load(),
    .update(), .toggle(), .norm() — ordinary domain vocabulary, not framework methods, so no
    BCL/stdlib blocklist reaches them.

    Two observations that may be useful for the fix:

    1. The false edges concentrate exactly where they do the most damage. Intra-application edges were
      fine (app A 9285, app B 3921, app C 579, all plausible). It is the cross-module edges — the ones a
      reader consults precisely because they are surprising — where precision collapsed to ~7% (3/40).
      A user checking "are these two subsystems coupled?" gets a confident wrong answer.
    2. A blocklist is the wrong shape for this. The three EXTRACTED cross-application edges in the
      same run were all correct (verified against source — genuine from x.y import z statements). The
      split is clean: resolution that has a real binding is trustworthy; resolution that falls back to
      matching a bare callee name against any node label in the graph is not. Rather than enumerating
      names to skip, consider not emitting a cross-file INFERRED edge at all when the only evidence is a
      name match on a dotted/receiver-less call (obj.method()), which is also what calls edges are never resolved for member/dotted calls (obj.method(), Type.method()) by deliberate design — only bare (undotted) calls resolve, via a fragile label-text match that isn't scoped to real definitions #2041 is about.
      That would be language-agnostic and would have removed all 37 here without touching the 3 true ones.

    Workaround for anyone landing here: filter confidence == "EXTRACTED" before reading the graph. On
    that filter the output was accurate in my run — it correctly surfaced a real cross-application import I
    did not know about.

  2. durmazoguzhan commented on Aug 24, 2026

    @durmazoguzhan
    Contributor

    A data point from a nearby change, since this issue is the reason I checked.

    While adding object creation to the C# call_types (#2997, patch in #2998) I tested what happens when the constructed name is ambiguous. Two classes called Cache in different namespaces, one construction site, using on one of them: the result is no edge at all rather than a pick.

    So for type-name targets the guard already behaves the way you describe here. I added a test that asserts it, so a later change cannot turn it into a false edge without the suite noticing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions