FA-4196 / Sequence semantics / Open access
Reverse enumeration retains indices · case 01
The operation returns a result or retained state that violates this contract: Visit elements in reverse order while retaining their original indices.
ROOT CAUSE
Enumerating a reversed list assigns new indices instead of preserving original ones.
VERIFIED REPAIR
Visit elements in reverse order while retaining their original indices.
Unsuccessful approach: Value lookup confuses repeated values with their first occurrence.
Case contract
Visit elements in reverse order while retaining their original indices. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.
Why this case matters
A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
return [[i,v] for i,v in enumerate(reversed(x))]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [[0, 'a']])
check('two distinct elements', solve(['a', 'b']), [[1, 'b'], [0, 'a']])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [[3, 'c'], [2, 'b'], [1, 'a'], [0, '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 |
|---|---|---|---|
| empty collection | [] | [] | Passed |
| singleton collection | [[0, 'a']] | [[0, 'a']] | Passed |
| two distinct elements | [[0, 'b'], [1, 'a']] | [[1, 'b'], [0, 'a']] | Failed |
| nonadjacent duplicate and unsorted order | [[0, 'c'], [1, 'b'], [2, 'a'], [3, 'b']] | [[3, 'c'], [2, 'b'], [1, 'a'], [0, 'b']] | Failed |
SHA-256 / 43e5faaa984c1384e06084d81e8cb8808a8e9e22f6619afe7366b427055bd892
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
return [[x.index(v),v] for v in reversed(x)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [[0, 'a']])
check('two distinct elements', solve(['a', 'b']), [[1, 'b'], [0, 'a']])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [[3, 'c'], [2, 'b'], [1, 'a'], [0, '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 |
|---|---|---|---|
| empty collection | [] | [] | Passed |
| singleton collection | [[0, 'a']] | [[0, 'a']] | Passed |
| two distinct elements | [[1, 'b'], [0, 'a']] | [[1, 'b'], [0, 'a']] | Passed |
| nonadjacent duplicate and unsorted order | [[3, 'c'], [0, 'b'], [1, 'a'], [0, 'b']] | [[3, 'c'], [2, 'b'], [1, 'a'], [0, 'b']] | Failed |
SHA-256 / 10b912f4b092832bb1c0189fd061dcee82903f0c154420655175c3230026144d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
return [[i,x[i]] for i in range(len(x)-1,-1,-1)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [[0, 'a']])
check('two distinct elements', solve(['a', 'b']), [[1, 'b'], [0, 'a']])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [[3, 'c'], [2, 'b'], [1, 'a'], [0, '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 |
|---|---|---|---|
| empty collection | [] | [] | Passed |
| singleton collection | [[0, 'a']] | [[0, 'a']] | Passed |
| two distinct elements | [[1, 'b'], [0, 'a']] | [[1, 'b'], [0, 'a']] | Passed |
| nonadjacent duplicate and unsorted order | [[3, 'c'], [2, 'b'], [1, 'a'], [0, 'b']] | [[3, 'c'], [2, 'b'], [1, 'a'], [0, 'b']] | Passed |
SHA-256 / ed26e6112694b19a90a191565fbca715f7a9dba93b4fc54d8f465c593b7ea065
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:37:36.791054+00:00.
Case digest / e9e629fb1c83b0c34afb9e5349606349be8745a1795a26ec11186ebe9e4b8397