| 1028 | |
| 1029 | impl SemanticDeletionEvidence { |
| 1030 | pub(super) fn load( |
| 1031 | loader: &dyn Fn(&Hash) -> Result<Change, String>, |
| 1032 | txn: &atomic_core::pristine::WriteTxn<'_>, |
| 1033 | trunk: atomic_core::crdt::TrunkId, |
| 1034 | visibility: &atomic_core::pristine::GraphVisibilityClosure, |
| 1035 | ) -> Result<Self, String> { |
| 1036 | use atomic_core::pristine::GraphTxnT; |
| 1037 | let mut evidence = Self::default(); |
| 1038 | for (change_id, hash) in txn.list_registered_changes().map_err(|e| e.to_string())? { |
| 1039 | // Registration alone is never proof that FileOps executed. |
| 1040 | if !txn |
| 1041 | .was_change_applied(change_id) |
| 1042 | .map_err(|e| e.to_string())? |
| 1043 | { |
| 1044 | continue; |
| 1045 | } |
| 1046 | let Ok(change) = loader(&hash) else { continue }; |
| 1047 | for ops in change.file_ops() { |
| 1048 | if !file_ops_target_trunk(ops, change_id, trunk) { |
| 1049 | continue; |
| 1050 | } |
| 1051 | for line in ops.line_ops() { |
| 1052 | if !matches!( |
| 1053 | line.operation(), |
| 1054 | atomic_core::crdt::BranchOp::Delete { .. } |
| 1055 | | atomic_core::crdt::BranchOp::Modify { .. } |
| 1056 | ) { |
| 1057 | continue; |
| 1058 | } |
| 1059 | let raw = line.branch_id(); |
| 1060 | let branch = if raw.change_id().is_root() { |
| 1061 | atomic_core::crdt::BranchId::new(change_id, raw.branch_idx()) |
| 1062 | } else { |
| 1063 | raw |
| 1064 | }; |
| 1065 | evidence.applied.insert(branch); |
| 1066 | if !visibility.contains(change_id) { |
| 1067 | evidence.outside.insert(branch); |
| 1068 | } |
| 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | Ok(evidence) |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | /// Review E1: whether the GLOBAL graph genuinely proves `branch`'s bound |