{"record":{"id":"fe8d148593ebd819","repo":"Hmbown/CodeWhale","slug":"baseline-provenance-needs-field","errorCode":null,"errorMessage":"baseline provenance needs {field}","messagePattern":"baseline provenance needs (.+?)","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":311,"sourceCode":"        )\n    if baseline_payload < baseline_retained * FIXTURE[\"content_bytes_per_request\"]:\n        raise PersistenceBacklogError(\n            \"baseline_observation payload is smaller than frozen retained content\"\n        )\n    provenance = baseline.get(\"provenance\")\n    if not isinstance(provenance, dict):\n        raise PersistenceBacklogError(\"baseline_observation needs provenance\")\n    if provenance.get(\"platform\") != \"macos\":\n        raise PersistenceBacklogError(\"baseline provenance platform must be macos\")\n    if not isinstance(provenance.get(\"source_sha\"), str) or not SOURCE_SHA_PATTERN.fullmatch(\n        provenance[\"source_sha\"]\n    ):\n        raise PersistenceBacklogError(\"baseline provenance needs an exact source SHA\")\n    if provenance.get(\"source_dirty\") is not False:\n        raise PersistenceBacklogError(\"baseline provenance must identify a clean source tree\")\n    for field, prefix in ((\"rustc_version\", \"rustc \"), (\"cargo_version\", \"cargo \")):\n        if not isinstance(provenance.get(field), str) or not provenance[field].startswith(prefix):\n            raise PersistenceBacklogError(f\"baseline provenance needs {field}\")\n    if provenance.get(\"build_profile\") != \"test\" or not (\n        type(provenance.get(\"sample_count\")) is int\n        and provenance[\"sample_count\"] == 1\n    ):\n        raise PersistenceBacklogError(\"baseline provenance build profile/sample count changed\")\n\n\ndef validate_baseline_receipt(\n    budget: dict[str, Any], baseline_receipt: dict[str, Any]\n) -> None:\n    validate_receipt(baseline_receipt, require_clean_source=True)\n    baseline = budget[\"baseline_observation\"]\n    for field in (\"accepted_requests\", \"applied_version\", *CEILING_FIELDS):\n        if baseline_receipt[field] != baseline[field]:\n            raise PersistenceBacklogError(\n                f\"baseline receipt {field} does not match baseline_observation\"\n            )\n    provenance = baseline[\"provenance\"]","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L293-L329","documentation":"Raised by validate_budget() for rustc_version or cargo_version when provenance[field] is not a string starting with 'rustc ' or 'cargo ' respectively ({field} interpolates the offending field name). The full command output (e.g. 'rustc 1.97.0 (2d8144b78 2026-07-07)') is stored so the baseline toolchain is fully identifiable; a bare '1.97.0', a non-string, or swapped fields fails the prefix check.","triggerScenarios":"provenance.rustc_version = '1.97.0' (no 'rustc ' prefix), the two fields swapped, null/number values, or custom wrapper output without the expected prefix.","commonSituations":"Hand-writing provenance and trimming the version output; fields swapped during templating; toolchain wrappers printing custom version strings.","solutions":["Store the exact stdout of rustc --version and cargo --version","Regenerate the baseline receipt so toolchain fields are captured verbatim","Keep the 'rustc ' / 'cargo ' prefixes - the checker matches on them"],"exampleFix":"// before (budget.json)\n\"provenance\": { \"rustc_version\": \"1.97.0\", \"cargo_version\": \"1.97.0\" }\n\n// after: verbatim tool output\n\"provenance\": {\n  \"rustc_version\": \"rustc 1.97.0 (2d8144b78 2026-07-07)\",\n  \"cargo_version\": \"cargo 1.97.0 (c980f4866 2026-06-30)\" }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"from typing import TypeGuard\n\ndef has_toolchain_versions(provenance: object) -> TypeGuard[dict]:\n    if not isinstance(provenance, dict):\n        return False\n    rustc = provenance.get(\"rustc_version\")\n    cargo = provenance.get(\"cargo_version\")\n    return (isinstance(rustc, str) and rustc.startswith(\"rustc \")\n            and isinstance(cargo, str) and cargo.startswith(\"cargo \"))","tryCatchPattern":null,"preventionTips":["Regenerate baselines via the measure script so provenance is captured verbatim from git/rustc/cargo","Re-baseline only on macOS with a clean tree (git status --porcelain empty)","Never hand-write provenance fields; copy them from scripts/persistence-backlog-baseline-receipt.json"],"tags":["json","provenance","toolchain","python","ci-gate"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}