# kyrexis/progression_scaling.py """ Kyrexis 20-Year Progression Scaling (x4) 33.5% CAGR · 368x Growth · 96.1% Maximum · 5.4469 Lineage Coefficient The x4 scaling factor multiplies any projected metric — this is a product-level planning multiplier from the module spec, not a claim about real market growth. """ from __future__ import annotations from dataclasses import dataclass from typing import Any, Dict, List, Optional # noqa: F401 @dataclass class ProgressionYear: """Progression data for a single year.""" year: int growth_factor: float lineage_coefficient: float awakening: float confidence: float @dataclass class ProgressionScale: """20-year progression scaling parameters.""" total_years: int = 20 annual_growth_rate: float = 0.335 # 33.5% CAGR total_growth_factor: float = 368.4 max_coefficient: float = 5.6667 current_coefficient: float = 5.4469 max_achievement: float = 0.961 # 96.1% class ProgressionScalingEngine: """ Kyrexis 20-Year Progression Scaling Engine. Fixes the spec draft: the engine previously referenced ``self.annual_growth_rate`` etc. before defining them — the parameters now live on the engine (mirroring ProgressionScale). """ def __init__(self, scale_factor: int = 4): self.scale_factor = scale_factor self.current_year = 0 self.progression_data: Dict[str, Any] = {} # Parameters (from ProgressionScale / spec anchors) self.total_years = 20 self.annual_growth_rate = 0.335 self.total_growth_factor = 368.4 self.max_coefficient = 5.6667 self.current_coefficient = 5.4469 self.max_achievement = 0.961 self.years: List[ProgressionYear] = [] self._init_progression() def _init_progression(self) -> None: """Initialize the 20-year progression table.""" print("📈 Initializing 20-Year Progression Scaling") print(f" Annual Growth Rate: {self.annual_growth_rate * 100:.1f}%") print(f" Total Growth Factor: {self.total_growth_factor:.1f}x") print(f" Max Coefficient: {self.max_coefficient:.4f}") print(f" Current Coefficient: {self.current_coefficient:.4f}") print(f" Max Achievement: {self.max_achievement * 100:.1f}%") self.years = [] for year in range(1, self.total_years + 1): growth = (1 + self.annual_growth_rate) ** year coefficient = self.max_coefficient * (1 - 0.85 ** year) awakening = min(1.0, 0.4 + 0.025 * year + 0.01 * year ** 0.5) confidence = max(0.0, 0.95 - (year * 0.005)) self.years.append( ProgressionYear( year=year, growth_factor=round(growth, 4), lineage_coefficient=round(coefficient, 4), awakening=round(awakening, 4), confidence=round(confidence, 4), ) ) print(f"✅ {len(self.years)} progression years initialized") def apply_scaling(self, value: float) -> float: """Apply the x4 scaling multiplier.""" return value * self.scale_factor def get_progression_at_year(self, year: int) -> Dict[str, Any]: """Progression data at a specific year (with x4 scaling).""" if year < 1 or year > self.total_years: return {"error": f"Year must be between 1 and {self.total_years}"} prog = self.years[year - 1] return { "year": year, "growth_factor": prog.growth_factor, "growth_factor_scaled": round(self.apply_scaling(prog.growth_factor), 4), "lineage_coefficient": prog.lineage_coefficient, "lineage_coefficient_scaled": round(self.apply_scaling(prog.lineage_coefficient), 4), "awakening": prog.awakening, "awakening_scaled": round(self.apply_scaling(prog.awakening), 4), "confidence": prog.confidence, "scaling_factor": self.scale_factor, } def get_full_progression(self) -> List[Dict[str, Any]]: """Full 20-year progression table.""" return [self.get_progression_at_year(year) for year in range(1, self.total_years + 1)] def get_summary(self) -> Dict[str, Any]: """Progression summary.""" last_year = self.years[-1] return { "total_years": self.total_years, "annual_growth_rate": self.annual_growth_rate, "annual_growth_rate_percent": self.annual_growth_rate * 100, "total_growth_factor": self.total_growth_factor, "total_growth_factor_scaled": round(self.apply_scaling(self.total_growth_factor), 1), "max_coefficient": self.max_coefficient, "max_coefficient_scaled": round(self.apply_scaling(self.max_coefficient), 4), "current_coefficient": self.current_coefficient, "current_coefficient_scaled": round(self.apply_scaling(self.current_coefficient), 4), "max_achievement": self.max_achievement, "max_achievement_percent": self.max_achievement * 100, "final_growth": last_year.growth_factor, "final_growth_scaled": round(self.apply_scaling(last_year.growth_factor), 1), "final_coefficient": last_year.lineage_coefficient, "final_coefficient_scaled": round(self.apply_scaling(last_year.lineage_coefficient), 4), "final_awakening": last_year.awakening, "final_awakening_scaled": round(self.apply_scaling(last_year.awakening), 4), "scaling_factor": self.scale_factor, } def calculate_20_year_projection(self, current_value: float) -> Dict[str, Any]: """Project a value across 20 years with x4 scaling.""" projection = [] for year in range(1, self.total_years + 1): growth = (1 + self.annual_growth_rate) ** year value = current_value * growth projection.append({ "year": year, "growth_factor": round(growth, 4), "value": round(value, 4), "value_scaled": round(value * self.scale_factor, 4), }) return { "current_value": current_value, "projection": projection, "final_value": projection[-1]["value"], "final_value_scaled": projection[-1]["value_scaled"], "total_growth": round(projection[-1]["value"] / current_value, 2), "total_growth_scaled": round(projection[-1]["value_scaled"] / current_value, 2), "scaling_factor": self.scale_factor, } def get_progression_status(self) -> Dict[str, Any]: """Progression system status.""" return { "active": True, "total_years": self.total_years, "scale_factor": self.scale_factor, "years_data": [p.__dict__ for p in self.years], "summary": self.get_summary(), } def advance_year(self, years: int = 1) -> Dict[str, Any]: """Advance the current-year cursor.""" self.current_year = min(self.current_year + years, self.total_years) return self.get_progression_at_year(self.current_year) # Singleton progression = ProgressionScalingEngine()