{"record":{"id":"296882440a24ab0f","repo":"Hmbown/CodeWhale","slug":"persistence-measurement-source-tree-is-dirty","errorCode":null,"errorMessage":"persistence measurement source tree is dirty","messagePattern":"persistence measurement source tree is dirty","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":178,"sourceCode":"        if not isinstance(receipt[field], str) or not receipt[field].startswith(prefix):\n            raise PersistenceBacklogError(f\"receipt {field} must be a version string\")\n    validate_frozen_field(\"build_profile\", receipt[\"build_profile\"], \"test\")\n    validate_frozen_field(\"sample_count\", receipt[\"sample_count\"], 1)\n    if expected_source is not None:\n        for field in (\n            \"source_sha\",\n            \"source_dirty\",\n            \"rustc_version\",\n            \"cargo_version\",\n            \"build_profile\",\n            \"sample_count\",\n        ):\n            if receipt[field] != expected_source[field]:\n                raise PersistenceBacklogError(\n                    f\"receipt {field} does not match the checked source\"\n                )\n    if require_clean_source and receipt[\"source_dirty\"]:\n        raise PersistenceBacklogError(\"persistence measurement source tree is dirty\")\n    platform = receipt[\"platform\"]\n    if not isinstance(platform, str) or platform not in SUPPORTED_PLATFORMS:\n        raise PersistenceBacklogError(\"receipt platform is unsupported\")\n\n    attempted = non_negative_integer(receipt[\"requests_attempted\"], \"requests_attempted\")\n    accepted = non_negative_integer(receipt[\"accepted_requests\"], \"accepted_requests\")\n    if accepted != attempted:\n        raise PersistenceBacklogError(\n            \"accepted_requests must equal requests_attempted; sender rejection is not backlog improvement\"\n        )\n    retained = non_negative_integer(\n        receipt[\"retained_queued_requests\"], \"retained_queued_requests\"\n    )\n    if retained > accepted:\n        raise PersistenceBacklogError(\"retained_queued_requests exceeds accepted_requests\")\n    for field in (\"estimated_retained_payload_bytes\", \"enqueue_elapsed_ns\"):\n        non_negative_integer(receipt[field], field)\n    if retained == 0 or receipt[\"estimated_retained_payload_bytes\"] == 0:","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L160-L196","documentation":"Raised in validate_receipt (scripts/check-persistence-backlog-budget.py:177-178) when require_clean_source is true (main() and validate_baseline_receipt both set it) and receipt.source_dirty is true. Backlog numbers from a dirty tree are untrustworthy because uncommitted code could change the measurement, so the gate demands a clean checkout.","triggerScenarios":"Running the measurement or baseline validation with uncommitted modifications or untracked files (git status --porcelain non-empty); the receipt recording source_dirty=true at capture time; a build artifact tracked as untracked noise.","commonSituations":"Local dev runs with work-in-progress changes; CI checkouts polluted by generated files; baseline receipt committed from a dirty tree.","solutions":["Commit or stash your work (git stash --include-untracked), then re-measure.","Add generated artifacts to .gitignore or remove them so `git status --porcelain` is empty.","If the committed baseline receipt is dirty, re-measure it from a clean checkout and commit the replacement."],"exampleFix":"# before\n git status --porcelain  # -> M src/lib.rs\n python scripts/check-persistence-backlog-budget.py\n# after\ngit stash --include-untracked && python scripts/check-persistence-backlog-budget.py","handlingStrategy":"validation","validationCode":"dirty = subprocess.run([\"git\", \"status\", \"porcelain\", \"--untracked-files=normal\"], cwd=ROOT, text=True, capture_output=True).stdout\nif dirty:\n    sys.exit(\"tree is dirty; commit or `git stash --include-untracked` before measuring\")","typeGuard":null,"tryCatchPattern":"try:\n    validate_receipt(receipt, require_clean_source=True)\nexcept PersistenceBacklogError as e:\n    if \"source tree is dirty\" in str(e):\n        print(\"clean the worktree and re-run scripts/measure-persistence-backlog.py\")\n    raise","preventionTips":["Run `git status --porcelain` and require empty output before every measurement.","gitignore generated artifacts so builds never dirty the tree.","Commit the baseline receipt only from a clean verified checkout."],"tags":["git","provenance","ci","hygiene"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}