|
| 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 | +``` |
0 commit comments