FAILURE MAP
← Case archive

FA-4761 / Bounded deques / Open access

Bounded deque append evicts oldest left · case 01

The operation returns a result or retained state that violates this contract: Append to a bounded deque, evicting from the left when capacity is exceeded; zero capacity retains nothing.

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

ROOT CAUSE

Keeping the oldest prefix discards the new value instead of evicting the oldest.

VERIFIED REPAIR

Append to a bounded deque, evicting from the left when capacity is exceeded; zero capacity retains nothing.

Unsuccessful approach: A negative-zero slice retains everything at zero capacity.

Case contract

Append to a bounded deque, evicting from the left when capacity is exceeded; zero capacity retains nothing. 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 (list(x)+[y[1]])[:y[0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full evicts oldest', solve(['a', 'b'], [2, 'c']), ['b', 'c'])
check('zero capacity', solve([], [0, 'a']), [])
check('room remains', solve(['a'], [3, 'b']), ['a', 'b'])
check('empty accepts', solve([], [2, 'a']), ['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 evicts oldest['a', 'b']['b', 'c']Failed
zero capacity[][]Passed
room remains['a', 'b']['a', 'b']Passed
empty accepts['a']['a']Passed

SHA-256 / b8d2e22206e2112aeea7d8892b288e163ab34741be7b84f8873ecddff017d12d

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 (list(x)+[y[1]])[-y[0]:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full evicts oldest', solve(['a', 'b'], [2, 'c']), ['b', 'c'])
check('zero capacity', solve([], [0, 'a']), [])
check('room remains', solve(['a'], [3, 'b']), ['a', 'b'])
check('empty accepts', solve([], [2, 'a']), ['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 evicts oldest['b', 'c']['b', 'c']Passed
zero capacity['a'][]Failed
room remains['a', 'b']['a', 'b']Passed
empty accepts['a']['a']Passed

SHA-256 / 8c9c4e075686521fab96a656747aef95e855318b88d2a27dc055b30605010ced

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.append(y[1]); return list(a)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full evicts oldest', solve(['a', 'b'], [2, 'c']), ['b', 'c'])
check('zero capacity', solve([], [0, 'a']), [])
check('room remains', solve(['a'], [3, 'b']), ['a', 'b'])
check('empty accepts', solve([], [2, 'a']), ['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 evicts oldest['b', 'c']['b', 'c']Passed
zero capacity[][]Passed
room remains['a', 'b']['a', 'b']Passed
empty accepts['a']['a']Passed

SHA-256 / ce7da12a8293be137b5dee74849e2fa7dcace44a42b1b211b48285a7adc77a23

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

Case digest / e989d2c73ed4920a5506bf883549e2d9e176865f8574d1e46a61fe59fc32f286