MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / find_sequences

Function find_sequences

atomic-agent/src/provenance/consolidate.rs:127–182  ·  view source on GitHub ↗

Indices of unclassified tool-derived nodes grouped into sequences separated by structural boundaries (goals, patches, human gates, errors).

(nodes: &[GraphNode])

Source from the content-addressed store, hash-verified

125/// Indices of unclassified tool-derived nodes grouped into sequences
126/// separated by structural boundaries (goals, patches, human gates, errors).
127fn find_sequences(nodes: &[GraphNode]) -> Vec<Vec<usize>> {
128 let mut sequences = Vec::new();
129 let mut current = Vec::new();
130
131 for (i, node) in nodes.iter().enumerate() {
132 if node.classified {
133 if current.len() >= 2 {
134 sequences.push(std::mem::take(&mut current));
135 } else {
136 current.clear();
137 }
138 continue;
139 }
140
141 match node.kind {
142 // Structural boundaries break sequences
143 NodeKind::Goal
144 | NodeKind::PatchProposal
145 | NodeKind::HumanGate
146 | NodeKind::Todo
147 | NodeKind::TodoStatusChange
148 | NodeKind::PhaseTransition
149 | NodeKind::Lesson
150 | NodeKind::LlmResponse
151 | NodeKind::HumanGateResolution => {
152 if current.len() >= 2 {
153 sequences.push(std::mem::take(&mut current));
154 } else {
155 current.clear();
156 }
157 }
158 // Decision nodes are already consolidated
159 NodeKind::Decision => {
160 if current.len() >= 2 {
161 sequences.push(std::mem::take(&mut current));
162 } else {
163 current.clear();
164 }
165 }
166 // Tool-derived nodes accumulate into the current sequence
167 NodeKind::Exploration
168 | NodeKind::Commitment
169 | NodeKind::Verification
170 | NodeKind::Execution
171 | NodeKind::Error => {
172 current.push(i);
173 }
174 }
175 }
176
177 if current.len() >= 2 {
178 sequences.push(current);
179 }
180
181 sequences
182}
183
184// =============================================================================

Calls 4

clearMethod · 0.65
iterMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45