fix(simulation): validate dangling with_role in TriangleDef constraints
TriangleDef.validate() now rejects relationship constraints where with_role references a role not in the triangle's three roles. Catches authoring errors at load time instead of silently producing broken constraint data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -430,6 +430,7 @@ impl TriangleDef {
|
||||
));
|
||||
}
|
||||
|
||||
let role_set: std::collections::BTreeSet<&RoleId> = self.roles.iter().collect();
|
||||
for (i, constraint) in self.relationship_constraints.iter().enumerate() {
|
||||
if constraint.required_trust.min > constraint.required_trust.max {
|
||||
return Err(format!(
|
||||
@@ -437,6 +438,12 @@ impl TriangleDef {
|
||||
i, constraint.required_trust.min, constraint.required_trust.max
|
||||
));
|
||||
}
|
||||
if !role_set.contains(&constraint.with_role) {
|
||||
return Err(format!(
|
||||
"relationship_constraints[{}]: with_role '{}' not in triangle roles",
|
||||
i, constraint.with_role.0
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user