FA-4756 / Scoped mappings / Open access
Chainmap clear only current scope · case 01
The operation returns a result or retained state that violates this contract: Clear erases only the first scope, preserving all outer bindings.
ROOT CAUSE
Clearing every scope destroys inherited state.
VERIFIED REPAIR
Clear erases only the first scope, preserving all outer bindings.
Unsuccessful approach: Replacing the entire chain with one empty scope discards parent scope structure.
Case contract
Clear erases only the first scope, preserving all outer bindings. 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 [{} for m in x]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('outer preserved', solve([{'a': 2}, {'a': 1}]), [{}, {'a': 1}])
check('three scopes', solve([{'a': 1}, {'b': 2}, {'c': 3}]), [{}, {'b': 2}, {'c': 3}])
check('one scope', solve([{'a': 1}]), [{}])
check('empty top', solve([{}, {'a': 1}]), [{}, {'a': 1}])
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 |
|---|---|---|---|
| outer preserved | [{}, {}] | [{}, {'a': 1}] | Failed |
| three scopes | [{}, {}, {}] | [{}, {'b': 2}, {'c': 3}] | Failed |
| one scope | [{}] | [{}] | Passed |
| empty top | [{}, {}] | [{}, {'a': 1}] | Failed |
SHA-256 / 95a2606d118e7baa4b90daacda1662abbe89b9ca48fd26326786846f25ad9044
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 [{}]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('outer preserved', solve([{'a': 2}, {'a': 1}]), [{}, {'a': 1}])
check('three scopes', solve([{'a': 1}, {'b': 2}, {'c': 3}]), [{}, {'b': 2}, {'c': 3}])
check('one scope', solve([{'a': 1}]), [{}])
check('empty top', solve([{}, {'a': 1}]), [{}, {'a': 1}])
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 |
|---|---|---|---|
| outer preserved | [{}] | [{}, {'a': 1}] | Failed |
| three scopes | [{}] | [{}, {'b': 2}, {'c': 3}] | Failed |
| one scope | [{}] | [{}] | Passed |
| empty top | [{}] | [{}, {'a': 1}] | Failed |
SHA-256 / d5a4ee71809428d65f9d261fed9d2c69a4605b614ea51f6e6b901badf3ee8b04
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]); c.clear(); return c.maps
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('outer preserved', solve([{'a': 2}, {'a': 1}]), [{}, {'a': 1}])
check('three scopes', solve([{'a': 1}, {'b': 2}, {'c': 3}]), [{}, {'b': 2}, {'c': 3}])
check('one scope', solve([{'a': 1}]), [{}])
check('empty top', solve([{}, {'a': 1}]), [{}, {'a': 1}])
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 |
|---|---|---|---|
| outer preserved | [{}, {'a': 1}] | [{}, {'a': 1}] | Passed |
| three scopes | [{}, {'b': 2}, {'c': 3}] | [{}, {'b': 2}, {'c': 3}] | Passed |
| one scope | [{}] | [{}] | Passed |
| empty top | [{}, {'a': 1}] | [{}, {'a': 1}] | Passed |
SHA-256 / 65263f9184d4820b06882d8942c31692645c213a80f75d6f5344d4b490544ef1
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.492143+00:00.
Case digest / 7ced3986c93d19a8084bf67ced18526079556013aa9e4616431f8738438d16d5