Hmbown/CodeWhale · error · PersistenceBacklogError

receipt {field} does not match the checked source

Error message

receipt {field} does not match the checked source

What it means

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.

Source

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

        raise PersistenceBacklogError("receipt source_sha must be an exact lowercase Git SHA")
    if type(receipt["source_dirty"]) is not bool:
        raise PersistenceBacklogError("receipt source_dirty must be boolean")
    for field, prefix in (("rustc_version", "rustc "), ("cargo_version", "cargo ")):
        if not isinstance(receipt[field], str) or not receipt[field].startswith(prefix):
            raise PersistenceBacklogError(f"receipt {field} must be a version string")
    validate_frozen_field("build_profile", receipt["build_profile"], "test")
    validate_frozen_field("sample_count", receipt["sample_count"], 1)
    if expected_source is not None:
        for field in (
            "source_sha",
            "source_dirty",
            "rustc_version",
            "cargo_version",
            "build_profile",
            "sample_count",
        ):
            if receipt[field] != expected_source[field]:
                raise PersistenceBacklogError(
                    f"receipt {field} does not match the checked source"
                )
    if require_clean_source and receipt["source_dirty"]:
        raise PersistenceBacklogError("persistence measurement source tree is dirty")
    platform = receipt["platform"]
    if not isinstance(platform, str) or platform not in SUPPORTED_PLATFORMS:
        raise PersistenceBacklogError("receipt platform is unsupported")

    attempted = non_negative_integer(receipt["requests_attempted"], "requests_attempted")
    accepted = non_negative_integer(receipt["accepted_requests"], "accepted_requests")
    if accepted != attempted:
        raise PersistenceBacklogError(
            "accepted_requests must equal requests_attempted; sender rejection is not backlog improvement"
        )
    retained = non_negative_integer(
        receipt["retained_queued_requests"], "retained_queued_requests"
    )
    if retained > accepted:

View on GitHub (pinned to 8880682c63)

Solutions

  1. Re-measure at the current HEAD: run scripts/measure-persistence-backlog.py, or run the checker without --receipt.
  2. Commit or stash local changes so source_dirty agrees between measurement and check.
  3. Pin the Rust toolchain (rustup toolchain file or +version) across measure and check steps.
  4. Treat receipts as single-commit artifacts — never cache and reuse them.

Example fix

# before (stale receipt across commits)
python scripts/check-persistence-backlog-budget.py --receipt cached-receipt.json
# after (fresh measurement pinned to HEAD)
python scripts/check-persistence-backlog-budget.py
Defensive patterns

Strategy: validation

Validate before calling

import subprocess
expected = subprocess.run(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True, capture_output=True).stdout.strip()
if receipt["source_sha"] != expected:
    sys.exit("receipt predates current HEAD; re-measure before checking")

Try / catch

try:
    validate_receipt(receipt, expected_source=current_source_identity())
except PersistenceBacklogError as e:
    if "does not match the checked source" in str(e):
        raise RuntimeError("stale receipt: provenance differs from this checkout/toolchain") from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: Reusing yesterday's receipt artifact in CI; developer measured locally then pulled upstream; toolchain auto-update between jobs.

Related errors


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