{"abstract":"The operation returns a result or retained state that violates this contract: Assignment always writes the first scope, even when the key exists only in an outer scope; return all scopes.","category":"Scoped mappings","checks":4,"contract":"Assignment always writes the first scope, even when the key exists only in an outer scope; return all scopes. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.","evaluation_group":"model-0aecd59cb92ac5a0","failed_approach":"Writing to the last scope mutates the outermost binding.","family":"xr-chainmap-write-always-top-scope","id":"FA-4716","implementations":{"attempt":{"sha256":"1b2cd40b733fc31d3956b07c2c4320fbf4810e7f8b04935fe6be4c2ec4d9f9a5","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom collections import Counter, ChainMap, deque\nimport heapq\nN = 1\nobservations = []\ndef solve(x, y=None):\n    a=[dict(m) for m in x]; a[-1][y[0]]=y[1]; return a\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('shadow outer binding', solve([{}, {'a': 1}], ['a', 2]), [{'a': 2}, {'a': 1}])\ncheck('new key belongs inner', solve([{}, {}], ['a', 1]), [{'a': 1}, {}])\ncheck('replace inner', solve([{'a': 1}, {'a': 3}], ['a', 2]), [{'a': 2}, {'a': 3}])\ncheck('one scope', solve([{}], ['a', 1]), [{'a': 1}])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"6967f50dce10cdc765bc45a49e1fb55c61f976052c7d93ebe89d1f5d7bab2ffb","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom collections import Counter, ChainMap, deque\nimport heapq\nN = 1\nobservations = []\ndef solve(x, y=None):\n    a=[dict(m) for m in x]; next((m for m in a if y[0] in m),a[0])[y[0]]=y[1]; return a\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('shadow outer binding', solve([{}, {'a': 1}], ['a', 2]), [{'a': 2}, {'a': 1}])\ncheck('new key belongs inner', solve([{}, {}], ['a', 1]), [{'a': 1}, {}])\ncheck('replace inner', solve([{'a': 1}, {'a': 3}], ['a', 2]), [{'a': 2}, {'a': 3}])\ncheck('one scope', solve([{}], ['a', 1]), [{'a': 1}])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"44ec3dadaae122378011154d4423452ad998212dd4740a3662c178a7209ecd1c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom collections import Counter, ChainMap, deque\nimport heapq\nN = 1\nobservations = []\ndef solve(x, y=None):\n    a=[dict(m) for m in x]; c=ChainMap(*a); c[y[0]]=y[1]; return c.maps\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('shadow outer binding', solve([{}, {'a': 1}], ['a', 2]), [{'a': 2}, {'a': 1}])\ncheck('new key belongs inner', solve([{}, {}], ['a', 1]), [{'a': 1}, {}])\ncheck('replace inner', solve([{'a': 1}, {'a': 3}], ['a', 2]), [{'a': 2}, {'a': 3}])\ncheck('one scope', solve([{}], ['a', 1]), [{'a': 1}])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":" 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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"xr-chainmap-write-always-top-scope","generated_at":"2026-09-29T14:37:42.105166+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.","repair":"Assignment always writes the first scope, even when the key exists only in an outer scope; return all scopes.","root_cause":"Updating the first existing binding mutates a parent instead of creating an inner shadow.","sha256":"862142228e320f76c9e4c6168006740695bda87b7f9581761e98cd4fe1a4c4b2","title":"Chainmap write always top scope · case 01","variant":1,"variant_policy":"Five execution reruns of a fixed adversarial fixture suite; variant number does not alter semantic inputs.","verification":{"attempt":{"elapsed_ms":40.733,"exit_code":1,"observations":[{"actual":[{},{"a":2}],"check":"shadow outer binding","expected":[{"a":2},{"a":1}],"passed":false},{"actual":[{},{"a":1}],"check":"new key belongs inner","expected":[{"a":1},{}],"passed":false},{"actual":[{"a":1},{"a":2}],"check":"replace inner","expected":[{"a":2},{"a":3}],"passed":false},{"actual":[{"a":1}],"check":"one scope","expected":[{"a":1}],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"shadow outer binding\", \"actual\": [{}, {\"a\": 2}], \"expected\": [{\"a\": 2}, {\"a\": 1}], \"passed\": false}, {\"check\": \"new key belongs inner\", \"actual\": [{}, {\"a\": 1}], \"expected\": [{\"a\": 1}, {}], \"passed\": false}, {\"check\": \"replace inner\", \"actual\": [{\"a\": 1}, {\"a\": 2}], \"expected\": [{\"a\": 2}, {\"a\": 3}], \"passed\": false}, {\"check\": \"one scope\", \"actual\": [{\"a\": 1}], \"expected\": [{\"a\": 1}], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.77,"exit_code":1,"observations":[{"actual":[{},{"a":2}],"check":"shadow outer binding","expected":[{"a":2},{"a":1}],"passed":false},{"actual":[{"a":1},{}],"check":"new key belongs inner","expected":[{"a":1},{}],"passed":true},{"actual":[{"a":2},{"a":3}],"check":"replace inner","expected":[{"a":2},{"a":3}],"passed":true},{"actual":[{"a":1}],"check":"one scope","expected":[{"a":1}],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"shadow outer binding\", \"actual\": [{}, {\"a\": 2}], \"expected\": [{\"a\": 2}, {\"a\": 1}], \"passed\": false}, {\"check\": \"new key belongs inner\", \"actual\": [{\"a\": 1}, {}], \"expected\": [{\"a\": 1}, {}], \"passed\": true}, {\"check\": \"replace inner\", \"actual\": [{\"a\": 2}, {\"a\": 3}], \"expected\": [{\"a\": 2}, {\"a\": 3}], \"passed\": true}, {\"check\": \"one scope\", \"actual\": [{\"a\": 1}], \"expected\": [{\"a\": 1}], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.318,"exit_code":0,"observations":[{"actual":[{"a":2},{"a":1}],"check":"shadow outer binding","expected":[{"a":2},{"a":1}],"passed":true},{"actual":[{"a":1},{}],"check":"new key belongs inner","expected":[{"a":1},{}],"passed":true},{"actual":[{"a":2},{"a":3}],"check":"replace inner","expected":[{"a":2},{"a":3}],"passed":true},{"actual":[{"a":1}],"check":"one scope","expected":[{"a":1}],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"shadow outer binding\", \"actual\": [{\"a\": 2}, {\"a\": 1}], \"expected\": [{\"a\": 2}, {\"a\": 1}], \"passed\": true}, {\"check\": \"new key belongs inner\", \"actual\": [{\"a\": 1}, {}], \"expected\": [{\"a\": 1}, {}], \"passed\": true}, {\"check\": \"replace inner\", \"actual\": [{\"a\": 2}, {\"a\": 3}], \"expected\": [{\"a\": 2}, {\"a\": 3}], \"passed\": true}, {\"check\": \"one scope\", \"actual\": [{\"a\": 1}], \"expected\": [{\"a\": 1}], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}