archctx-contracts 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fixtures/invalid/native-context-invalid-model-summary.json +4 -1
- package/fixtures/invalid/native-context-missing-contract-bytes.json +4 -1
- package/fixtures/invalid/native-context-missing-input-bytes.json +4 -1
- package/fixtures/invalid/native-context-mixed-snapshot.json +4 -1
- package/fixtures/invalid/node-invalid-layer.json +10 -0
- package/fixtures/invalid/node-mount-missing-target.json +13 -0
- package/fixtures/model/invalid/runtime-topology-runs-in-non-namespace.json +30 -0
- package/fixtures/model/valid/layered.json +59 -0
- package/fixtures/model/valid/runtime-topology.json +223 -0
- package/fixtures/valid/archctx-capabilities.json +1 -1
- package/fixtures/valid/architecture-node-layered.json +11 -0
- package/fixtures/valid/architecture-node-mount.json +14 -0
- package/fixtures/valid/native-context-export.json +4 -1
- package/fixtures/valid/product-version-manifest.json +5 -5
- package/package.json +1 -1
- package/schemas/repo/architecture-node.schema.json +33 -1
- package/schemas/repo/architecture-relation.schema.json +1 -1
- package/schemas/runtime/capability-dependencies.schema.json +1 -1
- package/schemas/runtime/projection-manifest.schema.json +27 -12
- package/schemas/runtime/projection-target.schema.json +1 -1
- package/src/failure.ts +2 -1
- package/src/index.ts +1 -0
- package/src/ledger.ts +2 -0
- package/src/native-context.ts +5 -0
- package/src/ownership-dependencies.ts +4 -2
- package/src/product-version.ts +1 -1
- package/src/projection-manifest.ts +35 -8
- package/src/runtime-topology.ts +115 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "archcontext.node/v2",
|
|
3
|
+
"id": "module.subscription",
|
|
4
|
+
"kind": "module",
|
|
5
|
+
"name": "Subscription",
|
|
6
|
+
"status": "active",
|
|
7
|
+
"layer": "Domain Services",
|
|
8
|
+
"summary": "Owns subscription lifecycle.",
|
|
9
|
+
"responsibilities": ["create-subscription"]
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "archcontext.node/v2",
|
|
3
|
+
"id": "mount.shop.app-code",
|
|
4
|
+
"kind": "mount",
|
|
5
|
+
"name": "App code",
|
|
6
|
+
"status": "active",
|
|
7
|
+
"summary": "The built application, read-only.",
|
|
8
|
+
"mount": {
|
|
9
|
+
"source": "./dist",
|
|
10
|
+
"mode": "ro",
|
|
11
|
+
"order": 0
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodes": [
|
|
3
|
+
{
|
|
4
|
+
"schemaVersion": "archcontext.node/v2",
|
|
5
|
+
"id": "component.shop.api",
|
|
6
|
+
"kind": "component",
|
|
7
|
+
"name": "API",
|
|
8
|
+
"status": "active",
|
|
9
|
+
"summary": "Serves the storefront API."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"schemaVersion": "archcontext.node/v2",
|
|
13
|
+
"id": "process.shop.api-server",
|
|
14
|
+
"kind": "process",
|
|
15
|
+
"name": "API server",
|
|
16
|
+
"status": "active",
|
|
17
|
+
"summary": "Serves HTTP requests."
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"relations": [
|
|
21
|
+
{
|
|
22
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
23
|
+
"id": "relation.shop.api-runs-in-component",
|
|
24
|
+
"kind": "runs-in",
|
|
25
|
+
"source": "process.shop.api-server",
|
|
26
|
+
"target": "component.shop.api",
|
|
27
|
+
"intent": "A process cannot run in a component."
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodes": [
|
|
3
|
+
{
|
|
4
|
+
"schemaVersion": "archcontext.node/v2",
|
|
5
|
+
"id": "capability.billing",
|
|
6
|
+
"kind": "capability",
|
|
7
|
+
"name": "Billing",
|
|
8
|
+
"status": "active",
|
|
9
|
+
"summary": "Bills customers."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"schemaVersion": "archcontext.node/v2",
|
|
13
|
+
"id": "module.billing.api",
|
|
14
|
+
"kind": "module",
|
|
15
|
+
"name": "Billing API",
|
|
16
|
+
"status": "active",
|
|
17
|
+
"parent": "capability.billing",
|
|
18
|
+
"layer": "interface-adapters",
|
|
19
|
+
"summary": "Accepts billing requests."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"schemaVersion": "archcontext.node/v2",
|
|
23
|
+
"id": "module.billing.ledger",
|
|
24
|
+
"kind": "module",
|
|
25
|
+
"name": "Ledger",
|
|
26
|
+
"status": "active",
|
|
27
|
+
"parent": "capability.billing",
|
|
28
|
+
"layer": "domain",
|
|
29
|
+
"summary": "Keeps the billing ledger."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"schemaVersion": "archcontext.node/v2",
|
|
33
|
+
"id": "datastore.billing.invoices",
|
|
34
|
+
"kind": "datastore",
|
|
35
|
+
"name": "Invoices",
|
|
36
|
+
"status": "active",
|
|
37
|
+
"parent": "capability.billing",
|
|
38
|
+
"summary": "Stores invoices."
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"relations": [
|
|
42
|
+
{
|
|
43
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
44
|
+
"id": "relation.billing.api-ledger",
|
|
45
|
+
"kind": "calls",
|
|
46
|
+
"source": "module.billing.api",
|
|
47
|
+
"target": "module.billing.ledger",
|
|
48
|
+
"intent": "Posts ledger entries."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
52
|
+
"id": "relation.billing.ledger-invoices",
|
|
53
|
+
"kind": "writes",
|
|
54
|
+
"source": "module.billing.ledger",
|
|
55
|
+
"target": "datastore.billing.invoices",
|
|
56
|
+
"intent": "Persists invoices."
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodes": [
|
|
3
|
+
{
|
|
4
|
+
"schemaVersion": "archcontext.node/v2",
|
|
5
|
+
"id": "capability.shop",
|
|
6
|
+
"kind": "capability",
|
|
7
|
+
"name": "Shop",
|
|
8
|
+
"status": "active",
|
|
9
|
+
"summary": "Sells products."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"schemaVersion": "archcontext.node/v2",
|
|
13
|
+
"id": "component.shop.api",
|
|
14
|
+
"kind": "component",
|
|
15
|
+
"name": "API",
|
|
16
|
+
"status": "active",
|
|
17
|
+
"parent": "capability.shop",
|
|
18
|
+
"summary": "Serves the storefront API."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"schemaVersion": "archcontext.node/v2",
|
|
22
|
+
"id": "namespace.shop.host",
|
|
23
|
+
"kind": "namespace",
|
|
24
|
+
"name": "Host",
|
|
25
|
+
"status": "active",
|
|
26
|
+
"summary": "The host machine.",
|
|
27
|
+
"namespace": {
|
|
28
|
+
"type": "host"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"schemaVersion": "archcontext.node/v2",
|
|
33
|
+
"id": "namespace.shop.pod",
|
|
34
|
+
"kind": "namespace",
|
|
35
|
+
"name": "Shop pod",
|
|
36
|
+
"status": "active",
|
|
37
|
+
"parent": "namespace.shop.host",
|
|
38
|
+
"summary": "The pod that runs the shop.",
|
|
39
|
+
"namespace": {
|
|
40
|
+
"type": "pod"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"schemaVersion": "archcontext.node/v2",
|
|
45
|
+
"id": "namespace.shop.api-container",
|
|
46
|
+
"kind": "namespace",
|
|
47
|
+
"name": "API container",
|
|
48
|
+
"status": "active",
|
|
49
|
+
"parent": "namespace.shop.pod",
|
|
50
|
+
"summary": "The container of the API server.",
|
|
51
|
+
"namespace": {
|
|
52
|
+
"type": "container"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"schemaVersion": "archcontext.node/v2",
|
|
57
|
+
"id": "process.shop.api-server",
|
|
58
|
+
"kind": "process",
|
|
59
|
+
"name": "API server",
|
|
60
|
+
"status": "active",
|
|
61
|
+
"summary": "Serves HTTP requests."
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"schemaVersion": "archcontext.node/v2",
|
|
65
|
+
"id": "process.shop.worker",
|
|
66
|
+
"kind": "process",
|
|
67
|
+
"name": "Worker",
|
|
68
|
+
"status": "active",
|
|
69
|
+
"summary": "Runs background jobs."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"schemaVersion": "archcontext.node/v2",
|
|
73
|
+
"id": "process.shop.cron",
|
|
74
|
+
"kind": "process",
|
|
75
|
+
"name": "Cron",
|
|
76
|
+
"status": "active",
|
|
77
|
+
"summary": "Schedules maintenance on the host."
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"schemaVersion": "archcontext.node/v2",
|
|
81
|
+
"id": "mount.shop.app-code",
|
|
82
|
+
"kind": "mount",
|
|
83
|
+
"name": "App code",
|
|
84
|
+
"status": "active",
|
|
85
|
+
"summary": "The built application, read-only.",
|
|
86
|
+
"mount": {
|
|
87
|
+
"source": "./dist",
|
|
88
|
+
"target": "/app",
|
|
89
|
+
"mode": "ro",
|
|
90
|
+
"order": 0
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"schemaVersion": "archcontext.node/v2",
|
|
95
|
+
"id": "mount.shop.app-data",
|
|
96
|
+
"kind": "mount",
|
|
97
|
+
"name": "App data",
|
|
98
|
+
"status": "active",
|
|
99
|
+
"summary": "Persistent shop data.",
|
|
100
|
+
"mount": {
|
|
101
|
+
"source": "volume:shop-data",
|
|
102
|
+
"target": "/app/data",
|
|
103
|
+
"mode": "rw",
|
|
104
|
+
"order": 1
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"schemaVersion": "archcontext.node/v2",
|
|
109
|
+
"id": "mount.shop.app-cache",
|
|
110
|
+
"kind": "mount",
|
|
111
|
+
"name": "App cache",
|
|
112
|
+
"status": "active",
|
|
113
|
+
"summary": "In-memory cache files.",
|
|
114
|
+
"mount": {
|
|
115
|
+
"source": "tmpfs",
|
|
116
|
+
"target": "/app/cache",
|
|
117
|
+
"mode": "rw",
|
|
118
|
+
"order": 1
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"schemaVersion": "archcontext.node/v2",
|
|
123
|
+
"id": "mount.shop.config",
|
|
124
|
+
"kind": "mount",
|
|
125
|
+
"name": "Shop config",
|
|
126
|
+
"status": "active",
|
|
127
|
+
"summary": "Configuration shared by the pod.",
|
|
128
|
+
"mount": {
|
|
129
|
+
"source": "configmap:shop",
|
|
130
|
+
"target": "/etc/shop",
|
|
131
|
+
"mode": "ro",
|
|
132
|
+
"order": 0
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"schemaVersion": "archcontext.node/v2",
|
|
137
|
+
"id": "mount.shop.tmp",
|
|
138
|
+
"kind": "mount",
|
|
139
|
+
"name": "Scratch",
|
|
140
|
+
"status": "active",
|
|
141
|
+
"summary": "Anonymous scratch space.",
|
|
142
|
+
"mount": {
|
|
143
|
+
"target": "/tmp",
|
|
144
|
+
"mode": "rw",
|
|
145
|
+
"order": 0
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"relations": [
|
|
150
|
+
{
|
|
151
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
152
|
+
"id": "relation.shop.api-deployed-on-server",
|
|
153
|
+
"kind": "deployed-on",
|
|
154
|
+
"source": "component.shop.api",
|
|
155
|
+
"target": "process.shop.api-server",
|
|
156
|
+
"intent": "The API component runs as the API server process."
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
160
|
+
"id": "relation.shop.api-runs-in-container",
|
|
161
|
+
"kind": "runs-in",
|
|
162
|
+
"source": "process.shop.api-server",
|
|
163
|
+
"target": "namespace.shop.api-container",
|
|
164
|
+
"intent": "The API server runs in its container."
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
168
|
+
"id": "relation.shop.worker-runs-in-container",
|
|
169
|
+
"kind": "runs-in",
|
|
170
|
+
"source": "process.shop.worker",
|
|
171
|
+
"target": "namespace.shop.api-container",
|
|
172
|
+
"intent": "The worker shares the API container."
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
176
|
+
"id": "relation.shop.api-spawns-worker",
|
|
177
|
+
"kind": "spawns",
|
|
178
|
+
"source": "process.shop.api-server",
|
|
179
|
+
"target": "process.shop.worker",
|
|
180
|
+
"intent": "The API server starts the worker."
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
184
|
+
"id": "relation.shop.api-mounts-code",
|
|
185
|
+
"kind": "mounts",
|
|
186
|
+
"source": "process.shop.api-server",
|
|
187
|
+
"target": "mount.shop.app-code",
|
|
188
|
+
"intent": "Reads the built application."
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
192
|
+
"id": "relation.shop.api-mounts-data",
|
|
193
|
+
"kind": "mounts",
|
|
194
|
+
"source": "process.shop.api-server",
|
|
195
|
+
"target": "mount.shop.app-data",
|
|
196
|
+
"intent": "Stores shop data."
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
200
|
+
"id": "relation.shop.api-mounts-cache",
|
|
201
|
+
"kind": "mounts",
|
|
202
|
+
"source": "process.shop.api-server",
|
|
203
|
+
"target": "mount.shop.app-cache",
|
|
204
|
+
"intent": "Caches rendered pages."
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
208
|
+
"id": "relation.shop.pod-mounts-config",
|
|
209
|
+
"kind": "mounts",
|
|
210
|
+
"source": "namespace.shop.pod",
|
|
211
|
+
"target": "mount.shop.config",
|
|
212
|
+
"intent": "Shares configuration with every container."
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"schemaVersion": "archcontext.relation/v1",
|
|
216
|
+
"id": "relation.shop.worker-mounts-tmp",
|
|
217
|
+
"kind": "mounts",
|
|
218
|
+
"source": "process.shop.worker",
|
|
219
|
+
"target": "mount.shop.tmp",
|
|
220
|
+
"intent": "Writes job scratch files."
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "archcontext.capabilities/v1",
|
|
3
|
-
"package": { "name": "archctx", "version": "0.9.
|
|
3
|
+
"package": { "name": "archctx", "version": "0.9.3" },
|
|
4
4
|
"protocols": {
|
|
5
5
|
"projectionRequest": "archcontext.projection-request/v1",
|
|
6
6
|
"projectionResult": "archcontext.projection-result/v2",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "archcontext.node/v2",
|
|
3
|
+
"id": "module.subscription",
|
|
4
|
+
"kind": "module",
|
|
5
|
+
"name": "Subscription",
|
|
6
|
+
"status": "active",
|
|
7
|
+
"parent": "capability.subscriptions",
|
|
8
|
+
"layer": "domain-services",
|
|
9
|
+
"summary": "Owns subscription lifecycle and plan transitions.",
|
|
10
|
+
"responsibilities": ["create-subscription", "change-plan"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "archcontext.node/v2",
|
|
3
|
+
"id": "mount.shop.app-code",
|
|
4
|
+
"kind": "mount",
|
|
5
|
+
"name": "App code",
|
|
6
|
+
"status": "active",
|
|
7
|
+
"summary": "The built application, read-only.",
|
|
8
|
+
"mount": {
|
|
9
|
+
"source": "./dist",
|
|
10
|
+
"target": "/app",
|
|
11
|
+
"mode": "ro",
|
|
12
|
+
"order": 0
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": "archcontext.product-version-manifest/v1",
|
|
3
3
|
"product": {
|
|
4
4
|
"name": "archctx",
|
|
5
|
-
"version": "0.9.
|
|
5
|
+
"version": "0.9.3",
|
|
6
6
|
"distribution": "one-package"
|
|
7
7
|
},
|
|
8
8
|
"packageManager": "bun@1.4.3",
|
|
@@ -12,25 +12,25 @@
|
|
|
12
12
|
"surfaces": {
|
|
13
13
|
"cli": {
|
|
14
14
|
"packageName": "@archcontext/surfaces",
|
|
15
|
-
"version": "0.9.
|
|
15
|
+
"version": "0.9.3",
|
|
16
16
|
"entrypoint": "archctx"
|
|
17
17
|
},
|
|
18
18
|
"daemon": {
|
|
19
19
|
"packageName": "@archcontext/local-runtime",
|
|
20
|
-
"version": "0.9.
|
|
20
|
+
"version": "0.9.3",
|
|
21
21
|
"entrypoint": "archctx daemon start",
|
|
22
22
|
"rpcSchemaVersion": "archcontext.runtime-rpc/v2"
|
|
23
23
|
},
|
|
24
24
|
"mcp": {
|
|
25
25
|
"packageName": "@archcontext/surfaces",
|
|
26
|
-
"version": "0.9.
|
|
26
|
+
"version": "0.9.3",
|
|
27
27
|
"entrypoint": "archctx mcp",
|
|
28
28
|
"transport": "stdio"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"schemas": {
|
|
32
32
|
"schemaSetVersion": "2026-06-25.al0-ledger",
|
|
33
|
-
"contractsPackageVersion": "0.9.
|
|
33
|
+
"contractsPackageVersion": "0.9.3",
|
|
34
34
|
"reviewChallenge": "archcontext.review-challenge/v2",
|
|
35
35
|
"attestation": "archcontext.attestation/v2",
|
|
36
36
|
"deviceIdentity": "archcontext.device-identity/v1",
|
package/package.json
CHANGED
|
@@ -5,17 +5,49 @@
|
|
|
5
5
|
"type": "object",
|
|
6
6
|
"additionalProperties": false,
|
|
7
7
|
"required": ["schemaVersion", "id", "kind", "name", "status", "summary"],
|
|
8
|
+
"allOf": [
|
|
9
|
+
{
|
|
10
|
+
"if": { "properties": { "kind": { "const": "namespace" } }, "required": ["kind"] },
|
|
11
|
+
"then": { "required": ["namespace"] },
|
|
12
|
+
"else": { "not": { "required": ["namespace"] } }
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"if": { "properties": { "kind": { "const": "mount" } }, "required": ["kind"] },
|
|
16
|
+
"then": { "required": ["mount"] },
|
|
17
|
+
"else": { "not": { "required": ["mount"] } }
|
|
18
|
+
}
|
|
19
|
+
],
|
|
8
20
|
"properties": {
|
|
9
21
|
"schemaVersion": { "const": "archcontext.node/v2" },
|
|
10
22
|
"id": { "type": "string", "pattern": "^([a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)+$" },
|
|
11
23
|
"kind": {
|
|
12
24
|
"type": "string",
|
|
13
|
-
"enum": ["capability", "module", "component", "interface", "event", "datastore", "external-system", "deployment"]
|
|
25
|
+
"enum": ["capability", "module", "component", "interface", "event", "datastore", "external-system", "deployment", "process", "namespace", "mount"]
|
|
14
26
|
},
|
|
15
27
|
"name": { "type": "string" },
|
|
16
28
|
"status": { "type": "string", "enum": ["active", "planned", "deprecated", "removed"] },
|
|
17
29
|
"parent": { "type": "string", "pattern": "^([a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)+$" },
|
|
30
|
+
"layer": { "type": "string", "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$" },
|
|
18
31
|
"summary": { "type": "string" },
|
|
32
|
+
"namespace": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"required": ["type"],
|
|
36
|
+
"properties": {
|
|
37
|
+
"type": { "type": "string", "enum": ["host", "container", "pod", "kubernetes", "pid", "mount", "net", "user"] }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"mount": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"required": ["target", "mode", "order"],
|
|
44
|
+
"properties": {
|
|
45
|
+
"source": { "type": "string", "minLength": 1 },
|
|
46
|
+
"target": { "type": "string", "pattern": "^/([^/\\u0000]+(/[^/\\u0000]+)*)?$" },
|
|
47
|
+
"mode": { "type": "string", "enum": ["ro", "rw"] },
|
|
48
|
+
"order": { "type": "integer", "minimum": 0 }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
19
51
|
"responsibilities": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
|
|
20
52
|
"source": {
|
|
21
53
|
"type": "object",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"id": { "type": "string", "pattern": "^([a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)+$" },
|
|
11
11
|
"kind": {
|
|
12
12
|
"type": "string",
|
|
13
|
-
"enum": ["depends-on", "calls", "publishes", "subscribes", "reads", "writes", "implements", "deployed-on"]
|
|
13
|
+
"enum": ["depends-on", "calls", "publishes", "subscribes", "reads", "writes", "implements", "deployed-on", "spawns", "runs-in", "mounts"]
|
|
14
14
|
},
|
|
15
15
|
"source": { "type": "string", "pattern": "^([a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)+$" },
|
|
16
16
|
"target": { "type": "string", "pattern": "^([a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\\.[a-z0-9][a-z0-9-]*)+$" },
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"to": { "type": "string", "minLength": 1 },
|
|
31
31
|
"imports": { "type": "integer", "minimum": 1 },
|
|
32
32
|
"calls": { "type": "null" },
|
|
33
|
-
"declared": { "type": "boolean", "description": "A relation of a declaring kind (every kind but deployed-on) runs from a node that rolls up to `from` into a node that rolls up to `to`. A cell with from equal to to is always declared and lists no relation ids." },
|
|
33
|
+
"declared": { "type": "boolean", "description": "A relation of a declaring kind (every kind but deployed-on, spawns, runs-in and mounts) runs from a node that rolls up to `from` into a node that rolls up to `to`. A cell with from equal to to is always declared and lists no relation ids." },
|
|
34
34
|
"relationIds": { "type": "array", "uniqueItems": true, "description": "The declaring relation ids, sorted. Non-empty exactly when a cross-capability cell is declared.", "items": { "type": "string", "minLength": 1 } }
|
|
35
35
|
},
|
|
36
36
|
"if": { "properties": { "relationIds": { "minItems": 1 } } },
|
|
@@ -266,6 +266,8 @@
|
|
|
266
266
|
"diagram-mermaid",
|
|
267
267
|
"diagram-structurizr",
|
|
268
268
|
"diagram-likec4",
|
|
269
|
+
"diagram-runtime-topology",
|
|
270
|
+
"runtime-topology-summary",
|
|
269
271
|
"agent-context"
|
|
270
272
|
]
|
|
271
273
|
},
|
|
@@ -330,7 +332,7 @@
|
|
|
330
332
|
},
|
|
331
333
|
"sourceStamps": {
|
|
332
334
|
"type": "object",
|
|
333
|
-
"description": "entity-summary targets only: the content digest of every declared source footprint this target documents, by node id.
|
|
335
|
+
"description": "entity-summary and runtime topology targets only: the content digest of every declared source footprint this target documents, by node id. A footprint belongs to its node's nearest ancestor-or-self with an entity-summary target, so it is stamped on exactly one entity-summary row; a runtime topology node's footprint is stamped on every runtime topology row instead, and those rows carry identical stamps (ADR-0049).",
|
|
334
336
|
"additionalProperties": {
|
|
335
337
|
"$ref": "#/$defs/digest"
|
|
336
338
|
}
|
|
@@ -358,24 +360,37 @@
|
|
|
358
360
|
"properties": {
|
|
359
361
|
"type": {
|
|
360
362
|
"not": {
|
|
361
|
-
"
|
|
363
|
+
"enum": [
|
|
364
|
+
"entity-summary",
|
|
365
|
+
"diagram-runtime-topology",
|
|
366
|
+
"runtime-topology-summary"
|
|
367
|
+
]
|
|
362
368
|
}
|
|
363
369
|
}
|
|
364
370
|
}
|
|
365
371
|
},
|
|
366
372
|
"then": {
|
|
367
373
|
"not": {
|
|
368
|
-
"
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
374
|
+
"required": [
|
|
375
|
+
"sourceStamps"
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"if": {
|
|
382
|
+
"properties": {
|
|
383
|
+
"type": {
|
|
384
|
+
"not": {
|
|
385
|
+
"const": "entity-summary"
|
|
378
386
|
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
"then": {
|
|
391
|
+
"not": {
|
|
392
|
+
"required": [
|
|
393
|
+
"scale"
|
|
379
394
|
]
|
|
380
395
|
}
|
|
381
396
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"targetId": { "type": "string", "pattern": "^projection_target\\.[a-zA-Z0-9_.-]+$" },
|
|
14
14
|
"type": {
|
|
15
15
|
"type": "string",
|
|
16
|
-
"enum": ["architecture-index", "entity-summary", "relation-summary", "decision-index", "architecture-changelog", "diagram-mermaid", "diagram-structurizr", "diagram-likec4", "agent-context"]
|
|
16
|
+
"enum": ["architecture-index", "entity-summary", "relation-summary", "decision-index", "architecture-changelog", "diagram-mermaid", "diagram-structurizr", "diagram-likec4", "diagram-runtime-topology", "runtime-topology-summary", "agent-context"]
|
|
17
17
|
},
|
|
18
18
|
"scope": {
|
|
19
19
|
"type": "object",
|
package/src/failure.ts
CHANGED
|
@@ -39,8 +39,9 @@ const policies: Record<string, Policy> = {
|
|
|
39
39
|
"model-missing": { code: "AC_MODEL_ADOPTION_REQUIRED", message: "Architecture debt requires an adopted model.", fields: ["checks"] },
|
|
40
40
|
"changed-path-invalid": { code: "AC_SCHEMA_INVALID", message: "Changed paths must be an array of repository-relative POSIX paths.", fields: ["checks"] },
|
|
41
41
|
"debt-report-invalid": { code: "AC_SCHEMA_INVALID", message: "Architecture debt evidence violates its contract.", fields: ["checks"] },
|
|
42
|
-
"projection-manifest-upgrade-required": { code: "AC_PRECONDITION_FAILED", message: "The committed projection manifest requires supported re-baselining." },
|
|
42
|
+
"projection-manifest-upgrade-required": { code: "AC_PRECONDITION_FAILED", message: "The committed projection manifest requires supported re-baselining. First restore the original model if missing; the manifest digest cannot recover it. With the reviewed model available, follow docs/runbooks/architecture-documentation-projections.md before running archctx docs apply --approved --profile <default|repo-harness/v1>." },
|
|
43
43
|
"projection-manifest-invalid": { code: "AC_PRECONDITION_FAILED", message: "The committed projection manifest violates its contract." },
|
|
44
|
+
"architecture-model-ignored": { code: "AC_PRECONDITION_FAILED", action: "commit-architecture-model", message: "Git ignore rules exclude architecture model paths, so the model cannot be committed and a manifest digest cannot rebuild it. Remove or narrow the rule, commit the model, then retry adoption. The diagnostic command prints each deciding rule.", facts: { pathCount: "uint", paths: "optional:diagnosticPaths", commands: "optional:diagnosticCommands", omittedPathCount: "uint" } },
|
|
44
45
|
"projection-footprint-uncovered": { code: "AC_PRECONDITION_FAILED", message: "Declared source footprints lack a projection target." },
|
|
45
46
|
"index-missing": { code: "AC_CODE_FACTS_UNAVAILABLE", message: "Required code facts have no available index. Run codegraph init." },
|
|
46
47
|
"code-facts-not-ready": { code: "AC_CODE_FACTS_NOT_READY", message: "Repository code facts are not ready. Run archctx doctor --json and follow the reported action.", facts: { issues: "codeFactsIssues" } },
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./projection-writer";
|
|
|
15
15
|
export * from "./projection-manifest";
|
|
16
16
|
export * from "./product-version";
|
|
17
17
|
export * from "./refactor";
|
|
18
|
+
export * from "./runtime-topology";
|
|
18
19
|
export * from "./schema";
|
|
19
20
|
export * from "./failure";
|
|
20
21
|
export * from "./validator";
|
package/src/ledger.ts
CHANGED
|
@@ -150,6 +150,8 @@ export type ProjectionTargetType =
|
|
|
150
150
|
| "diagram-mermaid"
|
|
151
151
|
| "diagram-structurizr"
|
|
152
152
|
| "diagram-likec4"
|
|
153
|
+
| "diagram-runtime-topology"
|
|
154
|
+
| "runtime-topology-summary"
|
|
153
155
|
| "agent-context";
|
|
154
156
|
export type ProjectionTargetScopeKind = "repository" | "entity" | "relation" | "decision" | "diagram" | "changelog";
|
|
155
157
|
export type ProjectionTargetOwnership = "generated" | "mixed";
|
package/src/native-context.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FailureError, knownFailure, toEnvelope, unclassifiedFailure } from "./failure";
|
|
2
2
|
import { canonicalize, errorEnvelope, type ArchContextErrorCode, type Json, type JsonEnvelope } from "./schema";
|
|
3
|
+
import { runtimeTopologyModelIssues } from "./runtime-topology";
|
|
3
4
|
import { jsonSchemaResolver, validateJsonSchema, type JsonSchemaResolver } from "./validator";
|
|
4
5
|
|
|
5
6
|
export const NATIVE_CONTEXT_SCHEMA_VERSION = "archcontext.native-context-export/v1" as const;
|
|
@@ -248,6 +249,10 @@ export function nativeContextModelIssues(model: NativeContextModel, schemas: Nat
|
|
|
248
249
|
for (const relation of model.relations) {
|
|
249
250
|
for (const field of ["source", "target", "via"] as const) if (relation[field] !== undefined && !nodes.has(relation[field] as string)) add(relation, field, "relation-node-missing");
|
|
250
251
|
}
|
|
252
|
+
const relations = new Map(model.relations.map(relation => [relation.id as string, relation]));
|
|
253
|
+
for (const issue of runtimeTopologyModelIssues(model)) {
|
|
254
|
+
add(relations.get(issue.entityId) ?? nodes.get(issue.entityId) ?? issue.entityId, issue.field, issue.invariant);
|
|
255
|
+
}
|
|
251
256
|
for (const flow of model.flows) {
|
|
252
257
|
if (nodes.get(flow.capabilityId as string)?.kind !== "capability") add(flow, "capabilityId", "flow-capability-missing");
|
|
253
258
|
if (flow.applicability !== "required") continue;
|
|
@@ -75,8 +75,10 @@ export const CAPABILITY_DEPENDENCIES_EDGE_LIMIT = 200;
|
|
|
75
75
|
export const CAPABILITY_DEPENDENCIES_CALLS_UNAVAILABLE_REASON = "call-edges-not-exposed" as const;
|
|
76
76
|
/**
|
|
77
77
|
* The relation kinds that declare an import dependency: every `archcontext.relation/v1` kind in
|
|
78
|
-
* which the source uses the target. `deployed-on` places a node on infrastructure and
|
|
79
|
-
*
|
|
78
|
+
* which the source uses the target. `deployed-on` places a node on infrastructure, and the runtime
|
|
79
|
+
* topology kinds `spawns`, `runs-in` and `mounts` (ADR-0049) describe processes, namespaces and
|
|
80
|
+
* mounts; none of them declares a code dependency. A kind added to the relation schema later
|
|
81
|
+
* declares nothing until it is listed.
|
|
80
82
|
*
|
|
81
83
|
* The rule: an import from a file owned by capability A into a file owned by capability B, A != B,
|
|
82
84
|
* is declared when the model has a relation of one of these kinds whose `source` rolls up to A and
|
package/src/product-version.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const ARCHCONTEXT_PRODUCT_NAME = "archctx";
|
|
2
|
-
export const ARCHCONTEXT_PRODUCT_VERSION = "0.9.
|
|
2
|
+
export const ARCHCONTEXT_PRODUCT_VERSION = "0.9.3";
|
|
3
3
|
export const ARCHCONTEXT_PACKAGE_MANAGER = "bun@1.4.3";
|
|
4
4
|
export const ARCHCONTEXT_NODE_RANGE = ">=22.22 <26";
|
|
5
5
|
export const LOCAL_RUNTIME_RPC_SCHEMA_VERSION = "archcontext.runtime-rpc/v2";
|
|
@@ -36,7 +36,7 @@ export const SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS =
|
|
|
36
36
|
export const PROJECTION_MANIFEST_UPGRADE_REQUIRED = "projection-manifest-upgrade-required" as const;
|
|
37
37
|
/** The reason code of a current-format manifest that fails its contract; restore it from Git. */
|
|
38
38
|
export const PROJECTION_MANIFEST_INVALID = "projection-manifest-invalid" as const;
|
|
39
|
-
/** The reason code of a declared source footprint that no
|
|
39
|
+
/** The reason code of a declared source footprint that no stamping target carries a stamp for. */
|
|
40
40
|
export const PROJECTION_FOOTPRINT_UNCOVERED = "projection-footprint-uncovered" as const;
|
|
41
41
|
export const ARCHITECTURE_DOCS_PROJECTION_PROVENANCE_SCHEMA_VERSION = "archcontext.architecture-docs-projection-provenance/v3" as const;
|
|
42
42
|
export const ARCHITECTURE_DOCS_LAYOUT_VERSION_V1 = "archcontext.docs-layout/v1" as const;
|
|
@@ -130,9 +130,11 @@ export interface ArchitectureDocsProjectionManifestTargetV3 {
|
|
|
130
130
|
/** `digestJson({ targetId, body })` of the generated body: the region of a `mixed` target, the whole file of a `generated` one. */
|
|
131
131
|
outputDigest: string;
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
133
|
+
* The content digest of every declared source footprint this target documents, by node id. On an
|
|
134
|
+
* `entity-summary` row a footprint belongs to its node's nearest ancestor-or-self that has an
|
|
135
|
+
* entity-summary target, so it is stamped on exactly one such row. A runtime topology node's
|
|
136
|
+
* footprint (ADR-0049) is stamped on every runtime topology row instead, and those rows carry
|
|
137
|
+
* identical stamps. No other target type carries stamps.
|
|
136
138
|
*/
|
|
137
139
|
sourceStamps?: Record<string, string>;
|
|
138
140
|
/** Present exactly when `sourceStamps` stamps the target's own node: the scale buckets its document prints (#264). */
|
|
@@ -177,8 +179,15 @@ const TARGET_TYPES: Record<ProjectionTargetType, true> = {
|
|
|
177
179
|
"diagram-mermaid": true,
|
|
178
180
|
"diagram-structurizr": true,
|
|
179
181
|
"diagram-likec4": true,
|
|
182
|
+
"diagram-runtime-topology": true,
|
|
183
|
+
"runtime-topology-summary": true,
|
|
180
184
|
"agent-context": true
|
|
181
185
|
};
|
|
186
|
+
/** The whole-model targets that render the runtime topology and carry its nodes' stamps (ADR-0049). */
|
|
187
|
+
export const RUNTIME_TOPOLOGY_TARGET_TYPES = ["diagram-runtime-topology", "runtime-topology-summary"] as const satisfies readonly ProjectionTargetType[];
|
|
188
|
+
export function isRuntimeTopologyTargetType(type: unknown): type is (typeof RUNTIME_TOPOLOGY_TARGET_TYPES)[number] {
|
|
189
|
+
return typeof type === "string" && (RUNTIME_TOPOLOGY_TARGET_TYPES as readonly string[]).includes(type);
|
|
190
|
+
}
|
|
182
191
|
const SCOPE_KINDS: Record<ProjectionTargetScopeKind, true> = { repository: true, entity: true, relation: true, decision: true, diagram: true, changelog: true };
|
|
183
192
|
const OWNERSHIPS: Record<ProjectionTargetOwnership, true> = { generated: true, mixed: true };
|
|
184
193
|
const FORMATS: Record<ProjectionTargetFormat, true> = { markdown: true, mermaid: true, "structurizr-json": true, likec4: true };
|
|
@@ -211,6 +220,7 @@ export function architectureDocsProjectionManifestIssues(value: unknown): string
|
|
|
211
220
|
}
|
|
212
221
|
const paths = new Set<string>();
|
|
213
222
|
const stampOwners = new Map<string, string>();
|
|
223
|
+
let topologyStamps: { targetId: string; stamps: string } | undefined;
|
|
214
224
|
for (const [targetId, row] of Object.entries(targets)) {
|
|
215
225
|
const prefix = `manifest.targets[${JSON.stringify(targetId)}]`;
|
|
216
226
|
if (!isNonEmptyString(targetId)) issues.push("manifest.targets keys must be non-empty targetIds");
|
|
@@ -220,7 +230,20 @@ export function architectureDocsProjectionManifestIssues(value: unknown): string
|
|
|
220
230
|
if (paths.has(path)) issues.push(`${prefix}.path is recorded by another target`);
|
|
221
231
|
paths.add(path);
|
|
222
232
|
}
|
|
223
|
-
|
|
233
|
+
const stamps = record(record(row)?.sourceStamps) ?? {};
|
|
234
|
+
if (isRuntimeTopologyTargetType(record(row)?.type)) {
|
|
235
|
+
// Every topology row renders the same topology, so all of them carry one stamp set.
|
|
236
|
+
const serialized = JSON.stringify(Object.keys(stamps).sort(compareStrings).map((nodeId) => [nodeId, stamps[nodeId]]));
|
|
237
|
+
if (topologyStamps === undefined) topologyStamps = { targetId, stamps: serialized };
|
|
238
|
+
else if (topologyStamps.stamps !== serialized) issues.push(`${prefix}.sourceStamps must equal the sourceStamps of ${topologyStamps.targetId}`);
|
|
239
|
+
for (const nodeId of Object.keys(stamps)) {
|
|
240
|
+
const owner = stampOwners.get(nodeId);
|
|
241
|
+
if (owner !== undefined && !isRuntimeTopologyTargetType(record(targets[owner])?.type)) issues.push(`${prefix}.sourceStamps.${nodeId} is already stamped on ${owner}`);
|
|
242
|
+
else if (owner === undefined) stampOwners.set(nodeId, targetId);
|
|
243
|
+
}
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
for (const nodeId of Object.keys(stamps)) {
|
|
224
247
|
const owner = stampOwners.get(nodeId);
|
|
225
248
|
if (owner !== undefined) issues.push(`${prefix}.sourceStamps.${nodeId} is already stamped on ${owner}`);
|
|
226
249
|
else stampOwners.set(nodeId, targetId);
|
|
@@ -317,7 +340,10 @@ export function architectureSemanticStateFromCapabilities(capabilities: readonly
|
|
|
317
340
|
};
|
|
318
341
|
}
|
|
319
342
|
|
|
320
|
-
/**
|
|
343
|
+
/**
|
|
344
|
+
* Every stamp the rows record, by node id. A valid manifest stamps each node on one entity-summary
|
|
345
|
+
* row, or with one digest on every runtime topology row.
|
|
346
|
+
*/
|
|
321
347
|
export function architectureDocsProjectionManifestSourceStamps(manifest: ArchitectureDocsProjectionManifestV3): Record<string, string> {
|
|
322
348
|
const stamps: Record<string, string> = {};
|
|
323
349
|
for (const row of Object.values(manifest.targets)) Object.assign(stamps, row.sourceStamps ?? {});
|
|
@@ -500,9 +526,10 @@ function manifestTargetIssues(value: unknown, prefix: string): string[] {
|
|
|
500
526
|
if (typeof target.ownership !== "string" || !Object.hasOwn(OWNERSHIPS, target.ownership)) issues.push(`${prefix}.ownership is unsupported`);
|
|
501
527
|
if (typeof target.format !== "string" || !Object.hasOwn(FORMATS, target.format)) issues.push(`${prefix}.format is unsupported`);
|
|
502
528
|
if (!isDigest(target.outputDigest)) issues.push(`${prefix}.outputDigest must be a SHA-256 digest`);
|
|
503
|
-
if (
|
|
504
|
-
issues.push(`${prefix}.sourceStamps
|
|
529
|
+
if (target.sourceStamps !== undefined && target.type !== "entity-summary" && !isRuntimeTopologyTargetType(target.type)) {
|
|
530
|
+
issues.push(`${prefix}.sourceStamps are only allowed on entity-summary and runtime topology targets`);
|
|
505
531
|
}
|
|
532
|
+
if (target.scale !== undefined && target.type !== "entity-summary") issues.push(`${prefix}.scale is only allowed on entity-summary targets`);
|
|
506
533
|
if (target.sourceStamps !== undefined) {
|
|
507
534
|
const stamps = record(target.sourceStamps);
|
|
508
535
|
if (!stamps || Object.keys(stamps).length === 0) issues.push(`${prefix}.sourceStamps must be a non-empty object keyed by node id`);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Json } from "./schema";
|
|
2
|
+
|
|
3
|
+
/** The runtime topology node kinds (ADR-0049). Their kind-specific objects live in the node schema. */
|
|
4
|
+
export const RUNTIME_TOPOLOGY_NODE_KINDS = ["process", "namespace", "mount"] as const;
|
|
5
|
+
export type RuntimeTopologyNodeKind = (typeof RUNTIME_TOPOLOGY_NODE_KINDS)[number];
|
|
6
|
+
|
|
7
|
+
export function isRuntimeTopologyNodeKind(kind: unknown): kind is RuntimeTopologyNodeKind {
|
|
8
|
+
return typeof kind === "string" && (RUNTIME_TOPOLOGY_NODE_KINDS as readonly string[]).includes(kind);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The node kinds each topology relation may connect. Every other relation kind is unconstrained here. */
|
|
12
|
+
export const RUNTIME_TOPOLOGY_RELATION_ENDPOINT_KINDS: Readonly<Record<"spawns" | "runs-in" | "mounts", { source: readonly RuntimeTopologyNodeKind[]; target: readonly RuntimeTopologyNodeKind[] }>> = {
|
|
13
|
+
spawns: { source: ["process"], target: ["process"] },
|
|
14
|
+
"runs-in": { source: ["process"], target: ["namespace"] },
|
|
15
|
+
mounts: { source: ["process", "namespace"], target: ["mount"] }
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type RuntimeTopologyInvariant =
|
|
19
|
+
| "topology-relation-endpoint-missing"
|
|
20
|
+
| "topology-relation-source-kind-invalid"
|
|
21
|
+
| "topology-relation-target-kind-invalid"
|
|
22
|
+
| "topology-process-namespace-ambiguous"
|
|
23
|
+
| "topology-mount-mounter-ambiguous"
|
|
24
|
+
| "topology-namespace-parent-missing"
|
|
25
|
+
| "topology-namespace-parent-kind-invalid"
|
|
26
|
+
| "topology-namespace-parent-cycle";
|
|
27
|
+
|
|
28
|
+
export interface RuntimeTopologyIssue {
|
|
29
|
+
/** The node or relation id that carries the problem. */
|
|
30
|
+
entityId: string;
|
|
31
|
+
field: string;
|
|
32
|
+
invariant: RuntimeTopologyInvariant;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type TopologyRecord = Readonly<Record<string, Json | undefined>>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Cross-entity rules of the runtime topology (ADR-0049) that a per-file JSON schema cannot state.
|
|
39
|
+
* Native-context validation and the YAML model store both call this one function, and the topology
|
|
40
|
+
* renderer refuses a model it reports on, so `archctx check` and a projection cannot disagree.
|
|
41
|
+
*
|
|
42
|
+
* - `spawns` connects two processes, `runs-in` a process to a namespace, `mounts` a process or a
|
|
43
|
+
* namespace to a mount. A topology relation whose endpoint names no node is reported here too:
|
|
44
|
+
* the model store has no other relation reference check, so every caller fails closed.
|
|
45
|
+
* - A process runs in at most one namespace: the innermost one. Outer namespaces come from the
|
|
46
|
+
* namespace `parent` chain.
|
|
47
|
+
* - A mount is mounted by at most one process or namespace, because a mount node is one entry of
|
|
48
|
+
* one mount table.
|
|
49
|
+
* - A namespace's `parent`, when present, is another namespace, and the chain has no cycle; it is
|
|
50
|
+
* the nesting the topology view draws.
|
|
51
|
+
*
|
|
52
|
+
* Records whose id is not a string are skipped: shape validation reports them. Issues come out
|
|
53
|
+
* sorted by entity id, then field and invariant.
|
|
54
|
+
*/
|
|
55
|
+
export function runtimeTopologyModelIssues(model: { nodes: readonly TopologyRecord[]; relations: readonly TopologyRecord[] }): RuntimeTopologyIssue[] {
|
|
56
|
+
const issues: RuntimeTopologyIssue[] = [];
|
|
57
|
+
const nodesById = new Map<string, TopologyRecord>();
|
|
58
|
+
for (const node of model.nodes) if (typeof node.id === "string") nodesById.set(node.id, node);
|
|
59
|
+
const namespacesByProcess = new Map<string, string[]>();
|
|
60
|
+
const mountersByMount = new Map<string, string[]>();
|
|
61
|
+
for (const relation of model.relations) {
|
|
62
|
+
if (typeof relation.id !== "string" || typeof relation.kind !== "string" || !Object.hasOwn(RUNTIME_TOPOLOGY_RELATION_ENDPOINT_KINDS, relation.kind)) continue;
|
|
63
|
+
const rule = RUNTIME_TOPOLOGY_RELATION_ENDPOINT_KINDS[relation.kind as keyof typeof RUNTIME_TOPOLOGY_RELATION_ENDPOINT_KINDS];
|
|
64
|
+
let endpointsValid = true;
|
|
65
|
+
for (const field of ["source", "target"] as const) {
|
|
66
|
+
const endpoint = relation[field];
|
|
67
|
+
const node = typeof endpoint === "string" ? nodesById.get(endpoint) : undefined;
|
|
68
|
+
if (!node) {
|
|
69
|
+
issues.push({ entityId: relation.id, field, invariant: "topology-relation-endpoint-missing" });
|
|
70
|
+
endpointsValid = false;
|
|
71
|
+
} else if (!(rule[field] as readonly unknown[]).includes(node.kind)) {
|
|
72
|
+
issues.push({ entityId: relation.id, field, invariant: field === "source" ? "topology-relation-source-kind-invalid" : "topology-relation-target-kind-invalid" });
|
|
73
|
+
endpointsValid = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!endpointsValid) continue;
|
|
77
|
+
const source = relation.source as string;
|
|
78
|
+
const target = relation.target as string;
|
|
79
|
+
if (relation.kind === "runs-in") namespacesByProcess.set(source, [...(namespacesByProcess.get(source) ?? []), target]);
|
|
80
|
+
if (relation.kind === "mounts") mountersByMount.set(target, [...(mountersByMount.get(target) ?? []), source]);
|
|
81
|
+
}
|
|
82
|
+
for (const [processId, namespaces] of namespacesByProcess) {
|
|
83
|
+
if (new Set(namespaces).size > 1) issues.push({ entityId: processId, field: "runs-in", invariant: "topology-process-namespace-ambiguous" });
|
|
84
|
+
}
|
|
85
|
+
for (const [mountId, mounters] of mountersByMount) {
|
|
86
|
+
if (new Set(mounters).size > 1) issues.push({ entityId: mountId, field: "mounts", invariant: "topology-mount-mounter-ambiguous" });
|
|
87
|
+
}
|
|
88
|
+
for (const [id, node] of nodesById) {
|
|
89
|
+
if (node.kind !== "namespace" || node.parent === undefined) continue;
|
|
90
|
+
const parent = typeof node.parent === "string" ? nodesById.get(node.parent) : undefined;
|
|
91
|
+
if (!parent) {
|
|
92
|
+
issues.push({ entityId: id, field: "parent", invariant: "topology-namespace-parent-missing" });
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (parent.kind !== "namespace") {
|
|
96
|
+
issues.push({ entityId: id, field: "parent", invariant: "topology-namespace-parent-kind-invalid" });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const seen = new Set<string>([id]);
|
|
100
|
+
let cursor: TopologyRecord | undefined = parent;
|
|
101
|
+
while (cursor && cursor.kind === "namespace" && typeof cursor.id === "string") {
|
|
102
|
+
if (seen.has(cursor.id)) {
|
|
103
|
+
issues.push({ entityId: id, field: "parent", invariant: "topology-namespace-parent-cycle" });
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
seen.add(cursor.id);
|
|
107
|
+
cursor = typeof cursor.parent === "string" ? nodesById.get(cursor.parent) : undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return issues.sort((left, right) => compare(left.entityId, right.entityId) || compare(left.field, right.field) || compare(left.invariant, right.invariant));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function compare(left: string, right: string): number {
|
|
114
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
115
|
+
}
|