pub struct EntityResolver<'a> { /* private fields */ }Implementations§
Source§impl<'a> EntityResolver<'a>
impl<'a> EntityResolver<'a>
pub fn new(store: &'a GraphStore) -> Self
pub fn with_embedding_store(self, store: &'a Arc<EmbeddingStore>) -> Self
pub fn with_provider(self, provider: &'a AnyProvider) -> Self
pub fn with_thresholds(self, similarity: f32, ambiguous: f32) -> Self
Sourcepub fn fallback_count(&self) -> Arc<AtomicU64> ⓘ
pub fn fallback_count(&self) -> Arc<AtomicU64> ⓘ
Shared fallback counter — tests can clone this Arc to inspect the value.
Sourcepub async fn resolve(
&self,
name: &str,
entity_type: &str,
summary: Option<&str>,
) -> Result<(i64, ResolutionOutcome), MemoryError>
pub async fn resolve( &self, name: &str, entity_type: &str, summary: Option<&str>, ) -> Result<(i64, ResolutionOutcome), MemoryError>
Resolve an extracted entity using the alias-first canonicalization pipeline.
Pipeline:
- Normalize: trim, lowercase, strip control chars, truncate to 512 bytes.
- Parse entity type (fallback to Concept on unknown).
- Alias lookup: search
graph_entity_aliasesby normalized name +entity_type. If found, touchlast_seen_atand return the existing entity id. - Canonical name lookup: search
graph_entitiesbycanonical_name+entity_type. If found, touchlast_seen_atand return the existing entity id. - When
embedding_storeandproviderare configured, performs embedding-based fuzzy matching: cosine similarity search (Qdrant), LLM disambiguation for ambiguous range, merge or create based on result. Failures degrade gracefully to step 6. - Create: upsert new entity with
canonical_name= normalized name. - Register the normalized form (and original trimmed form if different) as aliases.
§Errors
Returns an error if the entity name is empty after normalization, or if a DB operation fails.
Sourcepub async fn resolve_batch(
&self,
entities: &[ExtractedEntity],
) -> Result<Vec<(i64, ResolutionOutcome)>, MemoryError>
pub async fn resolve_batch( &self, entities: &[ExtractedEntity], ) -> Result<Vec<(i64, ResolutionOutcome)>, MemoryError>
Resolve a batch of extracted entities concurrently.
Returns a Vec of (entity_id, ResolutionOutcome) in the same order as input.
§Errors
Returns an error if any DB operation fails.
§Panics
Panics if an internal stream collection bug causes a result index to be missing. This indicates a programming error and should never occur in correct usage.
Sourcepub async fn resolve_edge(
&self,
source_id: i64,
target_id: i64,
relation: &str,
fact: &str,
confidence: f32,
episode_id: Option<MessageId>,
) -> Result<Option<i64>, MemoryError>
pub async fn resolve_edge( &self, source_id: i64, target_id: i64, relation: &str, fact: &str, confidence: f32, episode_id: Option<MessageId>, ) -> Result<Option<i64>, MemoryError>
Resolve an extracted edge: deduplicate or supersede existing edges.
- If an active edge with the same direction and relation exists with an identical fact,
returns
None(deduplicated). - If an active edge with the same direction and relation exists with a different fact,
invalidates the old edge and inserts the new one, returning
Some(new_id). - If no matching edge exists, inserts a new edge and returns
Some(new_id).
Relation and fact strings are sanitized (control chars stripped, length-capped).
§Errors
Returns an error if any database operation fails.
Auto Trait Implementations§
impl<'a> Freeze for EntityResolver<'a>
impl<'a> !RefUnwindSafe for EntityResolver<'a>
impl<'a> Send for EntityResolver<'a>
impl<'a> Sync for EntityResolver<'a>
impl<'a> Unpin for EntityResolver<'a>
impl<'a> UnsafeUnpin for EntityResolver<'a>
impl<'a> !UnwindSafe for EntityResolver<'a>
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request