Output the content of an alive graph to a span buffer. This function traverses the graph in SCC order (as computed by [`compute_order`](crate::output::alive::compute_order)) and writes each span's content to the buffer. Conflicts are handled by: - **Cyclic conflicts**: Multi-span SCCs are output with conflict markers - **Zombie content**: Deleted vertices with live edges get zombie markers # Ar
(
changes: &C,
hash_fn: F,
graph: &AliveGraph,
order: &OrderResult,
buffer: &mut V,
)
| 187 | /// 3. For zombie vertices: wrap in zombie conflict markers |
| 188 | /// 4. Track and report any content retrieval errors |
| 189 | pub fn output_graph_content<C, F, V>( |
| 190 | changes: &C, |
| 191 | hash_fn: F, |
| 192 | graph: &AliveGraph, |
| 193 | order: &OrderResult, |
| 194 | buffer: &mut V, |
| 195 | ) -> OutputResult<()> |
| 196 | where |
| 197 | C: ChangeStore, |
| 198 | F: Fn(NodeId) -> Result<Option<Hash>, PristineError>, |
| 199 | V: VertexBuffer, |
| 200 | { |
| 201 | validate_order_vertices(graph, order)?; |
| 202 | |
| 203 | // Track conflict IDs |
| 204 | let mut conflict_id: usize = 0; |
| 205 | |
| 206 | // Track zombie state |
| 207 | let mut in_zombie: Option<usize> = None; |
| 208 | |
| 209 | // Debug-only guard: each vertex's content must be emitted at most once. |
| 210 | // Emitting a vertex twice is the silent-duplication signature (e.g. a |
| 211 | // conflict tail written once per side). Zero cost in release builds. |
| 212 | #[cfg(debug_assertions)] |
| 213 | let mut emitted_content: std::collections::HashSet<VertexId> = std::collections::HashSet::new(); |
| 214 | |
| 215 | // Process SCCs in reverse order (Tarjan produces reverse topological order, |
| 216 | // so we iterate in reverse to get forward topological order for correct output) |
| 217 | for scc in order.sccs.iter().rev() { |
| 218 | // Skip empty SCCs (shouldn't happen, but be safe) |
| 219 | if scc.is_empty() { |
| 220 | continue; |
| 221 | } |
| 222 | |
| 223 | // Check if this is a cyclic conflict (multi-span SCC) |
| 224 | let is_cyclic = scc.len() > 1; |
| 225 | |
| 226 | if is_cyclic { |
| 227 | conflict_id += 1; |
| 228 | buffer |
| 229 | .begin_cyclic_conflict(conflict_id) |
| 230 | .map_err(OutputError::io)?; |
| 231 | } |
| 232 | |
| 233 | // Output each span in the SCC |
| 234 | for (i, &vertex_id) in scc.iter().enumerate() { |
| 235 | // Get span data. |
| 236 | let vertex_data = graph |
| 237 | .try_get_vertex(vertex_id) |
| 238 | .ok_or_else(|| missing_vertex("order", vertex_id))?; |
| 239 | |
| 240 | let node = vertex_data.node; |
| 241 | |
| 242 | // Handle zombie state transitions |
| 243 | let is_zombie = vertex_data.is_zombie(); |
| 244 | |
| 245 | if is_zombie && in_zombie.is_none() { |
| 246 | // Entering zombie region |