pub struct ModelCard {
pub card_version: String,
pub weights_hash: String,
pub allowed_capability_set: StringSet,
pub banned_tools: StringSet,
pub training_data_class: String,
pub issuer: String,
pub issued_at: DateTime<Utc>,
pub expires_at: DateTime<Utc>,
}Expand description
Signed declaration binding a model’s loaded weights to a permitted capability set, banned tools, and a training-data class.
Schema locked at spec/schemas/model-card.v1.json. Canonical-JSON
encoding (RFC 8785 / JCS) is the on-the-wire byte form that cosign
signatures are taken over; the serde field declaration order is
therefore irrelevant to the hashed bytes.
Fields§
§card_version: StringSchema version. MUST be CARD_VERSION_V1 for v1 cards; any other
value rejects at validation.
weights_hash: StringLowercase 64-character hexadecimal SHA-256 digest of the canonical weights blob.
allowed_capability_set: StringSetCapability scopes the kernel is permitted to grant against a provider bound under this card.
banned_tools: StringSetTool identifiers the kernel MUST NOT route to under this card.
training_data_class: StringCoarse-grained training-data classification (free-form).
issuer: StringLogical issuer identity (URI / OIDC subject / SAN).
issued_at: DateTime<Utc>RFC 3339 UTC timestamp at which the issuer minted this card.
expires_at: DateTime<Utc>RFC 3339 UTC timestamp at which this card expires.
Implementations§
Source§impl ModelCard
impl ModelCard
Sourcepub fn new(
weights_hash: impl Into<String>,
allowed_capability_set: StringSet,
banned_tools: StringSet,
training_data_class: impl Into<String>,
issuer: impl Into<String>,
issued_at: DateTime<Utc>,
expires_at: DateTime<Utc>,
) -> Result<Self, WeightsError>
pub fn new( weights_hash: impl Into<String>, allowed_capability_set: StringSet, banned_tools: StringSet, training_data_class: impl Into<String>, issuer: impl Into<String>, issued_at: DateTime<Utc>, expires_at: DateTime<Utc>, ) -> Result<Self, WeightsError>
Build a v1 model card. Performs structural validation; returns a
WeightsError if any required invariant is violated.
Validated invariants:
weights_hashis a 64-character lowercase hexadecimal string.training_data_classis non-empty.issueris non-empty.expires_at >= issued_at.
Sourcepub fn validate(&self) -> Result<(), WeightsError>
pub fn validate(&self) -> Result<(), WeightsError>
Re-run structural validation. Called by Self::new and exposed for
post-deserialisation use.
Sourcepub fn require_live(&self, now: DateTime<Utc>) -> Result<(), WeightsError>
pub fn require_live(&self, now: DateTime<Utc>) -> Result<(), WeightsError>
Verifier-side liveness check.
Sourcepub fn to_canonical_json(&self) -> Result<Vec<u8>, WeightsError>
pub fn to_canonical_json(&self) -> Result<Vec<u8>, WeightsError>
Encode to canonical JSON bytes (RFC 8785 / JCS). Deterministic across any compliant implementation.
Sourcepub fn from_canonical_json(bytes: &[u8]) -> Result<Self, WeightsError>
pub fn from_canonical_json(bytes: &[u8]) -> Result<Self, WeightsError>
Decode from canonical JSON bytes. Round-trip with
Self::to_canonical_json. Validates after deserialisation.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ModelCard
impl<'de> Deserialize<'de> for ModelCard
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ModelCard
impl StructuralPartialEq for ModelCard
Auto Trait Implementations§
impl Freeze for ModelCard
impl RefUnwindSafe for ModelCard
impl Send for ModelCard
impl Sync for ModelCard
impl Unpin for ModelCard
impl UnsafeUnpin for ModelCard
impl UnwindSafe for ModelCard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more