FA-39786 / Tree accessibility / Open access
Optimistic subtree move rollback ownership: Superseded operation is reported as committed or rolled back · case 01
Superseded operation is reported as committed or rolled back produces the wrong hierarchical widget state in a regression fixture.
ROOT CAUSE
The move-rollback contract is violated at `'rolled-back' if rollback else ('committed' if owned and d['success'] else 'superseded')` by replacing it with `'rolled-back' if rollback else 'committed'`.
VERIFIED REPAIR
Restore `'rolled-back' if rollback else ('committed' if owned and d['success'] else 'superseded')` at this fault site while retaining the other tree state decisions.
Unsuccessful approach: The partial repair `'rolled-back' if not d['success'] else 'committed'` still violates a boundary or preservation case.
Case contract
A failed optimistic move may roll back only while the current parent version and transaction ID match its write. Restore the subtree root at its original sibling position, restore descendant levels by inverse delta, preserve later unrelated selection, and recover focus only if the optimistic move owned it.
Why this case matters
Offline executable model of a hierarchical accessibility interaction; inputs are bounded and valid as stipulated. No browser, assistive technology, or normative ARIA conformance is claimed.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
owned=d['transaction']==d['current_transaction'] and d['written_version']==d['current_version']
rollback=owned and not d['success']
parent=d['old_parent'] if rollback else d['new_parent']
source=list(d['source'])
if rollback: source=source[:d['old_index']]+[d['root']]+source[d['old_index']:]
target=[x for x in d['target'] if not(rollback and x==d['root'])]
levels={x:v-d['delta'] if rollback and x in d['closure'] else v for x,v in d['levels'].items()}
focus=d['old_focus'] if rollback and d['focus']==d['owned_focus'] else d['focus']
selection=d['selected']
status='rolled-back' if rollback else 'committed'
return [parent,source,target,levels,focus,selection,status]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 2: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 3: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 4: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 5: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 6, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])]}
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| owned failure | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
| success | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | Passed |
| new transaction | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | Failed |
| new parent version | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | Failed |
| outside focus | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back'] | Passed |
| original first | ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
| original last | ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
SHA-256 / 62b1d6b876a67826139654c0f222978802b161a2725eb4e5466cf47dc579fcb0
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
owned=d['transaction']==d['current_transaction'] and d['written_version']==d['current_version']
rollback=owned and not d['success']
parent=d['old_parent'] if rollback else d['new_parent']
source=list(d['source'])
if rollback: source=source[:d['old_index']]+[d['root']]+source[d['old_index']:]
target=[x for x in d['target'] if not(rollback and x==d['root'])]
levels={x:v-d['delta'] if rollback and x in d['closure'] else v for x,v in d['levels'].items()}
focus=d['old_focus'] if rollback and d['focus']==d['owned_focus'] else d['focus']
selection=d['selected']
status='rolled-back' if not d['success'] else 'committed'
return [parent,source,target,levels,focus,selection,status]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 2: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 3: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 4: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 5: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 6, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])]}
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| owned failure | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
| success | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | Passed |
| new transaction | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'rolled-back'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | Failed |
| new parent version | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'rolled-back'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | Failed |
| outside focus | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back'] | Passed |
| original first | ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
| original last | ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
SHA-256 / 71b64b25f88039c6d4b224294717568e4bfa7a2a7d2aebeab299a628e119d7a7
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
owned=d['transaction']==d['current_transaction'] and d['written_version']==d['current_version']
rollback=owned and not d['success']
parent=d['old_parent'] if rollback else d['new_parent']
source=list(d['source'])
if rollback: source=source[:d['old_index']]+[d['root']]+source[d['old_index']:]
target=[x for x in d['target'] if not(rollback and x==d['root'])]
levels={x:v-d['delta'] if rollback and x in d['closure'] else v for x,v in d['levels'].items()}
focus=d['old_focus'] if rollback and d['focus']==d['owned_focus'] else d['focus']
selection=d['selected']
status='rolled-back' if rollback else ('committed' if owned and d['success'] else 'superseded')
return [parent,source,target,levels,focus,selection,status]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 1, 'current_version': 1, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 2, 'closure': ['b', 'c'], 'levels': {'b': 3, 'c': 4, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 2: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 4, 'c': 5, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 2, 'current_version': 2, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 3, 'closure': ['b', 'c'], 'levels': {'b': 4, 'c': 5, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 3: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 5, 'c': 6, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 3, 'current_version': 3, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 4, 'closure': ['b', 'c'], 'levels': {'b': 5, 'c': 6, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 4: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 6, 'c': 7, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 4, 'current_version': 4, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 5, 'closure': ['b', 'c'], 'levels': {'b': 6, 'c': 7, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])], 5: [('owned failure', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('success', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': True, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'committed']), ('new transaction', {'transaction': 't', 'current_transaction': 'new', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('new parent version', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 6, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 7, 'c': 8, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']), ('outside focus', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 1, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'outside', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back']), ('original first', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 0, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']), ('original last', {'transaction': 't', 'current_transaction': 't', 'written_version': 5, 'current_version': 5, 'success': False, 'old_parent': 'r', 'new_parent': 'q', 'source': ['a', 'z'], 'target': ['x', 'b', 'y'], 'root': 'b', 'old_index': 2, 'delta': 6, 'closure': ['b', 'c'], 'levels': {'b': 7, 'c': 8, 'outside': 0}, 'old_focus': 'c', 'focus': 'b', 'owned_focus': 'b', 'selected': ['c', 'outside'], 'old_selected': ['b']}, ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'])]}
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| owned failure | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
| success | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed'] | Passed |
| new transaction | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | Passed |
| new parent version | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | ['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded'] | Passed |
| outside focus | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'outside', ['c', 'outside'], 'rolled-back'] | Passed |
| original first | ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['b', 'a', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
| original last | ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | ['r', ['a', 'z', 'b'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back'] | Passed |
SHA-256 / 53ea74152aeac279f567b631037a2c42fca64976267bbd908b61dc3725afc7e3
Verification & scope
Synthetic deterministic hierarchical-widget data contract; not an implementation of a browser accessibility tree. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:43:24.691250+00:00.
Case digest / 8fb69d71043c9da344a9fa7f152395f9076aacd4fcd3e22088b2c0e49adbe6d3