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

Function collect_zombie_context

atomic-core/src/apply/edge.rs:481–522  ·  view source on GitHub ↗

Collect zombie context when deleting content. If we're deleting content that has children or parents from unknown changes (not in our dependencies), those become zombies. A zombie is content that: - We want to delete - But has live connections from changes we don't know about # Arguments `txn` - Transaction for graph queries `workspace` - Workspace to track zombies `change` - Current change fo

(
    txn: &T,
    workspace: &mut Workspace,
    change: &Change,
    verified_frontier: &VerifiedCausalFrontier,
    edge: &NewEdge<Option<Hash>>,
    change_id: NodeId,
)

Source from the content-addressed store, hash-verified

479/// * `edge` - The deletion edge
480/// * `change_id` - Internal ID of current change
481fn collect_zombie_context<T: GraphTxnT>(
482 txn: &T,
483 workspace: &mut Workspace,
484 change: &Change,
485 verified_frontier: &VerifiedCausalFrontier,
486 edge: &NewEdge<Option<Hash>>,
487 change_id: NodeId,
488) -> Result<(), LocalApplyError> {
489 // Get the target position range
490 let start_pos = resolve_position(txn, &edge.to.start_pos(), change_id)?;
491 let end_pos = resolve_position(txn, &edge.to.end_pos(), change_id)?;
492
493 // Find all vertices in the target range
494 let mut pos = start_pos;
495 while let Ok(node) = txn.find_block(pos) {
496 // Check for non-deleted edges that we don't know about
497 check_vertex_for_zombies(txn, workspace, change, verified_frontier, node, change_id)?;
498
499 // Move to next span in range
500 if node.end < end_pos.pos {
501 let next_pos = if node.end == node.start {
502 // Empty vertex (e.g., inode marker) — skip past it
503 ChangePosition::new(node.end.get() + 1)
504 } else {
505 node.end
506 };
507 if next_pos <= pos.pos {
508 // Safety: avoid infinite loop if we can't advance
509 log::warn!(
510 "collect_zombie_context: pos not advancing at {:?}, breaking",
511 pos
512 );
513 break;
514 }
515 pos.pos = next_pos;
516 } else {
517 break;
518 }
519 }
520
521 Ok(())
522}
523
524/// Check a single span for zombie conflicts.
525///

Callers 1

write_new_edgeFunction · 0.85

Calls 6

resolve_positionFunction · 0.85
check_vertex_for_zombiesFunction · 0.85
getMethod · 0.65
start_posMethod · 0.45
end_posMethod · 0.45
find_blockMethod · 0.45

Tested by

no test coverage detected