pub struct AutoProtector {
pub protection_low_access: u32,
pub protection_medium_access: u32,
pub protection_high_access: u32,
pub protection_medium_sessions: u32,
pub protection_high_sessions: u32,
pub demotion_stale_days: u32,
}Expand description
Automatic protection calculator.
Protection levels are computed from access patterns:
- None → Low: 2+ accesses
- Low → Medium: 3+ accesses OR 2+ session appearances
- Medium → High: 5+ accesses OR 3+ session appearances OR user correction
- High → Permanent: UserProfile/Preference type OR explicit pin
Protection can also be demoted when entries become stale.
Fields§
§protection_low_access: u32Minimum access count for Low protection.
protection_medium_access: u32Minimum access count for Medium protection.
protection_high_access: u32Minimum access count for High protection.
protection_medium_sessions: u32Minimum session appearances for Medium protection.
protection_high_sessions: u32Minimum session appearances for High protection.
demotion_stale_days: u32Days without access before considering demotion.
Implementations§
Source§impl AutoProtector
impl AutoProtector
Sourcepub fn new(
low_access: u32,
medium_access: u32,
high_access: u32,
medium_sessions: u32,
high_sessions: u32,
demotion_stale_days: u32,
) -> Self
pub fn new( low_access: u32, medium_access: u32, high_access: u32, medium_sessions: u32, high_sessions: u32, demotion_stale_days: u32, ) -> Self
Create a new protector with the given thresholds.
Sourcepub fn default_protector() -> Self
pub fn default_protector() -> Self
Create with default thresholds from RFC-008.
Sourcepub fn compute_protection(&self, entry: &MemoryEntry) -> ProtectionLevel
pub fn compute_protection(&self, entry: &MemoryEntry) -> ProtectionLevel
Compute protection level for a memory entry based on access patterns.
This is the core auto-protection logic. Dream calls this every run.
Sourcepub fn should_demote_protection(
&self,
entry: &MemoryEntry,
current: ProtectionLevel,
) -> Option<ProtectionLevel>
pub fn should_demote_protection( &self, entry: &MemoryEntry, current: ProtectionLevel, ) -> Option<ProtectionLevel>
Evaluate whether a protection level should be demoted.
Only demotes by one step at a time (High → Medium, Medium → Low, etc.).
Returns None if no demotion is warranted.
Sourcepub fn record_access(entry: &mut MemoryEntry, current_session_id: &str)
pub fn record_access(entry: &mut MemoryEntry, current_session_id: &str)
Record access to a memory entry (updates tracking fields).
Call this whenever a memory is recalled or searched.
Trait Implementations§
Source§impl Clone for AutoProtector
impl Clone for AutoProtector
Source§fn clone(&self) -> AutoProtector
fn clone(&self) -> AutoProtector
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more