pub struct T3 { /* private fields */ }Expand description
A 3-dimensional trust tensor with fractal sub-dimension support
Implementations§
Source§impl T3
impl T3
Sourcepub fn with_scores(scores: [f64; 3]) -> Result<Self>
pub fn with_scores(scores: [f64; 3]) -> Result<Self>
Create a T3 with specific initial root scores
Sourcepub fn from_parts(scores: [f64; 3], observation_counts: [u64; 3]) -> Self
pub fn from_parts(scores: [f64; 3], observation_counts: [u64; 3]) -> Self
Reconstruct a T3 from persisted parts: root scores + per-dimension
observation counts. Weights are recomputed from the counts using the
same logarithmic formula as T3::apply_delta/T3::observe, so a
tensor that is saved and re-loaded keeps its confidence without having
to replay its observation history. Scores are clamped to [0, 1].
This is the persistence-round-trip constructor used by at-rest stores
(e.g. sealed EntityTrust files): the serialized form carries the three
root scores plus their observation counts, and this rebuilds the exact
tensor state. Sub-dimensions are not part of the persisted parts and are
initialized empty.
Sourcepub fn score(&self, dimension: TrustDimension) -> f64
pub fn score(&self, dimension: TrustDimension) -> f64
Get the score for a root dimension
Sourcepub fn weight(&self, dimension: TrustDimension) -> f64
pub fn weight(&self, dimension: TrustDimension) -> f64
Get the weight (confidence) for a root dimension
Sourcepub fn observation_counts(&self) -> &[u64; 3]
pub fn observation_counts(&self) -> &[u64; 3]
Get all per-dimension observation counts.
Exposes the raw evidence counts so persistence layers can serialize and
later restore confidence via T3::from_parts. Weights are a pure
function of these counts, so this is sufficient to round-trip state.
Sourcepub fn sub_dimensions(&self) -> &HashMap<String, SubDimensionScore>
pub fn sub_dimensions(&self) -> &HashMap<String, SubDimensionScore>
Get sub-dimensions map
Sourcepub fn apply_delta(&mut self, dimension: TrustDimension, delta: f64) -> f64
pub fn apply_delta(&mut self, dimension: TrustDimension, delta: f64) -> f64
Record an observation for a root dimension
Uses exponential moving average with decay factor based on observation count
Apply a signed reputation delta directly to a dimension, clamped to
[0, 1], counting it as one observation. This is how a
ReputationDelta from an R7 action outcome
— e.g. a missed deadline debiting Temperament — folds into the tensor.
Returns the realized change after clamping.
pub fn observe( &mut self, dimension: TrustDimension, observed_score: f64, ) -> Result<()>
Sourcepub fn observe_sub_dimension(
&mut self,
name: &str,
parent: TrustDimension,
observed_score: f64,
) -> Result<()>
pub fn observe_sub_dimension( &mut self, name: &str, parent: TrustDimension, observed_score: f64, ) -> Result<()>
Record an observation for a sub-dimension
Sub-dimensions are keyed by name and linked to a root dimension. Uses the same EMA math as root dimensions.
Sourcepub fn aggregate(&self) -> f64
pub fn aggregate(&self) -> f64
Compute the aggregate trust score (weighted geometric mean)
Geometric mean ensures that a zero in any dimension zeros the total, reflecting that trust requires all dimensions to be positive.
Sourcepub fn merge(&self, other: &T3) -> Self
pub fn merge(&self, other: &T3) -> Self
Merge with another T3 using weighted average
The merge is weighted by the observation counts in each tensor
Sourcepub fn decay(&mut self, decay_factor: f64)
pub fn decay(&mut self, decay_factor: f64)
Apply time decay to the tensor
Trust that isn’t reinforced decays toward neutral (0.5) over time. The decay_factor should be in (0, 1), where smaller = faster decay.
Sourcepub fn meets_thresholds(&self, min_scores: &[f64; 3]) -> bool
pub fn meets_thresholds(&self, min_scores: &[f64; 3]) -> bool
Check if trust meets minimum thresholds