Best-effort compact provenance for a change: session, agent label, turn timestamp, and governing plan id. `None` if no provenance graph explains it.
(repo: &Repository, hash_b32: &str)
| 856 | /// Best-effort compact provenance for a change: session, agent label, turn |
| 857 | /// timestamp, and governing plan id. `None` if no provenance graph explains it. |
| 858 | fn load_provenance_compact(repo: &Repository, hash_b32: &str) -> Option<serde_json::Value> { |
| 859 | let hash = Hash::from_base32(hash_b32.as_bytes())?; |
| 860 | let graphs = load_graphs(repo, &hash).ok()?; |
| 861 | let (_, g) = graphs.first()?; |
| 862 | let agent = if g.agent_display_name.is_empty() { |
| 863 | g.agent_name.clone() |
| 864 | } else { |
| 865 | g.agent_display_name.clone() |
| 866 | }; |
| 867 | Some(serde_json::json!({ |
| 868 | "session_id": g.session_id, |
| 869 | "agent": agent, |
| 870 | "timestamp": g.timestamp, |
| 871 | "plan_id": g.plan_id, |
| 872 | })) |
| 873 | } |
| 874 | |
| 875 | #[cfg(test)] |
| 876 | mod tests { |
no test coverage detected