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

Function check_deleted_context

atomic-core/src/apply/insertion.rs:237–282  ·  view source on GitHub ↗

Check if a context span was deleted by an unknown change. If the context has DELETED edges from changes not in our dependencies, we have a zombie conflict. The workspace tracks these for later resolution. # Arguments `txn` - Transaction for graph queries `workspace` - Workspace to record conflicts `change` - Current change for dependency checking `node` - GraphNode to check for deleted context

(
    txn: &T,
    workspace: &mut Workspace,
    change: &Change,
    node: GraphNode<NodeId>,
)

Source from the content-addressed store, hash-verified

235/// * `change` - Current change for dependency checking
236/// * `node` - GraphNode to check for deleted context
237fn check_deleted_context<T: GraphTxnT>(
238 txn: &T,
239 workspace: &mut Workspace,
240 change: &Change,
241 node: GraphNode<NodeId>,
242) -> Result<(), LocalApplyError> {
243 // Skip ROOT span
244 if node.is_root() {
245 return Ok(());
246 }
247
248 // Look for parent edges with DELETED flag
249 let min_flag = EdgeFlags::PARENT | EdgeFlags::BLOCK;
250 let max_flag = EdgeFlags::PARENT | EdgeFlags::BLOCK | EdgeFlags::DELETED | EdgeFlags::FOLDER;
251
252 let edges =
253 txn.iter_adjacent(node, min_flag, max_flag)
254 .map_err(|e| LocalApplyError::Internal {
255 message: format!("Failed to iterate adjacent edges: {}", e),
256 })?;
257
258 for edge_result in edges {
259 let edge = edge_result.map_err(|e| LocalApplyError::Internal {
260 message: format!("Edge iteration error: {}", e),
261 })?;
262
263 // Check if edge is deleted
264 if edge.flag().contains(EdgeFlags::DELETED) {
265 // Get the change that introduced the deletion
266 let introduced_by = edge.introduced_by();
267 if !introduced_by.is_root() {
268 // Look up the external hash
269 if let Ok(Some(hash)) = txn.get_external(introduced_by) {
270 // Check if this change knows about the deletion
271 if !change.knows(&hash) {
272 // Unknown deletion - mark as zombie
273 workspace.add_zombie_vertex(node);
274 break;
275 }
276 }
277 }
278 }
279 }
280
281 Ok(())
282}
283
284// Tests
285

Callers 1

write_new_vertexFunction · 0.85

Calls 8

flagMethod · 0.80
is_rootMethod · 0.45
iter_adjacentMethod · 0.45
containsMethod · 0.45
introduced_byMethod · 0.45
get_externalMethod · 0.45
knowsMethod · 0.45
add_zombie_vertexMethod · 0.45

Tested by

no test coverage detected