Hmbown/CodeWhale · error · PersistenceBacklogError

source provenance command failed: {' '.join(command)}

Error message

source provenance command failed: {' '.join(command)}

What it means

Raised in current_source_identity (scripts/check-persistence-backlog-budget.py:118-121) when one of the provenance commands — git rev-parse HEAD, git status --porcelain --untracked-files=normal, rustc --version, cargo --version — exits non-zero. The checker captures the current toolchain and commit identity to pin receipts to the exact source that produced them, so the environment must have a working git repository and Rust toolchain before validation starts.

Source

Thrown at scripts/check-persistence-backlog-budget.py:119

def validate_frozen_field(field: str, value: Any, expected: Any) -> None:
    if type(value) is not type(expected) or value != expected:
        raise PersistenceBacklogError(
            f"receipt {field} must remain {expected!r}, got {value!r}"
        )


def current_source_identity() -> dict[str, Any]:
    def run(command: list[str]) -> str:
        result = subprocess.run(
            command,
            cwd=ROOT,
            text=True,
            capture_output=True,
            check=False,
        )
        if result.returncode != 0:
            raise PersistenceBacklogError(
                f"source provenance command failed: {' '.join(command)}"
            )
        return result.stdout.strip()

    return {
        "source_sha": run(["git", "rev-parse", "HEAD"]),
        "source_dirty": bool(
            run(["git", "status", "--porcelain", "--untracked-files=normal"])
        ),
        "rustc_version": run(["rustc", "--version"]),
        "cargo_version": run(["cargo", "--version"]),
        "build_profile": "test",
        "sample_count": 1,
    }


def validate_receipt(
    receipt: dict[str, Any],

View on GitHub (pinned to 8880682c63)

Solutions

  1. Run from a full git clone and confirm `git rev-parse HEAD` succeeds in the repo root.
  2. Install/activate the Rust toolchain (rustup default stable) so `rustc --version` and `cargo --version` work in the same shell.
  3. If the repo has no commits yet, create one before running the budget check.
  4. In containers, mount or clone the repository instead of copying a gitless source tree.

Example fix

# before (gitless export)
cd codewhale-src-export && python scripts/check-persistence-backlog-budget.py
# after (full clone)
git clone <repo> codewhale && cd codewhale && python scripts/check-persistence-backlog-budget.py
Defensive patterns

Strategy: validation

Validate before calling

import shutil, subprocess

for tool in ("git", "rustc", "cargo"):
    if shutil.which(tool) is None:
        sys.exit(f"missing {tool} on PATH; fix the environment before checking the budget")
if subprocess.run(["git", "rev-parse", "HEAD"], cwd=ROOT, capture_output=True).returncode != 0:
    sys.exit("not a git repo with commits; clone the full repository first")

Try / catch

try:
    identity = current_source_identity()
except PersistenceBacklogError as e:
    if "provenance command failed" in str(e):
        print("environment lacks git/rustc/cargo; run from a full clone with a Rust toolchain")
    raise

Prevention

When it happens

Trigger: Running the script outside a git repository (ROOT resolved from a tarball/source export); a freshly `git init`-ed repo with no commits (rev-parse HEAD fails on unborn branch); git, rustc, or cargo not on PATH; a corrupted .git directory.

Common situations: CI images that strip git; Docker containers with source COPYed in without .git; rustup not sourced in a non-login shell; running from an extracted release archive.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/36d81fdea551ee77. Report an issue: GitHub.