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

Function vertex_content_bytes

atomic-repository/src/repository/synthesis.rs:1128–1160  ·  view source on GitHub ↗

The bytes a validated branch→vertex binding renders to consumers (the same slice `output_file_via_crdt` reads for the binding): the writer change's content blob at exactly the vertex's range (review E1).

(
    repo: &Repository,
    txn: &atomic_core::pristine::WriteTxn<'_>,
    node: &atomic_core::types::GraphNode<atomic_core::types::NodeId>,
)

Source from the content-addressed store, hash-verified

1126/// same slice `output_file_via_crdt` reads for the binding): the writer
1127/// change's content blob at exactly the vertex's range (review E1).
1128fn vertex_content_bytes(
1129 repo: &Repository,
1130 txn: &atomic_core::pristine::WriteTxn<'_>,
1131 node: &atomic_core::types::GraphNode<atomic_core::types::NodeId>,
1132) -> Result<Vec<u8>, String> {
1133 let len = (node.end.get().saturating_sub(node.start.get())) as usize;
1134 if len == 0 {
1135 return Ok(Vec::new());
1136 }
1137 if node.change.is_root() {
1138 return Err(
1139 "a branch binds the ROOT sentinel vertex; the semantic layer cannot \
1140 reconstruct its content"
1141 .to_string(),
1142 );
1143 }
1144 let content_hash = txn
1145 .get_external(node.change)
1146 .map_err(|e| e.to_string())?
1147 .ok_or_else(|| "branch vertex writer has no external hash".to_string())?;
1148 let hash_fn = move |id: atomic_core::types::NodeId| -> Option<Hash> {
1149 if id == node.change {
1150 Some(content_hash)
1151 } else {
1152 None
1153 }
1154 };
1155 let mut out = vec![0u8; len];
1156 repo.change_store
1157 .get_contents(hash_fn, *node, &mut out)
1158 .map_err(|e| format!("cannot read the branch vertex content: {e}"))?;
1159 Ok(out)
1160}
1161
1162/// Whether an applied change OUTSIDE `visibility` recorded the semantic
1163/// trunk delete for `path` (review C1: operation attribution for tombstones

Callers 1

Calls 4

getMethod · 0.65
is_rootMethod · 0.45
get_externalMethod · 0.45
get_contentsMethod · 0.45

Tested by

no test coverage detected