Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(ingestion): retire inert reads membership from SYMBOL_USE_EDGE_TYPES (#2364)

Rishabh Mishra681370e4dc30
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.py
index 3abd9af09..ea6821a1d 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
@@ -68,14 +68,8 @@ _TRIVIAL_NAMES = frozenset(
# match here at all: 0 symbol -> symbol `imports` edges exist across 42 local
# indexes.
#
-# `reads` is in the shared view and is *nearly* as inert here, for a weaker
-# reason worth writing down. Its one symbol-layer producer,
-# `framework_edges/express.py`, joins a file's `path::__module__` node to a
-# handler in the same file, so the cross-file test below drops it and
-# `_SKIP_KINDS` keeps `__module__` from ever being a chosen concept. That is a
-# property of today's extractor, not of the graph's shape, so it is taken from
-# the shared view rather than trimmed out: a future cross-file `reads` should
-# start counting here without anyone remembering to add it.
+# `reads` is file -> file (produced by `csharp_member_reads`), so it is not in
+# `SYMBOL_USE_EDGE_TYPES` and omitted from `_CONCEPT_EDGE_TYPES`.
_CONCEPT_EDGE_TYPES = SYMBOL_USE_EDGE_TYPES
@@ -101,10 +95,10 @@ class ConceptSymbol:
#
# Ceiling: c4_builder/labels.py `_EDGE_VERB` answers a similar question over
# all 14 types, but it lives in packages/server and core cannot import it, and
-# it disagrees here on 2 of the 5 shared keys - `extends` reads "inherits from"
-# and `reads` reads "uses", both tuned for a C4 arrow rather than for prose. If
-# a third copy appears, reconcile the wording first, then lift one map into
-# core; a straight merge would silently reword these prompts.
+# it disagrees here on `extends` ("inherits from"), tuned for a C4 arrow
+# rather than for prose. If a third copy appears, reconcile the wording first,
+# then lift one map into core; a straight merge would silently reword these
+# prompts.
_RELATION_VERB: dict[str, str] = {
"calls": "calls",
"extends": "extends",
@@ -112,7 +106,6 @@ _RELATION_VERB: dict[str, str] = {
"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, since
# "calls" would claim an invocation this edge never observed.
diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.py
index c3b5a8db3..cc8aee259 100644
--- a/packages/core/src/repowise/core/ingestion/models.py
+++ b/packages/core/src/repowise/core/ingestion/models.py
@@ -537,20 +537,13 @@ FILE_DEPENDENCY_EDGE_TYPES: frozenset[str] = frozenset(
"dynamic_imports",
"dynamic_url_route",
# C# member access (`var x = new T(); x.Prop`) resolves to the file
- # declaring the type, so this is a real file-level reference. See the
- # note on SYMBOL_USE_EDGE_TYPES: `reads` is emitted at both layers.
+ # declaring the type, so this is a real file-level reference.
"reads",
}
)
# Symbol → symbol references. "Something reaches this symbol", so containment
# is excluded: a class containing a method is not the method being used.
-#
-# `reads` is a member here for a reason that no longer holds: its symbol-level
-# producer moved to `framework_binds`, so `csharp_member_reads` is the only one
-# left and it emits file → file. A file node can never be a symbol node's
-# predecessor, so membership is inert rather than wrong. Retiring it moves the
-# vocabulary and belongs to a diff that can measure that.
SYMBOL_USE_EDGE_TYPES: frozenset[str] = frozenset(
{
"calls",
@@ -564,7 +557,6 @@ SYMBOL_USE_EDGE_TYPES: frozenset[str] = frozenset(
# 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 "no
# use" reported entire registration layers as safe to delete (#1602).
@@ -575,13 +567,12 @@ SYMBOL_USE_EDGE_TYPES: frozenset[str] = frozenset(
# Symbol → symbol edges along which control can actually reach the target, for
# the question "would running this test execute that code?". The reachability
-# view minus the two that record a mention rather than a transfer of control:
-# `references` is a name sitting in a dispatch table and `reads` is a field
-# access, and neither runs the thing it names. Narrower than
-# SYMBOL_USE_EDGE_TYPES on purpose — dead code asks "is this used", which a
-# mention answers, and the inferred test map asks "is this run", which it does
-# not.
-EXECUTION_EDGE_TYPES: frozenset[str] = SYMBOL_USE_EDGE_TYPES - {"references", "reads"}
+# view minus the one that records a mention rather than a transfer of control:
+# `references` is a name sitting in a dispatch table and does not run the thing
+# it names. Narrower than SYMBOL_USE_EDGE_TYPES on purpose — dead code asks
+# "is this used", which a mention answers, and the inferred test map asks "is
+# this run", which it does not.
+EXECUTION_EDGE_TYPES: frozenset[str] = SYMBOL_USE_EDGE_TYPES - {"references"}
# "Does anything use this symbol at all?" — the reachability view. Adds
diff --git a/packages/server/src/repowise/server/schemas/intelligence.py b/packages/server/src/repowise/server/schemas/intelligence.py
index b2f7f55a1..e07d73312 100644
--- a/packages/server/src/repowise/server/schemas/intelligence.py
+++ b/packages/server/src/repowise/server/schemas/intelligence.py
@@ -91,7 +91,7 @@ SYMBOL_RELATION_GROUPS: dict[str, frozenset[str]] = {
"call": frozenset({"calls"}),
"heritage": frozenset({"extends", "implements", "method_implements", "dispatches_to"}),
"wiring": frozenset({"framework_binds"}),
- "reference": frozenset({"reads", "references"}),
+ "reference": frozenset({"references"}),
}
#: Reverse index, so a fetched edge can name its own group without a scan.
diff --git a/packages/ui/src/graph/symbol-relations.ts b/packages/ui/src/graph/symbol-relations.ts
index e87fe1e6c..133ee216b 100644
--- a/packages/ui/src/graph/symbol-relations.ts
+++ b/packages/ui/src/graph/symbol-relations.ts
@@ -41,7 +41,6 @@ const RELATION_LABELS: Record<string, Record<SymbolRelationDirection, string>> =
// site. Runs consumer -> provider, so a fixture's inbound edges are the
// tests it is wired into (388 of them for `client` on this repo).
framework_binds: { in: "Wired into", out: "Wired to" },
- reads: { in: "Read by", out: "Reads" },
references: { in: "Referenced by", out: "References" },
};
diff --git a/tests/unit/ingestion/test_csharp_member_reads.py b/tests/unit/ingestion/test_csharp_member_reads.py
index 6f3abda2d..f62e03b12 100644
--- a/tests/unit/ingestion/test_csharp_member_reads.py
+++ b/tests/unit/ingestion/test_csharp_member_reads.py
@@ -99,3 +99,27 @@ def test_self_reads_skipped() -> None:
resolve_csharp_member_reads(graph, cs_texts, {"Order": "Order.cs"})
assert not graph.has_edge("Order.cs", "Order.cs")
+
+
+def test_reads_edges_are_strictly_file_to_file() -> None:
+ """Every `reads` edge emitted connects two file nodes, never symbol nodes."""
+ graph = _seed_graph("Caller.cs", "Order.cs")
+ cs_texts = {
+ "Caller.cs": (
+ "namespace Acme;\npublic class Caller {\n"
+ " decimal Sum() { var order = new Order(); return order.Total; }\n}"
+ ),
+ "Order.cs": "namespace Acme;\npublic class Order { public decimal Total { get; } }",
+ }
+ type_to_file = {"Order": "Order.cs", "Caller": "Caller.cs"}
+ resolve_csharp_member_reads(graph, cs_texts, type_to_file)
+
+ reads_edges = [
+ (u, v) for u, v, d in graph.edges(data=True) if d.get("edge_type") == "reads"
+ ]
+ assert reads_edges, "Expected at least one reads edge"
+ for u, v in reads_edges:
+ assert "::" not in u, f"reads edge source {u} is a symbol node, expected file node"
+ assert "::" not in v, f"reads edge target {v} is a symbol node, expected file node"
+ assert u.endswith(".cs")
+ assert v.endswith(".cs")
diff --git a/tests/unit/ingestion/test_edge_type_vocabulary.py b/tests/unit/ingestion/test_edge_type_vocabulary.py
index ffa29d6b4..fd337423a 100644
--- a/tests/unit/ingestion/test_edge_type_vocabulary.py
+++ b/tests/unit/ingestion/test_edge_type_vocabulary.py
@@ -414,3 +414,13 @@ def test_the_removed_phantoms_stay_removed(phantom: str) -> None:
than a count.
"""
assert phantom not in EDGE_TYPE_VALUES
+
+
+def test_reads_edge_producer_is_strictly_file_level() -> None:
+ """`reads` is produced exclusively by csharp_member_reads at the file level."""
+ producers = [
+ path for path, types in _edge_type_literals().items() if "reads" in types
+ ]
+ assert producers == ["packages/core/src/repowise/core/ingestion/languages/csharp_member_reads.py"], (
+ f"`reads` edge emitted by unexpected producers: {producers}"
+ )