---
library: "bootstrap"
slug: "Compensate"
name: "Compensate"
ref: "Compensate#4b87"
hash: "sema:Compensate#mh:SHA-256:4b87623f38564fcc95b87d2cbf5df2f5ff41ef27e617ccafd76c7b7896b144e7"
type: "Primitives"
layer: "Infrastructure"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/Compensate"
---

# Compensate

Structured rollback via logged inverses in LIFO order

Infrastructure · Primitives

## Mechanism

Execute inverse actions to undo partial coordination across the [System](https://semahash.org/vocabularies/bootstrap/patterns/System.md) after BREAK. On receiving BREAK, agent retrieves compensation_log (built during forward execution—each action logged its inverse). Execute inverses in REVERSE chronological order (LIFO). For each inverse: attempt execution, if fail retry (inverses must be idempotent), if still fail log and continue or escalate. Report COMPENSATE_RESULT: {completed: [steps undone], failed: [steps that couldn't undo], clean: bool, downstream_confirmed: bool}. Multi-agent coordination: each agent compensates their own scope. BREAK propagates with upstream_agents hint for cross-agent dependencies—downstream agents compensate first, confirm, then upstream proceeds. Compensation cannot introduce NEW coordinated work (only cleanup and notification). Triggered by [Break](https://semahash.org/vocabularies/bootstrap/patterns/Break.md), it reads the [TimeWarpLog](https://semahash.org/vocabularies/bootstrap/patterns/TimeWarpLog.md) in reverse to execute the idempotent inverse of each prior action.

## Invariants

- Every forward action logs its inverse as it executes; an action with no logged inverse is not compensable.
- Inverses execute in reverse chronological order.
- Inverses are idempotent, so a retried compensation does not compound.
- Reports per-inverse outcome, including which inverses failed.

## Preconditions

- Compensation mechanism available
- Detected failure/loss

## Postconditions

- A status report exists naming which inverses succeeded and which did not

## Failure modes

- Inverse wasn't logged (can't compensate what wasn't tracked).
- Inverse isn't truly idempotent (retry corrupts state).
- External state changed between action and compensation (assumption invalid).
- Compensation creates new failure (cascading compensation).
- Time-sensitive compensation (too late to undo, window passed).
- Compensation log lost or corrupted.
- Downstream agent doesn't confirm (blocks upstream compensation).

## Caution

Compensation must not erase the audit trail of what was rolled back — log both the forward action and the compensation.

## Where this came from

—

## Builds on

- [System](https://semahash.org/vocabularies/bootstrap/patterns/System.md) (references)
- [Break](https://semahash.org/vocabularies/bootstrap/patterns/Break.md) (references)
- [TimeWarpLog](https://semahash.org/vocabularies/bootstrap/patterns/TimeWarpLog.md) (references)

## Used by

- [AtomicBid](https://semahash.org/vocabularies/bootstrap/patterns/AtomicBid.md) (composes_with)
- [EjectionSeat](https://semahash.org/vocabularies/bootstrap/patterns/EjectionSeat.md) (references)
- [FrameError](https://semahash.org/vocabularies/bootstrap/patterns/FrameError.md) (references)
- [Gardener](https://semahash.org/vocabularies/bootstrap/patterns/Gardener.md) (references)
- [OptimisticSolver](https://semahash.org/vocabularies/bootstrap/patterns/OptimisticSolver.md) (composes_with)
- [Retry](https://semahash.org/vocabularies/bootstrap/patterns/Retry.md) (references)
- [Rollout](https://semahash.org/vocabularies/bootstrap/patterns/Rollout.md) (composes_with)

## Related

- [Retry](https://semahash.org/vocabularies/bootstrap/patterns/Retry.md)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: Compensate#4b87
- Hash: sema:Compensate#mh:SHA-256:4b87623f38564fcc95b87d2cbf5df2f5ff41ef27e617ccafd76c7b7896b144e7

## Links

- Page: https://semahash.org/vocabularies/bootstrap/patterns/Compensate
- JSON: https://semahash.org/vocabularies/bootstrap/patterns/Compensate.json
- Library: https://semahash.org/vocabularies/bootstrap
- Library index: https://semahash.org/vocabularies/bootstrap/index.json
