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

N = 1
observations = []
def solve(d):
    matched=set(d['matches'])&set(d['rows'])
    context={a for x in matched for a in d['ancestors'].get(x,[])}
    projected=[x for x in d['rows'] if x in matched|context]
    opened=sorted(set(d['saved_open'])|context)
    selected=d['selected']
    focus=d['focus'] if d['focus'] in projected else next((a for a in reversed(d['ancestors'].get(d['focus'],[])) if a in projected),(projected[0] if projected else None))
    positions={x:1+sum(d['parents'].get(y)==d['parents'].get(x) for y in projected[:i]) for i,x in enumerate(projected)}
    sizes={x:sum(d['parents'].get(y)==d['parents'].get(x) for y in projected) for x in projected}
    context_only=[x for x in projected if x not in matched]
    empty=not d['rows']
    return [projected,opened,selected,focus,positions,sizes,context_only,empty]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 2: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 3: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 4: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 5: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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(d):
    matched=set(d['matches'])&set(d['rows'])
    context={a for x in matched for a in d['ancestors'].get(x,[])}
    projected=[x for x in d['rows'] if x in matched|context]
    opened=sorted(set(d['saved_open'])|context)
    selected=d['selected']
    focus=d['focus'] if d['focus'] in projected else next((a for a in reversed(d['ancestors'].get(d['focus'],[])) if a in projected),(projected[0] if projected else None))
    positions={x:1+sum(d['parents'].get(y)==d['parents'].get(x) for y in projected[:i]) for i,x in enumerate(projected)}
    sizes={x:sum(d['parents'].get(y)==d['parents'].get(x) for y in projected) for x in projected}
    context_only=[x for x in projected if x not in matched]
    empty=not context
    return [projected,opened,selected,focus,positions,sizes,context_only,empty]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 2: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 3: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 4: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])], 5: [('deep match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False]), ('missing match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['b', 'gone'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z', 'a'], False]), ('ancestor match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['a', 'b'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['z', 'a', 'b'], ['a', 'q', 'z'], ['c', 'q'], 'a', {'z': 1, 'a': 1, 'b': 1}, {'z': 1, 'a': 1, 'b': 1}, ['z'], False]), ('no matches', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': [], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [[], ['q'], ['c', 'q'], None, {}, {}, [], True]), ('root match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'c'}, [['q'], ['q'], ['c', 'q'], 'q', {'q': 1}, {'q': 1}, [], False]), ('focused match', {'rows': ['z', 'a', 'b', 'c', 'q', 'v0', 'v1', 'v2', 'v3', 'v4'], 'matches': ['b', 'q'], 'ancestors': {'z': [], 'a': ['z'], 'b': ['z', 'a'], 'c': ['z', 'a'], 'q': [], 'gone': ['ghost']}, 'parents': {'z': None, 'a': 'z', 'b': 'a', 'c': 'a', 'q': None}, 'saved_open': ['q'], 'selected': ['c', 'q'], 'focus': 'b'}, [['z', 'a', 'b', 'q'], ['a', 'q', 'z'], ['c', 'q'], 'b', {'z': 1, 'a': 1, 'b': 1, 'q': 2}, {'z': 2, 'a': 1, 'b': 1, 'q': 2}, ['z', 'a'], False])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
Empty-result state is inferred from original tree produces the wrong hierarchical widget state in a regression fixture.

Matching rows retain all ancestors as context. Context-only branches auto-open without changing saved expansion. Selection remains by ID across filtering; focus hidden by the filter returns to nearest projected ancestor. Sibling positions are recomputed among projected children.

split: open-access


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

N = 1
observations = []
def solve(d):
    cols=[x for x in d['columns'] if True]
    editable=[x for x in cols if x in d['editable']]
    enter=d['command']=='enter' and bool(editable) and not d['row_disabled']
    escape=d['command']=='escape'
    mode='row' if escape else ('cell' if enter else d['mode'])
    cell=(editable[0] if enter else d['cell']) if mode=='cell' else None
    cell=cell if cell in cols else (cols[0] if mode=='cell' and cols else None)
    active=d['row']+':'+cell if mode=='cell' and cell is not None else d['row']
    rowtab=0 if mode=='row' else -1
    celltabs={x:(0 if mode=='cell' and x==cell else -1) for x in cols}
    expanded=d['expanded']
    return [mode,cell,active,rowtab,celltabs,expanded]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('enter', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 2: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 3: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 4: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 5: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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(d):
    cols=[x for x in d['columns'] if x in d['hidden']]
    editable=[x for x in cols if x in d['editable']]
    enter=d['command']=='enter' and bool(editable) and not d['row_disabled']
    escape=d['command']=='escape'
    mode='row' if escape else ('cell' if enter else d['mode'])
    cell=(editable[0] if enter else d['cell']) if mode=='cell' else None
    cell=cell if cell in cols else (cols[0] if mode=='cell' and cols else None)
    active=d['row']+':'+cell if mode=='cell' and cell is not None else d['row']
    rowtab=0 if mode=='row' else -1
    celltabs={x:(0 if mode=='cell' and x==cell else -1) for x in cols}
    expanded=d['expanded']
    return [mode,cell,active,rowtab,celltabs,expanded]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('enter', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 2: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 3: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 4: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 5: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
Hidden treegrid columns remain focus candidates produces the wrong hierarchical widget state in a regression fixture.

Row navigation uses one logical active row. Entering cell mode chooses a visible editable cell in the row; unavailable cells are skipped. Escape returns row mode without moving row focus. Column hiding repairs cell identity, and editable descendants never become separate tree rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    cols=[x for x in d['columns'] if x not in d['hidden']]
    editable=[x for x in cols if True]
    enter=d['command']=='enter' and bool(editable) and not d['row_disabled']
    escape=d['command']=='escape'
    mode='row' if escape else ('cell' if enter else d['mode'])
    cell=(editable[0] if enter else d['cell']) if mode=='cell' else None
    cell=cell if cell in cols else (cols[0] if mode=='cell' and cols else None)
    active=d['row']+':'+cell if mode=='cell' and cell is not None else d['row']
    rowtab=0 if mode=='row' else -1
    celltabs={x:(0 if mode=='cell' and x==cell else -1) for x in cols}
    expanded=d['expanded']
    return [mode,cell,active,rowtab,celltabs,expanded]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('enter', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 2: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 3: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 4: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 5: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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(d):
    cols=[x for x in d['columns'] if x not in d['hidden']]
    editable=[x for x in cols if x not in d['editable']]
    enter=d['command']=='enter' and bool(editable) and not d['row_disabled']
    escape=d['command']=='escape'
    mode='row' if escape else ('cell' if enter else d['mode'])
    cell=(editable[0] if enter else d['cell']) if mode=='cell' else None
    cell=cell if cell in cols else (cols[0] if mode=='cell' and cols else None)
    active=d['row']+':'+cell if mode=='cell' and cell is not None else d['row']
    rowtab=0 if mode=='row' else -1
    celltabs={x:(0 if mode=='cell' and x==cell else -1) for x in cols}
    expanded=d['expanded']
    return [mode,cell,active,rowtab,celltabs,expanded]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('enter', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 2: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 3: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 4: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])], 5: [('enter', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('readonly first', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': [], 'editable': ['x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'name': -1, 'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('escape', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'escape', 'row_disabled': False, 'mode': 'cell', 'cell': 'x', 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('disabled', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': True, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no editable', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': [], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('hidden active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'name', 'row': 'r', 'expanded': ['r']}, ['cell', 'x', 'r:x', -1, {'x': 0, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('visible active', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'cell', 'cell': 'y', 'row': 'r', 'expanded': ['r']}, ['cell', 'y', 'r:y', -1, {'x': -1, 'y': 0, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('passive row', {'columns': ['name', 'x', 'y', 'v0', 'v1', 'v2', 'v3', 'v4'], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'refresh', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {'x': -1, 'y': -1, 'v0': -1, 'v1': -1, 'v2': -1, 'v3': -1, 'v4': -1}, ['r']]), ('no columns', {'columns': [], 'hidden': ['name'], 'editable': ['name', 'x', 'y'], 'command': 'enter', 'row_disabled': False, 'mode': 'row', 'cell': None, 'row': 'r', 'expanded': ['r']}, ['row', None, 'r', 0, {}, ['r']])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
Cell entry chooses a read-only column produces the wrong hierarchical widget state in a regression fixture.

Row navigation uses one logical active row. Entering cell mode chooses a visible editable cell in the row; unavailable cells are skipped. Escape returns row mode without moving row focus. Column hiding repairs cell identity, and editable descendants never become separate tree rows.

split: open-access