feat: competitive intelligence & historical pattern matching layer
This commit is contained in:
@@ -110,6 +110,19 @@ BUCKET_RETENTION_FIELDS: dict[str, str] = {
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class MacroConfig:
|
||||
"""Configuration for the macro news interpolation layer.
|
||||
|
||||
Requirements: 5.6, 10.1, 10.2, 12.9
|
||||
"""
|
||||
macro_signal_weight: float = 0.3 # relative weight of macro vs company signals
|
||||
macro_enabled: bool = True # runtime toggle state (default on)
|
||||
macro_confidence_threshold: float = 0.4 # minimum confidence for event inclusion
|
||||
macro_short_term_staleness_hours: int = 48 # hours after which short-term events get accelerated decay
|
||||
projection_confidence_threshold: float = 0.3 # minimum confidence for projections to influence recommendations
|
||||
|
||||
|
||||
@dataclass
|
||||
class AlertingConfig:
|
||||
"""Thresholds for operational alerting rules.
|
||||
@@ -135,6 +148,26 @@ class AlertingConfig:
|
||||
check_interval_seconds: int = 120
|
||||
|
||||
|
||||
@dataclass
|
||||
class CompetitiveConfig:
|
||||
"""Configuration for the competitive intelligence & historical pattern matching layer.
|
||||
|
||||
Requirements: 5.6, 6.1, 9.1, 9.2, 11.2, 11.3
|
||||
"""
|
||||
competitive_signal_weight: float = 0.2
|
||||
competitive_enabled: bool = True
|
||||
pattern_confidence_threshold: float = 0.3
|
||||
propagation_strength_threshold: float = 0.2
|
||||
routine_lookback_days: int = 180
|
||||
major_decision_lookback_days: int = 365
|
||||
major_decision_weight_multiplier: float = 1.3
|
||||
staleness_window_days: int = 180
|
||||
staleness_recent_days: int = 90
|
||||
staleness_decay_penalty: float = 0.5
|
||||
min_pattern_samples: int = 3
|
||||
propagation_failure_threshold: int = 5 # consecutive failures before operator alert
|
||||
|
||||
|
||||
@dataclass
|
||||
class AppConfig:
|
||||
postgres: PostgresConfig = field(default_factory=PostgresConfig)
|
||||
@@ -146,6 +179,8 @@ class AppConfig:
|
||||
broker: BrokerConfig = field(default_factory=BrokerConfig)
|
||||
retention: RetentionConfig = field(default_factory=RetentionConfig)
|
||||
alerting: AlertingConfig = field(default_factory=AlertingConfig)
|
||||
macro: MacroConfig = field(default_factory=MacroConfig)
|
||||
competitive: CompetitiveConfig = field(default_factory=CompetitiveConfig)
|
||||
log_level: str = "INFO"
|
||||
json_logs: bool = True
|
||||
|
||||
@@ -222,6 +257,27 @@ def load_config() -> AppConfig:
|
||||
broker_error_window_hours=int(os.getenv("ALERT_BROKER_ERROR_WINDOW_HOURS", "1")),
|
||||
check_interval_seconds=int(os.getenv("ALERT_CHECK_INTERVAL_SECONDS", "120")),
|
||||
),
|
||||
macro=MacroConfig(
|
||||
macro_signal_weight=float(os.getenv("MACRO_SIGNAL_WEIGHT", "0.3")),
|
||||
macro_enabled=os.getenv("MACRO_ENABLED", "true").lower() == "true",
|
||||
macro_confidence_threshold=float(os.getenv("MACRO_CONFIDENCE_THRESHOLD", "0.4")),
|
||||
macro_short_term_staleness_hours=int(os.getenv("MACRO_SHORT_TERM_STALENESS_HOURS", "48")),
|
||||
projection_confidence_threshold=float(os.getenv("PROJECTION_CONFIDENCE_THRESHOLD", "0.3")),
|
||||
),
|
||||
competitive=CompetitiveConfig(
|
||||
competitive_signal_weight=float(os.getenv("COMPETITIVE_SIGNAL_WEIGHT", "0.2")),
|
||||
competitive_enabled=os.getenv("COMPETITIVE_ENABLED", "true").lower() == "true",
|
||||
pattern_confidence_threshold=float(os.getenv("COMPETITIVE_PATTERN_CONFIDENCE_THRESHOLD", "0.3")),
|
||||
propagation_strength_threshold=float(os.getenv("COMPETITIVE_PROPAGATION_STRENGTH_THRESHOLD", "0.2")),
|
||||
routine_lookback_days=int(os.getenv("COMPETITIVE_ROUTINE_LOOKBACK_DAYS", "180")),
|
||||
major_decision_lookback_days=int(os.getenv("COMPETITIVE_MAJOR_DECISION_LOOKBACK_DAYS", "365")),
|
||||
major_decision_weight_multiplier=float(os.getenv("COMPETITIVE_MAJOR_DECISION_WEIGHT_MULTIPLIER", "1.3")),
|
||||
staleness_window_days=int(os.getenv("COMPETITIVE_STALENESS_WINDOW_DAYS", "180")),
|
||||
staleness_recent_days=int(os.getenv("COMPETITIVE_STALENESS_RECENT_DAYS", "90")),
|
||||
staleness_decay_penalty=float(os.getenv("COMPETITIVE_STALENESS_DECAY_PENALTY", "0.5")),
|
||||
min_pattern_samples=int(os.getenv("COMPETITIVE_MIN_PATTERN_SAMPLES", "3")),
|
||||
propagation_failure_threshold=int(os.getenv("COMPETITIVE_PROPAGATION_FAILURE_THRESHOLD", "5")),
|
||||
),
|
||||
log_level=os.getenv("LOG_LEVEL", "INFO"),
|
||||
json_logs=os.getenv("JSON_LOGS", "true").lower() == "true",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user