Compensation is domain-specific
A product may generate an asset, copy it, attach it to a campaign and notify a reviewer. Failure at the last step does not erase the earlier successful steps. Define which actions can be reversed and which remain completed evidence.
What to do next
- 01
List side effects and boundaries
Write down each business step, its durable evidence and whether it is reversible. Include generation, local copying, campaign attachment and notification as separate operations rather than one opaque success flag.
- 02
Choose recovery per step
Retry a failed attachment using the same asset, remove an incorrect local link if needed, or pause for review. Never submit a new generation merely because a downstream business update failed.
- 03
Record compensation outcomes
Give compensating actions their own identities and state. If compensation itself fails, retain both the original and recovery evidence so an operator can resolve the workflow without guessing which side effects occurred.
A concrete example
Illustrative example: an image completes and is stored, but campaign attachment fails because the campaign was archived. The app retains the image in project history and marks attachment blocked; it does not regenerate or claim the generation charge was undone.
Run the local counterexample
Local runtime fixture, executed November 16, 2026. No AISwapLab request, payment or model generation was made.
Recorded runtime: Python 3.12.10; SQLite 3.49.1. Run the complete script below using that runtime or record the version and changed behavior in your own environment. The script uses synthetic data and temporary resources only.
import sqlite3,tempfile,json
from pathlib import Path
with tempfile.TemporaryDirectory() as d:
c=sqlite3.connect(':memory:');c.execute('CREATE TABLE action(id TEXT)');c.commit()
artifact=Path(d)/'local-artifact.txt'
c.execute('BEGIN');c.execute("INSERT INTO action VALUES('A')")
artifact.write_text('local side effect',encoding='utf-8');c.rollback()
print(json.dumps({'actionRowsAfterRollback':c.execute('SELECT count(*) FROM action').fetchone()[0],
'fileStillExists':artifact.exists(),'fileContents':artifact.read_text(encoding='utf-8')}))
c.close()
Actual output from this run
{
"actionRowsAfterRollback": 0,
"fileStillExists": true,
"fileContents": "local side effect"
}Use the result within its scope
The transaction row disappeared while the file remained. Database atomicity did not include the filesystem write. In a local generation workflow, record the completed side effect and decide its cleanup or reuse separately instead of erasing its evidence when a later business step fails. Keep compensation permissions distinct from the approval that originally authorized creation.
The external resource here is only a temporary file. This is not an AISwapLab call, refund experiment or proof that any remote request was accepted.
Before you call it ready
- Completed assets survive later-step failure.
- Compensation names the local action reversed.
- Recovery attempts have durable evidence.
When to stop or choose another method
Stop treating distributed workflow failure as permission to roll back remote creative history or promise an automatic provider refund.
