Skip to content

Commit 07a1c6c

Browse files
committed
Use shared CEDV object loader in relation checker
1 parent 0e6293c commit 07a1c6c

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

scripts/check_cedv_relation_basis_validation.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
if str(ROOT) not in sys.path:
1111
sys.path.insert(0, str(ROOT))
1212

13+
from scripts.lib.cedv_objects import load_cedv_objects # noqa: E402
1314
from scripts.lib.protocol_constants import ( # noqa: E402
1415
CANONICAL_RELATION_TYPES,
1516
CEDV_ID_PREFIX_TO_OBJECT_TYPE,
@@ -20,7 +21,6 @@
2021
relation_allowed_by_matrix,
2122
validate_relation_matrix,
2223
)
23-
from scripts.lib.simple_yaml import parse_simple_yaml # noqa: E402
2424

2525
BASE = ROOT / 'protocol' / 'cedv'
2626
DOC = BASE / 'relation-basis-validation-v1.md'
@@ -75,27 +75,14 @@ def main() -> int:
7575
relation_matrix = load_relation_matrix(RELATION_MATRIX)
7676
errors.extend(validate_relation_matrix(relation_matrix))
7777

78-
objects: dict[str, dict] = {}
79-
for filename in REQ_EXAMPLES:
80-
text = read(EXAMPLES / filename, errors)
81-
if not text:
82-
continue
83-
obj = parse_simple_yaml(text)
84-
object_id = obj.get('id')
85-
if not isinstance(object_id, str):
86-
errors.append(f'{filename} missing id')
87-
continue
88-
if object_id in objects:
89-
errors.append(f'duplicate object id: {object_id}')
90-
objects[object_id] = obj
78+
objects = load_cedv_objects((EXAMPLES / filename for filename in REQ_EXAMPLES), errors, ROOT)
9179

9280
for object_id, obj in objects.items():
9381
source_type = obj.get('object_type')
9482
if not isinstance(source_type, str):
9583
errors.append(f'{object_id} missing object_type')
9684
continue
9785
if source_type not in CEDV_OBJECT_TYPES:
98-
errors.append(f'{object_id} object_type is not a shared CEDV type: {source_type}')
9986
continue
10087
links = obj.get('links')
10188
if not isinstance(links, list):
@@ -143,7 +130,7 @@ def main() -> int:
143130
print('- CEDV link targets and basis_refs resolve')
144131
print('- relation source/target families are admissible through relation-admissibility-matrix-v1.json')
145132
print('- shared CEDV prefix and object-type constants are used by this checker')
146-
print('- shared simple YAML parser is used by this checker')
133+
print('- shared CEDV object loader is used by this checker')
147134
print('- evidence, dissent, and verdict objects do not float free')
148135
return 0
149136

0 commit comments

Comments
 (0)