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

Function build_decision_edges

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

Build edges connecting a decision node to the surrounding context. The decision node gets: - An edge from the most recent goal (if any precedes the sequence) - An edge to the next structural node after the sequence (if any)

(nodes: &[GraphNode], seq: &[usize], decision_id: &str)

Source from the content-addressed store, hash-verified

674/// - An edge from the most recent goal (if any precedes the sequence)
675/// - An edge to the next structural node after the sequence (if any)
676fn build_decision_edges(nodes: &[GraphNode], seq: &[usize], decision_id: &str) -> Vec<GraphEdge> {
677 let mut edges = Vec::new();
678
679 let first_idx = match seq.first() {
680 Some(&i) => i,
681 None => return edges,
682 };
683
684 // Find the most recent goal before this sequence
685 for i in (0..first_idx).rev() {
686 if nodes[i].kind == NodeKind::Goal {
687 edges.push(GraphEdge::new(
688 nodes[i].id.clone(),
689 decision_id.to_string(),
690 EdgeKind::LedTo,
691 ));
692 break;
693 }
694 }
695
696 // Find the next patch proposal after this sequence to link to
697 let last_idx = seq.last().copied().unwrap_or(first_idx);
698 for node in nodes.iter().skip(last_idx + 1) {
699 if node.kind == NodeKind::PatchProposal {
700 edges.push(GraphEdge::new(
701 decision_id.to_string(),
702 node.id.clone(),
703 EdgeKind::CommittedVia,
704 ));
705 break;
706 }
707 }
708
709 edges
710}
711
712/// Generate the next node ID.
713fn next_id(counter: &mut u64, prefix: &str) -> String {

Callers 6

detect_backtrackingFunction · 0.85
detect_full_cycleFunction · 0.85
detect_commit_and_verifyFunction · 0.85
detect_informed_commitFunction · 0.85

Calls 5

lastMethod · 0.80
skipMethod · 0.80
pushMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected