FA-4536 / Iterator consumption / Open access
Islice leaves unrequested tail · case 01
The operation returns a result or retained state that violates this contract: Take at most n values from a one-pass iterator and return [taken,unconsumed tail]; taking zero consumes nothing.
ROOT CAUSE
Materializing the stream before slicing consumes the entire tail.
VERIFIED REPAIR
Take at most n values from a one-pass iterator and return [taken,unconsumed tail]; taking zero consumes nothing.
Unsuccessful approach: Reading one extra value to bound the prefix loses an unrequested item.
Case contract
Take at most n values from a one-pass iterator and return [taken,unconsumed tail]; taking zero consumes nothing. 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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
g=iter(x); a=list(g)[:y]; return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded prefix', solve(['a', 'b', 'c'], 1), [['a'], ['b', 'c']])
check('zero consumes none', solve(['a'], 0), [[], ['a']])
check('exhaustion', solve(['a'], 3), [['a'], []])
check('empty', solve([], 1), [[], []])
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 |
|---|---|---|---|
| bounded prefix | [['a'], []] | [['a'], ['b', 'c']] | Failed |
| zero consumes none | [[], []] | [[], ['a']] | Failed |
| exhaustion | [['a'], []] | [['a'], []] | Passed |
| empty | [[], []] | [[], []] | Passed |
SHA-256 / dac9687a8ad5cdca998cdf4e7be3cc3422297cea2e095e902f5a29161176b7e7
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
g=iter(x); a=list(it.islice(g,y+1))[:y]; return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded prefix', solve(['a', 'b', 'c'], 1), [['a'], ['b', 'c']])
check('zero consumes none', solve(['a'], 0), [[], ['a']])
check('exhaustion', solve(['a'], 3), [['a'], []])
check('empty', solve([], 1), [[], []])
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 |
|---|---|---|---|
| bounded prefix | [['a'], ['c']] | [['a'], ['b', 'c']] | Failed |
| zero consumes none | [[], []] | [[], ['a']] | Failed |
| exhaustion | [['a'], []] | [['a'], []] | Passed |
| empty | [[], []] | [[], []] | Passed |
SHA-256 / d7e55437e7f02d8d6b092fef8cc5e02d80ba0b8f4d1cf3b1682cce251a13854d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
g=iter(x); a=list(it.islice(g,y)); return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded prefix', solve(['a', 'b', 'c'], 1), [['a'], ['b', 'c']])
check('zero consumes none', solve(['a'], 0), [[], ['a']])
check('exhaustion', solve(['a'], 3), [['a'], []])
check('empty', solve([], 1), [[], []])
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 |
|---|---|---|---|
| bounded prefix | [['a'], ['b', 'c']] | [['a'], ['b', 'c']] | Passed |
| zero consumes none | [[], ['a']] | [[], ['a']] | Passed |
| exhaustion | [['a'], []] | [['a'], []] | Passed |
| empty | [[], []] | [[], []] | Passed |
SHA-256 / 2eb8dcde47f1aa1c8fbc44d08f8155269a854382ee68a89227e18415c0c3a36a
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:40.087542+00:00.
Case digest / a8637f587c300ba3c6e8e60bfd1bb66bf7ee3e918268e718baf14c7e6f87597f