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

Function fresh_attested_intent

libatomic/src/daemon/services_agent.rs:707–731  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

705
706/// The fresh attested intent node, when a current attestation exists.
707fn fresh_attested_intent(
708 repo: &Repository,
709 id: &str,
710 frontmatter: &Map<String, Value>,
711 body: &str,
712) -> Option<CanonicalNode> {
713 let vault_path = format!(
714 "attestations/{}/attested.md",
715 sanitize_id(&normalized_id(repo, id))
716 );
717 let entry = repo.vault_retrieve(&vault_path).ok()??;
718 let node: CanonicalNode = serde_json::from_str(body_of(&entry).trim_end()).ok()?;
719 let fresh = serde_json::from_str::<Value>(&entry.frontmatter_json)
720 .ok()
721 .and_then(|v| {
722 v.get("sourceContentHash")
723 .and_then(Value::as_str)
724 .map(str::to_string)
725 });
726 if fresh.as_deref() == Some(source_content_hash(frontmatter, body).as_str()) {
727 Some(node)
728 } else {
729 None
730 }
731}
732
733/// Evidence failures are user-fixable gate refusals over the wire.
734fn evidence_status(error: intent_evidence::EvidenceError) -> Status {

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