FAILURE MAP
← Case archive

FA-39746 / Tree accessibility / Open access

Optimistic subtree move rollback ownership: Successful or superseded move is rolled back · case 01

Successful or superseded move is rolled back produces the wrong hierarchical widget state in a regression fixture.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The move-rollback contract is violated at `rollback=owned and not d['success']` by replacing it with `rollback=not d['success']`.

VERIFIED REPAIR

Restore `rollback=owned and not d['success']` at this fault site while retaining the other tree state decisions.

Unsuccessful approach: The partial repair `rollback=owned` 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=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 fixtureActualExpectedOutcome
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['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'superseded']Failed
new parent version['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['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 / 84ec442abe002327a5844d9b982600a9cf44947b492cbf0bda69ac5016313189

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
    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 fixtureActualExpectedOutcome
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['r', ['a', 'b', 'z'], ['x', 'y'], {'b': 1, 'c': 2, 'outside': 0}, 'c', ['c', 'outside'], 'rolled-back']['q', ['a', 'z'], ['x', 'b', 'y'], {'b': 3, 'c': 4, 'outside': 0}, 'b', ['c', 'outside'], 'committed']Failed
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 / 1ed80fb5a3b35f403f45446cf202e98a4b4308d90cf3023a5edfddb80e49f606

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 fixtureActualExpectedOutcome
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.312634+00:00.

Case digest / a8c2dd96ad0b53e1fdc81b70f23907af1d91380dfd60181c9e2fa7b6740481ce