{"record":{"id":"408b844efa8b7c1b","repo":"Hmbown/CodeWhale","slug":"receipt-field-does-not-match-the-checked-source","errorCode":null,"errorMessage":"receipt {field} does not match the checked source","messagePattern":"receipt (.+?) does not match the checked source","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":174,"sourceCode":"        raise PersistenceBacklogError(\"receipt source_sha must be an exact lowercase Git SHA\")\n    if type(receipt[\"source_dirty\"]) is not bool:\n        raise PersistenceBacklogError(\"receipt source_dirty must be boolean\")\n    for field, prefix in ((\"rustc_version\", \"rustc \"), (\"cargo_version\", \"cargo \")):\n        if not isinstance(receipt[field], str) or not receipt[field].startswith(prefix):\n            raise PersistenceBacklogError(f\"receipt {field} must be a version string\")\n    validate_frozen_field(\"build_profile\", receipt[\"build_profile\"], \"test\")\n    validate_frozen_field(\"sample_count\", receipt[\"sample_count\"], 1)\n    if expected_source is not None:\n        for field in (\n            \"source_sha\",\n            \"source_dirty\",\n            \"rustc_version\",\n            \"cargo_version\",\n            \"build_profile\",\n            \"sample_count\",\n        ):\n            if receipt[field] != expected_source[field]:\n                raise PersistenceBacklogError(\n                    f\"receipt {field} does not match the checked source\"\n                )\n    if require_clean_source and receipt[\"source_dirty\"]:\n        raise PersistenceBacklogError(\"persistence measurement source tree is dirty\")\n    platform = receipt[\"platform\"]\n    if not isinstance(platform, str) or platform not in SUPPORTED_PLATFORMS:\n        raise PersistenceBacklogError(\"receipt platform is unsupported\")\n\n    attempted = non_negative_integer(receipt[\"requests_attempted\"], \"requests_attempted\")\n    accepted = non_negative_integer(receipt[\"accepted_requests\"], \"accepted_requests\")\n    if accepted != attempted:\n        raise PersistenceBacklogError(\n            \"accepted_requests must equal requests_attempted; sender rejection is not backlog improvement\"\n        )\n    retained = non_negative_integer(\n        receipt[\"retained_queued_requests\"], \"retained_queued_requests\"\n    )\n    if retained > accepted:","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L156-L192","documentation":"Raised in validate_receipt (scripts/check-persistence-backlog-budget.py:164-176) when an expected_source was supplied (main() always passes current_source_identity()) and one of source_sha, source_dirty, rustc_version, cargo_version, build_profile, or sample_count differs between the receipt and the environment performing the check. This pins every receipt to the exact commit, tree cleanliness, and toolchain that produced it, so stale receipts cannot gate different code.","triggerScenarios":"Re-checking an old --receipt after new commits landed (SHA mismatch); upgrading rustc/cargo between measurement and check; the tree being clean at measurement but dirty at check time (or vice versa); build_profile/sample_count written differently by the emitter.","commonSituations":"Reusing yesterday's receipt artifact in CI; developer measured locally then pulled upstream; toolchain auto-update between jobs.","solutions":["Re-measure at the current HEAD: run scripts/measure-persistence-backlog.py, or run the checker without --receipt.","Commit or stash local changes so source_dirty agrees between measurement and check.","Pin the Rust toolchain (rustup toolchain file or +version) across measure and check steps.","Treat receipts as single-commit artifacts — never cache and reuse them."],"exampleFix":"# before (stale receipt across commits)\npython scripts/check-persistence-backlog-budget.py --receipt cached-receipt.json\n# after (fresh measurement pinned to HEAD)\npython scripts/check-persistence-backlog-budget.py","handlingStrategy":"validation","validationCode":"import subprocess\nexpected = subprocess.run([\"git\", \"rev-parse\", \"HEAD\"], cwd=ROOT, text=True, capture_output=True).stdout.strip()\nif receipt[\"source_sha\"] != expected:\n    sys.exit(\"receipt predates current HEAD; re-measure before checking\")","typeGuard":null,"tryCatchPattern":"try:\n    validate_receipt(receipt, expected_source=current_source_identity())\nexcept PersistenceBacklogError as e:\n    if \"does not match the checked source\" in str(e):\n        raise RuntimeError(\"stale receipt: provenance differs from this checkout/toolchain\") from e\n    raise","preventionTips":["Generate and check receipts in the same job on the same commit — never reuse across commits.","Commit or stash changes and keep the toolchain identical between measure and check.","Have CI run the checker without --receipt so provenance is captured live."],"tags":["provenance","git","validation","ci"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}