Hmbown/CodeWhale · error · PersistenceBacklogError

baseline provenance needs an exact source SHA

Error message

baseline provenance needs an exact source SHA

What it means

Raised by validate_budget() when provenance.source_sha is not a string that fullmatches the 40-character lowercase-hex pattern [0-9a-f]{40} (SOURCE_SHA_PATTERN). The baseline must be traceable to one exact commit; abbreviated SHAs, uppercase hex, or placeholder strings break reproducibility.

Source

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

            "baseline_observation must retain the final request and payload"
        )
    if baseline_retained > baseline_accepted:
        raise PersistenceBacklogError(
            "baseline_observation.retained_queued_requests exceeds accepted_requests"
        )
    if baseline_payload < baseline_retained * FIXTURE["content_bytes_per_request"]:
        raise PersistenceBacklogError(
            "baseline_observation payload is smaller than frozen retained content"
        )
    provenance = baseline.get("provenance")
    if not isinstance(provenance, dict):
        raise PersistenceBacklogError("baseline_observation needs provenance")
    if provenance.get("platform") != "macos":
        raise PersistenceBacklogError("baseline provenance platform must be macos")
    if not isinstance(provenance.get("source_sha"), str) or not SOURCE_SHA_PATTERN.fullmatch(
        provenance["source_sha"]
    ):
        raise PersistenceBacklogError("baseline provenance needs an exact source SHA")
    if provenance.get("source_dirty") is not False:
        raise PersistenceBacklogError("baseline provenance must identify a clean source tree")
    for field, prefix in (("rustc_version", "rustc "), ("cargo_version", "cargo ")):
        if not isinstance(provenance.get(field), str) or not provenance[field].startswith(prefix):
            raise PersistenceBacklogError(f"baseline provenance needs {field}")
    if provenance.get("build_profile") != "test" or not (
        type(provenance.get("sample_count")) is int
        and provenance["sample_count"] == 1
    ):
        raise PersistenceBacklogError("baseline provenance build profile/sample count changed")


def validate_baseline_receipt(
    budget: dict[str, Any], baseline_receipt: dict[str, Any]
) -> None:
    validate_receipt(baseline_receipt, require_clean_source=True)
    baseline = budget["baseline_observation"]
    for field in ("accepted_requests", "applied_version", *CEILING_FIELDS):

View on GitHub (pinned to 8880682c63)

Solutions

  1. Run git rev-parse HEAD at the clean baseline commit and use that full 40-character lowercase SHA
  2. Verify first: python -c "import re,sys;print(bool(re.fullmatch(sys.argv[1], r'[0-9a-f]{40}')))" <sha>
  3. Regenerate the baseline receipt, which records the SHA automatically via current_source_identity()

Example fix

// before (budget.json)
"provenance": { "source_sha": "2d4a9cb" }

// after: full lowercase 40-hex SHA
"provenance": { "source_sha": "2d4a9cb58c5c22ac361ab221bda1243a0e4349fb" }
Defensive patterns

Strategy: validation

Validate before calling

import re

SHA_RE = re.compile(r"[0-9a-f]{40}")

def provenance_sha_ok(budget: dict) -> bool:
    sha = budget.get("baseline_observation", {}).get("provenance", {}).get("source_sha")
    return isinstance(sha, str) and SHA_RE.fullmatch(sha) is not None

Prevention

When it happens

Trigger: source_sha holding a 7-character short SHA ('2d4a9cb'), an uppercase SHA, 'unknown', 'HEAD', a non-string value, or a SHA with surrounding whitespace (fullmatch leaves no room).

Common situations: Copying short SHAs from git log --oneline; tooling that uppercases hex digits; placeholder values left from templating; pasting with a trailing newline.

Related errors


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