pub struct RiskContext {
pub guardrail_proximity_pct: Option<f64>,
pub halted: bool,
}Expand description
Engine-reported risk context the classifier/friction layer consults to escalate TILT → L3 or L4.
Defaults describe “engine is healthy, no proximity alert” so a
caller without engine access (test harnesses, headless replay)
gets pre-M2 behaviour: L2 cap, no escalation. Every field is
optional / boolean; the escalation is strictly a one-way bump
(never down-graded below from_label).
Fields§
§guardrail_proximity_pct: Option<f64>Distance in percentage points between the engine’s current
drawdown_pct and its last_drawdown_alert_pct threshold.
None when either field is missing from the engine mirror
(no proximity signal → no L3 escalation).
halted: boolAny of the halt booleans on Risk is set — see
Risk::is_halted. Setting this alongside Label::Tilt
escalates to L4.
Implementations§
Source§impl RiskContext
impl RiskContext
Sourcepub const PROXIMITY_PCT: f64 = 1.0
pub const PROXIMITY_PCT: f64 = 1.0
Threshold (in percentage points) within which TILT escalates to L3. Taken from M2_PLAN §3 (“guardrail-proximity within 1 percent of a hard limit”). The overlay-side threshold in §4 is separately tuned (0.5 pp) — do not unify without updating both plan rows.
Sourcepub fn from_engine(
drawdown_pct: Option<f64>,
last_drawdown_alert_pct: Option<f64>,
halted: bool,
) -> Self
pub fn from_engine( drawdown_pct: Option<f64>, last_drawdown_alert_pct: Option<f64>, halted: bool, ) -> Self
Construct a context from the engine mirror’s
drawdown_pct + last_drawdown_alert_pct pair, plus a halt
boolean. Returns the default (no-escalation) shape when
either percentage field is missing.
Sourcepub fn near_guardrail(&self) -> bool
pub fn near_guardrail(&self) -> bool
True when drawdown is within
Self::PROXIMITY_PCT of the last alert threshold. False
when the proximity reading is missing — the honest behaviour
is “no proximity signal → no escalation”, not “missing ⇒
conservatively escalate”, because the latter would penalise
an engine restart that hasn’t populated
last_drawdown_alert_pct yet.
Trait Implementations§
Source§impl Clone for RiskContext
impl Clone for RiskContext
Source§fn clone(&self) -> RiskContext
fn clone(&self) -> RiskContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more