AST extractor emits meaningless `uses` edges from builtin-type nodes (str/int/bool) at confidence 0.5 — inflates god-node rankings
Version: graphifyy 0.8.32 (pip, Windows, Python 3.12)
What happened
The AST extractor creates per-file nodes for builtin type annotations (str, int, bool, float, also MagicMock) and links them with uses edges to user classes that merely co-occur in the same function signature. All these edges carry confidence_score=0.5 — the exact value the extraction spec forbids as a default.
Example (measured on a ~6,000-node graph of a Python repo)
A class PipelineLog reported 60 edges / 37 INFERRED. On inspection, 14 of the INFERRED edges were of the form:
src_services_google_scout_py_str -> services_pipeline_logger_pipelinelog [uses, 0.5]
src_services_google_scout_py_int -> services_pipeline_logger_pipelinelog [uses, 0.5]
tests_test_find_contact_fallthrough_py_magicmock -> ... [uses, 0.5]
These come from signatures like def f(place_id: str, domain: str, plog: PipelineLog) -> Optional[dict]. A "str uses PipelineLog" edge is semantically meaningless.
Impact
- Degree counts inflate ~25% on affected classes;
str(35 edges) andJSONResponse(50 edges, 48 INFERRED) appeared in the god-node top-10 of GRAPH_REPORT.md, displacing real abstractions. - The report's suggested questions then point users at verifying these junk edges.
Related (same family): a type annotation at a usage site (plog: PipelineLog in another module) produced a ghost duplicate node (pipelinelog, source = the using file) separate from the real class node (services_pipeline_logger_pipelinelog), connected only by an INFERRED uses 0.5 edge.
Suggested fix
Skip uses edges where either endpoint is a builtin/typing name (str/int/float/bool/bytes/dict/list/Optional/Any/...), or at minimum exclude builtin nodes from degree/god-node statistics.
Fixed in v0.8.33 (a380b34).
Added _PYTHON_ANNOTATION_NOISE frozenset covering scalar builtins (str, int, float, bool, bytes, bytearray, complex, object) and test mocks (MagicMock, Mock, AsyncMock, etc.). Applied at all three guards in _python_collect_type_refs so these names are never created as nodes or emitted as edges.
Defense-in-depth guard added to god_nodes in analyze.py so pre-existing graphs are also protected — builtins won't appear in rankings even if a graph was built before this fix.
Upgrade: uv tool upgrade graphifyy