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

Function attestation_detail_bundle

libatomic/src/daemon/services_agent.rs:2934–2973  ·  view source on GitHub ↗

One resolved attestation's detail (schema "atomic.attestation.detail.v1"): the domain payload plus the per-view coverage rows (in the view listing's order, zero-total views skipped), so the client renders the detail with the same code the local body runs.

(
    repo: &Repository,
    hash: &atomic_core::types::Hash,
    attest: &Attestation,
)

Source from the content-addressed store, hash-verified

2932/// listing's order, zero-total views skipped), so the client renders the
2933/// detail with the same code the local body runs.
2934fn attestation_detail_bundle(
2935 repo: &Repository,
2936 hash: &atomic_core::types::Hash,
2937 attest: &Attestation,
2938) -> Result<VersionedBytes, Status> {
2939 let mut coverage: Vec<Value> = Vec::new();
2940 if let Ok(views) = repo.list_views() {
2941 for view_name in &views {
2942 let Ok(history) =
2943 repo.log(atomic_repository::history::HistoryOptions::default().view(view_name))
2944 else {
2945 continue;
2946 };
2947 let total = history.len();
2948 if total == 0 {
2949 continue;
2950 }
2951 let covered = history
2952 .iter()
2953 .filter(|entry| attest.covers_change(&entry.hash))
2954 .count();
2955 coverage.push(serde_json::json!({
2956 "view": view_name,
2957 "covered": covered,
2958 "total": total,
2959 }));
2960 }
2961 }
2962 let payload = serde_json::json!({
2963 "hash": hash.to_base32(),
2964 "attestation": attest,
2965 "coverage": coverage,
2966 });
2967 serde_json::to_vec(&payload)
2968 .map(|payload| VersionedBytes {
2969 schema: "atomic.attestation.detail.v1".to_string(),
2970 payload,
2971 })
2972 .map_err(|error| Status::internal(error.to_string()))
2973}
2974
2975pub struct AttestationImpl {
2976 pub state: Arc<DaemonState>,

Callers 1

list_attestationsMethod · 0.85

Calls 8

covers_changeMethod · 0.80
list_viewsMethod · 0.45
logMethod · 0.45
viewMethod · 0.45
lenMethod · 0.45
countMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected