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
feat(graph): link a framework-wired symbol to the symbol it is wired to (#1654)
Raghav Chamadiyafe173c62d4fd
diff --git a/packages/core/src/repowise/core/analysis/knowledge_graph.py b/packages/core/src/repowise/core/analysis/knowledge_graph.pyindex 1dd88fe69..6368d21d9 100644--- a/packages/core/src/repowise/core/analysis/knowledge_graph.py+++ b/packages/core/src/repowise/core/analysis/knowledge_graph.py@@ -215,7 +215,9 @@ def _slugify(text: str) -> str:# ranking, neither of which moves a node or edge count.# "3": `references` joined the map, so C/C++ dispatch tables and registration# macros reach the export instead of being dropped.-KG_BUILDER_VERSION = "3"+# "4": `framework_binds` joined the map, so a container-wired symbol pair+# reaches the export instead of being dropped.+KG_BUILDER_VERSION = "4"# An unmapped type is dropped from the export entirely (see the# `if not kg_type: continue` below), which is silent. Six real types used to be@@ -242,6 +244,7 @@ _EDGE_TYPE_MAP: dict[str, str] = {"implements": "depends_on","method_implements": "depends_on","dispatches_to": "depends_on",+ "framework_binds": "depends_on","reads": "depends_on","references": "depends_on",}diff --git a/packages/core/src/repowise/core/generation/onboarding/subkinds/key_concepts.py b/packages/core/src/repowise/core/generation/onboarding/subkinds/key_concepts.pyindex 04f93b2aa..ea8c887a8 100644--- a/packages/core/src/repowise/core/generation/onboarding/subkinds/key_concepts.py+++ b/packages/core/src/repowise/core/generation/onboarding/subkinds/key_concepts.py@@ -109,6 +109,7 @@ _RELATION_VERB: dict[str, str] = {"implements": "implements","method_implements": "implements","dispatches_to": "dispatches to",+ "framework_binds": "is wired to","reads": "reads from",# Named rather than called: a dispatch-table entry, a callback field, an# argument to a registration macro. "references" is the honest verb, sincediff --git a/packages/core/src/repowise/core/ingestion/framework_edges/base.py b/packages/core/src/repowise/core/ingestion/framework_edges/base.pyindex ef77f55af..101676af8 100644--- a/packages/core/src/repowise/core/ingestion/framework_edges/base.py+++ b/packages/core/src/repowise/core/ingestion/framework_edges/base.py@@ -61,6 +61,39 @@ def _add_edge_if_new(graph: nx.DiGraph, source: str, target: str) -> bool:return True+# Below `same_file` (0.95) because the framework can rebind at run time, level+# with the heritage-walk origins because the binding follows a documented rule+# and checks no signature.+FRAMEWORK_BIND_CONFIDENCE = 0.90+++def add_symbol_edge(graph: nx.DiGraph, source: str, target: str) -> bool:+ """Link two *symbol* nodes the framework wires together.++ Not a flag on ``_add_edge_if_new``: a ``DiGraph`` holds one edge per ordered+ pair and ``defines`` already occupies (file, symbol), so that helper's+ first-wins guard would let containment silently swallow a symbol edge.+ Both ends must already be symbol nodes, so a wrong id cannot mint a bare+ node with no attributes for every later consumer to defend against.+ """+ if source == target:+ return False+ for node in (source, target):+ data = graph.nodes.get(node)+ if data is None or data.get("node_type") != "symbol":+ return False+ if graph.has_edge(source, target):+ return False+ graph.add_edge(+ source,+ target,+ edge_type="framework_binds",+ confidence=FRAMEWORK_BIND_CONFIDENCE,+ imported_names=[],+ )+ return True++def read_text(parsed: Any, encoding: str = "utf-8") -> str:"""Read a parsed file's source text, returning ``""`` on read failure.@@ -87,6 +120,25 @@ def _build_class_to_file(return result+def build_type_to_symbol(+ parsed_files: dict[str, Any], languages: tuple[str, ...]+) -> dict[str, str]:+ """Map a declared type name → its symbol id, for names declared exactly once.++ Stricter than :func:`_build_class_to_file`, which keeps the first declarer:+ an ambiguous name must stay unclaimed rather than bind to whichever file the+ walk reached first.+ """+ seen: dict[str, str | None] = {}+ for _path, parsed in parsed_files.items():+ if parsed.file_info.language not in languages:+ continue+ for sym in parsed.symbols:+ if sym.kind in ("class", "interface", "struct", "record", "enum", "trait"):+ seen[sym.name] = None if sym.name in seen else sym.id+ return {name: sid for name, sid in seen.items() if sid is not None}++def _build_function_to_file(parsed_files: dict[str, Any], languages: tuple[str, ...]) -> dict[str, list[str]]:diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/express.py b/packages/core/src/repowise/core/ingestion/framework_edges/express.pyindex e857f1ff4..f512d5ee0 100644--- a/packages/core/src/repowise/core/ingestion/framework_edges/express.py+++ b/packages/core/src/repowise/core/ingestion/framework_edges/express.py@@ -15,6 +15,7 @@ from .base import (_add_edge_if_new,_build_class_to_file,_build_ts_var_to_file,+ add_symbol_edge,read_text,)@@ -57,15 +58,6 @@ def _match_paren(text: str, open_idx: int) -> int:return -1-def _add_reads_edge(graph: nx.DiGraph, source: str, target: str) -> bool:- if source == target or not graph.has_node(source) or not graph.has_node(target):- return False- if graph.has_edge(source, target):- return False- graph.add_edge(source, target, edge_type="reads", imported_names=[])- return True--def _has_express_imports(parsed_files: dict[str, Any]) -> bool:for parsed in parsed_files.values():if parsed.file_info.language not in ("typescript", "javascript"):@@ -120,7 +112,7 @@ def _add_express_edges(arg_blob = _STRING_LITERAL_RE.sub("", text[m.end() : close])for ident in _ARG_IDENT_RE.finditer(arg_blob):sym_id = local_funcs.get(ident.group(0))- if sym_id and _add_reads_edge(graph, module_sym, sym_id):+ if sym_id and add_symbol_edge(graph, module_sym, sym_id):count += 1# ---- NestJS: @Module({ controllers: [...], providers: [...], imports: [...] }) ----diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py b/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.pyindex 62ea21b54..056f0ba64 100644--- a/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py+++ b/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py@@ -1,23 +1,192 @@"""pytest conftest convention edges.-Split out of ``framework_edges.py`` (PR 3.5) — behaviour-preserving move.+Two conventions, both invisible to a static import graph: a ``conftest.py`` is+imported by collection rather than by any statement, and a test's parameter+names are fixture requests resolved at run time."""from __future__ import annotations+import re+from fnmatch import fnmatchfrom pathlib import Pathfrom typing import TYPE_CHECKING, Anyfrom ..resolvers import ResolverContext+from ..type_names import strip_type_argumentsfrom .base import (DetectionContext,FrameworkHandler,_add_edge_if_new,+ add_symbol_edge,)if TYPE_CHECKING:import networkx as nx+# Matched at the attribute tail rather than on `pytest.`, so `@my.fixture` and+# `@pytest_asyncio.fixture` are both accepted: pytest resolves the decorator by+# identity, not by module path.+_FIXTURE_DECORATOR_RE = re.compile(r"^@(?:[\w.]+\.)?fixture\b")+_PARAMETRIZE_RE = re.compile(r"^@(?:[\w.]+\.)?parametrize\b")+_QUOTED_RE = re.compile(r"""["']([^"']*)["']""")+# `@pytest.fixture(name="app")` registers `fixture_app` as `app`. Read as a+# top-level keyword only: a `name=` nested in a params list is not the+# fixture's name.+_NAME_KWARG_ARG_RE = re.compile(r"""^name\s*=\s*["']([^"']+)["']$""")++_TEST_FILE_RE = re.compile(r"(?:^|/)(?:test_[^/]*|[^/]*_test)\.py$")++# pytest collects methods only from classes matching `python_classes`, so a+# `class Harness` with a `test_connection` method is never run and its+# parameters are ordinary arguments its callers pass. The setting is read+# rather than assumed: celery configures `test_*`, and assuming the default+# refused 346 of its 359 bindings.+_DEFAULT_TEST_CLASS_GLOBS = ("Test*",)+_PYTHON_CLASSES_RE = re.compile(+ r"^\s*python_classes\s*=\s*(.+?)\s*$", re.MULTILINE+)+++def _test_class_globs(repo_path: Path | None) -> tuple[str, ...]:+ """The ``python_classes`` globs this project collects test classes by."""+ if repo_path is None:+ return _DEFAULT_TEST_CLASS_GLOBS+ for name in ("pyproject.toml", "pytest.ini", "tox.ini", "setup.cfg"):+ try:+ text = (repo_path / name).read_text(encoding="utf-8", errors="ignore")+ except OSError:+ continue+ match = _PYTHON_CLASSES_RE.search(text)+ if not match:+ continue+ globs = tuple(match.group(1).strip().strip("\"'").split())+ if globs:+ return globs+ return _DEFAULT_TEST_CLASS_GLOBS+++def _call_arguments(text: str) -> list[str]:+ """Top-level arguments of the first call in *text*, unsplit by nesting.++ A plain `split(",")` cannot do this and neither can one regex: a default+ value, a subscripted annotation and a nested `dict(...)` all contain the+ characters the split keys on. Depth counting with string awareness is the+ smallest thing that reads `def t(a, cb: Callable[[int], str], o=(1, 2))`+ correctly.+ """+ start = text.find("(")+ if start == -1:+ return []+ depth = 0+ quote: str | None = None+ escaped = False+ comment = False+ args: list[str] = []+ current: list[str] = []+ for ch in text[start:]:+ if comment:+ # A signature spanning several lines carries its comments, and an+ # apostrophe or a stray bracket in one used to swallow the rest of+ # the parameter list.+ if ch == "\n":+ comment = False+ continue+ if quote:+ current.append(ch)+ if escaped:+ escaped = False+ elif ch == "\\":+ escaped = True+ elif ch == quote:+ quote = None+ continue+ if ch == "#":+ comment = True+ continue+ if ch in "\"'":+ quote = ch+ current.append(ch)+ continue+ if ch in "([{":+ depth += 1+ if depth == 1:+ continue+ elif ch in ")]}":+ depth -= 1+ if depth == 0:+ args.append("".join(current))+ return [a.strip() for a in args if a.strip()]+ elif ch == "," and depth == 1:+ args.append("".join(current))+ current = []+ continue+ current.append(ch)+ # Unbalanced — a truncated signature. Return nothing rather than a guess.+ return []+++def _has_default(param: str) -> bool:+ """Whether a single parameter carries a default value."""+ depth = 0+ quote: str | None = None+ escaped = False+ for i, ch in enumerate(param):+ if quote:+ if escaped:+ escaped = False+ elif ch == "\\":+ escaped = True+ elif ch == quote:+ quote = None+ continue+ if ch in "\"'":+ quote = ch+ elif ch in "([{":+ depth += 1+ elif ch in ")]}":+ depth -= 1+ elif (+ ch == "="+ and depth == 0+ # A comparison or walrus is not a default.+ and param[i - 1 : i] not in ("=", "<", ">", "!", ":")+ and param[i + 1 : i + 2] != "="+ ):+ return True+ return False+++def _fixture_scopes(parsed: Any, class_name: str | None) -> list[str | None]:+ """The class scopes a test in *class_name* can see a fixture through.++ A subclass sees its base's fixtures, which is the commonest class-scoped+ arrangement there is -- scoping the lookup to the declaring class alone+ fixes a rare wrong edge by introducing a frequent missing one. Walked from+ the file's own heritage, so a base in another module is out of reach and+ stays unclaimed.+ """+ if class_name is None:+ return [None]+ parents: dict[str, list[str]] = {}+ for rel in parsed.heritage:+ parents.setdefault(rel.child_name, []).append(+ strip_type_arguments(rel.parent_name).strip()+ )++ scopes: list[str | None] = []+ seen: set[str] = set()+ queue = [class_name]+ while queue:+ current = queue.pop(0)+ if current in seen:+ continue+ seen.add(current)+ scopes.append(current)+ queue.extend(parents.get(current, ()))+ scopes.append(None)+ return scopes+def _add_conftest_edges(graph: nx.DiGraph, path_set: set[str]) -> int:"""conftest.py -> test files in the same or child directories."""@@ -40,6 +209,151 @@ def _add_conftest_edges(graph: nx.DiGraph, path_set: set[str]) -> int:return count+def _registered_name(sym: Any, decorator: str) -> str:+ """The name pytest registers the fixture under.++ ``name=`` must be read as a top-level keyword, not found anywhere in the+ text: ``@pytest.fixture(params=[dict(name="alice")])`` otherwise registers+ the fixture as ``alice``, which both loses the real request and mints a+ fabricated one.+ """+ for arg in _call_arguments(decorator):+ match = _NAME_KWARG_ARG_RE.match(arg)+ if match:+ return match.group(1)+ return sym.name+++def _declared_fixtures(parsed: Any) -> dict[tuple[str | None, str], str]:+ """``{(owning class or None, fixture name): symbol id}``.++ Keyed by scope rather than by name alone. A fixture declared inside a test+ class serves that class only, and flattening the two makes every sibling+ class share it — which is a wrong edge whichever way the collision is+ resolved.+ """+ out: dict[tuple[str | None, str], str] = {}+ for sym in parsed.symbols:+ if sym.kind not in ("function", "method"):+ continue+ for dec in sym.decorators:+ if not _FIXTURE_DECORATOR_RE.match(dec.strip()):+ continue+ out.setdefault((sym.parent_name, _registered_name(sym, dec)), sym.id)+ break+ return out+++def _requested_fixtures(sym: Any) -> list[str]:+ """The parameter names *sym* asks pytest to inject.++ Reads the recorded signature rather than re-parsing: a second pass over+ every test file is the cost of running inside the build rather than beside+ it.+ """+ supplied: set[str] = set()+ for dec in sym.decorators:+ if not _PARAMETRIZE_RE.match(dec.strip()):+ continue+ # Only the first argument is the argnames spec. Reading the whole+ # decorator instead makes every parametrize *value* look like a name+ # the test supplies, so a real fixture request whose name is also a+ # common literal is silently refused.+ args = _call_arguments(dec)+ if args:+ for token in _QUOTED_RE.findall(args[0]):+ supplied.update(p.strip() for p in token.split(","))++ names = []+ for raw in _call_arguments(sym.signature or ""):+ # A defaulted parameter is never injected -- pytest skips any argument+ # whose default is not empty. The `=` has to be found at depth zero:+ # `client: Annotated[int, Field(ge=0)]` has no default and is injected.+ if raw.startswith("*") or _has_default(raw):+ continue+ name = raw.split(":")[0].strip()+ if not name or name in ("self", "cls", "/"):+ continue+ if name in supplied:+ continue+ names.append(name)+ return names+++def _add_fixture_injection_edges(+ graph: nx.DiGraph, parsed_files: dict[str, Any], repo_path: Path | None = None+) -> int:+ """Link each test function to the fixture it asks for by name.++ Scope follows pytest's own rule, innermost first: the test's own class, then+ its module, then the nearest ``conftest.py`` at or above it. Nothing else is+ searched, so a plugin-provided fixture stays unclaimed rather than being+ bound to a same-named local one.+ """+ # Only a conftest's module-level fixtures are visible to other files; one+ # declared inside a class there serves that class alone.+ conftests: dict[str, dict[str, str]] = {}+ for path, parsed in parsed_files.items():+ if Path(path).name != "conftest.py":+ continue+ declared = {+ name: sid for (owner, name), sid in _declared_fixtures(parsed).items()+ if owner is None+ }+ if declared:+ conftests[Path(path).parent.as_posix()] = declared++ class_globs = _test_class_globs(repo_path)++ count = 0+ for path, parsed in parsed_files.items():+ if parsed.file_info.language != "python" or not _TEST_FILE_RE.search(path):+ continue++ own = _declared_fixtures(parsed)+ # Nearest-first: the deepest conftest directory that is a prefix of this+ # file's directory shadows the ones above it, as pytest does.+ chain = sorted(+ (d for d in conftests if path.startswith(f"{d}/") or d == "."),+ key=len,+ reverse=True,+ )++ for sym in parsed.symbols:+ if sym.kind not in ("function", "method") or not sym.name.startswith("test_"):+ continue+ if sym.parent_name and not any(+ fnmatch(sym.parent_name, g) for g in class_globs+ ):+ continue+ scopes = _fixture_scopes(parsed, sym.parent_name)+ for name in _requested_fixtures(sym):+ target = next(+ (own[(s, name)] for s in scopes if (s, name) in own), None+ ) or next(+ (conftests[d][name] for d in chain if name in conftests[d]), None+ )+ if target and add_symbol_edge(graph, sym.id, target):+ count += 1+ return count+++class _FixtureInjectionHandler:+ """A test's parameter names are fixture requests pytest resolves at run time."""++ def detect(self, dctx: DetectionContext) -> bool:+ return any(p.file_info.language == "python" for p in dctx.parsed_files.values())++ def add_edges(+ self,+ graph: nx.DiGraph,+ parsed_files: dict[str, Any],+ ctx: ResolverContext,+ path_set: set[str],+ ) -> int:+ return _add_fixture_injection_edges(graph, parsed_files, ctx.repo_path)++class _ConftestHandler:"""pytest ``conftest.py`` fixtures are imported implicitly by collection."""@@ -56,4 +370,4 @@ class _ConftestHandler:return _add_conftest_edges(graph, path_set)-HANDLERS: list[FrameworkHandler] = [_ConftestHandler()]+HANDLERS: list[FrameworkHandler] = [_ConftestHandler(), _FixtureInjectionHandler()]diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/spring.py b/packages/core/src/repowise/core/ingestion/framework_edges/spring.pyindex c0a931e3d..c6d4c827d 100644--- a/packages/core/src/repowise/core/ingestion/framework_edges/spring.py+++ b/packages/core/src/repowise/core/ingestion/framework_edges/spring.py@@ -30,11 +30,14 @@ from pathlib import Pathfrom typing import TYPE_CHECKING, Anyfrom ..resolvers import ResolverContext+from ..type_names import strip_type_argumentsfrom .base import (DetectionContext,FrameworkHandler,_add_edge_if_new,_build_class_to_file,+ add_symbol_edge,+ build_type_to_symbol,read_text,)@@ -65,8 +68,12 @@ _SPRING_BEAN_METHOD_KOTLIN_RE = re.compile(# Lombok constructor-synthesis annotations. RAC = constructor over every# ``final`` (and ``@NonNull``) field; AAC = constructor over every field.-_LOMBOK_RAC_ANNOT = ("@RequiredArgsConstructor", "@AllArgsConstructor")-_LOMBOK_DATA_VALUE = ("@Data", "@Value")+_LOMBOK_RAC_ANNOT = ("@RequiredArgsConstructor", "@AllArgsConstructor", "@Data")+# Lombok's `@Value` makes a class immutable and takes no argument; Spring's+# takes a property expression and sits on a field. Matching the bare spelling+# is what separates them — reading `@Value("${app.name}")` as Lombok turns+# every field in the class into a constructor parameter.+_LOMBOK_VALUE_RE = re.compile(r"@Value\s*(?![(\w])")# Spring Data repository base interfaces — any interface extending one of# these has Spring-generated impls at runtime and must be treated as an@@ -127,21 +134,41 @@ def _is_spring_data_repo(parsed: Any) -> bool:return False-def _scan_lombok_ctor_params(text: str) -> list[str]:+def _owner_at_offset(parsed: Any, text: str, offset: int) -> str | None:+ """The innermost declared type whose body contains *offset*.++ The injection regexes scan whole-file text with no scope awareness, so the+ owner has to come from the match position. Taking the type the file is+ named for instead attributes a nested ``@Configuration``'s injections to the+ outer class -- and finds nothing at all in a file whose stem names no type.+ """+ line = text.count("\n", 0, offset) + 1+ best: str | None = None+ best_span = None+ for sym in parsed.symbols:+ if sym.kind not in ("class", "interface", "record", "enum"):+ continue+ if not (sym.start_line <= line <= sym.end_line):+ continue+ span = sym.end_line - sym.start_line+ if best_span is None or span < best_span:+ best, best_span = sym.id, span+ return best+++def _scan_lombok_ctor_params(text: str) -> list[tuple[str, int]]:"""Return Lombok-synthesized constructor param types (head identifiers).For a class annotated ``@RequiredArgsConstructor`` (or ``@Data``), thisis every ``final`` field's head type; for ``@AllArgsConstructor`` (or``@Value``), every field's head type. Builtin types are filtered."""- is_rac = any(a in text for a in _LOMBOK_RAC_ANNOT) or any(- a in text for a in _LOMBOK_DATA_VALUE if a == "@Data"- )- is_aac = "@AllArgsConstructor" in text or "@Value" in text+ is_rac = any(a in text for a in _LOMBOK_RAC_ANNOT)+ is_aac = "@AllArgsConstructor" in text or bool(_LOMBOK_VALUE_RE.search(text))if not (is_rac or is_aac):return []- params: list[str] = []+ params: list[tuple[str, int]] = []for m in _JAVA_FINAL_FIELD_RE.finditer(text):is_final = bool(m.group(1))type_head = m.group(2)@@ -150,10 +177,21 @@ def _scan_lombok_ctor_params(text: str) -> list[str]:"List", "Map", "Set", "Collection"):continueif is_aac or (is_rac and is_final):- params.append(type_head)+ params.append((type_head, m.start()))return params+def _bind_injected_symbol(+ graph: nx.DiGraph, type_to_symbol: dict[str, str], owner: str | None, type_name: str+) -> int:+ if owner is None:+ return 0+ target = type_to_symbol.get(strip_type_arguments(type_name).strip())+ if target is None:+ return 0+ return 1 if add_symbol_edge(graph, owner, target) else 0++def _add_spring_edges(graph: nx.DiGraph,parsed_files: dict[str, Any],@@ -162,6 +200,7 @@ def _add_spring_edges() -> int:count = 0class_to_file = _build_class_to_file(parsed_files, ("java", "kotlin"))+ type_to_symbol = build_type_to_symbol(parsed_files, ("java", "kotlin"))# Build interface → list of impl files map from heritageimpl_map: dict[str, list[str]] = {}@@ -218,6 +257,9 @@ def _add_spring_edges(# 2a. Field injection (@Autowired / @Inject / @Resource)for m in _SPRING_INJECT_FIELD_RE.finditer(text):type_name = m.group(1).split("<")[0].strip()+ count += _bind_injected_symbol(+ graph, type_to_symbol, _owner_at_offset(parsed, text, m.start()), type_name+ )for target in _resolve_type(type_name):if target in path_set and _add_edge_if_new(graph, path, target):count += 1@@ -236,12 +278,21 @@ def _add_spring_edges(type_name = pm.group(1)if type_name in ("String", "Integer", "Long", "Boolean", "Double", "Float"):continue+ count += _bind_injected_symbol(+ graph,+ type_to_symbol,+ _owner_at_offset(parsed, text, ctor_match.start()),+ type_name,+ )for target in _resolve_type(type_name):if target in path_set and _add_edge_if_new(graph, path, target):count += 1# 2c. Lombok @RequiredArgsConstructor / @AllArgsConstructor / @Data- for type_name in _scan_lombok_ctor_params(text):+ for type_name, offset in _scan_lombok_ctor_params(text):+ count += _bind_injected_symbol(+ graph, type_to_symbol, _owner_at_offset(parsed, text, offset), type_name+ )for target in _resolve_type(type_name):if target in path_set and _add_edge_if_new(graph, path, target):count += 1diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.pyindex 0a3cfb811..372b60dd7 100644--- a/packages/core/src/repowise/core/ingestion/models.py+++ b/packages/core/src/repowise/core/ingestion/models.py@@ -291,9 +291,15 @@ EdgeType = Literal["dispatches_to","co_changes","framework",- # A data reference rather than a call. Two `_add_reads_edge` helpers emit- # it at different layers: C# member access file → file, Express- # route/middleware wiring symbol → symbol.+ # The symbol-level sibling of `framework`, emitted when a handler can name+ # both ends as symbols. Deliberately not `calls`: nothing here is a call the+ # parser could have seen, and letting it read as one would put an inferred+ # wiring hop into an execution flow as if it were source.+ "framework_binds",+ # A data reference rather than a call: C# member access, file → file. It+ # used to name two unrelated things — the Express route wiring emitted it+ # symbol → symbol — which is why one consumer set could not say which layer+ # it meant. That producer now emits `framework_binds`."reads",# Dynamic-dispatch hints. `dynamic_hints` extractors emit a `DynamicKind`# sub-type and `EdgesMixin.add_dynamic_edges` prefixes it, so `url_route`@@ -466,6 +472,9 @@ SYMBOL_USE_EDGE_TYPES: frozenset[str] = frozenset(# answers for, and that call lands on the base. Without this the whole# implementation side of an interface reads as called by nobody."dispatches_to",+ # A fixture nobody calls and a collaborator nobody constructs are both+ # used — by the container, which no parser sees.+ "framework_binds","reads",# Naming a function is using it. A handler sitting in a dispatch table# is never called anywhere a parser can see, and treating that as "nodiff --git a/packages/server/src/repowise/server/services/c4_builder/labels.py b/packages/server/src/repowise/server/services/c4_builder/labels.pyindex a63c70162..951668450 100644--- a/packages/server/src/repowise/server/services/c4_builder/labels.py+++ b/packages/server/src/repowise/server/services/c4_builder/labels.py@@ -41,6 +41,8 @@ _EDGE_VERB: dict[str, str] = {"dynamic_uses": "uses","dynamic_url_route": "uses","framework": "uses",+ # Symbol-level wiring; same verb as its file-level sibling on purpose.+ "framework_binds": "uses","reads": "uses",# A type reference without an import: named, but not imported."type_use": "references",diff --git a/tests/unit/analysis/test_kg_skip_logic.py b/tests/unit/analysis/test_kg_skip_logic.pyindex 29135d28e..7bd496e29 100644--- a/tests/unit/analysis/test_kg_skip_logic.py+++ b/tests/unit/analysis/test_kg_skip_logic.py@@ -210,7 +210,7 @@ class TestFingerprintDeterminism:one: whoever bumps the constant updates this line and sees, in thediff, that they are asking every existing store to re-curate."""- assert knowledge_graph.KG_BUILDER_VERSION == "3"+ assert knowledge_graph.KG_BUILDER_VERSION == "4"# ---------------------------------------------------------------------------diff --git a/tests/unit/ingestion/test_express_framework_edges.py b/tests/unit/ingestion/test_express_framework_edges.pyindex 82c140ab7..e4d8b9b1c 100644--- a/tests/unit/ingestion/test_express_framework_edges.py+++ b/tests/unit/ingestion/test_express_framework_edges.py@@ -138,8 +138,8 @@ class TestExpressLocalMiddlewareReads:module_sym = "routes.ts::__module__"for name in ("logRequest", "validateRequest", "handler"):sym_id = f"routes.ts::{name}"- assert graph.has_edge(module_sym, sym_id), f"missing reads edge to {name}"- assert graph[module_sym][sym_id]["edge_type"] == "reads"+ assert graph.has_edge(module_sym, sym_id), f"missing wiring edge to {name}"+ assert graph[module_sym][sym_id]["edge_type"] == "framework_binds"def test_app_use_middleware_gets_reads_edge(self, tmp_path: Path) -> None:(tmp_path / "mw.ts").write_text(@@ -150,7 +150,7 @@ class TestExpressLocalMiddlewareReads:)graph = _build_graph_with_framework_edges(tmp_path)assert graph.has_edge("mw.ts::__module__", "mw.ts::authGuard")- assert graph["mw.ts::__module__"]["mw.ts::authGuard"]["edge_type"] == "reads"+ assert graph["mw.ts::__module__"]["mw.ts::authGuard"]["edge_type"] == "framework_binds"def test_defines_edge_preserved(self, tmp_path: Path) -> None:(tmp_path / "routes.ts").write_text(@@ -173,7 +173,7 @@ class TestExpressLocalMiddlewareReads:graph = _build_graph_with_framework_edges(tmp_path)handler = "routes.ts::handler"assert graph.has_edge("routes.ts::__module__", handler)- assert graph["routes.ts::__module__"][handler]["edge_type"] == "reads"+ assert graph["routes.ts::__module__"][handler]["edge_type"] == "framework_binds"assert graph.has_edge("routes.ts::__module__", "routes.ts::requireRole")def test_commonjs_multiline_route_reads_edges(self, tmp_path: Path) -> None:@@ -196,8 +196,8 @@ class TestExpressLocalMiddlewareReads:module_sym = "routes.js::__module__"for name in ("logRequest", "validateRequest"):sym_id = f"routes.js::{name}"- assert graph.has_edge(module_sym, sym_id), f"missing reads edge to {name}"- assert graph[module_sym][sym_id]["edge_type"] == "reads"+ assert graph.has_edge(module_sym, sym_id), f"missing wiring edge to {name}"+ assert graph[module_sym][sym_id]["edge_type"] == "framework_binds"def test_non_route_receiver_in_express_file_no_reads_edge(self, tmp_path: Path) -> None:(tmp_path / "svc.ts").write_text(diff --git a/tests/unit/ingestion/test_pytest_fixture_edges.py b/tests/unit/ingestion/test_pytest_fixture_edges.pynew file mode 100644index 000000000..71f3f4c4c--- /dev/null+++ b/tests/unit/ingestion/test_pytest_fixture_edges.py@@ -0,0 +1,417 @@+"""A test function is linked to the fixture it asks for by parameter name.++The refusals matter more than the happy path: a parameter name is an ordinary+identifier, so anything claiming one without evidence mints a wrong edge.+"""++from __future__ import annotations++from datetime import datetime+from pathlib import Path++import networkx as nx++from repowise.core.ingestion import GraphBuilder+from repowise.core.ingestion.framework_edges import add_framework_edges+from repowise.core.ingestion.models import FileInfo, ParsedFile+from repowise.core.ingestion.parser import ASTParser+from repowise.core.ingestion.resolvers.context import ResolverContext+++def _file_info(rel: str, abs_path: str) -> FileInfo:+ return FileInfo(+ path=rel,+ abs_path=abs_path,+ language="python",+ size_bytes=100,+ git_hash="",+ last_modified=datetime.now(),+ is_test=False,+ is_config=False,+ is_api_contract=False,+ is_entry_point=False,+ )+++def _build(repo: Path) -> nx.DiGraph:+ parser = ASTParser()+ parsed: dict[str, ParsedFile] = {}+ for src in sorted(repo.rglob("*.py")):+ rel = src.resolve().relative_to(repo.resolve()).as_posix()+ parsed[rel] = parser.parse_file(_file_info(rel, str(src.resolve())), src.read_bytes())++ builder = GraphBuilder(repo)+ for pf in parsed.values():+ builder.add_file(pf)+ graph = builder.build()++ path_set = set(parsed)+ stem_map: dict[str, list[str]] = {}+ for p in path_set:+ stem_map.setdefault(Path(p).stem.lower(), []).append(p)+ ctx = ResolverContext(+ path_set=path_set, stem_map=stem_map, graph=graph, repo_path=repo+ )+ add_framework_edges(graph, parsed, ctx, [])+ return graph+++def _bound(graph: nx.DiGraph) -> set[tuple[str, str]]:+ return {+ (s, t)+ for s, t, d in graph.edges(data=True)+ if d.get("edge_type") == "framework_binds"+ }+++class TestFixtureInjection:+ def test_conftest_fixture_is_linked_to_the_test_that_asks_for_it(+ self, tmp_path: Path+ ) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text("def test_get(client):\n assert client\n")++ assert ("test_api.py::test_get", "conftest.py::client") in _bound(_build(tmp_path))++ def test_a_fixture_in_the_tests_own_module_wins_over_the_conftest(+ self, tmp_path: Path+ ) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 2\n\n\n"+ "def test_get(client):\n assert client\n"+ )++ bound = _bound(_build(tmp_path))+ assert ("test_api.py::test_get", "test_api.py::client") in bound+ assert ("test_api.py::test_get", "conftest.py::client") not in bound++ def test_the_nearest_conftest_wins(self, tmp_path: Path) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ sub = tmp_path / "sub"+ sub.mkdir()+ (sub / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 2\n"+ )+ (sub / "test_api.py").write_text("def test_get(client):\n assert client\n")++ bound = _bound(_build(tmp_path))+ assert ("sub/test_api.py::test_get", "sub/conftest.py::client") in bound+ assert ("sub/test_api.py::test_get", "conftest.py::client") not in bound++ def test_a_conftest_below_the_test_does_not_serve_it(self, tmp_path: Path) -> None:+ sub = tmp_path / "sub"+ sub.mkdir()+ (sub / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text("def test_get(client):\n assert client\n")++ assert _bound(_build(tmp_path)) == set()++ def test_the_name_keyword_renames_the_fixture(self, tmp_path: Path) -> None:+ # `@pytest.fixture(name="app")` on `fixture_app` means tests ask for+ # `app`. Binding on the function name would miss it and claim a wrong+ # one; flask writes fixtures this way.+ (tmp_path / "conftest.py").write_text(+ 'import pytest\n\n\[email protected](name="app")\n'+ "def fixture_app():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "def test_get(app):\n assert app\n\n\n"+ "def test_other(fixture_app):\n assert fixture_app\n"+ )++ bound = _bound(_build(tmp_path))+ assert ("test_api.py::test_get", "conftest.py::fixture_app") in bound+ assert ("test_api.py::test_other", "conftest.py::fixture_app") not in bound++ def test_a_parametrize_argument_is_not_a_fixture_request(self, tmp_path: Path) -> None:+ # A parametrize argument that happens to share a fixture's name would+ # otherwise mint a wrong edge.+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef value():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "import pytest\n\n\n"+ '@pytest.mark.parametrize("value", [1, 2])\n'+ "def test_get(value):\n assert value\n"+ )++ assert _bound(_build(tmp_path)) == set()++ def test_an_undecorated_function_is_not_a_fixture(self, tmp_path: Path) -> None:+ (tmp_path / "conftest.py").write_text("def client():\n return 1\n")+ (tmp_path / "test_api.py").write_text("def test_get(client):\n assert client\n")++ assert _bound(_build(tmp_path)) == set()++ def test_a_non_test_function_asks_for_nothing(self, tmp_path: Path) -> None:+ # Only `test_*` functions get their parameters injected by pytest. A+ # helper's parameters are ordinary arguments its callers supply.+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "def helper(client):\n return client\n"+ )++ assert _bound(_build(tmp_path)) == set()++ def test_a_module_that_is_not_a_test_file_asks_for_nothing(self, tmp_path: Path) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "helpers.py").write_text("def test_get(client):\n assert client\n")++ assert _bound(_build(tmp_path)) == set()++ def test_a_repo_with_no_fixtures_gains_nothing(self, tmp_path: Path) -> None:+ (tmp_path / "test_api.py").write_text("def test_get():\n assert True\n")+ (tmp_path / "app.py").write_text("def run(config):\n return config\n")++ assert _bound(_build(tmp_path)) == set()++ def test_the_edge_carries_a_confidence(self, tmp_path: Path) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text("def test_get(client):\n assert client\n")++ graph = _build(tmp_path)+ data = graph["test_api.py::test_get"]["conftest.py::client"]+ assert data["edge_type"] == "framework_binds"+ assert data["confidence"] == 0.90+++class TestRefusals:+ """Each of these mints a wrong edge without the rule it names."""++ def test_a_module_level_assignment_asks_for_nothing(self, tmp_path: Path) -> None:+ # `test_client = TestClient(app)` is a variable, and its recorded+ # signature is the assignment line — so a parameter-list read finds+ # `app` in it and calls a data constant a caller of the fixture.+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef app():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "from client import TestClient\n\ntest_client = TestClient(app)\n"+ )++ assert _bound(_build(tmp_path)) == set()++ def test_a_defaulted_parameter_is_not_injected(self, tmp_path: Path) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "def test_get(client=None):\n assert client is None\n"+ )++ assert _bound(_build(tmp_path)) == set()++ def test_a_class_scoped_fixture_does_not_serve_a_sibling_class(+ self, tmp_path: Path+ ) -> None:+ (tmp_path / "test_api.py").write_text(+ "import pytest\n\n\n"+ "class TestA:\n"+ " @pytest.fixture\n"+ " def client(self):\n return 1\n\n"+ " def test_a(self, client):\n assert client\n\n\n"+ "class TestB:\n"+ " def test_b(self, client):\n assert client\n"+ )++ bound = _bound(_build(tmp_path))+ assert ("test_api.py::TestA::test_a", "test_api.py::TestA::client") in bound+ assert ("test_api.py::TestB::test_b", "test_api.py::TestA::client") not in bound++ def test_a_base_test_class_serves_its_subclass(self, tmp_path: Path) -> None:+ # Scoping the lookup to the declaring class alone fixes a rare wrong+ # edge by introducing a frequent missing one: a base class holding the+ # shared fixtures is the commonest class-scoped arrangement there is.+ (tmp_path / "test_api.py").write_text(+ "import pytest\n\n\n"+ "class TestBase:\n"+ " @pytest.fixture\n"+ " def client(self):\n return 1\n\n\n"+ "class TestChild(TestBase):\n"+ " def test_a(self, client):\n assert client\n"+ )++ assert (+ "test_api.py::TestChild::test_a",+ "test_api.py::TestBase::client",+ ) in _bound(_build(tmp_path))++ def test_an_annotation_containing_an_equals_is_not_a_default(+ self, tmp_path: Path+ ) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "from typing import Annotated, Literal\n\n\n"+ "def test_get(client: Annotated[int, Field(ge=0)]):\n assert client\n\n\n"+ "def test_two(client: Literal['a=b']):\n assert client\n"+ )++ bound = _bound(_build(tmp_path))+ assert ("test_api.py::test_get", "conftest.py::client") in bound+ assert ("test_api.py::test_two", "conftest.py::client") in bound++ def test_a_comment_in_a_multiline_signature_does_not_swallow_it(+ self, tmp_path: Path+ ) -> None:+ # An apostrophe or a stray bracket in a per-parameter comment used to+ # take the whole list with it.+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "def test_get(\n client, # don't drop me, see foo(\n):\n assert client\n"+ )++ assert (+ "test_api.py::test_get",+ "conftest.py::client",+ ) in _bound(_build(tmp_path))++ def test_an_escaped_quote_in_a_default_does_not_swallow_the_list(+ self, tmp_path: Path+ ) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ 'def test_get(client, label="it\\"s"):\n assert client and label\n'+ )++ assert (+ "test_api.py::test_get",+ "conftest.py::client",+ ) in _bound(_build(tmp_path))++ def test_a_method_of_a_class_pytest_never_collects_asks_for_nothing(+ self, tmp_path: Path+ ) -> None:+ # pytest collects methods only from `Test*` classes.+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "class Harness:\n def test_connection(self, client):\n return client\n"+ )++ assert _bound(_build(tmp_path)) == set()++ def test_the_projects_own_python_classes_setting_is_honoured(+ self, tmp_path: Path+ ) -> None:+ # celery collects `test_*` classes, not pytest's default `Test*`.+ # Assuming the default refuses almost every binding such a repo has.+ (tmp_path / "pyproject.toml").write_text(+ '[tool.pytest.ini_options]\npython_classes = "test_*"\n'+ )+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "class test_api:\n def test_get(self, client):\n assert client\n"+ )++ assert (+ "test_api.py::test_api::test_get",+ "conftest.py::client",+ ) in _bound(_build(tmp_path))++ def test_name_is_read_as_a_top_level_keyword_only(self, tmp_path: Path) -> None:+ # A `name=` nested in a params list is not the fixture's name.+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\n"+ '@pytest.fixture(params=[dict(name="alice")])\n'+ "def user(request):\n return request.param\n"+ )+ (tmp_path / "test_api.py").write_text(+ "def test_u(user):\n assert user\n\n\n"+ "def test_v(alice):\n assert alice\n"+ )++ bound = _bound(_build(tmp_path))+ assert ("test_api.py::test_u", "conftest.py::user") in bound+ assert ("test_api.py::test_v", "conftest.py::user") not in bound++ def test_a_parametrize_value_does_not_refuse_a_real_request(+ self, tmp_path: Path+ ) -> None:+ # Only the first argument names parameters. Reading the whole decorator+ # made every parametrize *value* look like a supplied name, so a fixture+ # called `client` became unreachable in any test parametrized over the+ # string "client".+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "import pytest\n\n\n"+ '@pytest.mark.parametrize("method", ["client", "server"])\n'+ "def test_dispatch(method, client):\n assert client\n"+ )++ bound = _bound(_build(tmp_path))+ assert ("test_api.py::test_dispatch", "conftest.py::client") in bound++ def test_an_annotation_containing_a_bracket_does_not_truncate_the_list(+ self, tmp_path: Path+ ) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n\n\n"+ "@pytest.fixture\ndef later():\n return 2\n"+ )+ (tmp_path / "test_api.py").write_text(+ "from typing import Any, Callable\n\n\n"+ "def test_get(cb: Callable[[int], str], client, later):\n"+ " assert client and later and cb\n"+ )++ bound = _bound(_build(tmp_path))+ assert ("test_api.py::test_get", "conftest.py::client") in bound+ assert ("test_api.py::test_get", "conftest.py::later") in bound++ def test_a_nested_default_call_does_not_leak_a_keyword_as_a_request(+ self, tmp_path: Path+ ) -> None:+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text(+ "def test_get(tmp_path, opts=dict(a=1, client=2)):\n assert opts\n"+ )++ assert _bound(_build(tmp_path)) == set()+++class TestFixtureIsNotDeadCode:+ def test_a_fixture_used_only_by_injection_has_an_incoming_use_edge(+ self, tmp_path: Path+ ) -> None:+ # Before this, nothing in the graph pointed at a fixture at all.+ (tmp_path / "conftest.py").write_text(+ "import pytest\n\n\[email protected]\ndef client():\n return 1\n"+ )+ (tmp_path / "test_api.py").write_text("def test_get(client):\n assert client\n")++ from repowise.core.ingestion.models import REACHABILITY_USE_EDGE_TYPES++ graph = _build(tmp_path)+ target = "conftest.py::client"+ assert any(+ graph[pred][target].get("edge_type") in REACHABILITY_USE_EDGE_TYPES+ for pred in graph.predecessors(target)+ )diff --git a/tests/unit/ingestion/test_spring_framework_edges.py b/tests/unit/ingestion/test_spring_framework_edges.pyindex 032a5e855..6418efecf 100644--- a/tests/unit/ingestion/test_spring_framework_edges.py+++ b/tests/unit/ingestion/test_spring_framework_edges.py@@ -150,3 +150,115 @@ class TestSpringGate:ctx = _ctx(tmp_path, parsed)count = add_framework_edges(graph, parsed, ctx, tech_stack=[])assert count == 0+++def _build_graph(repo: Path):+ """A real graph, so the symbol-level edges have symbol nodes to land on."""+ from repowise.core.ingestion import GraphBuilder++ parsed = _build_parsed(repo)+ builder = GraphBuilder(repo)+ for pf in parsed.values():+ builder.add_file(pf)+ graph = builder.build()+ add_framework_edges(graph, parsed, _ctx(repo, parsed), tech_stack=["spring"])+ return graph+++def _bound(graph) -> set[tuple[str, str]]:+ return {+ (s, t)+ for s, t, d in graph.edges(data=True)+ if d.get("edge_type") == "framework_binds"+ }+++class TestSpringSymbolEdges:+ def test_injection_links_the_two_declarations(self, tmp_path: Path) -> None:+ (tmp_path / "UserService.java").write_text(+ "import org.springframework.stereotype.Service;\n"+ "@Service\npublic class UserService {}\n"+ )+ (tmp_path / "UserController.java").write_text(+ "import org.springframework.beans.factory.annotation.Autowired;\n"+ "import org.springframework.web.bind.annotation.RestController;\n"+ "@RestController\npublic class UserController {\n"+ " @Autowired private UserService userService;\n"+ "}\n"+ )++ bound = _bound(_build_graph(tmp_path))+ assert (+ "UserController.java::UserController",+ "UserService.java::UserService",+ ) in bound++ def test_a_nested_configuration_owns_its_own_injection(self, tmp_path: Path) -> None:+ # The injection regexes read whole-file text. Attributing every hit to+ # the type the file is named for gives the outer class an injection it+ # does not declare, and nested @Configuration classes are a standard+ # idiom.+ (tmp_path / "PaymentGateway.java").write_text(+ "import org.springframework.stereotype.Service;\n"+ "@Service\npublic class PaymentGateway {}\n"+ )+ (tmp_path / "AppConfig.java").write_text(+ "import org.springframework.context.annotation.Configuration;\n"+ "import org.springframework.beans.factory.annotation.Autowired;\n"+ "@Configuration\npublic class AppConfig {\n"+ " @Configuration\n"+ " static class Inner {\n"+ " @Autowired private PaymentGateway gateway;\n"+ " }\n"+ "}\n"+ )++ bound = _bound(_build_graph(tmp_path))+ target = "PaymentGateway.java::PaymentGateway"+ assert ("AppConfig.java::AppConfig", target) not in bound+ assert any(src.startswith("AppConfig.java::") for src, dst in bound if dst == target)++ def test_an_ambiguous_type_name_stays_unclaimed(self, tmp_path: Path) -> None:+ # Two files declaring `UserService` cannot settle which one is injected,+ # and picking whichever was walked first is a coin flip.+ for sub in ("a", "b"):+ d = tmp_path / sub+ d.mkdir()+ (d / "UserService.java").write_text(+ "import org.springframework.stereotype.Service;\n"+ "@Service\npublic class UserService {}\n"+ )+ (tmp_path / "UserController.java").write_text(+ "import org.springframework.beans.factory.annotation.Autowired;\n"+ "import org.springframework.web.bind.annotation.RestController;\n"+ "@RestController\npublic class UserController {\n"+ " @Autowired private UserService userService;\n"+ "}\n"+ )++ bound = _bound(_build_graph(tmp_path))+ assert not [d for _s, d in bound if d.endswith("::UserService")]++ def test_springs_value_annotation_is_not_lomboks(self, tmp_path: Path) -> None:+ # Lombok's @Value makes a class immutable and takes no argument;+ # Spring's takes a property expression. Reading one as the other turns+ # every field in the class into a constructor parameter.+ (tmp_path / "MailService.java").write_text(+ "import org.springframework.stereotype.Service;\n"+ "@Service\npublic class MailService {}\n"+ )+ (tmp_path / "User.java").write_text("public class User {}\n")+ (tmp_path / "UserResource.java").write_text(+ "import org.springframework.web.bind.annotation.RestController;\n"+ "import org.springframework.beans.factory.annotation.Value;\n"+ "@RestController\npublic class UserResource {\n"+ ' @Value("${app.name}")\n'+ " private String applicationName;\n"+ " private final User cachedUser = null;\n"+ " public UserResource(MailService mailService) {}\n"+ "}\n"+ )++ bound = _bound(_build_graph(tmp_path))+ assert ("UserResource.java::UserResource", "MailService.java::MailService") in bound+ assert ("UserResource.java::UserResource", "User.java::User") not in bound