Skip to main content

MemoryService

Struct MemoryService 

Source
pub struct MemoryService { /* private fields */ }

Implementations§

Source§

impl MemoryService

Source

pub fn with_judge(self, decide: Decide) -> Self

Have dreaming’s verdicts asked of the judge (the session’s judge.decide).

Source

pub fn dream( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

memory.dream({days?, limit?}): see the module docs. {confirmed, revised, retracted, conflicts, review, unchecked, judged}; ids are the backend’s claim ids.

Source

pub fn write_page( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

memory.brief(text, scope, topic?) (dreaming): writes the startup brief of scope (what opens each context as the project’s or the user’s brief), or its topic page topic, replacing the one before. Within page_budget; a text holding a secret is refused. {id, scope, topic}.

Source

pub fn topic( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

memory.topic(topic?, scope): the topic page topic of scope ({topic, content, refreshedAt}, null when there is none), or without a topic the names of the scope’s topic pages.

Source§

impl MemoryService

Source

pub fn new( store: Arc<dyn DocumentStore>, backend: Arc<dyn MemoryBackend>, gate: MemoryGate, ) -> Result<Self, MemoryError>

Source

pub fn with_root(self, root: impl Into<PathBuf>) -> Self

Check evidence quotes of project and session memories against the files under root when they are recalled (the composition root passes the session’s working directory). A global memory’s quotes name files of whatever project it came from, so they are never checked.

Source

pub fn with_clock(self, clock: Clock) -> Self

The clock the service reads “now” from (fixtures pin it; the composition root keeps the system clock).

Source

pub fn with_records(self, records: Arc<RecordIndex>) -> Self

Keep typed records’ metadata in records (the composition root passes the agent directory’s shared index).

Source

pub fn records(&self) -> &Arc<RecordIndex> ⓘ

The typed record index this service writes.

Source

pub fn filters(&self) -> &Map<String, Value>

Scope → identity tags of this service’s backend.

Source

pub fn list(&self) -> Result<Value, MemoryError>

Source

pub fn why(&self, task_id: &Value) -> Result<Value, MemoryError>

Source

pub fn prepare( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

Source

pub fn recall_for_turn( &self, query: &str, limit: usize, signal: &Signal, ) -> Result<Vec<Value>, MemoryError>

Automatic recall for a user message (Rust-only; the session runs it before each root turn, see session-core auto_memory): one cheap Hindsight recall over the project and global scopes, at most limit entries {id, text, scope, type?, memoryId?, stale?} (stale: why its quoted evidence no longer holds, see MemoryService::with_root). It is read-only and journals nothing; what the user forgot or replaced is withheld as MemoryService::prepare withholds it, and a result tagged with neither scope’s tags exactly is dropped, and so is an automatic memory not confirmed for [AUTO_MEMORY_MAX_AGE_MS].

Source

pub fn retain_session_tail( &self, document_id: &str, text: &str, context: &str, through: &str, signal: &Signal, ) -> Result<bool, MemoryError>

Automatic retain of a session’s distilled notes (Rust-only; session-core auto_memory sends them): text is the keyed claim document_id under the project scope, replacing the claim’s text, and is marked as distilled up to through, the session entry (or compaction) it came from. A text the write gate finds sensitive, or a backend without retain, is not sent (Ok(false)).

Source

pub fn tail_kept_through( &self, document_id: &str, through: &str, signal: &Signal, ) -> bool

Whether document_id already holds notes distilled up to through (kept by an earlier MemoryService::retain_session_tail), so that part of the session is not distilled again. A document the backend cannot read counts as not kept.

Source

pub fn confirm_recalled(&self, ids: &[String], signal: &Signal)

Marks the memories ids re-confirmed in the backend: what the context showed and the model relied on. Only numeric ids are claims (episode-* are not); a backend without confirm, or a failed call, is ignored.

Source

pub fn reflect( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

memory.reflect (Rust-only): Hindsight’s answer to query, reasoned over the memories of scope, else of the project and global scopes; {text}. Read-only and journaled nowhere. Unlike a recall, the answer is written by Hindsight’s model and may draw on a document the user forgot that the bank has not yet dropped.

Source

pub fn invalidate( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

memory.invalidate (Rust-only): retires the fact id that a recall showed ([fact <id>]), with the reason, so no later recall returns it. Only a unit tagged with one of this session’s scopes exactly may be retired (UNKNOWN_MEMORY otherwise); a reason the write gate finds sensitive is not sent. Hindsight derives an observation from facts and refuses to curate it, and only some of those facts may be wrong: an observation retires nothing and answers {id, state: "observation", sources: [{id, text}]}, its live source facts, so the caller invalidates the wrong ones and Hindsight rewrites the observation from the rest.

Source

pub fn project_digest( &self, signal: &Signal, ) -> Result<Option<Value>, MemoryError>

The project’s brief (Rust-only; automatic memory opens a context with it): the Hindsight mental model ultron-project-<identity>, which Hindsight rewrites from the project and global memories after each consolidation, at most hourly. {id, content, refreshedAt}, or None while it has no content. The first call for a project creates the model, whose first content Hindsight writes in the background.

Source

pub fn user_brief(&self, signal: &Signal) -> Result<Option<Value>, MemoryError>

The user’s brief, like Self::project_digest but written from the global memories only: ultron-user-<global identity>, what the user prefers, corrects and asks for in every project. A project’s own rules stay out of it, so one repo’s convention never reaches another as the user’s.

Source§

impl MemoryService

Source

pub fn propose( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

Source

pub fn correct( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

Source

pub fn forget( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

Source

pub fn get( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>

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: Sized + 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: Sized + 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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