{"record":{"id":"846e706dd5705e86","repo":"abhigyanpatwari/GitNexus","slug":"frozen-overlay-bytes-do-not-match-the-authorized-i","errorCode":null,"errorMessage":"frozen overlay bytes do not match the authorized input","messagePattern":"frozen overlay bytes do not match the authorized input","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"eval/workflow_bench/promotion_apply.py","lineNumber":82,"sourceCode":"                    handle.flush()\n                    os.fsync(handle.fileno())\n            finally:\n                os.close(descriptor)\n        for directory in sorted(\n            (path for path in staging.rglob(\"*\") if path.is_dir()),\n            key=lambda path: len(path.parts),\n            reverse=True,\n        ):\n            directory.chmod(0o500)\n        staging.chmod(0o500)\n        os.replace(staging, destination)\n    except BaseException:\n        if staging.exists():\n            shutil.rmtree(staging)\n        raise\n    frozen_digest, _ = candidate_overlay_payload(destination)\n    if frozen_digest != digest:\n        raise RuntimeError(\"frozen overlay bytes do not match the authorized input\")\n    return digest\n\n\ndef _stage_replacement(path: Path, content: bytes, mode: int) -> Path:\n    descriptor, raw_path = tempfile.mkstemp(prefix=\".wfevolve-\", dir=path.parent)\n    staged = Path(raw_path)\n    try:\n        os.fchmod(descriptor, stat.S_IMODE(mode))\n        with os.fdopen(descriptor, \"wb\", closefd=False) as handle:\n            handle.write(content)\n            handle.flush()\n            os.fsync(handle.fileno())\n    except BaseException:\n        # A partially written candidate/backup is never eligible for later\n        # cleanup through the replacements list, so remove it here before the\n        # staging exception escapes.\n        os.close(descriptor)\n        staged.unlink(missing_ok=True)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/promotion_apply.py#L64-L100","documentation":"After freeze_overlay's atomic os.replace, the harness re-reads the destination via candidate_overlay_payload and compares digests. A mismatch raises RuntimeError — the bytes on disk do not match the bytes that were authorized. This is a hard integrity failure: the frozen snapshot cannot be trusted.","triggerScenarios":"Triggered when frozen_digest != digest at the end of freeze_overlay. Causes: a concurrent process modified files between fsync and re-read; a CoW / dedup / sync layer altered bytes; a disk error; antivirus rewrote the file; encoding/line-ending translation by a sync driver.","commonSituations":"Running on SMB / NFS / VirtualBox synced folders that mangle bytes; AV scanner that 'disinfects' the freshly-written file; an overlay filesystem with snapshot interference; an SSD with failing flash translating bytes (very rare).","solutions":["Run the promotion on a local, non-synced filesystem (ext4/xfs/tmpfs).","Disable real-time AV scanning for the destination directory.","Capture both digests in the log and inspect the destination bytes (xxd / cmp) to identify what changed.","If reproducible, file a bug — the harness assumes a stable byte channel and the cause is environmental."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# After freeze_overlay, also verify on a known-quiet local filesystem.\nimport hashlib\nfrom pathlib import Path\n\ndef local_fs(path: Path) -> bool:\n    # crude check: refuse SMB/NFS/vboxsf\n    import shutil\n    total, used, free = shutil.disk_usage(path)\n    st = path.stat()\n    return st.st_dev  # caller can map to known local devs","typeGuard":null,"tryCatchPattern":"try:\n    digest = freeze_overlay(overlay, destination)\nexcept RuntimeError as exc:\n    if 'do not match the authorized input' in str(exc):\n        log.critical('filesystem corrupted frozen overlay; rerun on local disk without AV')\n    raise","preventionTips":["Run promotion on local disk (ext4/xfs/tmpfs) only — never on SMB/NFS/synced folders.","Disable real-time AV scanning on the destination directory.","If reproducible, capture both digests and diff the destination bytes."],"tags":["overlay","promotion","integrity","filesystem","diagnostic"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}