FA-46211 / Bounded deques / Open access
Edit history records the new deque rather than the old snapshot · case 01
Edit history records the new deque rather than the old snapshot.
ROOT CAUSE
Edit history records the new deque rather than the old snapshot.
VERIFIED REPAIR
Restore the documented snapshot content invariant in undo-snapshots.
Unsuccessful approach: The partial repair still applies the incorrect transition to an admitted boundary or multi-element case.
Case contract
Bounded deque edits store the complete prior logical snapshot. Undo and redo transfer current snapshots between independent history stacks. A new edit invalidates redo history.
Why this case matters
Controlled bounded deque implementation model with explicit storage and lifecycle observations.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,past,future,command,value,cap=x
if command=='edit':
new=(a+[value])[-cap:] if cap else []
return [new,past+[new],[]]
if command=='undo' and past:
return [past[-1],past[:-1],future+[a]]
if command=='redo' and future:
return [future[-1],past+[a],future[:-1]]
return [a,past,future]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('edit invalidates redo', solve([[N],[[N-1]],[[N+1]],"edit",N+2,3]), {1: [[1, 3], [[0], [1]], []], 2: [[2, 4], [[1], [2]], []], 3: [[3, 5], [[2], [3]], []], 4: [[4, 6], [[3], [4]], []], 5: [[5, 7], [[4], [5]], []]}[N])
check('undo latest', solve([[N+2],[[N],[N+1]],[],"undo",0,3]), {1: [[2], [[1]], [[3]]], 2: [[3], [[2]], [[4]]], 3: [[4], [[3]], [[5]]], 4: [[5], [[4]], [[6]]], 5: [[6], [[5]], [[7]]]}[N])
check('redo latest', solve([[N],[],[[N+2],[N+1]],"redo",0,3]), {1: [[2], [[1]], [[3]]], 2: [[3], [[2]], [[4]]], 3: [[4], [[3]], [[5]]], 4: [[5], [[4]], [[6]]], 5: [[6], [[5]], [[7]]]}[N])
check('empty undo', solve([[N],[],[],"undo",0,3]), {1: [[1], [], []], 2: [[2], [], []], 3: [[3], [], []], 4: [[4], [], []], 5: [[5], [], []]}[N])
check('overflow snapshot', solve([[N,N+1],[],[],"edit",N+2,2]), {1: [[2, 3], [[1, 2]], []], 2: [[3, 4], [[2, 3]], []], 3: [[4, 5], [[3, 4]], []], 4: [[5, 6], [[4, 5]], []], 5: [[6, 7], [[5, 6]], []]}[N])
check('zero bound edit', solve([[],[[N]],[],"edit",N+1,0]), {1: [[], [[1], []], []], 2: [[], [[2], []], []], 3: [[], [[3], []], []], 4: [[], [[4], []], []], 5: [[], [[5], []], []]}[N])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| edit invalidates redo | [[1, 3], [[0], [1, 3]], []] | [[1, 3], [[0], [1]], []] | Failed |
| undo latest | [[2], [[1]], [[3]]] | [[2], [[1]], [[3]]] | Passed |
| redo latest | [[2], [[1]], [[3]]] | [[2], [[1]], [[3]]] | Passed |
| empty undo | [[1], [], []] | [[1], [], []] | Passed |
| overflow snapshot | [[2, 3], [[2, 3]], []] | [[2, 3], [[1, 2]], []] | Failed |
| zero bound edit | [[], [[1], []], []] | [[], [[1], []], []] | Passed |
SHA-256 / cb4afbca98bd764fa3bc4ba8693b68b3dff3339cdf700c211ad514d74d9db404
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,past,future,command,value,cap=x
if command=='edit':
new=(a+[value])[-cap:] if cap else []
return [new,past+[a if not a else new],[]]
if command=='undo' and past:
return [past[-1],past[:-1],future+[a]]
if command=='redo' and future:
return [future[-1],past+[a],future[:-1]]
return [a,past,future]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('edit invalidates redo', solve([[N],[[N-1]],[[N+1]],"edit",N+2,3]), {1: [[1, 3], [[0], [1]], []], 2: [[2, 4], [[1], [2]], []], 3: [[3, 5], [[2], [3]], []], 4: [[4, 6], [[3], [4]], []], 5: [[5, 7], [[4], [5]], []]}[N])
check('undo latest', solve([[N+2],[[N],[N+1]],[],"undo",0,3]), {1: [[2], [[1]], [[3]]], 2: [[3], [[2]], [[4]]], 3: [[4], [[3]], [[5]]], 4: [[5], [[4]], [[6]]], 5: [[6], [[5]], [[7]]]}[N])
check('redo latest', solve([[N],[],[[N+2],[N+1]],"redo",0,3]), {1: [[2], [[1]], [[3]]], 2: [[3], [[2]], [[4]]], 3: [[4], [[3]], [[5]]], 4: [[5], [[4]], [[6]]], 5: [[6], [[5]], [[7]]]}[N])
check('empty undo', solve([[N],[],[],"undo",0,3]), {1: [[1], [], []], 2: [[2], [], []], 3: [[3], [], []], 4: [[4], [], []], 5: [[5], [], []]}[N])
check('overflow snapshot', solve([[N,N+1],[],[],"edit",N+2,2]), {1: [[2, 3], [[1, 2]], []], 2: [[3, 4], [[2, 3]], []], 3: [[4, 5], [[3, 4]], []], 4: [[5, 6], [[4, 5]], []], 5: [[6, 7], [[5, 6]], []]}[N])
check('zero bound edit', solve([[],[[N]],[],"edit",N+1,0]), {1: [[], [[1], []], []], 2: [[], [[2], []], []], 3: [[], [[3], []], []], 4: [[], [[4], []], []], 5: [[], [[5], []], []]}[N])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| edit invalidates redo | [[1, 3], [[0], [1, 3]], []] | [[1, 3], [[0], [1]], []] | Failed |
| undo latest | [[2], [[1]], [[3]]] | [[2], [[1]], [[3]]] | Passed |
| redo latest | [[2], [[1]], [[3]]] | [[2], [[1]], [[3]]] | Passed |
| empty undo | [[1], [], []] | [[1], [], []] | Passed |
| overflow snapshot | [[2, 3], [[2, 3]], []] | [[2, 3], [[1, 2]], []] | Failed |
| zero bound edit | [[], [[1], []], []] | [[], [[1], []], []] | Passed |
SHA-256 / c3c4a2437de379c438035793f754d7da010bdf005878a8856514eed1b9ab765f
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,past,future,command,value,cap=x
if command=='edit':
new=(a+[value])[-cap:] if cap else []
return [new,past+[a],[]]
if command=='undo' and past:
return [past[-1],past[:-1],future+[a]]
if command=='redo' and future:
return [future[-1],past+[a],future[:-1]]
return [a,past,future]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('edit invalidates redo', solve([[N],[[N-1]],[[N+1]],"edit",N+2,3]), {1: [[1, 3], [[0], [1]], []], 2: [[2, 4], [[1], [2]], []], 3: [[3, 5], [[2], [3]], []], 4: [[4, 6], [[3], [4]], []], 5: [[5, 7], [[4], [5]], []]}[N])
check('undo latest', solve([[N+2],[[N],[N+1]],[],"undo",0,3]), {1: [[2], [[1]], [[3]]], 2: [[3], [[2]], [[4]]], 3: [[4], [[3]], [[5]]], 4: [[5], [[4]], [[6]]], 5: [[6], [[5]], [[7]]]}[N])
check('redo latest', solve([[N],[],[[N+2],[N+1]],"redo",0,3]), {1: [[2], [[1]], [[3]]], 2: [[3], [[2]], [[4]]], 3: [[4], [[3]], [[5]]], 4: [[5], [[4]], [[6]]], 5: [[6], [[5]], [[7]]]}[N])
check('empty undo', solve([[N],[],[],"undo",0,3]), {1: [[1], [], []], 2: [[2], [], []], 3: [[3], [], []], 4: [[4], [], []], 5: [[5], [], []]}[N])
check('overflow snapshot', solve([[N,N+1],[],[],"edit",N+2,2]), {1: [[2, 3], [[1, 2]], []], 2: [[3, 4], [[2, 3]], []], 3: [[4, 5], [[3, 4]], []], 4: [[5, 6], [[4, 5]], []], 5: [[6, 7], [[5, 6]], []]}[N])
check('zero bound edit', solve([[],[[N]],[],"edit",N+1,0]), {1: [[], [[1], []], []], 2: [[], [[2], []], []], 3: [[], [[3], []], []], 4: [[], [[4], []], []], 5: [[], [[5], []], []]}[N])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| edit invalidates redo | [[1, 3], [[0], [1]], []] | [[1, 3], [[0], [1]], []] | Passed |
| undo latest | [[2], [[1]], [[3]]] | [[2], [[1]], [[3]]] | Passed |
| redo latest | [[2], [[1]], [[3]]] | [[2], [[1]], [[3]]] | Passed |
| empty undo | [[1], [], []] | [[1], [], []] | Passed |
| overflow snapshot | [[2, 3], [[1, 2]], []] | [[2, 3], [[1, 2]], []] | Passed |
| zero bound edit | [[], [[1], []], []] | [[], [[1], []], []] | Passed |
SHA-256 / da55aae5a8afface8a7c50ef27009098fbb82025e99083b705a070db635cce46
Verification & scope
Offline finite deterministic model; no claim of production implementation or concurrent memory-model conformance. 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:44:29.890639+00:00.
Case digest / 8674090d5d0bc516385a9ab619a827b858045d3860cc2f2cb83cae64fcbdd603