{"abstract":"Leaving a query block retains its CTE definitions.","category":"Data systems","checks":7,"contract":"Interpret nested query blocks using actions push(definitions), pop, and read(name). Every push opens a new CTE scope; reads search innermost scope first then outer scopes. Empty inner scopes still hide nothing, popping restores outer definitions, and unresolved names yield MISSING. Definitions are already evaluated row lists.","contract_signature":"d","evaluation_group":"s3-data-systems-cte-lexical-environments","failed_approach":"Clearing only the top dictionary leaves an extra scope frame that affects later nesting.","family":"s3-data-systems-cte-lexical-environments-pop-persistence","id":"FA-45611","implementations":{"attempt":{"sha256":"ccc6ab945a55a5b3a9d914288932c0f00f1ed6932d2568e81b4119d338077620","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(d):\n    try:\n        scopes=[{}]; out=[]\n        for action,arg in d:\n            if action=='push': scopes.append(dict(arg))\n            elif action=='pop': scopes[-1].clear()\n            else:\n                found='MISSING'\n                for scope in reversed(scopes):\n                    if arg in scope: found=scope[arg]; break\n                out.append(found)\n        return out\n    except (IndexError, KeyError, ValueError, StopIteration) as exc:\n        return {\"representation_error\": type(exc).__name__}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nif N == 1:\n    check('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])\n    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])\n    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])\n    check('no actions', solve([]), [])\nelif N == 2:\n    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])\n    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])\n    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])\n    check('no actions', solve([]), [])\nelif N == 3:\n    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])\n    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])\n    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])\n    check('no actions', solve([]), [])\nelif N == 4:\n    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])\n    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])\n    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])\n    check('no actions', solve([]), [])\nelif N == 5:\n    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])\n    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])\n    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])\n    check('no actions', solve([]), [])\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":"dbedafd3b920415d0979a1b0e8edb1b68b0c68320b058a50dd75697271c86e06","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(d):\n    try:\n        scopes=[{}]; out=[]\n        for action,arg in d:\n            if action=='push': scopes.append(dict(arg))\n            elif action=='pop': pass\n            else:\n                found='MISSING'\n                for scope in reversed(scopes):\n                    if arg in scope: found=scope[arg]; break\n                out.append(found)\n        return out\n    except (IndexError, KeyError, ValueError, StopIteration) as exc:\n        return {\"representation_error\": type(exc).__name__}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nif N == 1:\n    check('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])\n    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])\n    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])\n    check('no actions', solve([]), [])\nelif N == 2:\n    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])\n    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])\n    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])\n    check('no actions', solve([]), [])\nelif N == 3:\n    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])\n    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])\n    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])\n    check('no actions', solve([]), [])\nelif N == 4:\n    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])\n    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])\n    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])\n    check('no actions', solve([]), [])\nelif N == 5:\n    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])\n    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])\n    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])\n    check('missing name', solve([['read', 'x']]), ['MISSING'])\n    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])\n    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])\n    check('no actions', solve([]), [])\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":"Offline stipulated semantics over valid small inputs; no performance, concurrency, or production-engine conformance claim. 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":"s3-data-systems-cte-lexical-environments-pop-persistence","generated_at":"2026-09-29T14:44:24.181768+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A bounded deterministic data engine model makes representation and changelog faults reproducible.","root_cause":"cte-lexical-environments: Leaving a query block retains its CTE definitions.","sha256":"0f74efe5afaea0419c652c6625ac8ce5d67b490cd16895c402a5b06e3b59cb14","title":"Leaving a query block retains its CTE definitions · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":44.145,"exit_code":1,"observations":[{"actual":[[2],[1]],"check":"inner shadow","expected":[[2],[1]],"passed":true},{"actual":[[1]],"check":"outer fallback","expected":[[1]],"passed":true},{"actual":[[]],"check":"empty shadow","expected":[[]],"passed":true},{"actual":["MISSING"],"check":"missing name","expected":["MISSING"],"passed":true},{"actual":["MISSING"],"check":"restore missing","expected":["MISSING"],"passed":true},{"actual":[[2]],"check":"nested pops","expected":[[1]],"passed":false},{"actual":[],"check":"no actions","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"inner shadow\", \"actual\": [[2], [1]], \"expected\": [[2], [1]], \"passed\": true}, {\"check\": \"outer fallback\", \"actual\": [[1]], \"expected\": [[1]], \"passed\": true}, {\"check\": \"empty shadow\", \"actual\": [[]], \"expected\": [[]], \"passed\": true}, {\"check\": \"missing name\", \"actual\": [\"MISSING\"], \"expected\": [\"MISSING\"], \"passed\": true}, {\"check\": \"restore missing\", \"actual\": [\"MISSING\"], \"expected\": [\"MISSING\"], \"passed\": true}, {\"check\": \"nested pops\", \"actual\": [[2]], \"expected\": [[1]], \"passed\": false}, {\"check\": \"no actions\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":44.306,"exit_code":1,"observations":[{"actual":[[2],[2]],"check":"inner shadow","expected":[[2],[1]],"passed":false},{"actual":[[1]],"check":"outer fallback","expected":[[1]],"passed":true},{"actual":[[]],"check":"empty shadow","expected":[[]],"passed":true},{"actual":["MISSING"],"check":"missing name","expected":["MISSING"],"passed":true},{"actual":[[1]],"check":"restore missing","expected":["MISSING"],"passed":false},{"actual":[[2]],"check":"nested pops","expected":[[1]],"passed":false},{"actual":[],"check":"no actions","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"inner shadow\", \"actual\": [[2], [2]], \"expected\": [[2], [1]], \"passed\": false}, {\"check\": \"outer fallback\", \"actual\": [[1]], \"expected\": [[1]], \"passed\": true}, {\"check\": \"empty shadow\", \"actual\": [[]], \"expected\": [[]], \"passed\": true}, {\"check\": \"missing name\", \"actual\": [\"MISSING\"], \"expected\": [\"MISSING\"], \"passed\": true}, {\"check\": \"restore missing\", \"actual\": [[1]], \"expected\": [\"MISSING\"], \"passed\": false}, {\"check\": \"nested pops\", \"actual\": [[2]], \"expected\": [[1]], \"passed\": false}, {\"check\": \"no actions\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}