@@ -96,11 +96,42 @@ def test_community_article_shows_cohesion(tmp_path):
9696
9797
9898def test_community_article_has_audit_trail (tmp_path ):
99+ """Each incident edge is counted exactly ONCE (#2633).
100+
101+ The Parsing Layer (n1, n2) touches two edges: n1-n2 (EXTRACTED, both
102+ endpoints inside) and n1-n3 (INFERRED, crossing out). Counting
103+ ``nodes x G.neighbors`` visited the intra-community edge from both ends and
104+ the crossing one from only one, reporting EXTRACTED 2 (67%) / INFERRED 1
105+ (33%) — biased towards confidence, which understates the AMBIGUOUS review
106+ burden the section exists to surface.
107+ """
99108 G = _make_graph ()
100109 to_wiki (G , COMMUNITIES , tmp_path , community_labels = LABELS )
101110 parsing = (tmp_path / "Parsing_Layer.md" ).read_text ()
102- assert "EXTRACTED" in parsing
103- assert "INFERRED" in parsing
111+ audit = parsing [parsing .index ("## Audit Trail" ):]
112+ assert "- EXTRACTED: 1 (50%)" in audit , audit
113+ assert "- INFERRED: 1 (50%)" in audit , audit
114+ assert "- AMBIGUOUS: 0 (0%)" in audit , audit
115+
116+
117+ def test_audit_trail_counts_parallel_edges_individually (tmp_path ):
118+ """On a MultiGraph each parallel edge is its own row in the split (#2633).
119+
120+ Collapsing them to the first (``edge_data``) hid an AMBIGUOUS edge behind an
121+ EXTRACTED one running between the same pair — the same understatement as the
122+ double-count above.
123+ """
124+ G = nx .MultiGraph ()
125+ G .add_node ("n1" , label = "parse" , file_type = "code" , source_file = "parser.py" )
126+ G .add_node ("n2" , label = "validate" , file_type = "code" , source_file = "parser.py" )
127+ G .add_edge ("n1" , "n2" , relation = "calls" , confidence = "EXTRACTED" , weight = 1.0 )
128+ G .add_edge ("n1" , "n2" , relation = "references" , confidence = "AMBIGUOUS" , weight = 1.0 )
129+
130+ to_wiki (G , {0 : ["n1" , "n2" ]}, tmp_path , community_labels = {0 : "Parsing Layer" })
131+ audit = (tmp_path / "Parsing_Layer.md" ).read_text ()
132+ audit = audit [audit .index ("## Audit Trail" ):]
133+ assert "- EXTRACTED: 1 (50%)" in audit , audit
134+ assert "- AMBIGUOUS: 1 (50%)" in audit , audit
104135
105136
106137def test_god_node_article_has_connections (tmp_path ):
0 commit comments