abhigyanpatwari/GitNexus · critical · RuntimeError

frozen overlay bytes do not match the authorized input

Error message

frozen overlay bytes do not match the authorized input

What it means

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.

Source

Thrown at eval/workflow_bench/promotion_apply.py:82

                    handle.flush()
                    os.fsync(handle.fileno())
            finally:
                os.close(descriptor)
        for directory in sorted(
            (path for path in staging.rglob("*") if path.is_dir()),
            key=lambda path: len(path.parts),
            reverse=True,
        ):
            directory.chmod(0o500)
        staging.chmod(0o500)
        os.replace(staging, destination)
    except BaseException:
        if staging.exists():
            shutil.rmtree(staging)
        raise
    frozen_digest, _ = candidate_overlay_payload(destination)
    if frozen_digest != digest:
        raise RuntimeError("frozen overlay bytes do not match the authorized input")
    return digest


def _stage_replacement(path: Path, content: bytes, mode: int) -> Path:
    descriptor, raw_path = tempfile.mkstemp(prefix=".wfevolve-", dir=path.parent)
    staged = Path(raw_path)
    try:
        os.fchmod(descriptor, stat.S_IMODE(mode))
        with os.fdopen(descriptor, "wb", closefd=False) as handle:
            handle.write(content)
            handle.flush()
            os.fsync(handle.fileno())
    except BaseException:
        # A partially written candidate/backup is never eligible for later
        # cleanup through the replacements list, so remove it here before the
        # staging exception escapes.
        os.close(descriptor)
        staged.unlink(missing_ok=True)

View on GitHub (pinned to d540b00184)

Solutions

  1. Run the promotion on a local, non-synced filesystem (ext4/xfs/tmpfs).
  2. Disable real-time AV scanning for the destination directory.
  3. Capture both digests in the log and inspect the destination bytes (xxd / cmp) to identify what changed.
  4. If reproducible, file a bug — the harness assumes a stable byte channel and the cause is environmental.
Defensive patterns

Strategy: validation

Validate before calling

# After freeze_overlay, also verify on a known-quiet local filesystem.
import hashlib
from pathlib import Path

def local_fs(path: Path) -> bool:
    # crude check: refuse SMB/NFS/vboxsf
    import shutil
    total, used, free = shutil.disk_usage(path)
    st = path.stat()
    return st.st_dev  # caller can map to known local devs

Try / catch

try:
    digest = freeze_overlay(overlay, destination)
except RuntimeError as exc:
    if 'do not match the authorized input' in str(exc):
        log.critical('filesystem corrupted frozen overlay; rerun on local disk without AV')
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/846e706dd5705e86. Report an issue: GitHub.