Tutorial: Record Hand-Back State Before a Human Resumes
Imagine a batch of refunds paused after a network interruption. One refund has a provider receipt, one was never attempted, and a third request was sent just before the connection closed. A βResumeβ button that treats th
Imagine a batch of refunds paused after a network interruption. One refund has a provider receipt, one was never attempted, and a third request was sent just before the connection closed. A βResumeβ button that treats the last two cases alike can issue a second refund.
Record what the reviewer can establish
| Effect | Evidence at pause | What the reviewer can do |
|---|---|---|
| A | Receipt ties the providerβs operation to this order and amount | Mark complete and exclude it from replay |
| B | No dispatch occurred in the durable workflow | Offer it for execution after rechecking authorization |
| C | Dispatch intent exists, but there is no definitive outcome | Reconcile through the provider before offering replay |
Store a stable run ID, the step that stopped, who or what stopped it, and an entry for every intended effect. Each entry needs its target, operation ID and observed state. Keep receipt references separate from credentials and customer details. An empty result field cannot tell you whether dispatch occurred. If a job can die between sending the request and saving a receipt, explicitly represent that case as unknown.
Make Resume a decision
Start by validating required fields and allowed state names. JSON Schema can reject a missing field if it is listed as required. A syntactically valid string saying βpermission checkedβ is still only a string. On the server, check current authorization, the target version and any deadline. If an operation ID occurs in both the committed list and the unattempted list, show the conflict and deny this resume. A confirmed provider-side idempotency guarantee can change which actions are safe to repeat; check its scope and retention period.
The reviewer should see the held effect and a concrete reason even if half the batch can proceed. Record the version of the hand-back record used to authorize the transition. A second tab using an older version should have to reload. Exercise the three cases in the table, a grant revoked during the pause, and simultaneous resumes. The observable result to check is the number of effects at the receiver, not just the color of the button. JSON Schema object validation.
This article was created with AI assistance.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.