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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,1)+1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
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 duplicate label counter result violates the stipulated table export projection contract.

Exports distinguish all source rows from current view rows and selected view rows; preserve view/schema order, omit forbidden columns, optionally include hidden columns, distinguish raw/display values with fallback, and disambiguate duplicate human labels in encounter order.

split: open-access


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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else label)
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else c['id'])
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
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 duplicate label suffix result violates the stipulated table export projection contract.

Exports distinguish all source rows from current view rows and selected view rows; preserve view/schema order, omit forbidden columns, optionally include hidden columns, distinguish raw/display values with fallback, and disambiguate duplicate human labels in encounter order.

split: open-access


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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id']) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get(c['id']) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
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 formatted value fallback result violates the stipulated table export projection contract.

Exports distinguish all source rows from current view rows and selected view rows; preserve view/schema order, omit forbidden columns, optionally include hidden columns, distinguish raw/display values with fallback, and disambiguate duplicate human labels in encounter order.

split: open-access


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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if True else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if False else r.get(c['id']) for c in cols])
    return {'columns':[c['id'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
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 explicit raw export result violates the stipulated table export projection contract.

Exports distinguish all source rows from current view rows and selected view rows; preserve view/schema order, omit forbidden columns, optionally include hidden columns, distinguish raw/display values with fallback, and disambiguate duplicate human labels in encounter order.

split: open-access


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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':sorted(c['id'] for c in cols),'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rows, columns, view_ids, scope, hidden, include_hidden, selected, values):
    by={r['id']:r for r in rows}
    ids=[r['id'] for r in rows] if scope=='all' else [k for k in view_ids if k in by]
    if scope=='selected': ids=[k for k in ids if k in selected]
    cols=[c for c in columns if c.get('export',True) and (include_hidden or c['id'] not in hidden)]
    labels=[]; counts={}
    for c in cols:
        label=c['label']; counts[label]=counts.get(label,0)+1
        labels.append(label if counts[label]==1 else label+' ('+str(counts[label])+')')
    records=[]
    for key in ids:
        r=by[key]
        records.append([r.get('_formatted',{}).get(c['id'],r.get(c['id'])) if values=='display' else r.get(c['id']) for c in cols])
    return {'columns':[c['label'] for c in cols],'labels':labels,'records':records,'row_ids':ids,'scope':scope}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('filtered view display', solve([{'id':'a','z':1,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 2:
    check('filtered view display', solve([{'id':'a','z':2,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 3:
    check('filtered view display', solve([{'id':'a','z':3,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 4:
    check('filtered view display', solve([{'id':'a','z':4,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

if N == 5:
    check('filtered view display', solve([{'id':'a','z':5,'b':2,'_formatted':{'z':'one'}},{'id':'b','z':3,'b':4},{'id':'c','z':5,'b':6}], [{'id':'z','label':'Value'},{'id':'b','label':'Value'}], ['b','a','gone'], 'view', [], False, [], 'display'), {'columns': ['z', 'b'], 'labels': ['Value', 'Value (2)'], 'records': [[3, 4], ['one', 2]], 'row_ids': ['b', 'a'], 'scope': 'view'})
    check('selected on view', solve([{'id':'a','z':1},{'id':'b','z':2},{'id':'c','z':3}], [{'id':'z','label':'Z'}], ['b','a'], 'selected', [], False, ['a','c'], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1]], 'row_ids': ['a'], 'scope': 'selected'})
    check('all records', solve([{'id':'a','z':1},{'id':'b','z':2}], [{'id':'z','label':'Z'}], ['b'], 'all', [], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[1], [2]], 'row_ids': ['a', 'b'], 'scope': 'all'})
    check('hidden requested', solve([{'id':'a','z':1,'b':2,'p':3}], [{'id':'z','label':'Z'},{'id':'b','label':'B'},{'id':'p','label':'Private','export':False}], ['a'], 'view', ['b'], True, [], 'raw'), {'columns': ['z', 'b'], 'labels': ['Z', 'B'], 'records': [[1, 2]], 'row_ids': ['a'], 'scope': 'view'})
    check('hidden omitted raw', solve([{'id':'a','z':0,'b':2,'_formatted':{'z':'zero'}}], [{'id':'z','label':'Z'},{'id':'b','label':'B'}], ['a'], 'view', ['b'], False, [], 'raw'), {'columns': ['z'], 'labels': ['Z'], 'records': [[0]], 'row_ids': ['a'], 'scope': 'view'})
    check('no rows', solve([], [{'id':'z','label':'Z'}], [], 'view', [], False, [], 'display'), {'columns': ['z'], 'labels': ['Z'], 'records': [], 'row_ids': [], 'scope': 'view'})

check('variant formatted export value', solve([{'id':'r','x':N,'_formatted':{'x':'value'+str(N)}}], [{'id':'x','label':'X'}], ['r'], 'view', [], False, [], 'display'), {'columns':['x'], 'labels':['X'], 'records':[['value'+str(N)]], 'row_ids':['r'], 'scope':'view'})
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 export column order result violates the stipulated table export projection contract.

Exports distinguish all source rows from current view rows and selected view rows; preserve view/schema order, omit forbidden columns, optionally include hidden columns, distinguish raw/display values with fallback, and disambiguate duplicate human labels in encounter order.

split: open-access