pub struct ChallengeMemoryEntry {
pub domain: String,
pub target_class: TargetClass,
pub last_outcome: ChallengeOutcome,
pub observation_count: u32,
pub recorded_at_unix_secs: u64,
}Expand description
One entry in the challenge memory.
An entry represents the last observed outcome for a single
(domain, target_class) pair, along with a count of how many
times the runner has recorded an outcome for that key (capped at
u32::MAX for monotonic counters). The TTL is owned by the
LruTtlStore backing the
ChallengeMemory — once the LRU entry expires, the whole
entry is dropped and the runner falls back to the unadjusted
risk score.
§Example
use stygian_charon::challenge_feedback::{ChallengeMemoryEntry, ChallengeOutcome};
use stygian_charon::types::TargetClass;
let entry = ChallengeMemoryEntry {
domain: "example.com".to_string(),
target_class: TargetClass::ContentSite,
last_outcome: ChallengeOutcome::HardChallenge,
observation_count: 1,
recorded_at_unix_secs: 1_700_000_000,
};
assert_eq!(entry.risk_delta(), ChallengeOutcome::HardChallenge.risk_delta());Fields§
§domain: StringLower-cased host the outcome was recorded for.
target_class: TargetClassTarget class the outcome was recorded for.
last_outcome: ChallengeOutcomeMost recently recorded outcome for this key.
observation_count: u32Number of outcomes the runner has recorded for this key (saturating on overflow).
recorded_at_unix_secs: u64Unix epoch seconds when the entry was last updated.
Implementations§
Source§impl ChallengeMemoryEntry
impl ChallengeMemoryEntry
Sourcepub const fn risk_delta(&self) -> f64
pub const fn risk_delta(&self) -> f64
Risk-score contribution this entry would add to the next
policy. Delegates to
ChallengeOutcome::risk_delta
and is therefore bounded by
MAX_RISK_DELTA.
Trait Implementations§
Source§impl Clone for ChallengeMemoryEntry
impl Clone for ChallengeMemoryEntry
Source§fn clone(&self) -> ChallengeMemoryEntry
fn clone(&self) -> ChallengeMemoryEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChallengeMemoryEntry
impl Debug for ChallengeMemoryEntry
Source§impl<'de> Deserialize<'de> for ChallengeMemoryEntry
impl<'de> Deserialize<'de> for ChallengeMemoryEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ChallengeMemoryEntry
impl PartialEq for ChallengeMemoryEntry
Source§impl Serialize for ChallengeMemoryEntry
impl Serialize for ChallengeMemoryEntry
impl Eq for ChallengeMemoryEntry
impl StructuralPartialEq for ChallengeMemoryEntry
Auto Trait Implementations§
impl Freeze for ChallengeMemoryEntry
impl RefUnwindSafe for ChallengeMemoryEntry
impl Send for ChallengeMemoryEntry
impl Sync for ChallengeMemoryEntry
impl Unpin for ChallengeMemoryEntry
impl UnsafeUnpin for ChallengeMemoryEntry
impl UnwindSafe for ChallengeMemoryEntry
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.