abhigyanpatwari/GitNexus · error · ValueError

oracle sanitization did not retain its parentless task snaps

Error message

oracle sanitization did not retain its parentless task snapshot

What it means

Post-condition: `git rev-parse --verify HEAD^{commit}` must equal the sanitized_head computed earlier from `git commit-tree`. A mismatch means HEAD moved between writing the parentless commit and verifying it, so the harness cannot trust the snapshot identity.

Source

Thrown at eval/workflow_bench/oracle_assets.py:451

            ["git", "-C", str(root), "cat-file", "-e", forbidden_object],
            timeout=60,
        )
        if probe.ok:
            raise ValueError(f"oracle sanitization left the {label} recoverable")
        if probe.state != "exited" or probe.returncode not in {1, 128}:
            raise ValueError(f"oracle sanitization could not verify removal of the {label}")

    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):

View on GitHub (pinned to d540b00184)

Solutions

  1. Compare: `git -C <clone> rev-parse HEAD^{commit}` vs the sanitized_head from commit-tree.
  2. Disable hooks for the clone: `git -C <clone> config core.hooksFile /dev/null` and run with `-c core.hooksPath=/dev/null`.
  3. Ensure no other git process (IDE, daemon, concurrent task) touches the clone during sanitization.
  4. Re-clone and sanitize in a single-process, hooks-disabled environment.
Defensive patterns

Strategy: try-catch

Validate before calling

from pathlib import Path
from eval.workflow_bench.process_control import run_checked

def head_matches(clone: Path, expected_sha: str) -> bool:
    got = run_checked(["git","-C",str(clone),"rev-parse","--verify","HEAD^{commit}"], timeout=60).stdout_tail.strip()
    return got == expected_sha

Type guard

def is_head_drift(exc: BaseException) -> bool:
    return isinstance(exc, ValueError) and "did not retain its parentless task snapshot" 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 HEAD changes after `update-ref HEAD <sanitized_head>` — e.g., a git hook (post-commit, post-rewrite), a concurrent git process, or an IDE that auto-checks-out another ref during the sanitization window.

Common situations: A core.hooksPath hook that runs git operations on commit; a concurrent `git checkout` from an IDE or another task; a reflog rewrite by gc running in the background.

Related errors


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