pub fn adjust_runtime_policy(
policy: &RuntimePolicy,
memory: &ChallengeMemory,
domain: &str,
target_class: TargetClass,
) -> RuntimePolicyExpand description
Apply a bounded challenge-memory adjustment to an existing
RuntimePolicy.
The adjustment is added to policy.risk_score and the result is
re-clamped to [0.0, 1.0]. The adjustment itself is
per-key clamped to
ChallengeFeedbackPolicy::max_delta
(default MAX_RISK_DELTA = 0.20) before being added, so a single
entry can never shift the risk score by more than the documented
ceiling.
ยงExample
use stygian_charon::challenge_feedback::{
adjust_runtime_policy, ChallengeMemory, ChallengeOutcome, MAX_RISK_DELTA,
};
use stygian_charon::types::{
ExecutionMode, RuntimePolicy, SessionMode, TargetClass, TelemetryLevel,
};
use std::collections::BTreeMap;
let memory = ChallengeMemory::with_defaults();
memory.record("example.com", TargetClass::ContentSite, ChallengeOutcome::Captcha);
let base = RuntimePolicy {
execution_mode: ExecutionMode::Http,
session_mode: SessionMode::Stateless,
telemetry_level: TelemetryLevel::Standard,
rate_limit_rps: 3.0,
max_retries: 2,
backoff_base_ms: 250,
enable_warmup: false,
enforce_webrtc_proxy_only: false,
sticky_session_ttl_secs: None,
required_stygian_features: Vec::new(),
config_hints: BTreeMap::new(),
risk_score: 0.30,
};
let adjusted = adjust_runtime_policy(&base, &memory, "example.com", TargetClass::ContentSite);
assert!(adjusted.risk_score >= base.risk_score);
assert!(adjusted.risk_score <= base.risk_score + MAX_RISK_DELTA);