{"abstract":"Forgets to acquire the outer manager and changes the required Python-language result.","category":"Context managers","checks":4,"contract":"Enter A then B and exit acquired managers in reverse order. A manager whose __enter__ raises is not exited; previously entered managers still exit. Body errors unwind both. Inputs use the finite Python types shown in the fixtures. An error string denotes the specified caught exception, not an unhandled process failure.","evaluation_group":"xl-nested-context-unwinding","failed_approach":"The alternative still fails because it forgets to acquire the inner manager.","family":"xl-nested-context-unwinding-outer-manager-omitted","id":"FA-5186","implementations":{"attempt":{"sha256":"3f3b753d4c39751a3572b7ec99061ec9be9b44574da2ff576ab77b85a782f7b1","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(fail, body_error):\n    log=[]\n    class Manager:\n        def __init__(self,name): self.name=name\n        def __enter__(self):\n            log.append('enter:'+self.name)\n            if fail==self.name: raise ValueError(self.name)\n            return self\n        def __exit__(self,typ,exc,tb): log.append('exit:'+self.name); return False\n    try:\n        with Manager('A'):\n            log.append('body')\n            if body_error: raise KeyError('body')\n    except Exception as exc: log.append(type(exc).__name__)\n    return log\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('normal nesting', solve(None, False), ['enter:A', 'enter:B', 'body', 'exit:B', 'exit:A'])\ncheck('first enter fails', solve('A', False), ['enter:A', 'ValueError'])\ncheck('second enter fails', solve('B', False), ['enter:A', 'enter:B', 'exit:A', 'ValueError'])\ncheck('body unwinds both', solve(None, True), ['enter:A', 'enter:B', 'body', 'exit:B', 'exit:A', 'KeyError'])\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":"6ade3c21450b682c25008b02e233b4872fded5b40a61dc6281f026e887a55087","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(fail, body_error):\n    log=[]\n    class Manager:\n        def __init__(self,name): self.name=name\n        def __enter__(self):\n            log.append('enter:'+self.name)\n            if fail==self.name: raise ValueError(self.name)\n            return self\n        def __exit__(self,typ,exc,tb): log.append('exit:'+self.name); return False\n    try:\n        with Manager('B'):\n            log.append('body')\n            if body_error: raise KeyError('body')\n    except Exception as exc: log.append(type(exc).__name__)\n    return log\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('normal nesting', solve(None, False), ['enter:A', 'enter:B', 'body', 'exit:B', 'exit:A'])\ncheck('first enter fails', solve('A', False), ['enter:A', 'ValueError'])\ncheck('second enter fails', solve('B', False), ['enter:A', 'enter:B', 'exit:A', 'ValueError'])\ncheck('body unwinds both', solve(None, True), ['enter:A', 'enter:B', 'body', 'exit:B', 'exit:A', 'KeyError'])\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":"3cfc64d2cd163d48503d274f83ab8b0b5d8e8d7cd25949cce96e9ae6429c4bf1","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(fail, body_error):\n    log=[]\n    class Manager:\n        def __init__(self,name): self.name=name\n        def __enter__(self):\n            log.append('enter:'+self.name)\n            if fail==self.name: raise ValueError(self.name)\n            return self\n        def __exit__(self,typ,exc,tb): log.append('exit:'+self.name); return False\n    try:\n        with Manager('A'), Manager('B'):\n            log.append('body')\n            if body_error: raise KeyError('body')\n    except Exception as exc: log.append(type(exc).__name__)\n    return log\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('normal nesting', solve(None, False), ['enter:A', 'enter:B', 'body', 'exit:B', 'exit:A'])\ncheck('first enter fails', solve('A', False), ['enter:A', 'ValueError'])\ncheck('second enter fails', solve('B', False), ['enter:A', 'enter:B', 'exit:A', 'ValueError'])\ncheck('body unwinds both', solve(None, True), ['enter:A', 'enter:B', 'body', 'exit:B', 'exit:A', 'KeyError'])\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":"xl-nested-context-unwinding-outer-manager-omitted","generated_at":"2026-09-29T14:37:46.939126+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Runs Python standard-library language operations in a deterministic local reproducer. Literal expected answers are authored independently. Related defects share an evaluation group to avoid benchmark split leakage.","repair":"Enter A then B and exit acquired managers in reverse order. A manager whose __enter__ raises is not exited; previously entered managers still exit. Body errors unwind both.","root_cause":"Forgets to acquire the outer manager. The executable reproducer isolates this operation from the rest of the contract.","sha256":"e717cc1be1f35b82c636d18b05a6e907f4ce8f6c55b13922505360dfcb252eb1","title":"Nested context unwinding: Forgets to acquire the outer manager · case 01","variant":1,"variant_policy":"The five numbered cases rerun the same authored boundary fixtures; they are reproducibility runs, not independent input variants.","verification":{"attempt":{"elapsed_ms":36.847,"exit_code":1,"observations":[{"actual":["enter:A","body","exit:A"],"check":"normal nesting","expected":["enter:A","enter:B","body","exit:B","exit:A"],"passed":false},{"actual":["enter:A","ValueError"],"check":"first enter fails","expected":["enter:A","ValueError"],"passed":true},{"actual":["enter:A","body","exit:A"],"check":"second enter fails","expected":["enter:A","enter:B","exit:A","ValueError"],"passed":false},{"actual":["enter:A","body","exit:A","KeyError"],"check":"body unwinds both","expected":["enter:A","enter:B","body","exit:B","exit:A","KeyError"],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"normal nesting\", \"actual\": [\"enter:A\", \"body\", \"exit:A\"], \"expected\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\"], \"passed\": false}, {\"check\": \"first enter fails\", \"actual\": [\"enter:A\", \"ValueError\"], \"expected\": [\"enter:A\", \"ValueError\"], \"passed\": true}, {\"check\": \"second enter fails\", \"actual\": [\"enter:A\", \"body\", \"exit:A\"], \"expected\": [\"enter:A\", \"enter:B\", \"exit:A\", \"ValueError\"], \"passed\": false}, {\"check\": \"body unwinds both\", \"actual\": [\"enter:A\", \"body\", \"exit:A\", \"KeyError\"], \"expected\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\", \"KeyError\"], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":37.003,"exit_code":1,"observations":[{"actual":["enter:B","body","exit:B"],"check":"normal nesting","expected":["enter:A","enter:B","body","exit:B","exit:A"],"passed":false},{"actual":["enter:B","body","exit:B"],"check":"first enter fails","expected":["enter:A","ValueError"],"passed":false},{"actual":["enter:B","ValueError"],"check":"second enter fails","expected":["enter:A","enter:B","exit:A","ValueError"],"passed":false},{"actual":["enter:B","body","exit:B","KeyError"],"check":"body unwinds both","expected":["enter:A","enter:B","body","exit:B","exit:A","KeyError"],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"normal nesting\", \"actual\": [\"enter:B\", \"body\", \"exit:B\"], \"expected\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\"], \"passed\": false}, {\"check\": \"first enter fails\", \"actual\": [\"enter:B\", \"body\", \"exit:B\"], \"expected\": [\"enter:A\", \"ValueError\"], \"passed\": false}, {\"check\": \"second enter fails\", \"actual\": [\"enter:B\", \"ValueError\"], \"expected\": [\"enter:A\", \"enter:B\", \"exit:A\", \"ValueError\"], \"passed\": false}, {\"check\": \"body unwinds both\", \"actual\": [\"enter:B\", \"body\", \"exit:B\", \"KeyError\"], \"expected\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\", \"KeyError\"], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":37.587,"exit_code":0,"observations":[{"actual":["enter:A","enter:B","body","exit:B","exit:A"],"check":"normal nesting","expected":["enter:A","enter:B","body","exit:B","exit:A"],"passed":true},{"actual":["enter:A","ValueError"],"check":"first enter fails","expected":["enter:A","ValueError"],"passed":true},{"actual":["enter:A","enter:B","exit:A","ValueError"],"check":"second enter fails","expected":["enter:A","enter:B","exit:A","ValueError"],"passed":true},{"actual":["enter:A","enter:B","body","exit:B","exit:A","KeyError"],"check":"body unwinds both","expected":["enter:A","enter:B","body","exit:B","exit:A","KeyError"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"normal nesting\", \"actual\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\"], \"expected\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\"], \"passed\": true}, {\"check\": \"first enter fails\", \"actual\": [\"enter:A\", \"ValueError\"], \"expected\": [\"enter:A\", \"ValueError\"], \"passed\": true}, {\"check\": \"second enter fails\", \"actual\": [\"enter:A\", \"enter:B\", \"exit:A\", \"ValueError\"], \"expected\": [\"enter:A\", \"enter:B\", \"exit:A\", \"ValueError\"], \"passed\": true}, {\"check\": \"body unwinds both\", \"actual\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\", \"KeyError\"], \"expected\": [\"enter:A\", \"enter:B\", \"body\", \"exit:B\", \"exit:A\", \"KeyError\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}