pub struct ScoringWeights {
pub vector: f32,
pub warmth: f32,
pub recency: f32,
pub abstraction: f32,
pub graph: f32,
pub keyword: f32,
pub causal: f32,
}Expand description
Weights for deterministic scoring formula.
Seven orthogonal factors, each weight ∈ [0, 1], summing to 1.0 (±ε).
score = w_v·S_vector + w_w·S_warmth + w_r·S_recency
+ w_a·S_abstraction + w_g·S_graph + w_k·S_keyword
+ w_c·S_causalThe causal factor scores entities by their proximity to recent events
in the Event DAG. When no Event DAG data is available, adaptive weight
renormalization zeros causal and redistributes its budget to the
remaining factors.
Fields§
§vector: f32Cosine similarity between query embedding and entity embedding
warmth: f32Access frequency with temporal decay
recency: f32Creation time decay (newer = higher)
abstraction: f32Abstraction level (Principle > Summary > Raw)
graph: f32Graph proximity via edge traversal (degrees of separation)
keyword: f32Keyword/substring match score
causal: f32Event DAG causal proximity (how recently events reference this entity)
Implementations§
Source§impl ScoringWeights
impl ScoringWeights
Sourcepub fn validate(&self) -> bool
pub fn validate(&self) -> bool
Validate that all weights sum to 1.0 within epsilon tolerance.
The tolerance matches the PostgreSQL weights_sum_to_one CHECK
constraint: ABS(sum - 1.0) < 0.001.
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Normalize weights so they sum to exactly 1.0, preserving ratios.
§Mathematical Properties
- Idempotent:
normalize(normalize(w)) = normalize(w) - Ratio-preserving:
wᵢ/wⱼis invariant under normalization - No-op on zero: if all weights are 0, remains all zeros
Sourcepub fn legacy_six_factor() -> Self
pub fn legacy_six_factor() -> Self
Legacy 6-factor weights for backward compatibility.
Returns weights with causal = 0.0 and the original 6-factor
defaults. Useful when Event DAG is not available.
Sourcepub fn score(&self, factors: &ScoringFactors) -> f32
pub fn score(&self, factors: &ScoringFactors) -> f32
Compute the weighted score given per-factor raw scores.
Each raw score should be in [0, 1]. The result is in [0, 1] when weights are valid (sum to 1.0).
Non-finite factor values (NaN, ±Inf) are clamped to [0, 1] to prevent silent propagation through downstream scoring.
Trait Implementations§
Source§impl Clone for ScoringWeights
impl Clone for ScoringWeights
Source§fn clone(&self) -> ScoringWeights
fn clone(&self) -> ScoringWeights
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more