hierarchy: drop the unread Display for NodeId; pin a tail that leads into a broken cycle
Mutation pass: replacing == with != in the cycle walk survived; the new test kills it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9563694045
commit
3f7b2a0a68
1 changed files with 15 additions and 6 deletions
|
|
@ -41,12 +41,6 @@ const NODE_NAMESPACE: &str = "ghostlight.gestalt.node.v1";
|
|||
#[serde(transparent)]
|
||||
pub struct NodeId(Uuid);
|
||||
|
||||
impl std::fmt::Display for NodeId {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(formatter, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl NodeId {
|
||||
pub(crate) fn of(world: WorldId, anchor: &NodeAnchor) -> Self {
|
||||
Self(derive_uuid(
|
||||
|
|
@ -678,6 +672,21 @@ mod tests {
|
|||
assert_eq!(hierarchy.home[&high], inst(&hierarchy, &f.state, low));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_tail_leading_into_a_cycle_keeps_its_parent_when_the_cycle_breaks() {
|
||||
let mut f = Fixture::new();
|
||||
let tail = f.subject("Tail", SubjectKind::Institution, None);
|
||||
let one = f.subject("One", SubjectKind::Institution, None);
|
||||
let two = f.subject("Two", SubjectKind::Institution, None);
|
||||
f.grant(one, AuthorityTarget::Subject(tail));
|
||||
f.grant(one, AuthorityTarget::Subject(two));
|
||||
f.grant(two, AuthorityTarget::Subject(one));
|
||||
let hierarchy = derive_hierarchy(&f.state);
|
||||
assert_eq!(hierarchy.home[&tail], inst(&hierarchy, &f.state, one));
|
||||
assert_eq!(hierarchy.home[&one], hierarchy.root());
|
||||
assert_eq!(hierarchy.home[&two], inst(&hierarchy, &f.state, one));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_player_is_placed_and_never_a_voice() {
|
||||
let mut f = Fixture::new();
|
||||
|
|
|
|||
Loading…
Reference in a new issue