{"record":{"id":"1ae72b2cf40de704","repo":"Hmbown/CodeWhale","slug":"accepted-requests-must-equal-requests-attempted-sender","errorCode":null,"errorMessage":"accepted_requests must equal requests_attempted; sender rejection is not backlog improvement","messagePattern":"accepted_requests must equal requests_attempted; sender rejection is not backlog improvement","errorType":"validation","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":186,"sourceCode":"            \"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:\n        raise PersistenceBacklogError(\n            \"the paused channel must retain the newest request and its payload\"\n        )\n    minimum_payload_bytes = retained * FIXTURE[\"content_bytes_per_request\"]\n    if receipt[\"estimated_retained_payload_bytes\"] < minimum_payload_bytes:\n        raise PersistenceBacklogError(\n            \"estimated_retained_payload_bytes is smaller than the frozen retained content\"\n        )","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L168-L204","documentation":"validate_receipt enforces that accepted_requests equals requests_attempted in a persistence-backlog receipt. The frozen fixture sends 128 requests into a paused channel, so every request must be accepted by the sender; a mismatch means the sender dropped or rejected requests, which would fake a smaller backlog without actually reducing retained memory. The check guards against measurement results that 'improve' the backlog by shedding work instead of buffering it.","triggerScenarios":"Raised by validate_receipt (invoked from validate_baseline_receipt and compare) when receipt['accepted_requests'] != receipt['requests_attempted'], i.e. the measurement harness reports fewer accepted than attempted requests.","commonSituations":"A modified measure-persistence-backlog.py that aborts sends on backpressure; a hand-edited or partially regenerated baseline receipt; a fixture change that alters requests_attempted without resyncing accepted_requests.","solutions":["Regenerate the receipt with the unmodified scripts/measure-persistence-backlog.py so every attempted request is accepted.","If running with --receipt, re-check that the receipt file was produced by the current measurement script, not edited by hand.","Fix the sending harness so it never drops requests (retries or blocking enqueue) before re-measuring."],"exampleFix":"// before\nreceipt[\"accepted_requests\"] = 127  # hand-adjusted to look smaller\n// after\n# regenerate via: python scripts/measure-persistence-backlog.py\nassert receipt[\"accepted_requests\"] == receipt[\"requests_attempted\"] == 128","handlingStrategy":"validation","validationCode":"def receipt_counts_consistent(receipt):\n    return (\n        isinstance(receipt.get(\"accepted_requests\"), int)\n        and isinstance(receipt.get(\"requests_attempted\"), int)\n        and receipt[\"accepted_requests\"] == receipt[\"requests_attempted\"]\n    )","typeGuard":"def is_non_negative_int(v):\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":"try:\n    compare(receipt, budget)\nexcept PersistenceBacklogError as e:\n    print(f\"[persistence-backlog-budget] ERROR: {e}\", file=sys.stderr)\n    sys.exit(2)","preventionTips":["Always generate receipts with scripts/measure-persistence-backlog.py, never by hand.","Assert accepted == attempted in the harness immediately after the send loop.","Keep the fixture's requests_attempted and the sender's behavior in lockstep."],"tags":["measurement","validation","backpressure","python"],"backgroundTag":"invalid-argument-value","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"}