> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jaantonio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Recovery

> How Lambda continues interrupted work or safely reevaluates a document after a meaningful correction.

Recovery continues only when the next safe action is proven. It does not blindly repeat an issuance
or replace CargoWise accounting decisions.

## Automatic recovery

Automatic recovery resumes persisted work without changing the CargoWise source.

| Interrupted boundary               | Automatic action                                        |
| ---------------------------------- | ------------------------------------------------------- |
| Accepted document never started    | Re-enqueue the persisted intent                         |
| Exact provider attempt interrupted | Resume the same request and idempotency identity        |
| Provider known not to have created | Replay the exact proven request in a controlled attempt |
| Parent dependency incomplete       | Continue when the parent evidence becomes usable        |
| Stamped file missing               | Backfill from the exact issued evidence                 |
| Lambda outbound incomplete         | Retry only the pending CargoWise delivery               |
| Cancellation pending               | Poll or verify the exact cancellation                   |

Automatic recovery stops and opens a failure when:

* the provider outcome remains unknown
* the stored state is inconsistent
* the bounded attempts are exhausted
* a source correction is required

## Corrective recovery

Corrective recovery is for a document that stopped and later received a meaningful correction. It
does not repeat the same failed attempt unchanged.

A document can become eligible when:

* the saved CargoWise source now maps to different fiscal facts
* a required parent or SAT UUID is now usable
* a required certificate, route, or approved prerequisite is now usable

Stamped, cancelled, in-flight, waiting, or unchanged documents remain protected.

<Steps>
  <Step title="Build the preview">
    Lambda reads the immutable capture, current mapping, active failure, lifecycle, and prerequisite
    evidence.
  </Step>

  <Step title="Explain the decision">
    The preview shows whether the document is eligible, what changed, and which standard action
    would run.
  </Step>

  <Step title="Bind the preview">
    Lambda hashes the exact preview state. The hash changes if the document, source, failure, or
    prerequisite changes.
  </Step>

  <Step title="Apply the exact preview">
    Apply must present the fresh hash and a reason. Lambda verifies the hash again and records the
    result.
  </Step>
</Steps>

The original capture remains unchanged. A stale preview cannot act after the document or its
prerequisites change.

## Choose the owning path

| Condition                                                                 | Owning path                                         |
| ------------------------------------------------------------------------- | --------------------------------------------------- |
| Transient dispatch, exact attempt, parent, file, or delivery interruption | Automatic recovery                                  |
| Corrected CargoWise source or approved prerequisite                       | Corrective recovery                                 |
| Bounded Lambda-owned balance or payload-conversion problem                | [Edward](/stamping/edward), if enabled and eligible |
| Unknown provider outcome or internal inconsistency needing investigation  | Support                                             |

Recovery never creates a second live CFDI while an earlier result may exist.
