FA-4331 / Container mutation / Open access
List insert clamps negative index · case 01
The operation returns a result or retained state that violates this contract: Insert a value using Python positional insertion: negative offsets are relative to length and clamp at zero.
ROOT CAUSE
Clamping before resolving a negative offset loses its relative-to-end meaning.
VERIFIED REPAIR
Insert a value using Python positional insertion: negative offsets are relative to length and clamp at zero.
Unsuccessful approach: Modulo wraps oversized positions instead of applying insertion clamping.
Case contract
Insert a value using Python positional insertion: negative offsets are relative to length and clamp at zero. 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):
a=list(x); a.insert(max(0,y[0]),y[1]); return a
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('relative negative', solve(['a', 'b'], [-1, 'c']), ['a', 'c', 'b'])
check('underflow clamps', solve(['a', 'b'], [-9, 'c']), ['c', 'a', 'b'])
check('overflow appends', solve(['a', 'b'], [9, 'c']), ['a', 'b', 'c'])
check('empty accepts', solve([], [0, 'c']), ['c'])
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 |
|---|---|---|---|
| relative negative | ['c', 'a', 'b'] | ['a', 'c', 'b'] | Failed |
| underflow clamps | ['c', 'a', 'b'] | ['c', 'a', 'b'] | Passed |
| overflow appends | ['a', 'b', 'c'] | ['a', 'b', 'c'] | Passed |
| empty accepts | ['c'] | ['c'] | Passed |
SHA-256 / 88e57f1f03bbdaf505652d8533e6b225cffe329f693f190e2f482876c82edead
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
a=list(x); a.insert(y[0]%len(a) if a else 0,y[1]); return a
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('relative negative', solve(['a', 'b'], [-1, 'c']), ['a', 'c', 'b'])
check('underflow clamps', solve(['a', 'b'], [-9, 'c']), ['c', 'a', 'b'])
check('overflow appends', solve(['a', 'b'], [9, 'c']), ['a', 'b', 'c'])
check('empty accepts', solve([], [0, 'c']), ['c'])
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 |
|---|---|---|---|
| relative negative | ['a', 'c', 'b'] | ['a', 'c', 'b'] | Passed |
| underflow clamps | ['a', 'c', 'b'] | ['c', 'a', 'b'] | Failed |
| overflow appends | ['a', 'c', 'b'] | ['a', 'b', 'c'] | Failed |
| empty accepts | ['c'] | ['c'] | Passed |
SHA-256 / dba6bb83584d47d30b7cd1575ab1f5b31d0c7a517a4f0b610bbb16846d29c1b8
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
a=list(x); a.insert(y[0],y[1]); return a
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('relative negative', solve(['a', 'b'], [-1, 'c']), ['a', 'c', 'b'])
check('underflow clamps', solve(['a', 'b'], [-9, 'c']), ['c', 'a', 'b'])
check('overflow appends', solve(['a', 'b'], [9, 'c']), ['a', 'b', 'c'])
check('empty accepts', solve([], [0, 'c']), ['c'])
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 |
|---|---|---|---|
| relative negative | ['a', 'c', 'b'] | ['a', 'c', 'b'] | Passed |
| underflow clamps | ['c', 'a', 'b'] | ['c', 'a', 'b'] | Passed |
| overflow appends | ['a', 'b', 'c'] | ['a', 'b', 'c'] | Passed |
| empty accepts | ['c'] | ['c'] | Passed |
SHA-256 / 978dc0cf8d3d7b4ef3b74e481fb9b5eb7ba586f948636906b7a551efd3db1d2f
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:37.907067+00:00.
Case digest / 4c98f141a368a30cb0628bd71469f608db37855a553c232a951cd6d423d5913f