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

Function quarantine_change_record

atomic-repository/src/git_binding/pack.rs:302–333  ·  view source on GitHub ↗

Quarantine one candidate change record and recover its identity. Two distinct, deliberate key namespaces meet here — this is the resolved CB-6A/CB-6B ambiguity (RFC §8.6): - **Pack addressing** (the record `key`): lowercase-hex `blake3(record bytes)` — the audited [`binding_pack_records`] contract. The change *file* is the addressed object; its trailer is excluded from this digest by the V3 form

(record: &ObjectRecord)

Source from the content-addressed store, hash-verified

300///
301/// [`binding_pack_records`]: super::privacy::binding_pack_records
302pub fn quarantine_change_record(record: &ObjectRecord) -> Result<(Hash, Change), BindingPackError> {
303 if !matches!(record.family, ObjectFamily::Change) {
304 return Err(BindingPackError::Refused {
305 detail: format!(
306 "binding pack refused {:?} object {}: only V3 change files may enter Git",
307 record.family, record.key
308 ),
309 });
310 }
311 if !is_blake3_key(&record.key) {
312 return Err(BindingPackError::InvalidKey {
313 key: record.key.clone(),
314 });
315 }
316 if Hash::of(&record.bytes).to_hex() != record.key {
317 return Err(BindingPackError::HashMismatch {
318 key: record.key.clone(),
319 });
320 }
321 let (change, identity) = Change::deserialize(&mut std::io::Cursor::new(&record.bytes))
322 .map_err(|error| BindingPackError::ChangeDecode {
323 key: record.key.clone(),
324 reason: error.to_string(),
325 })?;
326 if let Some(detail) = private_material_in_change(&change) {
327 return Err(BindingPackError::PrivateMaterial {
328 key: record.key.clone(),
329 detail,
330 });
331 }
332 Ok((identity, change))
333}
334
335/// The private material a change carries for Git transport, if any (§12.13).
336///

Calls 5

is_blake3_keyFunction · 0.85
deserializeFunction · 0.70
cloneMethod · 0.45
to_hexMethod · 0.45