{"abstract":"The operation returns a result or retained state that violates this contract: For a nonempty heap, replace and return the old minimum even if the new value is smaller.","category":"Heap invariants","checks":4,"contract":"For a nonempty heap, replace and return the old minimum even if the new value is smaller. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.","evaluation_group":"model-8a54772cb39c93fa","failed_approach":"Popping without inserting loses the replacement item.","family":"xr-heapreplace-always-evicts-old-minimum","id":"FA-4811","implementations":{"attempt":{"sha256":"03177d5e185cd02feebd202ccd7a2485e00e3f0993d86c2c720cae05038977cd","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=list(x); heapq.heapify(a); v=heapq.heappop(a); return [v,sorted(a)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('smaller replacement retained', solve(['b', 'c'], 'a'), ['b', ['a', 'c']])\ncheck('larger replacement retained', solve(['a', 'b'], 'c'), ['a', ['b', 'c']])\ncheck('singleton replacement', solve(['b'], 'a'), ['b', ['a']])\ncheck('equal minimum', solve(['a', 'b'], 'a'), ['a', ['a', 'b']])\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":"6fc4bff0a0b06c4b5f087292183804711e17ce1251fa005998da0ddc9cf2cdf0","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=list(x); heapq.heapify(a); v=heapq.heappushpop(a,y); return [v,sorted(a)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('smaller replacement retained', solve(['b', 'c'], 'a'), ['b', ['a', 'c']])\ncheck('larger replacement retained', solve(['a', 'b'], 'c'), ['a', ['b', 'c']])\ncheck('singleton replacement', solve(['b'], 'a'), ['b', ['a']])\ncheck('equal minimum', solve(['a', 'b'], 'a'), ['a', ['a', 'b']])\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":"1cc99fd3c1e7bced7e81af1052063d85cdeef0d0bd049aae6b86d337b2051bf8","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=list(x); heapq.heapify(a); v=heapq.heapreplace(a,y); return [v,sorted(a)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('smaller replacement retained', solve(['b', 'c'], 'a'), ['b', ['a', 'c']])\ncheck('larger replacement retained', solve(['a', 'b'], 'c'), ['a', ['b', 'c']])\ncheck('singleton replacement', solve(['b'], 'a'), ['b', ['a']])\ncheck('equal minimum', solve(['a', 'b'], 'a'), ['a', ['a', 'b']])\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-heapreplace-always-evicts-old-minimum","generated_at":"2026-09-29T14:37:42.924448+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":"For a nonempty heap, replace and return the old minimum even if the new value is smaller.","root_cause":"Push-pop can discard the new item rather than the required old minimum.","sha256":"70e46641333da0b568ae396b173c8821ea8deeef0541d2c0920a92429a391fd5","title":"Heapreplace always evicts old minimum · 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.878,"exit_code":1,"observations":[{"actual":["b",["c"]],"check":"smaller replacement retained","expected":["b",["a","c"]],"passed":false},{"actual":["a",["b"]],"check":"larger replacement retained","expected":["a",["b","c"]],"passed":false},{"actual":["b",[]],"check":"singleton replacement","expected":["b",["a"]],"passed":false},{"actual":["a",["b"]],"check":"equal minimum","expected":["a",["a","b"]],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"smaller replacement retained\", \"actual\": [\"b\", [\"c\"]], \"expected\": [\"b\", [\"a\", \"c\"]], \"passed\": false}, {\"check\": \"larger replacement retained\", \"actual\": [\"a\", [\"b\"]], \"expected\": [\"a\", [\"b\", \"c\"]], \"passed\": false}, {\"check\": \"singleton replacement\", \"actual\": [\"b\", []], \"expected\": [\"b\", [\"a\"]], \"passed\": false}, {\"check\": \"equal minimum\", \"actual\": [\"a\", [\"b\"]], \"expected\": [\"a\", [\"a\", \"b\"]], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":37.823,"exit_code":1,"observations":[{"actual":["a",["b","c"]],"check":"smaller replacement retained","expected":["b",["a","c"]],"passed":false},{"actual":["a",["b","c"]],"check":"larger replacement retained","expected":["a",["b","c"]],"passed":true},{"actual":["a",["b"]],"check":"singleton replacement","expected":["b",["a"]],"passed":false},{"actual":["a",["a","b"]],"check":"equal minimum","expected":["a",["a","b"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"smaller replacement retained\", \"actual\": [\"a\", [\"b\", \"c\"]], \"expected\": [\"b\", [\"a\", \"c\"]], \"passed\": false}, {\"check\": \"larger replacement retained\", \"actual\": [\"a\", [\"b\", \"c\"]], \"expected\": [\"a\", [\"b\", \"c\"]], \"passed\": true}, {\"check\": \"singleton replacement\", \"actual\": [\"a\", [\"b\"]], \"expected\": [\"b\", [\"a\"]], \"passed\": false}, {\"check\": \"equal minimum\", \"actual\": [\"a\", [\"a\", \"b\"]], \"expected\": [\"a\", [\"a\", \"b\"]], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":36.016,"exit_code":0,"observations":[{"actual":["b",["a","c"]],"check":"smaller replacement retained","expected":["b",["a","c"]],"passed":true},{"actual":["a",["b","c"]],"check":"larger replacement retained","expected":["a",["b","c"]],"passed":true},{"actual":["b",["a"]],"check":"singleton replacement","expected":["b",["a"]],"passed":true},{"actual":["a",["a","b"]],"check":"equal minimum","expected":["a",["a","b"]],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"smaller replacement retained\", \"actual\": [\"b\", [\"a\", \"c\"]], \"expected\": [\"b\", [\"a\", \"c\"]], \"passed\": true}, {\"check\": \"larger replacement retained\", \"actual\": [\"a\", [\"b\", \"c\"]], \"expected\": [\"a\", [\"b\", \"c\"]], \"passed\": true}, {\"check\": \"singleton replacement\", \"actual\": [\"b\", [\"a\"]], \"expected\": [\"b\", [\"a\"]], \"passed\": true}, {\"check\": \"equal minimum\", \"actual\": [\"a\", [\"a\", \"b\"]], \"expected\": [\"a\", [\"a\", \"b\"]], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}