From 8f9284cb92c2e45c129a2945e0a0e8249f2be616 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Thu, 10 Sep 2026 15:40:00 -0600 Subject: [PATCH] refactor(graph): keep the ordered visit log test-only GraphState.history was pushed to on every node visit and deep-cloned on every super-step snapshot and map fork, but its only reader is the cfg(test) current_node accessor. Gate the field, its initializer, and the push behind cfg(test) so production builds no longer carry an unbounded Vec that nothing observes. --- src/graph/types.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/graph/types.rs b/src/graph/types.rs index 3b36c6e..af4f2e8 100644 --- a/src/graph/types.rs +++ b/src/graph/types.rs @@ -499,6 +499,8 @@ pub enum Reducer { #[derive(Debug, Clone, Default)] pub struct GraphState { data: HashMap, + /// Ordered visit log, kept for test assertions only. + #[cfg(test)] history: Vec, loop_counts: HashMap, } @@ -507,6 +509,7 @@ impl GraphState { pub fn new(initial: HashMap) -> Self { Self { data: initial, + #[cfg(test)] history: Vec::new(), loop_counts: HashMap::new(), } @@ -535,6 +538,7 @@ impl GraphState { } pub fn visit_node(&mut self, node_id: &str) { + #[cfg(test)] self.history.push(node_id.to_string()); *self.loop_counts.entry(node_id.to_string()).or_insert(0) += 1; }