abhigyanpatwari/GitNexus · error · ValueError

oracle sanitization retained reflog metadata

Error message

oracle sanitization retained reflog metadata

What it means

Post-condition: after `shutil.rmtree(.git/logs)` and reflog expiry, .git/logs must not exist or be a symlink. If it re-appears, reflog metadata survived and could keep oracle-bearing commits reachable, so the harness aborts.

Source

Thrown at eval/workflow_bench/oracle_assets.py:458

    hidden_listing = _git_checked(
        root,
        ["ls-tree", "-r", "--name-only", "HEAD", "--", HIDDEN_HARNESS_PATH.as_posix()],
        timeout=60,
    )
    if hidden_listing or current.exists() or current.is_symlink():
        raise ValueError("oracle sanitization left the benchmark harness visible")
    if _git_checked(root, ["status", "--porcelain=v1", "--untracked-files=all"], timeout=60):
        raise ValueError("oracle sanitization did not produce a clean task snapshot")
    if _git_checked(root, ["rev-parse", "--verify", "HEAD^{commit}"], timeout=60) != sanitized_head:
        raise ValueError("oracle sanitization did not retain its parentless task snapshot")
    parents = _git_checked(root, ["show", "-s", "--format=%P", "HEAD"], timeout=60)
    if parents:
        raise ValueError("oracle sanitization snapshot unexpectedly retained parent history")
    if _git_checked(root, ["remote"], timeout=60):
        raise ValueError("oracle sanitization retained a repository remote")
    if logs.exists() or logs.is_symlink():
        raise ValueError("oracle sanitization retained reflog metadata")
    return sanitized_head


def _write_stage_file(stage_root: Path, item: OracleFileSnapshot) -> None:
    destination = stage_root.joinpath(*PurePosixPath(item.target).parts)
    destination.parent.mkdir(parents=True, mode=0o700, exist_ok=True)
    current = stage_root
    for part in PurePosixPath(item.target).parts[:-1]:
        current /= part
        metadata = current.lstat()
        if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode):
            raise ValueError(f"oracle stage parent must be a real directory: {item.target}")
        current.chmod(0o700)
    descriptor = os.open(
        destination,
        os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, "O_NOFOLLOW", 0),
        0o400,
    )

View on GitHub (pinned to d540b00184)

Solutions

  1. Disable reflog logging in the clone: `git -C <clone> config core.logAllRefUpdates false` (and `core.logAllRefUpdates=never` on newer git) before sanitizing.
  2. Re-run reflog expire and remove logs again: `git -C <clone> reflog expire --expire=now --all && rm -rf <clone>/.git/logs`.
  3. Ensure no git op runs between rmtree and the final check; re-clone if state is unclear.
Defensive patterns

Strategy: try-catch

Validate before calling

from pathlib import Path

def logs_absent(clone: Path) -> bool:
    logs = clone / ".git" / "logs"
    return not logs.exists() and not logs.is_symlink()

Type guard

def is_reflog_retained(exc: BaseException) -> bool:
    return isinstance(exc, ValueError) and "retained reflog metadata" in str(exc)

Try / catch

try:
    oracle_assets.sanitize_clone_for_hidden_oracles(clone)
except ValueError as exc:
    quarantine(clone)
    raise AbortTask(str(exc)) from exc

Prevention

When it happens

Trigger: Triggered when .git/logs is recreated after rmtree — commonly because a subsequent `git update-ref`/commit re-enabled core.logAllRefUpdates and wrote a new log, or rmtree partially failed and a process recreated the directory.

Common situations: A git operation between rmtree and the check that turns logging back on (default core.logAllRefUpdates=true on clones); core.logAllRefUpdates=true in the clone config; a concurrent writer.

Related errors


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