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

N = 1
observations = []
def solve(rows, cols, anchors, hidden_rows, hidden_cols):
    vr=[r for r in rows if r not in hidden_rows]
    vc=[c for c in cols if c not in hidden_cols]
    result=[]
    covered=set()
    for a in anchors:
        rr=[r for r in rows[a['r']:a['r']+a['rs']] if r in vr]
        cc=[c for c in cols[a['c']:a['c']+a['cs']] if c in vc]
        if not rr or not cc: continue
        cells={(r,c) for r in rr for c in cc}
        if cells & covered: continue
        covered |= cells
        result.append({'anchor':[rr[0],cc[0]],'rowspan':len(rr),'colspan':len(cc),'value':a['value'],'covered':sorted(cells-{(rr[0],cc[0])})})
    return {'merges':result,'plain':[(r,c) for r in vr for c in vc if True]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':1}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 1, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 2:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':2}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 2, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 3:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':3}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 3, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 4:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':4}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 4, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 5:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':5}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 5, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

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(rows, cols, anchors, hidden_rows, hidden_cols):
    vr=[r for r in rows if r not in hidden_rows]
    vc=[c for c in cols if c not in hidden_cols]
    result=[]
    covered=set()
    for a in anchors:
        rr=[r for r in rows[a['r']:a['r']+a['rs']] if r in vr]
        cc=[c for c in cols[a['c']:a['c']+a['cs']] if c in vc]
        if not rr or not cc: continue
        cells={(r,c) for r in rr for c in cc}
        if cells & covered: continue
        covered |= cells
        result.append({'anchor':[rr[0],cc[0]],'rowspan':len(rr),'colspan':len(cc),'value':a['value'],'covered':sorted(cells-{(rr[0],cc[0])})})
    return {'merges':result,'plain':[(r,c) for r in vr for c in vc if r not in {x[0] for x in covered}]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':1}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 1, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 2:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':2}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 2, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 3:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':3}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 3, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 4:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':4}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 4, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

if N == 5:
    check('nonzero origin', solve(['r0','r1','r2','r3'], ['a','b','c','d'], [{'r':1,'c':1,'rs':2,'cs':2,'value':5}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 2, 'colspan': 2, 'value': 5, 'covered': [('r1', 'c'), ('r2', 'b'), ('r2', 'c')]}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r0', 'c'), ('r0', 'd'), ('r1', 'a'), ('r1', 'd'), ('r2', 'a'), ('r2', 'd'), ('r3', 'a'), ('r3', 'b'), ('r3', 'c'), ('r3', 'd')]})
    check('hidden anchor', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':3,'cs':3,'value':'x'}], ['r0','r1'], ['a','b']), {'merges': [{'anchor': ['r2', 'c'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': []})
    check('partial overlap', solve(['r0','r1','r2'], ['a','b','c'], [{'r':0,'c':0,'rs':2,'cs':2,'value':'x'},{'r':1,'c':1,'rs':2,'cs':2,'value':'y'}], [], []), {'merges': [{'anchor': ['r0', 'a'], 'rowspan': 2, 'colspan': 2, 'value': 'x', 'covered': [('r0', 'b'), ('r1', 'a'), ('r1', 'b')]}], 'plain': [('r0', 'c'), ('r1', 'c'), ('r2', 'a'), ('r2', 'b'), ('r2', 'c')]})
    check('hidden merge', solve(['r0'], ['a'], [{'r':0,'c':0,'rs':1,'cs':1,'value':'x'}], ['r0'], []), {'merges': [], 'plain': []})
    check('clamped span', solve(['r0','r1'], ['a','b'], [{'r':1,'c':1,'rs':4,'cs':4,'value':'x'}], [], []), {'merges': [{'anchor': ['r1', 'b'], 'rowspan': 1, 'colspan': 1, 'value': 'x', 'covered': []}], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a')]})
    check('unmerged grid', solve(['r0','r1'], ['a','b'], [], [], []), {'merges': [], 'plain': [('r0', 'a'), ('r0', 'b'), ('r1', 'a'), ('r1', 'b')]})

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 plain cell suppression result violates the stipulated merged cell rendering contract.

Merged rectangles are expressed in source coordinates, clipped to source bounds and visible rows/columns, rebased to the first visible cell, and accepted in declaration order only if disjoint; plain cells omit every accepted merged cell.

split: open-access


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

N = 1
observations = []
def solve(rows, selected, page, disabled, mode, excluded):
    known=set(range(len(rows)))
    eligible=[r['id'] for r in rows if r['id'] in page and r['id'] not in disabled]
    active=set(selected) & known
    checked=[r for r in eligible if (r not in excluded if mode=='all' else r in active)]
    return {'eligible':eligible,'checked':checked,'all':bool(eligible) and len(checked)==len(eligible),'mixed':0<len(checked)<len(eligible),'disabled':not eligible,'select_page':sorted(active|set(eligible)),'clear_page':sorted(active-set(eligible)),'off_page':sorted(active-set(page)),'excluded':sorted(set(excluded)&known),'count':len(known-set(excluded)) if mode=='all' else len(active)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(1)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 2:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(2)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 3:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(3)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 4:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(4)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 5:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(5)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

check('variant selected identity', solve([{'id':'a'},{'id':'b'+str(N)}], ['b'+str(N)], ['a','b'+str(N)], [], 'explicit', []), {'eligible':['a','b'+str(N)], 'checked':['b'+str(N)], 'all':False, 'mixed':True, 'disabled':False, 'select_page':['a','b'+str(N)], 'clear_page':[], 'off_page':[], 'excluded':[], 'count':1})
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(rows, selected, page, disabled, mode, excluded):
    known=set(page)
    eligible=[r['id'] for r in rows if r['id'] in page and r['id'] not in disabled]
    active=set(selected) & known
    checked=[r for r in eligible if (r not in excluded if mode=='all' else r in active)]
    return {'eligible':eligible,'checked':checked,'all':bool(eligible) and len(checked)==len(eligible),'mixed':0<len(checked)<len(eligible),'disabled':not eligible,'select_page':sorted(active|set(eligible)),'clear_page':sorted(active-set(eligible)),'off_page':sorted(active-set(page)),'excluded':sorted(set(excluded)&known),'count':len(known-set(excluded)) if mode=='all' else len(active)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(1)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 2:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(2)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 3:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(3)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 4:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(4)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 5:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(5)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

check('variant selected identity', solve([{'id':'a'},{'id':'b'+str(N)}], ['b'+str(N)], ['a','b'+str(N)], [], 'explicit', []), {'eligible':['a','b'+str(N)], 'checked':['b'+str(N)], 'all':False, 'mixed':True, 'disabled':False, 'select_page':['a','b'+str(N)], 'clear_page':[], 'off_page':[], 'excluded':[], 'count':1})
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 stable row key result violates the stipulated table row checkbox reconciliation contract.

Checkbox header state concerns enabled loaded page rows; explicit selections use stable row IDs and survive pagination, global select-all uses exclusions, stale IDs are removed, and empty eligible pages are disabled and unchecked.

split: open-access


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

N = 1
observations = []
def solve(rows, selected, page, disabled, mode, excluded):
    known={r['id'] for r in rows}
    eligible=[r['id'] for r in rows if r['id'] not in disabled]
    active=set(selected) & known
    checked=[r for r in eligible if (r not in excluded if mode=='all' else r in active)]
    return {'eligible':eligible,'checked':checked,'all':bool(eligible) and len(checked)==len(eligible),'mixed':0<len(checked)<len(eligible),'disabled':not eligible,'select_page':sorted(active|set(eligible)),'clear_page':sorted(active-set(eligible)),'off_page':sorted(active-set(page)),'excluded':sorted(set(excluded)&known),'count':len(known-set(excluded)) if mode=='all' else len(active)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(1)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 2:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(2)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 3:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(3)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 4:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(4)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 5:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(5)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

check('variant selected identity', solve([{'id':'a'},{'id':'b'+str(N)}], ['b'+str(N)], ['a','b'+str(N)], [], 'explicit', []), {'eligible':['a','b'+str(N)], 'checked':['b'+str(N)], 'all':False, 'mixed':True, 'disabled':False, 'select_page':['a','b'+str(N)], 'clear_page':[], 'off_page':[], 'excluded':[], 'count':1})
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(rows, selected, page, disabled, mode, excluded):
    known={r['id'] for r in rows}
    eligible=[r['id'] for r in rows if r['id'] in page]
    active=set(selected) & known
    checked=[r for r in eligible if (r not in excluded if mode=='all' else r in active)]
    return {'eligible':eligible,'checked':checked,'all':bool(eligible) and len(checked)==len(eligible),'mixed':0<len(checked)<len(eligible),'disabled':not eligible,'select_page':sorted(active|set(eligible)),'clear_page':sorted(active-set(eligible)),'off_page':sorted(active-set(page)),'excluded':sorted(set(excluded)&known),'count':len(known-set(excluded)) if mode=='all' else len(active)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(1)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 2:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(2)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 3:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(3)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 4:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(4)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 5:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(5)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

check('variant selected identity', solve([{'id':'a'},{'id':'b'+str(N)}], ['b'+str(N)], ['a','b'+str(N)], [], 'explicit', []), {'eligible':['a','b'+str(N)], 'checked':['b'+str(N)], 'all':False, 'mixed':True, 'disabled':False, 'select_page':['a','b'+str(N)], 'clear_page':[], 'off_page':[], 'excluded':[], 'count':1})
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 page scope result violates the stipulated table row checkbox reconciliation contract.

Checkbox header state concerns enabled loaded page rows; explicit selections use stable row IDs and survive pagination, global select-all uses exclusions, stale IDs are removed, and empty eligible pages are disabled and unchecked.

split: open-access


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

N = 1
observations = []
def solve(rows, selected, page, disabled, mode, excluded):
    known={r['id'] for r in rows}
    eligible=[r['id'] for r in rows if r['id'] in page and r['id'] not in disabled]
    active=set(selected)
    checked=[r for r in eligible if (r not in excluded if mode=='all' else r in active)]
    return {'eligible':eligible,'checked':checked,'all':bool(eligible) and len(checked)==len(eligible),'mixed':0<len(checked)<len(eligible),'disabled':not eligible,'select_page':sorted(active|set(eligible)),'clear_page':sorted(active-set(eligible)),'off_page':sorted(active-set(page)),'excluded':sorted(set(excluded)&known),'count':len(known-set(excluded)) if mode=='all' else len(active)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(1)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 2:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(2)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 3:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(3)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 4:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(4)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 5:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(5)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

check('variant selected identity', solve([{'id':'a'},{'id':'b'+str(N)}], ['b'+str(N)], ['a','b'+str(N)], [], 'explicit', []), {'eligible':['a','b'+str(N)], 'checked':['b'+str(N)], 'all':False, 'mixed':True, 'disabled':False, 'select_page':['a','b'+str(N)], 'clear_page':[], 'off_page':[], 'excluded':[], 'count':1})
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(rows, selected, page, disabled, mode, excluded):
    known={r['id'] for r in rows}
    eligible=[r['id'] for r in rows if r['id'] in page and r['id'] not in disabled]
    active=set(selected)&set(page)
    checked=[r for r in eligible if (r not in excluded if mode=='all' else r in active)]
    return {'eligible':eligible,'checked':checked,'all':bool(eligible) and len(checked)==len(eligible),'mixed':0<len(checked)<len(eligible),'disabled':not eligible,'select_page':sorted(active|set(eligible)),'clear_page':sorted(active-set(eligible)),'off_page':sorted(active-set(page)),'excluded':sorted(set(excluded)&known),'count':len(known-set(excluded)) if mode=='all' else len(active)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(1)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 2:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(2)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 3:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(3)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 4:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(4)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

if N == 5:
    check('partial page', solve([{'id':'a'},{'id':'b'},{'id':'c'},{'id':'d'+str(5)}], ['a','c','stale'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b', 'c'], 'clear_page': ['c'], 'off_page': ['c'], 'excluded': [], 'count': 2})
    check('disabled row', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': ['a'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': ['b'], 'off_page': [], 'excluded': [], 'count': 2})
    check('global mode', solve([{'id':'a'},{'id':'b'},{'id':'c'}], [], ['a','b'], [], 'all', ['b','stale']), {'eligible': ['a', 'b'], 'checked': ['a'], 'all': False, 'mixed': True, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': ['b'], 'count': 2})
    check('empty page', solve([{'id':'a'}], ['a'], [], [], 'explicit', []), {'eligible': [], 'checked': [], 'all': False, 'mixed': False, 'disabled': True, 'select_page': ['a'], 'clear_page': ['a'], 'off_page': ['a'], 'excluded': [], 'count': 1})
    check('none checked', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})
    check('full checked', solve([{'id':'a'},{'id':'b'}], ['a','b'], ['a','b'], [], 'explicit', []), {'eligible': ['a', 'b'], 'checked': ['a', 'b'], 'all': True, 'mixed': False, 'disabled': False, 'select_page': ['a', 'b'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 2})
    check('disabled unselected', solve([{'id':'a'},{'id':'b'}], [], ['a','b'], ['b'], 'explicit', []), {'eligible': ['a'], 'checked': [], 'all': False, 'mixed': False, 'disabled': False, 'select_page': ['a'], 'clear_page': [], 'off_page': [], 'excluded': [], 'count': 0})

check('variant selected identity', solve([{'id':'a'},{'id':'b'+str(N)}], ['b'+str(N)], ['a','b'+str(N)], [], 'explicit', []), {'eligible':['a','b'+str(N)], 'checked':['b'+str(N)], 'all':False, 'mixed':True, 'disabled':False, 'select_page':['a','b'+str(N)], 'clear_page':[], 'off_page':[], 'excluded':[], 'count':1})
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 stale selection result violates the stipulated table row checkbox reconciliation contract.

Checkbox header state concerns enabled loaded page rows; explicit selections use stable row IDs and survive pagination, global select-all uses exclusions, stale IDs are removed, and empty eligible pages are disabled and unchecked.

split: open-access