FAILURE MAP
← Case archive

FA-8051 / Undo and history / Open access

Undo stack transitions: Redo omits the state needed for a subsequent undo · case 01

Redo omits the state needed for a subsequent undo.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The redo operation uses `(past, future[0], future[1:])` where the contract requires `(past + [present], future[0], future[1:])`.

VERIFIED REPAIR

Implement the redo operation as `(past + [present], future[0], future[1:])`.

Unsuccessful approach: Taking the newest future skips intermediate redo states.

Case contract

Distinct edits push the old present and clear redo; undo and redo transfer one state while preserving order; no-op edits and unavailable traversal preserve history.

Why this case matters

A deterministic model of undo stack transitions; this isolates one interface invariant without requiring a browser.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(past, present, future, event, value):
    past, future = list(past), list(future)
    if event == 'edit' and value != present: return (past + [present], value, [])
    if event == 'undo' and past: return (past[:-1], past[-1], [present] + future)
    if event == 'redo' and future: return (past, future[0], future[1:])
    return (past, present, future)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop retains redo', solve(['a'], 'b', ['c'], 'edit', 'b'), (['a'], 'b', ['c']))
check('branch', solve(['a'], 'b', ['c'], 'edit', 'x'), (['a', 'b'], 'x', []))
check('undo', solve(['a','b'], 'c', ['d'], 'undo', None), (['a'], 'b', ['c', 'd']))
check('redo', solve(['a'], 'b', ['c','d'], 'redo', None), (['a', 'b'], 'c', ['d']))
check('empty undo', solve([], 'a', [], 'undo', None), ([], 'a', []))
check('empty redo', solve([], 'a', [], 'redo', None), ([], 'a', []))
check('parameterized history length', solve(list(range(N)), N, [], 'edit', N+1), (list(range(N+1)), N+1, []))
for repetition in range(N):
    check('repeat empty redo', solve([], 'a', [], 'redo', None), ([], 'a', []))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
noop retains redo[['a'], 'b', ['c']][['a'], 'b', ['c']]Passed
branch[['a', 'b'], 'x', []][['a', 'b'], 'x', []]Passed
undo[['a'], 'b', ['c', 'd']][['a'], 'b', ['c', 'd']]Passed
redo[['a'], 'c', ['d']][['a', 'b'], 'c', ['d']]Failed
empty undo[[], 'a', []][[], 'a', []]Passed
empty redo[[], 'a', []][[], 'a', []]Passed
parameterized history length[[0, 1], 2, []][[0, 1], 2, []]Passed
repeat empty redo[[], 'a', []][[], 'a', []]Passed

SHA-256 / 54349d197a841a21453f30c7ca03315006740a1732ff727a3007852955f2fa7e

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(past, present, future, event, value):
    past, future = list(past), list(future)
    if event == 'edit' and value != present: return (past + [present], value, [])
    if event == 'undo' and past: return (past[:-1], past[-1], [present] + future)
    if event == 'redo' and future: return (past + [present], future[-1], future[:-1])
    return (past, present, future)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop retains redo', solve(['a'], 'b', ['c'], 'edit', 'b'), (['a'], 'b', ['c']))
check('branch', solve(['a'], 'b', ['c'], 'edit', 'x'), (['a', 'b'], 'x', []))
check('undo', solve(['a','b'], 'c', ['d'], 'undo', None), (['a'], 'b', ['c', 'd']))
check('redo', solve(['a'], 'b', ['c','d'], 'redo', None), (['a', 'b'], 'c', ['d']))
check('empty undo', solve([], 'a', [], 'undo', None), ([], 'a', []))
check('empty redo', solve([], 'a', [], 'redo', None), ([], 'a', []))
check('parameterized history length', solve(list(range(N)), N, [], 'edit', N+1), (list(range(N+1)), N+1, []))
for repetition in range(N):
    check('repeat empty redo', solve([], 'a', [], 'redo', None), ([], 'a', []))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
noop retains redo[['a'], 'b', ['c']][['a'], 'b', ['c']]Passed
branch[['a', 'b'], 'x', []][['a', 'b'], 'x', []]Passed
undo[['a'], 'b', ['c', 'd']][['a'], 'b', ['c', 'd']]Passed
redo[['a', 'b'], 'd', ['c']][['a', 'b'], 'c', ['d']]Failed
empty undo[[], 'a', []][[], 'a', []]Passed
empty redo[[], 'a', []][[], 'a', []]Passed
parameterized history length[[0, 1], 2, []][[0, 1], 2, []]Passed
repeat empty redo[[], 'a', []][[], 'a', []]Passed

SHA-256 / ae74640fdada14d1d526a28ccdf166cc7015cafbc1d0f3481b159861615f09e7

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(past, present, future, event, value):
    past, future = list(past), list(future)
    if event == 'edit' and value != present: return (past + [present], value, [])
    if event == 'undo' and past: return (past[:-1], past[-1], [present] + future)
    if event == 'redo' and future: return (past + [present], future[0], future[1:])
    return (past, present, future)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop retains redo', solve(['a'], 'b', ['c'], 'edit', 'b'), (['a'], 'b', ['c']))
check('branch', solve(['a'], 'b', ['c'], 'edit', 'x'), (['a', 'b'], 'x', []))
check('undo', solve(['a','b'], 'c', ['d'], 'undo', None), (['a'], 'b', ['c', 'd']))
check('redo', solve(['a'], 'b', ['c','d'], 'redo', None), (['a', 'b'], 'c', ['d']))
check('empty undo', solve([], 'a', [], 'undo', None), ([], 'a', []))
check('empty redo', solve([], 'a', [], 'redo', None), ([], 'a', []))
check('parameterized history length', solve(list(range(N)), N, [], 'edit', N+1), (list(range(N+1)), N+1, []))
for repetition in range(N):
    check('repeat empty redo', solve([], 'a', [], 'redo', None), ([], 'a', []))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
noop retains redo[['a'], 'b', ['c']][['a'], 'b', ['c']]Passed
branch[['a', 'b'], 'x', []][['a', 'b'], 'x', []]Passed
undo[['a'], 'b', ['c', 'd']][['a'], 'b', ['c', 'd']]Passed
redo[['a', 'b'], 'c', ['d']][['a', 'b'], 'c', ['d']]Passed
empty undo[[], 'a', []][[], 'a', []]Passed
empty redo[[], 'a', []][[], 'a', []]Passed
parameterized history length[[0, 1], 2, []][[0, 1], 2, []]Passed
repeat empty redo[[], 'a', []][[], 'a', []]Passed

SHA-256 / dae50cc92d1d321aec589e97f3f328c59a42305b416a5d870a20baf5d3824433

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:38:17.739177+00:00.

Case digest / 478d1931297f6e65aa127b65b4f62b753f50c21457b8384e402650c1fdeeaccb