FA-45041 / Data systems / Open access
Fetch decrements quota per batch rather than per emitted row · case 01
Fetch decrements quota per batch rather than per emitted row.
ROOT CAUSE
batch-resume-cursor: Fetch decrements quota per batch rather than per emitted row.
VERIFIED REPAIR
Preserve the stated physical representation and operation order: Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.
Unsuccessful approach: Counting only first rows of batches still exceeds row quota within a batch.
Case contract
Fetch at most quota rows from a sequence of batches starting at [batch-index,row-offset]. Skip exhausted and empty batches, return the emitted rows and a canonical next cursor, and mark exhaustion as [number-of-batches,0]. Quota zero preserves a normalized cursor.
Why this case matters
A bounded deterministic data engine model makes representation and changelog faults reproducible.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
try:
batches,batch,offset,quota=d
out=[]
while batch<len(batches) and offset>=len(batches[batch]):
batch+=1; offset=0
while quota>0 and batch<len(batches):
out.append(batches[batch][offset])
offset+=1; quota-=int(offset==len(batches[batch]))
while batch<len(batches) and offset>=len(batches[batch]):
batch+=1; offset=0
return [out,[batch,offset]]
except (IndexError, KeyError, ValueError, StopIteration) as exc:
return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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 |
|---|---|---|---|
| partial current batch | [[2, 3], [1, 0]] | [[2], [0, 2]] | Failed |
| cross empty batches | [[1, 2, 3], [4, 0]] | [[1, 2], [3, 1]] | Failed |
| initial exhausted | [[1, 2], [3, 0]] | [[1], [2, 1]] | Failed |
| resume past long batch | [[1, 2, 3, 4], [2, 0]] | [[1, 2, 3], [1, 1]] | Failed |
| all exhausted | [[], [1, 0]] | [[], [1, 0]] | Passed |
| zero quota | [[], [0, 1]] | [[], [0, 1]] | Passed |
| within long batch | [[1, 2, 3, 4], [1, 0]] | [[1, 2], [0, 2]] | Failed |
| empty stream | [[], [0, 0]] | [[], [0, 0]] | Passed |
SHA-256 / 6b64c20d0a78b093ae3c08b232e4ac94d21c54fb97e33fdd1f03627cc83ae072
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
try:
batches,batch,offset,quota=d
out=[]
while batch<len(batches) and offset>=len(batches[batch]):
batch+=1; offset=0
while quota>0 and batch<len(batches):
out.append(batches[batch][offset])
offset+=1; quota-=int(offset==1)
while batch<len(batches) and offset>=len(batches[batch]):
batch+=1; offset=0
return [out,[batch,offset]]
except (IndexError, KeyError, ValueError, StopIteration) as exc:
return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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 |
|---|---|---|---|
| partial current batch | [[2, 3], [1, 0]] | [[2], [0, 2]] | Failed |
| cross empty batches | [[1, 2], [3, 1]] | [[1, 2], [3, 1]] | Passed |
| initial exhausted | [[1], [2, 1]] | [[1], [2, 1]] | Passed |
| resume past long batch | [[1, 2, 3, 4], [2, 0]] | [[1, 2, 3], [1, 1]] | Failed |
| all exhausted | [[], [1, 0]] | [[], [1, 0]] | Passed |
| zero quota | [[], [0, 1]] | [[], [0, 1]] | Passed |
| within long batch | [[1, 2, 3, 4], [1, 0]] | [[1, 2], [0, 2]] | Failed |
| empty stream | [[], [0, 0]] | [[], [0, 0]] | Passed |
SHA-256 / d09848668027ce1395b8b96cfc5120d7b33c91d23b136a3da5ce1a7fd0d2fbdf
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
try:
batches,batch,offset,quota=d
out=[]
while batch<len(batches) and offset>=len(batches[batch]):
batch+=1; offset=0
while quota>0 and batch<len(batches):
out.append(batches[batch][offset])
offset+=1; quota-=1
while batch<len(batches) and offset>=len(batches[batch]):
batch+=1; offset=0
return [out,[batch,offset]]
except (IndexError, KeyError, ValueError, StopIteration) as exc:
return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('partial current batch', solve([[[1, 2, 3]], 0, 1, 1]), [[2], [0, 2]])
check('cross empty batches', solve([[[1], [], [], [2, 3]], 0, 0, 2]), [[1, 2], [3, 1]])
check('initial exhausted', solve([[[], [], [1, 2]], 0, 0, 1]), [[1], [2, 1]])
check('resume past long batch', solve([[[1, 2], [3, 4]], 0, 0, 3]), [[1, 2, 3], [1, 1]])
check('all exhausted', solve([[[1]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[1, 2]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[1, 2, 3, 4]], 0, 0, 2]), [[1, 2], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 2:
check('partial current batch', solve([[[2, 3, 4]], 0, 1, 1]), [[3], [0, 2]])
check('cross empty batches', solve([[[2], [], [], [3, 4]], 0, 0, 2]), [[2, 3], [3, 1]])
check('initial exhausted', solve([[[], [], [2, 3]], 0, 0, 1]), [[2], [2, 1]])
check('resume past long batch', solve([[[2, 3], [4, 5]], 0, 0, 3]), [[2, 3, 4], [1, 1]])
check('all exhausted', solve([[[2]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[2, 3]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[2, 3, 4, 5]], 0, 0, 2]), [[2, 3], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 3:
check('partial current batch', solve([[[3, 4, 5]], 0, 1, 1]), [[4], [0, 2]])
check('cross empty batches', solve([[[3], [], [], [4, 5]], 0, 0, 2]), [[3, 4], [3, 1]])
check('initial exhausted', solve([[[], [], [3, 4]], 0, 0, 1]), [[3], [2, 1]])
check('resume past long batch', solve([[[3, 4], [5, 6]], 0, 0, 3]), [[3, 4, 5], [1, 1]])
check('all exhausted', solve([[[3]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[3, 4]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[3, 4, 5, 6]], 0, 0, 2]), [[3, 4], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 4:
check('partial current batch', solve([[[4, 5, 6]], 0, 1, 1]), [[5], [0, 2]])
check('cross empty batches', solve([[[4], [], [], [5, 6]], 0, 0, 2]), [[4, 5], [3, 1]])
check('initial exhausted', solve([[[], [], [4, 5]], 0, 0, 1]), [[4], [2, 1]])
check('resume past long batch', solve([[[4, 5], [6, 7]], 0, 0, 3]), [[4, 5, 6], [1, 1]])
check('all exhausted', solve([[[4]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[4, 5]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[4, 5, 6, 7]], 0, 0, 2]), [[4, 5], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
elif N == 5:
check('partial current batch', solve([[[5, 6, 7]], 0, 1, 1]), [[6], [0, 2]])
check('cross empty batches', solve([[[5], [], [], [6, 7]], 0, 0, 2]), [[5, 6], [3, 1]])
check('initial exhausted', solve([[[], [], [5, 6]], 0, 0, 1]), [[5], [2, 1]])
check('resume past long batch', solve([[[5, 6], [7, 8]], 0, 0, 3]), [[5, 6, 7], [1, 1]])
check('all exhausted', solve([[[5]], 0, 1, 3]), [[], [1, 0]])
check('zero quota', solve([[[5, 6]], 0, 1, 0]), [[], [0, 1]])
check('within long batch', solve([[[5, 6, 7, 8]], 0, 0, 2]), [[5, 6], [0, 2]])
check('empty stream', solve([[], 0, 0, 2]), [[], [0, 0]])
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 |
|---|---|---|---|
| partial current batch | [[2], [0, 2]] | [[2], [0, 2]] | Passed |
| cross empty batches | [[1, 2], [3, 1]] | [[1, 2], [3, 1]] | Passed |
| initial exhausted | [[1], [2, 1]] | [[1], [2, 1]] | Passed |
| resume past long batch | [[1, 2, 3], [1, 1]] | [[1, 2, 3], [1, 1]] | Passed |
| all exhausted | [[], [1, 0]] | [[], [1, 0]] | Passed |
| zero quota | [[], [0, 1]] | [[], [0, 1]] | Passed |
| within long batch | [[1, 2], [0, 2]] | [[1, 2], [0, 2]] | Passed |
| empty stream | [[], [0, 0]] | [[], [0, 0]] | Passed |
SHA-256 / 34cfb8de043f357459ed127f3f4dc3f1e677c7651a54044fb299fa4adf6b3c23
Verification & scope
Offline stipulated semantics over valid small inputs; no performance, concurrency, or production-engine conformance claim. 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:18.162583+00:00.
Case digest / 3a91f1b3fe0550a83346e79e7e159a74a4f1f26724120a345da84a53fab54d22