Skip to main content

RegistryStore

Struct RegistryStore 

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

SQLite-backed registry store.

Thread-safe via internal Mutex<Connection> — registry operations are short-lived and infrequent so contention is negligible.

Implementations§

Source§

impl RegistryStore

Source

pub fn open(data_dir: &Path) -> Result<Self>

Opens (or creates) the registry database at <data_dir>/registry.db.

On first run (empty database), seeds the cache from the embedded registry snapshot so the provider catalog is immediately available without a network fetch.

If an existing database is unreadable (corrupt file, truncated WAL/SHM, or SQLite disk I/O errors on open), the broken files are removed and a fresh cache is recreated from the embedded snapshot. Callers that need the remote catalog should follow up with sync_registry.

Source

pub fn meta_get(&self, key: &str) -> Result<Option<String>>

Returns the value of a metadata key, or None.

Source

pub fn meta_set(&self, key: &str, value: &str) -> Result<()>

Sets a metadata key-value pair (upsert).

Source

pub fn is_empty(&self) -> Result<bool>

Returns true if the providers table is empty.

Source

pub fn provider_count(&self) -> Result<usize>

Returns the number of providers in the cache.

Source

pub fn model_count(&self) -> Result<usize>

Returns the total number of models across all providers.

Source

pub fn provider_sha256(&self, provider_id: &str) -> Result<Option<String>>

Returns the stored SHA-256 hash for a provider, or None.

Source

pub fn provider_ids(&self) -> Result<HashSet<String>>

Returns the set of provider ids currently in the cache.

Source

pub fn load_provider_models( &self, provider_id: &str, ) -> Result<HashMap<String, RegistryModel>>

Loads existing models for a provider from the cache, keyed by model name. Used by aggregator sync to preserve metadata (context_window, etc) for models that the API returns without rich metadata.

Source

pub fn delete_providers_not_in(&self, keep: &HashSet<&str>) -> Result<()>

Deletes providers that are not in the given set of ids. Used during sync to remove providers that were deleted from the remote registry.

Source

pub fn upsert_provider(&self, provider: &RegistryProvider) -> Result<()>

Upserts a provider and its models from a RegistryProvider.

Source

pub fn upsert_transcription_provider( &self, provider: &RegistryTranscriptionProvider, sha256: Option<&str>, ) -> Result<()>

Upserts a remote transcription provider (stored as JSON for simplicity).

Source

pub fn transcription_provider_sha256(&self, id: &str) -> Result<Option<String>>

SHA-256 of a cached transcription provider, if known.

Source

pub fn load_transcription_providers( &self, ) -> Result<Vec<RegistryTranscriptionProvider>>

Loads all cached transcription providers.

Source

pub fn delete_transcription_providers_not_in( &self, keep: &HashSet<&str>, ) -> Result<()>

Deletes transcription providers not in keep.

Source

pub fn upsert_canonical_model( &self, id: &str, model: &CanonicalModel, sha256: Option<&str>, ) -> Result<()>

Upserts a canonical model JSON blob with its integrity hash.

Source

pub fn canonical_model_sha256(&self, id: &str) -> Result<Option<String>>

Returns the SHA-256 of a cached canonical model, if any.

Source

pub fn load_canonical_model_catalog(&self) -> Result<ModelCatalog>

Loads the full canonical model catalog from the cache.

Source

pub fn delete_canonical_models_not_in(&self, keep: &HashSet<&str>) -> Result<()>

Deletes canonical models not present in keep.

Source

pub fn canonical_model_count(&self) -> Result<usize>

Number of cached canonical models.

Source

pub fn transcription_provider_count(&self) -> Result<usize>

Number of cached transcription providers.

Source

pub fn seed_transcription_from_embedded_if_empty(&self) -> Result<()>

Seeds the transcription cache from the embedded snapshot when empty.

Source

pub fn upsert_provider_union_models( &self, provider: &RegistryProvider, sha256: Option<&str>, ) -> Result<()>

Upserts a provider while preserving any local models that are not in provider.models.

Used by embedded/remote registry updates so a smaller catalog snapshot cannot wipe models discovered via sync models / provider /models. Incoming models win on name conflicts (refresh metadata); local-only names are kept.

Source

pub fn rehydrate_provider_models_from_catalog(&self) -> Result<usize>

Re-apply canonical model catalog metadata onto every cached provider model.

Fixes stale rows written by API sync sibling inheritance (e.g. grok-4.5 wrongly holding grok-4.3’s 1M context / low+high efforts) without wiping API-discovered model names or changing provider sha256 markers.

Returns the number of model rows touched by the UPDATE.

Source

pub fn upsert_provider_with_sha256( &self, provider: &RegistryProvider, sha256: Option<&str>, ) -> Result<()>

Upserts a provider with its SHA-256 hash for diff-based sync.

Source

pub fn load_all_providers(&self) -> Result<Vec<ProviderConfig>>

Loads all providers from the cache as ProviderConfig values compatible with the existing catalog.

Source

pub fn replace_all(&self, providers: &[RegistryProvider]) -> Result<()>

Replaces the entire cache with the given providers (full refresh).

Source

pub fn save_manifest_meta(&self, manifest: &RegistryManifest) -> Result<()>

Saves the manifest metadata.

Source

pub fn manifest_version(&self) -> Result<Option<u32>>

Returns the stored manifest version, if any.

Source

pub fn manifest_updated_at(&self) -> Result<Option<String>>

Returns the stored manifest updated_at, if any.

Source

pub fn upsert_capabilities( &self, model_id: &str, provider_id: &str, capabilities: &[(String, String)], ) -> Result<()>

Upserts capabilities for a model. Replaces all existing capabilities for that model.

Source

pub fn load_capabilities(&self, model_id: &str) -> Result<Vec<ModelCapability>>

Loads all capabilities for a model.

Source

pub fn upsert_pricing( &self, model_id: &str, provider_id: &str, input_price: Option<f64>, output_price: Option<f64>, ) -> Result<()>

Upserts pricing for a model.

Source

pub fn load_pricing(&self, model_id: &str) -> Result<Option<ModelPricing>>

Loads pricing for a model.

Source

pub fn upsert_profile(&self, profile: &Profile) -> Result<()>

Upserts a profile definition.

Source

pub fn upsert_model_profile( &self, model_id: &str, provider_id: &str, profile_id: &str, score: f64, ) -> Result<()>

Upserts a model-profile association.

Source

pub fn query_models_by_profile( &self, profile_id: &str, ) -> Result<Vec<RankedModel>>

Queries for models matching a profile, ranked by score and price.

Returns models that satisfy the profile’s constraints (min context, max price, tool support) ordered by score descending, then input price ascending.

Source

pub fn seed_default_profiles(&self) -> Result<()>

Seeds the default built-in profile definitions.

Source

pub fn delete_provider_metadata(&self, provider_id: &str) -> Result<()>

Deletes all capabilities, pricing, and model-profile entries for a provider.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> MaybeSend for T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<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