FAILURE MAP
← Case archive

FA-45606 / Data systems / Open access

Opening a query block overwrites its parent CTE dictionary · case 01

Opening a query block overwrites its parent CTE dictionary.

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

ROOT CAUSE

cte-lexical-environments: Opening a query block overwrites its parent CTE dictionary.

VERIFIED REPAIR

Preserve the stated physical representation and operation order: 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.

Unsuccessful approach: Aliasing the parent dictionary still leaks inner definitions after pop.

Case 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.

Why this case matters

A bounded deterministic data engine model makes representation and changelog faults reproducible.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes[-1].update(arg); scopes.append({})
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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 fixtureActualExpectedOutcome
inner shadow[[2], [2]][[2], [1]]Failed
outer fallback[[1]][[1]]Passed
empty shadow[[]][[]]Passed
missing name['MISSING']['MISSING']Passed
restore missing[[1]]['MISSING']Failed
nested pops[[2]][[1]]Failed
no actions[][]Passed

SHA-256 / deb66eb83086a8522374658458a243bf2ed1578832d6bcb569cd3f5d8e0d0afa

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(scopes[-1]); scopes[-1].update(arg)
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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 fixtureActualExpectedOutcome
inner shadow[[2], [2]][[2], [1]]Failed
outer fallback[[1]][[1]]Passed
empty shadow[[]][[]]Passed
missing name['MISSING']['MISSING']Passed
restore missing[[1]]['MISSING']Failed
nested pops[[2]][[1]]Failed
no actions[][]Passed

SHA-256 / 0a91d5c535414624fee27ff5ca5c80244dfe0ea153bf9f012f050fb362406893

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    try:
        scopes=[{}]; out=[]
        for action,arg in d:
            if action=='push': scopes.append(dict(arg))
            elif action=='pop': scopes.pop()
            else:
                found='MISSING'
                for scope in reversed(scopes):
                    if arg in scope: found=scope[arg]; break
                out.append(found)
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('inner shadow', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[2], [1]])
    check('outer fallback', solve([['push', {'x': [1]}], ['push', {}], ['read', 'x']]), [[1]])
    check('empty shadow', solve([['push', {'x': [1]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [1]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [1]}], ['push', {'x': [2]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[1]])
    check('no actions', solve([]), [])
elif N == 2:
    check('inner shadow', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[3], [2]])
    check('outer fallback', solve([['push', {'x': [2]}], ['push', {}], ['read', 'x']]), [[2]])
    check('empty shadow', solve([['push', {'x': [2]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [2]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [2]}], ['push', {'x': [3]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[2]])
    check('no actions', solve([]), [])
elif N == 3:
    check('inner shadow', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[4], [3]])
    check('outer fallback', solve([['push', {'x': [3]}], ['push', {}], ['read', 'x']]), [[3]])
    check('empty shadow', solve([['push', {'x': [3]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [3]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [3]}], ['push', {'x': [4]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[3]])
    check('no actions', solve([]), [])
elif N == 4:
    check('inner shadow', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[5], [4]])
    check('outer fallback', solve([['push', {'x': [4]}], ['push', {}], ['read', 'x']]), [[4]])
    check('empty shadow', solve([['push', {'x': [4]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [4]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [4]}], ['push', {'x': [5]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[4]])
    check('no actions', solve([]), [])
elif N == 5:
    check('inner shadow', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['read', 'x'], ['pop', None], ['read', 'x']]), [[6], [5]])
    check('outer fallback', solve([['push', {'x': [5]}], ['push', {}], ['read', 'x']]), [[5]])
    check('empty shadow', solve([['push', {'x': [5]}], ['push', {'x': []}], ['read', 'x']]), [[]])
    check('missing name', solve([['read', 'x']]), ['MISSING'])
    check('restore missing', solve([['push', {'x': [5]}], ['pop', None], ['read', 'x']]), ['MISSING'])
    check('nested pops', solve([['push', {'x': [5]}], ['push', {'x': [6]}], ['push', {}], ['pop', None], ['pop', None], ['read', 'x']]), [[5]])
    check('no actions', 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 fixtureActualExpectedOutcome
inner shadow[[2], [1]][[2], [1]]Passed
outer fallback[[1]][[1]]Passed
empty shadow[[]][[]]Passed
missing name['MISSING']['MISSING']Passed
restore missing['MISSING']['MISSING']Passed
nested pops[[1]][[1]]Passed
no actions[][]Passed

SHA-256 / 6f6534aa1ff2c258ca2015af67b08f8ac06efa282c875621256588015773afb8

Verification & scope

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.

Observations recorded using Python 3.12.14 at 2026-09-29T14:44:23.962572+00:00.

Case digest / ccc86440f83c3c14a1db0e932b544925bcdf470ec0701654b84e064cf20ea3f4