Skip to content

Commit 04a291b

Browse files
committed
feat(ir): add service/container metadata and bump schema to v2
1 parent 0410837 commit 04a291b

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

pacta/ir/types.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ class IRNode:
144144
context: str | None = None
145145
tags: tuple[str, ...] = field(default_factory=tuple)
146146

147+
# v2: service-level enrichment
148+
service: str | None = None # top-level container ancestor
149+
container_kind: str | None = None # container kind (service/module/library)
150+
147151
attributes: Mapping[str, Any] = field(default_factory=dict)
148152

149153
def to_dict(self) -> dict[str, Any]:
@@ -157,6 +161,8 @@ def to_dict(self) -> dict[str, Any]:
157161
"layer": self.layer,
158162
"context": self.context,
159163
"tags": list(self.tags),
164+
"service": self.service,
165+
"container_kind": self.container_kind,
160166
"attributes": dict(self.attributes),
161167
}
162168

@@ -172,6 +178,8 @@ def from_dict(data: Mapping[str, Any]) -> "IRNode":
172178
layer=data.get("layer"),
173179
context=data.get("context"),
174180
tags=tuple(data.get("tags", [])),
181+
service=data.get("service"),
182+
container_kind=data.get("container_kind"),
175183
attributes=dict(data.get("attributes", {})),
176184
)
177185

@@ -201,6 +209,12 @@ class IREdge:
201209
dst_layer: str | None = None
202210
dst_context: str | None = None
203211

212+
# v2: service-level enrichment
213+
src_service: str | None = None
214+
dst_service: str | None = None
215+
src_container_kind: str | None = None
216+
dst_container_kind: str | None = None
217+
204218
def to_dict(self) -> dict[str, Any]:
205219
return {
206220
"src": self.src.to_dict(),
@@ -215,6 +229,10 @@ def to_dict(self) -> dict[str, Any]:
215229
"dst_container": self.dst_container,
216230
"dst_layer": self.dst_layer,
217231
"dst_context": self.dst_context,
232+
"src_service": self.src_service,
233+
"dst_service": self.dst_service,
234+
"src_container_kind": self.src_container_kind,
235+
"dst_container_kind": self.dst_container_kind,
218236
}
219237

220238
@staticmethod
@@ -232,6 +250,10 @@ def from_dict(data: Mapping[str, Any]) -> "IREdge":
232250
dst_container=data.get("dst_container"),
233251
dst_layer=data.get("dst_layer"),
234252
dst_context=data.get("dst_context"),
253+
src_service=data.get("src_service"),
254+
dst_service=data.get("dst_service"),
255+
src_container_kind=data.get("src_container_kind"),
256+
dst_container_kind=data.get("dst_container_kind"),
235257
)
236258

237259

@@ -265,7 +287,7 @@ def empty(cls, repo_root: str | Path) -> "ArchitectureIR":
265287
Convenience constructor for an empty IR.
266288
"""
267289
return cls(
268-
schema_version=1,
290+
schema_version=2,
269291
produced_by="pacta-core",
270292
repo_root=str(repo_root),
271293
nodes=(),

0 commit comments

Comments
 (0)