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

Function is_vertex_alive

atomic-core/src/output/alive/retrieve/classify.rs:82–114  ·  view source on GitHub ↗

Check if a node is alive (not fully deleted). A node is alive if it has at least one non-deleted, non-pseudo-only parent edge. For empty vertices (inodes), any non-deleted parent — including pseudo parents — proves aliveness. Uses typed [`ParentEdgeKind`] matching instead of raw `EdgeFlags` bitflag checks, so every case is visible and the compiler rejects missing arms.

(
    txn: &T,
    node: &GraphNode<NodeId>,
)

Source from the content-addressed store, hash-verified

80/// bitflag checks, so every case is visible and the compiler rejects
81/// missing arms.
82pub(super) fn is_vertex_alive<T: GraphTxnT>(
83 txn: &T,
84 node: &GraphNode<NodeId>,
85) -> Result<bool, PristineError> {
86 // Root node is always alive
87 if node.is_root() {
88 return Ok(true);
89 }
90
91 // Iterate non-deleted parent edges only
92 let parents = txn.iter_parents(*node, false)?;
93
94 for parent in &parents {
95 match parent.kind {
96 // Real (non-pseudo) parent edges prove aliveness for any vertex
97 ParentEdgeKind::Block | ParentEdgeKind::Folder => return Ok(true),
98
99 // Pseudo parents prove aliveness only for empty vertices (inodes)
100 ParentEdgeKind::PseudoBlock | ParentEdgeKind::PseudoFolder => {
101 if node.is_empty() {
102 return Ok(true);
103 }
104 // For content vertices, pseudo parents alone don't prove aliveness
105 }
106
107 // BlockDeleted/FolderDeleted are excluded by include_deleted=false,
108 // but handle them explicitly for exhaustiveness
109 ParentEdgeKind::BlockDeleted | ParentEdgeKind::FolderDeleted => {}
110 }
111 }
112
113 Ok(false)
114}
115
116/// Check if a node is a zombie (deleted but with live connections).
117///

Callers 2

create_alive_vertexFunction · 0.85
is_vertex_aliveMethod · 0.85

Calls 3

iter_parentsMethod · 0.80
is_rootMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected