Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(graph): the bare-name tier must not answer for the standard library (#1708)
Raghav Chamadiya13cc339a7a7c
diff --git a/packages/core/src/repowise/core/ingestion/call_resolver.py b/packages/core/src/repowise/core/ingestion/call_resolver.pyindex 472a1d484..259f79dfe 100644--- a/packages/core/src/repowise/core/ingestion/call_resolver.py+++ b/packages/core/src/repowise/core/ingestion/call_resolver.py@@ -31,6 +31,7 @@ from typing import Anyimport structlog+from .language_data import get_builtin_methodsfrom .languages.receiver_types import (FRAMEWORK_DECORATOR_LANGUAGES,IMPLICIT_FIELD_LANGUAGES,@@ -946,8 +947,15 @@ class CallResolver:# and a method both declare, firing the tier where it used to refuse —# measured at +916 new 0.50-confidence edges on goose, on the one tier# hand-read at 28.6% precision.+ #+ # A std-library name is refused the same way, and for the same reason+ # one rung up: the name is in scope in every file without an import,+ # so the repo symbol that happens to share it is not what the call+ # site named. `Ok(())` and a chained `.unwrap()` are the shape.candidates = self._global_symbols.get(target_name, [])if len(candidates) == 1 and candidates[0] != caller_id:+ if target_name in get_builtin_methods(self._language_of(file_path) or ""):+ return Noneif candidates[0] in self._non_callable_ids:# Refused here rather than by falling through, so "this tier# can lose an edge but never gain one" is true of the controldiff --git a/packages/core/src/repowise/core/ingestion/language_data.py b/packages/core/src/repowise/core/ingestion/language_data.pyindex f8f3958a6..991e7d686 100644--- a/packages/core/src/repowise/core/ingestion/language_data.py+++ b/packages/core/src/repowise/core/ingestion/language_data.py@@ -49,6 +49,12 @@ def get_builtin_parents(language: str) -> frozenset[str]:return spec.builtin_parents if spec else frozenset()+def get_builtin_methods(language: str) -> frozenset[str]:+ """Return the std-library method names the bare-name tier must not answer."""+ spec = REGISTRY.get(language)+ return spec.builtin_methods if spec else frozenset()++def get_builtin_types(language: str) -> frozenset[str]:"""Return the type names that never resolve to a repo-declared symbol."""spec = REGISTRY.get(language)diff --git a/packages/core/src/repowise/core/ingestion/languages/spec.py b/packages/core/src/repowise/core/ingestion/languages/spec.pyindex 29fce0596..6122e29c9 100644--- a/packages/core/src/repowise/core/ingestion/languages/spec.py+++ b/packages/core/src/repowise/core/ingestion/languages/spec.py@@ -147,6 +147,13 @@ class LanguageSpec:# clause; a type may be ubiquitous in parameter position without ever# being inherited from.builtin_types: frozenset[str] = field(default_factory=frozenset)+ # Method and constructor names the language's own standard library owns.+ # Read *only* by the bare-name fallback in ``CallResolver``, to stop it+ # answering ``Ok(..)`` or ``.unwrap()`` with whatever same-named symbol the+ # repository happens to declare once. Deliberately not ``builtin_calls``:+ # that set is matched receiver-blind in the parser and drops the call site+ # outright, which would also delete a real ``obj.unwrap()`` edge.+ builtin_methods: frozenset[str] = field(default_factory=frozenset)# -- Display ---------------------------------------------------------color_hex: str = "#8b5cf6" # fallback purple ("other")diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/rust.py b/packages/core/src/repowise/core/ingestion/languages/specs/rust.pyindex fd77c36dd..5d5ea6788 100644--- a/packages/core/src/repowise/core/ingestion/languages/specs/rust.py+++ b/packages/core/src/repowise/core/ingestion/languages/specs/rust.py@@ -111,5 +111,34 @@ SPEC = LanguageSpec("Self", "self",}),+ # Prelude constructors and std trait methods. Every one is in scope in+ # every file without an import, so a bare-name guess that answers one with+ # a repo symbol is answering for the standard library — `Ok(())` bound to+ # the single repo symbol spelled `Ok`, `.unwrap()` on a chained receiver+ # bound to an unrelated private helper. Names a repository plausibly+ # declares and calls in its own right (`new`, `from`, `get`, `len`, `map`,+ # `next`, `insert`, `push`, `parse`) are deliberately absent: the tier this+ # feeds is a guess, but it is not always a wrong one, and the gate is that+ # every edge it loses was wrong.+ builtin_methods=frozenset(+ {+ # Prelude constructors and variants+ "Ok", "Err", "Some", "None",+ # Option / Result+ "unwrap", "unwrap_or", "unwrap_or_else", "unwrap_or_default",+ "unwrap_err", "expect", "expect_err",+ "is_some", "is_none", "is_ok", "is_err",+ "ok_or", "ok_or_else", "map_err", "and_then", "or_else",+ # Iterator+ "collect", "filter_map", "flat_map", "enumerate", "rev",+ "cloned", "copied", "into_iter", "peekable", "zip",+ # Conversion and ownership+ "to_owned", "to_string", "to_vec", "as_ref", "as_mut",+ "as_str", "as_bytes", "as_slice", "borrow_mut",+ # str / slice / Path methods with no plausible repo twin+ "starts_with", "ends_with", "to_lowercase", "to_uppercase",+ "canonicalize", "is_file", "is_dir",+ }+ ),color_hex="#DEA584",)