@@ -72,12 +72,23 @@ def _enrich_node(self, node: IRNode, model: ArchitectureModel) -> IRNode:
7272 if container_id is not None :
7373 context_id = model .get_context_for_container (container_id )
7474
75+ # v2: derive service (top-level ancestor) and container_kind
76+ service : str | None = None
77+ container_kind : str | None = None
78+ if container_id is not None :
79+ service = container_id .split ("." )[0 ]
80+ container = model .get_container (container_id )
81+ if container is not None and container .kind is not None :
82+ container_kind = container .kind .value
83+
7584 # Return enriched node if anything changed, otherwise return original
7685 if (
7786 node .container == container_id
7887 and node .layer == layer_id
7988 and node .context == context_id
8089 and node .tags == tags
90+ and node .service == service
91+ and node .container_kind == container_kind
8192 ):
8293 return node
8394
@@ -87,6 +98,8 @@ def _enrich_node(self, node: IRNode, model: ArchitectureModel) -> IRNode:
8798 layer = layer_id ,
8899 context = context_id ,
89100 tags = tags ,
101+ service = service ,
102+ container_kind = container_kind ,
90103 )
91104
92105 def _match_container (self , node : IRNode , model : ArchitectureModel ) -> str | None :
@@ -160,10 +173,14 @@ def _enrich_edge(self, edge: IREdge, node_lookup: dict[str, IRNode]) -> IREdge:
160173 src_container = src_node .container if src_node else None
161174 src_layer = src_node .layer if src_node else None
162175 src_context = src_node .context if src_node else None
176+ src_service = src_node .service if src_node else None
177+ src_container_kind = src_node .container_kind if src_node else None
163178
164179 dst_container = dst_node .container if dst_node else None
165180 dst_layer = dst_node .layer if dst_node else None
166181 dst_context = dst_node .context if dst_node else None
182+ dst_service = dst_node .service if dst_node else None
183+ dst_container_kind = dst_node .container_kind if dst_node else None
167184
168185 # Return enriched edge if anything changed
169186 if (
@@ -173,6 +190,10 @@ def _enrich_edge(self, edge: IREdge, node_lookup: dict[str, IRNode]) -> IREdge:
173190 and edge .dst_container == dst_container
174191 and edge .dst_layer == dst_layer
175192 and edge .dst_context == dst_context
193+ and edge .src_service == src_service
194+ and edge .dst_service == dst_service
195+ and edge .src_container_kind == src_container_kind
196+ and edge .dst_container_kind == dst_container_kind
176197 ):
177198 return edge
178199
@@ -184,6 +205,10 @@ def _enrich_edge(self, edge: IREdge, node_lookup: dict[str, IRNode]) -> IREdge:
184205 dst_container = dst_container ,
185206 dst_layer = dst_layer ,
186207 dst_context = dst_context ,
208+ src_service = src_service ,
209+ dst_service = dst_service ,
210+ src_container_kind = src_container_kind ,
211+ dst_container_kind = dst_container_kind ,
187212 )
188213
189214 def _normalize_path (self , path : str ) -> str :
0 commit comments