{"record":{"id":"f61bcdc637785038","repo":"abhigyanpatwari/GitNexus","slug":"atomic-overlay-exchange-parity-check-failed-repl","errorCode":null,"errorMessage":"atomic overlay exchange parity check failed: {replacement['target']}","messagePattern":"atomic overlay exchange parity check failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"eval/workflow_bench/promotion_apply.py","lineNumber":800,"sourceCode":"                completed.append(replacement)\n            observed_destination = current_state(replacement)\n            observed_previous = entry_state(replacement, replacement[\"candidate\"])\n            destination_identity = _entry_identity_at(\n                replacement[\"parent_descriptor\"],\n                replacement[\"name\"],\n            )\n            displaced_identity = _entry_identity_at(\n                replacement[\"parent_descriptor\"],\n                replacement[\"candidate\"],\n            )\n            if (\n                observed_destination == replacement[\"candidate_state\"]\n                and observed_previous == replacement[\"base_state\"]\n                and destination_identity == replacement[\"candidate_identity\"]\n                and displaced_identity == previous_identity\n            ):\n                continue\n            raise RuntimeError(f\"atomic overlay exchange parity check failed: {replacement['target']}\")\n        for replacement in replacements:\n            if (\n                current_state(replacement) != replacement[\"candidate_state\"]\n                or entry_state(replacement, replacement[\"candidate\"]) != replacement[\"base_state\"]\n                or _entry_identity_at(replacement[\"parent_descriptor\"], replacement[\"name\"])\n                != replacement[\"candidate_identity\"]\n                or _entry_identity_at(replacement[\"parent_descriptor\"], replacement[\"candidate\"])\n                != replacement[\"publication_previous_identity\"]\n            ):\n                raise RuntimeError(f\"post-apply parity check failed: {replacement['target']}\")\n        _validate_prepared_paths(\n            repo_root,\n            root_descriptor,\n            replacements,\n            phase=\"post-apply validation\",\n        )\n        published_all = True\n    except BaseException as exc:","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/promotion_apply.py#L782-L818","documentation":"Thrown immediately after a single `_exchange_at` returned success but the four-way parity check (destination==candidate_state, displaced==base_state, identity match on both slots) failed. The atomic swap reported success yet the resulting directory entries do not look like a clean RENAME_EXCHANGE, indicating kernel/filesystem misbehavior or a race that the syscall did not serialize.","triggerScenarios":"`renameat2(RENAME_EXCHANGE)` returned 0 but the destination slot does not hold the candidate bytes/identity or the displaced slot does not hold the original. Seen on filesystems that silently degrade RENAME_EXCHANGE, under heavy concurrent I/O, or when an external editor rewrote both slots in the same window.","commonSituations":"Overlayfs/fuse/NFS pretending to support RENAME_EXCHANGE; a kernel bug; an antivirus or sync client rewriting files mid-swap; concurrent `apply_promoted_overlay` on the same target; storage with non-atomic metadata updates.","solutions":["Move the target directory to a filesystem with reliable RENAME_EXCHANGE (ext4/xfs/btrfs on kernel >= 3.15) — see also error 401.","Serialize promotion so no two callers act on the same target set (lock file / mutex).","Reproduce with a standalone probe that does RENAME_EXCHANGE then stat-checks both slots on the exact directory+FS.","If reproducible, file a kernel/filesystem bug; meanwhile fall back to a non-atomic publish on a known-good FS."],"exampleFix":"# probe RENAME_EXCHANGE reliability on the exact target FS before relying on it\nimport ctypes, os, tempfile\nd = tempfile.mkdtemp(dir=str(repo_root))  # same FS as the targets\na = os.path.join(d, 'a'); b = os.path.join(d, 'b')\nopen(a,'w').write('A'); open(b,'w').write('B')\nfd = os.open(d, os.O_RDONLY)\nlibc = ctypes.CDLL(None, use_errno=True)\nlibc.renameat2(fd, b'a', fd, b'b', 2)  # check return + both file contents after","handlingStrategy":"validation","validationCode":"# see error 401's filesystem_supports_rename_exchange probe — run it on the\n# EXACT parent directory of every target before relying on RENAME_EXCHANGE.\nfrom workflow_bench.promotion_apply import _prepare_targets, candidate_overlay_payload\n\ndef all_target_parents_support_exchange(overlay, repo_root) -> bool:\n    _, payload = candidate_overlay_payload(overlay)\n    _, _, prepared = _prepare_targets(payload, repo_root)\n    try:\n        return all(filesystem_supports_rename_exchange(str(p[\"parent_path\"])) for p in prepared)\n    finally:\n        from workflow_bench.promotion_apply import _close_prepared\n        _close_prepared(prepared[0][\"parent_descriptor\"], prepared)  # close descriptors","typeGuard":"null","tryCatchPattern":"try:\n    apply_promoted_overlay(overlay, expected_target_bases=bases)\nexcept RuntimeError as exc:\n    if \"parity check failed\" in str(exc):\n        # suspect FS misbehaviour; do NOT auto-retry on the same FS\n        raise SystemExit(f\"parity failure on {exc}; move repo to ext4/xfs/btrfs\")\n    raise","preventionTips":["Probe every target's parent directory for reliable RENAME_EXCHANGE before apply.","Never silently retry a parity failure — it usually means the FS lied about atomicity.","Keep promotion off overlayfs/fuse/network filesystems."],"tags":["integrity","parity","renameat2","filesystem","atomic"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}