FA-8221 / Direct manipulation / Open access
Drag-and-drop list reordering: Reordering duplicates the dragged item instead of moving it · case 01
Reordering duplicates the dragged item instead of moving it.
ROOT CAUSE
The remove source operation uses `items = list(items)` where the contract requires `items.remove(source)`.
VERIFIED REPAIR
Implement the remove source operation as `items.remove(source)`.
Unsuccessful approach: Reversing before removal scrambles the unaffected items.
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 = list(items)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| cancel | ['a', 'b', 'c'] | ['a', 'b', 'c'] | Passed |
| missing | ['a', 'b'] | ['a', 'b'] | Passed |
| self | ['a', 'b'] | ['a', 'b'] | Passed |
| after | ['a', 'b', 'c', 'a'] | ['b', 'c', 'a'] | Failed |
| before | ['c', 'a', 'b', 'c'] | ['c', 'a', 'b'] | Failed |
| parameterized drag length | [0, 1, 2, 0] | [1, 2, 0] | Failed |
| repeat before | ['c', 'a', 'b', 'c'] | ['c', 'a', 'b'] | Failed |
SHA-256 / b2e4e548ba49cb519f90b5964db3405b142bcf328e36f26eb183bfeac58cf436
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.reverse(); 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| cancel | ['a', 'b', 'c'] | ['a', 'b', 'c'] | Passed |
| missing | ['a', 'b'] | ['a', 'b'] | Passed |
| self | ['a', 'b'] | ['a', 'b'] | Passed |
| after | ['c', 'a', 'b'] | ['b', 'c', 'a'] | Failed |
| before | ['b', 'c', 'a'] | ['c', 'a', 'b'] | Failed |
| parameterized drag length | [2, 0, 1] | [1, 2, 0] | Failed |
| repeat before | ['b', 'c', 'a'] | ['c', 'a', 'b'] | Failed |
SHA-256 / 3bb47edaff7ab83f48040bcf0c3f6dc1a5771a355b88f51e55504581a4362e39
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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.558851+00:00.
Case digest / 5d760e798bffca04163197cebd82c39847cae4bfaef4a552c1f9d99fb6ddd49c