Skip to content

Commit dc24550

Browse files
committed
Use shared CEDV prefix constants in relation checker
1 parent 886a497 commit dc24550

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

scripts/check_cedv_relation_basis_validation.py

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

13-
from scripts.lib.protocol_constants import CANONICAL_RELATION_TYPES # noqa: E402
13+
from scripts.lib.protocol_constants import ( # noqa: E402
14+
CANONICAL_RELATION_TYPES,
15+
CEDV_ID_PREFIX_TO_OBJECT_TYPE,
16+
CEDV_OBJECT_TYPES,
17+
)
1418

1519
BASE = ROOT / 'protocol' / 'cedv'
1620
DOC = BASE / 'relation-basis-validation-v1.md'
@@ -88,14 +92,9 @@ def parse_simple_yaml(text: str) -> dict:
8892

8993

9094
def object_family(object_id: str) -> str | None:
91-
if object_id.startswith('C-'):
92-
return 'claim'
93-
if object_id.startswith('E-'):
94-
return 'evidence'
95-
if object_id.startswith('D-'):
96-
return 'dissent'
97-
if object_id.startswith('V-'):
98-
return 'verdict'
95+
for prefix, object_type in CEDV_ID_PREFIX_TO_OBJECT_TYPE.items():
96+
if object_id.startswith(prefix):
97+
return object_type
9998
return None
10099

101100

@@ -112,9 +111,9 @@ def relation_allowed(source_type: str, rel: str, target: str) -> bool:
112111
if source_type == 'evidence':
113112
return rel in {'supports', 'challenges'} and target_type in {'claim', 'verdict'}
114113
if source_type == 'dissent':
115-
return rel == 'challenges' and target_type in {'claim', 'evidence', 'dissent', 'verdict'}
114+
return rel == 'challenges' and target_type in CEDV_OBJECT_TYPES
116115
if source_type == 'verdict':
117-
return (rel == 'depends_on' and target_type in {'claim', 'evidence', 'dissent', 'verdict'}) or (rel == 'supersedes' and target_type == 'verdict')
116+
return (rel == 'depends_on' and target_type in CEDV_OBJECT_TYPES) or (rel == 'supersedes' and target_type == 'verdict')
118117
return False
119118

120119

@@ -144,6 +143,9 @@ def main() -> int:
144143
if not isinstance(source_type, str):
145144
errors.append(f'{object_id} missing object_type')
146145
continue
146+
if source_type not in CEDV_OBJECT_TYPES:
147+
errors.append(f'{object_id} object_type is not a shared CEDV type: {source_type}')
148+
continue
147149
links = obj.get('links')
148150
if not isinstance(links, list):
149151
errors.append(f'{object_id} links must be a list')
@@ -188,6 +190,7 @@ def main() -> int:
188190
print('- object ids are unique')
189191
print('- CEDV link targets and basis_refs resolve')
190192
print('- relation source/target families are admissible')
193+
print('- shared CEDV prefix and object-type constants are used by this checker')
191194
print('- evidence, dissent, and verdict objects do not float free')
192195
return 0
193196

0 commit comments

Comments
 (0)