Gate the undocumented components reason on a real semantic layer

GRAPH_REPORT.md's Knowledge Gaps section always offered undocumented
components as a possible explanation for an isolated node, regardless
of whether the graph could ever actually have one. That phrase only
means anything when a semantic layer exists, document, paper or image
nodes an LLM extracted meaning from, where an isolated node genuinely
could be mentioned but never explained further. A code only graph has
no such nodes at all, so offering it as a live possibility on every
report is misleading.

The reason now checks whether any node in the graph carries a
document, paper or image file_type before including that clause,
using the same VALID_FILE_TYPES distinction validate.py already
draws between the semantic layer and code/rationale/concept nodes, so
no new build time flag is needed.

Fixes issue 3801.

(cherry picked from commit 8a49e1f38a)
This commit is contained in:
ayushcodes10 authored and safishamsi committed 2026-09-25 15:44:21 +01:00
1 parent 0dd9f8ba5c
commit 6b6778aede
1 file changed
+16 -1
+16 -1
View File
@@ -335,8 +335,23 @@ def generate(
suffix = f" (+{len(isolated)-5} more)" if len(isolated) > 5 else ""
raw_isolated = sum(1 for n in G.nodes() if G.degree(n) <= 1)
lines.append(f"- **{len(isolated)} isolated node(s):** {', '.join(f'`{l}`' for l in isolated_labels)}{suffix}")
# "Undocumented components" only means anything when a semantic
# layer exists: document/paper/image nodes an LLM extracted
# meaning from, where an isolated node genuinely could be
# "mentioned but never explained further." A code-only graph
# (--code-only, or any run where semantic extraction never
# happened) has no such nodes at all, so offering it as a live
# possibility on every report is misleading (#3801).
has_semantic_layer = any(
G.nodes[n].get("file_type") in ("document", "paper", "image")
for n in G.nodes()
)
reason = (
"possible missing edges or undocumented components" if has_semantic_layer
else "possible missing edges"
)
lines.append(
" These have ≤1 connection - possible missing edges or undocumented components. "
f" These have ≤1 connection - {reason}. "
f"(Counts symbols only; {raw_isolated} node(s) total have ≤1 connection when "
"file, concept and rationale nodes are included.)"
)