pub struct MemoryService { /* private fields */ }Implementations§
Source§impl MemoryService
impl MemoryService
Sourcepub fn with_judge(self, decide: Decide) -> Self
pub fn with_judge(self, decide: Decide) -> Self
Have dreaming’s verdicts asked of the judge (the session’s judge.decide).
Sourcepub fn dream(
&self,
payload: &Map<String, Value>,
signal: &Signal,
) -> Result<Value, MemoryError>
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.
Sourcepub fn write_page(
&self,
payload: &Map<String, Value>,
signal: &Signal,
) -> Result<Value, MemoryError>
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§impl MemoryService
impl MemoryService
pub fn new( store: Arc<dyn DocumentStore>, backend: Arc<dyn MemoryBackend>, gate: MemoryGate, ) -> Result<Self, MemoryError>
Sourcepub fn with_root(self, root: impl Into<PathBuf>) -> Self
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.
Sourcepub fn with_clock(self, clock: Clock) -> Self
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).
Sourcepub fn with_records(self, records: Arc<RecordIndex>) -> Self
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).
Sourcepub fn records(&self) -> &Arc<RecordIndex> ⓘ
pub fn records(&self) -> &Arc<RecordIndex> ⓘ
The typed record index this service writes.
pub fn list(&self) -> Result<Value, MemoryError>
pub fn why(&self, task_id: &Value) -> Result<Value, MemoryError>
pub fn prepare( &self, payload: &Map<String, Value>, signal: &Signal, ) -> Result<Value, MemoryError>
Sourcepub fn recall_for_turn(
&self,
query: &str,
limit: usize,
signal: &Signal,
) -> Result<Vec<Value>, MemoryError>
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].
Sourcepub fn retain_session_tail(
&self,
document_id: &str,
text: &str,
context: &str,
through: &str,
signal: &Signal,
) -> Result<bool, MemoryError>
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)).
Sourcepub fn tail_kept_through(
&self,
document_id: &str,
through: &str,
signal: &Signal,
) -> bool
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.
Sourcepub fn confirm_recalled(&self, ids: &[String], signal: &Signal)
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.
Sourcepub fn reflect(
&self,
payload: &Map<String, Value>,
signal: &Signal,
) -> Result<Value, MemoryError>
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.
Sourcepub fn invalidate(
&self,
payload: &Map<String, Value>,
signal: &Signal,
) -> Result<Value, MemoryError>
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.
Sourcepub fn project_digest(
&self,
signal: &Signal,
) -> Result<Option<Value>, MemoryError>
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.
Sourcepub fn user_brief(&self, signal: &Signal) -> Result<Option<Value>, MemoryError>
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.