patterns_success_factors
patterns_success_factors
¶
Pattern success factors (metacognitive reflection) mixin for GlobalLearningStore.
Provides methods for understanding WHY patterns succeed: - update_success_factors: Record context conditions of successful application - get_success_factors: Retrieve a pattern's success factors - analyze_pattern_why: Generate human-readable WHY analysis - get_patterns_with_why: Query patterns with their analysis
v22 Evolution: Metacognitive Pattern Reflection
Classes¶
PatternSuccessFactorsMixin
¶
Bases: _SuccessFactorsBase
Mixin providing pattern success factor analysis methods.
This mixin requires that the composed class provides: - _get_connection(): Context manager yielding sqlite3.Connection - get_pattern_by_id(): For pattern lookup (from PatternQueryMixin) - _row_to_pattern_record(): For row conversion (from PatternQueryMixin) - analyze_pattern_why(): Self-reference for get_patterns_with_why
Functions¶
update_success_factors
¶
update_success_factors(pattern_id, validation_types=None, error_categories=None, prior_sheet_status=None, retry_iteration=0, escalation_was_pending=False, grounding_confidence=None)
Update success factors for a pattern based on a successful application.
Captures the WHY behind pattern success — the context conditions that were present when the pattern worked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern_id
|
str
|
The pattern that succeeded. |
required |
validation_types
|
list[str] | None
|
Validation types active (file, regex, artifact, etc.) |
None
|
error_categories
|
list[str] | None
|
Error categories present (rate_limit, auth, etc.) |
None
|
prior_sheet_status
|
str | None
|
Status of prior sheet (completed, failed, skipped) |
None
|
retry_iteration
|
int
|
Which retry this success occurred on (0 = first) |
0
|
escalation_was_pending
|
bool
|
Whether escalation was pending |
False
|
grounding_confidence
|
float | None
|
Grounding confidence if external validation present |
None
|
Returns:
| Type | Description |
|---|---|
SuccessFactors | None
|
Updated SuccessFactors, or None if pattern not found. |
Source code in src/marianne/learning/store/patterns_success_factors.py
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 | |
get_success_factors
¶
Get the success factors for a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern_id
|
str
|
The pattern ID to get factors for. |
required |
Returns:
| Type | Description |
|---|---|
SuccessFactors | None
|
SuccessFactors if the pattern has captured factors, None otherwise. |
Source code in src/marianne/learning/store/patterns_success_factors.py
analyze_pattern_why
¶
Analyze WHY a pattern succeeds with structured explanation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern_id
|
str
|
The pattern to analyze. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with analysis results including factors_summary, |
dict[str, Any]
|
key_conditions, confidence, and recommendations. |
Source code in src/marianne/learning/store/patterns_success_factors.py
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 | |
get_patterns_with_why
¶
Get patterns with their WHY analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_observations
|
int
|
Minimum success factor observations required. |
1
|
limit
|
int
|
Maximum number of patterns to return. |
20
|
Returns:
| Type | Description |
|---|---|
list[tuple[PatternRecord, dict[str, Any]]]
|
List of (PatternRecord, analysis_dict) tuples. |