Skip to content

Commit c8243b0

Browse files
xiangu-batwhoe-jo
authored andcommitted
add validation specification
1 parent a41ef0d commit c8243b0

2 files changed

Lines changed: 181 additions & 0 deletions

File tree

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<!-- ----------------------------------------------------------------------------
2+
Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
4+
See the NOTICE file(s) distributed with this work for additional
5+
information regarding copyright ownership.
6+
7+
This program and the accompanying materials are made available under the
8+
terms of the Apache License Version 2.0 which is available at
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
SPDX-License-Identifier: Apache-2.0
12+
----------------------------------------------------------------------------- -->
13+
14+
# Bazel Component Specification
15+
16+
## Purpose
17+
18+
Define the consistency rules between the indexed Bazel architecture and the
19+
indexed PlantUML component diagram.
20+
21+
This validator checks whether the same SEooC packages, components, and units
22+
exist on both sides after model normalization.
23+
24+
## What is Validated
25+
26+
A dependable element must be defined both in Bazel and in PlantUML. The validator checks:
27+
28+
- top-level dependable element: PlantUML `package <<SEooC>>` vs. Bazel dependable element
29+
- names: PlantUML `alias` when present, otherwise `id` vs. Bazel target name
30+
- components: PlantUML `<<component>>` vs. Bazel component under the expected parent
31+
- units: PlantUML `<<unit>>` vs. Bazel unit under the expected component
32+
- parent context must match
33+
- matching is case-insensitive
34+
35+
In the common case, components nested directly under the dependable element use
36+
the dependable element alias as parent. More deeply nested components use their
37+
immediate enclosing component alias as parent.
38+
39+
## Failure Cases
40+
41+
### Missing in PlantUML
42+
43+
Validation fails when Bazel defines a dependable element, component, or unit
44+
that is not present in the PlantUML diagram.
45+
46+
This includes cases where the name exists in PlantUML but under the wrong
47+
parent, or with the wrong stereotype.
48+
49+
### Extra in PlantUML
50+
51+
Validation fails when PlantUML contains a dependable element, component, or
52+
unit that does not have a corresponding definition in Bazel.
53+
54+
This ensures the diagram does not introduce additional structure beyond what is
55+
declared in the Bazel architecture.
56+
57+
## Debug Output
58+
59+
The validator appends a debug log containing:
60+
61+
- all diagram entities
62+
- filtered entity counts
63+
- all normalized PlantUML keys
64+
- all normalized Bazel keys
65+
66+
## Example
67+
68+
In Bazel BUILD files, the same structure can be declared like this:
69+
70+
```starlark
71+
component(
72+
name = "component_example",
73+
components = [
74+
"//bazel/rules/rules_score/examples/seooc/unit_1:unit_1",
75+
"//bazel/rules/rules_score/examples/seooc/unit_2:unit_2",
76+
],
77+
)
78+
79+
dependable_element(
80+
name = "safety_software_seooc_example",
81+
components = [":component_example"],
82+
)
83+
84+
unit(
85+
name = "unit_1",
86+
)
87+
88+
unit(
89+
name = "unit_2",
90+
)
91+
```
92+
93+
When exported into the indexed Bazel architecture, these targets produce keys such as:
94+
95+
If the Bazel architecture JSON contains:
96+
97+
- dependable element: `safety_software_seooc_example` -> key: `("safety_software_seooc_example", None)`
98+
- component: `@//bazel/rules/rules_score/examples/seooc:component_example` -> key: `("component_example", Some("safety_software_seooc_example"))`
99+
- unit: `@//bazel/rules/rules_score/examples/seooc/unit_1:unit_1` -> key: `("unit_1", Some("component_example"))`
100+
- unit: `@//bazel/rules/rules_score/examples/seooc/unit_2:unit_2` -> key: `("unit_2", Some("component_example"))`
101+
102+
then PlantUML must contain entities with the same normalized keys:
103+
104+
```plantuml
105+
package "Sample Seooc" as safety_software_seooc_example <<SEooC>> {
106+
component "Component Example" as component_example <<component>> {
107+
component "Unit 1" as unit_1 <<unit>>
108+
component "Unit 2" as unit_2 <<unit>>
109+
}
110+
}
111+
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!-- ----------------------------------------------------------------------------
2+
Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
4+
See the NOTICE file(s) distributed with this work for additional
5+
information regarding copyright ownership.
6+
7+
This program and the accompanying materials are made available under the
8+
terms of the Apache License Version 2.0 which is available at
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
SPDX-License-Identifier: Apache-2.0
12+
----------------------------------------------------------------------------- -->
13+
14+
# Component Sequence Specification
15+
16+
## Purpose
17+
18+
Define the intended consistency rules between component-diagram units and the
19+
participants observed in sequence diagrams.
20+
21+
This validator checks whether unit aliases from component diagrams match the
22+
set of used participants collected from sequence diagrams.
23+
24+
## What is Validated
25+
26+
Component-diagram units and sequence-diagram participants must match. The validator checks:
27+
28+
- unit aliases from the component diagram vs. participant aliases used in sequence diagrams
29+
- matching is case-sensitive
30+
31+
## Failure Cases
32+
33+
### Missing sequence participant
34+
35+
Validation fails when a unit alias defined in the component diagram does not
36+
appear among the participants used in the sequence diagrams.
37+
38+
### Unexpected sequence participant
39+
40+
Validation fails when a sequence diagram uses a participant alias that does not
41+
correspond to any unit alias declared in the component diagram.
42+
43+
## Debug Output
44+
45+
The validator emits a debug view containing:
46+
47+
- expected unit aliases
48+
- observed caller/callee participants
49+
50+
## Example
51+
52+
If the component diagram defines the unit aliases `unit_1` and `unit_2`, then
53+
the sequence diagrams must use the same participant aliases.
54+
55+
```plantuml
56+
' component diagram
57+
package "Package A" as package_a <<SEooC>> {
58+
component "Component A" as component_a <<component>> {
59+
component "Unit 1" as unit_1 <<unit>>
60+
component "Unit 2" as unit_2 <<unit>>
61+
}
62+
}
63+
64+
' sequence diagram
65+
participant "Unit 1" as unit_1
66+
participant "Unit 2" as unit_2
67+
68+
unit_1 -> unit_2 : SendSignal
69+
unit_2 --> unit_1 : Ack
70+
```

0 commit comments

Comments
 (0)