FA-4771 / Bounded deques / Open access
Deque extendleft reverses source order · case 01
The operation returns a result or retained state that violates this contract: extendleft repeatedly prepends input elements, so input order reverses; bounded overflow evicts the right.
ROOT CAUSE
Reversing the source before repeated prepends cancels the required order reversal.
VERIFIED REPAIR
extendleft repeatedly prepends input elements, so input order reverses; bounded overflow evicts the right.
Unsuccessful approach: Right extension inserts and evicts at the opposite ends.
Case contract
extendleft repeatedly prepends input elements, so input order reverses; bounded overflow evicts the right. 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):
a=deque(x,maxlen=y[0]); a.extendleft(reversed(y[1])); return list(a)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('source reverses', solve(['a'], [4, ['b', 'c']]), ['c', 'b', 'a'])
check('overflow evicts right', solve(['a', 'b'], [2, ['c', 'd']]), ['d', 'c'])
check('empty extension', solve(['a'], [2, []]), ['a'])
check('zero capacity', solve([], [0, ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| source reverses | ['b', 'c', 'a'] | ['c', 'b', 'a'] | Failed |
| overflow evicts right | ['c', 'd'] | ['d', 'c'] | Failed |
| empty extension | ['a'] | ['a'] | Passed |
| zero capacity | [] | [] | Passed |
SHA-256 / 0eb9f9b23361617eeca36dd08e53b41b9b633e852a424d34e5c1cd6009a54267
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):
a=deque(x,maxlen=y[0]); a.extend(y[1]); return list(a)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('source reverses', solve(['a'], [4, ['b', 'c']]), ['c', 'b', 'a'])
check('overflow evicts right', solve(['a', 'b'], [2, ['c', 'd']]), ['d', 'c'])
check('empty extension', solve(['a'], [2, []]), ['a'])
check('zero capacity', solve([], [0, ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| source reverses | ['a', 'b', 'c'] | ['c', 'b', 'a'] | Failed |
| overflow evicts right | ['c', 'd'] | ['d', 'c'] | Failed |
| empty extension | ['a'] | ['a'] | Passed |
| zero capacity | [] | [] | Passed |
SHA-256 / c565a8330d79d57515e5aee966983d4cbbc7c72fc641bc3c351ebb5c32b96bd0
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):
a=deque(x,maxlen=y[0]); a.extendleft(y[1]); return list(a)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('source reverses', solve(['a'], [4, ['b', 'c']]), ['c', 'b', 'a'])
check('overflow evicts right', solve(['a', 'b'], [2, ['c', 'd']]), ['d', 'c'])
check('empty extension', solve(['a'], [2, []]), ['a'])
check('zero capacity', solve([], [0, ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| source reverses | ['c', 'b', 'a'] | ['c', 'b', 'a'] | Passed |
| overflow evicts right | ['d', 'c'] | ['d', 'c'] | Passed |
| empty extension | ['a'] | ['a'] | Passed |
| zero capacity | [] | [] | Passed |
SHA-256 / 0f70ac920901f158d092939e2abaa209df49160937b2cb7a3ee3f042398ac7ea
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.730480+00:00.
Case digest / e8c534f61c85f1a83c1b7816b2b3a8d9fee7322fe17009d9ec1e32fa9c9ff613