Skip to main content

HmsCore

Struct HmsCore 

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

Lock ordering: ShardSet (read) -> Shard.vectors -> Shard.ivf -> Shard.nsg. Arena lock is independent (managed internally by PersistentArena).

Implementations§

Source§

impl HmsCore

Source

pub fn synthesize_concepts(&self) -> Vec<ConceptCandidate>

Cluster similar vectors and return concept candidates with centroids and coherence scores.

Source§

impl HmsCore

Source

pub fn memorize_triplet( &self, id: String, h: String, r: String, t: String, ) -> Result<()>

Encode a (head, relation, tail) triplet as h XOR r XOR t and memorize it.

Source

pub fn memorize_sequence(&self, id: String, sequence: &[String]) -> Result<()>

Encode an ordered sequence using position-based permutation and memorize it.

Source

pub fn query_triplet( &self, h: String, r: String, k: u32, ) -> Result<Vec<RetrievalResult>>

Query for tails matching head XOR relation.

Source

pub fn find_analogy( &self, a: &str, b: &str, c: &str, k: u32, ) -> Vec<RetrievalResult>

Find analogy: A is to B as C is to ? Returns k closest matches.

Source

pub fn query_sequence( &self, partial: &[String], k: u32, ) -> Result<Vec<RetrievalResult>>

Query for sequences matching a partial sequence prefix.

Source§

impl HmsCore

Source

pub fn query(&self, query_vec: &EntangledHVec, k: u32) -> Vec<RetrievalResult>

Query the memory system for the k most similar vectors.

Source

pub fn query_batch( &self, queries: &[EntangledHVec], k: u32, ) -> Vec<Vec<RetrievalResult>>

Process multiple queries in parallel using rayon.

Source

pub fn analyze_components(&self, vector: &EntangledHVec) -> Vec<RetrievalResult>

Analyze components of a vector by finding its nearest neighbors. Filters by similarity threshold from QueryConfig (default 0.05).

Source§

impl HmsCore

Source

pub fn new( dimensions: u32, storage_path: Option<String>, config: Option<HmsConfig>, ) -> Result<Self>

Create a new HMS instance. If storage_path is None, uses the current directory.

Source

pub fn bundle<V: Borrow<EntangledHVec>>(&self, vectors: &[V]) -> EntangledHVec

Bundle vectors respecting the PrivacyConfig. When dp_enabled, uses Laplace noise with the configured epsilon.

Source

pub fn dimensions(&self) -> usize

Returns the dimensionality of the hypervector space.

Source

pub fn encode_text(&self, text: &str) -> EntangledHVec

Encode text into a sparse hypervector using character trigrams.

Source

pub fn analyze_text(&self, text: &str) -> TextMetrics

Compute word, sentence, syllable, and character-class counts for text.

Source

pub fn calculate_readability(&self, metrics: &TextMetrics) -> f64

Compute Flesch Reading Ease score from text metrics.

Source

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

Delete a vector by ID. Returns true if it existed. Crash-safe: tombstone is persisted first.

Source

pub fn memorize_meaning(&self, id: &str, text: &str) -> Result<()>

Source

pub fn compact(&self) -> Result<()>

Compact the arena log by rewriting only live vectors. Blocks all writes during compaction.

Source

pub fn memorize(&self, id: String, vector: EntangledHVec) -> Result<()>

Store a vector with the given ID. Persists to the arena log and updates all indices.

Source

pub fn memorize_vector(&self, id: String, dense: &[f32]) -> Result<()>

Convert a dense f32 vector to sparse and memorize it.

Source

pub fn memorize_scalar( &self, id: String, value: f64, min: f64, max: f64, ) -> Result<()>

Encode a bounded scalar value as a hypervector and memorize it.

Source

pub fn vector_count(&self) -> u64

Returns the total number of stored vectors across all shards.

Source

pub fn add_relation(&self, rel: &Relation) -> Result<()>

Source

pub fn remove_relation( &self, source_id: &str, relation_type: &str, target_id: &str, ) -> bool

Source

pub fn declare_relation_type(&self, rel_type: RelationType)

Source

pub fn traverse( &self, start_id: &str, relation_type: Option<&str>, max_depth: u32, at_time: f64, ) -> Vec<GraphPath>

Source

pub fn outgoing_relations( &self, source_id: &str, relation_type: Option<&str>, at_time: f64, ) -> Vec<Relation>

Source

pub fn incoming_relations( &self, target_id: &str, relation_type: Option<&str>, at_time: f64, ) -> Vec<Relation>

Source

pub fn relation_count(&self) -> usize

Source

pub fn federated_query( &self, peer_paths: &[String], query_vec: &EntangledHVec, k: u32, ) -> Result<Vec<RetrievalResult>>

Source

pub fn structural_query( &self, known: &[(&str, &EntangledHVec)], target_role: &str, ) -> Vec<StructuralResult>

Source

pub fn multi_hop(&self, start: &str, relations: &[&str]) -> Vec<MultiHopResult>

Source

pub fn meaning_cleanup(&self, noisy: &EntangledHVec) -> Option<(String, f64)>

Source

pub fn declare_rule( &self, name: &str, input_relations: Vec<String>, output_relation: String, )

Source

pub fn meaning_enabled(&self) -> bool

Source

pub fn meaning_atom_count(&self) -> usize

Source

pub fn meaning_composite_count(&self) -> usize

Source

pub fn meaning_triple_count(&self) -> usize

Source

pub fn meaning_rule_count(&self) -> usize

Source

pub fn register_role(&mut self, name: &str, shift: usize) -> Result<()>

Source

pub fn start_cognition(&self) -> Result<()>

Source

pub fn stop_cognition(&self)

Source

pub fn cognition_running(&self) -> bool

Source

pub fn cognition_cycle_count(&self) -> u64

Source

pub fn take_insights(&self) -> Vec<Insight>

Source

pub fn cognition_insight_count(&self) -> usize

Source

pub fn run_cognition_once(&self) -> Vec<Insight>

Source

pub fn govern_memory(&self) -> GovernanceReport

Source

pub fn cognition_enabled(&self) -> bool

Source

pub fn ivf_trained(&self) -> bool

Returns true if the IVF index has been trained.

Source

pub fn train_ivf(&self) -> Result<()>

Train the IVF index on current vectors. Persists the index to disk.

Source

pub fn nsg_trained(&self) -> bool

Returns true if the NSG graph index has been trained.

Source

pub fn train_nsg(&self) -> Result<()>

Train the NSG graph index on current vectors. Persists the index to disk.

Source

pub fn audit_since(&self, timestamp_ms: u64) -> Result<Vec<AuditEntry>>

Query the audit log for entries since timestamp_ms. Returns an empty vec if audit logging is disabled.

Source

pub fn factorize_diffusion( &self, product: &EntangledHVec, domain_codebooks: &[Vec<EntangledHVec>], max_iter: usize, ) -> Vec<Option<EntangledHVec>>

Decompose a product vector into factors from domain codebooks using diffusion.

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V