{"record":{"id":"36d81fdea551ee77","repo":"Hmbown/CodeWhale","slug":"source-provenance-command-failed-join-comman","errorCode":null,"errorMessage":"source provenance command failed: {' '.join(command)}","messagePattern":"source provenance command failed: (.+?)","errorType":"exception","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/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L101-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run from a full git clone and confirm `git rev-parse HEAD` succeeds in the repo root.","Install/activate the Rust toolchain (rustup default stable) so `rustc --version` and `cargo --version` work in the same shell.","If the repo has no commits yet, create one before running the budget check.","In containers, mount or clone the repository instead of copying a gitless source tree."],"exampleFix":"# before (gitless export)\ncd codewhale-src-export && python scripts/check-persistence-backlog-budget.py\n# after (full clone)\ngit clone <repo> codewhale && cd codewhale && python scripts/check-persistence-backlog-budget.py","handlingStrategy":"validation","validationCode":"import shutil, subprocess\n\nfor tool in (\"git\", \"rustc\", \"cargo\"):\n    if shutil.which(tool) is None:\n        sys.exit(f\"missing {tool} on PATH; fix the environment before checking the budget\")\nif subprocess.run([\"git\", \"rev-parse\", \"HEAD\"], cwd=ROOT, capture_output=True).returncode != 0:\n    sys.exit(\"not a git repo with commits; clone the full repository first\")","typeGuard":null,"tryCatchPattern":"try:\n    identity = current_source_identity()\nexcept PersistenceBacklogError as e:\n    if \"provenance command failed\" in str(e):\n        print(\"environment lacks git/rustc/cargo; run from a full clone with a Rust toolchain\")\n    raise","preventionTips":["Run the gate only from a full git clone with rustup-managed toolchain on PATH.","In CI/containers, verify git and the Rust toolchain are installed before invoking the checker.","Prefer `git clean -xfd` over exporting source trees without .git."],"tags":["environment","git","toolchain","provenance"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}