FA-4616 / Iterator consumption / Open access
Map is lazy before consumption · case 01
The operation returns a result or retained state that violates this contract: Constructing map must not invoke callbacks; taking n results invokes only those callbacks. Return [calls before,calls after,results].
ROOT CAUSE
Eager materialization invokes every callback before the iterator is consumed.
VERIFIED REPAIR
Constructing map must not invoke callbacks; taking n results invokes only those callbacks. Return [calls before,calls after,results].
Unsuccessful approach: Materializing the map before truncation invokes callbacks for unrequested elements.
Case contract
Constructing map must not invoke callbacks; taking n results invokes only those callbacks. Return [calls before,calls after,results]. 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):
calls=[]
def f(v): calls.append(v); return [v]
g=iter([f(v) for v in x]); before=list(calls); a=list(it.islice(g,y)); return [before,calls,a]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('partial consumption', solve(['a', 'b'], 1), [[], ['a'], [['a']]])
check('zero consumption', solve(['a'], 0), [[], [], []])
check('full consumption', solve(['a'], 3), [[], ['a'], [['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 |
|---|---|---|---|
| partial consumption | [['a', 'b'], ['a', 'b'], [['a']]] | [[], ['a'], [['a']]] | Failed |
| zero consumption | [['a'], ['a'], []] | [[], [], []] | Failed |
| full consumption | [['a'], ['a'], [['a']]] | [[], ['a'], [['a']]] | Failed |
| empty | [[], [], []] | [[], [], []] | Passed |
SHA-256 / 1beab4515f3c06829120f7b8e296ff6c3c7ecab9d242c40a496258d19730d174
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):
calls=[]
def f(v): calls.append(v); return [v]
g=map(f,x); before=list(calls); a=list(g)[:y]; return [before,calls,a]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('partial consumption', solve(['a', 'b'], 1), [[], ['a'], [['a']]])
check('zero consumption', solve(['a'], 0), [[], [], []])
check('full consumption', solve(['a'], 3), [[], ['a'], [['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 |
|---|---|---|---|
| partial consumption | [[], ['a', 'b'], [['a']]] | [[], ['a'], [['a']]] | Failed |
| zero consumption | [[], ['a'], []] | [[], [], []] | Failed |
| full consumption | [[], ['a'], [['a']]] | [[], ['a'], [['a']]] | Passed |
| empty | [[], [], []] | [[], [], []] | Passed |
SHA-256 / 4c4db127352d12ed9f15f0639e52e93961c3f4352f383479e56fbf5eae31e1ee
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):
calls=[]
def f(v): calls.append(v); return [v]
g=map(f,x); before=list(calls); a=list(it.islice(g,y)); return [before,calls,a]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('partial consumption', solve(['a', 'b'], 1), [[], ['a'], [['a']]])
check('zero consumption', solve(['a'], 0), [[], [], []])
check('full consumption', solve(['a'], 3), [[], ['a'], [['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 |
|---|---|---|---|
| partial consumption | [[], ['a'], [['a']]] | [[], ['a'], [['a']]] | Passed |
| zero consumption | [[], [], []] | [[], [], []] | Passed |
| full consumption | [[], ['a'], [['a']]] | [[], ['a'], [['a']]] | Passed |
| empty | [[], [], []] | [[], [], []] | Passed |
SHA-256 / e2cd7d6b44f6c603ff21ea34504ac0e62e116b2ac9ed1f4a065ba1bc27b2f9c0
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:41.156254+00:00.
Case digest / 06670df5442bac83855be5c320e41b9f941551a453dc5e4bf697e2baf7517215