archsight 0.5.4 → 0.5.6

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/docs/archimate.md +4 -3
  3. data/docs/diagram.md +107 -6
  4. data/docs/icons.md +1 -0
  5. data/docs/index.md.erb +1 -0
  6. data/docs/modeling.md +71 -2
  7. data/lib/archsight/diagram/graph/attributes.rb +66 -11
  8. data/lib/archsight/diagram/graph/builder.rb +101 -3
  9. data/lib/archsight/diagram/graph/edge.rb +7 -1
  10. data/lib/archsight/diagram/graph/node.rb +29 -1
  11. data/lib/archsight/diagram/graph/port.rb +28 -0
  12. data/lib/archsight/diagram/graph.rb +18 -1
  13. data/lib/archsight/diagram/includes.rb +22 -4
  14. data/lib/archsight/diagram/layout/alignment.rb +138 -0
  15. data/lib/archsight/diagram/layout/expander.rb +13 -0
  16. data/lib/archsight/diagram/layout/ports.rb +182 -0
  17. data/lib/archsight/diagram/layout/rank_arranger.rb +27 -1
  18. data/lib/archsight/diagram/layout/stacker.rb +3 -2
  19. data/lib/archsight/diagram/layout.rb +15 -5
  20. data/lib/archsight/diagram/legend/inventory.rb +52 -4
  21. data/lib/archsight/diagram/legend/row.rb +44 -0
  22. data/lib/archsight/diagram/parser/ast.rb +9 -0
  23. data/lib/archsight/diagram/parser.rb +56 -5
  24. data/lib/archsight/diagram/renderer/dataflow_renderer.rb +2 -1
  25. data/lib/archsight/diagram/renderer/edge_renderer.rb +5 -2
  26. data/lib/archsight/diagram/renderer/label_placer.rb +98 -22
  27. data/lib/archsight/diagram/renderer/node_renderer.rb +49 -1
  28. data/lib/archsight/diagram/renderer/path_renderer.rb +2 -2
  29. data/lib/archsight/diagram/renderer/stylesheet.rb +10 -1
  30. data/lib/archsight/diagram/renderer/text_renderer.rb +1 -0
  31. data/lib/archsight/diagram/renderer.rb +21 -5
  32. data/lib/archsight/diagram/resource_links.rb +18 -12
  33. data/lib/archsight/diagram/routing/edge_routing.rb +106 -5
  34. data/lib/archsight/diagram/support/markdown_text.rb +2 -2
  35. data/lib/archsight/diagram/support/text_metrics.rb +7 -3
  36. data/lib/archsight/export/confluence/analysis_output.rb +12 -5
  37. data/lib/archsight/linter/structure.rb +17 -3
  38. data/lib/archsight/linter.rb +30 -4
  39. data/lib/archsight/pdf/embeds.rb +3 -2
  40. data/lib/archsight/pdf/typst/archsight.typ +4 -0
  41. data/lib/archsight/resources/base.rb +5 -0
  42. data/lib/archsight/resources/grouping.rb +80 -0
  43. data/lib/archsight/resources/technology_node.rb +17 -2
  44. data/lib/archsight/resources/technology_service.rb +6 -0
  45. data/lib/archsight/resources/technology_system_software.rb +5 -0
  46. data/lib/archsight/resources.rb +28 -0
  47. data/lib/archsight/summary/lens.rb +10 -0
  48. data/lib/archsight/template.rb +2 -2
  49. data/lib/archsight/version.rb +1 -1
  50. metadata +5 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 540f7640d06327e62c658d9bff6cb9e60475f10c63a36ba541170c8ca3077ef1
4
- data.tar.gz: 8cfbe67e126f99e743e45935527b034f980531979ef76ee54295b81e7b27bbdc
3
+ metadata.gz: c89d5fd482f52991a5df44acf11bc11b75b78a29d29ddb0dbe8eeae66526e810
4
+ data.tar.gz: 5462bf8570206aa3ac9de03889c5c545c23f5ac5c090d47ae1fcc6b097ef4b22
5
5
  SHA512:
6
- metadata.gz: 185739ca5a2c52b6c4e1df7ab29f58772908df3bc5bcb53452b7b2114e042ea2a62624fa5d2254c088a36bd2118b3daa81c48eb4b475aa76308ecbe0b32737e4
7
- data.tar.gz: 32384cbe603e19c21e2bdc661979777aeba42e8faeb2a97e88479320bf31fc844ba42c995d11fc316711e9609ab7197a052aa914a74b6808e1cebd6b5cda5a75
6
+ metadata.gz: bac8af3b8745b74e365b5f7aad70bc583e7a5c46f46465d89ddf61554295d666fea12f2b5718a639a38da2503ae03d5a6222862781f51ab941fbf85b93d29f39
7
+ data.tar.gz: 3c066d2d9dbece168030824d4df67639cce9bca8899eb8c95f99ac8219faf5f35960fedad5a2bb656b8e3387ac9b5905eedc93867c61dd2fda1611525c5259e5
data/docs/archimate.md CHANGED
@@ -44,8 +44,8 @@ ArchiMate is an open and independent enterprise architecture modeling language d
44
44
  | Relationship | Supported as |
45
45
  |--------------|--------------|
46
46
  | **Specialization** | `specializes` between technology elements of one kind (node, system software, service), see "Concept and Implementation" in the modeling guide |
47
- | **Composition** | `composedOf` between nodes and between system software |
48
- | **Aggregation** | `aggregates` between technology artifacts (an image contains packages), see "Deployment" in the modeling guide |
47
+ | **Composition** | `composedOf` between nodes and between system software; from a `Grouping` to resources of any kind |
48
+ | **Aggregation** | `aggregates` between technology artifacts (an image contains packages), see "Deployment" in the modeling guide; from a `Grouping` to resources of any kind |
49
49
  | **Assignment** | `assignedTo` from a node or system software to the technology artifacts deployed on it |
50
50
 
51
51
  ### Relationship Connectors
@@ -198,7 +198,8 @@ call-offs, SLAs and amendments, `stipulates` the requirements and constraints it
198
198
  | **Grouping** | Aggregates or composes concepts that belong together based on some common characteristic. |
199
199
  | **Location** | A conceptual or physical place or position where concepts are located (structure elements) or performed (behavior elements). |
200
200
 
201
- **Supported in archsight:** Location (`Location`) is modelled and shown under Other. Grouping is not.
201
+ **Supported in archsight:** Location (`Location`) and Grouping (`Grouping`) are modelled and shown under Other. A
202
+ grouping aggregates or composes resources of every kind, groupings included, see "Grouping" in the modeling guide.
202
203
 
203
204
  ## ArchiMate Layers
204
205
 
data/docs/diagram.md CHANGED
@@ -149,22 +149,29 @@ hint for near misses), never silently ignored.
149
149
  |---|---|---|
150
150
  | `label` | everything | any text (see *Label text*) |
151
151
  | `tint` | nodes, containers, edges | `gray`, `blue`, `indigo`, `purple`, `pink`, `red`, `orange`, `yellow`, `green`, `teal`, `cyan`, `brown` |
152
- | `link` | nodes, containers | `http(s)://…`, `mailto:…` or a relative URL |
153
- | `resource` | nodes, containers | a resource name (`Archsight:Web`) or `Kind/Name` (`ApplicationService/Archsight:Web`); see *Linking to resources* |
152
+ | `link` | nodes, containers, ports | `http(s)://…`, `mailto:…` or a relative URL |
153
+ | `resource` | nodes, containers, ports | a resource name (`Archsight:Web`) or `Kind/Name` (`ApplicationService/Archsight:Web`); see *Linking to resources* |
154
154
  | `extend` | nodes, containers | `true`, `false`; containers also `height`, and `width` on a direct child of a `layer` |
155
155
  | `width` | `text` | characters per line (positive integer); wraps the label |
156
- | `anchor` | containers | `top`, `bottom`, `left`, `right`, `center` |
156
+ | `anchor` | containers; leaves with `no-extend` | `top`, `bottom`, `left`, `right`, `center` |
157
+ | `badge` | nodes, ports | the id of a top-level `badge` definition (see *Badges and line styles*) |
158
+ | `legend` | nodes, containers | the text of the node's tint row in the legend (see *Legend*) |
159
+ | `align` | nodes, containers | `[edge] id` of another node to line up with, e.g. `top worker`; up to one horizontal and one vertical entry, comma-separated (see *Aligning across containers*) |
157
160
 
158
161
  `extend "height"` on a direct child of a `layer` grows it to its tallest sibling. Inside such a box (also through a `boundary` around a `stack`), a `stack` child carrying `extend "height"` takes the extra height and moves the ranks below it down, so e.g. a footer rank lines up across the columns. The child can be a `layer` too; its own `extend "height"` children then fill the layer's new height.
159
162
 
160
163
  `extend "width"` is the same for the other axis. When a `layer` is made wider than its content (for example it sits in a `stack` next to a wider sibling), its children normally stay together as one block placed by `anchor`. A direct child of the layer with `extend "width"` instead takes the spare width and pushes the siblings after it to the right edge, so `main` can sit at the left edge and `aside` at the right edge, and the `aside` columns line up across stacked layers. Several children with `extend "width"` share the spare width equally. The child's own content stays at its `anchor` (`left` by default) at its natural size. The attribute is an error anywhere but on a direct child of a `layer`; edges to boxes inside the pushed siblings follow their new positions.
161
164
 
162
165
  `anchor` says where a container's content sits when its box grows: `bottom` (or `top`) when it is made taller, `right` (or `left`) when it is made wider, `center` for the middle. Default: top for `extend "height"`, left for `extend "width"`, centered otherwise. It is not inherited, and has no effect on a box whose room is taken by a stack child with `extend "height"`.
166
+
167
+ `no-extend` on a leaf keeps it at its own size inside a wider `stack` (which otherwise stretches every rank to the widest one), centered there; `anchor "left"`/`"right"` puts it at that edge instead (an error without `no-extend`).
163
168
  | `shape` | leaves | `rectangle`, `circle`, `cylinder`, `pipe`, `actor`, `file`, `module` |
164
169
  | `gap` | containers | pixels (`40`), a percentage (`150%`) or a signed one (`+20%`, `-50%`) |
170
+ | `padding` | containers | the room between the box and its content, same values as `gap` (default: the theme's) |
165
171
  | `ranks` | containers | `auto`, `on`, `down`, `right`, `off` |
166
172
  | `columns` | containers | a positive integer |
167
173
  | `style` | edges | `straight`, `orthogonal` |
174
+ | `line` | edges | `solid` (default), `dashed`, `dotted`: the stroke only, the relation keeps its arrowhead |
168
175
  | `relation` | edges | `dependency`, `implements`, `control`, `data` |
169
176
  | `color` | dataflows | a hex color such as `#1a56db` |
170
177
 
@@ -182,8 +189,10 @@ empty id, and an edge from a node to itself are errors too.
182
189
  Any label anywhere (node, container, edge, dataflow) supports:
183
190
 
184
191
  - A small inline markdown-lite: `**bold**`, `*italic*`, `__underline__`,
185
- and `[text](url)` for a link on just that run of text (independent of
186
- a node-level `link` — a label can have both, or just one).
192
+ `` `code` `` (monospace, for commands, file names and ports), and
193
+ `[text](url)` for a link on just that run of text (independent of
194
+ a node-level `link` — a label can have both, or just one). Runs don't
195
+ nest: `` **`x`** `` shows the backticks.
187
196
  - Multi-line text, written either with an explicit `\n` escape
188
197
  (`label "Line one\nLine two"`) or by literally spanning multiple lines
189
198
  in the source; in the latter case each line's leading/trailing
@@ -214,6 +223,93 @@ Edge attributes:
214
223
  you pass `--relation=`, though layout always accounts for every edge
215
224
  regardless of what's shown.
216
225
 
226
+ ### Ports
227
+
228
+ A port is a small labelled tab on a leaf's border -- a TCP port, a socket,
229
+ a file a process listens on -- that edges attach to instead of the leaf as a
230
+ whole. Declare it inside the leaf and name it in an edge as `leaf.port`:
231
+
232
+ ```
233
+ component "mgr" {
234
+ label "**manager**"
235
+ port "tcp" { label "tcp :8075"; side "top" }
236
+ port "sock" { label "unix mgr.sock"; side "top"; badge "beta" }
237
+ }
238
+ client -> mgr.tcp { label "requests" }
239
+ agent -> mgr.sock
240
+ mgr.sock -> logger
241
+ ```
242
+
243
+ - `label` is drawn in monospace (default: the id), `side` is `top`,
244
+ `bottom`, `left` or `right`, `at` is `left`, `center`, `right` (`top`,
245
+ `center`, `bottom` on a left/right side) or a percentage of the side
246
+ (`25%`), and `badge` names a badge (see below).
247
+ - `link` and `resource` make the tab and its label a link, like on a node
248
+ (`port "api" { label "https"; resource "ApplicationInterface/Web:API" }`);
249
+ an unresolved `resource` draws the tab dashed with a tooltip, and
250
+ `archsight lint` reports it as `leaf.port`.
251
+ - Without `side`, the port goes on the side facing what its edges connect
252
+ it to (`top` without edges). Without `at`, it slides along its side to
253
+ line up with what its edges connect it to (the mean of their centers),
254
+ unless that spans the whole side; ports without a preference share the
255
+ side evenly in declaration order. Tabs on one side never overlap.
256
+ - The leaf grows to hold its tabs, and a `stack` leaves room between two
257
+ ranks for tabs sticking out of the sides they face.
258
+ - An edge to a port ends on the tab's outer side and never runs through
259
+ its own leaf; several edges on one tab are spread over it. Tabs are
260
+ obstacles to every other line, so no line ends on top of one.
261
+ - Ports need a box-shaped leaf (`rectangle`, `file`, `module` shapes). A
262
+ port id is local to its leaf and has no `.`. `leaf.port` resolves to a
263
+ node with that whole id first (ids of a namespaced include contain dots),
264
+ and an unknown port is an error listing the leaf's ports. Dataflow hops
265
+ name nodes, not ports.
266
+
267
+ ### Badges and line styles
268
+
269
+ Top-level definitions give the legend its text for a marker:
270
+
271
+ ```
272
+ badge "beta" { tint "orange"; label "beta channel only" }
273
+ line "dashed" { label "read only at start" }
274
+
275
+ component "agent" { badge "beta" }
276
+ config -> mgr { line "dashed"; label "read at start" }
277
+ ```
278
+
279
+ - `badge "id" { tint; label }` defines a dot that nodes and ports carry
280
+ with `badge "id"` (inside a node's top-right corner, at a port tab's right
281
+ end). Each badge used gets a legend row.
282
+ - `line "dashed" { label }` (or `"dotted"`) gives that line style its
283
+ legend row; without the definition, `line "dashed"` edges still draw
284
+ dashed but have no row. A diagram with ports gets a "Port" row.
285
+ - An included diagram's definitions count at the top level; the same
286
+ definition twice is fine, two different ones with one id are an error.
287
+ Inside a container-level include they are ignored with a warning.
288
+
289
+ ### Aligning across containers
290
+
291
+ `align "<edge> other"` moves a node (or container) until that edge of it
292
+ lines up with the same edge of `other`, which may sit in a different
293
+ container -- like the align buttons of a drawing editor:
294
+
295
+ | edge | lines up |
296
+ |---|---|
297
+ | `left`, `center`, `right` | the left edges, centers, right edges (horizontally) |
298
+ | `top`, `middle`, `bottom` | the top edges, centers, bottom edges (vertically) |
299
+
300
+ A bare id means `center` (`align "api"` puts a node under `api`).
301
+ One horizontal and one vertical entry can be combined with a comma:
302
+ `align "left db, top worker"`.
303
+
304
+ It only uses the room its container already has and never grows one.
305
+ Where the container packs along that axis (a `layer` for left/right, a
306
+ `stack` for up/down) the node's siblings keep their order and are pushed
307
+ along only when they would come closer than the sibling gap (plus half a
308
+ port tab on each facing side); elsewhere the node moves within its
309
+ container's inner box (an anonymous `layer`/`stack` lends it the room of
310
+ its own container on its packing axis). It stops as close as it gets. A
311
+ leaf a `stack` stretches has no room to move sideways; give it `no-extend`.
312
+
217
313
  ### Dataflows
218
314
 
219
315
  `dataflow "id" { hop "..."; hop "..."; ...; color "#hex"; label "..." }`
@@ -269,7 +365,12 @@ isn't affected.
269
365
  ### Legend
270
366
 
271
367
  A legend is added automatically, listing only the shapes, relations,
272
- boundary styles and dataflows actually used. It's left out entirely for a
368
+ boundary styles, dataflows, ports, badges and defined line styles actually used.
369
+ A tint set on a leaf gets a row named after the leaves carrying it (the first
370
+ line of each label, without markup, joined with commas), or by the `legend`
371
+ text of one of them; a tint whose leaves all sit inside a container of the
372
+ same tint gets none, the container's row explains it. A tinted container's
373
+ row reads `Boundary <label>` (or `Group <label>`), unless it has a `legend` text. It's left out entirely for a
273
374
  plain diagram of components and dependency edges.
274
375
 
275
376
  It's laid out like the rest of the drawing: a `layer` of `stack`s (its
data/docs/icons.md CHANGED
@@ -40,6 +40,7 @@ Current icon assignments for each resource type:
40
40
  | TechnologyDevice | `server` | <i class="iconoir-server"></i> |
41
41
  | TechnologyFacility | `building` | <i class="iconoir-building"></i> |
42
42
  | Location | `map-pin` | <i class="iconoir-map-pin"></i> |
43
+ | Grouping | `square-dashed` | <i class="iconoir-square-dashed"></i> |
43
44
  | TechnologyNode | `server-connection` | <i class="iconoir-server-connection"></i> |
44
45
  | StrategyCapability | `strategy` | <i class="iconoir-strategy"></i> |
45
46
  | TechnologyArtifact | `puzzle` | <i class="iconoir-puzzle"></i> |
data/docs/index.md.erb CHANGED
@@ -93,6 +93,7 @@ Resources representing technology infrastructure and artifacts.
93
93
  ### Other
94
94
 
95
95
  - [ComplianceEvidence](/doc/resources/compliance_evidence) - Evidence for compliance requirements
96
+ - [Grouping](/doc/resources/grouping) - Domains, scopes and families of resources of any kind
96
97
  - [Location](/doc/resources/location) - Countries, metros, regions and other places
97
98
  - [View](/doc/resources/view) - Saved queries and custom views
98
99
 
data/docs/modeling.md CHANGED
@@ -225,6 +225,8 @@ TechnologySystemSoftware, TechnologyService, TechnologyArtifact). The same princ
225
225
  (`connects`), never on the device, because a network is `realizedBy` its switches and the reverse arrow would
226
226
  close a cycle. A machine that reaches no network (air-gapped) has neither relation. Who uses it is the team or role
227
227
  (`servedBy`), not a person; groups of machines are tags and the end of support is `lifecycle/endOfLifeAt`.
228
+ 15. A virtual machine (`infrastructure/type: vm`) is `servedBy` the TechnologyService that hands out the VMs, which is
229
+ `suppliedBy` the hypervisor, which is `realizedBy` its hosts; see [Virtualization](#virtualization).
228
230
 
229
231
  **Checked by `archsight lint`**
230
232
 
@@ -240,6 +242,7 @@ As above, these are **warnings** in the "Modeling warnings" section and never fa
240
242
  | `TechnologyDevice 'Device:Switch01' is connectedTo itself` | 12 |
241
243
  | `TechnologyDevice 'Device:Router01' is a router that realizes no TechnologyCommunicationNetwork` | 11 |
242
244
  | `TechnologyDevice 'Device:a:server-3' is servedBy 'Kernel:Team', not by the team of its equipment ('Compute:Team')` | 13 |
245
+ | `TechnologyNode 'Node:Web:VMs' is a vm served by no technology service supplied by system software (its virtualization platform)` | 15 |
243
246
 
244
247
  Nested facilities need no location of their own (the outermost facility has it), and TechnologyEquipment that is part of other
245
248
  TechnologyEquipment, or composed of placed parts, needs no facility of its own. The same holds for a device inside a
@@ -736,6 +739,40 @@ favour of the relation, which the graph, views and analyses see; it still loads,
736
739
  as a deprecation without failing. See
737
740
  `examples/archsight/technology/payments-platform.yaml`.
738
741
 
742
+ ### Virtualization
743
+
744
+ A virtual machine runs on a virtualization platform, reached through the service that hands out the VMs. Every step is
745
+ written on the upper element and points down, like every relation:
746
+
747
+ ```
748
+ TechnologyNode (infrastructure/type: vm) the guests
749
+ ↓ servedBy
750
+ TechnologyService "virtual machines"
751
+ ↓ suppliedBy
752
+ TechnologySystemSoftware the hypervisor
753
+ ↓ realizedBy
754
+ TechnologyNode (infrastructure/type: bare-metal) the hosts
755
+ ```
756
+
757
+ | From | Verb | To |
758
+ |------|------|----|
759
+ | `TechnologyNode` (vm) | `servedBy` | `TechnologyService` (the service that provides the VM) |
760
+ | `TechnologyService` | `suppliedBy` | `TechnologySystemSoftware` (the hypervisor) |
761
+ | `TechnologySystemSoftware` | `realizedBy` | `TechnologyNode` (the hosts) |
762
+
763
+ - The service page lists the guests as incoming `servedBy`, the hosts' page the hypervisor as incoming `realizedBy`.
764
+ "What is affected if the hosts go away" is the impact analysis of the host node (incoming, depth 3).
765
+ - Not `composedOf`: the hosts' cluster consists of its hosts, not of the VMs that run on it. Not `realizedBy` between
766
+ the VM node and the host node either: realization goes across kinds (see [Concept and Implementation](#concept-and-implementation)).
767
+ - A VM virtualized on one machine (an isolated session of a hardened workstation) is `realizedBy` that
768
+ `TechnologyDevice` instead.
769
+ - Nested virtualization is the same chain again: the inner hypervisor is `realizedBy` the outer VM node.
770
+
771
+ `archsight lint` warns about a vm node that is neither `servedBy` a service with a `suppliedBy` nor `realizedBy` a
772
+ device. A chain that leads back to the VM is an error: through the chain alone (a hypervisor realized by its own
773
+ guest) it is a relation cycle, and mixed with `composedOf` or `aggregates` (a host cluster composed of a VM that runs
774
+ on it) it is a "cycle of virtualization and composition relations". See `examples/archsight/technology/platforms.yaml`.
775
+
739
776
  ### Concept and Implementation
740
777
 
741
778
  One technology *concept* often has several *implementations*: a "regional cluster" is implemented by a hypervisor
@@ -936,9 +973,10 @@ How to model it:
936
973
  - **Vulnerability scan.** One `MotivationAssessment` of type `vulnerability` per finding, `assesses` every node it was
937
974
  found on, `influences` the loss events and risks it makes possible. Business impact follows from the model: the node
938
975
  serves services, services serve processes.
939
- - **Grouping (risk domains).** ArchiMate has no domain element; set `risk/domain` (and `risk/category`: hazard,
976
+ - **Risk domains.** Set `risk/domain` (and `risk/category`: hazard,
940
977
  financial, operational, strategic, compliance, security) on events, assessments, drivers, requirements, controls and
941
- assets, and query or build a `View` per domain to see its threats, risks, measures and assets together.
978
+ assets, and query or build a `View` per domain to see its threats, risks, measures and assets together. A `Grouping`
979
+ is only worth it when the domain itself has an owner, a description or members that share no annotation.
942
980
  - **Policies.** The text of a policy is a `Page`; the structured statement (owner, validity, status, framework) is a
943
981
  `MotivationPrinciple` that links to the page with `[[Page]]`.
944
982
  - **Initial and residual risk.** Record both on the assessment (`risk/initial-*`, `risk/residual-*`) and the decision
@@ -975,6 +1013,37 @@ A ComplianceEvidence answers "how is the requirement met" in structured markdown
975
1013
  `evidence/verification`, `evidence/gaps` and `evidence/sources`. Because they are separate annotations they can be
976
1014
  queried, for example `ComplianceEvidence: evidence/gaps =~ "needs review"`.
977
1015
 
1016
+ ### Grouping
1017
+
1018
+ A `Grouping` gathers resources that belong together by a criterion that is not a place: a domain, the scope of a
1019
+ programme or review, a product family that spans layers. It holds resources of every kind, other groupings included, so
1020
+ groups nest. The members are listed on the grouping only, one key per kind under one of two verbs:
1021
+
1022
+ | Verb | Means | Example |
1023
+ |------|-------|---------|
1024
+ | `aggregates` | the member belongs to the group and stands on its own; it can be in several groups | a shared service in two domains |
1025
+ | `composedOf` | the member is a part of this whole and of no other | the components that exist only for the domain |
1026
+
1027
+ ```yaml
1028
+ kind: Grouping
1029
+ metadata:
1030
+ name: Domain:Payments
1031
+ spec:
1032
+ aggregates:
1033
+ strategyCapabilities: [Payment Processing]
1034
+ groupings: [Domain:Payments:Refunds]
1035
+ composedOf:
1036
+ applicationComponents: [Payments:API, CardVault:API]
1037
+ ```
1038
+
1039
+ A member's page lists its groups under Relations, and the MCP `summary` names them ("Groups" or "Part of"). Queries
1040
+ follow membership like any relation: `ApplicationComponent: <- Grouping` (in some group), `Grouping: -> "Payments:API"`.
1041
+ A grouping that contains itself through other groupings is a cycle that `archsight lint` reports.
1042
+
1043
+ Use a grouping when the set is a thing of its own (it has an owner, a description, a page). Resources that only share an
1044
+ attribute (a team, a tag, a risk domain) are found by a query or a `View`; a place is a `Location`; the wiki menu is a
1045
+ `PageMenu`.
1046
+
978
1047
  ### Derived References
979
1048
 
980
1049
  Text and diagrams already say which resources they are about, so archsight turns that into relations instead of asking you
@@ -24,15 +24,25 @@ module Archsight
24
24
  # container. Keep these tables in step with the readers in
25
25
  # `Graph::Node`/`Graph::Edge`/`Graph::DataFlow` and with `docs/diagram.md`.
26
26
  module Attributes
27
- NODE = %w[label tint link resource extend].freeze
27
+ NODE = %w[label tint link resource extend badge align legend].freeze
28
28
  LEAF_KINDS = %i[component application api database queue actor file text].freeze
29
- LEAF = (NODE + %w[shape]).freeze
29
+ # `anchor` places a leaf that keeps its own size (`extend "false"`) inside a wider stack.
30
+ LEAF = (NODE + %w[shape anchor]).freeze
30
31
  # A `text` has no box to restyle (no `shape`), but may wrap at `width` characters.
31
32
  TEXT = (NODE + %w[width]).freeze
32
33
  WIDTH_FORMAT = /\A[1-9]\d*\z/
33
- CONTAINER = (NODE + %w[gap ranks columns anchor]).freeze
34
- EDGE = %w[label style relation tint].freeze
34
+ CONTAINER = (NODE + %w[gap padding ranks columns anchor]).freeze
35
+ EDGE = %w[label style relation tint line].freeze
35
36
  DATAFLOW = %w[label color].freeze
37
+ PORT = %w[label side at badge link resource].freeze
38
+ BADGE_DEFINITION = %w[label tint].freeze
39
+ LINE_DEFINITION = %w[label].freeze
40
+
41
+ LINE_STYLES = %w[solid dashed dotted].freeze
42
+ PORT_SIDES = %w[top bottom left right].freeze
43
+ # A named spot on the port's side, or a percentage of its length (from the left or top).
44
+ PORT_AT = /\A(left|center|right|top|bottom|(100|[1-9]?\d)(\.\d+)?%)\z/
45
+ PORT_SHAPES = %w[rectangle file module].freeze
36
46
 
37
47
  EDGE_STYLES = %w[straight orthogonal].freeze
38
48
  LEAF_EXTEND = %w[true false].freeze
@@ -73,10 +83,55 @@ module Archsight
73
83
  when "style" then check_value!(key, value, EDGE_STYLES, where, ast_edge.line)
74
84
  when "relation" then check_value!(key, value, Relations.names, where, ast_edge.line)
75
85
  when "tint" then check_value!(key, value, Tints.names, where, ast_edge.line)
86
+ when "line" then check_value!(key, value, LINE_STYLES, where, ast_edge.line)
87
+ end
88
+ end
89
+ end
90
+
91
+ # A port's attrs, and that its leaf has a box shape to put a tab on.
92
+ def check_port!(ast_port, node)
93
+ where = "port #{ast_port.id.inspect} of #{node.kind} #{node.id.inspect}"
94
+ unless node.leaf? && node.kind != :text && PORT_SHAPES.include?(node.shape)
95
+ raise GraphError, "#{where} (line #{ast_port.line}): ports need a box-shaped leaf (shape #{PORT_SHAPES.join(", ")}), " \
96
+ "not #{node.kind == :text ? "a text" : "shape #{node.shape.inspect}"}"
97
+ end
98
+
99
+ ast_port.attrs.each do |key, value|
100
+ check_name!(key, PORT, where, ast_port.line)
101
+ case key
102
+ when "label" then check_label!(value, where, ast_port.line)
103
+ when "side" then check_value!(key, value, PORT_SIDES, where, ast_port.line)
104
+ when "at" then check_port_at!(value, ast_port.attrs["side"], where, ast_port.line)
105
+ when "link" then check_link!(value, where, ast_port.line)
106
+ when "resource" then check_resource!(value, ast_port.attrs, where, ast_port.line)
76
107
  end
77
108
  end
78
109
  end
79
110
 
111
+ def check_port_at!(value, side, where, line)
112
+ check_format!("at", value, PORT_AT, "left, center, right, top, bottom or a percentage (25%)", where, line)
113
+ along = side.nil? || %w[top bottom].include?(side) ? %w[left right] : %w[top bottom]
114
+ return unless (%w[left right top bottom] - along).include?(value)
115
+
116
+ raise GraphError, "at #{value.inspect} on #{where} (line #{line}) does not lie along its #{side || "top"} side; expected #{along.join(", ")}, center or a percentage"
117
+ end
118
+
119
+ # A top-level `badge`/`line` definition.
120
+ def check_definition!(definition)
121
+ where = "#{definition.kind} #{definition.id.inspect}"
122
+ allowed = definition.kind == :badge ? BADGE_DEFINITION : LINE_DEFINITION
123
+ if definition.kind == :line && !(LINE_STYLES - ["solid"]).include?(definition.id)
124
+ raise GraphError, "unknown line style #{definition.id.inspect} (line #{definition.line}); expected dashed or dotted" \
125
+ "#{suggestion(definition.id, LINE_STYLES - ["solid"])}"
126
+ end
127
+
128
+ definition.attrs.each do |key, value|
129
+ check_name!(key, allowed, where, definition.line)
130
+ check_label!(value, where, definition.line) if key == "label"
131
+ check_value!(key, value, Tints.names, where, definition.line) if key == "tint"
132
+ end
133
+ end
134
+
80
135
  # A dataflow's own attrs and each of its branches'.
81
136
  def check_dataflow!(ast_dataflow)
82
137
  where = "dataflow #{ast_dataflow.id.inspect}"
@@ -119,16 +174,16 @@ module Archsight
119
174
  def check_node_value!(key, value, block, where, ranks_modes)
120
175
  line = block.line
121
176
  case key
122
- when "label" then check_label!(value, where, line)
177
+ when "label", "legend" then check_label!(value, where, line)
123
178
  when "shape" then check_value!(key, value, Representers.names, where, line)
124
179
  when "tint" then check_value!(key, value, Tints.names, where, line)
125
180
  when "ranks" then check_value!(key, value, ranks_modes, where, line)
126
181
  when "extend" then check_value!(key, value, leaf?(block) ? LEAF_EXTEND : CONTAINER_EXTEND, where, line)
127
182
  when "anchor" then check_value!(key, value, ANCHORS, where, line)
128
- when "gap" then check_format!(key, value, GAP_FORMAT, "a pixel count (40), a percentage (150%) or a signed one (+20%, -50%)", where, line)
183
+ when "gap", "padding" then check_format!(key, value, GAP_FORMAT, "a pixel count (40), a percentage (150%) or a signed one (+20%, -50%)", where, line)
129
184
  when "width" then check_format!(key, value, WIDTH_FORMAT, "a positive number of characters per line", where, line)
130
185
  when "link" then check_link!(value, where, line)
131
- when "resource" then check_resource!(value, block, where, line)
186
+ when "resource" then check_resource!(value, block.attrs, where, line)
132
187
  end
133
188
  end
134
189
 
@@ -170,11 +225,11 @@ module Archsight
170
225
  end
171
226
 
172
227
  # Resolved against the resource database when rendering (see
173
- # `ResourceLinks`), which turns it into the node's `link`, so it
174
- # can't share a node with an explicit one.
175
- def check_resource!(value, block, where, line)
228
+ # `ResourceLinks`), which turns it into the node's/port's `link`, so it
229
+ # can't share one with an explicit one.
230
+ def check_resource!(value, attrs, where, line)
176
231
  check_format!("resource", value, RESOURCE_FORMAT, "a resource name (Archsight:Web) or Kind/Name (ApplicationService/Archsight:Web)", where, line)
177
- return unless block.attrs.key?("link")
232
+ return unless attrs.key?("link")
178
233
 
179
234
  raise GraphError, "#{where} (line #{line}) has both `link` and `resource`; a resource reference already provides the link"
180
235
  end
@@ -10,6 +10,9 @@ module Archsight
10
10
  raise GraphError, "#{block.kind} has an empty id (line #{block.line})" if block.id.strip.empty?
11
11
 
12
12
  Attributes.check_node!(block, ranks_modes: RANKS_MODES)
13
+ if Attributes.leaf?(block) && block.attrs.key?("anchor") && block.attrs["extend"] != "false"
14
+ raise GraphError, "anchor on #{block.kind} #{block.id.inspect} (line #{block.line}) only places a leaf that keeps its own size: add no-extend"
15
+ end
13
16
  raise GraphError, "extend \"width\" on #{block.kind} #{block.id.inspect} (line #{block.line}) only applies to a direct child of a layer" if block.attrs["extend"] == "width" && !parent&.layer?
14
17
 
15
18
  node = Node.for(id: block.id, kind: block.kind, attrs: block.attrs, children: [], parent: parent,
@@ -22,12 +25,82 @@ module Archsight
22
25
  node.children << build_node(child, node, raw_edges)
23
26
  when AST::Edge
24
27
  raw_edges << child
28
+ when AST::Port
29
+ add_port(node, child)
25
30
  end
26
31
  end
27
32
 
28
33
  node
29
34
  end
30
35
 
36
+ def add_port(node, ast_port)
37
+ Attributes.check_port!(ast_port, node)
38
+ if (first = node.port(ast_port.id))
39
+ raise GraphError, "duplicate port #{ast_port.id.inspect} on #{node.id.inspect} (line #{ast_port.line}, first defined at line #{first.line})"
40
+ end
41
+
42
+ node.ports << Port.new(id: ast_port.id, node: node, attrs: ast_port.attrs, line: ast_port.line)
43
+ end
44
+
45
+ # A top-level `badge "id" { ... }` / `line "dashed" { ... }`: each id once per kind.
46
+ def add_definition(ast_definition)
47
+ Attributes.check_definition!(ast_definition)
48
+ key = [ast_definition.kind, ast_definition.id]
49
+ if (first = @definitions[key])
50
+ return if first.attrs == ast_definition.attrs # the same definition, e.g. from two included diagrams
51
+
52
+ raise GraphError, "#{ast_definition.kind} #{ast_definition.id.inspect} already defined at line #{first.line} (line #{ast_definition.line})"
53
+ end
54
+
55
+ @definitions[key] = Definition.new(kind: ast_definition.kind, id: ast_definition.id, attrs: ast_definition.attrs, line: ast_definition.line)
56
+ end
57
+
58
+ # `badge "id"` on nodes and ports names a definition, `align "id"` another node.
59
+ def check_references!
60
+ @nodes_by_id.each_value do |node|
61
+ check_badge!(node.badge, "#{node.kind} #{node.id.inspect}", node.line) if node.badge
62
+ node.ports.each { |port| check_badge!(port.badge, "port #{port.ref.inspect}", port.line) if port.badge }
63
+ check_align!(node) if node.align
64
+ end
65
+ end
66
+
67
+ def check_badge!(id, where, line)
68
+ return if @definitions.key?([:badge, id])
69
+
70
+ known = @definitions.values.select { |d| d.kind == :badge }.map(&:id)
71
+ hint = known.empty? ? " (define it at the top level: badge #{id.inspect} { tint \"orange\"; label \"...\" })" : Attributes.suggestion(id, known)
72
+ raise GraphError, "unknown badge #{id.inspect} on #{where} (line #{line})#{hint}"
73
+ end
74
+
75
+ def check_align!(node)
76
+ where = "#{node.kind} #{node.id.inspect} (line #{node.line})"
77
+ entries = node.alignments
78
+ raise GraphError, "align #{node.align.inspect} on #{where} has an empty entry" if entries.any? { |_, _, id| id.empty? }
79
+
80
+ entries.group_by(&:first).each_value do |same_axis|
81
+ next if same_axis.length == 1
82
+
83
+ raise GraphError, "align #{node.align.inspect} on #{where} lines up #{same_axis.map { |_, e, _| e }.join(" and ")} on one axis; " \
84
+ "use one of left/center/right and one of top/middle/bottom"
85
+ end
86
+ entries.each { |_, _, id| check_align_target!(node, id, where) }
87
+ end
88
+
89
+ def check_align_target!(node, id, where)
90
+ target = @nodes_by_id[id]
91
+ unless target
92
+ word, rest = id.split(/\s+/, 2)
93
+ if rest
94
+ raise GraphError, "unknown edge #{word.inspect} in align #{node.align.inspect} on #{where}; expected one of " \
95
+ "#{Node::ALIGN_EDGES.keys.join(", ")}#{Attributes.suggestion(word, Node::ALIGN_EDGES.keys)}"
96
+ end
97
+ raise GraphError, "align #{node.align.inspect} on #{where} names no node #{id.inspect}#{Attributes.suggestion(id, @nodes_by_id.keys)}"
98
+ end
99
+ return unless target.ancestors.include?(node) || node.ancestors.include?(target)
100
+
101
+ raise GraphError, "align #{node.align.inspect} on #{where} names #{target == node ? "the node itself" : "a node it is nested with"}"
102
+ end
103
+
31
104
  # A top-level `theme "..."`/`legend "..."` statement: each may appear
32
105
  # once, with one of its own allowed values.
33
106
  def apply_setting(setting)
@@ -49,13 +122,38 @@ module Archsight
49
122
  end
50
123
 
51
124
  def resolve_edge(ast_edge)
52
- from = node(ast_edge.from)
53
- to = node(ast_edge.to)
54
- Edge.new(from: from, to: to, attrs: ast_edge.attrs, direction: ast_edge.direction, line: ast_edge.line)
125
+ from, from_port = endpoint(ast_edge.from)
126
+ to, to_port = endpoint(ast_edge.to)
127
+ raise GraphError, "connects #{from.id.inspect} to itself, which has no line to draw" if from == to
128
+
129
+ Edge.new(from: from, to: to, attrs: ast_edge.attrs, direction: ast_edge.direction, line: ast_edge.line,
130
+ from_port: from_port, to_port: to_port)
55
131
  rescue GraphError => e
56
132
  raise GraphError, "#{e.message} (edge at line #{ast_edge.line})"
57
133
  end
58
134
 
135
+ # An edge end: a node id, or `node.port` when no node has that whole id (namespaced ids contain dots too).
136
+ def endpoint(ref)
137
+ return [@nodes_by_id[ref], nil] if @nodes_by_id.key?(ref)
138
+
139
+ owner = port_owner(ref)
140
+ return [node(ref), nil] unless owner
141
+
142
+ port_id = ref.delete_prefix("#{owner.id}.")
143
+ port = owner.port(port_id)
144
+ return [owner, port] if port
145
+
146
+ known = owner.ports.map(&:id)
147
+ listed = known.empty? ? "it has no ports" : "its ports: #{known.join(", ")}"
148
+ raise GraphError, "unknown port #{port_id.inspect} on #{owner.id.inspect} (#{listed})#{Attributes.suggestion(port_id, known)}"
149
+ end
150
+
151
+ # The node `node.port` names, `nil` if the part before the last dot is no node
152
+ def port_owner(ref)
153
+ owner_id, dot, = ref.rpartition(".")
154
+ dot.empty? ? nil : @nodes_by_id[owner_id]
155
+ end
156
+
59
157
  def resolve_dataflow(ast_dataflow)
60
158
  group_index = ast_dataflow.hops.index { |h| h.is_a?(AST::DataFlowGroup) }
61
159
 
@@ -3,7 +3,8 @@
3
3
  module Archsight
4
4
  module Diagram
5
5
  class Graph
6
- Edge = Struct.new(:from, :to, :attrs, :direction, :line, keyword_init: true) do
6
+ # `from_port`/`to_port` are the `Graph::Port` an end attaches to (`a -> b.port`), `nil` for the node itself.
7
+ Edge = Struct.new(:from, :to, :attrs, :direction, :line, :from_port, :to_port, keyword_init: true) do
7
8
  def label
8
9
  attrs["label"]
9
10
  end
@@ -16,6 +17,11 @@ module Archsight
16
17
  attrs.fetch("relation", "dependency")
17
18
  end
18
19
 
20
+ # `solid` (the relation's own stroke), `dashed` or `dotted`.
21
+ def line_style
22
+ attrs.fetch("line", "solid")
23
+ end
24
+
19
25
  # The explicit `tint` attr, if any -- `nil` when unset, meaning
20
26
  # "use this relation's own fixed color" rather than falling back to
21
27
  # some default tint the way `Node#effective_tint` does (an edge
@@ -165,6 +165,30 @@ module Archsight
165
165
  attrs["link"]
166
166
  end
167
167
 
168
+ # The leaf's `port "id" { ... }` tabs, in declaration order (see `Graph::Port`).
169
+ def ports = (@ports ||= [])
170
+ def port(id) = ports.find { |p| p.id == id }
171
+
172
+ # The id of the top-level `badge` definition this node shows, if any.
173
+ def badge = attrs["badge"]
174
+
175
+ # The explicit text of this node's legend row (`legend "..."`), if any.
176
+ def legend_label = attrs["legend"]
177
+
178
+ # The raw `align` attr (see `Layout::Alignment`), if any.
179
+ def align = attrs["align"]
180
+
181
+ # `align "top a, left b"` as `[[axis, edge, id], ...]`; a bare id means `center`. The first word is an
182
+ # edge only when an id follows it, so a node named "top" can still be aligned to.
183
+ def alignments
184
+ return [] unless align
185
+
186
+ align.split(",").map(&:strip).map do |entry|
187
+ word, rest = entry.split(/\s+/, 2)
188
+ rest && Node::ALIGN_EDGES.key?(word) ? [Node::ALIGN_EDGES[word], word, rest.strip] : [:x, "center", entry]
189
+ end
190
+ end
191
+
168
192
  # Why this node's `resource` reference couldn't be resolved (see
169
193
  # `ResourceLinks`), or `nil` when it has none or it resolved.
170
194
  def broken_link
@@ -174,7 +198,8 @@ module Archsight
174
198
  # The padding and title band `Layout` reserves inside a container's
175
199
  # box -- none for an anonymous `layer`/`stack`, which never draws a
176
200
  # box of its own; `Legend::Frame` has its own fixed ones.
177
- def layout_padding(theme) = anonymous? ? 0.0 : theme.padding
201
+ # `padding` (same syntax as `gap`) overrides the theme's on a named container.
202
+ def layout_padding(theme) = anonymous? ? 0.0 : GapSpec.parse(attrs["padding"]).apply(theme.padding)
178
203
  def layout_title_height(theme) = anonymous? ? 0.0 : theme.title_height
179
204
 
180
205
  # See `Legend::Entry`, sized by `Layout` from its row instead of from
@@ -267,6 +292,9 @@ module Archsight
267
292
  def main_axis = Axis::HEIGHT
268
293
  end
269
294
 
295
+ # Which edge of another node an `align` entry lines a node up with, and on which axis.
296
+ Node::ALIGN_EDGES = { "left" => :x, "center" => :x, "right" => :x, "top" => :y, "middle" => :y, "bottom" => :y }.freeze
297
+
270
298
  Node::KIND_CLASSES = {
271
299
  component: Component, application: Application, api: Api, database: Database,
272
300
  queue: Queue, actor: Actor, file: FileNode, text: TextNode, group: Group, boundary: Boundary, layer: Layer, stack: Stack