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

Function vault_revision_hash

atomic-cli/src/commands/vault/context.rs:684–690  ·  view source on GitHub ↗

Identify the exact stored knowledge revision, not only its Markdown body. Length-prefixing keeps the hash input unambiguous while preserving the raw stored frontmatter as part of the revision contract.

(entry: &VaultEntry)

Source from the content-addressed store, hash-verified

682/// Length-prefixing keeps the hash input unambiguous while preserving the raw
683/// stored frontmatter as part of the revision contract.
684fn vault_revision_hash(entry: &VaultEntry) -> String {
685 let mut bytes = b"atomic-vault-revision-v1".to_vec();
686 append_hash_field(&mut bytes, entry.entry_type.as_str().as_bytes());
687 append_hash_field(&mut bytes, entry.frontmatter_json.as_bytes());
688 append_hash_field(&mut bytes, &entry.content_bytes);
689 Hash::of(&bytes).to_base32()
690}
691
692fn append_hash_field(target: &mut Vec<u8>, value: &[u8]) {
693 target.extend_from_slice(&(value.len() as u64).to_be_bytes());

Callers 1

resolve_and_rankFunction · 0.85

Calls 4

append_hash_fieldFunction · 0.85
as_bytesMethod · 0.45
as_strMethod · 0.45
to_base32Method · 0.45

Tested by

no test coverage detected