FAILURE MAP
← Case archive

FA-7931 / Selection controls / Open access

Hierarchical checkbox state: Selecting a subtree erases selections outside it · case 01

Selecting a subtree erases selections outside it.

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

ROOT CAUSE

The select all operation uses `selected = children` where the contract requires `selected |= children`.

VERIFIED REPAIR

Implement the select all operation as `selected |= children`.

Unsuccessful approach: Toggling descendants deselects already selected children.

Case contract

Subtree actions preserve outside selections; toggle is symmetric; parent status depends only on selected descendants and distinguishes none, mixed and all.

Why this case matters

A deterministic model of hierarchical checkbox state; this isolates one interface invariant without requiring a browser.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(selected, children, event, child):
    selected = set(selected)
    children = set(children)
    if event == 'all': selected = children
    elif event == 'none': selected -= children
    elif event == 'toggle': selected.symmetric_difference_update({child})
    visible = selected & children
    state = 'none' if not visible else ('all' if visible == children else 'mixed')
    return (sorted(selected), state)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('all keeps outside', solve(['x','a'], ['a','b'], 'all', None), (['a', 'b', 'x'], 'all'))
check('none keeps outside', solve(['x','a'], ['a','b'], 'none', None), (['x'], 'none'))
check('toggle off', solve(['a'], ['a','b'], 'toggle', 'a'), ([], 'none'))
check('toggle on', solve([], ['a','b'], 'toggle', 'a'), (['a'], 'mixed'))
check('outside only', solve(['x'], ['a','b'], 'read', None), (['x'], 'none'))
check('all', solve(['a','b'], ['a','b'], 'read', None), (['a', 'b'], 'all'))
check('parameterized checked subtree', solve(list(range(N)), list(range(N)), 'read', None), (list(range(N)), 'all'))
for repetition in range(N):
    check('repeat all', solve(['a','b'], ['a','b'], 'read', None), (['a', 'b'], 'all'))
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
all keeps outside[['a', 'b'], 'all'][['a', 'b', 'x'], 'all']Failed
none keeps outside[['x'], 'none'][['x'], 'none']Passed
toggle off[[], 'none'][[], 'none']Passed
toggle on[['a'], 'mixed'][['a'], 'mixed']Passed
outside only[['x'], 'none'][['x'], 'none']Passed
all[['a', 'b'], 'all'][['a', 'b'], 'all']Passed
parameterized checked subtree[[0], 'all'][[0], 'all']Passed
repeat all[['a', 'b'], 'all'][['a', 'b'], 'all']Passed

SHA-256 / d76ff1b24df741f88b725bbf5ea44f9adc59b36e6e2b8ed5c9e7168562b3f2a9

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(selected, children, event, child):
    selected = set(selected)
    children = set(children)
    if event == 'all': selected ^= children
    elif event == 'none': selected -= children
    elif event == 'toggle': selected.symmetric_difference_update({child})
    visible = selected & children
    state = 'none' if not visible else ('all' if visible == children else 'mixed')
    return (sorted(selected), state)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('all keeps outside', solve(['x','a'], ['a','b'], 'all', None), (['a', 'b', 'x'], 'all'))
check('none keeps outside', solve(['x','a'], ['a','b'], 'none', None), (['x'], 'none'))
check('toggle off', solve(['a'], ['a','b'], 'toggle', 'a'), ([], 'none'))
check('toggle on', solve([], ['a','b'], 'toggle', 'a'), (['a'], 'mixed'))
check('outside only', solve(['x'], ['a','b'], 'read', None), (['x'], 'none'))
check('all', solve(['a','b'], ['a','b'], 'read', None), (['a', 'b'], 'all'))
check('parameterized checked subtree', solve(list(range(N)), list(range(N)), 'read', None), (list(range(N)), 'all'))
for repetition in range(N):
    check('repeat all', solve(['a','b'], ['a','b'], 'read', None), (['a', 'b'], 'all'))
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
all keeps outside[['b', 'x'], 'mixed'][['a', 'b', 'x'], 'all']Failed
none keeps outside[['x'], 'none'][['x'], 'none']Passed
toggle off[[], 'none'][[], 'none']Passed
toggle on[['a'], 'mixed'][['a'], 'mixed']Passed
outside only[['x'], 'none'][['x'], 'none']Passed
all[['a', 'b'], 'all'][['a', 'b'], 'all']Passed
parameterized checked subtree[[0], 'all'][[0], 'all']Passed
repeat all[['a', 'b'], 'all'][['a', 'b'], 'all']Passed

SHA-256 / 322b0cad5dd520e6731838c5c2541ae109d740365d10673381af5ffdac272618

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(selected, children, event, child):
    selected = set(selected)
    children = set(children)
    if event == 'all': selected |= children
    elif event == 'none': selected -= children
    elif event == 'toggle': selected.symmetric_difference_update({child})
    visible = selected & children
    state = 'none' if not visible else ('all' if visible == children else 'mixed')
    return (sorted(selected), state)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('all keeps outside', solve(['x','a'], ['a','b'], 'all', None), (['a', 'b', 'x'], 'all'))
check('none keeps outside', solve(['x','a'], ['a','b'], 'none', None), (['x'], 'none'))
check('toggle off', solve(['a'], ['a','b'], 'toggle', 'a'), ([], 'none'))
check('toggle on', solve([], ['a','b'], 'toggle', 'a'), (['a'], 'mixed'))
check('outside only', solve(['x'], ['a','b'], 'read', None), (['x'], 'none'))
check('all', solve(['a','b'], ['a','b'], 'read', None), (['a', 'b'], 'all'))
check('parameterized checked subtree', solve(list(range(N)), list(range(N)), 'read', None), (list(range(N)), 'all'))
for repetition in range(N):
    check('repeat all', solve(['a','b'], ['a','b'], 'read', None), (['a', 'b'], 'all'))
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
all keeps outside[['a', 'b', 'x'], 'all'][['a', 'b', 'x'], 'all']Passed
none keeps outside[['x'], 'none'][['x'], 'none']Passed
toggle off[[], 'none'][[], 'none']Passed
toggle on[['a'], 'mixed'][['a'], 'mixed']Passed
outside only[['x'], 'none'][['x'], 'none']Passed
all[['a', 'b'], 'all'][['a', 'b'], 'all']Passed
parameterized checked subtree[[0], 'all'][[0], 'all']Passed
repeat all[['a', 'b'], 'all'][['a', 'b'], 'all']Passed

SHA-256 / 8601b5edb6a2428e9f04dc68f017ac8fa14035179bf7c42f7b2dc6a5cc451f6a

Verification & scope

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:38:16.656441+00:00.

Case digest / 7a3496b84e1cb3a35d05da01691563048bc04d2e043ba98739dca77504ee4748