Hmbown/CodeWhale · error · PersistenceBacklogError

baseline provenance must identify a clean source tree

Error message

baseline provenance must identify a clean source tree

What it means

Provenance.source_dirty must be exactly false: the baseline must come from a clean source tree so it is reproducible from the recorded SHA. A dirty tree baseline is rejected because its measurements can't be attributed to any committed revision.

Solutions

  1. Commit or stash all changes, verify `git status` is clean, then re-run the measurement to produce a new baseline.
  2. Keep the baseline-generation workflow in a clean worktree.
  3. Do not hand-flip source_dirty to false; the SHA must actually match the measured tree.

Example fix

git status --porcelain  # ensure empty
python scripts/measure-persistence-backlog.py  # regenerate baseline with source_dirty: false
Defensive patterns

Strategy: validation

Validate before calling

import subprocess
if subprocess.run(["git", "status", "--porcelain"], capture_output=True, text=True).stdout.strip():
    raise ValueError("commit or stash changes before measuring the baseline")

Try / catch

try:
    measure_and_write_baseline()
except PersistenceBacklogError as e:
    if "clean source tree" in str(e): commit/stash, then re-measure

Prevention

When it happens

Trigger: `compare` with provenance.source_dirty == true (or any value other than literal false), i.e. the baseline was measured with uncommitted changes present.

Common situations: Generating the baseline while local edits/WIP files are present, forgetting to commit before running the measure script.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/c1d8863bd41d6942. Report an issue: GitHub.

Appendix: source

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

    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):
        if baseline_receipt[field] != baseline[field]:
            raise PersistenceBacklogError(

View on GitHub (pinned to 433685b202)