{"record":{"id":"c8de3e97ab7b440b","repo":"Hmbown/CodeWhale","slug":"budget-needs-ceilings-and-baseline-observation-objects","errorCode":null,"errorMessage":"budget needs ceilings and baseline_observation objects","messagePattern":"budget needs ceilings and baseline_observation objects","errorType":"console","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":260,"sourceCode":"def 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}\")\n        observed = non_negative_integer(\n            baseline.get(field), f\"baseline_observation.{field}\"\n        )\n        if observed > ceiling:\n            raise PersistenceBacklogError(\n                f\"baseline_observation.{field} exceeds its ceiling\"\n            )\n    baseline_accepted = non_negative_integer(\n        baseline.get(\"accepted_requests\"), \"baseline_observation.accepted_requests\"\n    )\n    if baseline_accepted != FIXTURE[\"requests_attempted\"]:\n        raise PersistenceBacklogError(\n            \"baseline_observation.accepted_requests must equal requests_attempted\"\n        )\n    baseline_applied = non_negative_integer(\n        baseline.get(\"applied_version\"), \"baseline_observation.applied_version\"","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L242-L278","documentation":"validate_budget requires both budget.ceilings and budget.baseline_observation to be JSON objects (dicts). These two sections hold the one-way ceiling fields and the recorded baseline numbers the budget is built from. If either is missing, null, or a non-object type, the budget cannot be validated or compared and this error is raised.","triggerScenarios":"compare calls validate_budget and budget['ceilings'] or budget['baseline_observation'] is absent, null, a list, or some other non-dict value.","commonSituations":"A partially written or truncated budget file; an edit that replaced ceilings with a flat array; a schema-version-1 budget whose sections were named differently; merging JSON files and dropping one section.","solutions":["Add/restore both \"ceilings\" and \"baseline_observation\" as JSON objects in the budget","Regenerate the budget from the measurement pipeline to get a complete document","Validate the JSON structure with a quick script before running the checker"],"exampleFix":"// before\n{ \"ceilings\": [1, 2], \"baseline_observation\": null }\n// after\n{ \"ceilings\": { \"retained_queued_requests\": 1 }, \"baseline_observation\": { \"retained_queued_requests\": 1 } }","handlingStrategy":"validation","validationCode":"budget = json.load(open(\"scripts/persistence-backlog-budget.json\"))\nassert isinstance(budget.get(\"ceilings\"), dict) and isinstance(budget.get(\"baseline_observation\"), dict), \"budget needs ceilings and baseline_observation objects\"","typeGuard":"def has_required_sections(doc):\n    return isinstance(doc, dict) and isinstance(doc.get(\"ceilings\"), dict) and isinstance(doc.get(\"baseline_observation\"), dict)","tryCatchPattern":"try:\n    validate_budget(budget)\nexcept PersistenceBacklogError as e:\n    if \"needs ceilings and baseline_observation\" in str(e):\n        print(\"budget file is truncated or malformed; regenerate it\")\n    raise","preventionTips":["Validate budget JSON structure after every edit or merge","Regenerate the budget wholesale rather than splicing sections by hand","Keep both sections present when migrating between schema versions"],"tags":["validation","budget","structure"],"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"}