broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(total, pages, size, loading, errors, selected, estimate):
    slots=[{'kind':'placeholder','index':i,'key':('placeholder',i),'height':estimate} for i in range(total)]
    for offset,items in pages:
        for j,row in enumerate(items):
            i=offset+j
            if not 0<=i<total-1: continue
            if i>=len(slots): continue
            slots[i]={'kind':'row','index':i,'key':('row',row['id']),'row':row,'selected':row['id'] in selected}
    for s in slots:
        page=(s['index']//size)*size
        if s['kind']=='placeholder': s['loading']=page in loading; s['error']=errors.get(page)
    return {'slots':slots,'requests':sorted({(s['index']//size)*size for s in slots if s['kind']=='placeholder' and (s['index']//size)*size not in loading and (s['index']//size)*size not in errors})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':1}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 1}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 2:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':2}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 2}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 3:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':3}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 3}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 4:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':4}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 4}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 5:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':5}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 5}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(total, pages, size, loading, errors, selected, estimate):
    slots=[{'kind':'placeholder','index':i,'key':('placeholder',i),'height':estimate} for i in range(total)]
    for offset,items in pages:
        for j,row in enumerate(items):
            i=offset+j
            if not 0<i<total: continue
            if i>=len(slots): continue
            slots[i]={'kind':'row','index':i,'key':('row',row['id']),'row':row,'selected':row['id'] in selected}
    for s in slots:
        page=(s['index']//size)*size
        if s['kind']=='placeholder': s['loading']=page in loading; s['error']=errors.get(page)
    return {'slots':slots,'requests':sorted({(s['index']//size)*size for s in slots if s['kind']=='placeholder' and (s['index']//size)*size not in loading and (s['index']//size)*size not in errors})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':1}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 1}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 2:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':2}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 2}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 3:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':3}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 3}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 4:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':4}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 4}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 5:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':5}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 5}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

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)

prompt:
The table outofrange load result violates the stipulated sparse loaded table row slots contract.

Sparse table slots retain absolute indices across unloaded pages, distinguish placeholder and stable row keys, clip loaded pages to declared total, decorate only placeholders with page loading/errors, and schedule each missing nonfailed noninflight page once.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(total, pages, size, loading, errors, selected, estimate):
    slots=[{'kind':'placeholder','index':i,'key':('placeholder',i),'height':estimate} for i in range(total)]
    for offset,items in pages:
        for j,row in enumerate(items):
            i=offset+j
            if not 0<=i<total: continue
            if i>=len(slots): continue
            slots[i]={'kind':'row','index':i,'key':('row',i),'row':row,'selected':row['id'] in selected}
    for s in slots:
        page=(s['index']//size)*size
        if s['kind']=='placeholder': s['loading']=page in loading; s['error']=errors.get(page)
    return {'slots':slots,'requests':sorted({(s['index']//size)*size for s in slots if s['kind']=='placeholder' and (s['index']//size)*size not in loading and (s['index']//size)*size not in errors})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':1}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 1}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 2:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':2}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 2}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 3:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':3}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 3}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 4:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':4}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 4}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 5:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':5}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 5}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(total, pages, size, loading, errors, selected, estimate):
    slots=[{'kind':'placeholder','index':i,'key':('placeholder',i),'height':estimate} for i in range(total)]
    for offset,items in pages:
        for j,row in enumerate(items):
            i=offset+j
            if not 0<=i<total: continue
            if i>=len(slots): continue
            slots[i]={'kind':'row','index':i,'key':('placeholder',i),'row':row,'selected':row['id'] in selected}
    for s in slots:
        page=(s['index']//size)*size
        if s['kind']=='placeholder': s['loading']=page in loading; s['error']=errors.get(page)
    return {'slots':slots,'requests':sorted({(s['index']//size)*size for s in slots if s['kind']=='placeholder' and (s['index']//size)*size not in loading and (s['index']//size)*size not in errors})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':1}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 1}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 2:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':2}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 2}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 3:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':3}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 3}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 4:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':4}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 4}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 5:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':5}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 5}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

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)

prompt:
The table loaded render key result violates the stipulated sparse loaded table row slots contract.

Sparse table slots retain absolute indices across unloaded pages, distinguish placeholder and stable row keys, clip loaded pages to declared total, decorate only placeholders with page loading/errors, and schedule each missing nonfailed noninflight page once.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(total, pages, size, loading, errors, selected, estimate):
    slots=[{'kind':'placeholder','index':i,'key':('placeholder',i),'height':estimate} for i in range(total)]
    for offset,items in pages:
        for j,row in enumerate(items):
            i=offset+j
            if not 0<=i<total: continue
            if i>=len(slots): continue
            slots[i]={'kind':'row','index':i,'key':('row',row['id']),'row':row,'selected':i in selected}
    for s in slots:
        page=(s['index']//size)*size
        if s['kind']=='placeholder': s['loading']=page in loading; s['error']=errors.get(page)
    return {'slots':slots,'requests':sorted({(s['index']//size)*size for s in slots if s['kind']=='placeholder' and (s['index']//size)*size not in loading and (s['index']//size)*size not in errors})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':1}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 1}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 2:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':2}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 2}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 3:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':3}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 3}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 4:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':4}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 4}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 5:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':5}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 5}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(total, pages, size, loading, errors, selected, estimate):
    slots=[{'kind':'placeholder','index':i,'key':('placeholder',i),'height':estimate} for i in range(total)]
    for offset,items in pages:
        for j,row in enumerate(items):
            i=offset+j
            if not 0<=i<total: continue
            if i>=len(slots): continue
            slots[i]={'kind':'row','index':i,'key':('row',row['id']),'row':row,'selected':False}
    for s in slots:
        page=(s['index']//size)*size
        if s['kind']=='placeholder': s['loading']=page in loading; s['error']=errors.get(page)
    return {'slots':slots,'requests':sorted({(s['index']//size)*size for s in slots if s['kind']=='placeholder' and (s['index']//size)*size not in loading and (s['index']//size)*size not in errors})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':1}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 1}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 2:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':2}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 2}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 3:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':3}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 3}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 4:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':4}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 4}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

if N == 5:
    check('partial loaded pages', solve(7, [(0,[{'id':'a'},{'id':'b'}]),(4,[{'id':'e','v':5}])], 2, [2], {6:'failed'}, ['e'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': True, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': True, 'error': None}, {'kind': 'row', 'index': 4, 'key': ('row', 'e'), 'row': {'id': 'e', 'v': 5}, 'selected': True}, {'kind': 'placeholder', 'index': 5, 'key': ('placeholder', 5), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 6, 'key': ('placeholder', 6), 'height': 9, 'loading': False, 'error': 'failed'}], 'requests': [4]})
    check('offset loaded rows', solve(5, [(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, ['c'], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': True}, {'kind': 'row', 'index': 3, 'key': ('row', 'd'), 'row': {'id': 'd'}, 'selected': False}, {'kind': 'placeholder', 'index': 4, 'key': ('placeholder', 4), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 4]})
    check('outside total', solve(3, [(-1,[{'id':'x'},{'id':'a'}]),(2,[{'id':'c'},{'id':'d'}])], 2, [], {}, [], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'a'), 'row': {'id': 'a'}, 'selected': False}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'row', 'index': 2, 'key': ('row', 'c'), 'row': {'id': 'c'}, 'selected': False}], 'requests': [0]})
    check('empty table', solve(0, [], 2, [], {}, [], 9), {'slots': [], 'requests': []})
    check('all placeholders', solve(4, [], 2, [], {}, [], 9), {'slots': [{'kind': 'placeholder', 'index': 0, 'key': ('placeholder', 0), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 1, 'key': ('placeholder', 1), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 2, 'key': ('placeholder', 2), 'height': 9, 'loading': False, 'error': None}, {'kind': 'placeholder', 'index': 3, 'key': ('placeholder', 3), 'height': 9, 'loading': False, 'error': None}], 'requests': [0, 2]})
    check('replacement page', solve(2, [(0,[{'id':'a'},{'id':'b'}]),(0,[{'id':'new'}])], 2, [0], {0:'stale'}, ['new'], 9), {'slots': [{'kind': 'row', 'index': 0, 'key': ('row', 'new'), 'row': {'id': 'new'}, 'selected': True}, {'kind': 'row', 'index': 1, 'key': ('row', 'b'), 'row': {'id': 'b'}, 'selected': False}], 'requests': []})

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)

prompt:
The table loaded selection id result violates the stipulated sparse loaded table row slots contract.

Sparse table slots retain absolute indices across unloaded pages, distinguish placeholder and stable row keys, clip loaded pages to declared total, decorate only placeholders with page loading/errors, and schedule each missing nonfailed noninflight page once.

split: open-access