pub struct MemoryQuery {
pub scope: Option<ScopeAddress>,
pub kinds: Vec<MemoryKind>,
pub key: Option<String>,
pub tags: Vec<String>,
pub valid_at: Option<DateTime<Utc>>,
pub min_confidence: Option<f64>,
pub include_expired: bool,
pub include_superseded: bool,
pub authored_by: Option<ProvenanceAuthor>,
pub candidates_only: bool,
pub as_of: Option<DateTime<Utc>>,
}Expand description
A structured memory query. Deliberately not semantic: R0.8 has no similarity search (the design’s not-built list), so writers key and tag records deliberately and consumers treat absence of a hit as absence of a key, not absence of a fact.
Every field is optional; an empty query matches everything in the
namespace (subject to the two defaults: expired and superseded records
are excluded unless explicitly included). The query is journaled as the
read’s request, so its serialization is part of the replay contract —
sparse fields stay absent, and MemoryQuery::as_of is always resolved
before journaling (see JournaledMemory::read).
Fields§
§scope: Option<ScopeAddress>Restrict to one scope address (whose memory, concretely).
kinds: Vec<MemoryKind>Restrict to these kinds (empty = all kinds).
key: Option<String>Key equality.
Tag equality: a record must carry every listed tag.
valid_at: Option<DateTime<Utc>>Validity-at-time: the record’s validity window must contain this instant (the bitemporal “true as of” filter).
min_confidence: Option<f64>Minimum writer-declared confidence, inclusive.
include_expired: boolInclude records past their expires_at (default: excluded).
Expiration is a filter, not a reaper — the records are still there.
include_superseded: boolInclude records another record supersedes (default: excluded — the superseded record is retained as evidence, filtered from default retrieval).
Restrict to one author.
candidates_only: boolRestrict to correction-derived candidates pending evaluation (R0.8 wave 2; default: all records, candidates or not). This is how the evaluation half of the loop finds its queue: candidacy is a governance mark, so it filters like one — structurally, never by content.
as_of: Option<DateTime<Utc>>The instant expiry is evaluated against. When unset, the reader stamps it through the run’s clock at read time (wall clock for live reads; the deterministic logical clock for recorded runs) — so the journaled request always carries the resolved value and a replayed read re-derives the same one.
Implementations§
Source§impl MemoryQuery
impl MemoryQuery
Sourcepub fn matches(
&self,
record: &MemoryRecord,
superseded: bool,
now: DateTime<Utc>,
) -> bool
pub fn matches( &self, record: &MemoryRecord, superseded: bool, now: DateTime<Utc>, ) -> bool
Whether record matches every declared filter. superseded tells
whether another record in the queried universe supersedes this one
(computable only against the whole set, so the caller supplies it);
now is the resolved expiry instant (MemoryQuery::as_of).