Skip to main content

MemoryStore

Struct MemoryStore 

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

The four logs on disk.

Implementations§

Source§

impl MemoryStore

Source

pub fn new(root: impl Into<PathBuf>) -> Self

Memory lives under <root>/memory/. Nothing is created until the first write.

Source

pub fn remember(&self, record: &MemoryRecord) -> Result<()>

Append one record.

Appends rather than the tmp-and-rename used for snapshot files: a single write of one line to a file opened with append is what the bot’s trade log already relies on, and rewriting the whole log to add a line would lose history on a crash.

Source

pub fn read_all(&self, kind: MemoryKind) -> Result<(Vec<MemoryRecord>, usize)>

Every record of a kind, oldest first.

A line that will not parse is skipped and counted, not fatal: one corrupt line — a half-written record from a killed process — must not make the agent amnesiac. The count comes back so a caller can surface it rather than swallow it.

Source

pub fn recall( &self, kind: MemoryKind, query: &Recall, ) -> Result<Vec<MemoryRecord>>

Matching records, most recent first.

Source

pub fn calibration(&self) -> Result<Calibration>

Score past projections against outcomes, honestly.

Joins counterfactuals to realisations on (decision, hypothesis). Everything that does not join is unresolved — which, for branches the agent declined to take, is the overwhelming majority and always will be.

Source

pub fn counts(&self) -> Result<Vec<(MemoryKind, usize, usize)>>

Total records per kind, for scema remember --stats.

Source

pub fn root(&self) -> &Path

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, 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.