Hmbown/CodeWhale · error · PersistenceBacklogError

baseline_observation needs provenance

Error message

baseline_observation needs provenance

What it means

Every baseline observation must carry a provenance object describing how it was produced. If baseline_observation.provenance is missing or not a dict, the checker cannot attest the baseline's origin and raises this error before any comparison runs.

Solutions

  1. Add a complete provenance object (platform, source_sha, source_dirty, rustc_version, cargo_version, build_profile, sample_count) to the baseline.
  2. Regenerate the baseline via the measure script, which emits provenance automatically.
  3. Remove stale pre-schema-v2 baselines and record a fresh one.

Example fix

// before
"baseline_observation": { "applied_version": 127, ... }
// after
"baseline_observation": { "applied_version": 127, ..., "provenance": { "platform": "macos", "source_sha": "...", "source_dirty": false, "rustc_version": "rustc 1.78.0", "cargo_version": "cargo 1.78.0", "build_profile": "test", "sample_count": 1 } }
Defensive patterns

Strategy: type-guard

Validate before calling

if not isinstance(budget.get("baseline_observation", {}).get("provenance"), dict):
    raise ValueError("baseline missing provenance object")

Type guard

def has_provenance(b: dict) -> bool:
    return isinstance(b.get("provenance"), dict)

Try / catch

try:
    compare(budget, baseline_receipt)
except PersistenceBacklogError as e:
    if "needs provenance" in str(e): regenerate_baseline_with_provenance()

Prevention

When it happens

Trigger: `compare` with a baseline_observation lacking the provenance key, or where provenance is null/list/string — typically a hand-built or trimmed budget JSON.

Common situations: Baselines copied from older schema versions (schema_version < 2) that had no provenance block, manual JSON pruning, or a merge that dropped the object.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

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

            "baseline_observation.applied_version must be the final sent version"
        )
    baseline_retained = baseline["retained_queued_requests"]
    baseline_payload = baseline["estimated_retained_payload_bytes"]
    if baseline_retained == 0 or baseline_payload == 0:
        raise PersistenceBacklogError(
            "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")

View on GitHub (pinned to 433685b202)