FA-4551 / Iterator consumption / Open access
Compress consumes one extra data item · case 01
The operation returns a result or retained state that violates this contract: Use itertools compress semantics: consume one data item before discovering selectors are exhausted; return [selected,data remainder].
ROOT CAUSE
Reading data only for truthy selectors fails to advance through false selectors.
VERIFIED REPAIR
Use itertools compress semantics: consume one data item before discovering selectors are exhausted; return [selected,data remainder].
Unsuccessful approach: Slicing at selector count overlooks the extra data read before selector exhaustion is discovered.
Case contract
Use itertools compress semantics: consume one data item before discovering selectors are exhausted; return [selected,data remainder]. 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=[next(g) for flag in y if flag]; return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short selectors consume next data', solve(['a', 'b', 'c'], [True]), [['a'], ['c']])
check('false selector still advances', solve(['a', 'b', 'c'], [False, True]), [['b'], []])
check('empty selectors consume first', solve(['a', 'b'], []), [[], ['b']])
check('empty data', solve([], [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 |
|---|---|---|---|
| short selectors consume next data | [['a'], ['b', 'c']] | [['a'], ['c']] | Failed |
| false selector still advances | [['a'], ['b', 'c']] | [['b'], []] | Failed |
| empty selectors consume first | [[], ['a', 'b']] | [[], ['b']] | Failed |
| empty data | [[], []] | [[], []] | Passed |
SHA-256 / d09fe2570f0d1e4c21a3b20565892171e2890260ea77c8a9acc5543a697b2f4d
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):
n=min(len(x),len(y)); return [[x[i] for i in range(n) if y[i]],x[n:]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short selectors consume next data', solve(['a', 'b', 'c'], [True]), [['a'], ['c']])
check('false selector still advances', solve(['a', 'b', 'c'], [False, True]), [['b'], []])
check('empty selectors consume first', solve(['a', 'b'], []), [[], ['b']])
check('empty data', solve([], [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 |
|---|---|---|---|
| short selectors consume next data | [['a'], ['b', 'c']] | [['a'], ['c']] | Failed |
| false selector still advances | [['b'], ['c']] | [['b'], []] | Failed |
| empty selectors consume first | [[], ['a', 'b']] | [[], ['b']] | Failed |
| empty data | [[], []] | [[], []] | Passed |
SHA-256 / 107a92c929b78bccd7b83505753620ca6576a16bbfeb3d74eebc6e12250cd4be
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.compress(g,y)); return [a,list(g)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short selectors consume next data', solve(['a', 'b', 'c'], [True]), [['a'], ['c']])
check('false selector still advances', solve(['a', 'b', 'c'], [False, True]), [['b'], []])
check('empty selectors consume first', solve(['a', 'b'], []), [[], ['b']])
check('empty data', solve([], [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 |
|---|---|---|---|
| short selectors consume next data | [['a'], ['c']] | [['a'], ['c']] | Passed |
| false selector still advances | [['b'], []] | [['b'], []] | Passed |
| empty selectors consume first | [[], ['b']] | [[], ['b']] | Passed |
| empty data | [[], []] | [[], []] | Passed |
SHA-256 / 63b391382a01d63f89220885eea12037dcfc658c0ad947571d362443cc1f96d2
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.487609+00:00.
Case digest / 64dfd292c8afe0cb067b2a866687ee7d84353c4ed9dddd522bae67bcc7402cd5