From 3f7b2a0a68c04622e49179d78b44af5c43746657 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 06:32:40 +0100 Subject: [PATCH] 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 --- crates/ghostlight/src/hierarchy.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/ghostlight/src/hierarchy.rs b/crates/ghostlight/src/hierarchy.rs index 2a8fa9c..48002bb 100644 --- a/crates/ghostlight/src/hierarchy.rs +++ b/crates/ghostlight/src/hierarchy.rs @@ -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();