pub enum TemporalGranularity {
Day,
Week,
Month,
Quarter,
Year,
}Expand description
Temporal granularity of a memory: an orthogonal dimension to MemoryScope
that describes the time horizon a memory is meant to be valid over.
This is additive and optional — memories written before this dimension existed
(and any caller that does not set it) simply carry None, which preserves the
pre-existing behavior exactly. The dimension is intentionally NOT used as a hard
recall filter that flips the recalled subset every hour/day, because the recalled
memories are spliced into the LLM prompt prefix and a churning subset would shred
prompt prefix-cache hit rates. Instead it is a stable ranking / ordering signal:
coarser-grained memories (year/quarter) are low-frequency and cache-friendly and
sort earlier (toward the stable prefix); finer-grained memories (day/week) change
more often and sort later (toward the volatile suffix). See issue #61.
Passive recall ordering must remain stable across calls, so it is never
hard-filtered by granularity. This does not apply to an explicit
filters.granularity query or purge request, where hard filtering is the
caller’s stated intent.
Variants§
Day
Finest granularity. Highest churn, fastest to go stale (debugging notes, today’s working context). Least prefix-cache friendly → ranks last.
Week
Sprint-level / weekly priorities and progress.
Month
Monthly decisions and phase summaries.
Quarter
Quarter-level direction, large refactor plans.
Year
Coarsest granularity. Lowest churn, longest-lived (long-term goals, system evolution). Most prefix-cache friendly → ranks first.
Implementations§
Source§impl TemporalGranularity
impl TemporalGranularity
pub fn as_str(self) -> &'static str
Sourcepub fn parse(value: &str) -> Option<TemporalGranularity>
pub fn parse(value: &str) -> Option<TemporalGranularity>
Parse a case-insensitive granularity token. Returns None for unknown values
so callers can decide whether to error or fall back to the default.
Sourcepub fn cache_stability_rank(granularity: Option<TemporalGranularity>) -> u8
pub fn cache_stability_rank(granularity: Option<TemporalGranularity>) -> u8
Cache-stability rank: lower number = coarser = more prefix-cache friendly and should be ordered earlier (toward the stable prompt prefix). Higher number = finer = higher churn and should be ordered later (toward the volatile suffix).
Memories with no granularity set are treated as the most stable (rank 0) so existing/unclassified memories keep their current placement and never get demoted below classified ones purely for lacking the new dimension.
Sourcepub fn is_high_churn(granularity: Option<TemporalGranularity>) -> bool
pub fn is_high_churn(granularity: Option<TemporalGranularity>) -> bool
Whether this granularity is “high churn” per the issue’s Prefix Cache
Friendly constraint: day/week memories change often enough that they must
never land in a caller’s stable prefix segment.
None and month/quarter/year are low-churn / prefix-eligible; week/day are
high-churn / suffix-only. Derived from Self::cache_stability_rank so
callers cannot disagree with the ordering tie-break about which side of
the coarse/fine line a granularity falls on.
Trait Implementations§
Source§impl Clone for TemporalGranularity
impl Clone for TemporalGranularity
Source§fn clone(&self) -> TemporalGranularity
fn clone(&self) -> TemporalGranularity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TemporalGranularity
Source§impl Debug for TemporalGranularity
impl Debug for TemporalGranularity
Source§impl<'de> Deserialize<'de> for TemporalGranularity
impl<'de> Deserialize<'de> for TemporalGranularity
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TemporalGranularity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TemporalGranularity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for TemporalGranularity
Source§impl Hash for TemporalGranularity
impl Hash for TemporalGranularity
Source§impl Ord for TemporalGranularity
impl Ord for TemporalGranularity
Source§fn cmp(&self, other: &TemporalGranularity) -> Ordering
fn cmp(&self, other: &TemporalGranularity) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for TemporalGranularity
impl PartialEq for TemporalGranularity
Source§impl PartialOrd for TemporalGranularity
impl PartialOrd for TemporalGranularity
Source§impl Serialize for TemporalGranularity
impl Serialize for TemporalGranularity
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for TemporalGranularity
Auto Trait Implementations§
impl Freeze for TemporalGranularity
impl RefUnwindSafe for TemporalGranularity
impl Send for TemporalGranularity
impl Sync for TemporalGranularity
impl Unpin for TemporalGranularity
impl UnsafeUnpin for TemporalGranularity
impl UnwindSafe for TemporalGranularity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.