FA-46246 / Bounded deques / Open access
Deque merge drops the unmerged left suffix · case 01
Deque merge drops the unmerged left suffix.
ROOT CAUSE
Deque merge drops the unmerged left suffix.
VERIFIED REPAIR
Restore the documented left tail invariant in merge-runs.
Unsuccessful approach: The partial repair still applies the incorrect transition to an admitted boundary or multi-element case.
Case contract
Merge sorted deque runs by key, placing equal keys from the left run first and preserving each run order. Split the merged stream at output capacity.
Why this case matters
Controlled bounded deque implementation model with explicit storage and lifecycle observations.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,b,cap=x
out=[]
i=j=0
while i<len(a) and j<len(b):
if a[i][0]<=b[j][0]:
out.append(a[i]);i+=1
else:
out.append(b[j]);j+=1
out.extend([])
out.extend(b[j:])
return [out[:cap],out[cap:]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[[1,N],[2,N+1]],[[1,N+2],[3,N+3]],3]), {1: [[[1, 1], [1, 3], [2, 2]], [[3, 4]]], 2: [[[1, 2], [1, 4], [2, 3]], [[3, 5]]], 3: [[[1, 3], [1, 5], [2, 4]], [[3, 6]]], 4: [[[1, 4], [1, 6], [2, 5]], [[3, 7]]], 5: [[[1, 5], [1, 7], [2, 6]], [[3, 8]]]}[N])
check('1', solve([[[1,N]],[],2]), {1: [[[1, 1]], []], 2: [[[1, 2]], []], 3: [[[1, 3]], []], 4: [[[1, 4]], []], 5: [[[1, 5]], []]}[N])
check('2', solve([[],[[1,N]],0]), {1: [[], [[1, 1]]], 2: [[], [[1, 2]]], 3: [[], [[1, 3]]], 4: [[], [[1, 4]]], 5: [[], [[1, 5]]]}[N])
check('3', solve([[[1,N],[1,N+1]],[[1,N+2]],3]), {1: [[[1, 1], [1, 2], [1, 3]], []], 2: [[[1, 2], [1, 3], [1, 4]], []], 3: [[[1, 3], [1, 4], [1, 5]], []], 4: [[[1, 4], [1, 5], [1, 6]], []], 5: [[[1, 5], [1, 6], [1, 7]], []]}[N])
check('4', solve([[[4,N]],[[1,N+1],[2,N+2]],4]), {1: [[[1, 2], [2, 3], [4, 1]], []], 2: [[[1, 3], [2, 4], [4, 2]], []], 3: [[[1, 4], [2, 5], [4, 3]], []], 4: [[[1, 5], [2, 6], [4, 4]], []], 5: [[[1, 6], [2, 7], [4, 5]], []]}[N])
check('5', solve([[],[],2]), {1: [[], []], 2: [[], []], 3: [[], []], 4: [[], []], 5: [[], []]}[N])
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 |
|---|---|---|---|
| 0 | [[[1, 1], [1, 3], [2, 2]], [[3, 4]]] | [[[1, 1], [1, 3], [2, 2]], [[3, 4]]] | Passed |
| 1 | [[], []] | [[[1, 1]], []] | Failed |
| 2 | [[], [[1, 1]]] | [[], [[1, 1]]] | Passed |
| 3 | [[[1, 1], [1, 2], [1, 3]], []] | [[[1, 1], [1, 2], [1, 3]], []] | Passed |
| 4 | [[[1, 2], [2, 3]], []] | [[[1, 2], [2, 3], [4, 1]], []] | Failed |
| 5 | [[], []] | [[], []] | Passed |
SHA-256 / 0694305b73834ea46100dd0aacc70f8ad4aca2bcbbc08c78b0abb9b90f4d51eb
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,b,cap=x
out=[]
i=j=0
while i<len(a) and j<len(b):
if a[i][0]<=b[j][0]:
out.append(a[i]);i+=1
else:
out.append(b[j]);j+=1
out.extend(a[i:] if j==0 else [])
out.extend(b[j:])
return [out[:cap],out[cap:]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[[1,N],[2,N+1]],[[1,N+2],[3,N+3]],3]), {1: [[[1, 1], [1, 3], [2, 2]], [[3, 4]]], 2: [[[1, 2], [1, 4], [2, 3]], [[3, 5]]], 3: [[[1, 3], [1, 5], [2, 4]], [[3, 6]]], 4: [[[1, 4], [1, 6], [2, 5]], [[3, 7]]], 5: [[[1, 5], [1, 7], [2, 6]], [[3, 8]]]}[N])
check('1', solve([[[1,N]],[],2]), {1: [[[1, 1]], []], 2: [[[1, 2]], []], 3: [[[1, 3]], []], 4: [[[1, 4]], []], 5: [[[1, 5]], []]}[N])
check('2', solve([[],[[1,N]],0]), {1: [[], [[1, 1]]], 2: [[], [[1, 2]]], 3: [[], [[1, 3]]], 4: [[], [[1, 4]]], 5: [[], [[1, 5]]]}[N])
check('3', solve([[[1,N],[1,N+1]],[[1,N+2]],3]), {1: [[[1, 1], [1, 2], [1, 3]], []], 2: [[[1, 2], [1, 3], [1, 4]], []], 3: [[[1, 3], [1, 4], [1, 5]], []], 4: [[[1, 4], [1, 5], [1, 6]], []], 5: [[[1, 5], [1, 6], [1, 7]], []]}[N])
check('4', solve([[[4,N]],[[1,N+1],[2,N+2]],4]), {1: [[[1, 2], [2, 3], [4, 1]], []], 2: [[[1, 3], [2, 4], [4, 2]], []], 3: [[[1, 4], [2, 5], [4, 3]], []], 4: [[[1, 5], [2, 6], [4, 4]], []], 5: [[[1, 6], [2, 7], [4, 5]], []]}[N])
check('5', solve([[],[],2]), {1: [[], []], 2: [[], []], 3: [[], []], 4: [[], []], 5: [[], []]}[N])
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 |
|---|---|---|---|
| 0 | [[[1, 1], [1, 3], [2, 2]], [[3, 4]]] | [[[1, 1], [1, 3], [2, 2]], [[3, 4]]] | Passed |
| 1 | [[[1, 1]], []] | [[[1, 1]], []] | Passed |
| 2 | [[], [[1, 1]]] | [[], [[1, 1]]] | Passed |
| 3 | [[[1, 1], [1, 2], [1, 3]], []] | [[[1, 1], [1, 2], [1, 3]], []] | Passed |
| 4 | [[[1, 2], [2, 3]], []] | [[[1, 2], [2, 3], [4, 1]], []] | Failed |
| 5 | [[], []] | [[], []] | Passed |
SHA-256 / 777ced77e7e4c9bb4a8cf5154a583512509b2478a711b8fb9535c690fbd5ed0d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,b,cap=x
out=[]
i=j=0
while i<len(a) and j<len(b):
if a[i][0]<=b[j][0]:
out.append(a[i]);i+=1
else:
out.append(b[j]);j+=1
out.extend(a[i:])
out.extend(b[j:])
return [out[:cap],out[cap:]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[[1,N],[2,N+1]],[[1,N+2],[3,N+3]],3]), {1: [[[1, 1], [1, 3], [2, 2]], [[3, 4]]], 2: [[[1, 2], [1, 4], [2, 3]], [[3, 5]]], 3: [[[1, 3], [1, 5], [2, 4]], [[3, 6]]], 4: [[[1, 4], [1, 6], [2, 5]], [[3, 7]]], 5: [[[1, 5], [1, 7], [2, 6]], [[3, 8]]]}[N])
check('1', solve([[[1,N]],[],2]), {1: [[[1, 1]], []], 2: [[[1, 2]], []], 3: [[[1, 3]], []], 4: [[[1, 4]], []], 5: [[[1, 5]], []]}[N])
check('2', solve([[],[[1,N]],0]), {1: [[], [[1, 1]]], 2: [[], [[1, 2]]], 3: [[], [[1, 3]]], 4: [[], [[1, 4]]], 5: [[], [[1, 5]]]}[N])
check('3', solve([[[1,N],[1,N+1]],[[1,N+2]],3]), {1: [[[1, 1], [1, 2], [1, 3]], []], 2: [[[1, 2], [1, 3], [1, 4]], []], 3: [[[1, 3], [1, 4], [1, 5]], []], 4: [[[1, 4], [1, 5], [1, 6]], []], 5: [[[1, 5], [1, 6], [1, 7]], []]}[N])
check('4', solve([[[4,N]],[[1,N+1],[2,N+2]],4]), {1: [[[1, 2], [2, 3], [4, 1]], []], 2: [[[1, 3], [2, 4], [4, 2]], []], 3: [[[1, 4], [2, 5], [4, 3]], []], 4: [[[1, 5], [2, 6], [4, 4]], []], 5: [[[1, 6], [2, 7], [4, 5]], []]}[N])
check('5', solve([[],[],2]), {1: [[], []], 2: [[], []], 3: [[], []], 4: [[], []], 5: [[], []]}[N])
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 |
|---|---|---|---|
| 0 | [[[1, 1], [1, 3], [2, 2]], [[3, 4]]] | [[[1, 1], [1, 3], [2, 2]], [[3, 4]]] | Passed |
| 1 | [[[1, 1]], []] | [[[1, 1]], []] | Passed |
| 2 | [[], [[1, 1]]] | [[], [[1, 1]]] | Passed |
| 3 | [[[1, 1], [1, 2], [1, 3]], []] | [[[1, 1], [1, 2], [1, 3]], []] | Passed |
| 4 | [[[1, 2], [2, 3], [4, 1]], []] | [[[1, 2], [2, 3], [4, 1]], []] | Passed |
| 5 | [[], []] | [[], []] | Passed |
SHA-256 / 29c5f698168933d5a694c57753f86162759032454083f9ea1c95002fa7e116db
Verification & scope
Offline finite deterministic model; no claim of production implementation or concurrent memory-model conformance. 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:44:30.287752+00:00.
Case digest / f505c55160fdbac2e418c3b157d8b517f818271c7b2116568ef3c8f2150b367d