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

Function detect_full_cycle

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

Detect full cycle: explore → commit → verify. The agent reads files, makes a change, then validates it.

(
    nodes: &[GraphNode],
    seq: &[usize],
    counter: &mut u64,
    prefix: &str,
)

Source from the content-addressed store, hash-verified

343///
344/// The agent reads files, makes a change, then validates it.
345fn detect_full_cycle(
346 nodes: &[GraphNode],
347 seq: &[usize],
348 counter: &mut u64,
349 prefix: &str,
350) -> Option<(GraphNode, Vec<GraphEdge>)> {
351 let mut has_exploration = false;
352 let mut has_commitment = false;
353 let mut has_verification = false;
354 let mut committed_file = None;
355 let mut verify_cmd = None;
356
357 for &idx in seq {
358 let node = &nodes[idx];
359 match node.kind {
360 NodeKind::Exploration => has_exploration = true,
361 NodeKind::Commitment => {
362 has_commitment = true;
363 if committed_file.is_none() {
364 committed_file = extract_file(node);
365 }
366 }
367 NodeKind::Verification => {
368 has_verification = true;
369 if verify_cmd.is_none() {
370 verify_cmd = extract_command(node);
371 }
372 }
373 _ => {}
374 }
375 }
376
377 if !(has_exploration && has_commitment && has_verification) {
378 return None;
379 }
380
381 let file_display = committed_file
382 .as_deref()
383 .map(short_path)
384 .unwrap_or_else(|| "file".to_string());
385
386 let cmd_display = verify_cmd
387 .as_deref()
388 .map(|c| truncate(c, 40))
389 .unwrap_or_else(|| "tests".to_string());
390
391 let exploration_count = seq
392 .iter()
393 .filter(|&&i| nodes[i].kind == NodeKind::Exploration)
394 .count();
395
396 let summary = format!(
397 "Investigated ({} files) → fixed {} → verified with {}",
398 exploration_count, file_display, cmd_display
399 );
400
401 let consolidated_ids: Vec<String> = seq.iter().map(|&i| nodes[i].id.clone()).collect();
402

Callers 1

consolidateFunction · 0.85

Calls 11

extract_fileFunction · 0.85
truncateFunction · 0.85
build_decision_edgesFunction · 0.85
is_noneMethod · 0.80
lastMethod · 0.80
with_detailMethod · 0.80
extract_commandFunction · 0.70
next_idFunction · 0.70
countMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected