The fresh attested memory node, when a current attestation exists.
(
repo: &Repository,
id: &str,
frontmatter: &Map<String, Value>,
body: &str,
)
| 772 | |
| 773 | /// The fresh attested memory node, when a current attestation exists. |
| 774 | fn fresh_attested_memory( |
| 775 | repo: &Repository, |
| 776 | id: &str, |
| 777 | frontmatter: &Map<String, Value>, |
| 778 | body: &str, |
| 779 | ) -> Option<MemoryNode> { |
| 780 | let vault_path = format!("attestations/memory/{}/attested.md", sanitize_id(id)); |
| 781 | let entry = repo.vault_retrieve(&vault_path).ok()??; |
| 782 | let node: MemoryNode = serde_json::from_str(body_of(&entry).trim_end()).ok()?; |
| 783 | let fresh = serde_json::from_str::<Value>(&entry.frontmatter_json) |
| 784 | .ok() |
| 785 | .and_then(|v| { |
| 786 | v.get("sourceContentHash") |
| 787 | .and_then(Value::as_str) |
| 788 | .map(str::to_string) |
| 789 | }); |
| 790 | if fresh.as_deref() == Some(source_content_hash(frontmatter, body).as_str()) { |
| 791 | Some(node) |
| 792 | } else { |
| 793 | None |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | /// The versioned-opaque entry bundle (schema "atomic.vault.entry.bundle.v1"): |
| 798 | /// the stored entry's full domain serialization plus the RAW attestation |
no test coverage detected