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

N = 1
observations = []
def solve(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[])]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and c==ids[0]]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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 required column visibility result violates the stipulated saved table view restoration contract.

Restore a table view only at matching schema version; deduplicate known order, append new schema columns, keep required columns visible, accept positive-clamped integer nonboolean widths, validate pin sides/density/page-size enums, and ignore removed columns.

split: open-access


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

N = 1
observations = []
def solve(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:w for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:max(0,w) for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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 width floor result violates the stipulated saved table view restoration contract.

Restore a table view only at matching schema version; deduplicate known order, append new schema columns, keep required columns visible, accept positive-clamped integer nonboolean widths, validate pin sides/density/page-size enums, and ignore removed columns.

split: open-access


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

N = 1
observations = []
def solve(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,int)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,(int,float))}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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 width type result violates the stipulated saved table view restoration contract.

Restore a table view only at matching schema version; deduplicate known order, append new schema columns, keep required columns visible, accept positive-clamped integer nonboolean widths, validate pin sides/density/page-size enums, and ignore removed columns.

split: open-access


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

N = 1
observations = []
def solve(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if c in order[:1] and isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p in ('left','right')}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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 width column result violates the stipulated saved table view restoration contract.

Restore a table view only at matching schema version; deduplicate known order, append new schema columns, keep required columns visible, accept positive-clamped integer nonboolean widths, validate pin sides/density/page-size enums, and ignore removed columns.

split: open-access


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

N = 1
observations = []
def solve(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and True}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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(schema, saved, version, defaults):
    ids=[c['id'] for c in schema]
    if saved.get('version')!=version: return defaults
    order=[]
    for c in saved.get('order',[]):
        if c in ids and c not in order: order.append(c)
    order += [c for c in ids if c not in order]
    hidden=[c for c in order if c in saved.get('hidden',[]) and not next((x for x in schema if x['id']==c),{}).get('required')]
    widths={c:max(1,w) for c,w in saved.get('widths',{}).items() if c in ids and isinstance(w,int) and not isinstance(w,bool)}
    pins={c:p for c,p in saved.get('pins',{}).items() if c in ids and p=='left'}
    return {'order':order,'hidden':hidden,'widths':widths,'pins':pins,'density':saved.get('density') if saved.get('density') in ('compact','normal','comfortable') else defaults['density'],'page_size':saved.get('page_size') if saved.get('page_size') in (10,25,50) else defaults['page_size']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':1+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 3, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 2:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':2+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 4, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 3:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':3+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 5, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 4:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':4+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 6, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

if N == 5:
    check('schema evolution', solve([{'id':'a','required':True},{'id':'b'},{'id':'c'}], {'version':2,'order':['b','gone','b'],'hidden':['a','b'],'widths':{'a':5+2,'b':0,'gone':8},'pins':{'a':'right','b':'middle'},'density':'comfortable','page_size':25}, 2, {'density':'normal','page_size':10}), {'order': ['b', 'a', 'c'], 'hidden': ['b'], 'widths': {'a': 7, 'b': 1}, 'pins': {'a': 'right'}, 'density': 'comfortable', 'page_size': 25})
    check('old version', solve([{'id':'a'}], {'version':1}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('missing version', solve([{'id':'a'}], {}, 2, {'density':'normal','page_size':10}), {'density': 'normal', 'page_size': 10})
    check('invalid values', solve([{'id':'a'},{'id':'b'}], {'version':2,'widths':{'a':True,'b':2.5},'density':'wild','page_size':13}, 2, {'density':'normal','page_size':10}), {'order': ['a', 'b'], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'normal', 'page_size': 10})
    check('negative width', solve([{'id':'a'}], {'version':2,'widths':{'a':-4},'pins':{'a':'left'},'density':'normal','page_size':50}, 2, {'density':'compact','page_size':10}), {'order': ['a'], 'hidden': [], 'widths': {'a': 1}, 'pins': {'a': 'left'}, 'density': 'normal', 'page_size': 50})
    check('empty schema', solve([], {'version':2,'order':['gone'],'hidden':['gone'],'widths':{},'pins':{'gone':'left'},'density':'compact','page_size':10}, 2, {'density':'normal','page_size':25}), {'order': [], 'hidden': [], 'widths': {}, 'pins': {}, 'density': 'compact', 'page_size': 10})

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 pin side validation result violates the stipulated saved table view restoration contract.

Restore a table view only at matching schema version; deduplicate known order, append new schema columns, keep required columns visible, accept positive-clamped integer nonboolean widths, validate pin sides/density/page-size enums, and ignore removed columns.

split: open-access