Skip to main content

MemoryBook

Trait MemoryBook 

Source
pub trait MemoryBook: Send + Sync {
    // Required methods
    fn facts<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        user: &'life1 str,
        area: Option<&'life2 PartitionId>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RememberedFact>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn confirm<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        user: &'life1 str,
        id: &'life2 str,
        by: &'life3 SubjectRef,
    ) -> Pin<Box<dyn Future<Output = Result<RememberedFact>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn fix<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        user: &'life1 str,
        id: &'life2 str,
        text: &'life3 str,
        by: &'life4 SubjectRef,
    ) -> Pin<Box<dyn Future<Output = Result<RememberedFact>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn forget<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        user: &'life1 str,
        id: &'life2 str,
        by: &'life3 SubjectRef,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn tidy_ups<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TidyUp>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn undo_tidy_up<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        user: &'life1 str,
        id: &'life2 str,
        by: &'life3 SubjectRef,
    ) -> Pin<Box<dyn Future<Output = Result<TidyUpUndo>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

What the harness gives the kernel so the control plane can show and correct the agents’ memory (spec 3.3 §10 K5). user is the caller; a book answers only that person’s facts, as fact_not_found for anyone else’s.

§Example

use adk_core::principal::SubjectRef;
use adk_kernel::control::{FactOrigin, MemoryBook, RememberedFact, TidyUp, TidyUpUndo};

struct Nothing;

#[async_trait::async_trait]
impl MemoryBook for Nothing {
    async fn facts(&self, _: &str, _: Option<&adk_kernel::PartitionId>) -> adk_kernel::Result<Vec<RememberedFact>> { Ok(vec![]) }
    async fn confirm(&self, _: &str, id: &str, _: &SubjectRef) -> adk_kernel::Result<RememberedFact> { Err(adk_kernel::KernelError::NotFound { pid: id.into() }) }
    async fn fix(&self, _: &str, id: &str, _: &str, _: &SubjectRef) -> adk_kernel::Result<RememberedFact> { Err(adk_kernel::KernelError::NotFound { pid: id.into() }) }
    async fn forget(&self, _: &str, id: &str, _: &SubjectRef) -> adk_kernel::Result<()> { Err(adk_kernel::KernelError::NotFound { pid: id.into() }) }
    async fn tidy_ups(&self, _: &str) -> adk_kernel::Result<Vec<TidyUp>> { Ok(vec![]) }
    async fn undo_tidy_up(&self, _: &str, id: &str, _: &SubjectRef) -> adk_kernel::Result<TidyUpUndo> { Err(adk_kernel::KernelError::NotFound { pid: id.into() }) }
}

Required Methods§

Source

fn facts<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user: &'life1 str, area: Option<&'life2 PartitionId>, ) -> Pin<Box<dyn Future<Output = Result<Vec<RememberedFact>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

The live facts of user, of area when one is named, newest first.

§Errors

The book’s error.

Source

fn confirm<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, user: &'life1 str, id: &'life2 str, by: &'life3 SubjectRef, ) -> Pin<Box<dyn Future<Output = Result<RememberedFact>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

“That’s right”: user’s fact id becomes “You said this”.

§Errors

A NotFound error for a fact that is not user’s or not live, or the book’s error.

Source

fn fix<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, user: &'life1 str, id: &'life2 str, text: &'life3 str, by: &'life4 SubjectRef, ) -> Pin<Box<dyn Future<Output = Result<RememberedFact>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

“Fix it”: user’s fact id is replaced by text, which reads “You said this”; the old one is kept in the history.

§Errors

As confirm, and an InvalidInput error for a text the harness refuses (empty, too long, a secret).

Source

fn forget<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, user: &'life1 str, id: &'life2 str, by: &'life3 SubjectRef, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

“Forget it”: user’s fact id is never recalled again.

§Errors

As confirm.

Source

fn tidy_ups<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<TidyUp>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The tidy-ups of user’s memory, newest first.

§Errors

The book’s error.

Source

fn undo_tidy_up<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, user: &'life1 str, id: &'life2 str, by: &'life3 SubjectRef, ) -> Pin<Box<dyn Future<Output = Result<TidyUpUndo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

“Undo”: reverts tidy-up id of user’s memory.

§Errors

A NotFound error for an unknown tidy-up, a Conflict for one unfinished or already undone, or the book’s error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§