{"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":"console","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/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L288-L324","documentation":"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.","triggerScenarios":"`compare` with provenance.source_sha that is missing, non-string, a short/abbreviated SHA, or contains uppercase or non-hex characters.","commonSituations":"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.","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."],"exampleFix":"// before\n\"source_sha\": \"abc123\"\n// after\n\"source_sha\": \"0123456789abcdef0123456789abcdef01234567\"","handlingStrategy":"validation","validationCode":"import re\nSHA = re.compile(r\"[0-9a-f]{40}\")\nsha = budget.get(\"baseline_observation\", {}).get(\"provenance\", {}).get(\"source_sha\", \"\")\nif not SHA.fullmatch(sha):\n    raise ValueError(\"source_sha must be a full 40-char hex SHA\")","typeGuard":"def has_full_sha(p: dict) -> bool:\n    return bool(re.fullmatch(r\"[0-9a-f]{40}\", p.get(\"source_sha\", \"\")))","tryCatchPattern":"try:\n    compare(budget, baseline_receipt)\nexcept PersistenceBacklogError as e:\n    if \"exact source SHA\" in str(e): re-record `git rev-parse HEAD` and regenerate","preventionTips":["Always use `git rev-parse HEAD`, never abbreviated hashes.","Generate baselines from committed, non-shallow clones."],"tags":["python","validation","provenance","git"],"backgroundTag":"invalid-identifier-format","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}