Skip to main content

GrammarState

Enum GrammarState 

Source
pub enum GrammarState {
    Admissible,
    Boundary(ReasonCode),
    Violation,
}
Expand description

The DSFB grammar state — the typed intermediate representation.

This is what operators see instead of a scalar alarm count. The typed state encodes both the severity and the structural character of the observed residual trajectory.

Variants§

§

Admissible

Residual within envelope, drift inward or bounded. Nominal operation.

§

Boundary(ReasonCode)

Residual approaching envelope boundary with sustained outward drift or recurrent grazing. Early-warning state.

§

Violation

Residual has exited envelope. Structural fault state.

Implementations§

Source§

impl GrammarState

Source

pub fn requires_attention(&self) -> bool

Returns true if this state warrants any operator attention.

Source

pub fn is_violation(&self) -> bool

Returns true if this is a Violation state.

Source

pub fn is_boundary(&self) -> bool

Returns true if this is a Boundary state.

Source

pub fn severity(&self) -> u8

Severity level: 0=Admissible, 1=Boundary, 2=Violation.

Source

pub fn severity_trust(&self) -> f32

Severity-based trust scalar T ∈ [0, 1].

Returns a deterministic, bounded trust weight that downstream stages can use to down-weight grammar evidence that is already at boundary or violation. This is the semiotics-engine trust_scalar_for() severity dimension (de Beer 2026, §IV):

  • Admissible → 1.0 (full trust: nominal region, no structural concern)
  • Boundary → 0.5 (half trust: approach region, evidence partial)
  • Violation → 0.0 (no trust: outside envelope, evidence suppressed)

Use geometry_trust() for a continuous, geometry-aware version.

Source

pub fn geometry_trust(norm: f32, rho: f32, band_frac: f32) -> f32

Geometry-based grammar trust scalar T ∈ [0, 1].

Provides a continuous trust measure based on how far inside the admissibility envelope the current residual norm lies, within the boundary band. Derived from semiotics-engine eq. (trust_scalar_for):

margin        = (ρ − ‖r‖) / ρ              (normalised inward distance)
T             = clamp(margin / band_frac, 0, 1)

band_frac is the boundary band width as a fraction of ρ (semiotics-engine default: 0.04 = 4 %).

§Semantics
  • T = 1.0: residual deep inside envelope — full confidence
  • T ≈ 0.5: residual halfway through the boundary band
  • T = 0.0: residual at or outside the envelope boundary — suppressed

Independent of grammar state: can be used even when the FSM is in Admissible but the norm is close to ρ.

Source

pub fn combined_trust(&self, norm: f32, rho: f32, band_frac: f32) -> f32

Combined grammar trust scalar: minimum of severity_trust and geometry_trust.

Takes the more conservative of the two trust dimensions. This is the recommended scalar for downstream weighting (e.g., DSA score blending, HRET combination).

Trait Implementations§

Source§

impl Clone for GrammarState

Source§

fn clone(&self) -> GrammarState

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 GrammarState

Source§

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

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

impl PartialEq for GrammarState

Source§

fn eq(&self, other: &GrammarState) -> 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 Copy for GrammarState

Source§

impl StructuralPartialEq for GrammarState

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, 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.