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

Function check_deleted_context

atomic-core/src/apply/insertion.rs:259–305  ·  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,
    verified_frontier: &VerifiedCausalFrontier,
    node: GraphNode<NodeId>,
)

Source from the content-addressed store, hash-verified

257/// * `change` - Current change for dependency checking
258/// * `node` - GraphNode to check for deleted context
259fn check_deleted_context<T: GraphTxnT>(
260 txn: &T,
261 workspace: &mut Workspace,
262 change: &Change,
263 verified_frontier: &VerifiedCausalFrontier,
264 node: GraphNode<NodeId>,
265) -> Result<(), LocalApplyError> {
266 // Skip ROOT span
267 if node.is_root() {
268 return Ok(());
269 }
270
271 // Look for parent edges with DELETED flag
272 let min_flag = EdgeFlags::PARENT | EdgeFlags::BLOCK;
273 let max_flag = EdgeFlags::PARENT | EdgeFlags::BLOCK | EdgeFlags::DELETED | EdgeFlags::FOLDER;
274
275 let edges =
276 txn.iter_adjacent(node, min_flag, max_flag)
277 .map_err(|e| LocalApplyError::Internal {
278 message: format!("Failed to iterate adjacent edges: {}", e),
279 })?;
280
281 for edge_result in edges {
282 let edge = edge_result.map_err(|e| LocalApplyError::Internal {
283 message: format!("Edge iteration error: {}", e),
284 })?;
285
286 // Check if edge is deleted
287 if edge.flag().contains(EdgeFlags::DELETED) {
288 // Get the change that introduced the deletion
289 let introduced_by = edge.introduced_by();
290 if !introduced_by.is_root() {
291 // Look up the external hash
292 if let Ok(Some(hash)) = txn.get_external(introduced_by) {
293 // Check if this change knows about the deletion
294 if !change.knows_with_frontier(&hash, verified_frontier) {
295 // Unknown deletion - mark as zombie
296 workspace.add_zombie_vertex(node);
297 break;
298 }
299 }
300 }
301 }
302 }
303
304 Ok(())
305}
306
307// Tests
308

Callers 1

Calls 8

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

Tested by

no test coverage detected