Roll back a multi-step unit of work
ratchet_unwind_groupCall this when a multi-step workflow fails partway and the steps that already succeeded must be undone — a booking made but not paid for, a resource created but not configured.
Returns the exact compensations to perform, in the order to perform them, which is the REVERSE of the order they succeeded in. Undoing forwards can strand a step that depended on an earlier one.
Ratchet does NOT perform the compensations. For each step: call ratchet_begin_effect with the step's suggested_idempotency_key and compensates_effect_id, do the real undo, then call ratchet_report_effect. Gating the undo is what stops a retry from refunding twice.
Read unresolved first. If any effect in the group has an unknown outcome, STOP and resolve it before undoing anything around it. Read irreversible too: those steps succeeded and declared no way to undo themselves, so a human has to decide what to do about them. Say so plainly rather than implying the rollback was complete.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| reason | No | Why it is being rolled back. Stored for the operator. | |
| group_key | Yes | The unit of work to roll back, e.g. "booking:trip_8812". |