FA-4126 / Sequence semantics / Open access
Second element not second distinct · case 01
The operation returns a result or retained state that violates this contract: Return the second positional element or None if fewer than two elements exist.
ROOT CAUSE
The first element is selected even when a second element is required.
VERIFIED REPAIR
Return the second positional element or None if fewer than two elements exist.
Unsuccessful approach: Distinct-value ranking skips an equal-valued second position.
Case contract
Return the second positional element or None if fewer than two elements exist. 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 x[0] if x else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), None)
check('singleton collection', solve(['a']), None)
check('two distinct elements', solve(['a', 'b']), 'b')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), 'a')
check('equal first and second', solve(['a','a','b']), 'a')
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 | None | None | Passed |
| singleton collection | a | None | Failed |
| two distinct elements | a | b | Failed |
| nonadjacent duplicate and unsorted order | b | a | Failed |
| equal first and second | a | a | Passed |
SHA-256 / a263a1b7f3ecf55b0a7def427c69fdafb1d0f4bf46ff02d1736719aa2991506c
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(dict.fromkeys(x))[1] if len(set(x))>1 else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), None)
check('singleton collection', solve(['a']), None)
check('two distinct elements', solve(['a', 'b']), 'b')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), 'a')
check('equal first and second', solve(['a','a','b']), 'a')
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 | None | None | Passed |
| singleton collection | None | None | Passed |
| two distinct elements | b | b | Passed |
| nonadjacent duplicate and unsorted order | a | a | Passed |
| equal first and second | b | a | Failed |
SHA-256 / 5f80d85cd2238c5a9bdf433aafabeb024f2f3c80c8c687402926285a735b96ab
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 x[1] if len(x)>1 else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), None)
check('singleton collection', solve(['a']), None)
check('two distinct elements', solve(['a', 'b']), 'b')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), 'a')
check('equal first and second', solve(['a','a','b']), 'a')
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 | None | None | Passed |
| singleton collection | None | None | Passed |
| two distinct elements | b | b | Passed |
| nonadjacent duplicate and unsorted order | a | a | Passed |
| equal first and second | a | a | Passed |
SHA-256 / 9f1eb6458acfdf3917fe75a180674b632c6cc9ad88e6a54c89002cd4bcd5d4c2
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.052484+00:00.
Case digest / 36060435196c8530aa68dd5bf18d1ad432d0bc9955787d3af0b6ccdbfb6eabac