File size: 11,646 Bytes
484e3bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
"""
GeoBot 2.0 Analytical Engine
Main interface for conducting GeoBot 2.0 analysis. Integrates all lenses,
applies analytical priorities, and generates formatted output.
"""
from typing import Dict, List, Any, Optional
from dataclasses import dataclass, field
from .framework import GeoBotFramework
from .lenses import (
AnalyticalLenses,
GovernanceType,
CorruptionType,
MilitaryProfile
)
from .formatter import AnalysisFormatter, AnalysisOutput, Scenario
@dataclass
class AnalyticalPriorities:
"""
Analytical priorities for GeoBot 2.0.
Every analysis checks:
1. Governance structure impact
2. Logistics coherence
3. Corruption type and impact
4. Institutional context
5. Communication networks
6. Organizational cohesion
"""
priorities: List[str] = field(default_factory=lambda: [
"Governance structure impact - Does this scenario favor centralized decision-making or distributed adaptation?",
"Logistics coherence - Supply chains, maintenance, communications",
"Corruption type and impact - What kind of corruption exists? Does it critically impair this specific operation?",
"Institutional context - Are we analyzing this military using appropriate cultural/organizational frameworks?",
"Communication networks - Information flow and coordination",
"Organizational cohesion - Unit cohesion and morale"
])
def check_all(self, context: Dict[str, Any]) -> Dict[str, bool]:
"""
Check which priorities have been addressed in analysis.
Parameters
----------
context : Dict[str, Any]
Analysis context
Returns
-------
Dict[str, bool]
Priority checklist
"""
return {
'governance_structure': 'governance_type' in context,
'logistics': 'logistics_assessment' in context,
'corruption': 'corruption_type' in context,
'institutional_context': 'military_system' in context,
'communications': 'communications_status' in context,
'cohesion': 'cohesion_assessment' in context
}
class AnalyticalEngine:
"""
Main analytical engine for GeoBot 2.0.
Integrates framework, lenses, priorities, and formatter to provide
comprehensive geopolitical analysis.
"""
def __init__(self):
"""Initialize the analytical engine."""
self.framework = GeoBotFramework()
self.lenses = AnalyticalLenses()
self.priorities = AnalyticalPriorities()
self.formatter = AnalysisFormatter()
def analyze(
self,
query: str,
context: Dict[str, Any]
) -> str:
"""
Conduct complete GeoBot 2.0 analysis.
Parameters
----------
query : str
Analytical query or question
context : Dict[str, Any]
Context for analysis including:
- governance_type: GovernanceType
- corruption_type: CorruptionType
- military_system: str
- logistics_data: Dict
- scenario_description: str
Returns
-------
str
Formatted analysis
"""
# Apply all lenses
analysis_components = self._apply_lenses(context)
# Create structured output
output = self._create_output(query, context, analysis_components)
# Validate against framework
if not self.framework.validate_analysis(output.__dict__):
raise ValueError("Analysis does not adhere to GeoBot 2.0 framework")
# Format and return
return self.formatter.format_analysis(output)
def _apply_lenses(self, context: Dict[str, Any]) -> Dict[str, Any]:
"""
Apply all analytical lenses to context.
Parameters
----------
context : Dict[str, Any]
Analysis context
Returns
-------
Dict[str, Any]
Lens analyses
"""
components = {}
# Lens A: Logistics
components['logistics'] = self.lenses.logistics.analyze(context)
# Lens B: Governance
if 'governance_type' in context:
gov_type = context['governance_type']
scenario = context.get('scenario_description', 'General scenario')
components['governance'] = self.lenses.governance.analyze(
gov_type, scenario
)
else:
components['governance'] = {
'note': 'Governance type not specified'
}
# Lens C: Corruption
if 'corruption_type' in context:
corr_type = context['corruption_type']
operational_context = context.get('operational_context', 'General operations')
components['corruption'] = self.lenses.corruption.analyze(
corr_type, operational_context
)
else:
components['corruption'] = {
'note': 'Corruption type not specified'
}
# Lens D: Non-Western
if 'military_system' in context:
military = context['military_system']
components['non_western'] = self.lenses.non_western.analyze(military)
else:
components['non_western'] = {
'note': 'Military system not specified'
}
return components
def _create_output(
self,
query: str,
context: Dict[str, Any],
components: Dict[str, Any]
) -> AnalysisOutput:
"""
Create structured analysis output.
Parameters
----------
query : str
Original query
context : Dict[str, Any]
Analysis context
components : Dict[str, Any]
Lens analysis components
Returns
-------
AnalysisOutput
Structured output
"""
# Extract or create summary
summary = context.get('summary', f"Analysis of: {query}")
# Governance analysis
governance_analysis = {
'system_type': context.get('governance_type', 'Not specified'),
**components.get('governance', {})
}
# Logistics analysis
logistics_analysis = {
'assessment': context.get('logistics_assessment', 'Requires detailed logistics data'),
**components.get('logistics', {})
}
# Corruption assessment
corruption_assessment = {
'corruption_type': context.get('corruption_type', 'Not specified'),
**components.get('corruption', {})
}
# Non-Western perspective
non_western_perspective = {
'military_system': context.get('military_system', 'Not specified'),
**components.get('non_western', {})
}
# Scenarios
scenarios = context.get('scenarios', [])
# Uncertainty
uncertainty = context.get('uncertainty_factors', [
"Limited visibility into internal decision-making",
"Intelligence gaps in operational readiness",
"Uncertainty in actor intentions"
])
# Signals
signals = context.get('signals_to_watch', [
"Changes in leadership or command structure",
"Shifts in training tempo or deployment patterns",
"Procurement and supply chain activity"
])
# Comparative notes
comparative = context.get('comparative_notes')
return self.formatter.create_structured_output(
summary=summary,
governance=governance_analysis,
logistics=logistics_analysis,
corruption=corruption_assessment,
non_western=non_western_perspective,
scenarios=scenarios,
uncertainty=uncertainty,
signals=signals,
comparative=comparative
)
def quick_analysis(
self,
query: str,
governance_type: GovernanceType,
corruption_type: CorruptionType,
military_system: str,
summary: str,
**kwargs
) -> str:
"""
Quick analysis with minimal context.
Parameters
----------
query : str
Analysis query
governance_type : GovernanceType
Type of governance system
corruption_type : CorruptionType
Type of corruption present
military_system : str
Military system being analyzed
summary : str
Assessment summary
**kwargs
Additional context
Returns
-------
str
Formatted analysis
"""
context = {
'governance_type': governance_type,
'corruption_type': corruption_type,
'military_system': military_system,
'summary': summary,
**kwargs
}
return self.analyze(query, context)
def compare_governance_systems(
self,
scenario: str,
authoritarian_context: Dict[str, Any],
democratic_context: Dict[str, Any]
) -> str:
"""
Compare authoritarian vs democratic systems for a scenario.
Parameters
----------
scenario : str
Scenario description
authoritarian_context : Dict[str, Any]
Context for authoritarian system
democratic_context : Dict[str, Any]
Context for democratic system
Returns
-------
str
Comparative analysis
"""
comparison = self.lenses.governance.compare_systems(scenario)
output = [
f"COMPARATIVE ANALYSIS: {scenario}",
"",
"AUTHORITARIAN/CENTRALIZED SYSTEMS:",
"Advantages:"
]
for adv in comparison['authoritarian']['advantages']:
output.append(f" - {adv}")
output.append("\nDisadvantages:")
for dis in comparison['authoritarian']['disadvantages']:
output.append(f" - {dis}")
output.append("\nDEMOCRATIC/CONSENSUS SYSTEMS:")
output.append("Advantages:")
for adv in comparison['democratic']['advantages']:
output.append(f" - {adv}")
output.append("\nDisadvantages:")
for dis in comparison['democratic']['disadvantages']:
output.append(f" - {dis}")
output.append(f"\nKEY INSIGHT: {comparison['key_insight']}")
return "\n".join(output)
def assess_corruption_impact(
self,
corruption_type: CorruptionType,
operation_type: str
) -> str:
"""
Assess corruption impact on specific operation type.
Parameters
----------
corruption_type : CorruptionType
Type of corruption
operation_type : str
Type of operation
Returns
-------
str
Impact assessment
"""
return self.lenses.corruption.assess_impact(corruption_type, operation_type)
def get_framework_summary(self) -> Dict[str, Any]:
"""
Get summary of GeoBot 2.0 framework.
Returns
-------
Dict[str, Any]
Framework summary
"""
return self.framework.get_framework_summary()
def get_analytical_priorities(self) -> List[str]:
"""
Get list of analytical priorities.
Returns
-------
List[str]
Analytical priorities
"""
return self.priorities.priorities
|