Skip to main content

SurrealStore

Struct SurrealStore 

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

A SurrealDB-backed Store.

Implementations§

Source§

impl SurrealStore

Source

pub async fn open_embedded() -> Result<Self>

Opens an in-memory embedded store (the Mem engine), with no embedder. Use for tests; data does not survive restart.

§Errors

Returns IjimaError::Store if SurrealDB cannot initialize.

Source

pub async fn open_embedded_with(embedder: Arc<dyn Embedder>) -> Result<Self>

Opens an in-memory embedded store with an Embedder.

§Errors

Returns IjimaError::Store if SurrealDB cannot initialize.

Source

pub async fn open_persistent(path: impl AsRef<Path>) -> Result<Self>

Opens a persistent store (the SurrealKv engine) at path, with no embedder. Data survives restart. Creates the directory if absent.

§Locking (surrealdb 3)

The engine holds a directory LOCK file while open. Dropping the store handle does not release it synchronously — the datastore’s background tasks must wind down first (a task boundary + yield). Cross-process restarts are unaffected (the OS releases the lock at process exit); same-process sequential reopens of the same path need the spawn-and-yield pattern (see the persistence test).

§Errors

Returns IjimaError::Store if SurrealDB cannot initialize or the path is unwritable.

Source

pub async fn open_persistent_with( path: impl AsRef<Path>, embedder: Arc<dyn Embedder>, ) -> Result<Self>

Opens a persistent store with an Embedder.

§Errors

Returns IjimaError::Store if SurrealDB cannot initialize or the path is unwritable.

Source

pub async fn export_to(&self, path: impl AsRef<Path>) -> Result<()>

Exports the entire store as a SurrealDB SQL dump to path. Requires a persistent backend (SurrealKv); in-memory stores do not support Backup.

Trait Implementations§

Source§

impl KnowledgeGraph for SurrealStore

Source§

fn add_triple<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, subject: EntityId, predicate: &'life2 str, object: EntityId, valid_from: Option<&'life3 str>, confidence: f32, source_memory_id: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<Triple>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Adds (or refreshes) the subject + object entities and creates a triple edge between them. Returns the created Triple.
Source§

fn query_entity<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, entity: &'life2 EntityId, ) -> Pin<Box<dyn Future<Output = Result<EntityRecord>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Returns an entity and all its connected triples (outgoing + incoming) within ns.
Source§

fn invalidate_triple<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, triple_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Marks a triple as no longer current by setting valid_to. Idempotent.
Source§

fn find_triples<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, subject: Option<&'life2 EntityId>, predicate: Option<&'life3 str>, object: Option<&'life4 EntityId>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Finds triples matching any combination of subject / predicate / object (None = wildcard).
Source§

fn kg_timeline<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns triples in chronological order (by valid_from), most recent first.
Source§

fn knowledge_stats<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, ) -> Pin<Box<dyn Future<Output = Result<KgStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Entity + triple counts for ns.
Source§

fn kg_global_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<KgStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Global entity + triple counts across all namespaces.
Source§

impl Store for SurrealStore

Source§

fn store_memory<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, memory: Memory, ) -> Pin<Box<dyn Future<Output = Result<MemoryId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stores a curated memory under ns, performing content-hash + semantic dedup. Returns the stored id.
Source§

fn check_duplicate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, content: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryId>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Checks whether a memory with identical content already exists in ns (content-hash dedup). Returns the existing MemoryId if so.
Source§

fn recall_memory<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, id: &'life2 MemoryId, ) -> Pin<Box<dyn Future<Output = Result<Option<Memory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Recalls a single memory by id within ns. Returns None if the id is absent or belongs to a different namespace (isolation).
Source§

fn delete_memory<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, id: &'life2 MemoryId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Deletes a memory by id within ns.
Source§

fn list_memories<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Memory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Lists up to limit memories in ns, ranked by importance DESC then recency DESC. Powers wake-up composition (L1a personal essentials, L1b doctrine baseline).
Source§

fn store_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<StoreStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Global store statistics across all namespaces (operator/admin view). Powers GET /status.
Source§

fn list_rooms<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, project: Option<&'life2 str>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Room>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Lists rooms (topic cells) in ns, optionally filtered to a single project. Each room carries its memory count. Ordered by count desc.
Source§

fn taxonomy<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, ) -> Pin<Box<dyn Future<Output = Result<Vec<ProjectTaxon>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Full project → topic → count taxonomy of ns. Powers getTaxonomy navigation.
Source§

fn palace_graph<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, ) -> Pin<Box<dyn Future<Output = Result<PalaceGraph>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The palace graph: projects as nodes, shared-topic tunnels as edges. Powers getPalaceGraph“what connects these projects?”
Source§

fn traverse_tunnel<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, topic: &'life2 str, project_a: &'life3 str, project_b: &'life4 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<TunnelTraversal>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Traverses a tunnel: returns the actual memories from both projects on the shared topic, so the caller can see what connects them.
Source§

fn search_memories<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, embedding: &'life2 Embedding, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchHit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Semantic search over memories in ns by nearest embedding. Read more
Source§

fn ingest_turn<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, turn: SessionTurn, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Appends a raw turn to the session transcript under ns.
Source§

fn session_turns<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, session: &'life2 SessionId, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionTurn>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Returns the last limit turns of session under ns, in order.
Source§

fn create_session<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, session: Session, ) -> Pin<Box<dyn Future<Output = Result<SessionId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates or updates a session’s metadata under ns (upsert by id). Call when a session starts; turns reference the session id. ended_at is set via Self::end_session.
Source§

fn list_sessions<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, harness: Option<&'life2 Harness>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Session>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Lists up to limit sessions in ns, newest first, optionally filtered by harness.
Source§

fn end_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, session: &'life2 SessionId, ended_at: String, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Marks a session as ended (sets ended_at). Scoped by ns so a principal can only end sessions in their own namespace.
Source§

fn enqueue_extraction<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, memory: Memory, confidence: f32, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stages a PendingReview extraction in the per-namespace queue.
Source§

fn list_pending<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<QueuedExtraction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Lists pending extractions in ns, newest first.
Source§

fn accept_extraction<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, queue_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<AcceptedExtraction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Accepts a queued extraction: promotes it to the palace and removes it from the queue.
Source§

fn reject_extraction<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, queue_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Rejects a queued extraction: drops it from the queue without promoting.
Source§

fn write_diary<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, entry: DiaryEntry, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Appends a diary entry under ns.
Source§

fn read_diary<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, agent: &'life2 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<DiaryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Returns the last limit entries of agent’s diary under ns, in chronological order.
Source§

fn register_repo<'life0, 'async_trait>( &'life0 self, repo: RepoDirectory, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Registers or upserts a repository in the global registry (keyed by name). Powers POST /repos — the canonical Anima roster.
Source§

fn list_repos<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<RepoDirectory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists every registered repository (the ecosystem roster).
Source§

fn revoke_token<'life0, 'async_trait>( &'life0 self, revocation: TokenRevocation, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Records a token revocation (idempotent upsert keyed by hash). Powers POST /tokens/revoke (admin).
Source§

fn list_revocations<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TokenRevocation>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists every recorded revocation, oldest first. Powers GET /tokens/revocations (admin) and daemon-boot hydration of the in-memory rejection set.
Source§

fn grant_namespace_membership<'life0, 'async_trait>( &'life0 self, membership: NamespaceMembership, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Grants (upserts) a principal’s membership in a shared namespace. Admin operation; idempotent — re-granting refreshes granted_at/ granted_by but never duplicates.
Source§

fn revoke_namespace_membership<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, principal: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Revokes a membership. Idempotent: revoking an absent membership is not an error.
Source§

fn list_namespace_members<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, ) -> Pin<Box<dyn Future<Output = Result<Vec<NamespaceMembership>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Lists the members of a namespace, oldest grant first. Powers GET /namespaces/members (admin).
Source§

fn is_namespace_member<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, principal: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Hot-path membership check behind resolve_ns (shared-namespace reads/writes).
Source§

fn list_memories_filtered<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, project: Option<&'life2 str>, topic: Option<&'life3 str>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Memory>, IjimaError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Lists memories in ns, optionally filtered to project/topic. Powers GET /memories (the memory_recall browse path — distinct from Self::list_memories, which is the importance-ranked wake-up feed). Default: fetch a cap, filter in Rust, truncate. Backends MAY override with a native filtered query.
Source§

fn resolve_repo<'life0, 'life1, 'async_trait>( &'life0 self, cwd: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<RepoDirectory>, IjimaError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Reverse-resolves a working directory to its registered repo: the most specific repo whose path is a prefix of cwd (after normalizing). Powers GET /repos/resolve (CWD → project).

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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> AsyncFriendly for T
where T: Send + Sync + 'static,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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

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

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool