FAILURE MAP
← Case archive

FA-8031 / Undo and history / Open access

Undo stack transitions: An unchanged edit creates an undo step and destroys redo · case 01

An unchanged edit creates an undo step and destroys redo.

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

ROOT CAUSE

The noop operation uses `` where the contract requires ` and value != present`.

VERIFIED REPAIR

Implement the noop operation as ` and value != present`.

Unsuccessful approach: Accepting only unchanged edits discards actual edits.

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': 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'], 'b', []][['a'], 'b', ['c']]Failed
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 / a0c1c7a9d66fd5469da31fc64fb352edc8364f6b63c1195c3accf549a127baa9

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[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'], 'b', []][['a'], 'b', ['c']]Failed
branch[['a'], 'b', ['c']][['a', 'b'], 'x', []]Failed
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, []][[0, 1], 2, []]Failed
repeat empty redo[[], 'a', []][[], 'a', []]Passed

SHA-256 / 21252877d192884789cf54254bf00a9ecd88ebcb8dd97c7e3e08c6d0e15224f6

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.482487+00:00.

Case digest / 050f4cb647c4f587866f3c7e547c2f50d8f2f4a0913f943233edfdcd54f9780a