{"record":{"id":"2c630e3723ef5290","repo":"Hmbown/CodeWhale","slug":"baseline-observation-retained-queued-requests-exce","errorCode":null,"errorMessage":"baseline_observation.retained_queued_requests exceeds accepted_requests","messagePattern":"baseline_observation\\.retained_queued_requests exceeds accepted_requests","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":291,"sourceCode":"    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\"\n    )\n    if baseline_applied != FIXTURE[\"expected_applied_version\"]:\n        raise PersistenceBacklogError(\n            \"baseline_observation.applied_version must be the final sent version\"\n        )\n    baseline_retained = baseline[\"retained_queued_requests\"]\n    baseline_payload = baseline[\"estimated_retained_payload_bytes\"]\n    if baseline_retained == 0 or baseline_payload == 0:\n        raise PersistenceBacklogError(\n            \"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 \")):","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L273-L309","documentation":"Raised by validate_budget() when baseline_observation.retained_queued_requests is greater than baseline_observation.accepted_requests (validated earlier as exactly 128). A queue cannot retain more requests than were accepted, so retained > accepted signals duplicated queue entries or corrupted counters.","triggerScenarios":"retained_queued_requests of 129+ alongside accepted_requests 128 - a hand-edit typo, or a real duplication bug where the persistence queue stores the same snapshot more than once.","commonSituations":"Duplication regressions like the v0.9.5 journal repair (legacy messages plus the canonical journal double-counting retained work); hand-edit typos; counting applied plus queued requests as retained.","solutions":["If the value was hand-edited, correct retained_queued_requests to the observed value <= accepted_requests","If the real measurement shows duplication, fix the retention path so each request is retained once - do not raise accepted_requests instead","Add a regression test asserting retained <= accepted on receipts"],"exampleFix":"// before (budget.json)\n\"baseline_observation\": {\n  \"accepted_requests\": 128,\n  \"retained_queued_requests\": 256, ... }\n\n// after: deduplicated retention\n\"baseline_observation\": {\n  \"accepted_requests\": 128,\n  \"retained_queued_requests\": 128, ... }","handlingStrategy":"validation","validationCode":"def baseline_retained_bounded(budget: dict) -> bool:\n    b = budget.get(\"baseline_observation\", {})\n    return b.get(\"retained_queued_requests\", 0) <= b.get(\"accepted_requests\", 0)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Load budgets from the repo checkout (scripts/persistence-backlog-budget.json) instead of hand-maintained copies","Validate budget JSON with python -m json.tool and a key-set check before running the checker","Change FIXTURE/SCHEMA_VERSION in the checker only together with regenerating budget and baseline receipt in one commit"],"tags":["json","python","ci-gate","duplicate-detection","performance-budget"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}