FA-4646 / Iterator consumption / Open access
Iterator membership consumes through match · case 01
The operation returns a result or retained state that violates this contract: Membership testing on a one-pass iterator consumes through the matched item and leaves only later items.
ROOT CAUSE
Membership is tested on the original reusable list rather than advancing the iterator.
VERIFIED REPAIR
Membership testing on a one-pass iterator consumes through the matched item and leaves only later items.
Unsuccessful approach: Materializing before membership consumes the entire stream beyond the match.
Case contract
Membership testing on a one-pass iterator consumes through the matched item and leaves only later items. 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):
return [y in x,list(x)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle match', solve(['a', 'b', 'c'], 'b'), [True, ['c']])
check('first match', solve(['a', 'b'], 'a'), [True, ['b']])
check('missing exhausts', solve(['a'], 'z'), [False, []])
check('empty', solve([], 'z'), [False, []])
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 |
|---|---|---|---|
| middle match | [True, ['a', 'b', 'c']] | [True, ['c']] | Failed |
| first match | [True, ['a', 'b']] | [True, ['b']] | Failed |
| missing exhausts | [False, ['a']] | [False, []] | Failed |
| empty | [False, []] | [False, []] | Passed |
SHA-256 / cdb95e047570cf236b2518a0ea52c60b6d187226cc22ca74b9a1c529274d70d5
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=y in list(g); return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle match', solve(['a', 'b', 'c'], 'b'), [True, ['c']])
check('first match', solve(['a', 'b'], 'a'), [True, ['b']])
check('missing exhausts', solve(['a'], 'z'), [False, []])
check('empty', solve([], 'z'), [False, []])
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 |
|---|---|---|---|
| middle match | [True, []] | [True, ['c']] | Failed |
| first match | [True, []] | [True, ['b']] | Failed |
| missing exhausts | [False, []] | [False, []] | Passed |
| empty | [False, []] | [False, []] | Passed |
SHA-256 / 757ebb3544c5b6c196e59c0251aa5d84720ed66cc455c608d7697454ced5096f
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=y in g; return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle match', solve(['a', 'b', 'c'], 'b'), [True, ['c']])
check('first match', solve(['a', 'b'], 'a'), [True, ['b']])
check('missing exhausts', solve(['a'], 'z'), [False, []])
check('empty', solve([], 'z'), [False, []])
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 |
|---|---|---|---|
| middle match | [True, ['c']] | [True, ['c']] | Passed |
| first match | [True, ['b']] | [True, ['b']] | Passed |
| missing exhausts | [False, []] | [False, []] | Passed |
| empty | [False, []] | [False, []] | Passed |
SHA-256 / 63c3a820246230d378ae83770fa4d5d90e48bea6dcdaa2ea71f712ef3c45dce2
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.433695+00:00.
Case digest / 67688627af32774bcc90cf3d12b8e525df462d5feb5741849d85d2e825d4f8e0