codes
codes
¶
Error codes, categories, and severity levels.
Contains the structured error classification enums used throughout Marianne.
This module provides: - ExitReason: Type alias for process exit reasons - RetryDelays: Constants for retry timing - Severity: Severity levels for error classification - RetryBehavior: Precise retry recommendations per error code - ErrorCode: Structured error codes (E0xx-E9xx) - ErrorCategory: High-level categories for retry behavior
Error Code Taxonomy¶
Marianne uses a structured error code system organized by category prefixes. Each error code provides specific retry behavior guidance.
E0xx - Execution Errors Process-level failures during command execution.
| Code | Name | Retriable | Severity | Default Delay |
|------|------|-----------|----------|---------------|
| E001 | EXECUTION_TIMEOUT | Yes | ERROR | 60s |
| E002 | EXECUTION_KILLED | Yes | ERROR | 30s |
| E003 | EXECUTION_CRASHED | No | CRITICAL | N/A |
| E004 | EXECUTION_INTERRUPTED | No | ERROR | N/A |
| E005 | EXECUTION_OOM | No | CRITICAL | N/A |
| E006 | EXECUTION_STALE | Yes | WARNING | 120s |
| E009 | EXECUTION_UNKNOWN | Yes | ERROR | 10s |
E1xx - Rate Limit / Capacity Errors API throttling and resource exhaustion.
| Code | Name | Retriable | Severity | Default Delay |
|------|------|-----------|----------|---------------|
| E101 | RATE_LIMIT_API | Yes | ERROR | 1 hour |
| E102 | RATE_LIMIT_CLI | Yes | ERROR | 15 min |
| E103 | CAPACITY_EXCEEDED | Yes | WARNING | 5 min |
| E104 | QUOTA_EXHAUSTED | Yes | ERROR | Dynamic* |
*E104 delay is parsed from API response reset time.
E2xx - Validation Errors Output validation failures (retriable - LLM may produce correct output).
| Code | Name | Retriable | Severity | Default Delay |
|------|------|-----------|----------|---------------|
| E201 | VALIDATION_FILE_MISSING | Yes | ERROR | 5s |
| E202 | VALIDATION_CONTENT_MISMATCH | Yes | ERROR | 5s |
| E203 | VALIDATION_COMMAND_FAILED | Yes | ERROR | 10s |
| E204 | VALIDATION_TIMEOUT | Yes | WARNING | 30s |
| E209 | VALIDATION_GENERIC | Yes | ERROR | 5s |
E3xx - Configuration Errors Job configuration problems (not retriable - requires user fix).
| Code | Name | Retriable | Severity |
|------|------|-----------|----------|
| E301 | CONFIG_INVALID | No | ERROR |
| E302 | CONFIG_MISSING_FIELD | No | ERROR |
| E303 | CONFIG_PATH_NOT_FOUND | No | ERROR |
| E304 | CONFIG_PARSE_ERROR | No | ERROR |
| E305 | CONFIG_MCP_ERROR | No | ERROR |
| E306 | CONFIG_CLI_MODE_ERROR | No | ERROR |
E4xx - State Errors Checkpoint state issues.
| Code | Name | Retriable | Severity |
|------|------|-----------|----------|
| E401 | STATE_CORRUPTION | No | CRITICAL |
| E402 | STATE_LOAD_FAILED | Yes | ERROR |
| E403 | STATE_SAVE_FAILED | Yes | ERROR |
| E404 | STATE_VERSION_MISMATCH | No | ERROR |
E5xx - Backend Errors Backend service/connection issues.
| Code | Name | Retriable | Severity | Default Delay |
|------|------|-----------|----------|---------------|
| E501 | BACKEND_CONNECTION | Yes | ERROR | 30s |
| E502 | BACKEND_AUTH | No | CRITICAL | N/A |
| E503 | BACKEND_RESPONSE | Yes | ERROR | 15s |
| E504 | BACKEND_TIMEOUT | Yes | ERROR | 60s |
| E505 | BACKEND_NOT_FOUND | No | CRITICAL | N/A |
E6xx - Preflight Errors Pre-execution validation failures (not retriable).
| Code | Name | Retriable | Severity |
|------|------|-----------|----------|
| E601 | PREFLIGHT_PATH_MISSING | No | ERROR |
| E602 | PREFLIGHT_PROMPT_TOO_LARGE | No | ERROR |
| E603 | PREFLIGHT_WORKING_DIR_INVALID | No | ERROR |
| E604 | PREFLIGHT_VALIDATION_SETUP | No | ERROR |
E9xx - Network/Transient Errors Network connectivity and transient failures.
| Code | Name | Retriable | Severity | Default Delay |
|------|------|-----------|----------|---------------|
| E901 | NETWORK_CONNECTION_FAILED | Yes | ERROR | 30s |
| E902 | NETWORK_DNS_ERROR | Yes | ERROR | 30s |
| E903 | NETWORK_SSL_ERROR | Yes | ERROR | 30s |
| E904 | NETWORK_TIMEOUT | Yes | ERROR | 60s |
| E999 | UNKNOWN | Yes | ERROR | 30s |
Usage¶
Error codes are used throughout Marianne for: - Programmatic routing: Switch on error_code.category for handling logic - Retry decisions: Use error_code.get_retry_behavior() for delay/retriability - Logging/metrics: Structured error codes enable aggregation and alerting - User guidance: Error codes map to documentation and troubleshooting guides
Example::
result = error_classifier.classify(stdout, stderr, exit_code)
if result.primary.error_code.category == "rate_limit":
delay = result.primary.error_code.get_retry_behavior().delay_seconds
await asyncio.sleep(delay)
Classes¶
RetryDelays
¶
Constants for retry delay durations.
Centralizes magic numbers for retry timing to ensure consistency across the codebase and make timing decisions discoverable.
These values represent standard delays for different error scenarios. Actual delays may be adjusted dynamically based on error context, parsed reset times, or learning from previous attempts.
Severity
¶
Bases: IntEnum
Severity levels for error classification.
Lower numeric value = higher severity. This allows comparisons like
if severity <= Severity.ERROR to check for serious issues.
Assignments: - CRITICAL: Job cannot continue, requires immediate attention (E003 crash, E005 OOM, E401 corruption, E502 auth, E505 binary not found) - ERROR: Operation failed, may be retriable (most error codes) - WARNING: Degraded operation, job may continue (E103 capacity, E204 validation timeout) - INFO: Informational, no action required (reserved for future diagnostic codes)
RetryBehavior
¶
Bases: NamedTuple
Precise retry behavior recommendation for a specific error code.
Unlike ErrorCategory which provides broad retry guidelines, RetryBehavior encodes error-code-specific knowledge about optimal retry strategies.
Attributes:
| Name | Type | Description |
|---|---|---|
delay_seconds |
float
|
Recommended delay before retrying (0 = no delay). |
is_retriable |
bool
|
Whether this error is generally retriable. |
reason |
str
|
Human-readable explanation for the retry behavior. |
ErrorCode
¶
Bases: str, Enum
Structured error codes for comprehensive error classification.
Error codes are organized by category using numeric prefixes: - E0xx: Execution errors (timeouts, crashes, kills) - E1xx: Rate limit / capacity errors - E2xx: Validation errors - E3xx: Configuration errors - E4xx: State errors - E5xx: Backend errors - E6xx: Preflight errors
Error codes are stable identifiers that can be used for: - Programmatic error handling and routing - Log aggregation and alerting - Documentation and troubleshooting guides - Metrics and observability dashboards
Attributes¶
EXECUTION_TIMEOUT
class-attribute
instance-attribute
¶
Command execution exceeded timeout limit.
EXECUTION_KILLED
class-attribute
instance-attribute
¶
Process was killed by a signal (external termination).
EXECUTION_CRASHED
class-attribute
instance-attribute
¶
Process crashed (segfault, bus error, abort, etc.).
EXECUTION_INTERRUPTED
class-attribute
instance-attribute
¶
Process was interrupted by user (SIGINT/Ctrl+C).
EXECUTION_OOM
class-attribute
instance-attribute
¶
Process was killed due to out of memory condition.
EXECUTION_STALE
class-attribute
instance-attribute
¶
Execution killed by stale detection — no output for too long.
EXECUTION_UNKNOWN
class-attribute
instance-attribute
¶
Unknown execution error with non-zero exit code.
RATE_LIMIT_API
class-attribute
instance-attribute
¶
API rate limit exceeded (429, quota, throttling).
RATE_LIMIT_CLI
class-attribute
instance-attribute
¶
CLI-level rate limiting detected.
CAPACITY_EXCEEDED
class-attribute
instance-attribute
¶
Service capacity exceeded (overloaded, try again later).
QUOTA_EXHAUSTED
class-attribute
instance-attribute
¶
Token/usage quota exhausted - wait until reset time.
VALIDATION_FILE_MISSING
class-attribute
instance-attribute
¶
Expected output file does not exist.
VALIDATION_CONTENT_MISMATCH
class-attribute
instance-attribute
¶
Output content does not match expected pattern.
VALIDATION_COMMAND_FAILED
class-attribute
instance-attribute
¶
Validation command returned non-zero exit code.
VALIDATION_TIMEOUT
class-attribute
instance-attribute
¶
Validation check timed out.
VALIDATION_GENERIC
class-attribute
instance-attribute
¶
Generic validation failure (output validation needed).
CONFIG_INVALID
class-attribute
instance-attribute
¶
Configuration file is malformed or invalid.
CONFIG_MISSING_FIELD
class-attribute
instance-attribute
¶
Required configuration field is missing.
CONFIG_PATH_NOT_FOUND
class-attribute
instance-attribute
¶
Configuration file path does not exist.
CONFIG_PARSE_ERROR
class-attribute
instance-attribute
¶
Failed to parse configuration file (YAML/JSON syntax error).
CONFIG_MCP_ERROR
class-attribute
instance-attribute
¶
MCP server/plugin configuration error (missing env vars, invalid config).
CONFIG_CLI_MODE_ERROR
class-attribute
instance-attribute
¶
Claude CLI mode mismatch (e.g., streaming mode incompatible with operation).
STATE_CORRUPTION
class-attribute
instance-attribute
¶
Checkpoint state file is corrupted or inconsistent.
STATE_LOAD_FAILED
class-attribute
instance-attribute
¶
Failed to load checkpoint state from storage.
STATE_SAVE_FAILED
class-attribute
instance-attribute
¶
Failed to save checkpoint state to storage.
STATE_VERSION_MISMATCH
class-attribute
instance-attribute
¶
Checkpoint state version is incompatible.
BACKEND_CONNECTION
class-attribute
instance-attribute
¶
Failed to connect to backend service.
BACKEND_AUTH
class-attribute
instance-attribute
¶
Backend authentication or authorization failed.
BACKEND_RESPONSE
class-attribute
instance-attribute
¶
Invalid or unexpected response from backend.
BACKEND_TIMEOUT
class-attribute
instance-attribute
¶
Backend request timed out.
BACKEND_NOT_FOUND
class-attribute
instance-attribute
¶
Backend executable or service not found.
PREFLIGHT_PATH_MISSING
class-attribute
instance-attribute
¶
Required path does not exist (working_dir, referenced file).
PREFLIGHT_PROMPT_TOO_LARGE
class-attribute
instance-attribute
¶
Prompt exceeds recommended token limit.
PREFLIGHT_WORKING_DIR_INVALID
class-attribute
instance-attribute
¶
Working directory is not accessible or not a directory.
PREFLIGHT_VALIDATION_SETUP
class-attribute
instance-attribute
¶
Validation target path or pattern is invalid.
NETWORK_CONNECTION_FAILED
class-attribute
instance-attribute
¶
Network connection failed (refused, reset, unreachable).
NETWORK_DNS_ERROR
class-attribute
instance-attribute
¶
DNS resolution failed.
NETWORK_SSL_ERROR
class-attribute
instance-attribute
¶
SSL/TLS handshake or certificate error.
NETWORK_TIMEOUT
class-attribute
instance-attribute
¶
Network operation timed out.
UNKNOWN
class-attribute
instance-attribute
¶
Unclassified error - requires investigation.
category
property
¶
Get the category prefix (first digit) of this error code.
Returns:
| Type | Description |
|---|---|
str
|
Category string like "execution", "rate_limit", "validation", etc. |
is_retriable
property
¶
Check if this error code is generally retriable.
Returns:
| Type | Description |
|---|---|
bool
|
True if errors with this code are typically retriable. |
Functions¶
get_retry_behavior
¶
Get precise retry behavior for this error code.
Returns error-code-specific delay and retry recommendations. Uses module-level _RETRY_BEHAVIORS constant to avoid rebuilding the lookup table on every call.
Returns:
| Type | Description |
|---|---|
RetryBehavior
|
RetryBehavior with delay, retriability, and reason. |
Source code in src/marianne/core/errors/codes.py
get_severity
¶
Get the severity level for this error code.
Severity assignments: - CRITICAL: Fatal errors requiring immediate attention - ERROR: Most error codes (default) - WARNING: Degraded but potentially temporary conditions - INFO: Reserved for future diagnostic codes
Returns:
| Type | Description |
|---|---|
Severity
|
Severity level for this error code. |
Source code in src/marianne/core/errors/codes.py
ErrorCategory
¶
Bases: str, Enum
Categories of errors with different retry behaviors.
Attributes¶
RATE_LIMIT
class-attribute
instance-attribute
¶
Retriable with long wait - API/service is rate limiting.
TRANSIENT
class-attribute
instance-attribute
¶
Retriable with backoff - temporary network/service issues.
VALIDATION
class-attribute
instance-attribute
¶
Retriable - Claude ran but didn't produce expected output.
AUTH
class-attribute
instance-attribute
¶
Fatal - authentication/authorization failure, needs user intervention.
NETWORK
class-attribute
instance-attribute
¶
Retriable with backoff - network connectivity issues.
SIGNAL
class-attribute
instance-attribute
¶
Process killed by signal - may be retriable depending on signal.
CONFIGURATION
class-attribute
instance-attribute
¶
Non-retriable - configuration error needs user intervention (e.g., MCP setup).
PREFLIGHT
class-attribute
instance-attribute
¶
Pre-execution check failure — config or environment not ready.
ESCALATION
class-attribute
instance-attribute
¶
Escalation-based abort — grounding or escalation policy triggered.