escalation
escalation
¶
Escalation mixin for the global learning store.
This module contains the EscalationMixin class that provides escalation decision recording and learning functionality. When sheets trigger escalation and receive responses from human or AI handlers, this module records the decisions for future pattern-based suggestions.
Evolution v11: Escalation Learning Loop - closes the loop between escalation handlers and learning system, enabling pattern-based suggestions for similar escalation contexts.
Extracted from global_store.py as part of the modularization effort.
Attributes¶
Classes¶
EscalationMixin
¶
Mixin providing escalation decision functionality.
This mixin provides methods for recording and querying escalation decisions. When a sheet triggers escalation and receives a response, the decision is recorded so Marianne can learn from it and potentially suggest similar actions for future escalations with similar contexts.
Requires the following from the composed class
- _get_connection() -> context manager yielding sqlite3.Connection
- hash_job(job_id: str) -> str (static method)
Functions¶
record_escalation_decision
¶
record_escalation_decision(job_id, sheet_num, confidence, action, validation_pass_rate, retry_count, guidance=None, outcome_after_action=None, model=None)
Record an escalation decision for learning.
When a sheet triggers escalation and receives a response from a human or AI handler, this method records the decision so that Marianne can learn from it and potentially suggest similar actions for future escalations with similar contexts.
Evolution v11: Escalation Learning Loop - closes the loop between escalation handlers and learning system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
ID of the job that triggered escalation. |
required |
sheet_num
|
int
|
Sheet number that triggered escalation. |
required |
confidence
|
float
|
Aggregate confidence score at escalation time (0.0-1.0). |
required |
action
|
str
|
Action taken (retry, skip, abort, modify_prompt). |
required |
validation_pass_rate
|
float
|
Pass percentage at escalation time. |
required |
retry_count
|
int
|
Number of retries before escalation. |
required |
guidance
|
str | None
|
Optional guidance/notes from the handler. |
None
|
outcome_after_action
|
str | None
|
What happened after (success, failed, etc.). |
None
|
model
|
str | None
|
Optional model name used for execution. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The escalation decision record ID. |
Source code in src/marianne/learning/store/escalation.py
get_escalation_history
¶
Get historical escalation decisions.
Retrieves past escalation decisions for analysis or display. Can filter by job or action type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str | None
|
Optional job ID to filter by. |
None
|
action
|
str | None
|
Optional action type to filter by. |
None
|
limit
|
int
|
Maximum number of records to return. |
20
|
Returns:
| Type | Description |
|---|---|
list[EscalationDecisionRecord]
|
List of EscalationDecisionRecord objects. |
Source code in src/marianne/learning/store/escalation.py
get_similar_escalation
¶
get_similar_escalation(confidence, validation_pass_rate, confidence_tolerance=0.15, pass_rate_tolerance=15.0, limit=5)
Get similar past escalation decisions for guidance.
Finds historical escalations with similar context (confidence and pass rate) to help inform the current escalation decision. Can be used to suggest actions or provide guidance to human operators.
Evolution v11: Escalation Learning Loop - enables pattern-based suggestions for similar escalation contexts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
confidence
|
float
|
Current confidence level (0.0-1.0). |
required |
validation_pass_rate
|
float
|
Current validation pass percentage. |
required |
confidence_tolerance
|
float
|
How much confidence can differ (default 0.15). |
0.15
|
pass_rate_tolerance
|
float
|
How much pass rate can differ (default 15%). |
15.0
|
limit
|
int
|
Maximum number of similar records to return. |
5
|
Returns:
| Type | Description |
|---|---|
list[EscalationDecisionRecord]
|
List of EscalationDecisionRecord from similar past escalations, |
list[EscalationDecisionRecord]
|
ordered by outcome success (successful outcomes first). |
Source code in src/marianne/learning/store/escalation.py
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 | |
update_escalation_outcome
¶
Update the outcome of an escalation decision.
Called after an escalation action is taken and the result is known. This closes the feedback loop by recording whether the action led to success or failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
escalation_id
|
str
|
The escalation record ID to update. |
required |
outcome_after_action
|
str
|
What happened (success, failed, aborted, skipped). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the record was updated, False if not found. |