FAILURE MAP
← Case archive

FA-45201 / Data systems / Open access

Batch packing drops the final partially filled batch · case 01

Batch packing drops the final partially filled batch.

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

ROOT CAUSE

row-batch-packing: Batch packing drops the final partially filled batch.

VERIFIED REPAIR

Preserve the stated physical representation and operation order: Pack indivisible [id,size] rows into ordered batches under a positive byte budget. A row exceeding budget occupies its own batch. Flush before an overflowing row, permit exact fits, and omit empty batches.

Unsuccessful approach: Dropping singleton tails still loses valid rows.

Case contract

Pack indivisible [id,size] rows into ordered batches under a positive byte budget. A row exceeding budget occupies its own batch. Flush before an overflowing row, permit exact fits, and omit empty batches.

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:
        rows,budget=d
        batches=[]; current=[]; used=0
        for ident,size in rows:
            if current and used+size>budget:
                batches.append(current); current=[]; used=0
            current.append(ident); used+=size
            if size>budget:
                batches.append(current); current=[]; used=0
        if current and used>=budget: batches.append(current)
        return batches
    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('exact fit', solve([[[1, 1], [2, 1]], 2]), [[1, 2]])
    check('byte budget', solve([[[1, 2], [2, 2], [3, 1]], 3]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 2], [2, 2], [3, 1], [4, 1]], 3]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 4], [2, 0]], 3]), [[1], [2]])
    check('full followed by zero', solve([[[1, 3], [2, 0]], 3]), [[1, 2]])
    check('single partial', solve([[[1, 1]], 3]), [[1]])
    check('no rows', solve([[], 3]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 1]), [[1, 2]])
elif N == 2:
    check('exact fit', solve([[[1, 2], [2, 2]], 4]), [[1, 2]])
    check('byte budget', solve([[[1, 4], [2, 4], [3, 2]], 6]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 4], [2, 4], [3, 2], [4, 2]], 6]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 8], [2, 0]], 6]), [[1], [2]])
    check('full followed by zero', solve([[[1, 6], [2, 0]], 6]), [[1, 2]])
    check('single partial', solve([[[1, 2]], 6]), [[1]])
    check('no rows', solve([[], 6]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 2]), [[1, 2]])
elif N == 3:
    check('exact fit', solve([[[1, 3], [2, 3]], 6]), [[1, 2]])
    check('byte budget', solve([[[1, 6], [2, 6], [3, 3]], 9]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 6], [2, 6], [3, 3], [4, 3]], 9]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 12], [2, 0]], 9]), [[1], [2]])
    check('full followed by zero', solve([[[1, 9], [2, 0]], 9]), [[1, 2]])
    check('single partial', solve([[[1, 3]], 9]), [[1]])
    check('no rows', solve([[], 9]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 3]), [[1, 2]])
elif N == 4:
    check('exact fit', solve([[[1, 4], [2, 4]], 8]), [[1, 2]])
    check('byte budget', solve([[[1, 8], [2, 8], [3, 4]], 12]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 8], [2, 8], [3, 4], [4, 4]], 12]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 16], [2, 0]], 12]), [[1], [2]])
    check('full followed by zero', solve([[[1, 12], [2, 0]], 12]), [[1, 2]])
    check('single partial', solve([[[1, 4]], 12]), [[1]])
    check('no rows', solve([[], 12]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 4]), [[1, 2]])
elif N == 5:
    check('exact fit', solve([[[1, 5], [2, 5]], 10]), [[1, 2]])
    check('byte budget', solve([[[1, 10], [2, 10], [3, 5]], 15]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 10], [2, 10], [3, 5], [4, 5]], 15]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 20], [2, 0]], 15]), [[1], [2]])
    check('full followed by zero', solve([[[1, 15], [2, 0]], 15]), [[1, 2]])
    check('single partial', solve([[[1, 5]], 15]), [[1]])
    check('no rows', solve([[], 15]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 5]), [[1, 2]])
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
exact fit[[1, 2]][[1, 2]]Passed
byte budget[[1], [2, 3]][[1], [2, 3]]Passed
reset after flush[[1], [2, 3]][[1], [2, 3], [4]]Failed
oversize and zero[[1]][[1], [2]]Failed
full followed by zero[[1, 2]][[1, 2]]Passed
single partial[][[1]]Failed
no rows[][]Passed
zero-sized rows[][[1, 2]]Failed

SHA-256 / e5158fb0b931919ea377e6b6fbbfac28d98d8c98df9c1d85d409766210a2778b

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,budget=d
        batches=[]; current=[]; used=0
        for ident,size in rows:
            if current and used+size>budget:
                batches.append(current); current=[]; used=0
            current.append(ident); used+=size
            if size>budget:
                batches.append(current); current=[]; used=0
        if current and len(current)>1: batches.append(current)
        return batches
    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('exact fit', solve([[[1, 1], [2, 1]], 2]), [[1, 2]])
    check('byte budget', solve([[[1, 2], [2, 2], [3, 1]], 3]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 2], [2, 2], [3, 1], [4, 1]], 3]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 4], [2, 0]], 3]), [[1], [2]])
    check('full followed by zero', solve([[[1, 3], [2, 0]], 3]), [[1, 2]])
    check('single partial', solve([[[1, 1]], 3]), [[1]])
    check('no rows', solve([[], 3]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 1]), [[1, 2]])
elif N == 2:
    check('exact fit', solve([[[1, 2], [2, 2]], 4]), [[1, 2]])
    check('byte budget', solve([[[1, 4], [2, 4], [3, 2]], 6]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 4], [2, 4], [3, 2], [4, 2]], 6]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 8], [2, 0]], 6]), [[1], [2]])
    check('full followed by zero', solve([[[1, 6], [2, 0]], 6]), [[1, 2]])
    check('single partial', solve([[[1, 2]], 6]), [[1]])
    check('no rows', solve([[], 6]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 2]), [[1, 2]])
elif N == 3:
    check('exact fit', solve([[[1, 3], [2, 3]], 6]), [[1, 2]])
    check('byte budget', solve([[[1, 6], [2, 6], [3, 3]], 9]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 6], [2, 6], [3, 3], [4, 3]], 9]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 12], [2, 0]], 9]), [[1], [2]])
    check('full followed by zero', solve([[[1, 9], [2, 0]], 9]), [[1, 2]])
    check('single partial', solve([[[1, 3]], 9]), [[1]])
    check('no rows', solve([[], 9]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 3]), [[1, 2]])
elif N == 4:
    check('exact fit', solve([[[1, 4], [2, 4]], 8]), [[1, 2]])
    check('byte budget', solve([[[1, 8], [2, 8], [3, 4]], 12]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 8], [2, 8], [3, 4], [4, 4]], 12]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 16], [2, 0]], 12]), [[1], [2]])
    check('full followed by zero', solve([[[1, 12], [2, 0]], 12]), [[1, 2]])
    check('single partial', solve([[[1, 4]], 12]), [[1]])
    check('no rows', solve([[], 12]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 4]), [[1, 2]])
elif N == 5:
    check('exact fit', solve([[[1, 5], [2, 5]], 10]), [[1, 2]])
    check('byte budget', solve([[[1, 10], [2, 10], [3, 5]], 15]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 10], [2, 10], [3, 5], [4, 5]], 15]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 20], [2, 0]], 15]), [[1], [2]])
    check('full followed by zero', solve([[[1, 15], [2, 0]], 15]), [[1, 2]])
    check('single partial', solve([[[1, 5]], 15]), [[1]])
    check('no rows', solve([[], 15]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 5]), [[1, 2]])
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
exact fit[[1, 2]][[1, 2]]Passed
byte budget[[1], [2, 3]][[1], [2, 3]]Passed
reset after flush[[1], [2, 3]][[1], [2, 3], [4]]Failed
oversize and zero[[1]][[1], [2]]Failed
full followed by zero[[1, 2]][[1, 2]]Passed
single partial[][[1]]Failed
no rows[][]Passed
zero-sized rows[[1, 2]][[1, 2]]Passed

SHA-256 / 2bb9e933a56e457044a573591dc4dc71df92ca94f89750968443b024a8b0d3a0

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        rows,budget=d
        batches=[]; current=[]; used=0
        for ident,size in rows:
            if current and used+size>budget:
                batches.append(current); current=[]; used=0
            current.append(ident); used+=size
            if size>budget:
                batches.append(current); current=[]; used=0
        if current: batches.append(current)
        return batches
    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('exact fit', solve([[[1, 1], [2, 1]], 2]), [[1, 2]])
    check('byte budget', solve([[[1, 2], [2, 2], [3, 1]], 3]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 2], [2, 2], [3, 1], [4, 1]], 3]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 4], [2, 0]], 3]), [[1], [2]])
    check('full followed by zero', solve([[[1, 3], [2, 0]], 3]), [[1, 2]])
    check('single partial', solve([[[1, 1]], 3]), [[1]])
    check('no rows', solve([[], 3]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 1]), [[1, 2]])
elif N == 2:
    check('exact fit', solve([[[1, 2], [2, 2]], 4]), [[1, 2]])
    check('byte budget', solve([[[1, 4], [2, 4], [3, 2]], 6]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 4], [2, 4], [3, 2], [4, 2]], 6]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 8], [2, 0]], 6]), [[1], [2]])
    check('full followed by zero', solve([[[1, 6], [2, 0]], 6]), [[1, 2]])
    check('single partial', solve([[[1, 2]], 6]), [[1]])
    check('no rows', solve([[], 6]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 2]), [[1, 2]])
elif N == 3:
    check('exact fit', solve([[[1, 3], [2, 3]], 6]), [[1, 2]])
    check('byte budget', solve([[[1, 6], [2, 6], [3, 3]], 9]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 6], [2, 6], [3, 3], [4, 3]], 9]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 12], [2, 0]], 9]), [[1], [2]])
    check('full followed by zero', solve([[[1, 9], [2, 0]], 9]), [[1, 2]])
    check('single partial', solve([[[1, 3]], 9]), [[1]])
    check('no rows', solve([[], 9]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 3]), [[1, 2]])
elif N == 4:
    check('exact fit', solve([[[1, 4], [2, 4]], 8]), [[1, 2]])
    check('byte budget', solve([[[1, 8], [2, 8], [3, 4]], 12]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 8], [2, 8], [3, 4], [4, 4]], 12]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 16], [2, 0]], 12]), [[1], [2]])
    check('full followed by zero', solve([[[1, 12], [2, 0]], 12]), [[1, 2]])
    check('single partial', solve([[[1, 4]], 12]), [[1]])
    check('no rows', solve([[], 12]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 4]), [[1, 2]])
elif N == 5:
    check('exact fit', solve([[[1, 5], [2, 5]], 10]), [[1, 2]])
    check('byte budget', solve([[[1, 10], [2, 10], [3, 5]], 15]), [[1], [2, 3]])
    check('reset after flush', solve([[[1, 10], [2, 10], [3, 5], [4, 5]], 15]), [[1], [2, 3], [4]])
    check('oversize and zero', solve([[[1, 20], [2, 0]], 15]), [[1], [2]])
    check('full followed by zero', solve([[[1, 15], [2, 0]], 15]), [[1, 2]])
    check('single partial', solve([[[1, 5]], 15]), [[1]])
    check('no rows', solve([[], 15]), [])
    check('zero-sized rows', solve([[[1, 0], [2, 0]], 5]), [[1, 2]])
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
exact fit[[1, 2]][[1, 2]]Passed
byte budget[[1], [2, 3]][[1], [2, 3]]Passed
reset after flush[[1], [2, 3], [4]][[1], [2, 3], [4]]Passed
oversize and zero[[1], [2]][[1], [2]]Passed
full followed by zero[[1, 2]][[1, 2]]Passed
single partial[[1]][[1]]Passed
no rows[][]Passed
zero-sized rows[[1, 2]][[1, 2]]Passed

SHA-256 / 38740d6b6bf767ecfbd18edd55ee82214585d49d629c011cedc9fa6e4cb2c171

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

Case digest / 6f5ca72b03a827f9ce32a8b8b7bb51af063af81dec8f267f0d5d00a0ea5f545f