FAILURE MAP
← Case archive

FA-4781 / Bounded deques / Open access

Deque insert full rejects atomically · case 01

The operation returns a result or retained state that violates this contract: Insert at a positional index only when the bounded deque has room; full deque returns false unchanged rather than evicting.

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

ROOT CAUSE

Using append introduces an eviction even though positional insertion must reject a full deque.

VERIFIED REPAIR

Insert at a positional index only when the bounded deque has room; full deque returns false unchanged rather than evicting.

Unsuccessful approach: Mutating before reporting rejection leaves a partially applied insertion.

Case contract

Insert at a positional index only when the bounded deque has room; full deque returns false unchanged rather than evicting. 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.append(y[2]); return [True,list(a)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full insertion rejects', solve(['a', 'b'], [2, 0, 'c']), [False, ['a', 'b']])
check('room inserts positional', solve(['a', 'b'], [3, 1, 'c']), [True, ['a', 'c', 'b']])
check('zero capacity rejects', solve([], [0, 0, 'a']), [False, []])
check('empty insertion', solve([], [1, 0, 'a']), [True, ['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 fixtureActualExpectedOutcome
full insertion rejects[True, ['b', 'c']][False, ['a', 'b']]Failed
room inserts positional[True, ['a', 'b', 'c']][True, ['a', 'c', 'b']]Failed
zero capacity rejects[True, []][False, []]Failed
empty insertion[True, ['a']][True, ['a']]Passed

SHA-256 / c15475e9329a07eaf046da2f1eac3afb9d1f2ffdab9b5354637fa95fba871376

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=list(x); a.insert(y[1],y[2]); return [len(x)<y[0],a[:y[0]]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full insertion rejects', solve(['a', 'b'], [2, 0, 'c']), [False, ['a', 'b']])
check('room inserts positional', solve(['a', 'b'], [3, 1, 'c']), [True, ['a', 'c', 'b']])
check('zero capacity rejects', solve([], [0, 0, 'a']), [False, []])
check('empty insertion', solve([], [1, 0, 'a']), [True, ['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 fixtureActualExpectedOutcome
full insertion rejects[False, ['c', 'a']][False, ['a', 'b']]Failed
room inserts positional[True, ['a', 'c', 'b']][True, ['a', 'c', 'b']]Passed
zero capacity rejects[False, []][False, []]Passed
empty insertion[True, ['a']][True, ['a']]Passed

SHA-256 / a3066745ecb9815b6ea184c4a60bc235b6e8171d37c5501dafd37db023948d50

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]); ok=len(a)<y[0]
    if ok: a.insert(y[1],y[2])
    return [ok,list(a)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full insertion rejects', solve(['a', 'b'], [2, 0, 'c']), [False, ['a', 'b']])
check('room inserts positional', solve(['a', 'b'], [3, 1, 'c']), [True, ['a', 'c', 'b']])
check('zero capacity rejects', solve([], [0, 0, 'a']), [False, []])
check('empty insertion', solve([], [1, 0, 'a']), [True, ['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 fixtureActualExpectedOutcome
full insertion rejects[False, ['a', 'b']][False, ['a', 'b']]Passed
room inserts positional[True, ['a', 'c', 'b']][True, ['a', 'c', 'b']]Passed
zero capacity rejects[False, []][False, []]Passed
empty insertion[True, ['a']][True, ['a']]Passed

SHA-256 / fcb2bf7c4b31b55e35b0e253fcbb10d284ed1a455b537bbc64a94e04eb09016a

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

Case digest / 5aa8fb05918a52c4852edeb4f2e330704d092cbd6225dc6605e94b4e83173b2b