One refund goes out. Then the same incident triggers again after a service restart, or arrives four times simultaneously, and your remediation logic turns out to be not idempotent. The customer gets a second refund. Accounting gets a reconciliation problem.
This article walks through a duplicate-charge remediation workflow that routes large refunds through a manager approval step and prevents the same incident from issuing a second refund. All results come from a historical isolated twin run measured on 2026-10-19 using declared app version acme-ops-duplicate-charge-remediation-1.0.0-639dac1. No new execution has been run as of 2026-11-05. The pinned reproduction SHA is 48d4ded. The historical declared app version identifies what the runtime declared at run time; it is not an attestation that this SHA was the exact code executed in that session.
Can I run this myself?
Yes. You need a FetchSandbox account with managed-relay access, Node 22, and the acme-ops repo checked out at the pinned SHA. The runner injects temporary twin credentials privately per session. No live Stripe, Gmail, or HubSpot keys are needed for the isolated rehearsal.
What the workflow treats as a duplicate
A confirmed duplicate is two charges with the same amount, currency, and purchase reference arriving within a 15-minute window. Charges with distinct purchase references, or payments outside the match window, are not classified as duplicates by this workflow. Charges with a linked dispute are excluded entirely and no refund notice is drafted. These thresholds are defined in the workflow source and are specific to this acme-ops example, not universal FetchSandbox policy.
Three things the historical run checked
A refund above the approval threshold waited for an approver.
The large_refund_parked check confirmed that a confirmed duplicate above 50,000 minor currency units triggered a Slack digest to the finance channel and paused. No refund issued until an authorized approver responded. Two upper bounds also passed: the ceiling_halts check confirmed that above 100 refunds or 2,500,000 minor units total, the workflow halts the incident entirely. The cumulative auto-approval threshold is 200,000 minor units.
Rerunning the same incident after a refund had already gone out issued nothing.
The rerun_refunds_nothing check confirmed that a subsequent trigger for an already-refunded incident ID produced no additional refund. The idempotency check reads current refund state before acting.
Four simultaneous triggers for the same incident still resulted in one refund.
The concurrent_start check confirmed the workflow handles concurrent delivery without multiplying the refund. Two related cases also passed: approve_by_stranger_refused confirmed that an unauthorized user cannot approve a pending refund, and an independent full refund issued during the approval window prevents a second refund from going out.
The run also replayed an application restart mid-approval: the application restarted while a large refund was waiting for a decision, and the refund issued exactly once when approval arrived. This is a check on application state recovery behavior. The verifier session is not durable across verifier restarts; that is a separate limitation of the test infrastructure and is distinct from this application behavior check.
Public run summary for the duplicate-charge-remediation workflow, observed 2026-10-19 and reviewed from the live historical receipt 2026-11-05. The page shows all 23 checks passed and includes a scope warning. The full check list rows and declared version string are not visible in this screenshot.
HTTP 200 is not refund completion
Here is the recorded request and response excerpt from the twin session for the large-refund approval case. These are synthetic fixture IDs seeded by the runner. Do not send them to a production endpoint.
Request (recorded 2026-10-19T14:52:31 UTC):
{
"action": "start",
"runId": "large-refund-parked-vr_32045f5c19c54d8fa57cc7504523a437",
"input": {
"incidentId": "INC-large-refund-parked",
"description": "Payment retry job ran twice and charged customers a second time.",
"customers": [
"[email protected]"
],
"financeChannel": "C0BILLING01",
"approvers": [
"U_CONTROLLER"
]
},
"requestedBy": {
"userId": "U_FETCHSANDBOX"
},
"labels": {
"fs_run": "vr_32045f5c19c54d8fa57cc7504523a437",
"fs_case": "large_refund_parked"
}
}
Response excerpt:
{
"runId": "large-refund-parked-vr_32045f5c19c54d8fa57cc7504523a437",
"workflow": "duplicate-charge-remediation",
"phase": "AWAITING_APPROVAL",
"closed": false,
"outcome": "ok"
}
The HTTP 200 on the start action means the workflow accepted the request and started. phase: AWAITING_APPROVAL with closed: false means the workflow is waiting for an authorized approver. For this specific sample, one refund is pending approval with zero refund attempts issued so far. AWAITING_APPROVAL by itself does not establish that zero side effects have occurred across all channels: in this run, Asana and Slack actions had already applied before this response, while the Gmail refund notice remained pending the approval decision. If you instrument a workflow like this, a 200 at step one is not a signal the refund is done.
Approval gate detail captured 2026-11-05 from the public historical run summary. The request and response show AWAITING_APPROVAL phase with closed: false. The pending refund action detail appears below the fold and is not visible in this screenshot.
Running this yourself
git clone https://github.com/fetchsandbox/playground.git
cd playground
git checkout 48d4ded9832981e441fad4e83ed3daf838086ba4
cd acme-ops
npm ci
npm run bundle
node verify/relay-proof.mjs duplicate-charge-remediation
A FetchSandbox account with managed-relay access is required before running. The managed relay forwards verifier traffic through a cloud relay into your locally running application; FetchSandbox provides the relay, not application hosting. The runner injects temporary twin URLs and credentials privately per session. See the workflow guide for authentication prerequisites.
No live Stripe, Gmail, HubSpot, Asana, or Slack keys are needed for this isolated rehearsal. It is not anonymous; FetchSandbox authentication is required. Real calls against live providers require your own vendor credentials and separate qualification. These setup commands reference the pinned SHA and have not been rerun as of this article date.
Provider behavior in the twin run
Stripe charges and refunds go to an isolated twin. Gmail actions produce drafts only; no email is delivered to any inbox. Slack messages post to a twin digest channel. Asana records the incident. HubSpot provides customer context. Approval in the twin run uses controlled runtime identities, not live Slack user authentication. Workflow state is app-reported; storage is not independently attested beyond what the runtime declares.
What this run does not establish
The historical run measured 23 checks against the declared HTTP contract under isolated twin conditions. It does not establish production readiness, native provider parity, inbox delivery, behavior under live Stripe rate limits or dispute states, or compatibility with applications other than acme-ops. The public run summary includes recorded redacted request and response traces. Full proof access is owner-only.
To inspect the pinned workflow and rehearse its approval and retry checks using the authenticated runner, connect FetchSandbox MCP and ask the agent to walk through the duplicate-charge-remediation scenario.
Approval arrives after an independent manual refund
Approval gives the workflow permission to try a refund. It doesn't lock the payment. While the run is waiting for approval, someone can still refund the charge directly.
The manual_refund_race scenario in the pinned contract covers this case:
- Start the seeded large duplicate-charge incident. Expected: the workflow waits for approval.
- An independent
external_operatorsendsPOST /v1/refundsfor the seeded charge. Expected: the refund succeeds. - The configured approver approves. Expected: the workflow rechecks the current PaymentIntent and refunded amounts. It finds less refundable balance than planned and throws
FatalError. It also refuses the Gmail draft because the workflow refund wasn't applied. - Replay the approval without repeating the external refund. Expected: still no workflow refund.
Any failure won't count as a pass. The contract requires an app outcome of partial, with the workflow refund and the Gmail draft both failing fatally. Provider state must also show exactly one refund of the expected amount, and the operator has to be the one who created it. A passing scenario verdict can include failed actions.
When we reread the public receipt on Nov 12, this scenario showed Stripe refunds Expected 1, Actual 1, Passed. It also recorded the external POST /v1/refunds returning 200 succeeded, plus the repeated app invocations. This evidence comes from isolated twins, measured Oct 19 against declared version 639dac1. It wasn't a live Stripe run, and we ran nothing new. It also doesn't prove that pinned commit 48d4ded is what ran then.
You don't need live provider keys, but you do need a FetchSandbox account and managed-relay access. Connect your agent through the documented authenticated relay to rehearse stale approval against your own agreed contract.
Refund approval across application restarts: wait, approve, replay
This covers one narrow case. A refund is parked waiting for manager approval while the application runtime restarts. The manager approves after it comes back up. Then the same saved run is replayed after a second restart.
We read the existing historical receipt on November 17. No new test was run. It was recorded October 19, 2026, with declared app version acme-ops-duplicate-charge-remediation-1.0.0-639dac1. The raw stored status for restart_while_parked is "held", and the receipt displays it as Passed: expected exactly 1, found 1, stable under 2 repeats. The stored probe plan only describes planned actions, so we went through the recorded execution traces instead.
| Step | Expected | Actual |
|---|---|---|
| Start, wait for approval | No refund attempt |
AWAITING_APPROVAL, refund action pending_approval, attempts 0 |
| First restart, then approve | Saved run continues | Recorded runtime identity changed; DONE, refund action applied, attempts 1 |
| Replay start, second restart, replay approval | No new refund action | Runtime identity changed again; DONE, same refund ref, attempts 1 |
What this tested: the app-reported refund action kept its identity and attempt count through two application runtime restarts and a replay. The approval wait did not drop the run, and the replay did not add a second refund action.
The restarts were of the application runtime, not the n8n Cloud host or the whole verifier. The older verifier session was not durable across verifier restarts, which is a separate issue. The public check's provider_counts is empty, so this does not independently count Stripe refunds or attest database durability. It is also not a crash after the provider accepted the refund, which is a different failure boundary. All providers are isolated twins and Gmail only makes a draft, so no live charges, email delivery or production certification.
The pinned reproduction contract defines start, restart, then authorized decide, expecting DONE with one applied refund action and attempts 1. As with the declared version, the public SHA shows what to rerun, not what ran in October.
To try it on your own workflow, connect your development agent through FetchSandbox MCP. Ask it to probe waiting-approval, restart and replay on the refund workflow you agreed on. Keep the actual requests, runtime identities, refund action identity and attempt count. You need a FetchSandbox account with authenticated managed-relay access, but no live vendor keys for this twin rehearsal. This result does not carry over to your workflow automatically.
Which missing dependency should stop an automated refund?
Two dependencies failed in this acme-ops workflow, and they shouldn't get the same treatment. These rules are specific to this example. They aren't Stripe or FetchSandbox defaults.
- If we can't tell whether the payment is disputed, no refund goes out.
- If CRM enrichment is missing but the refund is otherwise verified as eligible, the refund still goes out.
The goal is to avoid paying out when the dispute status is unknown, without letting optional CRM data become a single point of failure.
The evidence comes from a historical window: October 19, 2026, 14:52:23 to 14:54:28 UTC, declared app version acme-ops-duplicate-charge-remediation-1.0.0-639dac1. I reread it on November 19, 2026. Nothing was run again. The public summary is archived but still shows the original scoped results and redacted execution traces. Both scenarios show Passed.
| Dispute check down | CRM rate limited | |
|---|---|---|
| Expected rule | Block the refund | Refund goes ahead without CRM data |
| Actual HTTP response |
GET /v1/disputes returned 503 |
POST /crm/v3/objects/contacts/search returned 429 |
| Agents | Payment scan ok, dispute check failed | Charge scan and dispute check ok, account context failed |
| Saved app state | phase DONE, outcome partial, output mode blocked, refunds 0, reason "dispute status unknown" | phase DONE, outcome partial, output mode refund, refunds 1, refundMinor 4900 |
| Applied actions | Asana remediation record, Slack digest. No stripe.refund_duplicate or gmail.draft_notice action exists |
stripe.refund_duplicate (attempts 1, status succeeded), gmail.draft_notice (attempts 1, sent: false), Asana, Slack |
| Replayed start | Stayed the same saved blocked run | Kept the same action references and attempts |
Both runs say outcome partial. That doesn't mean the rule failed. It means a dependency failed and the app degraded the way the rules say it should. Passed is about that refusal or degradation behavior, not about everything going green. Planned actions alone wouldn't prove anything, so the table only lists applied ones.
Some limits apply. The provider_counts table is empty in both checks, so "refunds 0" and the single refund action are app-reported state, not an independent count of real Stripe refunds. The Gmail action is a draft in a twin mailbox, and no email was delivered. All of this ran against isolated twins, not live vendors, and storage isn't independently attested. Full proof is owner-only.
Receipts: dispute scenario and CRM scenario.
Try it yourself. Start with the pinned workflow and setup guide. You need Node 22, a FetchSandbox account and the authenticated managed relay (MCP setup). The twin rehearsal doesn't need live provider keys. Ask your connected agent to rehearse dispute_outage_fails_closed and hubspot_rate_limited against the two rules above. Then look at the actual HTTP responses and the final saved action state. Don't stop at the Passed label.
Pin 48d4ded is a source revision you can reproduce from today. It doesn't prove that the October 19 run, declared as 639dac1, executed that revision. The checks are in the pinned contract, and the first-party guide covers the wider workflow.


Top comments (0)