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

Function load_attestation

atomic-cli/src/commands/memory/bridge.rs:229–263  ·  view source on GitHub ↗

Load a memory's attestation and classify it against the current source (`inputs`). Prefers the tracked vault entry, falling back to the legacy sidecar. A missing attestation is `None`; a corrupt/malformed one is treated as `None`/skipped with a warning (fail-open, so a read still works on the raw node). Same mechanism as the intent bridge.

(
    repo: &Repository,
    id_or_path: &str,
    inputs: &MemLiftInputs,
)

Source from the content-addressed store, hash-verified

227/// treated as `None`/skipped with a warning (fail-open, so a read still
228/// works on the raw node). Same mechanism as the intent bridge.
229pub fn load_attestation(
230 repo: &Repository,
231 id_or_path: &str,
232 inputs: &MemLiftInputs,
233) -> CliResult<Attestation> {
234 // 1) Tracked vault entry (authoritative). The body is the pretty
235 // JSON-LD node (+ trailing '\n'); the classification parses it
236 // straight to a MemoryNode.
237 let vpath = attestation_vault_path(id_or_path);
238 let tracked = repo
239 .vault_retrieve(&vpath)
240 .map_err(CliError::Repository)?
241 .map(|entry| TrackedAttestation {
242 vault_path: vpath.clone(),
243 frontmatter_json: entry.frontmatter_json,
244 content: entry.content_bytes,
245 });
246 // 2) Legacy sidecar fallback (pre-upgrade attestations). Memory has
247 // no PREFIX-N ambiguity, so there is exactly ONE candidate path.
248 let sidecar_path = attested_sidecar_path(repo, id_or_path);
249 let sidecar = if sidecar_path.exists() {
250 std::fs::read_to_string(&sidecar_path)
251 .ok()
252 .map(|text| SidecarArtifact {
253 path: sidecar_path.display().to_string(),
254 text,
255 })
256 } else {
257 None
258 };
259 Ok(classify_attestation(
260 AttestationSources { tracked, sidecar },
261 inputs,
262 ))
263}
264
265/// The dual-read classification, pure over its inputs — the same code the
266/// intent bridge runs, over the memory node shape. Both the local body

Callers 10

runMethod · 0.70
runMethod · 0.70
runMethod · 0.70
compute_rowFunction · 0.70
runMethod · 0.50
runMethod · 0.50
executeMethod · 0.50
compute_rowFunction · 0.50

Calls 8

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