Skip to main content

FrictionLevel

Enum FrictionLevel 

Source
pub enum FrictionLevel {
    L0,
    L1,
    L2,
    L3,
    L4,
}
Expand description

The friction escalator’s current level.

Level definitions come straight from Addendum A §3.1. Every variant is reachable: L0–L2 from FrictionLevel::from_label alone, L3/L4 from FrictionLevel::from_label_and_risk when the engine reports guardrail proximity or a halt flag alongside a TILT label. See M2_PLAN §3.

Variants§

§

L0

No friction — FRESH / STEADY / RECOVERY.

§

L1

3 s visible countdown before execute — ELEVATED.

§

L2

10 s pause + typed execute — TILT.

§

L3

30 s pause + typed re-read of the guardrail-proximity disclosure — TILT and engine-reported drawdown within RiskContext::PROXIMITY_PCT of the last alert threshold. The command still runs if the operator completes the re-read; this is a deliberate friction bump, not a refusal.

§

L4

Hard refusal — TILT and the engine reports any halt flag (risk.halted, global_halt, stop_failure_halt). Risk-increasing commands are dropped; only Reduces (/kill, /flatten-all, /close, /break, …) continue to pass through the un-gated path. This is the dead-man switch — a tired operator at 2 AM must not be able to reach for a risk-increasing command while the engine is already halted.

Implementations§

Source§

impl FrictionLevel

Source

pub const fn from_label(label: Label) -> Self

Map a state Label to its default friction level.

This form is capped at L2 and is the right call when the caller has no engine risk context — tests, the classifier’s pure classify(now) entrypoint, replay harnesses. Use FrictionLevel::from_label_and_risk from the dispatcher, which does see the engine mirror, to reach L3/L4.

Source

pub fn from_label_and_risk(label: Label, risk: RiskContext) -> Self

Map a (label, risk) pair to the full friction level, including the M2 L3/L4 escalations.

Escalation is one-way and TILT-gated:

L4 beats L3 when both conditions trip — the dead-man switch is the stronger signal.

Source

pub const fn pause(self) -> Duration

Required pause duration before execution.

L3 is 30 s — the spec’s “mandatory pause + re-read the exact disclosure phrase” window. L4 is 15 min for the pathological case that the operator clears the halt in that window; in practice L4 is rendered as a refusal and never reaches a timer.

Source

pub const fn requires_typed_confirm(self) -> bool

Whether the confirmation step requires typing a word/phrase rather than a single key. TILT and above switch away from single-key e to typed confirmations — execute at L2, the full proximity disclosure at L3 (§6.2, §3.2).

Source

pub const fn is_refusal(self) -> bool

True when this level is a refusal — the command is dropped, no pause can redeem it. Only L4 is a refusal.

This is the load-bearing check for “a tilted operator must not reach for a risk-increasing command while the engine is already halted”. See RiskContext and M2_PLAN §3.

Trait Implementations§

Source§

impl Clone for FrictionLevel

Source§

fn clone(&self) -> FrictionLevel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FrictionLevel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FrictionLevel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Ord for FrictionLevel

Source§

fn cmp(&self, other: &FrictionLevel) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for FrictionLevel

Source§

fn eq(&self, other: &FrictionLevel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for FrictionLevel

Source§

fn partial_cmp(&self, other: &FrictionLevel) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for FrictionLevel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for FrictionLevel

Source§

impl Eq for FrictionLevel

Source§

impl StructuralPartialEq for FrictionLevel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,