generated from john/python-template
2.7 KiB
2.7 KiB
Error Handling Policy (Version 4)
This policy defines active V4 error taxonomy, translation boundaries, and retry semantics.
Error Categories
| Category | Meaning | Typical Origin | User Treatment |
|---|---|---|---|
validation |
Input payload/selection is invalid | UI form parsing, service validators | Inline correction guidance |
not_found |
Target record is missing | ID lookup in service layer | Non-blocking warning or redirect |
conflict |
State prevents requested action | lifecycle transitions, duplicate semantic keys | Explain required precondition |
external |
Provider/network dependency failure | OpenRouter/provider adapter | Retry path and evidence retained |
timeout |
Provider call exceeded configured bound | worker/provider client timeout | Retry path and bounded messaging |
internal |
Unexpected local failure | unhandled service/runtime faults | Safe generic message + diagnostics capture |
Translation Boundaries
- Provider layer: raise provider-scoped exceptions with provider context; do not emit UI text.
- Service layer: map raw exceptions into domain-aware categories and preserve causal chain.
- UI/API layer: convert category to user-safe message with contextual action guidance.
Job and Page Failure Semantics
Page-Level (JobSource)
pending->transcribedwhen attempt succeeds.pending->failedwhen attempt fails terminally.pending->cancelledon job cancellation before processing.
Job-Level (Job)
transcribedwhen all pages transcribe successfully.partial_successwhen mixed success/failure outcomes exist.failedwhen no page transcribes successfully.
Retry and Retranscription Rules
- Failed/cancelled pages may be re-queued through retranscription workflows.
- Retry attempts must append new
ExecutionAttemptrows; prior evidence remains immutable. - Selecting a better candidate must update projection pointers, not mutate historical attempt rows.
Logging and Diagnostics Rules
- Persist sufficient attempt error metadata (
error_category,error_message, transport evidence) for post-hoc analysis. - Avoid leaking stack traces or local paths into user-facing message envelopes.
- Preserve causal exception chains for internal diagnostics.
UI Messaging Contract
- User-visible errors must be actionable, bounded, and category-consistent.
- Multi-page jobs must show partial outcomes instead of collapsing into a single opaque failure.
- Recovery actions (
retry,retranscribe,edit input) must be offered where available.