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
impl RegistryStore
Sourcepub fn open(data_dir: &Path) -> Result<Self>
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.
Sourcepub fn meta_get(&self, key: &str) -> Result<Option<String>>
pub fn meta_get(&self, key: &str) -> Result<Option<String>>
Returns the value of a metadata key, or None.
Sourcepub fn meta_set(&self, key: &str, value: &str) -> Result<()>
pub fn meta_set(&self, key: &str, value: &str) -> Result<()>
Sets a metadata key-value pair (upsert).
Sourcepub fn provider_count(&self) -> Result<usize>
pub fn provider_count(&self) -> Result<usize>
Returns the number of providers in the cache.
Sourcepub fn model_count(&self) -> Result<usize>
pub fn model_count(&self) -> Result<usize>
Returns the total number of models across all providers.
Sourcepub fn provider_sha256(&self, provider_id: &str) -> Result<Option<String>>
pub fn provider_sha256(&self, provider_id: &str) -> Result<Option<String>>
Returns the stored SHA-256 hash for a provider, or None.
Sourcepub fn provider_ids(&self) -> Result<HashSet<String>>
pub fn provider_ids(&self) -> Result<HashSet<String>>
Returns the set of provider ids currently in the cache.
Sourcepub fn load_provider_models(
&self,
provider_id: &str,
) -> Result<HashMap<String, RegistryModel>>
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.
Sourcepub fn delete_providers_not_in(&self, keep: &HashSet<&str>) -> Result<()>
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.
Sourcepub fn upsert_provider(&self, provider: &RegistryProvider) -> Result<()>
pub fn upsert_provider(&self, provider: &RegistryProvider) -> Result<()>
Upserts a provider and its models from a RegistryProvider.
Sourcepub fn upsert_transcription_provider(
&self,
provider: &RegistryTranscriptionProvider,
sha256: Option<&str>,
) -> Result<()>
pub fn upsert_transcription_provider( &self, provider: &RegistryTranscriptionProvider, sha256: Option<&str>, ) -> Result<()>
Upserts a remote transcription provider (stored as JSON for simplicity).
Sourcepub fn transcription_provider_sha256(&self, id: &str) -> Result<Option<String>>
pub fn transcription_provider_sha256(&self, id: &str) -> Result<Option<String>>
SHA-256 of a cached transcription provider, if known.
Sourcepub fn load_transcription_providers(
&self,
) -> Result<Vec<RegistryTranscriptionProvider>>
pub fn load_transcription_providers( &self, ) -> Result<Vec<RegistryTranscriptionProvider>>
Loads all cached transcription providers.
Sourcepub fn delete_transcription_providers_not_in(
&self,
keep: &HashSet<&str>,
) -> Result<()>
pub fn delete_transcription_providers_not_in( &self, keep: &HashSet<&str>, ) -> Result<()>
Deletes transcription providers not in keep.
Sourcepub fn upsert_canonical_model(
&self,
id: &str,
model: &CanonicalModel,
sha256: Option<&str>,
) -> Result<()>
pub fn upsert_canonical_model( &self, id: &str, model: &CanonicalModel, sha256: Option<&str>, ) -> Result<()>
Upserts a canonical model JSON blob with its integrity hash.
Sourcepub fn canonical_model_sha256(&self, id: &str) -> Result<Option<String>>
pub fn canonical_model_sha256(&self, id: &str) -> Result<Option<String>>
Returns the SHA-256 of a cached canonical model, if any.
Sourcepub fn load_canonical_model_catalog(&self) -> Result<ModelCatalog>
pub fn load_canonical_model_catalog(&self) -> Result<ModelCatalog>
Loads the full canonical model catalog from the cache.
Sourcepub fn delete_canonical_models_not_in(&self, keep: &HashSet<&str>) -> Result<()>
pub fn delete_canonical_models_not_in(&self, keep: &HashSet<&str>) -> Result<()>
Deletes canonical models not present in keep.
Sourcepub fn canonical_model_count(&self) -> Result<usize>
pub fn canonical_model_count(&self) -> Result<usize>
Number of cached canonical models.
Sourcepub fn transcription_provider_count(&self) -> Result<usize>
pub fn transcription_provider_count(&self) -> Result<usize>
Number of cached transcription providers.
Sourcepub fn seed_transcription_from_embedded_if_empty(&self) -> Result<()>
pub fn seed_transcription_from_embedded_if_empty(&self) -> Result<()>
Seeds the transcription cache from the embedded snapshot when empty.
Sourcepub fn upsert_provider_union_models(
&self,
provider: &RegistryProvider,
sha256: Option<&str>,
) -> Result<()>
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.
Sourcepub fn rehydrate_provider_models_from_catalog(&self) -> Result<usize>
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.
Sourcepub fn upsert_provider_with_sha256(
&self,
provider: &RegistryProvider,
sha256: Option<&str>,
) -> Result<()>
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.
Sourcepub fn load_all_providers(&self) -> Result<Vec<ProviderConfig>>
pub fn load_all_providers(&self) -> Result<Vec<ProviderConfig>>
Loads all providers from the cache as ProviderConfig values
compatible with the existing catalog.
Sourcepub fn replace_all(&self, providers: &[RegistryProvider]) -> Result<()>
pub fn replace_all(&self, providers: &[RegistryProvider]) -> Result<()>
Replaces the entire cache with the given providers (full refresh).
Sourcepub fn save_manifest_meta(&self, manifest: &RegistryManifest) -> Result<()>
pub fn save_manifest_meta(&self, manifest: &RegistryManifest) -> Result<()>
Saves the manifest metadata.
Sourcepub fn manifest_version(&self) -> Result<Option<u32>>
pub fn manifest_version(&self) -> Result<Option<u32>>
Returns the stored manifest version, if any.
Sourcepub fn manifest_updated_at(&self) -> Result<Option<String>>
pub fn manifest_updated_at(&self) -> Result<Option<String>>
Returns the stored manifest updated_at, if any.
Sourcepub fn upsert_capabilities(
&self,
model_id: &str,
provider_id: &str,
capabilities: &[(String, String)],
) -> Result<()>
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.
Sourcepub fn load_capabilities(&self, model_id: &str) -> Result<Vec<ModelCapability>>
pub fn load_capabilities(&self, model_id: &str) -> Result<Vec<ModelCapability>>
Loads all capabilities for a model.
Sourcepub fn upsert_pricing(
&self,
model_id: &str,
provider_id: &str,
input_price: Option<f64>,
output_price: Option<f64>,
) -> Result<()>
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.
Sourcepub fn load_pricing(&self, model_id: &str) -> Result<Option<ModelPricing>>
pub fn load_pricing(&self, model_id: &str) -> Result<Option<ModelPricing>>
Loads pricing for a model.
Sourcepub fn upsert_profile(&self, profile: &Profile) -> Result<()>
pub fn upsert_profile(&self, profile: &Profile) -> Result<()>
Upserts a profile definition.
Sourcepub fn upsert_model_profile(
&self,
model_id: &str,
provider_id: &str,
profile_id: &str,
score: f64,
) -> Result<()>
pub fn upsert_model_profile( &self, model_id: &str, provider_id: &str, profile_id: &str, score: f64, ) -> Result<()>
Upserts a model-profile association.
Sourcepub fn query_models_by_profile(
&self,
profile_id: &str,
) -> Result<Vec<RankedModel>>
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.
Sourcepub fn seed_default_profiles(&self) -> Result<()>
pub fn seed_default_profiles(&self) -> Result<()>
Seeds the default built-in profile definitions.
Sourcepub fn delete_provider_metadata(&self, provider_id: &str) -> Result<()>
pub fn delete_provider_metadata(&self, provider_id: &str) -> Result<()>
Deletes all capabilities, pricing, and model-profile entries for a provider.
Auto Trait Implementations§
impl !Freeze for RegistryStore
impl RefUnwindSafe for RegistryStore
impl Send for RegistryStore
impl Sync for RegistryStore
impl Unpin for RegistryStore
impl UnsafeUnpin for RegistryStore
impl UnwindSafe for RegistryStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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