FAILURE MAP
← Case archive

FA-4751 / Scoped mappings / Open access

Chainmap pop is top local · case 01

The operation returns a result or retained state that violates this contract: Pop removes only a top-scope binding; an outer-only binding returns the supplied fallback.

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

ROOT CAUSE

Searching outer scopes lets a local pop remove inherited bindings.

VERIFIED REPAIR

Pop removes only a top-scope binding; an outer-only binding returns the supplied fallback.

Unsuccessful approach: Reading inherited values returns a successful-looking pop without actually removing a local binding.

Case contract

Pop removes only a top-scope binding; an outer-only binding returns the supplied fallback. 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):
    a=[dict(m) for m in x]; m=next((m for m in a if y[0] in m),a[0]); v=m.pop(y[0],y[1]); return [v,a]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('outer-only returns default', solve([{}, {'a': 1}], ['a', 'missing']), ['missing', [{}, {'a': 1}]])
check('inner removes only inner', solve([{'a': 2}, {'a': 1}], ['a', 'missing']), [2, [{}, {'a': 1}]])
check('None pops', solve([{'a': None}], ['a', 'missing']), [None, [{}]])
check('absent fallback', solve([{}], ['a', 'missing']), ['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
outer-only returns default[1, [{}, {}]]['missing', [{}, {'a': 1}]]Failed
inner removes only inner[2, [{}, {'a': 1}]][2, [{}, {'a': 1}]]Passed
None pops[None, [{}]][None, [{}]]Passed
absent fallback['missing', [{}]]['missing', [{}]]Passed

SHA-256 / f20895b4d8192feb2cb11556bf879ff92b83253d97bef85442a462d1de77ecab

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):
    c=ChainMap(*[dict(m) for m in x]); v=c.get(y[0],y[1]); c.maps[0].pop(y[0],None); return [v,c.maps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('outer-only returns default', solve([{}, {'a': 1}], ['a', 'missing']), ['missing', [{}, {'a': 1}]])
check('inner removes only inner', solve([{'a': 2}, {'a': 1}], ['a', 'missing']), [2, [{}, {'a': 1}]])
check('None pops', solve([{'a': None}], ['a', 'missing']), [None, [{}]])
check('absent fallback', solve([{}], ['a', 'missing']), ['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
outer-only returns default[1, [{}, {'a': 1}]]['missing', [{}, {'a': 1}]]Failed
inner removes only inner[2, [{}, {'a': 1}]][2, [{}, {'a': 1}]]Passed
None pops[None, [{}]][None, [{}]]Passed
absent fallback['missing', [{}]]['missing', [{}]]Passed

SHA-256 / 70ddcc5c56077d2b96812bd8b595be4f6d118e47a3fe7ab4b46de6ef4c22977d

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):
    c=ChainMap(*[dict(m) for m in x]); v=c.pop(y[0],y[1]); return [v,c.maps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('outer-only returns default', solve([{}, {'a': 1}], ['a', 'missing']), ['missing', [{}, {'a': 1}]])
check('inner removes only inner', solve([{'a': 2}, {'a': 1}], ['a', 'missing']), [2, [{}, {'a': 1}]])
check('None pops', solve([{'a': None}], ['a', 'missing']), [None, [{}]])
check('absent fallback', solve([{}], ['a', 'missing']), ['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
outer-only returns default['missing', [{}, {'a': 1}]]['missing', [{}, {'a': 1}]]Passed
inner removes only inner[2, [{}, {'a': 1}]][2, [{}, {'a': 1}]]Passed
None pops[None, [{}]][None, [{}]]Passed
absent fallback['missing', [{}]]['missing', [{}]]Passed

SHA-256 / a7a72a6de7c0641edc66433c3ec8b6c23a6667fb24c2f4bcd7f6c600ab5c2006

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

Case digest / ac6fa3570e63ff2f5de869d4c9db76f3c4eee61decdf919928311914ab45b03f