pub struct JournaledMemory { /* private fields */ }Expand description
A memory handle bound to a run’s journal: the journaled read/write seam node code (and later waves’ run integration) uses.
Cheap to clone (the journal and source are shared handles), so node
closures capture it exactly the way they capture a Journal for
recording model and tool calls. Causal parentage comes from the
invocation’s node-input event id, passed as parent — node code reads
it from crate::journal::PARENT_EVENT_KEY in NodeConfig::extra.
Clock-read parity: the live and replay paths read the run’s clock the
same number of times in the same order (one as_of stamp, two latency
reads, one read inside Journal::record), so a logical clock’s tick
sequence — and therefore every journaled timestamp — reproduces exactly
on replay. This is the same parity rule the replaying model wrapper
documents.
Implementations§
Source§impl JournaledMemory
impl JournaledMemory
Sourcepub fn new(journal: &Journal, source: MemorySource) -> Self
pub fn new(journal: &Journal, source: MemorySource) -> Self
Bind source to journal (the run’s journal — build via
Journal::memory).
Sourcepub fn source(&self) -> &MemorySource
pub fn source(&self) -> &MemorySource
The source this handle answers from.
Sourcepub async fn read(
&self,
query: &MemoryQuery,
budget: &ContextBudget,
parent: Option<String>,
) -> Result<MemoryAssembly>
pub async fn read( &self, query: &MemoryQuery, budget: &ContextBudget, parent: Option<String>, ) -> Result<MemoryAssembly>
Perform a governed read: resolve MemoryQuery::as_of through the
run’s clock when unset, then — live — query the store, assemble
deterministically, and journal the assembly as a
RunEventKind::MemoryRead event (Effect::ReadOnly); or —
replay — serve the journaled assembly byte-identically and re-journal
it. Returns the assembly either way.
Sourcepub async fn write(
&self,
record: &MemoryRecord,
parent: Option<String>,
) -> Result<String>
pub async fn write( &self, record: &MemoryRecord, parent: Option<String>, ) -> Result<String>
Perform a governed write: store the record (content-addressed, so
retries converge) and journal it as a RunEventKind::MemoryWrite
event — Effect::Idempotent under the derived key
memory:{scope}:{memory_id}, with the record and its provenance as
the output payload. Returns the content address.
A memory write changes what future retrievals return — nothing else (the write path’s third gate). If the write is meant to change a prompt, a policy, or a permission, it belongs in the candidate pipeline, not here.
Fails during replay: writes are never served, so a replayed run issuing one has diverged from its evidence.