pub fn adjust_runtime_policy(
policy: &RuntimePolicy,
memory: &ChallengeMemory,
key: &EngineKey,
) -> RuntimePolicyExpand description
Apply a bounded challenge-memory adjustment to an existing
RuntimePolicy.
The adjustment is looked up under the supplied EngineKey
and added to policy.risk_score; 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, EngineKey, MAX_RISK_DELTA,
};
use stygian_charon::types::{
ExecutionMode, RuntimePolicy, SessionMode, TargetClass, TelemetryLevel,
};
use stygian_charon::vendor_classifier::VendorId;
use std::collections::BTreeMap;
let memory = ChallengeMemory::with_defaults();
let key = EngineKey {
engine: VendorId::Cloudflare,
version: None,
target_class: TargetClass::ContentSite,
tls_profile: None,
};
memory.record(&key, None, 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, &key);
assert!(adjusted.risk_score >= base.risk_score);
assert!(adjusted.risk_score <= base.risk_score + MAX_RISK_DELTA);