FAILURE MAP
← Case archive

FA-46321 / Bounded deques / Open access

Bookmark reorder writes the forward permutation as its inverse · case 01

Bookmark reorder writes the forward permutation as its inverse.

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

ROOT CAUSE

Bookmark reorder writes the forward permutation as its inverse.

VERIFIED REPAIR

Restore the documented inverse side invariant in permutation-reorder.

Unsuccessful approach: The partial repair still applies the incorrect transition to an admitted boundary or multi-element case.

Case contract

Reorder a bounded deque by a complete permutation of old indices, then return the inverse mapping used by bookmarks. Invalid duplicate, missing or out-of-range indices reject without changing the deque.

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,order=x
    valid=sorted(order)==list(range(len(a)))
    if not valid:return [a,False,[]]
    result=[a[i] for i in order]
    inverse=[0]*len(a)
    for new,old in enumerate(order):inverse[new]=old
    return [result,True,inverse]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[N,N+1,N+2],[2,0,1]]), {1: [[3, 1, 2], True, [1, 2, 0]], 2: [[4, 2, 3], True, [1, 2, 0]], 3: [[5, 3, 4], True, [1, 2, 0]], 4: [[6, 4, 5], True, [1, 2, 0]], 5: [[7, 5, 6], True, [1, 2, 0]]}[N])
check('1', solve([[N,N+1],[0,0]]), {1: [[1, 2], False, []], 2: [[2, 3], False, []], 3: [[3, 4], False, []], 4: [[4, 5], False, []], 5: [[5, 6], False, []]}[N])
check('2', solve([[N,N+1],[0]]), {1: [[1, 2], False, []], 2: [[2, 3], False, []], 3: [[3, 4], False, []], 4: [[4, 5], False, []], 5: [[5, 6], False, []]}[N])
check('3', solve([[N],[0]]), {1: [[1], True, [0]], 2: [[2], True, [0]], 3: [[3], True, [0]], 4: [[4], True, [0]], 5: [[5], True, [0]]}[N])
check('4', solve([[],[]]), {1: [[], True, []], 2: [[], True, []], 3: [[], True, []], 4: [[], True, []], 5: [[], True, []]}[N])
check('5', solve([[N,N+1,N+2,N+3],[1,3,0,2]]), {1: [[2, 4, 1, 3], True, [2, 0, 3, 1]], 2: [[3, 5, 2, 4], True, [2, 0, 3, 1]], 3: [[4, 6, 3, 5], True, [2, 0, 3, 1]], 4: [[5, 7, 4, 6], True, [2, 0, 3, 1]], 5: [[6, 8, 5, 7], True, [2, 0, 3, 1]]}[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 fixtureActualExpectedOutcome
0[[3, 1, 2], True, [2, 0, 1]][[3, 1, 2], True, [1, 2, 0]]Failed
1[[1, 2], False, []][[1, 2], False, []]Passed
2[[1, 2], False, []][[1, 2], False, []]Passed
3[[1], True, [0]][[1], True, [0]]Passed
4[[], True, []][[], True, []]Passed
5[[2, 4, 1, 3], True, [1, 3, 0, 2]][[2, 4, 1, 3], True, [2, 0, 3, 1]]Failed

SHA-256 / 0617706adb0461cd9a7700bdb3f5d538fa9c03f1ecbaf982d4acb07f0c653c32

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    a,order=x
    valid=sorted(order)==list(range(len(a)))
    if not valid:return [a,False,[]]
    result=[a[i] for i in order]
    inverse=[0]*len(a)
    for new,old in enumerate(order):inverse[old]=new if new==old else old
    return [result,True,inverse]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[N,N+1,N+2],[2,0,1]]), {1: [[3, 1, 2], True, [1, 2, 0]], 2: [[4, 2, 3], True, [1, 2, 0]], 3: [[5, 3, 4], True, [1, 2, 0]], 4: [[6, 4, 5], True, [1, 2, 0]], 5: [[7, 5, 6], True, [1, 2, 0]]}[N])
check('1', solve([[N,N+1],[0,0]]), {1: [[1, 2], False, []], 2: [[2, 3], False, []], 3: [[3, 4], False, []], 4: [[4, 5], False, []], 5: [[5, 6], False, []]}[N])
check('2', solve([[N,N+1],[0]]), {1: [[1, 2], False, []], 2: [[2, 3], False, []], 3: [[3, 4], False, []], 4: [[4, 5], False, []], 5: [[5, 6], False, []]}[N])
check('3', solve([[N],[0]]), {1: [[1], True, [0]], 2: [[2], True, [0]], 3: [[3], True, [0]], 4: [[4], True, [0]], 5: [[5], True, [0]]}[N])
check('4', solve([[],[]]), {1: [[], True, []], 2: [[], True, []], 3: [[], True, []], 4: [[], True, []], 5: [[], True, []]}[N])
check('5', solve([[N,N+1,N+2,N+3],[1,3,0,2]]), {1: [[2, 4, 1, 3], True, [2, 0, 3, 1]], 2: [[3, 5, 2, 4], True, [2, 0, 3, 1]], 3: [[4, 6, 3, 5], True, [2, 0, 3, 1]], 4: [[5, 7, 4, 6], True, [2, 0, 3, 1]], 5: [[6, 8, 5, 7], True, [2, 0, 3, 1]]}[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 fixtureActualExpectedOutcome
0[[3, 1, 2], True, [0, 1, 2]][[3, 1, 2], True, [1, 2, 0]]Failed
1[[1, 2], False, []][[1, 2], False, []]Passed
2[[1, 2], False, []][[1, 2], False, []]Passed
3[[1], True, [0]][[1], True, [0]]Passed
4[[], True, []][[], True, []]Passed
5[[2, 4, 1, 3], True, [0, 1, 2, 3]][[2, 4, 1, 3], True, [2, 0, 3, 1]]Failed

SHA-256 / 464ab49ebb4e09aac0c566739e394681f880442aaba4719d9e674bed2987763e

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    a,order=x
    valid=sorted(order)==list(range(len(a)))
    if not valid:return [a,False,[]]
    result=[a[i] for i in order]
    inverse=[0]*len(a)
    for new,old in enumerate(order):inverse[old]=new
    return [result,True,inverse]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[N,N+1,N+2],[2,0,1]]), {1: [[3, 1, 2], True, [1, 2, 0]], 2: [[4, 2, 3], True, [1, 2, 0]], 3: [[5, 3, 4], True, [1, 2, 0]], 4: [[6, 4, 5], True, [1, 2, 0]], 5: [[7, 5, 6], True, [1, 2, 0]]}[N])
check('1', solve([[N,N+1],[0,0]]), {1: [[1, 2], False, []], 2: [[2, 3], False, []], 3: [[3, 4], False, []], 4: [[4, 5], False, []], 5: [[5, 6], False, []]}[N])
check('2', solve([[N,N+1],[0]]), {1: [[1, 2], False, []], 2: [[2, 3], False, []], 3: [[3, 4], False, []], 4: [[4, 5], False, []], 5: [[5, 6], False, []]}[N])
check('3', solve([[N],[0]]), {1: [[1], True, [0]], 2: [[2], True, [0]], 3: [[3], True, [0]], 4: [[4], True, [0]], 5: [[5], True, [0]]}[N])
check('4', solve([[],[]]), {1: [[], True, []], 2: [[], True, []], 3: [[], True, []], 4: [[], True, []], 5: [[], True, []]}[N])
check('5', solve([[N,N+1,N+2,N+3],[1,3,0,2]]), {1: [[2, 4, 1, 3], True, [2, 0, 3, 1]], 2: [[3, 5, 2, 4], True, [2, 0, 3, 1]], 3: [[4, 6, 3, 5], True, [2, 0, 3, 1]], 4: [[5, 7, 4, 6], True, [2, 0, 3, 1]], 5: [[6, 8, 5, 7], True, [2, 0, 3, 1]]}[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 fixtureActualExpectedOutcome
0[[3, 1, 2], True, [1, 2, 0]][[3, 1, 2], True, [1, 2, 0]]Passed
1[[1, 2], False, []][[1, 2], False, []]Passed
2[[1, 2], False, []][[1, 2], False, []]Passed
3[[1], True, [0]][[1], True, [0]]Passed
4[[], True, []][[], True, []]Passed
5[[2, 4, 1, 3], True, [2, 0, 3, 1]][[2, 4, 1, 3], True, [2, 0, 3, 1]]Passed

SHA-256 / 5763b2a059ee17f1ef717747dbb018e886fdd5f637613eb27a9b26fece6f938c

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

Case digest / 3afbc3ae0e460e25e637d40b95cf5b0f7d443503b00c4e05a1c33b1f9ea8f45a