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':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=str(cell)
    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':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='Yes' if cell else '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 boolean cell label 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':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':'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['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':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','left'),'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 column alignment 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':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 True 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':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') and cell 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 link column gate 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(row, pending, response, draft):
    key=(response['row'],response['column'])
    request=pending.get(key)
    if request is None or False: return {'row':row,'pending':sorted(pending.items()),'draft':sorted(draft.items()),'error':None}
    if row['id']!=response['row']: return {'row':row,'pending':sorted(pending.items()),'draft':sorted(draft.items()),'error':None}
    next_pending=dict(pending); next_pending.pop(key)
    if response.get('error') is not None: return {'row':row,'pending':sorted(next_pending.items()),'draft':sorted(draft.items()),'error':response['error']}
    out=dict(row)
    if response['revision']<row['revision']: return {'row':out,'pending':sorted(next_pending.items()),'draft':sorted(draft.items()),'error':'stale'}
    out[response['column']]=response['value']; out['revision']=response['revision']
    next_draft=dict(draft)
    if key in next_draft and next_draft[key]['edit_id']==request['edit_id']: next_draft.pop(key)
    return {'row':out,'pending':sorted(next_pending.items()),'draft':sorted(next_draft.items()),'error':None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(1),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw1', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 2:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(2),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw2', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 3:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(3),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw3', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 4:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(4),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw4', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 5:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(5),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw5', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

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(row, pending, response, draft):
    key=(response['row'],response['column'])
    request=pending.get(key)
    if request is None or request['id']<response['request']: return {'row':row,'pending':sorted(pending.items()),'draft':sorted(draft.items()),'error':None}
    if row['id']!=response['row']: return {'row':row,'pending':sorted(pending.items()),'draft':sorted(draft.items()),'error':None}
    next_pending=dict(pending); next_pending.pop(key)
    if response.get('error') is not None: return {'row':row,'pending':sorted(next_pending.items()),'draft':sorted(draft.items()),'error':response['error']}
    out=dict(row)
    if response['revision']<row['revision']: return {'row':out,'pending':sorted(next_pending.items()),'draft':sorted(draft.items()),'error':'stale'}
    out[response['column']]=response['value']; out['revision']=response['revision']
    next_draft=dict(draft)
    if key in next_draft and next_draft[key]['edit_id']==request['edit_id']: next_draft.pop(key)
    return {'row':out,'pending':sorted(next_pending.items()),'draft':sorted(next_draft.items()),'error':None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(1),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw1', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 2:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(2),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw2', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 3:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(3),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw3', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 4:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(4),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw4', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

if N == 5:
    check('canonical server response', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':' raw '},('r','b'):{'id':3,'edit_id':10,'value':'B'}}, {'row':'r','column':'a','request':2,'revision':8,'value':'raw'+str(5),'warning':'informational'}, {('r','a'):{'edit_id':9,'value':' raw '},('r','b'):{'edit_id':10,'value':'B'}}), {'row': {'id': 'r', 'a': 'raw5', 'revision': 8}, 'pending': [(('r', 'b'), {'id': 3, 'edit_id': 10, 'value': 'B'})], 'draft': [(('r', 'b'), {'edit_id': 10, 'value': 'B'})], 'error': None})
    check('late old request', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':1,'revision':4,'value':'old ack'}, {}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('different row', solve({'id':'other','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {}), {'row': {'id': 'other', 'a': 'old', 'revision': 3}, 'pending': [(('r', 'a'), {'id': 2, 'edit_id': 9, 'value': 'v'})], 'draft': [], 'error': None})
    check('empty error message', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack','error':''}, {('r','a'):{'edit_id':9,'value':'v'}}), {'row': {'id': 'r', 'a': 'old', 'revision': 3}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 9, 'value': 'v'})], 'error': ''})
    check('stale revision', solve({'id':'r','a':'new','revision':7}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':6,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'new', 'revision': 7}, 'pending': [], 'draft': [], 'error': 'stale'})
    check('equal revision allowed', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':3,'value':'ack'}, {}), {'row': {'id': 'r', 'a': 'ack', 'revision': 3}, 'pending': [], 'draft': [], 'error': None})
    check('new edit same value', solve({'id':'r','a':'old','revision':3}, {('r','a'):{'id':2,'edit_id':9,'value':'v'}}, {'row':'r','column':'a','request':2,'revision':4,'value':'ack'}, {('r','a'):{'edit_id':10,'value':'v'}}), {'row': {'id': 'r', 'a': 'ack', 'revision': 4}, 'pending': [], 'draft': [(('r', 'a'), {'edit_id': 10, 'value': 'v'})], 'error': None})

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 ack request match result violates the stipulated asynchronous table cell save acknowledgement contract.

A save acknowledgement belongs to an exact pending request and row, clears only that pending cell, preserves errors and newer edits, rejects older server revisions, installs canonical server values/revisions, and clears a draft only when the original edit ID still owns it.

split: open-access