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

Function checkpoint_facts_bytes

atomic-repository/src/repository/adoption.rs:138–158  ·  view source on GitHub ↗

Canonical bytes of a checkpoint's FACTS (R3): the parsed checkpoint's deterministic wire serialization with the index digest normalized to base32. The Checkpoint lease digests these facts — not the raw file bytes — so the CLI's richer v2 writer (which records the index digest as hex) and the simple writer authenticate identically when the underlying facts match, and a fact-preserving rewrite is id

(
    checkpoint: &super::workspace_txn::WorkspaceCheckpoint,
)

Source from the content-addressed store, hash-verified

136/// hex) and the simple writer authenticate identically when the underlying
137/// facts match, and a fact-preserving rewrite is idempotent.
138pub(super) fn checkpoint_facts_bytes(
139 checkpoint: &super::workspace_txn::WorkspaceCheckpoint,
140) -> Result<Vec<u8>, RepositoryError> {
141 let mut normalized = checkpoint.clone();
142 if let Some(digest) = &checkpoint.git_index_digest {
143 if atomic_core::types::Merkle::from_base32(digest.as_bytes()).is_none() {
144 // The CLI checkpoint writer stores the canonical index digest as
145 // hex; normalize it to base32 so both encodings lease the same
146 // facts.
147 let bytes = hex_decode_bytes(digest)?;
148 let bytes: [u8; 32] =
149 bytes
150 .try_into()
151 .map_err(|_| RepositoryError::InvalidRepository {
152 reason: format!("'{digest}' is neither base32 nor a 32-byte hex digest"),
153 })?;
154 normalized.git_index_digest = Some(atomic_core::types::Merkle(bytes).to_base32());
155 }
156 }
157 super::workspace_txn::workspace_checkpoint_bytes(&normalized)
158}
159
160/// Build the hashed metadata marker for an adoption snapshot.
161pub fn adoption_snapshot_metadata(

Calls 7

hex_decode_bytesFunction · 0.85
MerkleClass · 0.85
is_noneMethod · 0.80
cloneMethod · 0.45
as_bytesMethod · 0.45
to_base32Method · 0.45

Tested by

no test coverage detected