Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,13 @@
],

// Disable internal type checking, since we use basedpyright
"python.analysis.typeCheckingMode": "off"
"python.analysis.typeCheckingMode": "off",
"cSpell.words": [
"ASIL",
"FMEA",
"isopas",
"isosae",
"stkh",
"workproduct"
]
}
2 changes: 1 addition & 1 deletion src/extensions/score_metamodel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ score_py_pytest(
# All requirements already in the library so no need to have it double
data = ["//src:test_rst_files"] + glob(
["tests/**/*.rst"],
),
),args = ["-s", "-vv"],
deps = [":score_metamodel"],
)
5 changes: 3 additions & 2 deletions src/extensions/score_metamodel/checks/graph_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ def check_metamodel_graph(
# Convert list to dictionary for easy lookup
needs_dict_all = {need["id"]: need for need in all_needs.values()}
needs_local = list(all_needs.filter_is_external(False).values())

print("graph_checks_global:", graph_checks_global)
# Iterate over all graph checks
for check in graph_checks_global.items():
apply, eval = check[1].values()

print(f"Applying check: {check[0]} with apply: {apply} and eval: {eval}")
# Get all needs that match the selection criteria
selected_needs = get_need_selection(needs_local, apply, log)
print(f"Selected needs: {selected_needs}")

for need in selected_needs:
for parent_relation in list(eval.keys()):
Expand Down
131 changes: 110 additions & 21 deletions src/extensions/score_metamodel/metamodel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,74 @@ needs_types:
safety: ^(QM|ASIL_B|ASIL_D)$
status: ^(valid|invalid)$

# Safety Analysis DFA
feat_plat_saf_dfa:
title: DFA
prefix: feat_plat_saf_dfa__
mandatory_options:
verifies: ^feat_arc_sta__[0-9a-z_]*$
id: ^gd_guidl__dfa_failure_initiators__[0-9a-z_]*$
violation_id: ^.*$
violation_cause: ^.*$
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
mitigation_issue: ^https://github.com/.*$
sufficient: ^(yes|no)$
status: ^(valid|invalid)$

feat_saf_dfa:
title: DFA
prefix: feat_saf_dfa__
mandatory_options:
verifies: ^feat_arc_sta__[0-9a-z_]*$
id: ^feat_saf_dfa__[0-9a-z_]*$
violation_id: ^.*$
violation_cause: ^.*$
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
mitigation_issue: ^https://github.com/.*$
sufficient: ^(yes|no)$
status: ^(valid|invalid)$

comp_saf_dfa:
title: DFA
prefix: comp_saf_dfa__
mandatory_options:
verifies: ^comp_arc_sta__[0-9a-z_]*$
id: ^comp_saf_dfa__[0-9a-z_]*$
violation_id: ^.*$
violation_cause: ^.*$
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
mitigation_issue: ^https://github.com/.*$
sufficient: ^(yes|no)$
status: ^(valid|invalid)$

# Safety Analysis FMEA
feat_saf_fmea:
title: FMEA
prefix: feat_saf_fmea__
mandatory_options:
verifies: ^feat_arc_dyn__[0-9a-z_]*$
id: ^feat_saf_dfa__[0-9a-z_]*$
violation_id: ^.*$
violation_cause: ^.*$
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
mitigation_issue: ^https://github.com/.*$
sufficient: ^(yes|no)$
status: ^(valid|invalid)$

comp_saf_fmea:
title: FMEA
prefix: comp_saf_fmea__
mandatory_options:
verifies: ^comp_arc_dyn__[0-9a-z_]*$
id: ^comp_saf_dfa__[0-9a-z_]*$
violation_id: ^.*$
violation_cause: ^.*$
mitigation: ^(comp_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
mitigation_issue: ^https://github.com/.*$
sufficient: ^(yes|no)$
argument: ^.+$
status: ^(valid|invalid)$

Comment thread
PandaeDo marked this conversation as resolved.
Outdated
# Extra link types, which shall be available and allow need types to be linked to each other.
# We use a dedicated linked type for each type of a connection, for instance from
# a specification to a requirement. This makes filtering and visualization of such connections
Expand Down Expand Up @@ -576,6 +644,10 @@ needs_extra_links:
included_by:
incoming: includes
outgoing: included by

mitigates:
incoming: mitigates
outgoing: mitigated by
##############################################################
# Graph Checks
# The graph checks focus on the relation of the needs and their attributes.
Expand All @@ -594,36 +666,53 @@ needs_extra_links:
##############################################################
# req- Id: gd_req__req__linkage_architecture
# req- Id: gd_req__req__linkage_safety
graph_checks:
# req- Id: gd_req__req__linkage_safety
req_safety_linkage:
# If need-req is `QM`, parent must be `QM`.
req_safety_linkage_qm:
needs:
include: comp_req, feat_req
condition:
and:
- safety != QM
- status == valid
and:
- safety == QM
check:
satisfies:
and:
- safety != QM
- status == valid
req_linkage:
and:
- safety == QM
# If need-req is `ASIL_B`, parent must be `QM` or `ASIL_B`.
req_safety_linkage_asil_b:
needs:
include: comp_req, feat_req
condition: status == valid
condition:
and:
- safety == ASIL_B
check:
# req- Id: gd_req__req__linkage_architecture
satisfies: status == valid
arch_safety_linkage:
satisfies:
not:
- safety == ASIL_D
# If need-req is `ASIL_D`, parent can `QM`, `ASIL_B` or `ASIL_D`.
# req_safety_linkage_asil_d:
# needs:
# include: comp_req, feat_req
# condition:
# and:
# - safety == " "
# check:
# satisfies:
# and:
# - safety == ASIL_D

# saf - ID gd_req__saf_linkage_safety
# It shall be checked that Safety Analysis (DFA and FMEA) can only be linked via mitigate against
# - <Feature | Component | AoU> Requirements with the same ASIL or
# - <Feature | Component | AoU> Requirements with a higher ASIL
# as the corresponding ASIL of the Feature or Component that is analyzed.
saf_linkage_safety:
needs:
include: comp_req, feat_req
include: feat_saf_fmea, comp_saf_fmea, feat_plat_saf_dfa, feat_saf_dfa, comp_saf_dfa, aou_req
condition:
and:
- safety != QM
- status == valid
- safety == ASIL_B
check:
fulfils:
and:
- safety != QM
- status == valid
mitigates:
or:
- safety == ASIL_B
- safety == ASIL_D
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,95 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

#CHECK: check_metamodel_graph

.. feat_req:: Parent requirement
:id: feat_req__parent__abcd
Comment thread
PandaeDo marked this conversation as resolved.
Outdated
:safety: QM
:status: valid

.. Parent requirement has not the correct safety level
#EXPECT: feat_req__child__abce: parent need `feat_req__parent__abcd` does not fulfill condition `{'and': ['safety != QM', 'status == valid']}`.
.. Parent requirement has the correct safety level
#EXPECT-NOT: feat_req__child__abce: parent need `feat_req__parent__abcd` does not fulfill condition `{'and': ['safety == QM']}`.

.. feat_req:: Child requirement
:id: feat_req__child__abce
:safety: ASIL_B
:status: valid
:safety: QM
:satisfies: feat_req__parent__abcd
:status: valid

.. feat_req:: Parent requirement 2
:id: feat_req__parent2__abcd
:safety: ASIL_B
.. feat_req:: Parent requirement2
:id: feat_req__parent__abcd2
:safety: QM
:status: valid

.. Parent requirement has the correct safety level
#EXPECT-NOT: feat_req__child2__abce: parent need `feat_req__parent2__abcd` does not fulfill condition
#EXPECT-NOT: feat_req__child__abce2: parent need `feat_req__parent__abcd2` does not fulfill condition `{'and': ['safety == QM']}`.

.. feat_req:: Child requirement 2
:id: feat_req__child2__abce
.. feat_req:: Child requirement2
:id: feat_req__child__abce2
:safety: ASIL_B
:satisfies: feat_req__parent__abcd2
:status: valid
:satisfies: feat_req__parent__abcd

.. Parent requirement does not exist
#EXPECT: feat_req__child3__abce: Parent need `feat_req__parent0__abcd` not found in needs_dict.

.. feat_req:: Child requirement 3
:id: feat_req__child3__abce
.. feat_req:: Parent requirement3
:id: feat_req__parent3__abcd
:safety: ASIL_B
:status: valid
:satisfies: feat_req__parent0__abcd

.. feat_req:: Parent requirement 3
:id: feat_req__parent3__abcd
:status: invalid

.. Graph check without combined condition (no and or or)
#EXPECT: comp_req__parent4__abcd: parent need `feat_req__parent3__abcd` does not fulfill condition `status == valid`.
#EXPECT: feat_req__child__abce3: parent need `feat_req__parent3__abcd` does not fulfill condition `safety == QM`.

.. comp_req:: Child requirement 4
:id: comp_req__parent4__abcd
:status: valid
.. comp_req:: Child requirement3
:id: feat_req__child__abce3
:safety: QM
:satisfies: feat_req__parent3__abcd
:status: valid
















.. .. feat_req:: Parent requirement 2
.. :id: feat_req__parent2__abcd
.. :safety: QM

.. .. Parent requirement has the correct safety level
.. #EXPECT-NOT: feat_req__child2__abce: parent need `feat_req__parent2__abcd` does not fulfill condition

.. .. feat_req:: Child requirement 2
.. :id: feat_req__child2__abce
.. :safety: QM
.. :satisfies: feat_req__parent2__abcd

.. .. Parent requirement does not exist
.. #EXPECT: feat_req__child3__abce: Parent need `feat_req__parent0__abcd` not found in needs_dict.

.. .. feat_req:: Child requirement 3
.. :id: feat_req__child3__abce
.. :safety: ASIL_B
.. :status: valid
.. :satisfies: feat_req__parent0__abcd

.. .. feat_req:: Parent requirement 3
.. :id: feat_req__parent3__abcd
.. :status: invalid

.. .. Graph check without combined condition (no and or or)
.. #EXPECT: comp_req__parent4__abcd: parent need `feat_req__parent3__abcd` does not fulfill condition `status == valid`.

.. .. comp_req:: Child requirement 4
.. :id: comp_req__parent4__abcd
.. :status: valid
.. :satisfies: feat_req__parent3__abcd
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_rst_files(

# Collect the warnings
warnings = app.warning.getvalue().splitlines()
# print(f"Warnings: {warnings}")
print(f"Warnings: {warnings}")

# Check if the expected warnings are present
for warning_info in rst_data.warning_infos:
Expand Down
Loading