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

N = 1
observations = []
def solve(rows, columns, x, y, header, scroll_y, scroll_x, width, left_ids, right_ids):
    if y<header: return {'region':'header','row':None,'column':None}
    body_y=y-header+scroll_y
    r=None; cursor=0
    for row in rows:
        if cursor<=body_y<cursor+row['height']: r=row['id']; break
        cursor+=row['height']
    left=[c for c in columns if c['id'] in left_ids]
    right=[c for c in columns if c['id'] in right_ids and c['id'] not in left_ids]
    center=[c for c in columns if c['id'] not in left_ids and c['id'] not in right_ids]
    lw=sum(c['width'] for c in left); rw=sum(c['width'] for c in right)
    if not 0<=x<width: return {'region':'outside','row':r,'column':None}
    if x<lw: pane=left; local=x; region='left'
    elif x>=width-rw: pane=right; local=x-(width-rw); region='right'
    else: pane=center; local=x-lw+scroll_x; region='center'
    col=None; cursor=0
    for c in pane:
        if cursor<=local<=cursor+c['width']: col=c['id']; break
        cursor+=c['width']
    return {'region':region,'row':r,'column':col}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':1+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 2:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':2+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 3:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':3+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 4:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':4+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 5:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':5+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

check('variant measured row boundary', solve([{'id':'r0','height':N+2},{'id':'r1','height':10}], [{'id':'x','width':4}], 1, 7, 2, 0, 0, 4, [], []), {'region':'center','row':'r1' if N<=3 else 'r0','column':'x'})
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, columns, x, y, header, scroll_y, scroll_x, width, left_ids, right_ids):
    if y<header: return {'region':'header','row':None,'column':None}
    body_y=y-header+scroll_y
    r=None; cursor=0
    for row in rows:
        if cursor<=body_y<cursor+row['height']: r=row['id']; break
        cursor+=row['height']
    left=[c for c in columns if c['id'] in left_ids]
    right=[c for c in columns if c['id'] in right_ids and c['id'] not in left_ids]
    center=[c for c in columns if c['id'] not in left_ids and c['id'] not in right_ids]
    lw=sum(c['width'] for c in left); rw=sum(c['width'] for c in right)
    if not 0<=x<width: return {'region':'outside','row':r,'column':None}
    if x<lw: pane=left; local=x; region='left'
    elif x>=width-rw: pane=right; local=x-(width-rw); region='right'
    else: pane=center; local=x-lw+scroll_x; region='center'
    col=None; cursor=0
    for c in pane:
        if cursor<local<cursor+c['width']: col=c['id']; break
        cursor+=c['width']
    return {'region':region,'row':r,'column':col}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':1+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 2:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':2+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 3:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':3+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 4:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':4+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

if N == 5:
    check('center scroll', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 5, 3, 2, 4, 4, 18, ['a'], ['d']), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('exact row column edges', solve([{'id':'r0','height':5},{'id':'r1','height':7}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 8, 7, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r1', 'column': 'c'})
    check('right pinned cell', solve([{'id':'r0','height':5+5}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':4},{'id':'d','width':3}], 13, 2, 2, 0, 2, 15, ['a'], ['c','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('left boundary', solve([{'id':'r0','height':5}], [{'id':'a','width':3},{'id':'b','width':5}], 3, 2, 2, 0, 0, 8, ['a'], []), {'region': 'center', 'row': 'r0', 'column': 'b'})
    check('overlapping pin assignment', solve([{'id':'r0','height':5}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 10, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'right', 'row': 'r0', 'column': 'd'})
    check('outside right edge', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], 3, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('negative x', solve([{'id':'r0','height':5}], [{'id':'a','width':3}], -1, 3, 2, 0, 0, 3, [], []), {'region': 'outside', 'row': 'r0', 'column': None})
    check('header offset crossing', solve([{'id':'r0','height':5},{'id':'r1','height':5}], [{'id':'a','width':3}], 1, 5, 2, 0, 0, 3, ['a'], []), {'region': 'left', 'row': 'r0', 'column': 'a'})
    check('overlap pin edge', solve([{'id':'r','height':8}], [{'id':'a','width':2},{'id':'b','width':3},{'id':'c','width':4},{'id':'d','width':5}], 6, 3, 2, 0, 0, 14, ['a','b'], ['b','d']), {'region': 'center', 'row': 'r', 'column': 'c'})
    check('center blank area', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6},{'id':'d','width':4}], 15, 3, 2, 0, 0, 30, ['a'], ['d']), {'region': 'center', 'row': 'r', 'column': None})
    check('left pane interior', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5}], 1, 3, 2, 0, 0, 8, ['a'], []), {'region': 'left', 'row': 'r', 'column': 'a'})
    check('center local origin', solve([{'id':'r','height':8}], [{'id':'a','width':3},{'id':'b','width':5},{'id':'c','width':6}], 6, 3, 2, 0, 0, 14, ['a'], []), {'region': 'center', 'row': 'r', 'column': 'b'})
    check('header region', solve([], [], 1, 1, 2, 0, 0, 3, [], []), {'region': 'header', 'row': None, 'column': None})

check('variant measured row boundary', solve([{'id':'r0','height':N+2},{'id':'r1','height':10}], [{'id':'x','width':4}], 1, 7, 2, 0, 0, 4, [], []), {'region':'center','row':'r1' if N<=3 else 'r0','column':'x'})
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 column hit halfopen result violates the stipulated table pane cell hit testing contract.

Hit testing subtracts header height, adds body scroll, applies half-open row/column extents, partitions left/right/center panes with left precedence, transforms right pinned and center-scrolled coordinates independently, and rejects coordinates outside the table viewport.

split: open-access


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

N = 1
observations = []
def solve(cell, column, row, selected, editing, pending, errors, stale):
    key=(row['id'],column.get('label',column['id']))
    if key in editing: return {'kind':'editor','value':editing[key],'selected':key in selected}
    if key in errors: return {'kind':'error','value':cell,'message':errors[key],'retry':key not in pending}
    if key in pending: return {'kind':'pending','value':cell,'dim':True}
    if row.get('placeholder'): return {'kind':'skeleton','value':None}
    if cell is None: text=column.get('null_text','')
    elif isinstance(cell,bool): text=column.get('true_text','Yes') if cell else column.get('false_text','No')
    else: text=str(cell)
    return {'kind':'cell','text':text,'align':column.get('align','start'),'selected':key in selected,'stale':key in stale,'link':row.get('_links',{}).get(column['id']) if column.get('link') else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('editor over errors', solve(1, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 2:
    check('editor over errors', solve(2, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 3:
    check('editor over errors', solve(3, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 4:
    check('editor over errors', solve(4, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 5:
    check('editor over errors', solve(5, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

check('variant active editor draft', solve(0, {'id':'a'}, {'id':'r'}, [], {('r','a'):N}, [], {}, []), {'kind':'editor','value':N,'selected':False})
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(cell, column, row, selected, editing, pending, errors, stale):
    key=(row.get('index'),column['id'])
    if key in editing: return {'kind':'editor','value':editing[key],'selected':key in selected}
    if key in errors: return {'kind':'error','value':cell,'message':errors[key],'retry':key not in pending}
    if key in pending: return {'kind':'pending','value':cell,'dim':True}
    if row.get('placeholder'): return {'kind':'skeleton','value':None}
    if cell is None: text=column.get('null_text','')
    elif isinstance(cell,bool): text=column.get('true_text','Yes') if cell else column.get('false_text','No')
    else: text=str(cell)
    return {'kind':'cell','text':text,'align':column.get('align','start'),'selected':key in selected,'stale':key in stale,'link':row.get('_links',{}).get(column['id']) if column.get('link') else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('editor over errors', solve(1, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 2:
    check('editor over errors', solve(2, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 3:
    check('editor over errors', solve(3, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 4:
    check('editor over errors', solve(4, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 5:
    check('editor over errors', solve(5, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

check('variant active editor draft', solve(0, {'id':'a'}, {'id':'r'}, [], {('r','a'):N}, [], {}, []), {'kind':'editor','value':N,'selected':False})
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 editor cell identity result violates the stipulated table cell renderer state precedence contract.

A table cell renders editor before error before pending before placeholder; retry excludes pending requests, ordinary cells distinguish None/empty/zero/boolean, respect column alignment and link policy, and all per-cell states use stable row-column identity.

split: open-access


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

N = 1
observations = []
def solve(cell, column, row, selected, editing, pending, errors, stale):
    key=(row['id'],column['id'])
    if key in editing and key not in errors: return {'kind':'editor','value':editing[key],'selected':key in selected}
    if key in errors: return {'kind':'error','value':cell,'message':errors[key],'retry':key not in pending}
    if key in pending: return {'kind':'pending','value':cell,'dim':True}
    if row.get('placeholder'): return {'kind':'skeleton','value':None}
    if cell is None: text=column.get('null_text','')
    elif isinstance(cell,bool): text=column.get('true_text','Yes') if cell else column.get('false_text','No')
    else: text=str(cell)
    return {'kind':'cell','text':text,'align':column.get('align','start'),'selected':key in selected,'stale':key in stale,'link':row.get('_links',{}).get(column['id']) if column.get('link') else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('editor over errors', solve(1, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 2:
    check('editor over errors', solve(2, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 3:
    check('editor over errors', solve(3, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 4:
    check('editor over errors', solve(4, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 5:
    check('editor over errors', solve(5, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

check('variant active editor draft', solve(0, {'id':'a'}, {'id':'r'}, [], {('r','a'):N}, [], {}, []), {'kind':'editor','value':N,'selected':False})
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(cell, column, row, selected, editing, pending, errors, stale):
    key=(row['id'],column['id'])
    if key in editing and key not in pending: return {'kind':'editor','value':editing[key],'selected':key in selected}
    if key in errors: return {'kind':'error','value':cell,'message':errors[key],'retry':key not in pending}
    if key in pending: return {'kind':'pending','value':cell,'dim':True}
    if row.get('placeholder'): return {'kind':'skeleton','value':None}
    if cell is None: text=column.get('null_text','')
    elif isinstance(cell,bool): text=column.get('true_text','Yes') if cell else column.get('false_text','No')
    else: text=str(cell)
    return {'kind':'cell','text':text,'align':column.get('align','start'),'selected':key in selected,'stale':key in stale,'link':row.get('_links',{}).get(column['id']) if column.get('link') else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('editor over errors', solve(1, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 2:
    check('editor over errors', solve(2, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 3:
    check('editor over errors', solve(3, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 4:
    check('editor over errors', solve(4, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 5:
    check('editor over errors', solve(5, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

check('variant active editor draft', solve(0, {'id':'a'}, {'id':'r'}, [], {('r','a'):N}, [], {}, []), {'kind':'editor','value':N,'selected':False})
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 editor state priority result violates the stipulated table cell renderer state precedence contract.

A table cell renders editor before error before pending before placeholder; retry excludes pending requests, ordinary cells distinguish None/empty/zero/boolean, respect column alignment and link policy, and all per-cell states use stable row-column identity.

split: open-access


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

N = 1
observations = []
def solve(cell, column, row, selected, editing, pending, errors, stale):
    key=(row['id'],column['id'])
    if key in editing: return {'kind':'editor','value':editing[key],'selected':key in selected}
    if key in errors: return {'kind':'error','value':cell,'message':str(cell),'retry':key not in pending}
    if key in pending: return {'kind':'pending','value':cell,'dim':True}
    if row.get('placeholder'): return {'kind':'skeleton','value':None}
    if cell is None: text=column.get('null_text','')
    elif isinstance(cell,bool): text=column.get('true_text','Yes') if cell else column.get('false_text','No')
    else: text=str(cell)
    return {'kind':'cell','text':text,'align':column.get('align','start'),'selected':key in selected,'stale':key in stale,'link':row.get('_links',{}).get(column['id']) if column.get('link') else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('editor over errors', solve(1, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 2:
    check('editor over errors', solve(2, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 3:
    check('editor over errors', solve(3, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 4:
    check('editor over errors', solve(4, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 5:
    check('editor over errors', solve(5, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

check('variant active editor draft', solve(0, {'id':'a'}, {'id':'r'}, [], {('r','a'):N}, [], {}, []), {'kind':'editor','value':N,'selected':False})
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(cell, column, row, selected, editing, pending, errors, stale):
    key=(row['id'],column['id'])
    if key in editing: return {'kind':'editor','value':editing[key],'selected':key in selected}
    if key in errors: return {'kind':'error','value':cell,'message':'Error','retry':key not in pending}
    if key in pending: return {'kind':'pending','value':cell,'dim':True}
    if row.get('placeholder'): return {'kind':'skeleton','value':None}
    if cell is None: text=column.get('null_text','')
    elif isinstance(cell,bool): text=column.get('true_text','Yes') if cell else column.get('false_text','No')
    else: text=str(cell)
    return {'kind':'cell','text':text,'align':column.get('align','start'),'selected':key in selected,'stale':key in stale,'link':row.get('_links',{}).get(column['id']) if column.get('link') else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('editor over errors', solve(1, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 2:
    check('editor over errors', solve(2, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 3:
    check('editor over errors', solve(3, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 4:
    check('editor over errors', solve(4, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

if N == 5:
    check('editor over errors', solve(5, {'id':'a','label':'Amount'}, {'id':'r','index':0}, [('r','a')], {('r','a'):5}, [('r','a')], {('r','a'):'Bad value'}, []), {'kind': 'editor', 'value': 5, 'selected': True})
    check('error pending retry', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': False})
    check('error retry allowed', solve(2, {'id':'a'}, {'id':'r'}, [], {}, [], {('r','a'):'Required'}, []), {'kind': 'error', 'value': 2, 'message': 'Required', 'retry': True})
    check('pending content', solve(3, {'id':'a'}, {'id':'r'}, [], {}, [('r','a')], {}, []), {'kind': 'pending', 'value': 3, 'dim': True})
    check('placeholder row', solve(4, {'id':'a'}, {'id':'r','placeholder':True}, [], {}, [], {}, []), {'kind': 'skeleton', 'value': None})
    check('false custom label', solve(False, {'id':'a','true_text':'On','false_text':'Off','align':'center'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'Off', 'align': 'center', 'selected': False, 'stale': False, 'link': None})
    check('zero link', solve(0, {'id':'a','null_text':'N/A','link':True,'align':'end'}, {'id':'r','_links':{'a':'/zero'}}, [('r','a')], {}, [], {}, [('r','a')]), {'kind': 'cell', 'text': '0', 'align': 'end', 'selected': True, 'stale': True, 'link': '/zero'})
    check('empty string distinct null', solve('', {'id':'a','null_text':'N/A'}, {'id':'r','_links':{'a':'/hidden'}}, [], {}, [], {}, []), {'kind': 'cell', 'text': '', 'align': 'start', 'selected': False, 'stale': False, 'link': None})
    check('null text', solve(None, {'id':'a','null_text':'N/A'}, {'id':'r'}, [], {}, [], {}, []), {'kind': 'cell', 'text': 'N/A', 'align': 'start', 'selected': False, 'stale': False, 'link': None})

check('variant active editor draft', solve(0, {'id':'a'}, {'id':'r'}, [], {('r','a'):N}, [], {}, []), {'kind':'editor','value':N,'selected':False})
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 error message value result violates the stipulated table cell renderer state precedence contract.

A table cell renders editor before error before pending before placeholder; retry excludes pending requests, ordinary cells distinguish None/empty/zero/boolean, respect column alignment and link policy, and all per-cell states use stable row-column identity.

split: open-access