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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if False: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if len(unknown)>1: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The table unknown row reject result violates the stipulated atomic table row editing contract.

Row commits validate the merged draft atomically, reject unknown schema fields, ignore readonly fields, preserve untouched cells and stable identity, reject revision conflicts, suppress no-ops, and increment the revision only after actual changes.

split: open-access


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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if False: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if len(errors)>1: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The table row atomic validation result violates the stipulated atomic table row editing contract.

Row commits validate the merged draft atomically, reject unknown schema fields, ignore readonly fields, preserve untouched cells and stable identity, reject revision conflicts, suppress no-ops, and increment the revision only after actual changes.

split: open-access


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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if False: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision>revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The table row version gate result violates the stipulated atomic table row editing contract.

Row commits validate the merged draft atomically, reject unknown schema fields, ignore readonly fields, preserve untouched cells and stable identity, reject revision conflicts, suppress no-ops, and increment the revision only after actual changes.

split: open-access


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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if False: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not draft: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The table noop row status result violates the stipulated atomic table row editing contract.

Row commits validate the merged draft atomically, reject unknown schema fields, ignore readonly fields, preserve untouched cells and stable identity, reject revision conflicts, suppress no-ops, and increment the revision only after actual changes.

split: open-access


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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated={}; updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated={k:v for k,v in row.items() if k in allowed}; updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision+1}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The table untouched cell preservation result violates the stipulated atomic table row editing contract.

Row commits validate the merged draft atomically, reject unknown schema fields, ignore readonly fields, preserve untouched cells and stable identity, reject revision conflicts, suppress no-ops, and increment the revision only after actual changes.

split: open-access


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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(row, draft, schema, revision, base_revision):
    allowed={c['id'] for c in schema if c.get('editable',True)}
    unknown=sorted(set(draft)-{c['id'] for c in schema})
    changes={k:v for k,v in draft.items() if k in allowed and row.get(k)!=v}
    errors={c['id']:'required' for c in schema if c.get('required') and draft.get(c['id'],row.get(c['id'])) in ('',None)}
    if unknown: return {'status':'unknown','fields':unknown,'row':row}
    if errors: return {'status':'invalid','fields':errors,'row':row}
    if base_revision!=revision: return {'status':'conflict','fields':[],'row':row}
    if not changes: return {'status':'unchanged','fields':[],'row':row}
    updated=dict(row); updated.update(changes)
    return {'status':'saved','fields':sorted(changes),'row':updated,'revision':base_revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':1+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 4, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 2:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':2+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 5, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 3:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':3+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 6, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 4:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':4+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 7, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

if N == 5:
    check('partial draft', solve({'id':'r','a':1,'b':2}, {'a':5+3}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'saved', 'fields': ['a'], 'row': {'id': 'r', 'a': 8, 'b': 2}, 'revision': 5})
    check('readonly draft', solve({'id':'r','a':1,'b':2}, {'b':9}, [{'id':'a'},{'id':'b','editable':False}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1, 'b': 2}})
    check('unknown draft', solve({'id':'r','a':1}, {'missing':2}, [{'id':'a'}], 4, 4), {'status': 'unknown', 'fields': ['missing'], 'row': {'id': 'r', 'a': 1}})
    check('required clear', solve({'id':'r','a':'ok','b':2}, {'a':''}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'invalid', 'fields': {'a': 'required'}, 'row': {'id': 'r', 'a': 'ok', 'b': 2}})
    check('required untouched', solve({'id':'r','a':'ok','b':2}, {'b':0}, [{'id':'a','required':True},{'id':'b'}], 4, 4), {'status': 'saved', 'fields': ['b'], 'row': {'id': 'r', 'a': 'ok', 'b': 0}, 'revision': 5})
    check('stale row', solve({'id':'r','a':1}, {'a':2}, [{'id':'a'}], 4, 3), {'status': 'conflict', 'fields': [], 'row': {'id': 'r', 'a': 1}})
    check('same value', solve({'id':'r','a':1}, {'a':1}, [{'id':'a'}], 4, 4), {'status': 'unchanged', 'fields': [], 'row': {'id': 'r', 'a': 1}})

print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The table row version increment result violates the stipulated atomic table row editing contract.

Row commits validate the merged draft atomically, reject unknown schema fields, ignore readonly fields, preserve untouched cells and stable identity, reject revision conflicts, suppress no-ops, and increment the revision only after actual changes.

split: open-access