abhigyanpatwari/GitNexus · critical · ValueError

oracle sanitization requires a self-contained clone: {root}

Error message

oracle sanitization requires a self-contained clone: {root}

What it means

Raised by sanitize_clone_for_hidden_oracles when lstat() on either the clone root or its '.git' entry raises OSError. The function requires a self-contained clone (a real directory plus a real '.git' directory) so it can surgically rewrite history and remove recoverable oracle bytes. If the root or .git cannot even be stat-ed, sanitization cannot proceed safely.

Source

Thrown at eval/workflow_bench/oracle_assets.py:258

    return result.stdout_tail.strip()


def sanitize_clone_for_hidden_oracles(clone: Path) -> str:
    """Remove the harness and its recoverable Git history from a disposable clone.

    A read-only mount over the checked-out harness is insufficient: a model
    could recover committed oracle bytes with ``git show``. Build a parentless
    commit from the clone's existing index after removing the complete harness,
    discard every other reference/reflog, and prune unreachable objects before
    any task asset, setup command, or model session is allowed to run.
    """

    root = clone.expanduser().absolute()
    try:
        root_metadata = root.lstat()
        git_metadata = (root / ".git").lstat()
    except OSError as exc:
        raise ValueError(f"oracle sanitization requires a self-contained clone: {root}") from exc
    if (
        stat.S_ISLNK(root_metadata.st_mode)
        or not stat.S_ISDIR(root_metadata.st_mode)
        or root.resolve(strict=True) != root
        or stat.S_ISLNK(git_metadata.st_mode)
        or not stat.S_ISDIR(git_metadata.st_mode)
    ):
        raise ValueError(f"oracle sanitization requires a real self-contained clone: {root}")

    original_head = _git_checked(root, ["rev-parse", "--verify", "HEAD^{commit}"])
    if len(original_head) not in {40, 64} or any(
        character not in "0123456789abcdefABCDEF" for character in original_head
    ):
        raise ValueError("clone HEAD is not an immutable commit")

    hidden_tree_result = run_managed(
        [
            "git",

View on GitHub (pinned to d540b00184)

Solutions

  1. Pass a real git clone directory that contains a '.git' entry.
  2. Re-run the clone step that produces the disposable clone before calling sanitize.
  3. Confirm the path exists and is accessible (ls -la <clone> shows '.git').
  4. Check that the harness process has permission to lstat the root and '.git'.
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def assert_clone_ready(clone: Path) -> None:
    root = clone.expanduser().absolute()
    if not root.is_dir() or not (root / ".git").exists():
        raise FileNotFoundError(f"clone missing root or .git: {root}")

Type guard

def is_self_contained_clone(clone) -> bool:
    root = Path(clone).expanduser().absolute()
    return root.is_dir() and (root / ".git").exists()

Try / catch

try:
    head = sanitize_clone_for_hidden_oracles(clone)
except ValueError as exc:
    if "self-contained clone" in str(exc):
        raise SystemExit(f"Re-clone a real git repo: {exc}") from exc
    raise

Prevention

When it happens

Trigger: Calling sanitize_clone_for_hidden_oracles(clone) where clone does not exist; '.git' does not exist (not a git repo); clone is on an unmounted/inaccessible path; permissions deny lstat.

Common situations: Passing a plain working directory that was never `git clone`-ed; pointing at a path where the clone was deleted; running in CI where the clone step was skipped or failed; a shallow/broken clone missing '.git'.

Related errors


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