petter2025 commited on
Commit
9846bab
·
verified ·
1 Parent(s): eccf061

Create config/settings.py

Browse files
Files changed (1) hide show
  1. config/settings.py +143 -0
config/settings.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Configuration management for ARF Demo
3
+ """
4
+ from pydantic import BaseSettings, Field, validator
5
+ from typing import Optional, Dict, Any, List
6
+ from enum import Enum
7
+ import os
8
+
9
+
10
+ class ARFMode(str, Enum):
11
+ """ARF operation modes"""
12
+ DEMO = "demo"
13
+ OSS = "oss"
14
+ ENTERPRISE = "enterprise"
15
+
16
+
17
+ class SafetyMode(str, Enum):
18
+ """Safety modes for execution"""
19
+ ADVISORY = "advisory"
20
+ APPROVAL = "approval"
21
+ AUTONOMOUS = "autonomous"
22
+
23
+
24
+ class Settings(BaseSettings):
25
+ """
26
+ Application settings with environment variable support
27
+ """
28
+
29
+ # ===== System Mode =====
30
+ arf_mode: ARFMode = Field(
31
+ default=ARFMode.DEMO,
32
+ description="ARF operation mode"
33
+ )
34
+
35
+ use_mock_arf: bool = Field(
36
+ default=True,
37
+ description="Use mock ARF implementation (for demo mode)"
38
+ )
39
+
40
+ # ===== ARF Configuration =====
41
+ arf_api_key: Optional[str] = Field(
42
+ default=None,
43
+ description="ARF API key for real integration"
44
+ )
45
+
46
+ arf_base_url: str = Field(
47
+ default="https://api.arf.dev",
48
+ description="ARF API base URL"
49
+ )
50
+
51
+ # ===== Business Configuration =====
52
+ engineer_hourly_rate: float = Field(
53
+ default=150.0,
54
+ ge=50.0,
55
+ le=500.0,
56
+ description="Engineer hourly rate in USD"
57
+ )
58
+
59
+ engineer_annual_cost: float = Field(
60
+ default=125000.0,
61
+ ge=50000.0,
62
+ le=250000.0,
63
+ description="Engineer annual cost in USD"
64
+ )
65
+
66
+ default_savings_rate: float = Field(
67
+ default=0.82,
68
+ ge=0.5,
69
+ le=0.95,
70
+ description="Default savings rate with ARF"
71
+ )
72
+
73
+ # ===== UI Configuration =====
74
+ auto_refresh_seconds: int = Field(
75
+ default=30,
76
+ ge=5,
77
+ le=300,
78
+ description="Auto-refresh interval in seconds"
79
+ )
80
+
81
+ max_history_items: int = Field(
82
+ default=100,
83
+ ge=10,
84
+ le=1000,
85
+ description="Maximum history items to display"
86
+ )
87
+
88
+ # ===== Demo Configuration =====
89
+ default_scenario: str = Field(
90
+ default="Cache Miss Storm",
91
+ description="Default incident scenario"
92
+ )
93
+
94
+ scenario_config_path: str = Field(
95
+ default="config/scenarios",
96
+ description="Path to scenario configuration files"
97
+ )
98
+
99
+ # ===== Safety Configuration =====
100
+ default_safety_mode: SafetyMode = Field(
101
+ default=SafetyMode.ADVISORY,
102
+ description="Default safety mode"
103
+ )
104
+
105
+ require_approval: bool = Field(
106
+ default=True,
107
+ description="Require human approval for execution"
108
+ )
109
+
110
+ # ===== Validation =====
111
+ @validator("arf_api_key")
112
+ def validate_api_key(cls, v: Optional[str], values: Dict[str, Any]) -> Optional[str]:
113
+ if values.get("arf_mode") == ARFMode.ENTERPRISE and not v:
114
+ raise ValueError("ARF API key required for Enterprise mode")
115
+ return v
116
+
117
+ @validator("use_mock_arf")
118
+ def validate_mock_mode(cls, v: bool, values: Dict[str, Any]) -> bool:
119
+ if values.get("arf_mode") == ARFMode.DEMO:
120
+ return True
121
+ return v
122
+
123
+ class Config:
124
+ env_file = ".env"
125
+ env_file_encoding = "utf-8"
126
+ case_sensitive = False
127
+ use_enum_values = True
128
+
129
+
130
+ # Global settings instance
131
+ settings = Settings()
132
+
133
+
134
+ def get_settings() -> Settings:
135
+ """Get settings instance (singleton pattern)"""
136
+ return settings
137
+
138
+
139
+ def reload_settings() -> Settings:
140
+ """Reload settings from environment"""
141
+ global settings
142
+ settings = Settings()
143
+ return settings