pub struct PowCapabilityProfile {
pub domain: String,
pub target_class: TargetClass,
pub vendor_family: VendorId,
pub solved_count: u32,
pub failed_count: u32,
pub retry_count: u32,
pub solve_latency_ms_p50: Option<u64>,
pub solve_latency_ms_p95: Option<u64>,
pub failure_modes: BTreeMap<PowFailureMode, u32>,
pub observation_window_secs: u64,
pub recorded_at_unix_secs: u64,
}Expand description
Aggregated PoW capability profile for one
(domain, target_class, vendor_family) triple.
A profile is built by merging one or more
PowCapabilitySamples through
PowCapabilityProfile::merge and then consumed by
PowCapabilityScorer
to produce a deterministic score. The profile is the
unit of persistence: the store keys profiles by
(domain, target_class, vendor_family) and re-uses the
LRU+TTL primitive from T83’s LruTtlStore
(the same primitive that backs ChallengeMemory).
§Example
use stygian_charon::pow_profile::{PowCapabilityProfile, PowCapabilitySample};
use stygian_charon::types::TargetClass;
use stygian_charon::vendor_classifier::VendorId;
let mut profile = PowCapabilityProfile::new(
"example.com",
TargetClass::ContentSite,
VendorId::Cloudflare,
);
profile.merge(&PowCapabilitySample::solved(1_000, 0));
profile.merge(&PowCapabilitySample::solved(1_500, 1));
assert_eq!(profile.solved_count, 2);
assert_eq!(profile.retry_count, 1);Fields§
§domain: StringLower-cased host the profile was observed for.
target_class: TargetClassTarget class the profile was observed for.
vendor_family: VendorIdVendor family the profile was observed for.
solved_count: u32Number of solved challenges inside the window.
failed_count: u32Number of failed challenges inside the window.
retry_count: u32Cumulative retry count across all attempts inside the window.
solve_latency_ms_p50: Option<u64>p50 solve latency in milliseconds for solved
samples (median). None when no samples are present.
solve_latency_ms_p95: Option<u64>p95 solve latency in milliseconds for solved
samples. None when fewer than the p95-eligible
floor is present (see PowCapabilityProfile::merge).
failure_modes: BTreeMap<PowFailureMode, u32>Failure-mode histogram (mode -> count).
observation_window_secs: u64Width of the sampling window in seconds.
recorded_at_unix_secs: u64Unix epoch seconds when the profile was last updated.
Implementations§
Source§impl PowCapabilityProfile
impl PowCapabilityProfile
Sourcepub fn new(
domain: &str,
target_class: TargetClass,
vendor_family: VendorId,
) -> Self
pub fn new( domain: &str, target_class: TargetClass, vendor_family: VendorId, ) -> Self
Build a fresh, empty profile for the given key.
The observation_window_secs is seeded with
DEFAULT_SAMPLE_WINDOW_SECS and recorded_at_unix_secs
is seeded with the current wall-clock time (falling
back to a documented zero when the clock is
unavailable, so serialisation never fails).
Sourcepub const fn total_attempts(&self) -> u32
pub const fn total_attempts(&self) -> u32
Total number of attempts inside the window (solved + failed).
Sourcepub fn success_rate(&self) -> f64
pub fn success_rate(&self) -> f64
Solve success rate in [0.0, 1.0]. Returns 0.0 for
an empty profile.
Sourcepub fn average_retries(&self) -> f64
pub fn average_retries(&self) -> f64
Average retries per attempt. Returns 0.0 for an
empty profile.
Sourcepub fn failure_severity(&self) -> f64
pub fn failure_severity(&self) -> f64
Failure severity in [0.0, 1.0] — a weighted
average of PowFailureMode::severity_weight over the
failure histogram. Returns 0.0 for a profile with
no failed attempts.
Sourcepub fn merge(&mut self, sample: &PowCapabilitySample)
pub fn merge(&mut self, sample: &PowCapabilitySample)
Merge a PowCapabilitySample into the profile.
Latency p50/p95 are recomputed from the full set of
solved samples (in the order they were merged) — the
profile stores enough information to rebuild the
samples on demand (solved count + p50/p95), so the
merge is monotonic. The implementation updates
recorded_at_unix_secs to the current wall-clock time
so the store’s TTL semantics still apply on a
read-after-merge cycle.
Sourcepub fn merge_profile(&mut self, other: &Self)
pub fn merge_profile(&mut self, other: &Self)
Merge another PowCapabilityProfile into this one
(same key assumed; the caller’s domain,
target_class, and vendor_family are preserved
untouched).
The merged profile keeps the larger of the two
observation_window_secs values so a custom-widow
profile is not silently shrunk by a merge with a
default-widow one. recorded_at_unix_secs is
refreshed to the current wall-clock time.
Trait Implementations§
Source§impl Clone for PowCapabilityProfile
impl Clone for PowCapabilityProfile
Source§fn clone(&self) -> PowCapabilityProfile
fn clone(&self) -> PowCapabilityProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PowCapabilityProfile
impl Debug for PowCapabilityProfile
Source§impl<'de> Deserialize<'de> for PowCapabilityProfile
impl<'de> Deserialize<'de> for PowCapabilityProfile
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 PowCapabilityProfile
impl PartialEq for PowCapabilityProfile
Source§impl Serialize for PowCapabilityProfile
impl Serialize for PowCapabilityProfile
impl Eq for PowCapabilityProfile
impl StructuralPartialEq for PowCapabilityProfile
Auto Trait Implementations§
impl Freeze for PowCapabilityProfile
impl RefUnwindSafe for PowCapabilityProfile
impl Send for PowCapabilityProfile
impl Sync for PowCapabilityProfile
impl Unpin for PowCapabilityProfile
impl UnsafeUnpin for PowCapabilityProfile
impl UnwindSafe for PowCapabilityProfile
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.