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

N = 1
observations = []
def solve(x):
    r0 = x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    r0 = x['original']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The tab workspace reports an incorrect cancel strip order.

Canceling a tab drag restores source pane and rank, removes provisional destination placeholder, restores prior selection, releases capture and discards detach preview.

split: open-access


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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The tab workspace reports an incorrect cancel pane owner.

Canceling a tab drag restores source pane and rank, removes provisional destination placeholder, restores prior selection, releases capture and discards detach preview.

split: open-access


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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = 0 if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The tab workspace reports an incorrect cancel insertion rank.

Canceling a tab drag restores source pane and rank, removes provisional destination placeholder, restores prior selection, releases capture and discards detach preview.

split: open-access


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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = False
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = True
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The tab workspace reports an incorrect placeholder discard.

Canceling a tab drag restores source pane and rank, removes provisional destination placeholder, restores prior selection, releases capture and discards detach preview.

split: open-access


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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['dragged']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active']
    r5 = 'discard' if x['cancel'] else 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The tab workspace reports an incorrect cancel selection restore.

Canceling a tab drag restores source pane and rank, removes provisional destination placeholder, restores prior selection, releases capture and discards detach preview.

split: open-access