use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum RejectReason {
#[error("candidate is malformed: {0}")]
Malformed(String),
#[error("profile mismatch on {artifact}: expected {expected}, got {got}")]
ProfileMismatch {
artifact: &'static str,
expected: String,
got: String,
},
#[error("settled continuity must carry transitions = null")]
SettledCarriesTransitions,
#[error("candidate continuity must carry exactly one transition, got {0}")]
TransitionCount(usize),
#[error("proof_of_relationship.type not accepted: {0}")]
PorType(String),
#[error("proof of relationship rejected: {0}")]
PorRejected(String),
#[error("workload signature invalid on {0}")]
WorkloadSignature(&'static str),
#[error("root.pca is not the currently trusted checkpoint")]
UntrustedCheckpoint,
#[error("root.pca_hash does not match SHA-256 of the exact root.pca bytes")]
PcaHashMismatch,
#[error("predecessor.type must be \"pca\"")]
PredecessorType,
#[error("predecessor.hash does not match the trusted checkpoint bytes")]
PredecessorHashMismatch,
#[error("transition.position must equal checkpoint position + 1")]
PositionProgression,
#[error("previous_challenge does not match the checkpoint next_challenge")]
ChallengeContinuity,
#[error("next_challenge is missing or empty")]
NextChallengeInvalid,
#[error("remove bitmap references a nonexistent index in section {0}")]
BitmapIndexOutOfRange(&'static str),
#[error("remove bitmap is not canonical (empty or trailing zero bytes)")]
BitmapNotCanonical,
#[error("duplicate execution-contract addition key: {0}")]
DuplicateAdditionKey(String),
#[error("invalid authority value for key {0}")]
InvalidAuthorityValue(String),
#[error("execution contract must contain at least one attribute")]
EmptyExecutionContract,
#[error("request/execution binding rejected")]
RequestBinding,
#[error("executor evidence / execution-contract conformance rejected")]
ContractConformance,
#[error("authority non-expansion violated")]
NonExpansion,
#[error("continuity state is revoked")]
Revoked,
#[error("local policy denied the advancement")]
PolicyDenied,
#[error("settlement-authority signature invalid on {0}")]
RealmSignature(&'static str),
}
#[derive(Debug, Error)]
pub enum ContinuityError {
#[error(transparent)]
Reject(#[from] RejectReason),
#[error("COSE error: {0}")]
Cose(#[from] crate::cose::CoseError),
#[error("CBOR encoding failed: {0}")]
Cbor(String),
#[error("JSON error: {0}")]
Json(String),
#[error("JWS error: {0}")]
Jws(String),
}