empathy-framework 4.7.0__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.
- empathy_framework-4.7.1.dist-info/METADATA +690 -0
- {empathy_framework-4.7.0.dist-info → empathy_framework-4.7.1.dist-info}/RECORD +31 -6
- {empathy_framework-4.7.0.dist-info → empathy_framework-4.7.1.dist-info}/top_level.txt +1 -0
- empathy_os/vscode_bridge 2.py +173 -0
- empathy_os/workflows/progressive/README 2.md +454 -0
- empathy_os/workflows/progressive/__init__ 2.py +92 -0
- empathy_os/workflows/progressive/cli 2.py +242 -0
- empathy_os/workflows/progressive/core 2.py +488 -0
- empathy_os/workflows/progressive/orchestrator 2.py +701 -0
- empathy_os/workflows/progressive/reports 2.py +528 -0
- empathy_os/workflows/progressive/telemetry 2.py +280 -0
- empathy_os/workflows/progressive/test_gen 2.py +514 -0
- empathy_os/workflows/progressive/workflow 2.py +628 -0
- patterns/README.md +119 -0
- patterns/__init__.py +95 -0
- patterns/behavior.py +298 -0
- patterns/code_review_memory.json +441 -0
- patterns/core.py +97 -0
- patterns/debugging.json +3763 -0
- patterns/empathy.py +268 -0
- patterns/health_check_memory.json +505 -0
- patterns/input.py +161 -0
- patterns/memory_graph.json +8 -0
- patterns/refactoring_memory.json +1113 -0
- patterns/registry.py +663 -0
- patterns/security_memory.json +8 -0
- patterns/structural.py +415 -0
- patterns/validation.py +194 -0
- empathy_framework-4.7.0.dist-info/METADATA +0 -1598
- {empathy_framework-4.7.0.dist-info → empathy_framework-4.7.1.dist-info}/WHEEL +0 -0
- {empathy_framework-4.7.0.dist-info → empathy_framework-4.7.1.dist-info}/entry_points.txt +0 -0
- {empathy_framework-4.7.0.dist-info → empathy_framework-4.7.1.dist-info}/licenses/LICENSE +0 -0
patterns/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Empathy Framework Pattern Catalog
|
|
2
|
+
|
|
3
|
+
A catalog of reusable patterns extracted from the Empathy Framework codebase, organized for cross-domain transfer and Level 5 (Systems Thinking) capability development.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This catalog serves three goals:
|
|
8
|
+
|
|
9
|
+
1. **Document existing patterns** - Capture what we've already built
|
|
10
|
+
2. **Enable cross-domain transfer** - Apply patterns from reliability to trust, from observability to empathy
|
|
11
|
+
3. **Accelerate Level 5 thinking** - Train the ability to recognize "this problem is like that solved problem"
|
|
12
|
+
|
|
13
|
+
## Pattern Categories
|
|
14
|
+
|
|
15
|
+
### Reliability Patterns
|
|
16
|
+
*Source: `src/empathy_os/resilience/`*
|
|
17
|
+
|
|
18
|
+
| Pattern | Level | Key Insight |
|
|
19
|
+
|---------|-------|-------------|
|
|
20
|
+
| [Circuit Breaker](reliability/circuit-breaker.md) | 4 | Predict failures, fail fast |
|
|
21
|
+
| [Graceful Degradation](reliability/graceful-degradation.md) | 4 | Partial value beats total failure |
|
|
22
|
+
| [Retry with Backoff](reliability/retry-with-backoff.md) | 3 | Transient failures are recoverable |
|
|
23
|
+
|
|
24
|
+
### Observability Patterns
|
|
25
|
+
*Source: `src/empathy_os/models/telemetry.py`, `src/empathy_os/resilience/health.py`*
|
|
26
|
+
|
|
27
|
+
| Pattern | Level | Key Insight |
|
|
28
|
+
|---------|-------|-------------|
|
|
29
|
+
| [Health Monitoring](observability/health-monitoring.md) | 4 | Degraded predicts unhealthy |
|
|
30
|
+
| [Telemetry Tracking](observability/telemetry-tracking.md) | 3-4 | Failures are learning data |
|
|
31
|
+
|
|
32
|
+
### Cross-Domain Transfers
|
|
33
|
+
*The Level 5 breakthrough patterns*
|
|
34
|
+
|
|
35
|
+
| Transfer | From → To | Status | Key Insight |
|
|
36
|
+
|----------|-----------|--------|-------------|
|
|
37
|
+
| [Circuit Breaker → Trust](cross-domain/circuit-breaker-to-trust.md) | Reliability → Trust | **IMPLEMENTED** | Protect relationships like systems |
|
|
38
|
+
| [Alerting → Empathy Levels](cross-domain/alerting-to-empathy-levels.md) | Observability → Empathy | Documented | Thresholds trigger level changes |
|
|
39
|
+
| [Degradation → Conversation](cross-domain/graceful-degradation-to-conversation.md) | Reliability → UX | Documented | Degraded response beats failure |
|
|
40
|
+
|
|
41
|
+
### Implemented Transfers
|
|
42
|
+
|
|
43
|
+
| Transfer | Implementation | Guide |
|
|
44
|
+
|----------|----------------|-------|
|
|
45
|
+
| Circuit Breaker → Trust | [`src/empathy_os/trust/`](../src/empathy_os/trust/) | [Trust Circuit Breaker Guide](../docs/guides/trust-circuit-breaker.md) |
|
|
46
|
+
|
|
47
|
+
## Capability Level Reference
|
|
48
|
+
|
|
49
|
+
| Level | Name | Pattern Characteristic |
|
|
50
|
+
|-------|------|----------------------|
|
|
51
|
+
| 1 | Reactive | Respond to explicit requests |
|
|
52
|
+
| 2 | Guided | Follow established patterns |
|
|
53
|
+
| 3 | Proactive | Anticipate immediate needs |
|
|
54
|
+
| 4 | Anticipatory | Predict future needs (30-90 days) |
|
|
55
|
+
| 5 | Systems | Transfer patterns across domains |
|
|
56
|
+
|
|
57
|
+
## How to Use This Catalog
|
|
58
|
+
|
|
59
|
+
### For Developers
|
|
60
|
+
1. When facing a new problem, search for similar patterns
|
|
61
|
+
2. Check cross-domain transfers for non-obvious solutions
|
|
62
|
+
3. Contribute new patterns following the template
|
|
63
|
+
|
|
64
|
+
### For AI Systems
|
|
65
|
+
1. Reference patterns when solving problems
|
|
66
|
+
2. Propose cross-domain transfers when patterns match
|
|
67
|
+
3. Track pattern usage for learning
|
|
68
|
+
|
|
69
|
+
### For Architects
|
|
70
|
+
1. Ensure new features follow established patterns
|
|
71
|
+
2. Identify opportunities for pattern consolidation
|
|
72
|
+
3. Propose new cross-domain transfers
|
|
73
|
+
|
|
74
|
+
## Pattern Template
|
|
75
|
+
|
|
76
|
+
```markdown
|
|
77
|
+
# Pattern Name
|
|
78
|
+
|
|
79
|
+
**Source Domain:** Where this pattern originated
|
|
80
|
+
**Location in Codebase:** File paths
|
|
81
|
+
**Level:** Capability level (1-5)
|
|
82
|
+
|
|
83
|
+
## Overview
|
|
84
|
+
What problem does this solve?
|
|
85
|
+
|
|
86
|
+
## Implementation
|
|
87
|
+
Code examples from actual codebase
|
|
88
|
+
|
|
89
|
+
## Key Insight
|
|
90
|
+
The one thing to remember
|
|
91
|
+
|
|
92
|
+
## Cross-Domain Transfer Potential
|
|
93
|
+
Where else could this apply?
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Contributing
|
|
97
|
+
|
|
98
|
+
1. Identify a pattern in the codebase
|
|
99
|
+
2. Document using the template above
|
|
100
|
+
3. Look for cross-domain transfer opportunities
|
|
101
|
+
4. Add to the appropriate category
|
|
102
|
+
|
|
103
|
+
## Metrics
|
|
104
|
+
|
|
105
|
+
Track pattern catalog health:
|
|
106
|
+
- Patterns documented: 5
|
|
107
|
+
- Cross-domain transfers: 3 (1 implemented)
|
|
108
|
+
- Implementations: 1 (Trust Circuit Breaker)
|
|
109
|
+
- Coverage of codebase: ~40%
|
|
110
|
+
- Last updated: 2025-12-28
|
|
111
|
+
|
|
112
|
+
## Documentation
|
|
113
|
+
|
|
114
|
+
- [Pattern Catalog Guide](../docs/guides/pattern-catalog.md) - How to use and contribute to the catalog
|
|
115
|
+
- [Trust Circuit Breaker Guide](../docs/guides/trust-circuit-breaker.md) - Detailed guide for the implemented transfer
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
*This catalog is a key component of reaching Level 5 (Systems Thinking) capability.*
|
patterns/__init__.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Wizard Factory Pattern Library.
|
|
2
|
+
|
|
3
|
+
This package provides a comprehensive pattern library for creating wizards
|
|
4
|
+
in the Empathy Framework. Patterns are extracted from 78 existing wizards
|
|
5
|
+
and encoded as Pydantic models for type safety and code generation.
|
|
6
|
+
|
|
7
|
+
**Pattern Categories:**
|
|
8
|
+
- Structural: Overall wizard flow and architecture
|
|
9
|
+
- Input: Data collection patterns
|
|
10
|
+
- Validation: Data validation and approval patterns
|
|
11
|
+
- Behavior: Wizard behavior and capabilities
|
|
12
|
+
- Empathy: User experience and empathy patterns
|
|
13
|
+
|
|
14
|
+
**Usage:**
|
|
15
|
+
from patterns import get_pattern_registry, LinearFlowPattern
|
|
16
|
+
|
|
17
|
+
# Get pattern registry
|
|
18
|
+
registry = get_pattern_registry()
|
|
19
|
+
|
|
20
|
+
# Search for patterns
|
|
21
|
+
patterns = registry.search("linear")
|
|
22
|
+
|
|
23
|
+
# Get pattern by ID
|
|
24
|
+
pattern = registry.get("linear_flow")
|
|
25
|
+
|
|
26
|
+
# Generate code from pattern
|
|
27
|
+
code = pattern.generate_code()
|
|
28
|
+
|
|
29
|
+
Copyright 2025 Smart AI Memory, LLC
|
|
30
|
+
Licensed under Fair Source 0.9
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
from .behavior import (
|
|
34
|
+
AIEnhancementPattern,
|
|
35
|
+
FixApplicationPattern,
|
|
36
|
+
PredictionPattern,
|
|
37
|
+
RiskAssessmentPattern,
|
|
38
|
+
RiskLevel,
|
|
39
|
+
)
|
|
40
|
+
from .core import BasePattern, CodeGeneratorMixin, PatternCategory, ValidationMixin
|
|
41
|
+
from .empathy import EducationalBannerPattern, EmpathyLevelPattern, UserGuidancePattern
|
|
42
|
+
from .input import (
|
|
43
|
+
CodeAnalysisPattern,
|
|
44
|
+
ContextBasedPattern,
|
|
45
|
+
FieldDefinition,
|
|
46
|
+
StructuredFieldsPattern,
|
|
47
|
+
)
|
|
48
|
+
from .registry import PatternRegistry, get_pattern_registry, load_patterns
|
|
49
|
+
from .structural import (
|
|
50
|
+
LinearFlowPattern,
|
|
51
|
+
PhaseConfig,
|
|
52
|
+
PhasedProcessingPattern,
|
|
53
|
+
SessionBasedPattern,
|
|
54
|
+
StepConfig,
|
|
55
|
+
)
|
|
56
|
+
from .validation import ApprovalPattern, ConfigValidationPattern, StepValidationPattern
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
# Core
|
|
60
|
+
"BasePattern",
|
|
61
|
+
"PatternCategory",
|
|
62
|
+
"CodeGeneratorMixin",
|
|
63
|
+
"ValidationMixin",
|
|
64
|
+
# Structural
|
|
65
|
+
"StepConfig",
|
|
66
|
+
"LinearFlowPattern",
|
|
67
|
+
"PhaseConfig",
|
|
68
|
+
"PhasedProcessingPattern",
|
|
69
|
+
"SessionBasedPattern",
|
|
70
|
+
# Input
|
|
71
|
+
"FieldDefinition",
|
|
72
|
+
"StructuredFieldsPattern",
|
|
73
|
+
"CodeAnalysisPattern",
|
|
74
|
+
"ContextBasedPattern",
|
|
75
|
+
# Validation
|
|
76
|
+
"ConfigValidationPattern",
|
|
77
|
+
"StepValidationPattern",
|
|
78
|
+
"ApprovalPattern",
|
|
79
|
+
# Behavior
|
|
80
|
+
"RiskLevel",
|
|
81
|
+
"RiskAssessmentPattern",
|
|
82
|
+
"AIEnhancementPattern",
|
|
83
|
+
"PredictionPattern",
|
|
84
|
+
"FixApplicationPattern",
|
|
85
|
+
# Empathy
|
|
86
|
+
"EmpathyLevelPattern",
|
|
87
|
+
"EducationalBannerPattern",
|
|
88
|
+
"UserGuidancePattern",
|
|
89
|
+
# Registry
|
|
90
|
+
"PatternRegistry",
|
|
91
|
+
"get_pattern_registry",
|
|
92
|
+
"load_patterns",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
__version__ = "1.0.0"
|
patterns/behavior.py
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"""Behavior patterns for wizard capabilities.
|
|
2
|
+
|
|
3
|
+
Behavior patterns define what wizards can do beyond basic data collection:
|
|
4
|
+
- Risk Assessment: Level 4 Anticipatory risk analysis
|
|
5
|
+
- AI Enhancement: Improve user input with AI
|
|
6
|
+
- Prediction: Predict future issues (Level 4)
|
|
7
|
+
- Fix Application: Automatically fix detected issues
|
|
8
|
+
|
|
9
|
+
Copyright 2025 Smart AI Memory, LLC
|
|
10
|
+
Licensed under Fair Source 0.9
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from typing import Literal
|
|
14
|
+
|
|
15
|
+
from pydantic import BaseModel, Field
|
|
16
|
+
|
|
17
|
+
from .core import BasePattern, CodeGeneratorMixin, PatternCategory
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RiskLevel(BaseModel):
|
|
21
|
+
"""Definition of a risk level."""
|
|
22
|
+
|
|
23
|
+
name: str = Field(..., description="Risk level name (e.g., 'critical', 'high')")
|
|
24
|
+
threshold: int = Field(..., description="Issue count threshold for this level", ge=0)
|
|
25
|
+
alert_message: str = Field(..., description="Alert message when threshold exceeded")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RiskAssessmentPattern(BasePattern, CodeGeneratorMixin):
|
|
29
|
+
"""Level 4 Anticipatory risk assessment pattern.
|
|
30
|
+
|
|
31
|
+
**Description:**
|
|
32
|
+
Wizards that analyze issues and predict which ones will cause problems.
|
|
33
|
+
This implements Level 4 Anticipatory Empathy by forecasting future failures.
|
|
34
|
+
|
|
35
|
+
**Usage:** 16 wizards (all coach wizards)
|
|
36
|
+
**Reusability:** 0.8
|
|
37
|
+
|
|
38
|
+
**Risk Levels:**
|
|
39
|
+
- CRITICAL: Will cause production failures (>0 critical issues)
|
|
40
|
+
- HIGH: High probability of bugs (>5 high-risk issues)
|
|
41
|
+
- MEDIUM: Moderate concern (>20 medium issues)
|
|
42
|
+
- LOW: Minor issues
|
|
43
|
+
|
|
44
|
+
**Output:**
|
|
45
|
+
{
|
|
46
|
+
"alert_level": "CRITICAL",
|
|
47
|
+
"by_risk_level": {"critical": 5, "high": 12, "medium": 8},
|
|
48
|
+
"predictions": [...],
|
|
49
|
+
"recommendations": [...],
|
|
50
|
+
}
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
|
|
54
|
+
risk_levels: list[RiskLevel] = Field(
|
|
55
|
+
default_factory=lambda: [
|
|
56
|
+
RiskLevel(
|
|
57
|
+
name="critical",
|
|
58
|
+
threshold=1,
|
|
59
|
+
alert_message="Critical issues detected - production failure likely",
|
|
60
|
+
),
|
|
61
|
+
RiskLevel(
|
|
62
|
+
name="high",
|
|
63
|
+
threshold=5,
|
|
64
|
+
alert_message="High-risk issues accumulating - bugs probable",
|
|
65
|
+
),
|
|
66
|
+
RiskLevel(
|
|
67
|
+
name="medium",
|
|
68
|
+
threshold=20,
|
|
69
|
+
alert_message="Medium issues detected - quality degrading",
|
|
70
|
+
),
|
|
71
|
+
],
|
|
72
|
+
description="Risk level definitions with thresholds",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def generate_code(self) -> str:
|
|
76
|
+
"""Generate risk assessment code."""
|
|
77
|
+
return '''
|
|
78
|
+
class RiskAnalyzer:
|
|
79
|
+
"""Analyze issues for risk levels"""
|
|
80
|
+
|
|
81
|
+
def __init__(self):
|
|
82
|
+
self.risk_levels = ["critical", "high", "medium", "low"]
|
|
83
|
+
|
|
84
|
+
def analyze(self, issues: list) -> dict[str, Any]:
|
|
85
|
+
"""Analyze issues and assess risk.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
issues: List of issues to analyze
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
Risk assessment with alert level and breakdown
|
|
92
|
+
"""
|
|
93
|
+
# Count by risk level
|
|
94
|
+
by_level = {level: 0 for level in self.risk_levels}
|
|
95
|
+
|
|
96
|
+
for issue in issues:
|
|
97
|
+
severity = issue.get("severity", "low")
|
|
98
|
+
if severity in by_level:
|
|
99
|
+
by_level[severity] += 1
|
|
100
|
+
|
|
101
|
+
# Determine alert level
|
|
102
|
+
alert_level = self._determine_alert_level(by_level)
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
"alert_level": alert_level,
|
|
106
|
+
"by_risk_level": by_level,
|
|
107
|
+
"total_issues": len(issues),
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
def _determine_alert_level(self, by_level: dict[str, int]) -> str:
|
|
111
|
+
"""Determine overall alert level"""
|
|
112
|
+
if by_level["critical"] > 0:
|
|
113
|
+
return "CRITICAL"
|
|
114
|
+
elif by_level["high"] > 5:
|
|
115
|
+
return "HIGH"
|
|
116
|
+
elif by_level["medium"] > 20:
|
|
117
|
+
return "MEDIUM"
|
|
118
|
+
else:
|
|
119
|
+
return "LOW"
|
|
120
|
+
'''
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class AIEnhancementPattern(BasePattern, CodeGeneratorMixin):
|
|
124
|
+
"""AI text enhancement pattern.
|
|
125
|
+
|
|
126
|
+
**Description:**
|
|
127
|
+
Wizards that use AI to improve user-provided text. Common in healthcare
|
|
128
|
+
wizards where users provide rough notes and AI enhances them with:
|
|
129
|
+
- Professional medical terminology
|
|
130
|
+
- Proper formatting
|
|
131
|
+
- Clarity improvements
|
|
132
|
+
- Grammar/spelling fixes
|
|
133
|
+
|
|
134
|
+
**Usage:** 16 wizards (all healthcare wizards)
|
|
135
|
+
**Reusability:** 0.7
|
|
136
|
+
|
|
137
|
+
**Endpoint:**
|
|
138
|
+
POST /{wizard_id}/enhance
|
|
139
|
+
Body: {"text": "...", "field": "chief_complaint"}
|
|
140
|
+
|
|
141
|
+
**Enhancement Guidelines:**
|
|
142
|
+
- Preserve original meaning
|
|
143
|
+
- Use domain-appropriate terminology
|
|
144
|
+
- Maintain professional tone
|
|
145
|
+
- Follow documentation standards
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
|
|
149
|
+
enhancement_guidelines: list[str] = Field(
|
|
150
|
+
default_factory=lambda: [
|
|
151
|
+
"Use appropriate clinical terminology",
|
|
152
|
+
"Clear and concise language",
|
|
153
|
+
"Maintain professional tone",
|
|
154
|
+
"Preserve all key information",
|
|
155
|
+
"Follow documentation standards",
|
|
156
|
+
],
|
|
157
|
+
description="Guidelines for AI enhancement",
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
def generate_code(self) -> str:
|
|
161
|
+
"""Generate AI enhancement endpoint."""
|
|
162
|
+
guidelines = "\n".join(f"- {g}" for g in self.enhancement_guidelines)
|
|
163
|
+
|
|
164
|
+
return f'''
|
|
165
|
+
@router.post("/{{wizard_id}}/enhance")
|
|
166
|
+
async def enhance_text(wizard_id: str, text_data: dict[str, Any]):
|
|
167
|
+
"""Enhance user text with AI
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
wizard_id: Wizard session ID
|
|
171
|
+
text_data: {{"text": "...", "field": "field_name"}}
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
Enhanced text
|
|
175
|
+
"""
|
|
176
|
+
session = await _get_session(wizard_id)
|
|
177
|
+
if not session:
|
|
178
|
+
raise HTTPException(404, "Wizard session not found")
|
|
179
|
+
|
|
180
|
+
original_text = text_data.get("text", "")
|
|
181
|
+
field_name = text_data.get("field", "text")
|
|
182
|
+
|
|
183
|
+
if not original_text:
|
|
184
|
+
raise HTTPException(422, "No text provided for enhancement")
|
|
185
|
+
|
|
186
|
+
# Get chat service
|
|
187
|
+
chat_service = get_service("chat")
|
|
188
|
+
|
|
189
|
+
# Enhancement prompt
|
|
190
|
+
prompt = f"""
|
|
191
|
+
You are assisting with documentation. Please enhance the following text:
|
|
192
|
+
|
|
193
|
+
Field: {{field_name}}
|
|
194
|
+
Original: {{original_text}}
|
|
195
|
+
|
|
196
|
+
Enhancement guidelines:
|
|
197
|
+
{guidelines}
|
|
198
|
+
|
|
199
|
+
Enhanced text:"""
|
|
200
|
+
|
|
201
|
+
response = await chat_service.chat(
|
|
202
|
+
message=prompt,
|
|
203
|
+
conversation_id=f"enhance_{{wizard_id}}",
|
|
204
|
+
context={{"wizard_id": wizard_id, "field": field_name}},
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
return {{
|
|
208
|
+
"original_text": original_text,
|
|
209
|
+
"enhanced_text": response.get("response", original_text),
|
|
210
|
+
"field": field_name,
|
|
211
|
+
}}
|
|
212
|
+
'''
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class PredictionPattern(BasePattern):
|
|
216
|
+
"""Level 4 Anticipatory prediction pattern.
|
|
217
|
+
|
|
218
|
+
**Description:**
|
|
219
|
+
Wizards that predict future issues before they occur. This implements
|
|
220
|
+
Level 4 Anticipatory Empathy by forecasting problems.
|
|
221
|
+
|
|
222
|
+
**Usage:** 16 wizards (all coach wizards)
|
|
223
|
+
**Reusability:** 0.8
|
|
224
|
+
|
|
225
|
+
**Prediction Types:**
|
|
226
|
+
- production_failure_risk: Critical issues → runtime errors
|
|
227
|
+
- bug_density_increase: High-risk accumulation → more bugs
|
|
228
|
+
- technical_debt_accumulation: Code quality degradation
|
|
229
|
+
- test_maintenance_burden: Flaky tests → maintenance overhead
|
|
230
|
+
|
|
231
|
+
**Signature:**
|
|
232
|
+
def predict_future_issues(
|
|
233
|
+
self,
|
|
234
|
+
code: str,
|
|
235
|
+
file_path: str,
|
|
236
|
+
project_context: dict,
|
|
237
|
+
timeline_days: int = 90
|
|
238
|
+
) -> list[WizardPrediction]
|
|
239
|
+
"""
|
|
240
|
+
|
|
241
|
+
category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
|
|
242
|
+
timeline_days: int = Field(
|
|
243
|
+
default=90,
|
|
244
|
+
description="Prediction timeline in days",
|
|
245
|
+
ge=1,
|
|
246
|
+
le=365,
|
|
247
|
+
)
|
|
248
|
+
prediction_types: list[str] = Field(
|
|
249
|
+
default_factory=lambda: [
|
|
250
|
+
"production_failure_risk",
|
|
251
|
+
"bug_density_increase",
|
|
252
|
+
"technical_debt_accumulation",
|
|
253
|
+
],
|
|
254
|
+
description="Types of predictions this wizard makes",
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class FixApplicationPattern(BasePattern):
|
|
259
|
+
"""Automatic fix application pattern.
|
|
260
|
+
|
|
261
|
+
**Description:**
|
|
262
|
+
Wizards that can automatically fix detected issues. Issues are grouped
|
|
263
|
+
into auto-fixable and manual categories.
|
|
264
|
+
|
|
265
|
+
**Usage:** 8 wizards (AI wizards with code modification)
|
|
266
|
+
**Reusability:** 0.75
|
|
267
|
+
|
|
268
|
+
**Workflow:**
|
|
269
|
+
1. Detect issues
|
|
270
|
+
2. Group by fixability (auto vs manual)
|
|
271
|
+
3. Apply auto-fixes if enabled
|
|
272
|
+
4. Track success/failure per fix
|
|
273
|
+
|
|
274
|
+
**Auto-Fixable Examples:**
|
|
275
|
+
- Linting issues (ruff --fix)
|
|
276
|
+
- Import sorting (isort)
|
|
277
|
+
- Code formatting (black)
|
|
278
|
+
- Simple refactorings
|
|
279
|
+
|
|
280
|
+
**Manual-Only Examples:**
|
|
281
|
+
- Architecture changes
|
|
282
|
+
- Logic bugs
|
|
283
|
+
- Security vulnerabilities
|
|
284
|
+
"""
|
|
285
|
+
|
|
286
|
+
category: Literal[PatternCategory.BEHAVIOR] = PatternCategory.BEHAVIOR
|
|
287
|
+
auto_fix_enabled: bool = Field(
|
|
288
|
+
default=False,
|
|
289
|
+
description="Whether auto-fix is enabled by default",
|
|
290
|
+
)
|
|
291
|
+
dry_run_by_default: bool = Field(
|
|
292
|
+
default=True,
|
|
293
|
+
description="Whether to dry-run fixes before applying",
|
|
294
|
+
)
|
|
295
|
+
supported_fix_types: list[str] = Field(
|
|
296
|
+
default_factory=lambda: ["lint", "format", "import", "refactor"],
|
|
297
|
+
description="Types of fixes this wizard supports",
|
|
298
|
+
)
|