FA-4621 / Iterator consumption / Open access
Filter lazily consumes through first match · case 01
The operation returns a result or retained state that violates this contract: Take the first value equal to sentinel from a filtered iterator; return [match or missing,unconsumed source].
ROOT CAUSE
Collecting every match consumes values beyond the first requested match.
VERIFIED REPAIR
Take the first value equal to sentinel from a filtered iterator; return [match or missing,unconsumed source].
Unsuccessful approach: Reading only the first source value does not scan through rejected values.
Case contract
Take the first value equal to sentinel from a filtered iterator; return [match or missing,unconsumed source]. 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(filter(lambda v:v==y,g)); return [a[0] if a else "missing",list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scan through match', solve(['a', 's', 'b'], 's'), ['s', ['b']])
check('first matches', solve(['s', 'a'], 's'), ['s', ['a']])
check('no match exhausts', solve(['a', 'b'], 's'), ['missing', []])
check('empty', solve([], 's'), ['missing', []])
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 |
|---|---|---|---|
| scan through match | ['s', []] | ['s', ['b']] | Failed |
| first matches | ['s', []] | ['s', ['a']] | Failed |
| no match exhausts | ['missing', []] | ['missing', []] | Passed |
| empty | ['missing', []] | ['missing', []] | Passed |
SHA-256 / ac71fd5032c519497b45cd57f765548372c23238bd75ac4a318cbf3da2d1b245
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=next(g,"missing"); return [a if a==y else "missing",list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scan through match', solve(['a', 's', 'b'], 's'), ['s', ['b']])
check('first matches', solve(['s', 'a'], 's'), ['s', ['a']])
check('no match exhausts', solve(['a', 'b'], 's'), ['missing', []])
check('empty', solve([], 's'), ['missing', []])
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 |
|---|---|---|---|
| scan through match | ['missing', ['s', 'b']] | ['s', ['b']] | Failed |
| first matches | ['s', ['a']] | ['s', ['a']] | Passed |
| no match exhausts | ['missing', ['b']] | ['missing', []] | Failed |
| empty | ['missing', []] | ['missing', []] | Passed |
SHA-256 / 0ccf9c46a8e671b6bc0e10a8334adc6d9cd4b4fc12b1032706299fcf6d790403
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=next(filter(lambda v:v==y,g),"missing"); return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scan through match', solve(['a', 's', 'b'], 's'), ['s', ['b']])
check('first matches', solve(['s', 'a'], 's'), ['s', ['a']])
check('no match exhausts', solve(['a', 'b'], 's'), ['missing', []])
check('empty', solve([], 's'), ['missing', []])
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 |
|---|---|---|---|
| scan through match | ['s', ['b']] | ['s', ['b']] | Passed |
| first matches | ['s', ['a']] | ['s', ['a']] | Passed |
| no match exhausts | ['missing', []] | ['missing', []] | Passed |
| empty | ['missing', []] | ['missing', []] | Passed |
SHA-256 / 92d94ed0ab3c8f8bf88b7c9757168f9dae7a5e1230e693eb379bcc00ee4d1e08
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.238371+00:00.
Case digest / af556c198a8178475fe9c37c9cf93f38956fd0f65123956952d6ab2e27e4822a