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: StringThe 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: MemoryKindWhat the record is.
scope: ScopeAddressWhose 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.
Writer-declared tags; retrieval matches by equality (a record must carry every queried tag).
priority: i64The 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: MemoryProvenanceWho wrote it, from what evidence, and when. Mandatory.
confidence: f64The 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: ValidityWindowThe 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: PayloadRefThe 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
impl MemoryRecord
Sourcepub fn new(
kind: MemoryKind,
scope: ScopeAddress,
provenance: MemoryProvenance,
confidence: f64,
validity: ValidityWindow,
created_at: DateTime<Utc>,
content: Value,
) -> Result<Self>
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.
Builder-style: set the tags.
Sourcepub fn with_priority(self, priority: i64) -> Self
pub fn with_priority(self, priority: i64) -> Self
Builder-style: set the explicit priority (the assembly rank’s first input).
Sourcepub fn with_expires_at(self, expires_at: DateTime<Utc>) -> Self
pub fn with_expires_at(self, expires_at: DateTime<Utc>) -> Self
Builder-style: set the TTL.
Sourcepub fn with_supersedes(self, supersedes: impl Into<String>) -> Self
pub fn with_supersedes(self, supersedes: impl Into<String>) -> Self
Builder-style: name the record this one supersedes.
Sourcepub fn with_candidacy(self, candidacy: Candidacy) -> Self
pub fn with_candidacy(self, candidacy: Candidacy) -> Self
Builder-style: mark the record as a correction-derived candidate
(R0.8 wave 2; Candidacy).
Sourcepub fn content_bytes(&self) -> u64
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).
Sourcepub fn content_ref_of(content: &Value) -> PayloadRef
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.