plexus.analysis.memory_weights module

Memory weights: reinforcement and decay for topic clusters.

Clusters that receive new documents are reinforced (weight -> 1.0). Clusters with no new documents decay (weight -> 0.0). Tiers: hot >= 0.7, warm >= 0.3, cold < 0.3.

plexus.analysis.memory_weights.decay(weight: float, days: int, rate: float = 0.05) float

Decrease weight toward 0.0 based on days since last reinforcement.

plexus.analysis.memory_weights.initial_weight() float

Neutral starting weight for new clusters.

plexus.analysis.memory_weights.reinforce(weight: float, new_docs: int, rate: float = 0.1) float

Increase weight toward 1.0 based on new document count.

plexus.analysis.memory_weights.should_prune(weight: float, threshold: float = 0.1) bool

Return True if weight is below prune threshold.

plexus.analysis.memory_weights.tier_from_weight(weight: float, hot_threshold: float = 0.7, warm_threshold: float = 0.3) str

Map weight to hot/warm/cold tier.

plexus.analysis.memory_weights.update_memory_weights(existing_clusters: List[Dict[str, Any]], active_cluster_ids: List[int], days_inactive: Dict[int, int] | None = None, reinforce_rate: float = 0.1, decay_rate: float = 0.05, prune_threshold: float = 0.1, prune: bool = True) Tuple[List[Dict[str, Any]], List[int]]

Compute updated weights and tiers for clusters. Returns (updated_clusters, pruned_cluster_ids).