pub struct ProviderRegistry { /* private fields */ }Expand description
Thread-safe registry of loaded providers backing every Soma surface, holding the active snapshot and supporting hot-reload from a file source.
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub async fn read_resource(
&self,
uri: &str,
principal: &ProviderPrincipal,
auth_mode: ProviderAuthMode,
) -> Result<ResourceReadOutput, ProviderError>
pub async fn read_resource( &self, uri: &str, principal: &ProviderPrincipal, auth_mode: ProviderAuthMode, ) -> Result<ResourceReadOutput, ProviderError>
Matches uri against the active snapshot’s exact resources and
dynamic resource templates (in that precedence order), enforces
resource.scope under ProviderAuthMode::Mounted the same way
dispatch() enforces tool.scope, then delegates to the owning
provider’s read_resource.
The match and the provider clone are fetched from the same read
lock acquisition, mirroring dispatch()’s pattern for tools — a
concurrent refresh_file_providers() between two separate lock
acquisitions could otherwise return params/scope from one snapshot
but a provider instance from a newer one (e.g. a hot-swapped
resources/foo.md -> resources/foo.ts letting a request matched
against the old unscoped static resource invoke the new
soma:write-scoped dynamic reader without ever being checked
against its scope).
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn new(
providers: Vec<Arc<dyn Provider>>,
) -> Result<Self, ProviderValidationError>
pub fn new( providers: Vec<Arc<dyn Provider>>, ) -> Result<Self, ProviderValidationError>
Builds a registry from the given providers with a default-deny capability broker.
Sourcepub fn with_capabilities(
providers: Vec<Arc<dyn Provider>>,
capabilities: CapabilityBroker,
) -> Result<Self, ProviderValidationError>
pub fn with_capabilities( providers: Vec<Arc<dyn Provider>>, capabilities: CapabilityBroker, ) -> Result<Self, ProviderValidationError>
Builds a registry from the given providers and capability broker.
Sourcepub fn with_file_source(
providers: Vec<Arc<dyn Provider>>,
capabilities: CapabilityBroker,
file_source: FileProviderSource,
) -> Result<Self, ProviderValidationError>
pub fn with_file_source( providers: Vec<Arc<dyn Provider>>, capabilities: CapabilityBroker, file_source: FileProviderSource, ) -> Result<Self, ProviderValidationError>
Builds a registry from the given base providers plus dynamic providers loaded from a file source, enabling later hot-reloads.
Sourcepub fn snapshot(&self) -> Arc<RegistrySnapshot>
pub fn snapshot(&self) -> Arc<RegistrySnapshot>
Returns the currently active registry snapshot.
Sourcepub fn refresh_file_providers(
&self,
) -> Result<Arc<RegistrySnapshot>, ProviderValidationError>
pub fn refresh_file_providers( &self, ) -> Result<Arc<RegistrySnapshot>, ProviderValidationError>
Refreshes providers from the file source, if any. Per the drop-in
provider layout contract (“If a resource disappears or becomes
invalid, a reload must leave the last valid snapshot active until a
valid replacement snapshot is available”), a failure anywhere in this
pipeline (an unreadable directory, a newly-invalid or colliding
provider file) is logged and this returns the previous snapshot
rather than propagating the error — one bad drop-in file must not
take down list_tools/list_prompts/read_resource/etc. for every
other, unrelated, already-loaded provider.
Sourcepub fn validate_reload(
&self,
providers: Vec<Arc<dyn Provider>>,
) -> Result<Arc<RegistrySnapshot>, ProviderValidationError>
pub fn validate_reload( &self, providers: Vec<Arc<dyn Provider>>, ) -> Result<Arc<RegistrySnapshot>, ProviderValidationError>
Builds and validates a snapshot from the given providers without installing it, for pre-flight checking a candidate reload.
Sourcepub fn reload(
&self,
providers: Vec<Arc<dyn Provider>>,
) -> Result<Arc<RegistrySnapshot>, ProviderValidationError>
pub fn reload( &self, providers: Vec<Arc<dyn Provider>>, ) -> Result<Arc<RegistrySnapshot>, ProviderValidationError>
Atomically replaces the loaded providers and active snapshot, clearing any file fingerprint.
Sourcepub async fn dispatch(
&self,
call: ProviderCall,
) -> Result<ProviderOutput, ProviderError>
pub async fn dispatch( &self, call: ProviderCall, ) -> Result<ProviderOutput, ProviderError>
Routes a provider call to its owning provider, enforcing pre-input
checks, declared capabilities, and the response size limit around the
provider’s own call.
Trait Implementations§
Source§impl Clone for ProviderRegistry
impl Clone for ProviderRegistry
Source§fn clone(&self) -> ProviderRegistry
fn clone(&self) -> ProviderRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ProviderRegistry
impl !RefUnwindSafe for ProviderRegistry
impl Send for ProviderRegistry
impl Sync for ProviderRegistry
impl Unpin for ProviderRegistry
impl UnsafeUnpin for ProviderRegistry
impl !UnwindSafe for ProviderRegistry
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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