FA-4731 / Scoped mappings / Open access
Chainmap new child keeps parent scopes · case 01
The operation returns a result or retained state that violates this contract: Creating a child prepends exactly the child map without merging or mutating the parent scope list.
ROOT CAUSE
Merging child bindings mutates the parent and collapses the scope boundary.
VERIFIED REPAIR
Creating a child prepends exactly the child map without merging or mutating the parent scope list.
Unsuccessful approach: Appending the child gives it lowest lookup precedence.
Case contract
Creating a child prepends exactly the child map without merging or mutating the parent scope list. 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]; a[0].update(y); return [a,a]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('child shadows without rewriting', solve([{'a': 1}], {'a': 2}), [[{'a': 2}, {'a': 1}], [{'a': 1}]])
check('empty child is scope', solve([{'a': 1}], {}), [[{}, {'a': 1}], [{'a': 1}]])
check('multiple parent scopes', solve([{'a': 1}, {'b': 2}], {'c': 3}), [[{'c': 3}, {'a': 1}, {'b': 2}], [{'a': 1}, {'b': 2}]])
check('empty parent scope', solve([{}], {}), [[{}, {}], [{}]])
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 |
|---|---|---|---|
| child shadows without rewriting | [[{'a': 2}], [{'a': 2}]] | [[{'a': 2}, {'a': 1}], [{'a': 1}]] | Failed |
| empty child is scope | [[{'a': 1}], [{'a': 1}]] | [[{}, {'a': 1}], [{'a': 1}]] | Failed |
| multiple parent scopes | [[{'a': 1, 'c': 3}, {'b': 2}], [{'a': 1, 'c': 3}, {'b': 2}]] | [[{'c': 3}, {'a': 1}, {'b': 2}], [{'a': 1}, {'b': 2}]] | Failed |
| empty parent scope | [[{}], [{}]] | [[{}, {}], [{}]] | Failed |
SHA-256 / f1e2a959f4df19e08c9026d95c72bcad8bff7d4b2b2ab587657ff4c35bcf14c1
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):
a=[dict(m) for m in x]; return [a+[dict(y)],a]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('child shadows without rewriting', solve([{'a': 1}], {'a': 2}), [[{'a': 2}, {'a': 1}], [{'a': 1}]])
check('empty child is scope', solve([{'a': 1}], {}), [[{}, {'a': 1}], [{'a': 1}]])
check('multiple parent scopes', solve([{'a': 1}, {'b': 2}], {'c': 3}), [[{'c': 3}, {'a': 1}, {'b': 2}], [{'a': 1}, {'b': 2}]])
check('empty parent scope', solve([{}], {}), [[{}, {}], [{}]])
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 |
|---|---|---|---|
| child shadows without rewriting | [[{'a': 1}, {'a': 2}], [{'a': 1}]] | [[{'a': 2}, {'a': 1}], [{'a': 1}]] | Failed |
| empty child is scope | [[{'a': 1}, {}], [{'a': 1}]] | [[{}, {'a': 1}], [{'a': 1}]] | Failed |
| multiple parent scopes | [[{'a': 1}, {'b': 2}, {'c': 3}], [{'a': 1}, {'b': 2}]] | [[{'c': 3}, {'a': 1}, {'b': 2}], [{'a': 1}, {'b': 2}]] | Failed |
| empty parent scope | [[{}, {}], [{}]] | [[{}, {}], [{}]] | Passed |
SHA-256 / 6b7752a1b4b4ad0d243e7042b3b6d3f5e666125309771e7f41af27d3a3182a13
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]); child=c.new_child(dict(y)); return [child.maps,c.maps]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('child shadows without rewriting', solve([{'a': 1}], {'a': 2}), [[{'a': 2}, {'a': 1}], [{'a': 1}]])
check('empty child is scope', solve([{'a': 1}], {}), [[{}, {'a': 1}], [{'a': 1}]])
check('multiple parent scopes', solve([{'a': 1}, {'b': 2}], {'c': 3}), [[{'c': 3}, {'a': 1}, {'b': 2}], [{'a': 1}, {'b': 2}]])
check('empty parent scope', solve([{}], {}), [[{}, {}], [{}]])
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 |
|---|---|---|---|
| child shadows without rewriting | [[{'a': 2}, {'a': 1}], [{'a': 1}]] | [[{'a': 2}, {'a': 1}], [{'a': 1}]] | Passed |
| empty child is scope | [[{}, {'a': 1}], [{'a': 1}]] | [[{}, {'a': 1}], [{'a': 1}]] | Passed |
| multiple parent scopes | [[{'c': 3}, {'a': 1}, {'b': 2}], [{'a': 1}, {'b': 2}]] | [[{'c': 3}, {'a': 1}, {'b': 2}], [{'a': 1}, {'b': 2}]] | Passed |
| empty parent scope | [[{}, {}], [{}]] | [[{}, {}], [{}]] | Passed |
SHA-256 / 69b35e7633ff168b1e9ded95b27ce98b9939d0e8be7b1f205cfec3214664f6da
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.146568+00:00.
Case digest / 130f15e3ccc2e75d60a47a23030986355fdf1efcb0c82aa75ea02ddb03474e25