Failure policy
Declarative dispatch from typed errors to recovery outcomes — retry, replan, skip, fallback to human, terminate.
Declarative dispatch from type[EntorinError] to a recovery PolicyOutcome. The control plane names the recovery; the orchestrator acts on it.
from entorin.errors import TransientError, ParseError
from entorin.policy import PolicyTable, PolicyOutcome, RetryPolicy
table = PolicyTable(bus=bus, default=RetryPolicy(max_attempts=1))
table.register(TransientError, RetryPolicy(max_attempts=3))
table.register(ParseError, RetryPolicy(max_attempts=1))
outcome = await table.handle(error, ctx, attempt=current_attempt)
match outcome:
case PolicyOutcome.retry: ...
case PolicyOutcome.replan: bus.publish(replan_event); ...
case PolicyOutcome.fallback_human: await checkpoint.request(ctx, ...)
case _: raise
Outcomes
Five fixed values: retry, replan, skip, fallback_human, terminate. Reference policies (RetryPolicy, ReplanPolicy, SkipPolicy, FallbackHumanPolicy) ship; user-supplied dispatch logic plugs into the same shape.
Lookup
MRO-walking — registering EntorinError catches everything not otherwise handled. Six typed categories all inherit EntorinError: TransientError, PolicyError, BudgetError, UserAbortError, ToolError, ParseError.