FA-47246 / Bounded deques / Open access
Deque scatter drain skips a zero segment instead of stopping · case 01
Deque scatter drain skips a zero segment instead of stopping.
ROOT CAUSE
Deque scatter drain skips a zero segment instead of stopping.
VERIFIED REPAIR
Restore the documented zero segment invariant in segmented-drain.
Unsuccessful approach: The partial repair still applies the incorrect transition to an admitted boundary or multi-element case.
Case contract
Drain a bounded deque into caller-provided segment capacities, respecting a total delivery limit. Stop at the first zero-length segment, exhausted input or exhausted limit. Preserve undispatched suffix and report consumed count and unused total budget.
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,capacities,limit=x
segments=[]
position=0
for room in capacities:
count=min(room,len(a)-position,limit-position)
if count<=0:continue
segment=a[position:position+count]
segments.append(segment)
position+=count
remaining=a[position:]
return [segments,remaining,position,len(segments),limit-position]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[N,N+1,N+2,N+3,N+4],[2,2,2],4]), {1: [[[1, 2], [3, 4]], [5], 4, 2, 0], 2: [[[2, 3], [4, 5]], [6], 4, 2, 0], 3: [[[3, 4], [5, 6]], [7], 4, 2, 0], 4: [[[4, 5], [6, 7]], [8], 4, 2, 0], 5: [[[5, 6], [7, 8]], [9], 4, 2, 0]}[N])
check('1', solve([[N,N+1,N+2],[1,0,2],3]), {1: [[[1]], [2, 3], 1, 1, 2], 2: [[[2]], [3, 4], 1, 1, 2], 3: [[[3]], [4, 5], 1, 1, 2], 4: [[[4]], [5, 6], 1, 1, 2], 5: [[[5]], [6, 7], 1, 1, 2]}[N])
check('2', solve([[N,N+1],[4,2],6]), {1: [[[1, 2]], [], 2, 1, 4], 2: [[[2, 3]], [], 2, 1, 4], 3: [[[3, 4]], [], 2, 1, 4], 4: [[[4, 5]], [], 2, 1, 4], 5: [[[5, 6]], [], 2, 1, 4]}[N])
check('3', solve([[],[2],3]), {1: [[], [], 0, 0, 3], 2: [[], [], 0, 0, 3], 3: [[], [], 0, 0, 3], 4: [[], [], 0, 0, 3], 5: [[], [], 0, 0, 3]}[N])
check('4', solve([[N,N+1],[1,2],0]), {1: [[], [1, 2], 0, 0, 0], 2: [[], [2, 3], 0, 0, 0], 3: [[], [3, 4], 0, 0, 0], 4: [[], [4, 5], 0, 0, 0], 5: [[], [5, 6], 0, 0, 0]}[N])
check('5', solve([[N,N+1,N+2,N+3],[1,2,1],4]), {1: [[[1], [2, 3], [4]], [], 4, 3, 0], 2: [[[2], [3, 4], [5]], [], 4, 3, 0], 3: [[[3], [4, 5], [6]], [], 4, 3, 0], 4: [[[4], [5, 6], [7]], [], 4, 3, 0], 5: [[[5], [6, 7], [8]], [], 4, 3, 0]}[N])
check('6', solve([[N,N+1],[1,1],3]), {1: [[[1], [2]], [], 2, 2, 1], 2: [[[2], [3]], [], 2, 2, 1], 3: [[[3], [4]], [], 2, 2, 1], 4: [[[4], [5]], [], 2, 2, 1], 5: [[[5], [6]], [], 2, 2, 1]}[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, 2], [3, 4]], [5], 4, 2, 0] | [[[1, 2], [3, 4]], [5], 4, 2, 0] | Passed |
| 1 | [[[1], [2, 3]], [], 3, 2, 0] | [[[1]], [2, 3], 1, 1, 2] | Failed |
| 2 | [[[1, 2]], [], 2, 1, 4] | [[[1, 2]], [], 2, 1, 4] | Passed |
| 3 | [[], [], 0, 0, 3] | [[], [], 0, 0, 3] | Passed |
| 4 | [[], [1, 2], 0, 0, 0] | [[], [1, 2], 0, 0, 0] | Passed |
| 5 | [[[1], [2, 3], [4]], [], 4, 3, 0] | [[[1], [2, 3], [4]], [], 4, 3, 0] | Passed |
| 6 | [[[1], [2]], [], 2, 2, 1] | [[[1], [2]], [], 2, 2, 1] | Passed |
SHA-256 / 2e794aa6dd7258e3b22970b616da47f89bfa721e464ddd3a0033bd857a2769b9
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,capacities,limit=x
segments=[]
position=0
for room in capacities:
count=min(room,len(a)-position,limit-position)
if count<=0:
if room==0: continue
break
segment=a[position:position+count]
segments.append(segment)
position+=count
remaining=a[position:]
return [segments,remaining,position,len(segments),limit-position]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[N,N+1,N+2,N+3,N+4],[2,2,2],4]), {1: [[[1, 2], [3, 4]], [5], 4, 2, 0], 2: [[[2, 3], [4, 5]], [6], 4, 2, 0], 3: [[[3, 4], [5, 6]], [7], 4, 2, 0], 4: [[[4, 5], [6, 7]], [8], 4, 2, 0], 5: [[[5, 6], [7, 8]], [9], 4, 2, 0]}[N])
check('1', solve([[N,N+1,N+2],[1,0,2],3]), {1: [[[1]], [2, 3], 1, 1, 2], 2: [[[2]], [3, 4], 1, 1, 2], 3: [[[3]], [4, 5], 1, 1, 2], 4: [[[4]], [5, 6], 1, 1, 2], 5: [[[5]], [6, 7], 1, 1, 2]}[N])
check('2', solve([[N,N+1],[4,2],6]), {1: [[[1, 2]], [], 2, 1, 4], 2: [[[2, 3]], [], 2, 1, 4], 3: [[[3, 4]], [], 2, 1, 4], 4: [[[4, 5]], [], 2, 1, 4], 5: [[[5, 6]], [], 2, 1, 4]}[N])
check('3', solve([[],[2],3]), {1: [[], [], 0, 0, 3], 2: [[], [], 0, 0, 3], 3: [[], [], 0, 0, 3], 4: [[], [], 0, 0, 3], 5: [[], [], 0, 0, 3]}[N])
check('4', solve([[N,N+1],[1,2],0]), {1: [[], [1, 2], 0, 0, 0], 2: [[], [2, 3], 0, 0, 0], 3: [[], [3, 4], 0, 0, 0], 4: [[], [4, 5], 0, 0, 0], 5: [[], [5, 6], 0, 0, 0]}[N])
check('5', solve([[N,N+1,N+2,N+3],[1,2,1],4]), {1: [[[1], [2, 3], [4]], [], 4, 3, 0], 2: [[[2], [3, 4], [5]], [], 4, 3, 0], 3: [[[3], [4, 5], [6]], [], 4, 3, 0], 4: [[[4], [5, 6], [7]], [], 4, 3, 0], 5: [[[5], [6, 7], [8]], [], 4, 3, 0]}[N])
check('6', solve([[N,N+1],[1,1],3]), {1: [[[1], [2]], [], 2, 2, 1], 2: [[[2], [3]], [], 2, 2, 1], 3: [[[3], [4]], [], 2, 2, 1], 4: [[[4], [5]], [], 2, 2, 1], 5: [[[5], [6]], [], 2, 2, 1]}[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, 2], [3, 4]], [5], 4, 2, 0] | [[[1, 2], [3, 4]], [5], 4, 2, 0] | Passed |
| 1 | [[[1], [2, 3]], [], 3, 2, 0] | [[[1]], [2, 3], 1, 1, 2] | Failed |
| 2 | [[[1, 2]], [], 2, 1, 4] | [[[1, 2]], [], 2, 1, 4] | Passed |
| 3 | [[], [], 0, 0, 3] | [[], [], 0, 0, 3] | Passed |
| 4 | [[], [1, 2], 0, 0, 0] | [[], [1, 2], 0, 0, 0] | Passed |
| 5 | [[[1], [2, 3], [4]], [], 4, 3, 0] | [[[1], [2, 3], [4]], [], 4, 3, 0] | Passed |
| 6 | [[[1], [2]], [], 2, 2, 1] | [[[1], [2]], [], 2, 2, 1] | Passed |
SHA-256 / d7f8dacca89ec2df3d24644847152427a1c54afd4b3f865f12532d9af84d0843
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
a,capacities,limit=x
segments=[]
position=0
for room in capacities:
count=min(room,len(a)-position,limit-position)
if count<=0:break
segment=a[position:position+count]
segments.append(segment)
position+=count
remaining=a[position:]
return [segments,remaining,position,len(segments),limit-position]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[N,N+1,N+2,N+3,N+4],[2,2,2],4]), {1: [[[1, 2], [3, 4]], [5], 4, 2, 0], 2: [[[2, 3], [4, 5]], [6], 4, 2, 0], 3: [[[3, 4], [5, 6]], [7], 4, 2, 0], 4: [[[4, 5], [6, 7]], [8], 4, 2, 0], 5: [[[5, 6], [7, 8]], [9], 4, 2, 0]}[N])
check('1', solve([[N,N+1,N+2],[1,0,2],3]), {1: [[[1]], [2, 3], 1, 1, 2], 2: [[[2]], [3, 4], 1, 1, 2], 3: [[[3]], [4, 5], 1, 1, 2], 4: [[[4]], [5, 6], 1, 1, 2], 5: [[[5]], [6, 7], 1, 1, 2]}[N])
check('2', solve([[N,N+1],[4,2],6]), {1: [[[1, 2]], [], 2, 1, 4], 2: [[[2, 3]], [], 2, 1, 4], 3: [[[3, 4]], [], 2, 1, 4], 4: [[[4, 5]], [], 2, 1, 4], 5: [[[5, 6]], [], 2, 1, 4]}[N])
check('3', solve([[],[2],3]), {1: [[], [], 0, 0, 3], 2: [[], [], 0, 0, 3], 3: [[], [], 0, 0, 3], 4: [[], [], 0, 0, 3], 5: [[], [], 0, 0, 3]}[N])
check('4', solve([[N,N+1],[1,2],0]), {1: [[], [1, 2], 0, 0, 0], 2: [[], [2, 3], 0, 0, 0], 3: [[], [3, 4], 0, 0, 0], 4: [[], [4, 5], 0, 0, 0], 5: [[], [5, 6], 0, 0, 0]}[N])
check('5', solve([[N,N+1,N+2,N+3],[1,2,1],4]), {1: [[[1], [2, 3], [4]], [], 4, 3, 0], 2: [[[2], [3, 4], [5]], [], 4, 3, 0], 3: [[[3], [4, 5], [6]], [], 4, 3, 0], 4: [[[4], [5, 6], [7]], [], 4, 3, 0], 5: [[[5], [6, 7], [8]], [], 4, 3, 0]}[N])
check('6', solve([[N,N+1],[1,1],3]), {1: [[[1], [2]], [], 2, 2, 1], 2: [[[2], [3]], [], 2, 2, 1], 3: [[[3], [4]], [], 2, 2, 1], 4: [[[4], [5]], [], 2, 2, 1], 5: [[[5], [6]], [], 2, 2, 1]}[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, 2], [3, 4]], [5], 4, 2, 0] | [[[1, 2], [3, 4]], [5], 4, 2, 0] | Passed |
| 1 | [[[1]], [2, 3], 1, 1, 2] | [[[1]], [2, 3], 1, 1, 2] | Passed |
| 2 | [[[1, 2]], [], 2, 1, 4] | [[[1, 2]], [], 2, 1, 4] | Passed |
| 3 | [[], [], 0, 0, 3] | [[], [], 0, 0, 3] | Passed |
| 4 | [[], [1, 2], 0, 0, 0] | [[], [1, 2], 0, 0, 0] | Passed |
| 5 | [[[1], [2, 3], [4]], [], 4, 3, 0] | [[[1], [2, 3], [4]], [], 4, 3, 0] | Passed |
| 6 | [[[1], [2]], [], 2, 2, 1] | [[[1], [2]], [], 2, 2, 1] | Passed |
SHA-256 / 65f1b933eadc060bf6da4f1dcc29c02366d11963d7e09e0f459ee62b87696f14
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:39.726331+00:00.
Case digest / 1bf78bac2c05c286a5a1ee047f80e6f83f24f4e7b0aeb9bd711356a9ae018dbc