FA-4776 / Bounded deques / Open access
Deque bounded extend consumes complete source · case 01
The operation returns a result or retained state that violates this contract: Extending a bounded deque consumes the complete iterator even when capacity is zero; retain the newest capacity values.
ROOT CAUSE
Stopping at available space leaves later source elements unconsumed and prevents replacement.
VERIFIED REPAIR
Extending a bounded deque consumes the complete iterator even when capacity is zero; retain the newest capacity values.
Unsuccessful approach: Skipping zero-capacity extension leaves the source undrained.
Case contract
Extending a bounded deque consumes the complete iterator even when capacity is zero; retain the newest capacity values. 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):
g=iter(y[1]); a=deque(x,maxlen=y[0]); a.extend(next(g) for _ in range(min(y[0]-len(a),len(y[1])))); return [list(a),list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full still consumes and replaces', solve(['a', 'b'], [2, ['c', 'd', 'e']]), [['d', 'e'], []])
check('zero drains source', solve([], [0, ['a', 'b']]), [[], []])
check('room accepts', solve([], [3, ['a']]), [['a'], []])
check('empty source', solve(['a'], [2, []]), [['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 |
|---|---|---|---|
| full still consumes and replaces | [['a', 'b'], ['c', 'd', 'e']] | [['d', 'e'], []] | Failed |
| zero drains source | [[], ['a', 'b']] | [[], []] | Failed |
| room accepts | [['a'], []] | [['a'], []] | Passed |
| empty source | [['a'], []] | [['a'], []] | Passed |
SHA-256 / 7636405e6e7fa2e1d8891fefe87e8ea35326394ba0b990d5a39e87825766aad3
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):
g=iter(y[1]); a=deque(x,maxlen=y[0]); a.extend(g if y[0] else []); return [list(a),list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full still consumes and replaces', solve(['a', 'b'], [2, ['c', 'd', 'e']]), [['d', 'e'], []])
check('zero drains source', solve([], [0, ['a', 'b']]), [[], []])
check('room accepts', solve([], [3, ['a']]), [['a'], []])
check('empty source', solve(['a'], [2, []]), [['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 |
|---|---|---|---|
| full still consumes and replaces | [['d', 'e'], []] | [['d', 'e'], []] | Passed |
| zero drains source | [[], ['a', 'b']] | [[], []] | Failed |
| room accepts | [['a'], []] | [['a'], []] | Passed |
| empty source | [['a'], []] | [['a'], []] | Passed |
SHA-256 / 561d8ba8fb471addd5778995c7a16a7ba8c8bb39f7d4d7dadcfbfd25321506d9
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):
g=iter(y[1]); a=deque(x,maxlen=y[0]); a.extend(g); return [list(a),list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full still consumes and replaces', solve(['a', 'b'], [2, ['c', 'd', 'e']]), [['d', 'e'], []])
check('zero drains source', solve([], [0, ['a', 'b']]), [[], []])
check('room accepts', solve([], [3, ['a']]), [['a'], []])
check('empty source', solve(['a'], [2, []]), [['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 |
|---|---|---|---|
| full still consumes and replaces | [['d', 'e'], []] | [['d', 'e'], []] | Passed |
| zero drains source | [[], []] | [[], []] | Passed |
| room accepts | [['a'], []] | [['a'], []] | Passed |
| empty source | [['a'], []] | [['a'], []] | Passed |
SHA-256 / 0dc2db90539c3a07adc9a6812df7166f133bce8b5f53c6067c7d8ba384a8869a
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.729378+00:00.
Case digest / 9826d008ffc497d92c85be490e528e289223ab919d5ff4b59b17b1e547428746