{"record":{"id":"ad2ee2bac2c8ec23","repo":"Hmbown/CodeWhale","slug":"baseline-provenance-needs-an-exact-source-sha","errorCode":null,"errorMessage":"baseline provenance needs an exact source SHA","messagePattern":"baseline provenance needs an exact source SHA","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":306,"sourceCode":"            \"baseline_observation must retain the final request and payload\"\n        )\n    if baseline_retained > baseline_accepted:\n        raise PersistenceBacklogError(\n            \"baseline_observation.retained_queued_requests exceeds accepted_requests\"\n        )\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):","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L288-L324","documentation":"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.","triggerScenarios":"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).","commonSituations":"Copying short SHAs from git log --oneline; tooling that uppercases hex digits; placeholder values left from templating; pasting with a trailing newline.","solutions":["Run git rev-parse HEAD at the clean baseline commit and use that full 40-character lowercase SHA","Verify first: python -c \"import re,sys;print(bool(re.fullmatch(sys.argv[1], r'[0-9a-f]{40}')))\" <sha>","Regenerate the baseline receipt, which records the SHA automatically via current_source_identity()"],"exampleFix":"// before (budget.json)\n\"provenance\": { \"source_sha\": \"2d4a9cb\" }\n\n// after: full lowercase 40-hex SHA\n\"provenance\": { \"source_sha\": \"2d4a9cb58c5c22ac361ab221bda1243a0e4349fb\" }","handlingStrategy":"validation","validationCode":"import re\n\nSHA_RE = re.compile(r\"[0-9a-f]{40}\")\n\ndef provenance_sha_ok(budget: dict) -> bool:\n    sha = budget.get(\"baseline_observation\", {}).get(\"provenance\", {}).get(\"source_sha\")\n    return isinstance(sha, str) and SHA_RE.fullmatch(sha) is not None","typeGuard":null,"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","git","python","ci-gate"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}