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): record Go interface embedding as inheritance (#1641)
Raghav Chamadiya306fdf40d106
diff --git a/packages/core/src/repowise/core/ingestion/extractors/heritage/go.py b/packages/core/src/repowise/core/ingestion/extractors/heritage/go.pyindex 9eb9459da..b52458e53 100644--- a/packages/core/src/repowise/core/ingestion/extractors/heritage/go.py+++ b/packages/core/src/repowise/core/ingestion/extractors/heritage/go.py@@ -46,16 +46,20 @@ def _extract_go_heritage(elif type_node.type == "interface_type":for child in type_node.children:- if child.type in ("{", "}", "\n"):+ if child.type != "type_elem":continue- if child.type in ("type_identifier", "qualified_type"):- bare = bare_type_name(node_text(child, src))- if bare:- out.append(- HeritageRelation(- child_name=name,- parent_name=bare,- kind="extends",- line=line,- )+ text = node_text(child, src).strip()+ # A type set (`~int | string`) wears the same node as an embed but+ # is a generic bound, carrying no methods to inherit.+ if "|" in text or "~" in text:+ continue+ bare = bare_type_name(text)+ if bare:+ out.append(+ HeritageRelation(+ child_name=name,+ parent_name=bare,+ kind="extends",+ line=line,)+ )diff --git a/tests/unit/ingestion/test_heritage_type_names.py b/tests/unit/ingestion/test_heritage_type_names.pyindex 5351812cc..8b4f7d18b 100644--- a/tests/unit/ingestion/test_heritage_type_names.py+++ b/tests/unit/ingestion/test_heritage_type_names.py@@ -58,6 +58,23 @@ CASES: list[tuple[str, str, str, str, list[tuple[str, str]]]] = [("go", "go", "type Child struct {{\n\t{p}\n}}\n", "Gen[Arg]", [("Gen", "mixin")]),("go", "go", "type Child struct {{\n\t{p}\n}}\n", "ns.Qual", [("Qual", "mixin")]),("go", "go", "type Child struct {{\n\t{p}\n}}\n", "ns.Both[Arg]", [("Both", "mixin")]),+ # --- go: interface embedding -------------------------------------------+ # The same relation through a different node — the grammar wraps each+ # embed in a `type_elem`.+ ("go", "go", "type Child interface {{\n\t{p}\n}}\n", "Bare", [("Bare", "extends")]),+ ("go", "go", "type Child interface {{\n\t{p}\n}}\n", "Gen[Arg]", [("Gen", "extends")]),+ ("go", "go", "type Child interface {{\n\t{p}\n}}\n", "ns.Qual", [("Qual", "extends")]),+ ("go", "go", "type Child interface {{\n\t{p}\n}}\n", "ns.Both[Arg]", [("Both", "extends")]),+ # A type set is a generic bound, not an embed: it carries no methods.+ ("go", "go", "type Child interface {{\n\t{p}\n}}\n", "~int | string", []),+ # ...and skipping one must not cost the embed sitting beside it.+ (+ "go",+ "go",+ "type Child interface {{\n\t~int | string\n\t{p}\n}}\n",+ "Bare",+ [("Bare", "extends")],+ ),# --- rust --------------------------------------------------------------("rust", "rs", "struct Child;\nimpl {p} for Child {{}}\n", "Bare", [("Bare", "trait_impl")]),(