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

Function change_from_bundle

libatomic/src/daemon/sandbox_wire.rs:350–369  ·  view source on GitHub ↗

Unwrap an interchange envelope without converting its payload. Legacy v3 and empty labels remain accepted, including schema-5 bytes sent by older libatomic producers. A v5 label requires a v5 header. The caller must use core/repository validation for the authenticated descriptor and claimed hash.

(bundle: &pb::ChangeBundle)

Source from the content-addressed store, hash-verified

348/// libatomic producers. A v5 label requires a v5 header. The caller must use
349/// core/repository validation for the authenticated descriptor and claimed hash.
350pub fn change_from_bundle(bundle: &pb::ChangeBundle) -> Result<(Hash, Vec<u8>), String> {
351 if !bundle.schema.is_empty()
352 && bundle.schema != CHANGE_SCHEMA
353 && bundle.schema != LEGACY_CHANGE_SCHEMA
354 {
355 return Err(format!(
356 "expected {CHANGE_SCHEMA} or {LEGACY_CHANGE_SCHEMA} change bytes, got '{}'",
357 bundle.schema
358 ));
359 }
360 if bundle.schema == CHANGE_SCHEMA
361 && change_file_header(&bundle.payload)?.version != FIELD_CODEC_FORMAT_VERSION
362 {
363 return Err("atomic.change.v5 requires an ATOM schema-5 payload".into());
364 }
365 Ok((
366 hash_from_proto(bundle.hash.as_ref())?,
367 bundle.payload.clone(),
368 ))
369}
370
371pub fn provenance_graph_bytes(graph: Vec<u8>) -> pb::VersionedBytes {
372 versioned(PROVENANCE_GRAPH_SCHEMA, graph)

Callers 1

submit_changeMethod · 0.85

Calls 5

change_file_headerFunction · 0.85
hash_from_protoFunction · 0.85
as_refMethod · 0.80
is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected