context
context
¶
Error context for self-healing diagnosis.
Captures all diagnostic information needed to analyze failures and determine appropriate remediation.
Attributes¶
Classes¶
ErrorContext
dataclass
¶
ErrorContext(error_code, error_message, error_category, exception=None, exit_code=None, signal=None, stdout_tail='', stderr_tail='', config_path=None, config=None, workspace=None, sheet_number=0, working_directory=None, environment=dict(), retry_count=0, max_retries=0, previous_errors=list(), raw_config_yaml=None, validation_details=list())
Rich context gathered when an error occurs.
Provides all information needed by the diagnosis engine and remedies to understand and potentially fix the error.
Attributes:
| Name | Type | Description |
|---|---|---|
error_code |
str
|
Structured error code (e.g., E601, E304) |
error_message |
str
|
Human-readable error description |
error_category |
str
|
High-level category (preflight, configuration, etc.) |
exception |
Exception | None
|
Original exception if available |
exit_code |
int | None
|
Process exit code (if applicable) |
signal |
int | None
|
Termination signal (if applicable) |
stdout_tail |
str
|
Last portion of stdout output |
stderr_tail |
str
|
Last portion of stderr output |
config_path |
Path | None
|
Path to the job configuration file |
config |
JobConfig | None
|
Parsed JobConfig object |
workspace |
Path | None
|
Workspace directory path |
sheet_number |
int
|
Current sheet number |
working_directory |
Path | None
|
Backend working directory |
environment |
dict[str, str]
|
Relevant environment variables |
retry_count |
int
|
Number of retries attempted |
max_retries |
int
|
Maximum retries configured |
previous_errors |
list[str]
|
Error codes from previous attempts |
Functions¶
from_execution_result
classmethod
¶
from_execution_result(result, config, config_path, sheet_number, error_code, error_message, error_category, retry_count=0, max_retries=0, previous_errors=None)
Create context from an execution result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ExecutionResult
|
The failed execution result. |
required |
config
|
JobConfig
|
Job configuration. |
required |
config_path
|
Path | None
|
Path to config file. |
required |
sheet_number
|
int
|
Current sheet number. |
required |
error_code
|
str
|
Classified error code. |
required |
error_message
|
str
|
Error message. |
required |
error_category
|
str
|
Error category. |
required |
retry_count
|
int
|
Current retry count. |
0
|
max_retries
|
int
|
Maximum retries allowed. |
0
|
previous_errors
|
list[str] | None
|
Error codes from previous attempts. |
None
|
Returns:
| Type | Description |
|---|---|
ErrorContext
|
ErrorContext with all diagnostic information. |
Source code in src/marianne/healing/context.py
from_preflight_error
classmethod
¶
Create context from a preflight check failure.
Preflight errors occur before execution starts, so there's no ExecutionResult. This is common for validation errors like missing workspace directories or invalid templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
JobConfig
|
Job configuration. |
required |
config_path
|
Path | None
|
Path to config file. |
required |
error_code
|
str
|
Preflight error code. |
required |
error_message
|
str
|
Error description. |
required |
sheet_number
|
int
|
Sheet number (0 if global). |
0
|
raw_yaml
|
str | None
|
Raw YAML content for template analysis. |
None
|
Returns:
| Type | Description |
|---|---|
ErrorContext
|
ErrorContext for preflight failures. |
Source code in src/marianne/healing/context.py
get_context_summary
¶
Get a summary of context for logging/display.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with key context information. |