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

Function fresh_attested_memory

libatomic/src/daemon/services_agent.rs:774–795  ·  view source on GitHub ↗

The fresh attested memory node, when a current attestation exists.

(
    repo: &Repository,
    id: &str,
    frontmatter: &Map<String, Value>,
    body: &str,
)

Source from the content-addressed store, hash-verified

772
773/// The fresh attested memory node, when a current attestation exists.
774fn fresh_attested_memory(
775 repo: &Repository,
776 id: &str,
777 frontmatter: &Map<String, Value>,
778 body: &str,
779) -> Option<MemoryNode> {
780 let vault_path = format!("attestations/memory/{}/attested.md", sanitize_id(id));
781 let entry = repo.vault_retrieve(&vault_path).ok()??;
782 let node: MemoryNode = serde_json::from_str(body_of(&entry).trim_end()).ok()?;
783 let fresh = serde_json::from_str::<Value>(&entry.frontmatter_json)
784 .ok()
785 .and_then(|v| {
786 v.get("sourceContentHash")
787 .and_then(Value::as_str)
788 .map(str::to_string)
789 });
790 if fresh.as_deref() == Some(source_content_hash(frontmatter, body).as_str()) {
791 Some(node)
792 } else {
793 None
794 }
795}
796
797/// The versioned-opaque entry bundle (schema "atomic.vault.entry.bundle.v1"):
798/// the stored entry's full domain serialization plus the RAW attestation

Callers 1

validate_vault_entityMethod · 0.85

Calls 6

body_ofFunction · 0.85
vault_retrieveMethod · 0.80
source_content_hashFunction · 0.70
getMethod · 0.65
okMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected