empathy-framework 4.6.6__py3-none-any.whl → 4.7.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. empathy_framework-4.7.1.dist-info/METADATA +690 -0
  2. empathy_framework-4.7.1.dist-info/RECORD +379 -0
  3. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/top_level.txt +1 -2
  4. empathy_healthcare_plugin/monitors/monitoring/__init__.py +9 -9
  5. empathy_llm_toolkit/agent_factory/__init__.py +6 -6
  6. empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +7 -10
  7. empathy_llm_toolkit/agents_md/__init__.py +22 -0
  8. empathy_llm_toolkit/agents_md/loader.py +218 -0
  9. empathy_llm_toolkit/agents_md/parser.py +271 -0
  10. empathy_llm_toolkit/agents_md/registry.py +307 -0
  11. empathy_llm_toolkit/commands/__init__.py +51 -0
  12. empathy_llm_toolkit/commands/context.py +375 -0
  13. empathy_llm_toolkit/commands/loader.py +301 -0
  14. empathy_llm_toolkit/commands/models.py +231 -0
  15. empathy_llm_toolkit/commands/parser.py +371 -0
  16. empathy_llm_toolkit/commands/registry.py +429 -0
  17. empathy_llm_toolkit/config/__init__.py +8 -8
  18. empathy_llm_toolkit/config/unified.py +3 -7
  19. empathy_llm_toolkit/context/__init__.py +22 -0
  20. empathy_llm_toolkit/context/compaction.py +455 -0
  21. empathy_llm_toolkit/context/manager.py +434 -0
  22. empathy_llm_toolkit/hooks/__init__.py +24 -0
  23. empathy_llm_toolkit/hooks/config.py +306 -0
  24. empathy_llm_toolkit/hooks/executor.py +289 -0
  25. empathy_llm_toolkit/hooks/registry.py +302 -0
  26. empathy_llm_toolkit/hooks/scripts/__init__.py +39 -0
  27. empathy_llm_toolkit/hooks/scripts/evaluate_session.py +201 -0
  28. empathy_llm_toolkit/hooks/scripts/first_time_init.py +285 -0
  29. empathy_llm_toolkit/hooks/scripts/pre_compact.py +207 -0
  30. empathy_llm_toolkit/hooks/scripts/session_end.py +183 -0
  31. empathy_llm_toolkit/hooks/scripts/session_start.py +163 -0
  32. empathy_llm_toolkit/hooks/scripts/suggest_compact.py +225 -0
  33. empathy_llm_toolkit/learning/__init__.py +30 -0
  34. empathy_llm_toolkit/learning/evaluator.py +438 -0
  35. empathy_llm_toolkit/learning/extractor.py +514 -0
  36. empathy_llm_toolkit/learning/storage.py +560 -0
  37. empathy_llm_toolkit/providers.py +4 -11
  38. empathy_llm_toolkit/security/__init__.py +17 -17
  39. empathy_llm_toolkit/utils/tokens.py +2 -5
  40. empathy_os/__init__.py +202 -70
  41. empathy_os/cache_monitor.py +5 -3
  42. empathy_os/cli/__init__.py +11 -55
  43. empathy_os/cli/__main__.py +29 -15
  44. empathy_os/cli/commands/inspection.py +21 -12
  45. empathy_os/cli/commands/memory.py +4 -12
  46. empathy_os/cli/commands/profiling.py +198 -0
  47. empathy_os/cli/commands/utilities.py +27 -7
  48. empathy_os/cli.py +28 -57
  49. empathy_os/cli_unified.py +525 -1164
  50. empathy_os/cost_tracker.py +9 -3
  51. empathy_os/dashboard/server.py +200 -2
  52. empathy_os/hot_reload/__init__.py +7 -7
  53. empathy_os/hot_reload/config.py +6 -7
  54. empathy_os/hot_reload/integration.py +35 -35
  55. empathy_os/hot_reload/reloader.py +57 -57
  56. empathy_os/hot_reload/watcher.py +28 -28
  57. empathy_os/hot_reload/websocket.py +2 -2
  58. empathy_os/memory/__init__.py +11 -4
  59. empathy_os/memory/claude_memory.py +1 -1
  60. empathy_os/memory/cross_session.py +8 -12
  61. empathy_os/memory/edges.py +6 -6
  62. empathy_os/memory/file_session.py +770 -0
  63. empathy_os/memory/graph.py +30 -30
  64. empathy_os/memory/nodes.py +6 -6
  65. empathy_os/memory/short_term.py +15 -9
  66. empathy_os/memory/unified.py +606 -140
  67. empathy_os/meta_workflows/agent_creator.py +3 -9
  68. empathy_os/meta_workflows/cli_meta_workflows.py +113 -53
  69. empathy_os/meta_workflows/form_engine.py +6 -18
  70. empathy_os/meta_workflows/intent_detector.py +64 -24
  71. empathy_os/meta_workflows/models.py +3 -1
  72. empathy_os/meta_workflows/pattern_learner.py +13 -31
  73. empathy_os/meta_workflows/plan_generator.py +55 -47
  74. empathy_os/meta_workflows/session_context.py +2 -3
  75. empathy_os/meta_workflows/workflow.py +20 -51
  76. empathy_os/models/cli.py +2 -2
  77. empathy_os/models/tasks.py +1 -2
  78. empathy_os/models/telemetry.py +4 -1
  79. empathy_os/models/token_estimator.py +3 -1
  80. empathy_os/monitoring/alerts.py +938 -9
  81. empathy_os/monitoring/alerts_cli.py +346 -183
  82. empathy_os/orchestration/execution_strategies.py +12 -29
  83. empathy_os/orchestration/pattern_learner.py +20 -26
  84. empathy_os/orchestration/real_tools.py +6 -15
  85. empathy_os/platform_utils.py +2 -1
  86. empathy_os/plugins/__init__.py +2 -2
  87. empathy_os/plugins/base.py +64 -64
  88. empathy_os/plugins/registry.py +32 -32
  89. empathy_os/project_index/index.py +49 -15
  90. empathy_os/project_index/models.py +1 -2
  91. empathy_os/project_index/reports.py +1 -1
  92. empathy_os/project_index/scanner.py +1 -0
  93. empathy_os/redis_memory.py +10 -7
  94. empathy_os/resilience/__init__.py +1 -1
  95. empathy_os/resilience/health.py +10 -10
  96. empathy_os/routing/__init__.py +7 -7
  97. empathy_os/routing/chain_executor.py +37 -37
  98. empathy_os/routing/classifier.py +36 -36
  99. empathy_os/routing/smart_router.py +40 -40
  100. empathy_os/routing/{wizard_registry.py → workflow_registry.py} +47 -47
  101. empathy_os/scaffolding/__init__.py +8 -8
  102. empathy_os/scaffolding/__main__.py +1 -1
  103. empathy_os/scaffolding/cli.py +28 -28
  104. empathy_os/socratic/__init__.py +3 -19
  105. empathy_os/socratic/ab_testing.py +25 -36
  106. empathy_os/socratic/blueprint.py +38 -38
  107. empathy_os/socratic/cli.py +34 -20
  108. empathy_os/socratic/collaboration.py +30 -28
  109. empathy_os/socratic/domain_templates.py +9 -1
  110. empathy_os/socratic/embeddings.py +17 -13
  111. empathy_os/socratic/engine.py +135 -70
  112. empathy_os/socratic/explainer.py +70 -60
  113. empathy_os/socratic/feedback.py +24 -19
  114. empathy_os/socratic/forms.py +15 -10
  115. empathy_os/socratic/generator.py +51 -35
  116. empathy_os/socratic/llm_analyzer.py +25 -23
  117. empathy_os/socratic/mcp_server.py +99 -159
  118. empathy_os/socratic/session.py +19 -13
  119. empathy_os/socratic/storage.py +98 -67
  120. empathy_os/socratic/success.py +38 -27
  121. empathy_os/socratic/visual_editor.py +51 -39
  122. empathy_os/socratic/web_ui.py +99 -66
  123. empathy_os/telemetry/cli.py +3 -1
  124. empathy_os/telemetry/usage_tracker.py +1 -3
  125. empathy_os/test_generator/__init__.py +3 -3
  126. empathy_os/test_generator/cli.py +28 -28
  127. empathy_os/test_generator/generator.py +64 -66
  128. empathy_os/test_generator/risk_analyzer.py +11 -11
  129. empathy_os/vscode_bridge 2.py +173 -0
  130. empathy_os/vscode_bridge.py +173 -0
  131. empathy_os/workflows/__init__.py +212 -120
  132. empathy_os/workflows/batch_processing.py +8 -24
  133. empathy_os/workflows/bug_predict.py +1 -1
  134. empathy_os/workflows/code_review.py +20 -5
  135. empathy_os/workflows/code_review_pipeline.py +13 -8
  136. empathy_os/workflows/keyboard_shortcuts/workflow.py +6 -2
  137. empathy_os/workflows/manage_documentation.py +1 -0
  138. empathy_os/workflows/orchestrated_health_check.py +6 -11
  139. empathy_os/workflows/orchestrated_release_prep.py +3 -3
  140. empathy_os/workflows/pr_review.py +18 -10
  141. empathy_os/workflows/progressive/README 2.md +454 -0
  142. empathy_os/workflows/progressive/__init__ 2.py +92 -0
  143. empathy_os/workflows/progressive/__init__.py +2 -12
  144. empathy_os/workflows/progressive/cli 2.py +242 -0
  145. empathy_os/workflows/progressive/cli.py +14 -37
  146. empathy_os/workflows/progressive/core 2.py +488 -0
  147. empathy_os/workflows/progressive/core.py +12 -12
  148. empathy_os/workflows/progressive/orchestrator 2.py +701 -0
  149. empathy_os/workflows/progressive/orchestrator.py +166 -144
  150. empathy_os/workflows/progressive/reports 2.py +528 -0
  151. empathy_os/workflows/progressive/reports.py +22 -31
  152. empathy_os/workflows/progressive/telemetry 2.py +280 -0
  153. empathy_os/workflows/progressive/telemetry.py +8 -14
  154. empathy_os/workflows/progressive/test_gen 2.py +514 -0
  155. empathy_os/workflows/progressive/test_gen.py +29 -48
  156. empathy_os/workflows/progressive/workflow 2.py +628 -0
  157. empathy_os/workflows/progressive/workflow.py +31 -70
  158. empathy_os/workflows/release_prep.py +21 -6
  159. empathy_os/workflows/release_prep_crew.py +1 -0
  160. empathy_os/workflows/secure_release.py +13 -6
  161. empathy_os/workflows/security_audit.py +8 -3
  162. empathy_os/workflows/test_coverage_boost_crew.py +3 -2
  163. empathy_os/workflows/test_maintenance_crew.py +1 -0
  164. empathy_os/workflows/test_runner.py +16 -12
  165. empathy_software_plugin/SOFTWARE_PLUGIN_README.md +25 -703
  166. empathy_software_plugin/cli.py +0 -122
  167. patterns/README.md +119 -0
  168. patterns/__init__.py +95 -0
  169. patterns/behavior.py +298 -0
  170. patterns/code_review_memory.json +441 -0
  171. patterns/core.py +97 -0
  172. patterns/debugging.json +3763 -0
  173. patterns/empathy.py +268 -0
  174. patterns/health_check_memory.json +505 -0
  175. patterns/input.py +161 -0
  176. patterns/memory_graph.json +8 -0
  177. patterns/refactoring_memory.json +1113 -0
  178. patterns/registry.py +663 -0
  179. patterns/security_memory.json +8 -0
  180. patterns/structural.py +415 -0
  181. patterns/validation.py +194 -0
  182. coach_wizards/__init__.py +0 -45
  183. coach_wizards/accessibility_wizard.py +0 -91
  184. coach_wizards/api_wizard.py +0 -91
  185. coach_wizards/base_wizard.py +0 -209
  186. coach_wizards/cicd_wizard.py +0 -91
  187. coach_wizards/code_reviewer_README.md +0 -60
  188. coach_wizards/code_reviewer_wizard.py +0 -180
  189. coach_wizards/compliance_wizard.py +0 -91
  190. coach_wizards/database_wizard.py +0 -91
  191. coach_wizards/debugging_wizard.py +0 -91
  192. coach_wizards/documentation_wizard.py +0 -91
  193. coach_wizards/generate_wizards.py +0 -347
  194. coach_wizards/localization_wizard.py +0 -173
  195. coach_wizards/migration_wizard.py +0 -91
  196. coach_wizards/monitoring_wizard.py +0 -91
  197. coach_wizards/observability_wizard.py +0 -91
  198. coach_wizards/performance_wizard.py +0 -91
  199. coach_wizards/prompt_engineering_wizard.py +0 -661
  200. coach_wizards/refactoring_wizard.py +0 -91
  201. coach_wizards/scaling_wizard.py +0 -90
  202. coach_wizards/security_wizard.py +0 -92
  203. coach_wizards/testing_wizard.py +0 -91
  204. empathy_framework-4.6.6.dist-info/METADATA +0 -1597
  205. empathy_framework-4.6.6.dist-info/RECORD +0 -410
  206. empathy_llm_toolkit/wizards/__init__.py +0 -43
  207. empathy_llm_toolkit/wizards/base_wizard.py +0 -364
  208. empathy_llm_toolkit/wizards/customer_support_wizard.py +0 -190
  209. empathy_llm_toolkit/wizards/healthcare_wizard.py +0 -378
  210. empathy_llm_toolkit/wizards/patient_assessment_README.md +0 -64
  211. empathy_llm_toolkit/wizards/patient_assessment_wizard.py +0 -193
  212. empathy_llm_toolkit/wizards/technology_wizard.py +0 -209
  213. empathy_os/wizard_factory_cli.py +0 -170
  214. empathy_software_plugin/wizards/__init__.py +0 -42
  215. empathy_software_plugin/wizards/advanced_debugging_wizard.py +0 -395
  216. empathy_software_plugin/wizards/agent_orchestration_wizard.py +0 -511
  217. empathy_software_plugin/wizards/ai_collaboration_wizard.py +0 -503
  218. empathy_software_plugin/wizards/ai_context_wizard.py +0 -441
  219. empathy_software_plugin/wizards/ai_documentation_wizard.py +0 -503
  220. empathy_software_plugin/wizards/base_wizard.py +0 -288
  221. empathy_software_plugin/wizards/book_chapter_wizard.py +0 -519
  222. empathy_software_plugin/wizards/code_review_wizard.py +0 -604
  223. empathy_software_plugin/wizards/debugging/__init__.py +0 -50
  224. empathy_software_plugin/wizards/debugging/bug_risk_analyzer.py +0 -414
  225. empathy_software_plugin/wizards/debugging/config_loaders.py +0 -446
  226. empathy_software_plugin/wizards/debugging/fix_applier.py +0 -469
  227. empathy_software_plugin/wizards/debugging/language_patterns.py +0 -385
  228. empathy_software_plugin/wizards/debugging/linter_parsers.py +0 -470
  229. empathy_software_plugin/wizards/debugging/verification.py +0 -369
  230. empathy_software_plugin/wizards/enhanced_testing_wizard.py +0 -537
  231. empathy_software_plugin/wizards/memory_enhanced_debugging_wizard.py +0 -816
  232. empathy_software_plugin/wizards/multi_model_wizard.py +0 -501
  233. empathy_software_plugin/wizards/pattern_extraction_wizard.py +0 -422
  234. empathy_software_plugin/wizards/pattern_retriever_wizard.py +0 -400
  235. empathy_software_plugin/wizards/performance/__init__.py +0 -9
  236. empathy_software_plugin/wizards/performance/bottleneck_detector.py +0 -221
  237. empathy_software_plugin/wizards/performance/profiler_parsers.py +0 -278
  238. empathy_software_plugin/wizards/performance/trajectory_analyzer.py +0 -429
  239. empathy_software_plugin/wizards/performance_profiling_wizard.py +0 -305
  240. empathy_software_plugin/wizards/prompt_engineering_wizard.py +0 -425
  241. empathy_software_plugin/wizards/rag_pattern_wizard.py +0 -461
  242. empathy_software_plugin/wizards/security/__init__.py +0 -32
  243. empathy_software_plugin/wizards/security/exploit_analyzer.py +0 -290
  244. empathy_software_plugin/wizards/security/owasp_patterns.py +0 -241
  245. empathy_software_plugin/wizards/security/vulnerability_scanner.py +0 -604
  246. empathy_software_plugin/wizards/security_analysis_wizard.py +0 -322
  247. empathy_software_plugin/wizards/security_learning_wizard.py +0 -740
  248. empathy_software_plugin/wizards/tech_debt_wizard.py +0 -726
  249. empathy_software_plugin/wizards/testing/__init__.py +0 -27
  250. empathy_software_plugin/wizards/testing/coverage_analyzer.py +0 -459
  251. empathy_software_plugin/wizards/testing/quality_analyzer.py +0 -525
  252. empathy_software_plugin/wizards/testing/test_suggester.py +0 -533
  253. empathy_software_plugin/wizards/testing_wizard.py +0 -274
  254. wizards/__init__.py +0 -82
  255. wizards/admission_assessment_wizard.py +0 -644
  256. wizards/care_plan.py +0 -321
  257. wizards/clinical_assessment.py +0 -769
  258. wizards/discharge_planning.py +0 -77
  259. wizards/discharge_summary_wizard.py +0 -468
  260. wizards/dosage_calculation.py +0 -497
  261. wizards/incident_report_wizard.py +0 -454
  262. wizards/medication_reconciliation.py +0 -85
  263. wizards/nursing_assessment.py +0 -171
  264. wizards/patient_education.py +0 -654
  265. wizards/quality_improvement.py +0 -705
  266. wizards/sbar_report.py +0 -324
  267. wizards/sbar_wizard.py +0 -608
  268. wizards/shift_handoff_wizard.py +0 -535
  269. wizards/soap_note_wizard.py +0 -679
  270. wizards/treatment_plan.py +0 -15
  271. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/WHEEL +0 -0
  272. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/entry_points.txt +0 -0
  273. {empathy_framework-4.6.6.dist-info → empathy_framework-4.7.1.dist-info}/licenses/LICENSE +0 -0
@@ -46,10 +46,7 @@ from typing import Any
46
46
  from empathy_os.config import _validate_file_path
47
47
 
48
48
  from ..orchestration.agent_templates import AgentTemplate, get_template
49
- from ..orchestration.execution_strategies import (
50
- ParallelStrategy,
51
- StrategyResult,
52
- )
49
+ from ..orchestration.execution_strategies import ParallelStrategy, StrategyResult
53
50
  from ..orchestration.meta_orchestrator import MetaOrchestrator
54
51
 
55
52
  logger = logging.getLogger(__name__)
@@ -184,7 +181,7 @@ class HealthCheckReport:
184
181
  bar = "█" * bar_length
185
182
  lines.append(
186
183
  f"{status} {category.name:15} {category.score:5.1f}/100 "
187
- f"(weight: {category.weight*100:2.0f}%) {bar}"
184
+ f"(weight: {category.weight * 100:2.0f}%) {bar}"
188
185
  )
189
186
 
190
187
  # Show issues for failing categories
@@ -318,7 +315,7 @@ class OrchestratedHealthCheckWorkflow:
318
315
  self,
319
316
  project_root: str | None = None,
320
317
  context: dict[str, Any] | None = None,
321
- **kwargs # Absorb extra parameters from VSCode/CLI (target, etc.)
318
+ **kwargs, # Absorb extra parameters from VSCode/CLI (target, etc.)
322
319
  ) -> HealthCheckReport:
323
320
  """Execute health check workflow.
324
321
 
@@ -334,8 +331,8 @@ class OrchestratedHealthCheckWorkflow:
334
331
  ValueError: If project_root is invalid
335
332
  """
336
333
  # Map 'target' to 'project_root' for VSCode compatibility
337
- if 'target' in kwargs and not project_root:
338
- project_root = kwargs['target']
334
+ if "target" in kwargs and not project_root:
335
+ project_root = kwargs["target"]
339
336
  if project_root:
340
337
  self.project_root = Path(project_root).resolve()
341
338
 
@@ -639,9 +636,7 @@ class OrchestratedHealthCheckWorkflow:
639
636
  recommendations.append(
640
637
  f"🧪 Increase test coverage to 80%+ (currently {category.score:.1f}%)"
641
638
  )
642
- recommendations.append(
643
- " → Run: pytest --cov=src --cov-report=term-missing"
644
- )
639
+ recommendations.append(" → Run: pytest --cov=src --cov-report=term-missing")
645
640
  recommendations.append(
646
641
  " → Or use: empathy workflow run test-gen --path <file>"
647
642
  )
@@ -294,7 +294,7 @@ class OrchestratedReleasePrepWorkflow:
294
294
  self,
295
295
  path: str = ".",
296
296
  context: dict[str, Any] | None = None,
297
- **kwargs # Absorb extra parameters from VSCode/CLI (target, etc.)
297
+ **kwargs, # Absorb extra parameters from VSCode/CLI (target, etc.)
298
298
  ) -> ReleaseReadinessReport:
299
299
  """Execute release preparation workflow.
300
300
 
@@ -310,8 +310,8 @@ class OrchestratedReleasePrepWorkflow:
310
310
  ValueError: If path is invalid
311
311
  """
312
312
  # Map 'target' to 'path' for VSCode compatibility
313
- if 'target' in kwargs and path == ".":
314
- path = kwargs['target']
313
+ if "target" in kwargs and path == ".":
314
+ path = kwargs["target"]
315
315
  if not path or not isinstance(path, str):
316
316
  raise ValueError("path must be a non-empty string")
317
317
 
@@ -356,11 +356,15 @@ class PRReviewWorkflow:
356
356
  files_changed: list[str],
357
357
  ) -> dict | None:
358
358
  """Run CodeReviewCrew."""
359
- from .code_review_adapters import (
360
- _check_crew_available,
361
- _get_crew_review,
362
- crew_report_to_workflow_format,
363
- )
359
+ try:
360
+ from .code_review_adapters import (
361
+ _check_crew_available,
362
+ _get_crew_review,
363
+ crew_report_to_workflow_format,
364
+ )
365
+ except ImportError:
366
+ logger.info("CodeReviewCrew adapters not installed")
367
+ return None
364
368
 
365
369
  if not _check_crew_available():
366
370
  logger.info("CodeReviewCrew not available")
@@ -381,11 +385,15 @@ class PRReviewWorkflow:
381
385
  target_path: str,
382
386
  ) -> dict | None:
383
387
  """Run SecurityAuditCrew."""
384
- from .security_adapters import (
385
- _check_crew_available,
386
- _get_crew_audit,
387
- crew_report_to_workflow_format,
388
- )
388
+ try:
389
+ from .security_adapters import (
390
+ _check_crew_available,
391
+ _get_crew_audit,
392
+ crew_report_to_workflow_format,
393
+ )
394
+ except ImportError:
395
+ logger.info("SecurityAuditCrew adapters not installed")
396
+ return None
389
397
 
390
398
  if not _check_crew_available():
391
399
  logger.info("SecurityAuditCrew not available")
@@ -0,0 +1,454 @@
1
+ # Progressive Tier Escalation System
2
+
3
+ **Version:** 4.1.0
4
+ **Status:** Production Ready
5
+ **Test Coverage:** 86.58% (123 tests)
6
+
7
+ ## Overview
8
+
9
+ The Progressive Tier Escalation System is an intelligent cost optimization framework that automatically routes tasks through multiple AI model tiers (cheap → capable → premium) based on quality metrics, providing 70-85% cost savings compared to using premium models for all tasks.
10
+
11
+ ## Key Features
12
+
13
+ - ✅ **Multi-tier execution**: Automatic progression from cheap to premium models
14
+ - ✅ **Composite Quality Score (CQS)**: Multi-signal failure detection
15
+ - ✅ **Smart escalation**: Only failed items escalate, successful ones stay at current tier
16
+ - ✅ **Cost management**: Budget controls with approval prompts
17
+ - ✅ **Privacy-preserving telemetry**: Local tracking with hashed user IDs
18
+ - ✅ **Comprehensive analytics**: Historical cost savings analysis
19
+ - ✅ **CLI tools**: Manage and analyze workflow results
20
+
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from empathy_os.workflows.progressive import (
25
+ ProgressiveTestGenWorkflow,
26
+ EscalationConfig,
27
+ Tier
28
+ )
29
+
30
+ # Configure escalation
31
+ config = EscalationConfig(
32
+ enabled=True,
33
+ tiers=[Tier.CHEAP, Tier.CAPABLE, Tier.PREMIUM],
34
+ max_cost=10.00,
35
+ auto_approve_under=1.00,
36
+ abort_on_budget_exceeded=True
37
+ )
38
+
39
+ # Create workflow
40
+ workflow = ProgressiveTestGenWorkflow(config)
41
+
42
+ # Execute with automatic tier progression
43
+ result = workflow.execute(target_file="src/myapp/calculator.py")
44
+
45
+ # View results
46
+ print(result.generate_report())
47
+ print(f"Cost: ${result.total_cost:.2f}")
48
+ print(f"Savings: ${result.cost_savings:.2f} ({result.cost_savings_percent:.0f}%)")
49
+
50
+ # Save results for analytics
51
+ result.save_to_disk()
52
+ ```
53
+
54
+ ## Architecture
55
+
56
+ ### Tier Progression
57
+
58
+ ```
59
+ ┌─────────────────────────────────────────────────────────────┐
60
+ │ PROGRESSIVE ESCALATION │
61
+ └─────────────────────────────────────────────────────────────┘
62
+
63
+
64
+ ┌─────────────────┐
65
+ │ CHEAP TIER │
66
+ │ (gpt-4o-mini) │
67
+ │ $0.003/item │
68
+ │ 1 agent │
69
+ └────────┬────────┘
70
+
71
+ CQS < 75? ───No──> SUCCESS
72
+
73
+ Yes
74
+
75
+
76
+ ┌─────────────────┐
77
+ │ CAPABLE TIER │
78
+ │ (claude-3-5-s) │
79
+ │ $0.015/item │
80
+ │ 2 agents │
81
+ └────────┬────────┘
82
+
83
+ CQS < 85? ───No──> SUCCESS
84
+
85
+ Yes
86
+
87
+
88
+ ┌─────────────────┐
89
+ │ PREMIUM TIER │
90
+ │ (claude-opus-4) │
91
+ │ $0.05/item │
92
+ │ 3 agents │
93
+ └────────┬────────┘
94
+
95
+
96
+ FINAL RESULT
97
+ ```
98
+
99
+ ### Composite Quality Score (CQS)
100
+
101
+ Quality is measured using a weighted multi-signal metric:
102
+
103
+ ```
104
+ CQS = (0.40 × test_pass_rate +
105
+ 0.25 × code_coverage +
106
+ 0.20 × assertion_quality +
107
+ 0.15 × llm_confidence) × syntax_penalty
108
+ ```
109
+
110
+ **Thresholds:**
111
+ - **CHEAP tier**: CQS ≥ 75 (pass), < 75 (escalate)
112
+ - **CAPABLE tier**: CQS ≥ 85 (pass), < 85 (escalate)
113
+ - **PREMIUM tier**: CQS ≥ 90 (target), no escalation
114
+
115
+ **Syntax Penalty:** 50% reduction if syntax errors detected
116
+
117
+ ## Core Components
118
+
119
+ ### 1. EscalationConfig
120
+
121
+ Configuration for tier escalation behavior:
122
+
123
+ ```python
124
+ config = EscalationConfig(
125
+ enabled=True, # Enable progressive escalation
126
+ tiers=[Tier.CHEAP, Tier.CAPABLE, Tier.PREMIUM],
127
+ cheap_min_attempts=2, # Try cheap tier 2× before escalating
128
+ capable_min_attempts=1, # Try capable tier 1× before escalating
129
+ max_cost=10.00, # Abort if cost exceeds $10
130
+ auto_approve_under=1.00, # Auto-approve costs < $1
131
+ abort_on_budget_exceeded=True, # Abort vs warn on budget exceeded
132
+ warn_on_budget_exceeded=False,
133
+ stagnation_threshold=0.05, # 5% improvement threshold
134
+ stagnation_window=2, # Over 2 consecutive runs
135
+ )
136
+ ```
137
+
138
+ ### 2. Meta-Orchestration
139
+
140
+ Dynamic agent team creation based on tier:
141
+
142
+ | Tier | Agents | Strategy |
143
+ |----------|--------|---------------------------------------|
144
+ | CHEAP | 1 | Single agent, fast iteration |
145
+ | CAPABLE | 2 | Planner + executor, collaborative |
146
+ | PREMIUM | 3 | Architect + executor + reviewer, deep |
147
+
148
+ ### 3. Telemetry
149
+
150
+ Privacy-preserving usage tracking:
151
+
152
+ ```python
153
+ from empathy_os.workflows.progressive import ProgressiveTelemetry
154
+
155
+ # Initialize telemetry
156
+ telemetry = ProgressiveTelemetry(
157
+ workflow_name="test-gen",
158
+ user_id="user@example.com" # SHA256 hashed for privacy
159
+ )
160
+
161
+ # Track tier execution
162
+ telemetry.track_tier_execution(tier_result, attempt=1, escalated=False)
163
+
164
+ # Track escalation
165
+ telemetry.track_escalation(
166
+ from_tier=Tier.CHEAP,
167
+ to_tier=Tier.CAPABLE,
168
+ reason="Low CQS (65)",
169
+ item_count=10,
170
+ current_cost=0.30
171
+ )
172
+
173
+ # Track workflow completion
174
+ telemetry.track_workflow_completion(result)
175
+ ```
176
+
177
+ **Data Stored:**
178
+ - Workflow name, tier, model, cost, tokens
179
+ - Quality metrics (CQS, test pass rate, coverage)
180
+ - Escalation reasons and patterns
181
+ - Timestamps and durations
182
+
183
+ **Privacy:**
184
+ - User IDs are SHA256 hashed
185
+ - No prompts, responses, or PII stored
186
+ - Local-only storage (~/.empathy/telemetry/)
187
+
188
+ ### 4. CLI Tools
189
+
190
+ Manage and analyze saved results:
191
+
192
+ ```bash
193
+ # List all workflow results
194
+ empathy progressive list
195
+
196
+ # Show detailed report for specific run
197
+ empathy progressive show test-gen-20260117-120000
198
+
199
+ # Show JSON output
200
+ empathy progressive show test-gen-20260117-120000 --json
201
+
202
+ # Generate cost analytics
203
+ empathy progressive analytics
204
+
205
+ # Cleanup old results (30 day retention)
206
+ empathy progressive cleanup --retention-days 30
207
+
208
+ # Dry run cleanup (preview)
209
+ empathy progressive cleanup --retention-days 30 --dry-run
210
+
211
+ # Custom storage path
212
+ empathy progressive list --storage-path ./my-results
213
+ ```
214
+
215
+ ## Usage Examples
216
+
217
+ ### Example 1: Test Generation with Escalation
218
+
219
+ ```python
220
+ from empathy_os.workflows.progressive import ProgressiveTestGenWorkflow
221
+
222
+ workflow = ProgressiveTestGenWorkflow()
223
+ result = workflow.execute(target_file="src/auth.py")
224
+
225
+ # View tier progression
226
+ for tier_result in result.tier_results:
227
+ print(f"{tier_result.tier.value}: CQS={tier_result.failure_analysis.calculate_quality_score():.1f}")
228
+ if tier_result.escalated:
229
+ print(f" → Escalated: {tier_result.escalation_reason}")
230
+
231
+ # Output:
232
+ # cheap: CQS=68.5
233
+ # → Escalated: Low CQS (68.5)
234
+ # capable: CQS=92.0
235
+ ```
236
+
237
+ ### Example 2: Cost Analysis
238
+
239
+ ```python
240
+ from empathy_os.workflows.progressive.reports import generate_cost_analytics
241
+
242
+ analytics = generate_cost_analytics()
243
+
244
+ print(f"Total runs: {analytics['total_runs']}")
245
+ print(f"Total cost: ${analytics['total_cost']:.2f}")
246
+ print(f"Total savings: ${analytics['total_savings']:.2f}")
247
+ print(f"Avg savings: {analytics['avg_savings_percent']:.1f}%")
248
+ print(f"Escalation rate: {analytics['escalation_rate']:.1%}")
249
+ print(f"Success rate: {analytics['success_rate']:.1%}")
250
+
251
+ # Per-workflow breakdown
252
+ for workflow, stats in analytics['workflow_stats'].items():
253
+ print(f"\n{workflow}:")
254
+ print(f" Runs: {stats['runs']}")
255
+ print(f" Avg cost: ${stats['avg_cost']:.2f}")
256
+ print(f" Success rate: {stats['success_rate']:.1%}")
257
+ ```
258
+
259
+ ### Example 3: Custom Escalation Logic
260
+
261
+ ```python
262
+ from empathy_os.workflows.progressive import ProgressiveWorkflow, Tier
263
+
264
+ class CustomWorkflow(ProgressiveWorkflow):
265
+ def _should_escalate_custom(self, tier_result):
266
+ """Custom escalation logic."""
267
+ # Example: Escalate if any syntax errors
268
+ if tier_result.failure_analysis.syntax_errors:
269
+ return True, "Syntax errors detected"
270
+
271
+ # Example: Escalate if test pass rate < 90%
272
+ if tier_result.failure_analysis.test_pass_rate < 0.90:
273
+ return True, f"Low test pass rate ({tier_result.failure_analysis.test_pass_rate:.1%})"
274
+
275
+ return False, None
276
+
277
+ def _execute_tier_impl(self, tier, items, context):
278
+ """Implement tier execution logic."""
279
+ # Your custom implementation
280
+ pass
281
+
282
+ workflow = CustomWorkflow()
283
+ result = workflow.execute(items=my_items)
284
+ ```
285
+
286
+ ## Performance Characteristics
287
+
288
+ ### Cost Savings
289
+
290
+ Based on production usage:
291
+
292
+ | Scenario | Cheap % | Capable % | Premium % | Savings |
293
+ |-----------------------|---------|-----------|-----------|---------|
294
+ | Simple tasks | 80% | 15% | 5% | 85% |
295
+ | Medium complexity | 60% | 30% | 10% | 72% |
296
+ | High complexity | 40% | 40% | 20% | 60% |
297
+ | **Average** | **60%** | **28%** | **12%** | **72%** |
298
+
299
+ ### Execution Time
300
+
301
+ Progressive execution adds minimal latency:
302
+
303
+ - **Cheap tier**: ~5-10s per item (baseline)
304
+ - **Capable tier**: ~10-20s per item (+5-10s overhead)
305
+ - **Premium tier**: ~20-40s per item (+10-20s overhead)
306
+
307
+ **Parallel escalation**: Failed items escalate in parallel, reducing total time.
308
+
309
+ ## Troubleshooting
310
+
311
+ ### Issue: Excessive Escalation
312
+
313
+ **Symptoms:** Most items escalate to premium tier
314
+
315
+ **Causes:**
316
+ - CQS thresholds too strict
317
+ - Input items too complex for cheap/capable tiers
318
+ - Stagnation detection too sensitive
319
+
320
+ **Solutions:**
321
+ ```python
322
+ # Lower CQS thresholds
323
+ config = EscalationConfig(
324
+ cheap_cqs_threshold=70, # Down from 75
325
+ capable_cqs_threshold=80 # Down from 85
326
+ )
327
+
328
+ # Increase stagnation threshold
329
+ config = EscalationConfig(
330
+ stagnation_threshold=0.10, # 10% improvement required
331
+ stagnation_window=3 # Over 3 runs
332
+ )
333
+
334
+ # Increase min attempts
335
+ config = EscalationConfig(
336
+ cheap_min_attempts=3, # Try 3× before escalating
337
+ capable_min_attempts=2
338
+ )
339
+ ```
340
+
341
+ ### Issue: Budget Exceeded Errors
342
+
343
+ **Symptoms:** `BudgetExceededError` raised frequently
344
+
345
+ **Solutions:**
346
+ ```python
347
+ # Increase budget
348
+ config = EscalationConfig(max_cost=20.00)
349
+
350
+ # Warn instead of abort
351
+ config = EscalationConfig(
352
+ abort_on_budget_exceeded=False,
353
+ warn_on_budget_exceeded=True
354
+ )
355
+
356
+ # Increase auto-approve threshold
357
+ config = EscalationConfig(auto_approve_under=5.00)
358
+ ```
359
+
360
+ ### Issue: Poor Quality Results
361
+
362
+ **Symptoms:** Final CQS < 85
363
+
364
+ **Causes:**
365
+ - Insufficient premium tier attempts
366
+ - Input quality issues
367
+ - Test assertion depth too low
368
+
369
+ **Solutions:**
370
+ ```python
371
+ # Force premium tier for critical tasks
372
+ config = EscalationConfig(
373
+ tiers=[Tier.PREMIUM], # Skip cheap/capable
374
+ enabled=False # Disable escalation
375
+ )
376
+
377
+ # Increase premium min attempts
378
+ config = EscalationConfig(
379
+ premium_min_attempts=2
380
+ )
381
+ ```
382
+
383
+ ## API Reference
384
+
385
+ ### Core Classes
386
+
387
+ - `Tier`: Enum defining tier levels (CHEAP, CAPABLE, PREMIUM)
388
+ - `EscalationConfig`: Configuration for tier escalation
389
+ - `FailureAnalysis`: Quality metrics and failure signals
390
+ - `TierResult`: Results from a single tier execution
391
+ - `ProgressiveWorkflowResult`: Complete multi-tier execution results
392
+
393
+ ### Base Classes
394
+
395
+ - `ProgressiveWorkflow`: Abstract base for progressive workflows
396
+ - `MetaOrchestrator`: Tier escalation decision logic
397
+
398
+ ### Workflows
399
+
400
+ - `ProgressiveTestGenWorkflow`: Test generation with progressive escalation
401
+
402
+ ### Utilities
403
+
404
+ - `ProgressiveTelemetry`: Usage tracking and analytics
405
+ - `generate_cost_analytics()`: Analyze historical cost savings
406
+ - `cleanup_old_results()`: Retention policy enforcement
407
+
408
+ ## Testing
409
+
410
+ Run progressive workflow tests:
411
+
412
+ ```bash
413
+ # All progressive tests
414
+ pytest tests/unit/workflows/progressive/ -v
415
+
416
+ # Specific test modules
417
+ pytest tests/unit/workflows/progressive/test_core.py -v
418
+ pytest tests/unit/workflows/progressive/test_orchestrator.py -v
419
+ pytest tests/unit/workflows/progressive/test_cost_telemetry.py -v
420
+ pytest tests/unit/workflows/progressive/test_reports_analytics.py -v
421
+ pytest tests/unit/workflows/progressive/test_test_gen.py -v
422
+
423
+ # With coverage
424
+ pytest tests/unit/workflows/progressive/ --cov=src/empathy_os/workflows/progressive --cov-report=term-missing
425
+ ```
426
+
427
+ **Test Coverage:** 86.58% (123 tests)
428
+
429
+ ## Contributing
430
+
431
+ When adding new progressive workflows:
432
+
433
+ 1. **Inherit from `ProgressiveWorkflow`**
434
+ 2. **Implement `_execute_tier_impl()`** for tier-specific execution logic
435
+ 3. **Define quality metrics** in `_analyze_quality()`
436
+ 4. **Add comprehensive tests** (aim for 85%+ coverage)
437
+ 5. **Document usage** with examples
438
+
439
+ See `ProgressiveTestGenWorkflow` for a complete implementation example.
440
+
441
+ ## License
442
+
443
+ Fair Source License 0.9
444
+
445
+ ## Version History
446
+
447
+ - **4.1.0** (2026-01-17): Initial release with test generation workflow
448
+ - **4.1.0-alpha**: Development version
449
+
450
+ ## Support
451
+
452
+ - **Documentation**: [Empathy Framework Docs](https://empathy-framework.readthedocs.io)
453
+ - **Issues**: [GitHub Issues](https://github.com/Smart-AI-Memory/empathy-framework/issues)
454
+ - **Discussions**: [GitHub Discussions](https://github.com/Smart-AI-Memory/empathy-framework/discussions)
@@ -0,0 +1,92 @@
1
+ """Progressive tier escalation system for cost-efficient, quality-driven workflows.
2
+
3
+ This module implements automatic model tier escalation (cheap → capable → premium)
4
+ based on failure analysis and quality metrics. Key features:
5
+
6
+ - Multi-signal failure detection (syntax, execution, coverage, confidence)
7
+ - Composite Quality Score (CQS) for objective quality measurement
8
+ - LLM-guided retry logic with stagnation detection
9
+ - Meta-orchestration with dynamic agent team creation
10
+ - Cost management with budget controls and approval prompts
11
+ - Comprehensive observability and reporting
12
+
13
+ Usage:
14
+ from empathy_os.workflows.progressive import (
15
+ ProgressiveWorkflow,
16
+ EscalationConfig,
17
+ Tier,
18
+ FailureAnalysis
19
+ )
20
+
21
+ # Configure escalation
22
+ config = EscalationConfig(
23
+ enabled=True,
24
+ max_cost=10.00,
25
+ auto_approve_under=5.00
26
+ )
27
+
28
+ # Create workflow
29
+ workflow = ProgressiveTestGenWorkflow(config)
30
+ result = workflow.execute(target_file="app.py")
31
+
32
+ # View report
33
+ print(result.generate_report())
34
+
35
+ Version: 4.1.0
36
+ Author: Empathy Framework Team
37
+ """
38
+
39
+ from empathy_os.workflows.progressive.core import (
40
+ EscalationConfig,
41
+ FailureAnalysis,
42
+ ProgressiveWorkflowResult,
43
+ Tier,
44
+ TierResult,
45
+ )
46
+ from empathy_os.workflows.progressive.orchestrator import (
47
+ MetaOrchestrator,
48
+ )
49
+ from empathy_os.workflows.progressive.telemetry import (
50
+ ProgressiveTelemetry,
51
+ )
52
+ from empathy_os.workflows.progressive.test_gen import (
53
+ ProgressiveTestGenWorkflow,
54
+ calculate_coverage,
55
+ execute_test_file,
56
+ )
57
+ from empathy_os.workflows.progressive.workflow import (
58
+ BudgetExceededError,
59
+ ProgressiveWorkflow,
60
+ UserCancelledError,
61
+ )
62
+
63
+ __all__ = [
64
+ # Enums
65
+ "Tier",
66
+
67
+ # Core data structures
68
+ "FailureAnalysis",
69
+ "TierResult",
70
+ "ProgressiveWorkflowResult",
71
+ "EscalationConfig",
72
+
73
+ # Base classes
74
+ "ProgressiveWorkflow",
75
+ "MetaOrchestrator",
76
+
77
+ # Telemetry
78
+ "ProgressiveTelemetry",
79
+
80
+ # Exceptions
81
+ "BudgetExceededError",
82
+ "UserCancelledError",
83
+
84
+ # Workflows
85
+ "ProgressiveTestGenWorkflow",
86
+
87
+ # Utilities
88
+ "execute_test_file",
89
+ "calculate_coverage",
90
+ ]
91
+
92
+ __version__ = "4.1.1"
@@ -43,12 +43,8 @@ from empathy_os.workflows.progressive.core import (
43
43
  Tier,
44
44
  TierResult,
45
45
  )
46
- from empathy_os.workflows.progressive.orchestrator import (
47
- MetaOrchestrator,
48
- )
49
- from empathy_os.workflows.progressive.telemetry import (
50
- ProgressiveTelemetry,
51
- )
46
+ from empathy_os.workflows.progressive.orchestrator import MetaOrchestrator
47
+ from empathy_os.workflows.progressive.telemetry import ProgressiveTelemetry
52
48
  from empathy_os.workflows.progressive.test_gen import (
53
49
  ProgressiveTestGenWorkflow,
54
50
  calculate_coverage,
@@ -63,27 +59,21 @@ from empathy_os.workflows.progressive.workflow import (
63
59
  __all__ = [
64
60
  # Enums
65
61
  "Tier",
66
-
67
62
  # Core data structures
68
63
  "FailureAnalysis",
69
64
  "TierResult",
70
65
  "ProgressiveWorkflowResult",
71
66
  "EscalationConfig",
72
-
73
67
  # Base classes
74
68
  "ProgressiveWorkflow",
75
69
  "MetaOrchestrator",
76
-
77
70
  # Telemetry
78
71
  "ProgressiveTelemetry",
79
-
80
72
  # Exceptions
81
73
  "BudgetExceededError",
82
74
  "UserCancelledError",
83
-
84
75
  # Workflows
85
76
  "ProgressiveTestGenWorkflow",
86
-
87
77
  # Utilities
88
78
  "execute_test_file",
89
79
  "calculate_coverage",