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<String> that nothing observes.
This commit is contained in:
Dark-Alex-17 committed 2026-09-11 10:56:27 -06:00
1 parent 69a3d928ee
commit 8f9284cb92
1 file changed
+4
+4
View File
@@ -499,6 +499,8 @@ pub enum Reducer {
#[derive(Debug, Clone, Default)]
pub struct GraphState {
data: HashMap<String, Value>,
/// Ordered visit log, kept for test assertions only.
#[cfg(test)]
history: Vec<String>,
loop_counts: HashMap<String, usize>,
}
@@ -507,6 +509,7 @@ impl GraphState {
pub fn new(initial: HashMap<String, Value>) -> 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;
}