Skip to main content

ModelRegistry

Struct ModelRegistry 

Source
pub struct ModelRegistry { /* private fields */ }
Expand description

Adopted models, persisted as JSON when opened on a path.

Implementations§

Source§

impl ModelRegistry

Source

pub fn in_memory() -> Self

A registry that is not persisted.

Source

pub fn with_trust(self, trust: ModelTrust) -> Self

Set what resolve verifies against.

Source

pub fn set_trust(&self, trust: ModelTrust)

Replace the trust (a key was pinned or removed, a revocation list was swapped). Takes effect on the next resolve.

Source

pub fn open(path: impl Into<PathBuf>) -> Result<Self, ModelError>

Open (or start) the registry file at path.

Source

pub fn adopt( &self, scanned: ScannedModel, key: &SigningKey, key_id: &str, anchors: &TrustAnchors, replace: bool, ) -> Result<AdoptedModel, ModelError>

Attest a scanned model with the operator key and register it. The key must be pinned in anchors, otherwise the attestation does not verify and nothing is registered. A different manifest under an existing name is refused unless replace is set.

Source

pub fn attach( &self, envelope: &ManifestEnvelope, root: &Path, anchors: &TrustAnchors, replace: bool, ) -> Result<AdoptedModel, ModelError>

Register an already-attested manifest (for example one fetched from another node) whose files lie under root. Its signature is checked against anchors; file hashes are checked lazily on first use.

Source

pub fn remove(&self, id_or_name: &str) -> Result<(), ModelError>

Forget a model (files are untouched).

Source

pub fn entries(&self) -> Vec<(String, ModelEntry)>

Snapshot of every entry, keyed by package id.

Source

pub fn get(&self, id_or_name: &str) -> Result<(String, ModelEntry), ModelError>

One entry by package id or name.

Source

pub fn check( &self, id_or_name: &str, mode: CheckMode, ) -> Result<ModelCheck, ModelError>

Check a model’s files.

Source§

impl ModelRegistry

Source

pub fn set_advertised( &self, id_or_name: &str, advertised: bool, ) -> Result<(), ModelError>

Hide or advertise a model in node facts (local, unsigned opt-out: shard hashes fingerprint which models this node holds).

Source

pub fn resolve(&self, id_or_name: &str) -> Result<ResolvedModel, ModelError>

The model for an adapter to load, verified against the registry’s trust (see with_trust); refused with ModelError::NotReady when none is set.

What a caller may rely on when this returns Ok:

  • the attestation verifies against the pinned anchors now, and the package, its signers and its shard hashes are not revoked;
  • the registry’s file list equals the attested body;
  • every file resolves inside the model root (or its HF blobs/), and the returned paths are those resolved locations;
  • the first resolve of a model in this process hashed every byte (a full check, which on a 45 GB model takes minutes); later resolves re-hash only files whose size or mtime changed.

The lazy window: after the first resolve, a file replaced with the same size and the same mtime is not noticed until the next process start or an explicit CheckMode::Full check. Adapters that must close that window call check(.., CheckMode::Full) before loading. Paths are returned, not handles: a file can still change between this call and the adapter opening it.

Source

pub fn resolve_with( &self, id_or_name: &str, trust: &ModelTrust, ) -> Result<ResolvedModel, ModelError>

resolve against an explicit trust (the sharing gate passes the anchors the caller holds right now).

Trait Implementations§

Source§

impl Debug for ModelRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more