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

Function load_attestation

atomic-repository/src/intent_bridge.rs:235–272  ·  view source on GitHub ↗

Load an intent's attestation sidecar and classify it against the current source (`inputs`). A missing sidecar is `None`; a corrupt/malformed one is treated as `None` with a warning (so a read still works on the raw node). This is what makes an attestation observable: `validate`/`show`/`verify` consult it instead of always re-lifting the un-attested vault entry.

(
    repo: &Repository,
    id: &str,
    inputs: &LiftInputs,
)

Source from the content-addressed store, hash-verified

233/// This is what makes an attestation observable: `validate`/`show`/`verify`
234/// consult it instead of always re-lifting the un-attested vault entry.
235pub fn load_attestation(
236 repo: &Repository,
237 id: &str,
238 inputs: &LiftInputs,
239) -> BridgeResult<Attestation> {
240 // 1) Tracked vault entry (new authoritative source). The body is the
241 // pretty JSON-LD node (+ a trailing '\n'); the classification parses
242 // it straight to a CanonicalNode.
243 let vpath = attestation_vault_path(repo, id)?;
244 let tracked = repo
245 .vault_retrieve(&vpath)?
246 .map(|entry| TrackedAttestation {
247 vault_path: vpath.clone(),
248 frontmatter_json: entry.frontmatter_json,
249 content: entry.content_bytes,
250 });
251 // 2) Legacy sidecar fallback (pre-upgrade attestations). Probe the
252 // normalized-id path first (what the current `attest` writes), then
253 // the raw-arg path an M1a-era build used (it sanitized the RAW CLI
254 // arg without normalizing), so a sidecar written via `attest 1` /
255 // `attest pimo-1` is still found after upgrade regardless of the id
256 // form (critic #4).
257 let sidecar = attested_sidecar_candidates(repo, id)?
258 .into_iter()
259 .find(|candidate| candidate.exists())
260 .and_then(|path| {
261 std::fs::read_to_string(&path)
262 .ok()
263 .map(|text| SidecarArtifact {
264 path: path.display().to_string(),
265 text,
266 })
267 });
268 Ok(classify_attestation(
269 AttestationSources { tracked, sidecar },
270 inputs,
271 ))
272}
273
274/// The dual-read classification, pure over its inputs: the tracked entry
275/// parses to a `CanonicalNode` and its `sourceContentHash` anchor decides

Callers 3

prepareFunction · 0.70
load_intent_nodeFunction · 0.50

Calls 9

vault_retrieveMethod · 0.80
displayMethod · 0.80
attestation_vault_pathFunction · 0.70
classify_attestationFunction · 0.70
cloneMethod · 0.45
into_iterMethod · 0.45
existsMethod · 0.45
okMethod · 0.45

Tested by 1