Principle:0x4m4 Hexstrike ai Resilient Subprocess Execution
| Knowledge Sources | |
|---|---|
| Domains | Subprocess, Reliability, Tool_Execution |
| Last Updated | 2026-10-10 00:00 GMT |
Overview
Execution pattern that wraps subprocess calls in a recovery loop with error detection, strategy selection, and multiple recovery actions (retry, parameter adjustment, tool switching, graceful degradation).
Description
The Resilient Subprocess Execution principle describes a wrapper around subprocess execution that treats failures as recoverable events rather than terminal errors. On each failure, the system classifies the error, selects a recovery strategy, and applies it before retrying. Recovery strategies include exponential backoff, scope reduction, parameter adjustment, alternative tool switching, graceful degradation, human escalation, and abort. The system tracks a full recovery history for debugging and escalation context.
Usage
Apply this principle when executing external commands that may fail transiently:
- Long-running scans: Tools like nmap and sqlmap may timeout or hit rate limits
- Unattended execution: Recovery allows scans to continue without human intervention
- Production reliability: Multiple recovery strategies prevent single-point failures from aborting entire pipelines
Theoretical Basis
The recovery loop follows a classify-act-retry cycle:
# Abstract pattern (NOT real implementation)
for attempt in range(max_attempts):
result = execute(command)
if result.success:
return result
error_type = classify(result.stderr)
strategy = select_strategy(error_type, attempt_count)
if strategy.action == RETRY_WITH_BACKOFF:
sleep(backoff_delay(attempt))
elif strategy.action == ADJUST_PARAMETERS:
command = rebuild_with_params(adjusted_params)
elif strategy.action == SWITCH_TOOL:
return suggest_alternative(strategy.alternative)
elif strategy.action == ESCALATE:
return escalate_to_human(context)