Undoing Undos

One input stream, three engines. Each reverses a different way and keeps a different shape of the past — so each makes a different promise. Run the story and watch the shapes diverge.

next: A

The story is the lesson: Add AAdd BUndoAdd C. All three land on the same state A C — but ask each one for B back, and only two can answer.

Linear undo

text-editor undo · Undo History composition
Reverses by replay-skip: move the cursor back, recompute as if it never happened.
shape · a line with a cursor
state:
A new action discards the undone tail. One timeline, total by construction — diverge and the alternate future is gone.

Branching undo

emacs undo-tree · Mercurial DAG · Vim :undolist
Reverses by moving up the tree: diverging adds a branch beside the old one — click any node to travel back.
shape · a tree, never collapsed
state:
Diverging destroys nothing. Every state ever visited stays reachable — this is the "keeps all undos forever" one.

Compensating undo

Saga compensation · command-pattern · double-entry ledger
Reverses by a recorded inverse action: undo is itself a new log entry, not a deletion.
shape · an append-only ledger
state:
The log only grows; reversal is posted, never erased. The only model that survives the effect escaping the log.

Why these are three concepts, not one with options

They differ on two independent axes, and the proof of independence is that each lands on a different state shape — a line, a tree, a monotonic ledger. A different shape with a different emergent invariant is a different concept, not a parameter on the same one.

Axis 1 — how reversal happens
Re-derivation — replay the log without the undone step. Requires the effect to live inside the log. linearbranching
Compensation — apply a recorded inverse. The only option once the effect already happened in the world. compensating
Axis 2 — what the past looks like
Single timeline — divergence discards the alternate future. linear
Branching — divergence preserves it as a sibling. branching
Monotonic — nothing is ever removed; reversals are appended. compensating
This is the same boundary as the Saga map. Re-derivation stops at the log's edge — linear and branching only work while the effect is replayable. Compensation is what you reach for once the effect escapes, which is exactly why Saga reverses with a compensating action and not an undo. The amber engine here is the Saga mechanism, shown small.
The verb is the cheap part. "Undo" names nothing until you say the noun — and the noun's shape (a line, a tree, a ledger) is the concept. There is no undo without the undo-noun. That is also why three isn't a fixed count: the two axes generate more cells than these three fill (a compensating log that branches; a re-derived log that never truncates), so what you have is a space, not a list. Three undos — for now.