{"record":{"id":"36d81fdea551ee77","repo":"Hmbown/CodeWhale","slug":"source-provenance-command-failed-join-command","errorCode":null,"errorMessage":"source provenance command failed: {' '.join(command)}","messagePattern":"source provenance command failed: (.+?)","errorType":"validation","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":119,"sourceCode":"\ndef validate_frozen_field(field: str, value: Any, expected: Any) -> None:\n    if type(value) is not type(expected) or value != expected:\n        raise PersistenceBacklogError(\n            f\"receipt {field} must remain {expected!r}, got {value!r}\"\n        )\n\n\ndef current_source_identity() -> dict[str, Any]:\n    def run(command: list[str]) -> str:\n        result = subprocess.run(\n            command,\n            cwd=ROOT,\n            text=True,\n            capture_output=True,\n            check=False,\n        )\n        if result.returncode != 0:\n            raise PersistenceBacklogError(\n                f\"source provenance command failed: {' '.join(command)}\"\n            )\n        return result.stdout.strip()\n\n    return {\n        \"source_sha\": run([\"git\", \"rev-parse\", \"HEAD\"]),\n        \"source_dirty\": bool(\n            run([\"git\", \"status\", \"--porcelain\", \"--untracked-files=normal\"])\n        ),\n        \"rustc_version\": run([\"rustc\", \"--version\"]),\n        \"cargo_version\": run([\"cargo\", \"--version\"]),\n        \"build_profile\": \"test\",\n        \"sample_count\": 1,\n    }\n\n\ndef validate_receipt(\n    receipt: dict[str, Any],","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L101-L137","documentation":"This error is raised by the `run` helper inside `current_source_identity()` when a provenance command (`git rev-parse HEAD`, `git status --porcelain`, `rustc --version`, or `cargo --version`) exits with a non-zero status. The script needs a trustworthy snapshot of the current source tree and toolchain before validating a persistence backlog receipt; if any command fails, that snapshot cannot be built, so the check aborts rather than comparing against unverified provenance. The message includes the exact command that failed.","triggerScenarios":"Running `check-persistence-backlog-budget.py` outside a git repository or with a broken HEAD; `rustc` or `cargo` not installed or not on PATH; git refusing due to dubious ownership or a corrupt index; any of the four subprocess calls returning a non-zero returncode.","commonSituations":"Executing the script in a CI container without the Rust toolchain installed; running it from an exported tarball instead of a git clone; a stale Git safe.directory configuration in Docker; a corrupted .git directory.","solutions":["Install the Rust toolchain (rustc and cargo) and confirm `rustc --version` and `cargo --version` succeed at the repo root","Run `git rev-parse HEAD` and `git status --porcelain` manually at the repo root to see the underlying git failure","If git reports dubious ownership, run `git config --global --add safe.directory <repo-path>`","Run the script from inside a valid git clone of the repository rather than a plain directory"],"exampleFix":"// before (in shell, script fails)\n$ python scripts/check-persistence-backlog-budget.py\n[persistence-backlog-budget] ERROR: source provenance command failed: rustc --version\n// after\n$ cargo --version   # install rustup first if missing\n$ python scripts/check-persistence-backlog-budget.py","handlingStrategy":"try-catch","validationCode":"import subprocess, shutil\ndef provenance_ready(root):\n    for cmd in ([\"git\", \"rev-parse\", \"HEAD\"], [\"git\", \"status\", \"--porcelain\"], [\"rustc\", \"--version\"], [\"cargo\", \"--version\"]):\n        if shutil.which(cmd[0]) is None:\n            return False\n        r = subprocess.run(cmd, cwd=root, capture_output=True, text=True)\n        if r.returncode != 0:\n            return False\n    return True","typeGuard":"def has_git_repo(root):\n    return (root / \".git\").exists() and shutil.which(\"git\") is not None","tryCatchPattern":"try:\n    receipt = check_budget()\nexcept PersistenceBacklogError as e:\n    if \"source provenance command failed\" in str(e):\n        install_toolchain_or_fix_git(e)\n    else:\n        raise","preventionTips":["Verify rustc/cargo/git are on PATH in CI images before running budget checks","Always run the script inside a real git clone, not an exported archive","Add `git config --global --add safe.directory` in containerized builds","Smoke-test `git rev-parse HEAD` in a preflight step"],"tags":["git","subprocess","toolchain","provenance"],"backgroundTag":"git-command-failed","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}