FA-4796 / Bounded deques / Open access
Deque reconstruction retains newest suffix · case 01
The operation returns a result or retained state that violates this contract: Construct a bounded deque from a sequence, retaining its newest suffix when the initial sequence exceeds capacity.
ROOT CAUSE
Keeping the prefix retains the oldest values instead of the newest.
VERIFIED REPAIR
Construct a bounded deque from a sequence, retaining its newest suffix when the initial sequence exceeds capacity.
Unsuccessful approach: Negative-zero slicing fails the zero-capacity boundary.
Case contract
Construct a bounded deque from a sequence, retaining its newest suffix when the initial sequence exceeds capacity. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.
Why this case matters
A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
return x[:y]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('truncates left', solve(['a', 'b', 'c'], 2), ['b', 'c'])
check('zero retains none', solve(['a'], 0), [])
check('under capacity', solve(['a'], 3), ['a'])
check('empty', solve([], 1), [])
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 |
|---|---|---|---|
| truncates left | ['a', 'b'] | ['b', 'c'] | Failed |
| zero retains none | [] | [] | Passed |
| under capacity | ['a'] | ['a'] | Passed |
| empty | [] | [] | Passed |
SHA-256 / 9db6f925d82ee58f2723bf96c24a391e85055f24a971ca9cdde3c3feb7f9c545
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
return x[-y:]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('truncates left', solve(['a', 'b', 'c'], 2), ['b', 'c'])
check('zero retains none', solve(['a'], 0), [])
check('under capacity', solve(['a'], 3), ['a'])
check('empty', solve([], 1), [])
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 |
|---|---|---|---|
| truncates left | ['b', 'c'] | ['b', 'c'] | Passed |
| zero retains none | ['a'] | [] | Failed |
| under capacity | ['a'] | ['a'] | Passed |
| empty | [] | [] | Passed |
SHA-256 / 37b645082b90d77daace59174bb6955f1224e1d6bdc6ca585f5e51f08509728e
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
return list(deque(x,maxlen=y))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('truncates left', solve(['a', 'b', 'c'], 2), ['b', 'c'])
check('zero retains none', solve(['a'], 0), [])
check('under capacity', solve(['a'], 3), ['a'])
check('empty', solve([], 1), [])
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 |
|---|---|---|---|
| truncates left | ['b', 'c'] | ['b', 'c'] | Passed |
| zero retains none | [] | [] | Passed |
| under capacity | ['a'] | ['a'] | Passed |
| empty | [] | [] | Passed |
SHA-256 / c4ce392d9cf634bb88c122fd0204e3fe6537ebc9b015dde1bc9d265199e247a4
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:37:42.887775+00:00.
Case digest / 73800e18f20871d0589bf315d3f9db23c73314dd66de9e39a5997f333a3002ca