(graph: &Graph, details: bool)
| 193 | } |
| 194 | |
| 195 | fn render_tree(graph: &Graph, details: bool) -> String { |
| 196 | use std::collections::BTreeMap; |
| 197 | |
| 198 | let root = graph.nodes.iter().find(|node| node.id == graph.root); |
| 199 | let mut out = match root { |
| 200 | Some(node) => { |
| 201 | let key = metadata_text(node, "human_key"); |
| 202 | let label = tree_label(node); |
| 203 | format!( |
| 204 | "Intent{} — {label}\n", |
| 205 | key.map(|s| format!(" {s}")).unwrap_or_default() |
| 206 | ) |
| 207 | } |
| 208 | None => "Intent [root missing]\n".into(), |
| 209 | }; |
| 210 | out.push_str(&format!( |
| 211 | "{} nodes · {} implementing · {} recording · {} dependency-only{}\n", |
| 212 | graph.nodes.len(), |
| 213 | graph.implementing_changes.len(), |
| 214 | graph.recording_changes.len(), |
| 215 | graph.dependency_changes.len(), |
| 216 | if graph.truncated { |
| 217 | " · [TRUNCATED]" |
| 218 | } else { |
| 219 | "" |
| 220 | }, |
| 221 | )); |
| 222 | |
| 223 | // These are presentation groups, not newly asserted graph edges. Each |
| 224 | // selected node appears once, even when it has multiple incoming edges. |
| 225 | let mut groups: BTreeMap<(u8, String), Vec<&atomic_core::KgNode>> = BTreeMap::new(); |
| 226 | for node in graph.nodes.iter().filter(|node| node.id != graph.root) { |
| 227 | let group = if graph.implementing_changes.contains(&node.id) { |
| 228 | (0, "Implementing changes".into()) |
| 229 | } else if graph.recording_changes.contains(&node.id) { |
| 230 | (1, "Intent recording evidence (not implementation)".into()) |
| 231 | } else if graph.dependency_changes.contains(&node.id) { |
| 232 | (2, "Dependency-only changes".into()) |
| 233 | } else if graph.intent_artifact.as_ref() == Some(&node.id) { |
| 234 | (3, "Intent artifact".into()) |
| 235 | } else if node.has_type(Class::Task) { |
| 236 | (4, "Tasks".into()) |
| 237 | } else if node.has_type(Class::AcceptanceCriterion) { |
| 238 | (5, "Acceptance criteria".into()) |
| 239 | } else if node.has_type(Class::ScopeItem) { |
| 240 | (6, "Scope".into()) |
| 241 | } else if node.has_type(Class::Constraint) { |
| 242 | (7, "Constraints".into()) |
| 243 | } else if node.has_type(Class::File) { |
| 244 | (8, "Files".into()) |
| 245 | } else { |
| 246 | ( |
| 247 | 9, |
| 248 | compact(node.primary_type()) |
| 249 | .trim_start_matches("atomic:") |
| 250 | .to_owned(), |
| 251 | ) |
| 252 | }; |
no test coverage detected