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

Method finalize_shim_git_write

atomic-repository/src/repository/operation.rs:689–743  ·  view source on GitHub ↗

Append the operation-level Verified receipt for a completed shim write. The GitRef effect lease is verified against `observed_ref`, which the shim reads back from Git after the mutation (the lease-safe executor the recovery layer requires). Any third value fails closed without a Verified receipt.

(
        &self,
        prepared: PreparedShimGitWrite,
        observed_ref: Option<GitRefTarget>,
    )

Source from the content-addressed store, hash-verified

687 /// the recovery layer requires). Any third value fails closed without a
688 /// Verified receipt.
689 pub fn finalize_shim_git_write(
690 &self,
691 prepared: PreparedShimGitWrite,
692 observed_ref: Option<GitRefTarget>,
693 ) -> Result<OperationId, RepositoryError> {
694 let operation_id = prepared.operation_id;
695 let operation = self.load_operation(operation_id)?;
696 self.validate_operation_lock(&prepared._operation_lock, &operation)?;
697 let receipts = {
698 let txn = self.pristine.read_txn().map_err(pristine_error)?;
699 txn.get_effect_receipts(operation_id)
700 .map_err(pristine_error)?
701 };
702 let completed: BTreeSet<u32> = receipts
703 .iter()
704 .filter_map(|receipt| match receipt.payload().kind {
705 EffectReceiptKind::Applied
706 | EffectReceiptKind::Recovered
707 | EffectReceiptKind::RolledBack => receipt.payload().effect_ordinal,
708 EffectReceiptKind::Verified | EffectReceiptKind::LeaseRejected => None,
709 })
710 .collect();
711 for effect in &operation.payload().delta.effects {
712 if !completed.contains(&effect.ordinal) {
713 return Err(RepositoryError::InvalidOperation {
714 message: format!(
715 "operation {} cannot be verified before effect {} has a successful receipt",
716 operation.id(),
717 effect.ordinal
718 ),
719 });
720 }
721 }
722 let observed = observed_ref
723 .map(EffectValue::GitRef)
724 .unwrap_or(EffectValue::Absent);
725 for effect in &operation.payload().delta.effects {
726 if observed != effect.expected_new {
727 return Err(lease_divergence_error(
728 effect,
729 &EffectValue::Absent,
730 Some(&observed),
731 ));
732 }
733 }
734 let receipt = deterministic_effect_receipt(
735 &operation,
736 None,
737 EffectReceiptKind::Verified,
738 None,
739 None,
740 )?;
741 self.append_receipt_immediate(&prepared._operation_lock, &operation, &receipt)?;
742 Ok(operation_id)
743 }
744
745 pub(super) fn current_working_copy_state(
746 &self,

Calls 11

lease_divergence_errorFunction · 0.85
load_operationMethod · 0.80
read_txnMethod · 0.80
get_effect_receiptsMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
payloadMethod · 0.45
containsMethod · 0.45