Check if a vertex is alive by examining all its parent edges. A vertex is alive if it has at least one live parent AND was not deleted by a change in our view's filter. Uses typed [`ParentEdgeKind`] matching instead of raw `EdgeFlags` bitflag checks, so every case is visible and the compiler rejects missing arms. # Logic - **Non-deleted parent edge** → live parent - **DELETED parent, introduce
(
&self,
txn: &T,
vertex: GraphNode<NodeId>,
)
| 247 | /// The vertex is alive when it has at least one live parent AND |
| 248 | /// was not deleted by an in-filter change. |
| 249 | pub fn is_vertex_alive<T: GraphTxnT>( |
| 250 | &self, |
| 251 | txn: &T, |
| 252 | vertex: GraphNode<NodeId>, |
| 253 | ) -> Result<bool, PristineError> { |
| 254 | // Without a filter (and without deletions_final), delegate to the |
| 255 | // unfiltered classifier. With deletions_final set, the logic below |
| 256 | // applies with every visible change "in the filter" — passes_filter |
| 257 | // returns true for everything when no set is present. |
| 258 | if !self.deletion_aware() { |
| 259 | return super::classify::is_vertex_alive(txn, &vertex); |
| 260 | } |
| 261 | |
| 262 | // Root is always alive |
| 263 | if vertex.is_root() { |
| 264 | return Ok(true); |
| 265 | } |
| 266 | |
| 267 | // Include deleted parents so we can distinguish "deleted by us" |
| 268 | // from "deleted by someone outside our filter". |
| 269 | let parents = txn.iter_parents(vertex, true)?; |
| 270 | |
| 271 | let mut has_live_parent = false; |
| 272 | let mut deleted_by_filter_change = false; |
| 273 | |
| 274 | for parent in &parents { |
| 275 | let introduced_by = parent.introduced_by; |
| 276 | let in_filter = self.passes_filter(introduced_by); |
| 277 | |
| 278 | match parent.kind { |
| 279 | // Non-deleted parent edges — vertex is connected (alive) |
| 280 | ParentEdgeKind::Block | ParentEdgeKind::Folder => { |
| 281 | has_live_parent = true; |
| 282 | } |
| 283 | // Pseudo parents count for empty vertices (inodes) |
| 284 | ParentEdgeKind::PseudoBlock | ParentEdgeKind::PseudoFolder => { |
| 285 | if vertex.is_empty() { |
| 286 | has_live_parent = true; |
| 287 | } |
| 288 | } |
| 289 | // Deleted parent — check who deleted it |
| 290 | ParentEdgeKind::BlockDeleted | ParentEdgeKind::FolderDeleted => { |
| 291 | if in_filter { |
| 292 | // Deletion from a change in our filter → vertex is dead |
| 293 | deleted_by_filter_change = true; |
| 294 | } else { |
| 295 | // Deletion from a change OUTSIDE our filter. |
| 296 | // From our perspective that deletion hasn't happened yet, |
| 297 | // so this edge still counts as a live connection. |
| 298 | has_live_parent = true; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | // Vertex is alive if it has at least one live parent (non-deleted |
| 305 | // or deleted-by-outside-change) AND was not explicitly deleted by |
| 306 | // a change in our filter. |
no test coverage detected