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

Function check_evidence_resolution

atomic-cli/src/commands/intent/validate.rs:204–240  ·  view source on GitHub ↗

Resolve `urn:atomic:change: ` evidence URNs against the change store at `repo_root`. One violation per URN that does not resolve. With no repository the check is skipped — the gate still enforces presence; resolution needs a change store. (Ported from PR #102, adapted to the top-level `intent validate`.)

(
    evidence: &[(String, String)],
    repo_root: Option<&Path>,
)

Source from the content-addressed store, hash-verified

202/// the check is skipped — the gate still enforces presence; resolution needs a
203/// change store. (Ported from PR #102, adapted to the top-level `intent validate`.)
204fn check_evidence_resolution(
205 evidence: &[(String, String)],
206 repo_root: Option<&Path>,
207) -> Vec<Violation> {
208 let mut violations = Vec::new();
209 if evidence.is_empty() {
210 return violations;
211 }
212 let Some(root) = repo_root else {
213 eprintln!("note: evidence resolution skipped — not inside an Atomic repository");
214 return violations;
215 };
216 let repo = match Repository::open_readonly(root) {
217 Ok(repo) => repo,
218 Err(e) => {
219 eprintln!("note: evidence resolution skipped — cannot open repository: {e}");
220 return violations;
221 }
222 };
223 for (focus, urn) in evidence {
224 let Some(hash_str) = urn.strip_prefix("urn:atomic:change:") else {
225 continue; // non-change URNs are out of scope here
226 };
227 let resolved = Hash::from_base32(hash_str.as_bytes())
228 .map(|h| repo.has_change(&h))
229 .unwrap_or(false);
230 if !resolved {
231 violations.push(Violation {
232 focus_node: focus.clone(),
233 shape: "EvidenceResolution".to_string(),
234 path: Some("evidence".to_string()),
235 message: format!("evidence {urn} does not resolve to a change in this repository"),
236 });
237 }
238 }
239 violations
240}
241
242/// Serialize a [`ValidationReport`] to the documented JSON shape:
243/// `{conforms, results: [{focus_node, shape, path, message}]}`.

Callers 4

runMethod · 0.85

Calls 5

is_emptyMethod · 0.45
as_bytesMethod · 0.45
has_changeMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45