FA-4216 / Sequence semantics / Open access
Last occurrence positions · case 01
The operation returns a result or retained state that violates this contract: Return positions at which each distinct value last appears, ordered by position.
ROOT CAUSE
First occurrences are selected instead of last occurrences.
VERIFIED REPAIR
Return positions at which each distinct value last appears, ordered by position.
Unsuccessful approach: Every position is retained even when an equal later element supersedes it.
Case contract
Return positions at which each distinct value last appears, ordered by position. 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 for i,v in enumerate(x) if v not in x[:i]]
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])
check('two distinct elements', solve(['a', 'b']), [0, 1])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [1, 2, 3])
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] | [0] | Passed |
| two distinct elements | [0, 1] | [0, 1] | Passed |
| nonadjacent duplicate and unsorted order | [0, 1, 3] | [1, 2, 3] | Failed |
SHA-256 / aae3d1e22422a408a32ed35a1722290daa3c907e8105b11da1319760a1e0ec29
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 list(range(len(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])
check('two distinct elements', solve(['a', 'b']), [0, 1])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [1, 2, 3])
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] | [0] | Passed |
| two distinct elements | [0, 1] | [0, 1] | Passed |
| nonadjacent duplicate and unsorted order | [0, 1, 2, 3] | [1, 2, 3] | Failed |
SHA-256 / d35af31b1e8a38373262eefc9822d78e71dc229a7cf55310ef9ba594fd75ac42
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 for i,v in enumerate(x) if v not in x[i+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])
check('two distinct elements', solve(['a', 'b']), [0, 1])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), [1, 2, 3])
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] | [0] | Passed |
| two distinct elements | [0, 1] | [0, 1] | Passed |
| nonadjacent duplicate and unsorted order | [1, 2, 3] | [1, 2, 3] | Passed |
SHA-256 / 31000064256232954395092dd202f07aacdc3b103250fcc418c4c64949d556c4
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.956658+00:00.
Case digest / 0cc0a11ec79ddf053249e25f732256ad2e9df212ed731e267f81ae5a78a8ff4a