FA-4131 / Sequence semantics / Open access
Penultimate element · case 01
The operation returns a result or retained state that violates this contract: Return the penultimate element, or None for lengths zero and one.
ROOT CAUSE
The final element is selected rather than the preceding position.
THE FAILURE
The final element is selected rather than the preceding position.
Unsuccessful approach: Index one selects the second element, not the penultimate element of longer lists.
Case contract
Return the penultimate element, or None for lengths zero and one. 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[-1] 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']), 'a')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), '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 | None | None | Passed |
| singleton collection | a | None | Failed |
| two distinct elements | b | a | Failed |
| nonadjacent duplicate and unsorted order | c | b | Failed |
SHA-256 / 2489f6479c1e51a11e189a42c202868cfc2f30e7ac79944abe6b05e158f20211
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[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']), 'a')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), '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 | None | None | Passed |
| singleton collection | None | None | Passed |
| two distinct elements | b | a | Failed |
| nonadjacent duplicate and unsorted order | a | b | Failed |
SHA-256 / bd5281aefe95baca69cc1231a30af5598d400f4299ee56eebace8c7e4a48bb5f
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 4 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:35.951385+00:00.
Case digest / 4ea0e9be2d8452dd1cf74748ab8382fc9e057429eba723cd67a0201d8b34bba3