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,
)
| 1095 | /// `CanonicalNode`), then the legacy sidecar candidates (the normalized |
| 1096 | /// id path, then the raw-arg path a pre-upgrade build wrote). |
| 1097 | fn 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 | } |
no test coverage detected