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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('icon_width',0) for c in eligible]
    if include_header: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+2*c.get('indent',0)+c.get('icon_width',0) for c in eligible]
    if include_header: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

prompt:
The table tree indent width result violates the stipulated table column auto-fit measurement contract.

Auto-fit measures only this column’s visible measured cells, includes indentation and cell icons, optionally measures header text plus both controls, takes the widest content, adds two-sided padding and reserved icons, clamps bounds, and reports changes in either direction.

split: open-access


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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0) for c in eligible]
    if include_header: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0)+icons for c in eligible]
    if include_header: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

prompt:
The table cell icon width result violates the stipulated table column auto-fit measurement contract.

Auto-fit measures only this column’s visible measured cells, includes indentation and cell icons, optionally measures header text plus both controls, takes the widest content, adds two-sided padding and reserved icons, clamps bounds, and reports changes in either direction.

split: open-access


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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0)+c.get('icon_width',0) for c in eligible]
    if include_header: widths.append(header['text_width'])
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0)+c.get('icon_width',0) for c in eligible]
    if include_header: widths.append(header['text_width']+max(header.get('sort_width',0),header.get('menu_width',0)))
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

prompt:
The table header control width result violates the stipulated table column auto-fit measurement contract.

Auto-fit measures only this column’s visible measured cells, includes indentation and cell icons, optionally measures header text plus both controls, takes the widest content, adds two-sided padding and reserved icons, clamps bounds, and reports changes in either direction.

split: open-access


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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0)+c.get('icon_width',0) for c in eligible]
    if True: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0)+c.get('icon_width',0) for c in eligible]
    if include_header and eligible: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=max(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

prompt:
The table header measure policy result violates the stipulated table column auto-fit measurement contract.

Auto-fit measures only this column’s visible measured cells, includes indentation and cell icons, optionally measures header text plus both controls, takes the widest content, adds two-sided padding and reserved icons, clamps bounds, and reports changes in either direction.

split: open-access


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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0)+c.get('icon_width',0) for c in eligible]
    if include_header: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=min(widths,default=0)
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

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

N = 1
observations = []
def solve(column, cells, header, padding, minimum, maximum, include_header, icons, current):
    eligible=[c for c in cells if c['column']==column and not c.get('hidden') and c.get('measured',True)]
    widths=[c['text_width']+c.get('indent',0)+c.get('icon_width',0) for c in eligible]
    if include_header: widths.append(header['text_width']+header.get('sort_width',0)+header.get('menu_width',0))
    content=sum(widths)//len(widths) if widths else 0
    result=max(minimum,min(maximum,content+2*padding+icons))
    return {'width':result,'changed':result!=current,'samples':len(eligible),'header_used':include_header,'clipped':content+2*padding+icons>maximum}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':1+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 21, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 2:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':2+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 22, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 3:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':3+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 23, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 4:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':4+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 24, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

if N == 5:
    check('varied cell decorations', solve('amount', [{'column':'amount','text_width':5+8,'indent':3,'icon_width':4},{'column':'amount','text_width':7},{'column':'other','text_width':90}], {'text_width':5,'sort_width':3,'menu_width':2}, 2, 1, 100, True, 1, 30), {'width': 25, 'changed': True, 'samples': 2, 'header_used': True, 'clipped': False})
    check('hidden and unmeasured', solve('a', [{'column':'a','text_width':90,'hidden':True},{'column':'a','text_width':80,'measured':False},{'column':'a','text_width':4,'offscreen':True}], {'text_width':2}, 1, 1, 100, False, 0, 6), {'width': 6, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('header wider', solve('a', [{'column':'a','text_width':2}], {'text_width':8,'sort_width':3,'menu_width':2}, 1, 1, 100, True, 0, 1), {'width': 15, 'changed': True, 'samples': 1, 'header_used': True, 'clipped': False})
    check('header excluded', solve('a', [{'column':'a','text_width':2}], {'text_width':30}, 1, 1, 100, False, 0, 4), {'width': 4, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': False})
    check('empty with header', solve('a', [], {'text_width':10}, 2, 1, 100, True, 0, 1), {'width': 14, 'changed': True, 'samples': 0, 'header_used': True, 'clipped': False})
    check('clipped sample', solve('a', [{'column':'a','text_width':50}], {'text_width':2}, 2, 5, 20, False, 1, 20), {'width': 20, 'changed': False, 'samples': 1, 'header_used': False, 'clipped': True})
    check('empty without header', solve('a', [], {'text_width':10}, 0, 5, 20, False, 0, 5), {'width': 5, 'changed': False, 'samples': 0, 'header_used': False, 'clipped': False})

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

prompt:
The table widest cell selection result violates the stipulated table column auto-fit measurement contract.

Auto-fit measures only this column’s visible measured cells, includes indentation and cell icons, optionally measures header text plus both controls, takes the widest content, adds two-sided padding and reserved icons, clamps bounds, and reports changes in either direction.

split: open-access