{"record":{"id":"c0d242dbc1a0db3b","repo":"Hmbown/CodeWhale","slug":"budget-document-kind-must-be-budget-kind","errorCode":null,"errorMessage":"budget document_kind must be {BUDGET_KIND}","messagePattern":"budget document_kind must be (.+?)","errorType":"console","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":244,"sourceCode":"    if receipt[\"rss_supported\"]:\n        for field in rss_fields:\n            non_negative_integer(receipt[field], field)\n        before = receipt[\"rss_before_bytes\"]\n        if receipt[\"rss_during_delta_bytes\"] != max(\n            0, receipt[\"rss_during_bytes\"] - before\n        ):\n            raise PersistenceBacklogError(\"rss_during_delta_bytes is inconsistent\")\n        if receipt[\"rss_after_delta_bytes\"] != max(\n            0, receipt[\"rss_after_bytes\"] - before\n        ):\n            raise PersistenceBacklogError(\"rss_after_delta_bytes is inconsistent\")\n    elif any(receipt[field] is not None for field in rss_fields):\n        raise PersistenceBacklogError(\"unsupported RSS fields must be null\")\n\n\ndef validate_budget(budget: dict[str, Any]) -> None:\n    if budget.get(\"document_kind\") != BUDGET_KIND:\n        raise PersistenceBacklogError(f\"budget document_kind must be {BUDGET_KIND}\")\n    if budget.get(\"schema_version\") != SCHEMA_VERSION:\n        raise PersistenceBacklogError(\"budget schema_version changed\")\n    fixture = budget.get(\"fixture\")\n    if not isinstance(fixture, dict) or set(fixture) != set(FIXTURE):\n        raise PersistenceBacklogError(\"budget fixture no longer matches the frozen workload\")\n    for field, expected in FIXTURE.items():\n        if type(fixture[field]) is not type(expected) or fixture[field] != expected:\n            raise PersistenceBacklogError(\n                f\"budget fixture.{field} must remain {expected!r}\"\n            )\n    if budget.get(\"baseline_receipt\") != BASELINE_RECEIPT_REFERENCE:\n        raise PersistenceBacklogError(\"budget baseline_receipt path changed\")\n    ceilings = budget.get(\"ceilings\")\n    baseline = budget.get(\"baseline_observation\")\n    if not isinstance(ceilings, dict) or not isinstance(baseline, dict):\n        raise PersistenceBacklogError(\"budget needs ceilings and baseline_observation objects\")\n    for field in CEILING_FIELDS:\n        ceiling = non_negative_integer(ceilings.get(field), f\"ceilings.{field}\")","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L226-L262","documentation":"validate_budget rejects a budget JSON whose document_kind is not exactly \"codewhale.persistence_backlog_budget\" (the BUDGET_KIND constant). The kind field identifies the JSON document type; the checker refuses any file at the budget path that is not a persistence backlog budget. This guards against pointing --budget at a receipt or unrelated JSON document.","triggerScenarios":"compare calls validate_budget on a budget dict loaded from the --budget path (default scripts/persistence-backlog-budget.json) whose document_kind is missing, misspelled, or set to another kind (e.g. a receipt's document_kind).","commonSituations":"Passing a receipt file to --budget; renaming or re-keying document_kind while editing the budget; copying an old template before the kind identifier was introduced.","solutions":["Set \"document_kind\": \"codewhale.persistence_backlog_budget\" in the budget JSON","Verify you passed the budget file, not a receipt, to --budget","Regenerate or restore the budget file from version control if it was corrupted"],"exampleFix":"// before\n{ \"document_kind\": \"codewhale.persistence_backlog_receipt\", ... }\n// after\n{ \"document_kind\": \"codewhale.persistence_backlog_budget\", ... }","handlingStrategy":"validation","validationCode":"budget = json.load(open(\"scripts/persistence-backlog-budget.json\"))\nassert budget.get(\"document_kind\") == \"codewhale.persistence_backlog_budget\", \"wrong document at budget path\"","typeGuard":"def is_budget(doc):\n    return isinstance(doc, dict) and doc.get(\"document_kind\") == \"codewhale.persistence_backlog_budget\"","tryCatchPattern":"try:\n    validate_budget(budget)\nexcept PersistenceBacklogError as e:\n    if \"document_kind must be\" in str(e):\n        print(\"check the --budget path: you may have passed a receipt file\")\n    raise","preventionTips":["Keep receipts and budgets in clearly named files and never swap their paths","Validate document_kind right after loading any JSON document","Use the default BUDGET_PATH instead of ad-hoc --budget overrides when possible"],"tags":["validation","budget","config"],"backgroundTag":"schema-validation-failed","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"}