Compensation is a durable business action
What This Concept Is
Compensation addresses the business consequence of an already committed step. It is another action that can fail, incur costs or need human intervention. A durable compensation intent and a confirmed compensation effect are separate facts.
Why It Matters Here
Semester 06 established state/outbox atomicity. Here that mechanism serves a longer workflow: a restart must not forget that a refund is owed, and retries must not refund repeatedly. Reuse the earlier mechanism while specifying the new business state and operation identity.
Concrete Example
The model's due tuple contains payment after a late successful charge. Polling the tuple three times does not authorize three refunds. Use a stable compensation identity derived from the workflow and step, persist the intent with the state transition, and let the participant deduplicate requests. Only an authoritative success confirmation removes the obligation.
If the refund endpoint is unavailable, the obligation remains open. If the provider reports a conflicting definitive outcome for the same operation, preserve the evidence and investigate. The reference rejects the contradiction without changing state; it does not decide which external report is true.
Common Confusion / Misconception
A refund does not erase a charge, fees, notifications or audit history. An outbox guarantees neither provider availability nor eventual success. A participant that does not support safe retries requires a lookup/reconciliation or manual policy rather than blind repeated effects.
How To Use It
Record forward and compensation operation IDs, owners, irreversible steps, retry limits and escalation rules. Persist state and outgoing intent atomically. Crash before and after persistence, dispatch and confirmation. Keep an unresolved obligation visible until authoritative closure, and monitor age as well as count.
Check Yourself
Which transaction contains compensation intent? What happens if the refund succeeds but its reply is lost? What extra mechanism is missing from the in-memory model? Who can resolve a contradictory report?
Mini Drill or Application
Use the original durable outbox/consumer implementation to deliver one compensation twice around a restart. Prove one semantic effect and retained audit history. Make the compensation fail and demonstrate that the workflow remains incomplete with an owner and escalation route.
Read This Only If Stuck
Microservices Patterns — saga implementation and outbox. Reuse Semester 06 transaction exercises; the archive intentionally does not reimplement transport or persistence.