FAILURE MAP
← Case archive

FA-45891 / Bounded deques / Open access

Growing a wrapped ring copies physical order · case 01

Growing a wrapped ring copies physical order.

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

ROOT CAUSE

A contiguous-copy shortcut loses the wrapped portion of the logical sequence.

VERIFIED REPAIR

Restore the documented linearization invariant in ring-grow.

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

Case contract

Grow a ring to larger positive capacity. Linearize occupied slots in logical order, clear unused storage, reset head and report next insertion index and unchanged logical count.

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):
    slots, head, size, capacity = x
    old = len(slots)
    live = slots[:size]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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
wrapped live data[[1, None, None, None, None, None, None], 0, 3, 3][[2, 3, 1, None, None, None, None], 0, 3, 3]Failed
empty shifted ring[[None, None, None, None, None, None], 0, 0, 0][[None, None, None, None, None, None], 0, 0, 0]Passed
one shifted value[[None, None, None, None, None], 0, 1, 1][[1, None, None, None, None], 0, 1, 1]Failed
full old ring[[1, 2, 3, None, None], 0, 3, 3][[2, 3, 1, None, None], 0, 3, 3]Failed
head zero[[1, 2, None, None, None, None], 0, 2, 2][[1, 2, None, None, None, None], 0, 2, 2]Passed
two wrapped values[[1, None, None, None, None, None, None, None], 0, 2, 2][[2, 1, None, None, None, None, None, None], 0, 2, 2]Failed

SHA-256 / 417f0f710ef853ed18dd1675b8a63905bf0c0bab9bd51e81a52350ccb6e01c04

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = slots[head:head+size] if head + size <= old else slots[:size]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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
wrapped live data[[1, None, None, None, None, None, None], 0, 3, 3][[2, 3, 1, None, None, None, None], 0, 3, 3]Failed
empty shifted ring[[None, None, None, None, None, None], 0, 0, 0][[None, None, None, None, None, None], 0, 0, 0]Passed
one shifted value[[1, None, None, None, None], 0, 1, 1][[1, None, None, None, None], 0, 1, 1]Passed
full old ring[[1, 2, 3, None, None], 0, 3, 3][[2, 3, 1, None, None], 0, 3, 3]Failed
head zero[[1, 2, None, None, None, None], 0, 2, 2][[1, 2, None, None, None, None], 0, 2, 2]Passed
two wrapped values[[1, None, None, None, None, None, None, None], 0, 2, 2][[2, 1, None, None, None, None, None, None], 0, 2, 2]Failed

SHA-256 / d0fc363c682a00d56500c0375291b33710c94465dea0731f20cd22fba3a7ef06

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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
wrapped live data[[2, 3, 1, None, None, None, None], 0, 3, 3][[2, 3, 1, None, None, None, None], 0, 3, 3]Passed
empty shifted ring[[None, None, None, None, None, None], 0, 0, 0][[None, None, None, None, None, None], 0, 0, 0]Passed
one shifted value[[1, None, None, None, None], 0, 1, 1][[1, None, None, None, None], 0, 1, 1]Passed
full old ring[[2, 3, 1, None, None], 0, 3, 3][[2, 3, 1, None, None], 0, 3, 3]Passed
head zero[[1, 2, None, None, None, None], 0, 2, 2][[1, 2, None, None, None, None], 0, 2, 2]Passed
two wrapped values[[2, 1, None, None, None, None, None, None], 0, 2, 2][[2, 1, None, None, None, None, None, None], 0, 2, 2]Passed

SHA-256 / 74e399d4194544c3749facf917a06f10515584a78a0bebc7a6ac1ed75537ed07

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

Case digest / 8653a48f0f8deabd8454e4551c8e038eb775459763bed134342187f415488cba