FA-4416 / Mapping semantics / Open access
Map invert groups collisions · case 01
The operation returns a result or retained state that violates this contract: Invert the map into value-to-key-lists, preserving all keys and their insertion order.
ROOT CAUSE
A single inverse binding overwrites earlier keys that share a value.
VERIFIED REPAIR
Invert the map into value-to-key-lists, preserving all keys and their insertion order.
Unsuccessful approach: Prepending collisions reverses their original insertion order.
Case contract
Invert the map into value-to-key-lists, preserving all keys and their 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 {v:[k] for k,v in x.items()}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('collision preserves both', solve({'a': 'v', 'b': 'v'}), {'v': ['a', 'b']})
check('distinct values', solve({'a': 'v', 'b': 'w'}), {'v': ['a'], 'w': ['b']})
check('empty', solve({}), {})
check('three-way collision', solve({'c': 'v', 'a': 'v', 'b': 'v'}), {'v': ['c', 'a', 'b']})
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 |
|---|---|---|---|
| collision preserves both | {'v': ['b']} | {'v': ['a', 'b']} | Failed |
| distinct values | {'v': ['a'], 'w': ['b']} | {'v': ['a'], 'w': ['b']} | Passed |
| empty | {} | {} | Passed |
| three-way collision | {'v': ['b']} | {'v': ['c', 'a', 'b']} | Failed |
SHA-256 / 0477bfc96422de804216809f48544c44334cb056232b0a14f6f7107a184fdf57
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
a={}
for k,v in x.items(): a.setdefault(v,[]).insert(0,k)
return a
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('collision preserves both', solve({'a': 'v', 'b': 'v'}), {'v': ['a', 'b']})
check('distinct values', solve({'a': 'v', 'b': 'w'}), {'v': ['a'], 'w': ['b']})
check('empty', solve({}), {})
check('three-way collision', solve({'c': 'v', 'a': 'v', 'b': 'v'}), {'v': ['c', 'a', 'b']})
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 |
|---|---|---|---|
| collision preserves both | {'v': ['b', 'a']} | {'v': ['a', 'b']} | Failed |
| distinct values | {'v': ['a'], 'w': ['b']} | {'v': ['a'], 'w': ['b']} | Passed |
| empty | {} | {} | Passed |
| three-way collision | {'v': ['b', 'a', 'c']} | {'v': ['c', 'a', 'b']} | Failed |
SHA-256 / 968838f079b400a0604d9caed3e19cb42e5896870185b54f10a6b0f3ab58ffbf
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x, y=None):
a={}
for k,v in x.items(): a.setdefault(v,[]).append(k)
return a
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('collision preserves both', solve({'a': 'v', 'b': 'v'}), {'v': ['a', 'b']})
check('distinct values', solve({'a': 'v', 'b': 'w'}), {'v': ['a'], 'w': ['b']})
check('empty', solve({}), {})
check('three-way collision', solve({'c': 'v', 'a': 'v', 'b': 'v'}), {'v': ['c', 'a', 'b']})
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 |
|---|---|---|---|
| collision preserves both | {'v': ['a', 'b']} | {'v': ['a', 'b']} | Passed |
| distinct values | {'v': ['a'], 'w': ['b']} | {'v': ['a'], 'w': ['b']} | Passed |
| empty | {} | {} | Passed |
| three-way collision | {'v': ['c', 'a', 'b']} | {'v': ['c', 'a', 'b']} | Passed |
SHA-256 / 544b1a9b0bb061575d4aad41cc1771cfbf7336efefa732928a633dc93d1c3385
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:38.972705+00:00.
Case digest / 7d41bc05382634ca87ee56b041a7fd12ccc0fdb9c5af0c6361f9d3a735f18be2