Skip to main content

FactState

Struct FactState 

Source
pub struct FactState {
Show 18 fields pub fact_id: FactId, pub subject: Subject, pub predicate: Predicate, pub value: FactValue, pub authority: Authority, pub ttl: Ttl, pub freshness_anchor: TimestampMillis, pub valid_from: Option<TimestampMillis>, pub valid_to: Option<TimestampMillis>, pub lifecycle: FactLifecycle, pub created_at: TimestampMillis, pub updated_at: TimestampMillis, pub last_event_id: FactEventId, pub superseded_by: Option<FactId>, pub contradicted_by: Vec<FactId>, pub evidence_count: usize, pub corroborating_sources: BTreeMap<SourceId, AuthorityLevel>, pub survived_challenges: BTreeMap<SourceId, AuthorityLevel>,
}
Expand description

The current projected state of a fact — the fold of its event stream. Serializable so a backend may materialize it (cache it as a derived row) or transmit it; it remains a pure projection of the log, never an independent source of truth.

Fields§

§fact_id: FactId§subject: Subject§predicate: Predicate§value: FactValue§authority: Authority

Entrenchment of the incumbent fact, captured at assertion. Drives authority-weighted supersession arbitration; see docs/belief-revision.md.

§ttl: Ttl

TTL captured at assertion, used by FactState::is_expired_at for read-time freshness evaluation.

§freshness_anchor: TimestampMillis

Valid-time anchor for TTL freshness: valid_from, else observed_at, else the assertion’s recorded_at.

§valid_from: Option<TimestampMillis>

The asserted valid-time lower bound (ADR 0016), kept distinct from freshness_anchor (which falls back to observed_at/recorded_at): a fact whose valid_from is in the future is not yet valid, so read-time freshness treats it as not-fresh until then. #[serde(default)] for projections materialized before it.

§valid_to: Option<TimestampMillis>

Valid-time upper bound captured at assertion (ADR 0016): the instant the fact is asserted to stop holding. Read-time freshness treats an elapsed valid_to exactly like an elapsed TTL; lifecycle is untouched. #[serde(default)] so projections materialized before the field existed still deserialize.

§lifecycle: FactLifecycle§created_at: TimestampMillis§updated_at: TimestampMillis§last_event_id: FactEventId§superseded_by: Option<FactId>§contradicted_by: Vec<FactId>§evidence_count: usize§corroborating_sources: BTreeMap<SourceId, AuthorityLevel>

The distinct provenance sources that have asserted or reinforced this exact value, each mapped to the highest authority it backed at. This measures same-value corroboration only — surviving a challenge is the separate entrenchment signal tracked in FactState::survived_challenges (ADR 0015). The asserter is the first entry.

§survived_challenges: BTreeMap<SourceId, AuthorityLevel>

The distinct sources whose challenge against this fact the firewall rejected, each mapped to the highest effective authority it challenged at (ADR 0015) — the “attacked and stood” half of earned entrenchment. #[serde(default)] so projections materialized before the field existed still deserialize.

Implementations§

Source§

impl FactState

Source

pub fn corroboration(&self) -> usize

Raw earned-entrenchment degree: the number of distinct sources backing this value. Sybil-inflatable on its own (an attacker minting many sources raises it), so security decisions should use FactState::corroboration_at_or_above to count only sufficiently-authoritative backers.

Source

pub fn corroboration_at_or_above(&self, min: AuthorityLevel) -> usize

Authority-weighted corroboration: the number of distinct backing sources whose authority is at least min. This is the Sybil-resistant entrenchment signal — minting low-authority sources cannot raise the count measured at a higher floor.

Source

pub fn survived_challenge_count(&self) -> usize

Raw survived-challenge degree: distinct sources whose challenge this fact survived. Sybil-inflatable like FactState::corroboration; security decisions should use FactState::survived_challenges_at_or_above.

Source

pub fn survived_challenges_at_or_above(&self, min: AuthorityLevel) -> usize

Authority-weighted survived challenges: distinct challengers whose effective authority was at least min when they challenged and lost. Minting low-authority challengers cannot simulate surviving strong attacks.

Source

pub fn earned_entrenchment_at_or_above(&self, min: AuthorityLevel) -> usize

Earned entrenchment at min (ADR 0017): the sum of both Sybil-resistant halves — independent backing (Self::corroboration_at_or_above) plus having-been-attacked-and-held (Self::survived_challenges_at_or_above), each counted only at authority ≥ min. This is the measure the opt-in supersession gate and the subject-level unearned-supersession audit compare, so a fact that survived challenges resists an equal-authority replacement as much as one with extra backing does.

Source

pub fn expires_at(&self) -> Option<TimestampMillis>

When this fact stops being fresh, if ever: the earliest of its TTL bound (relative to the freshness anchor) and its asserted valid_to (ADR 0016).

Source

pub fn is_not_yet_valid_at(&self, now: TimestampMillis) -> bool

Whether the fact is not yet valid at now (ADR 0016): its asserted valid_from is in the future. Distinct from expiry — a not-yet-valid fact reads as not-fresh because it has not started holding, not because it has stopped.

Source

pub fn is_fresh_at(&self, now: TimestampMillis) -> bool

Whether the fact is fresh at now: within its validity window — at or after valid_from (if set) and not past its TTL / valid_to upper bound. This is the read-time freshness predicate the receipt’s fresh flag reports; it does not consult lifecycle (a superseded fact can still be within its window).

Source

pub fn is_expired_at(&self, now: TimestampMillis) -> bool

Whether the fact’s freshness has elapsed at now — its TTL ran out or its asserted validity ended. A fact with Ttl::Never and no valid_to is never expired. Purely the upper bound; the lower bound is Self::is_not_yet_valid_at. It does not consult lifecycle (a superseded fact can still be “unexpired” by TTL).

Trait Implementations§

Source§

impl Clone for FactState

Source§

fn clone(&self) -> FactState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FactState

Source§

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

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

impl<'de> Deserialize<'de> for FactState

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 Eq for FactState

Source§

impl PartialEq for FactState

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for FactState

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 StructuralPartialEq for FactState

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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.