chio_weights/lib.rs
1//! Chio model-card surface.
2//!
3//! Signed model cards bind a provider's
4//! `(weights_hash, allowed_capability_set, banned_tools, training_data_class)`
5//! to a cosign-signed envelope. The kernel refuses to bind a provider whose
6//! loaded weights or requested scopes do not match the card.
7//!
8//! # Trust boundary
9//!
10//! Every public method that produces an `Ok(_)` result MUST mean the call
11//! satisfied the named precondition fully. There is no path through this
12//! crate that returns `Ok(_)` on a partial verification: bad inputs return
13//! typed error variants that carry stable `urn:chio:error:weights:*` codes
14//! from the workspace error-code registry.
15//!
16//! # Crate surface
17//!
18//! - `card` -- model card schema and the `ModelCard` type with RFC 8785
19//! canonical-JSON encoding.
20//! - `bundle` -- cosign bundle helper that consumes
21//! [`chio_attest_verify::SigstoreVerifier::verify_bundle`].
22//! - `lineage` -- lineage-anchor proof helpers for published model cards.
23//!
24//! The kernel binding refusal and `chio bind --card` CLI consume this
25//! surface from `chio-kernel` and `chio-cli` respectively.
26//!
27//! # Forbidden constructs
28//!
29//! No verifier or trust-boundary stubs: this crate forbids `unsafe`,
30//! `unwrap`, and `expect` at the lint level.
31
32#![forbid(unsafe_code)]
33#![forbid(clippy::unwrap_used)]
34#![forbid(clippy::expect_used)]
35
36pub mod bundle;
37pub mod card;
38pub mod error;
39pub mod lineage;
40
41#[cfg(kani)]
42mod kani_public_harnesses;
43
44pub use bundle::{verify_model_card_bundle, VerifiedModelCard};
45pub use card::{weights_hash_of, ModelCard, StringSet, CARD_VERSION_V1};
46pub use error::WeightsError;
47pub use lineage::{
48 anchor_model_card, verify_model_card_anchor, ModelCardLineageAnchor, MODEL_CARD_ANCHOR_SCHEMA,
49};