use std::collections::BTreeMap;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RulesetManifest {
pub bundle_version: String,
pub effective_date: DateTime<Utc>,
#[serde(default)]
pub act_citations: Vec<String>,
#[serde(default)]
pub schema_versions: BTreeMap<String, String>,
pub content_sha256: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SignedBundle {
pub manifest_jws: String,
pub content: serde_json::Value,
}
#[derive(Debug, Clone)]
pub struct VerifiedRuleset {
pub manifest: RulesetManifest,
pub content: serde_json::Value,
}
impl VerifiedRuleset {
#[must_use]
pub fn version(&self) -> &str {
&self.manifest.bundle_version
}
}
#[derive(Debug, thiserror::Error)]
pub enum RulesetError {
#[error("bundle signature invalid or not signed by the pinned publisher key")]
BadSignature,
#[error("bundle content hash mismatch — content does not match the signed manifest")]
ContentHashMismatch,
#[error("malformed bundle: {0}")]
Malformed(String),
}