Skip to main content

MicroResolve

Struct MicroResolve 

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

Multi-namespace decision engine.

One MicroResolve per application. Get a NamespaceHandle via engine.namespace(id) to operate on a specific namespace.

Connected mode. When MicroResolveConfig::server is Some, the engine pulls each ServerConfig::subscribe namespace from the server on startup and keeps them in sync via a background poll. resolve() calls buffer log entries that are flushed on each tick; correct() pushes corrections to the server inline.

Implementations§

Source§

impl MicroResolve

Source

pub fn new(config: MicroResolveConfig) -> Result<Self, Error>

Create a new MicroResolve instance with the given config.

If config.data_dir is set, every subdirectory is loaded as an existing namespace. Subdirectories whose names begin with _ are skipped (reserved for engine-level metadata).

Source

pub fn namespace(&self, id: &str) -> NamespaceHandle<'_>

Get a handle to a namespace, creating it lazily if missing.

Source

pub fn namespace_with( &self, id: &str, config: NamespaceConfig, ) -> NamespaceHandle<'_>

Get a handle to a namespace, applying explicit per-namespace config. The config replaces any previously-set namespace config.

Source

pub fn namespaces(&self) -> Vec<String>

IDs of all namespaces currently loaded into the engine.

Source

pub fn has_namespace(&self, id: &str) -> bool

Whether a namespace currently exists in the engine.

Source

pub fn try_namespace(&self, id: &str) -> Option<NamespaceHandle<'_>>

Get a handle to a namespace only if it already exists (no lazy create, unlike MicroResolve::namespace).

Source

pub fn remove_namespace(&self, id: &str) -> bool

Drop a namespace from the engine. Does not delete its data on disk.

Source

pub fn reload_namespace(&self, id: &str) -> Result<bool, Error>

Reload a namespace from data_dir/{id}, replacing any in-memory state.

Returns Ok(true) if a directory existed and was loaded, Ok(false) if no directory exists for that namespace (caller may want to drop the in-memory entry). Errors only when the directory exists but is corrupt or unreadable.

Source

pub fn flush(&self) -> Result<(), Error>

Flush all dirty namespaces to disk. No-op if data_dir is unset.

Source

pub fn config(&self) -> &MicroResolveConfig

The engine’s config (read-only view).

Source

pub fn resolve_threshold_for(&self, ns_id: &str) -> f32

Effective resolve threshold for a namespace (cascade: namespace → engine).

Source

pub fn languages_for(&self, ns_id: &str) -> Vec<String>

Effective language list for a namespace.

Source

pub fn llm_model_for(&self, ns_id: &str) -> Option<String>

Effective LLM model for a namespace, or None if no LLM is configured.

Trait Implementations§

Source§

impl Drop for MicroResolve

Source§

fn drop(&mut self)

Best-effort flush on drop. Errors are swallowed (callers who care about flush failures should call flush() explicitly).

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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