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
impl MicroResolve
Sourcepub fn new(config: MicroResolveConfig) -> Result<Self, Error>
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).
Sourcepub fn namespace(&self, id: &str) -> NamespaceHandle<'_>
pub fn namespace(&self, id: &str) -> NamespaceHandle<'_>
Get a handle to a namespace, creating it lazily if missing.
Sourcepub fn namespace_with(
&self,
id: &str,
config: NamespaceConfig,
) -> NamespaceHandle<'_>
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.
Sourcepub fn namespaces(&self) -> Vec<String>
pub fn namespaces(&self) -> Vec<String>
IDs of all namespaces currently loaded into the engine.
Sourcepub fn has_namespace(&self, id: &str) -> bool
pub fn has_namespace(&self, id: &str) -> bool
Whether a namespace currently exists in the engine.
Sourcepub fn try_namespace(&self, id: &str) -> Option<NamespaceHandle<'_>>
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).
Sourcepub fn remove_namespace(&self, id: &str) -> bool
pub fn remove_namespace(&self, id: &str) -> bool
Drop a namespace from the engine. Does not delete its data on disk.
Sourcepub fn reload_namespace(&self, id: &str) -> Result<bool, Error>
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.
Sourcepub fn flush(&self) -> Result<(), Error>
pub fn flush(&self) -> Result<(), Error>
Flush all dirty namespaces to disk. No-op if data_dir is unset.
Sourcepub fn config(&self) -> &MicroResolveConfig
pub fn config(&self) -> &MicroResolveConfig
The engine’s config (read-only view).
Sourcepub fn resolve_threshold_for(&self, ns_id: &str) -> f32
pub fn resolve_threshold_for(&self, ns_id: &str) -> f32
Effective resolve threshold for a namespace (cascade: namespace → engine).
Sourcepub fn languages_for(&self, ns_id: &str) -> Vec<String>
pub fn languages_for(&self, ns_id: &str) -> Vec<String>
Effective language list for a namespace.
Sourcepub fn llm_model_for(&self, ns_id: &str) -> Option<String>
pub fn llm_model_for(&self, ns_id: &str) -> Option<String>
Effective LLM model for a namespace, or None if no LLM is configured.