FAILURE MAP
← Case archive

FA-4711 / Scoped mappings / Open access

Chainmap lookup first scope wins · case 01

The operation returns a result or retained state that violates this contract: Look up the key in the first containing scope, retaining falsy values; return missing only when no scope contains it.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Reversing scope traversal lets outer bindings override inner bindings.

VERIFIED REPAIR

Look up the key in the first containing scope, retaining falsy values; return missing only when no scope contains it.

Unsuccessful approach: A truthiness-based search skips legitimate falsy inner values.

Case contract

Look up the key in the first containing scope, retaining falsy values; return missing only when no scope contains it. 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
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return ChainMap(*reversed(x)).get(y,"missing")
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('inner shadows outer', solve([{'a': 'inner'}, {'a': 'outer'}], 'a'), 'inner')
check('None shadows outer', solve([{'a': None}, {'a': 'outer'}], 'a'), None)
check('fallback scope', solve([{}, {'a': 'outer'}], 'a'), 'outer')
check('absent', solve([{}, {}], 'a'), '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 fixtureActualExpectedOutcome
inner shadows outerouterinnerFailed
None shadows outerouterNoneFailed
fallback scopeouterouterPassed
absentmissingmissingPassed

SHA-256 / 200ce9fb2dc568ac78141b085cb403e79c9cdd369a341ed197224ca93475bf7b

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return next((scope[y] for scope in x if scope.get(y)),"missing")
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('inner shadows outer', solve([{'a': 'inner'}, {'a': 'outer'}], 'a'), 'inner')
check('None shadows outer', solve([{'a': None}, {'a': 'outer'}], 'a'), None)
check('fallback scope', solve([{}, {'a': 'outer'}], 'a'), 'outer')
check('absent', solve([{}, {}], 'a'), '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 fixtureActualExpectedOutcome
inner shadows outerinnerinnerPassed
None shadows outerouterNoneFailed
fallback scopeouterouterPassed
absentmissingmissingPassed

SHA-256 / ce28a4f776ccce11b0b646a36922a938c83d90cdea5b3bc9b8457cd02f423f3e

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return ChainMap(*x).get(y,"missing")
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('inner shadows outer', solve([{'a': 'inner'}, {'a': 'outer'}], 'a'), 'inner')
check('None shadows outer', solve([{'a': None}, {'a': 'outer'}], 'a'), None)
check('fallback scope', solve([{}, {'a': 'outer'}], 'a'), 'outer')
check('absent', solve([{}, {}], 'a'), '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 fixtureActualExpectedOutcome
inner shadows outerinnerinnerPassed
None shadows outerNoneNonePassed
fallback scopeouterouterPassed
absentmissingmissingPassed

SHA-256 / 2049015e496f98242d81ba63482c3c0989e632207fc92febae460238daa9d6dc

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:42.096673+00:00.

Case digest / 99479823abc3115391c95be8fd5908b3873eac3d3d24891604daa1fa0e8bebb8