Hmbown/CodeWhale · error · PersistenceBacklogError
baseline provenance needs an exact source SHA
Error message
baseline provenance needs an exact source SHA
What it means
The baseline's provenance.source_sha must be a full 40-character lowercase hex git commit SHA matching SOURCE_SHA_PATTERN. This pins the baseline to an exact source revision; anything else (short SHA, dirty tag, description) is rejected.
Solutions
- Record the full `git rev-parse HEAD` output (40 hex chars) as source_sha.
- Regenerate the baseline with the measure script so it captures the SHA itself.
- Commit the working tree first if needed, then regenerate so the recorded SHA exists.
Example fix
// before "source_sha": "abc123" // after "source_sha": "0123456789abcdef0123456789abcdef01234567"
Defensive patterns
Strategy: validation
Validate before calling
import re
SHA = re.compile(r"[0-9a-f]{40}")
sha = budget.get("baseline_observation", {}).get("provenance", {}).get("source_sha", "")
if not SHA.fullmatch(sha):
raise ValueError("source_sha must be a full 40-char hex SHA") Type guard
def has_full_sha(p: dict) -> bool:
return bool(re.fullmatch(r"[0-9a-f]{40}", p.get("source_sha", ""))) Try / catch
try:
compare(budget, baseline_receipt)
except PersistenceBacklogError as e:
if "exact source SHA" in str(e): re-record `git rev-parse HEAD` and regenerate Prevention
- Always use `git rev-parse HEAD`, never abbreviated hashes.
- Generate baselines from committed, non-shallow clones.
When it happens
Trigger: `compare` with provenance.source_sha that is missing, non-string, a short/abbreviated SHA, or contains uppercase or non-hex characters.
Common situations: Hand-written source_sha, a baseline generated from a shallow/partial clone producing an abbreviated hash, or an old baseline from a different repository state.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- baseline provenance must identify a clean source tree
- baseline_observation needs provenance
- baseline provenance build profile/sample count changed
- baseline provenance needs
- baseline provenance platform must be macos
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/ad2ee2bac2c8ec23.
Report an issue: GitHub.
Appendix: 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 433685b202)