abhigyanpatwari/GitNexus · critical · ValueError
clone HEAD is not an immutable commit
Error message
clone HEAD is not an immutable commit
What it means
Raised by sanitize_clone_for_hidden_oracles when `git rev-parse --verify HEAD^{commit}` does not return a string of exactly 40 or 64 hexadecimal characters (i.e. a SHA-1 or SHA-256 object id). Without a valid immutable commit at HEAD, the sanitizer cannot record the original HEAD for later update-ref and cannot guarantee a known starting point for history rewriting.
Source
Thrown at eval/workflow_bench/oracle_assets.py:272
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",
"-C",
str(root),
"ls-tree",
"-d",
"--format=%(objectname)",
"HEAD",
"--",
HIDDEN_HARNESS_PATH.as_posix(),
],
timeout=60,
tail_bytes=1024,
)
if not hidden_tree_result.ok:
raise ValueError("cannot inspect the clone for committed benchmark harness data")View on GitHub (pinned to d540b00184)
Solutions
- Ensure the clone has at least one real commit on HEAD before sanitizing.
- Re-clone from the source to get a valid HEAD commit.
- Run `git -C <clone> rev-parse --verify HEAD^{commit}` manually and confirm it prints a 40- or 64-char hex SHA.
- Check the clone is not shallow/corrupted with `git fsck`.
Defensive patterns
Strategy: validation
Validate before calling
import re
from eval.workflow_bench.oracle_assets import _git_checked
def assert_head_commit(clone) -> None:
head = _git_checked(clone, ["rev-parse", "--verify", "HEAD^{commit}"])
if not re.fullmatch(r"[0-9a-fA-F]{40}|[0-9a-fA-F]{64}", head):
raise ValueError(f"HEAD is not a valid commit SHA: {head!r}") Type guard
def head_is_immutable_commit(clone) -> bool:
import re
from eval.workflow_bench.oracle_assets import _git_checked
try:
head = _git_checked(clone, ["rev-parse", "--verify", "HEAD^{commit}"])
except Exception:
return False
return bool(re.fullmatch(r"[0-9a-fA-F]{40}|[0-9a-fA-F]{64}", head)) Try / catch
try:
head = sanitize_clone_for_hidden_oracles(clone)
except ValueError as exc:
if "not an immutable commit" in str(exc):
raise SystemExit("Clone HEAD is unborn/invalid; commit at least once or re-clone") from exc
raise Prevention
- Ensure the clone has at least one commit on the default branch.
- Avoid sanitizing empty or freshly-init repos.
- Re-clone from source if HEAD is in a bad state.
When it happens
Trigger: The clone has no commits (unborn HEAD, fresh `git init` with nothing committed); HEAD is detached at a tag or non-commit object; git rev-parse output is malformed/empty; a corrupted repository where HEAD is not resolvable to a commit.
Common situations: Sanitizing a brand-new empty repo; a clone that failed to fetch any commits; a shallow clone with a broken HEAD; repository corruption; an unusual git version producing unexpected rev-parse output.
Related errors
- oracle sanitization requires a self-contained clone: {root}
- oracle sanitization requires a real self-contained clone: {r
- cannot inspect the clone for committed benchmark harness dat
- committed benchmark harness is not a single bounded tree
- oracle root must be a real non-symlink directory: {lexical}
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/7167208ccbfd34f8.
Report an issue: GitHub.