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,
)
| 306 | /// This is what makes an attestation observable: `validate`/`show`/`verify` |
| 307 | /// consult it instead of always re-lifting the un-attested vault entry. |
| 308 | pub fn load_attestation( |
| 309 | repo: &Repository, |
| 310 | id: &str, |
| 311 | inputs: &LiftInputs, |
| 312 | ) -> BridgeResult<Attestation> { |
| 313 | // 1) Tracked vault entry (new authoritative source). The body is the |
| 314 | // pretty JSON-LD node (+ a trailing '\n'); the classification parses |
| 315 | // it straight to a CanonicalNode. |
| 316 | let vpath = attestation_vault_path(repo, id)?; |
| 317 | let tracked = repo |
| 318 | .vault_retrieve(&vpath)? |
| 319 | .map(|entry| TrackedAttestation { |
| 320 | vault_path: vpath.clone(), |
| 321 | frontmatter_json: entry.frontmatter_json, |
| 322 | content: entry.content_bytes, |
| 323 | }); |
| 324 | // 2) Legacy sidecar fallback (pre-upgrade attestations). Probe the |
| 325 | // normalized-id path first (what the current `attest` writes), then |
| 326 | // the raw-arg path an M1a-era build used (it sanitized the RAW CLI |
| 327 | // arg without normalizing), so a sidecar written via `attest 1` / |
| 328 | // `attest pimo-1` is still found after upgrade regardless of the id |
| 329 | // form (critic #4). |
| 330 | let sidecar = attested_sidecar_candidates(repo, id)? |
| 331 | .into_iter() |
| 332 | .find(|candidate| candidate.exists()) |
| 333 | .and_then(|path| { |
| 334 | std::fs::read_to_string(&path) |
| 335 | .ok() |
| 336 | .map(|text| SidecarArtifact { |
| 337 | path: path.display().to_string(), |
| 338 | text, |
| 339 | }) |
| 340 | }); |
| 341 | Ok(classify_attestation( |
| 342 | AttestationSources { tracked, sidecar }, |
| 343 | inputs, |
| 344 | )) |
| 345 | } |
| 346 | |
| 347 | /// The dual-read classification, pure over its inputs: the tracked entry |
| 348 | /// parses to a `CanonicalNode` and its `sourceContentHash` anchor decides |