FA-4421 / Mapping semantics / Open access
Map filter keys not values · case 01
The operation returns a result or retained state that violates this contract: Keep entries whose keys occur in the supplied allowed-key list, retaining map insertion order.
ROOT CAUSE
The predicate tests values against an allowed-key collection.
VERIFIED REPAIR
Keep entries whose keys occur in the supplied allowed-key list, retaining map insertion order.
Unsuccessful approach: Iterating the allowlist gives its order precedence over map insertion order.
Case contract
Keep entries whose keys occur in the supplied allowed-key list, retaining map insertion order. 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
N = 1
observations = []
def solve(x, y=None):
return [[k,v] for k,v in x.items() if v in y]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('key differs from value', solve({'a': 'b', 'b': 'c'}, ['a']), [['a', 'b']])
check('allowed order ignored', solve({'a': 1, 'b': 2}, ['b', 'a']), [['a', 1], ['b', 2]])
check('empty filter', solve({'a': 1}, []), [])
check('empty map', solve({}, ['a']), [])
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 |
|---|---|---|---|
| key differs from value | [] | [['a', 'b']] | Failed |
| allowed order ignored | [] | [['a', 1], ['b', 2]] | Failed |
| empty filter | [] | [] | Passed |
| empty map | [] | [] | Passed |
SHA-256 / 1dea5cb3dc4cf4ee826b8bd22ab118e95b3de30d92ed9aea6cf5b37591a0d3f4
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
return [[k,x[k]] for k in y if k in x]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('key differs from value', solve({'a': 'b', 'b': 'c'}, ['a']), [['a', 'b']])
check('allowed order ignored', solve({'a': 1, 'b': 2}, ['b', 'a']), [['a', 1], ['b', 2]])
check('empty filter', solve({'a': 1}, []), [])
check('empty map', solve({}, ['a']), [])
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 |
|---|---|---|---|
| key differs from value | [['a', 'b']] | [['a', 'b']] | Passed |
| allowed order ignored | [['b', 2], ['a', 1]] | [['a', 1], ['b', 2]] | Failed |
| empty filter | [] | [] | Passed |
| empty map | [] | [] | Passed |
SHA-256 / 73529d36ae8bf2538256002596b0a793dfae26f43b70ca38e67ba59c0a2de5d0
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
return [[k,v] for k,v in x.items() if k in y]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('key differs from value', solve({'a': 'b', 'b': 'c'}, ['a']), [['a', 'b']])
check('allowed order ignored', solve({'a': 1, 'b': 2}, ['b', 'a']), [['a', 1], ['b', 2]])
check('empty filter', solve({'a': 1}, []), [])
check('empty map', solve({}, ['a']), [])
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 |
|---|---|---|---|
| key differs from value | [['a', 'b']] | [['a', 'b']] | Passed |
| allowed order ignored | [['a', 1], ['b', 2]] | [['a', 1], ['b', 2]] | Passed |
| empty filter | [] | [] | Passed |
| empty map | [] | [] | Passed |
SHA-256 / 7beab73bfd41f86dc767a411ddcbe3858d3b908685c30e0504debba3c7a90400
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:39.018564+00:00.
Case digest / eb4ca79ea81e641f053b44cc573ab83a58a27f0b15e807ee0a55ae90b99101d7