FAILURE MAP
← Case archive

FA-8226 / Direct manipulation / Open access

Drag-and-drop list reordering: Drop-after inserts before the target · case 01

Drop-after inserts before the target.

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

ROOT CAUSE

The after operation uses `0` where the contract requires `(1 if after else 0)`.

VERIFIED REPAIR

Implement the after operation as `(1 if after else 0)`.

Unsuccessful approach: Always adding one breaks drop-before positioning.

Case contract

Cancellation, missing endpoints and self drops preserve order; otherwise remove the source and insert it immediately before or after the surviving target.

Why this case matters

A deterministic model of drag-and-drop list reordering; 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(items, source, target, after, cancelled):
    items = list(items)
    if cancelled: return items
    if source not in items or target not in items: return items
    if source == target: return items
    items.remove(source)
    index = items.index(target) + 0
    items.insert(index, source)
    return items
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(['a','b','c'], 'a', 'c', True, True), ['a', 'b', 'c'])
check('missing', solve(['a','b'], 'a', 'gone', True, False), ['a', 'b'])
check('self', solve(['a','b'], 'a', 'a', True, False), ['a', 'b'])
check('after', solve(['a','b','c'], 'a', 'c', True, False), ['b', 'c', 'a'])
check('before', solve(['a','b','c'], 'c', 'a', False, False), ['c', 'a', 'b'])
check('parameterized drag length', solve(list(range(N+2)), 0, N+1, True, False), list(range(1,N+2))+[0])
for repetition in range(N):
    check('repeat before', solve(['a','b','c'], 'c', 'a', False, False), ['c', 'a', 'b'])
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
cancel['a', 'b', 'c']['a', 'b', 'c']Passed
missing['a', 'b']['a', 'b']Passed
self['a', 'b']['a', 'b']Passed
after['b', 'a', 'c']['b', 'c', 'a']Failed
before['c', 'a', 'b']['c', 'a', 'b']Passed
parameterized drag length[1, 0, 2][1, 2, 0]Failed
repeat before['c', 'a', 'b']['c', 'a', 'b']Passed

SHA-256 / 8d292f695a163181a2a888dfdf5af7133ee1c108124bb772a56716f75ce2ba8a

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(items, source, target, after, cancelled):
    items = list(items)
    if cancelled: return items
    if source not in items or target not in items: return items
    if source == target: return items
    items.remove(source)
    index = items.index(target) + 1
    items.insert(index, source)
    return items
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(['a','b','c'], 'a', 'c', True, True), ['a', 'b', 'c'])
check('missing', solve(['a','b'], 'a', 'gone', True, False), ['a', 'b'])
check('self', solve(['a','b'], 'a', 'a', True, False), ['a', 'b'])
check('after', solve(['a','b','c'], 'a', 'c', True, False), ['b', 'c', 'a'])
check('before', solve(['a','b','c'], 'c', 'a', False, False), ['c', 'a', 'b'])
check('parameterized drag length', solve(list(range(N+2)), 0, N+1, True, False), list(range(1,N+2))+[0])
for repetition in range(N):
    check('repeat before', solve(['a','b','c'], 'c', 'a', False, False), ['c', 'a', 'b'])
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
cancel['a', 'b', 'c']['a', 'b', 'c']Passed
missing['a', 'b']['a', 'b']Passed
self['a', 'b']['a', 'b']Passed
after['b', 'c', 'a']['b', 'c', 'a']Passed
before['a', 'c', 'b']['c', 'a', 'b']Failed
parameterized drag length[1, 2, 0][1, 2, 0]Passed
repeat before['a', 'c', 'b']['c', 'a', 'b']Failed

SHA-256 / 8b059dbb62195880bdd8ec6d6bd473ffba9c429f2723650393e9500795fd635e

3 / The verified repair

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

N = 1
observations = []
def solve(items, source, target, after, cancelled):
    items = list(items)
    if cancelled: return items
    if source not in items or target not in items: return items
    if source == target: return items
    items.remove(source)
    index = items.index(target) + (1 if after else 0)
    items.insert(index, source)
    return items
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancel', solve(['a','b','c'], 'a', 'c', True, True), ['a', 'b', 'c'])
check('missing', solve(['a','b'], 'a', 'gone', True, False), ['a', 'b'])
check('self', solve(['a','b'], 'a', 'a', True, False), ['a', 'b'])
check('after', solve(['a','b','c'], 'a', 'c', True, False), ['b', 'c', 'a'])
check('before', solve(['a','b','c'], 'c', 'a', False, False), ['c', 'a', 'b'])
check('parameterized drag length', solve(list(range(N+2)), 0, N+1, True, False), list(range(1,N+2))+[0])
for repetition in range(N):
    check('repeat before', solve(['a','b','c'], 'c', 'a', False, False), ['c', 'a', 'b'])
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
cancel['a', 'b', 'c']['a', 'b', 'c']Passed
missing['a', 'b']['a', 'b']Passed
self['a', 'b']['a', 'b']Passed
after['b', 'c', 'a']['b', 'c', 'a']Passed
before['c', 'a', 'b']['c', 'a', 'b']Passed
parameterized drag length[1, 2, 0][1, 2, 0]Passed
repeat before['c', 'a', 'b']['c', 'a', 'b']Passed

SHA-256 / dd447b91b66ff81728f3bffe4798f9817fe7259a02b0987235ab214a33f6dfd8

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

Case digest / 69f2e70f375559df615d925dee7821d7192751e524cea653458b99cce92caed1