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

Function intent_list_attestation

libatomic/src/daemon/services_agent.rs:1097–1156  ·  view source on GitHub ↗

An intent's attestation, loaded through the same dual-read the CLI bridge performs: the tracked vault entry first (its body parses to a `CanonicalNode`), then the legacy sidecar candidates (the normalized id path, then the raw-arg path a pre-upgrade build wrote).

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

Source from the content-addressed store, hash-verified

1095/// `CanonicalNode`), then the legacy sidecar candidates (the normalized
1096/// id path, then the raw-arg path a pre-upgrade build wrote).
1097fn intent_list_attestation(
1098 repo: &Repository,
1099 id: &str,
1100 frontmatter: &Map<String, Value>,
1101 body: &str,
1102) -> LoadedAttestation<CanonicalNode> {
1103 let vpath = format!(
1104 "attestations/{}/attested.md",
1105 sanitize_id(&normalized_id(repo, id))
1106 );
1107 if let Ok(Some(entry)) = repo.vault_retrieve(&vpath) {
1108 if let Ok(node) = serde_json::from_str::<CanonicalNode>(body_of(&entry).trim_end()) {
1109 return classify_artifact(
1110 node,
1111 tracked_source_anchor(&entry),
1112 source_content_hash(frontmatter, body),
1113 );
1114 }
1115 // A malformed tracked entry falls through to the sidecar.
1116 }
1117 let normalized = repo
1118 .dot_dir()
1119 .join("canonical")
1120 .join("intents")
1121 .join(sanitize_id(&normalized_id(repo, id)))
1122 .join("attested.jsonld");
1123 let raw = repo
1124 .dot_dir()
1125 .join("canonical")
1126 .join("intents")
1127 .join(sanitize_id(id))
1128 .join("attested.jsonld");
1129 for path in [normalized, raw] {
1130 if !path.exists() {
1131 continue;
1132 }
1133 if let Ok(text) = std::fs::read_to_string(&path) {
1134 if let Ok(artifact) = serde_json::from_str::<Value>(&text) {
1135 if let Ok(node) = serde_json::from_value::<CanonicalNode>(
1136 artifact.get("node").cloned().unwrap_or(Value::Null),
1137 ) {
1138 let recorded = artifact
1139 .get("source")
1140 .and_then(|s| s.get("sourceContentHash"))
1141 .and_then(Value::as_str)
1142 .map(str::to_string);
1143 return classify_artifact(
1144 node,
1145 recorded,
1146 source_content_hash(frontmatter, body),
1147 );
1148 }
1149 }
1150 // The CLI bridge warns and treats an unreadable sidecar as
1151 // none; the listing degrades the row the same way.
1152 return LoadedAttestation::None;
1153 }
1154 }

Callers 1

list_vault_entriesMethod · 0.85

Calls 10

body_ofFunction · 0.85
classify_artifactFunction · 0.85
tracked_source_anchorFunction · 0.85
vault_retrieveMethod · 0.80
source_content_hashFunction · 0.70
sanitize_idFunction · 0.70
normalized_idFunction · 0.70
getMethod · 0.65
dot_dirMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected