Skip to main content

MemoryRecord

Struct MemoryRecord 

Source
pub struct MemoryRecord {
Show 15 fields pub memory_id: String, pub kind: MemoryKind, pub scope: ScopeAddress, pub key: Option<String>, pub tags: Vec<String>, pub priority: i64, pub provenance: MemoryProvenance, pub confidence: f64, pub validity: ValidityWindow, pub created_at: DateTime<Utc>, pub expires_at: Option<DateTime<Utc>>, pub supersedes: Option<String>, pub candidacy: Option<Candidacy>, pub content: PayloadRef, pub embedding: Option<Value>,
}
Expand description

One governed memory record: content-addressed, immutable, scoped, attributed.

Every field exists because a downstream operation needs it (the design’s rule): retrieval filters on scope/kind/key/tags/confidence/validity/ expiration/supersession/author; the assembly ranks on priority/confidence/recency; the audit walks provenance; forgetting walks supersedes in reverse. The one reserved field is embedding — reserved so vector retrieval slots in additively when the roadmap’s de-prioritization lifts; nothing in R0.8 reads it.

Fields§

§memory_id: String

The content address: sha256 over the canonical serialization of the record’s content plus provenance (the one hashing primitive shared with artifact references and journal heads). Immutable by construction: a changed record is a new id.

§kind: MemoryKind

What the record is.

§scope: ScopeAddress

Whose memory it is.

§key: Option<String>

The writer-declared lookup key, when the record answers a named question (“what is user-7’s timezone”). With no vector retrieval in R0.8, keying is deliberate: absence of a hit is absence of a key, not absence of a fact.

§tags: Vec<String>

Writer-declared tags; retrieval matches by equality (a record must carry every queried tag).

§priority: i64

The writer-declared explicit priority — the assembly rank’s first input (higher packs first). 0 is the default and stays absent from the wire, so pre-priority records keep their shape.

§provenance: MemoryProvenance

Who wrote it, from what evidence, and when. Mandatory.

§confidence: f64

The writer-declared confidence in (0, 1]. Retrieval filters on it; nothing in the runtime computes it — confidence is a claim, not a measurement, and the model is honest about that.

§validity: ValidityWindow

The interval the record claims to be true.

§created_at: DateTime<Utc>

When the system learned it (the bitemporal split’s other timestamp; duplicates MemoryProvenance::written_at deliberately — the record is self-contained when provenance is summarized away by a consumer).

§expires_at: Option<DateTime<Utc>>

Optional TTL. Expiration is a retrieval filter (and, from wave 2, a forgetting trigger), not a silent reaper.

§supersedes: Option<String>

The record this one replaces, when it does. Supersession is a chain of immutable records; the superseded record is retained as evidence but filtered from default retrieval.

§candidacy: Option<Candidacy>

Set when the record is a correction-derived candidate pending evaluation (R0.8 wave 2; Candidacy). Additive: absent from the wire while unset, and outside the content address (candidacy is governance state, not identity).

§content: PayloadRef

The record body: inline at or below INLINE_PAYLOAD_MAX_BYTES, content-addressed above — the journal’s own payload discipline, so memory bodies share artifact storage and the large-body story needs nothing new.

§embedding: Option<Value>

Reserved for vector retrieval (deferred, per the design’s not-built list). Additive by construction: absent from the wire while unset, so the field lands without a wire change when it earns its keep.

Implementations§

Source§

impl MemoryRecord

Source

pub fn new( kind: MemoryKind, scope: ScopeAddress, provenance: MemoryProvenance, confidence: f64, validity: ValidityWindow, created_at: DateTime<Utc>, content: Value, ) -> Result<Self>

Build a record, deriving its content address from the content plus provenance and splitting the content per the payload discipline (inline ≤ INLINE_PAYLOAD_MAX_BYTES, content-addressed above).

Fails when confidence is outside (0, 1] — the one validity rule the contract enforces at construction, because a confidence outside the interval is not a claim at all.

Source

pub fn with_key(self, key: impl Into<String>) -> Self

Builder-style: set the lookup key.

Source

pub fn with_tags( self, tags: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Builder-style: set the tags.

Source

pub fn with_priority(self, priority: i64) -> Self

Builder-style: set the explicit priority (the assembly rank’s first input).

Source

pub fn with_expires_at(self, expires_at: DateTime<Utc>) -> Self

Builder-style: set the TTL.

Source

pub fn with_supersedes(self, supersedes: impl Into<String>) -> Self

Builder-style: name the record this one supersedes.

Source

pub fn with_candidacy(self, candidacy: Candidacy) -> Self

Builder-style: mark the record as a correction-derived candidate (R0.8 wave 2; Candidacy).

Source

pub fn content_bytes(&self) -> u64

The serialized size of the content in bytes — the input to the estimated-token accounting. Inline payloads serialize on demand; artifact-referenced payloads carry their size on the reference (the canonical-serialization size the address was minted from).

Source

pub fn content_ref_of(content: &Value) -> PayloadRef

Split content per the payload discipline, as MemoryRecord::new does: inline at or below INLINE_PAYLOAD_MAX_BYTES, content-addressed above. The artifact bytes are the canonical serialization of content; the caller persists them (the artifact store shared with the journal) under the reference’s address.

Trait Implementations§

Source§

impl Clone for MemoryRecord

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MemoryRecord

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for MemoryRecord

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for MemoryRecord

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MemoryRecord

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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