pub struct ChallengeMemoryEntry {
pub key: EngineKey,
pub last_observed_url: Option<String>,
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
EngineKey, along with a count of how many times the runner
has recorded an outcome for that key (capped at u32::MAX for
monotonic counters) and the last URL the runner saw the
outcome on (kept as a secondary debugging index only — the
primary key is the engine, not the URL). The TTL is owned by
the LRU+TTL store 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, EngineKey};
use stygian_charon::types::TargetClass;
use stygian_charon::vendor_classifier::VendorId;
let entry = ChallengeMemoryEntry {
key: EngineKey {
engine: VendorId::Cloudflare,
version: None,
target_class: TargetClass::ContentSite,
tls_profile: None,
},
last_observed_url: Some("https://example.com/path".to_string()),
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§
§key: EngineKeyPrimary identity of this entry — the engine, target class, version, and TLS profile the entry was recorded under.
last_observed_url: Option<String>Optional last URL the outcome was observed on. Kept for debugging (“where did we last see this engine?”) — it is NOT a primary key. Two different URLs on the same engine share the same memory entry.
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.
Sourcepub const fn target_class(&self) -> TargetClass
pub const fn target_class(&self) -> TargetClass
Convenience accessor for the entry’s target class.
Mirrors EngineKey::target_class so callers do not have
to reach through entry.key.target_class.
Sourcepub const fn engine(&self) -> VendorId
pub const fn engine(&self) -> VendorId
Convenience accessor for the entry’s engine. Mirrors
EngineKey::engine so callers do not have to reach
through entry.key.engine.
Trait Implementations§
Source§impl Clone for ChallengeMemoryEntry
impl Clone for ChallengeMemoryEntry
Source§fn clone(&self) -> ChallengeMemoryEntry
fn clone(&self) -> ChallengeMemoryEntry
1.0.0 (const: unstable) · 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>,
impl Eq for ChallengeMemoryEntry
Source§impl PartialEq for ChallengeMemoryEntry
impl PartialEq for ChallengeMemoryEntry
Source§fn eq(&self, other: &ChallengeMemoryEntry) -> bool
fn eq(&self, other: &ChallengeMemoryEntry) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ChallengeMemoryEntry
impl Serialize 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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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.