{"record":{"id":"cf70fc0e18ddcf02","repo":"Hmbown/CodeWhale","slug":"applied-version-is-not-the-final-sent-version","errorCode":null,"errorMessage":"applied_version is not the final sent version","messagePattern":"applied_version is not the final sent version","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":209,"sourceCode":"    )\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        )\n    applied = non_negative_integer(\n        receipt[\"applied_version\"], \"applied_version\"\n    )\n    if applied != FIXTURE[\"expected_applied_version\"]:\n        raise PersistenceBacklogError(\"applied_version is not the final sent version\")\n    if receipt[\"final_version_applied\"] is not True:\n        raise PersistenceBacklogError(\"final_version_applied must be true\")\n\n    limitations = receipt[\"limitations\"]\n    if not isinstance(limitations, list) or not limitations or not all(\n        isinstance(item, str) and item for item in limitations\n    ):\n        raise PersistenceBacklogError(\"limitations must be a non-empty string array\")\n\n    if not isinstance(receipt[\"rss_supported\"], bool):\n        raise PersistenceBacklogError(\"rss_supported must be boolean\")\n    if receipt[\"rss_supported\"] != (platform == \"macos\"):\n        raise PersistenceBacklogError(\n            \"rss_supported must be true exactly on the macOS measurement lane\"\n        )\n    rss_fields = RSS_SAMPLE_FIELDS + RSS_DELTA_FIELDS\n    if receipt[\"rss_supported\"]:\n        for field in rss_fields:","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L191-L227","documentation":"Raised in validate_receipt (scripts/check-persistence-backlog-budget.py:205-209) when applied_version != 127 (FIXTURE expected_applied_version). With 128 requests (versions 0..127) sent, the consumer must have applied exactly the final sent version before pausing; any other value means the pause/apply sequencing drifted.","triggerScenarios":"The consumer applying one version fewer (126) or one more (128) before pausing; an off-by-one in version bookkeeping after an actor refactor; the consumer never applying anything (0).","commonSituations":"Refactoring apply/pause ordering in the persistence actor; version counters switched from 0-based to 1-based; test helper applying a fixed number of requests instead of all-but-the-pause-point.","solutions":["Fix the measurement test so the consumer applies through version 127 and then pauses.","Audit version indexing (0-based vs 1-based) in both sender and consumer.","Regenerate the receipt after the sequencing fix."],"exampleFix":"// receipt (before)\n\"applied_version\": 126\n// receipt (after)\n\"applied_version\": 127","handlingStrategy":"validation","validationCode":"if receipt[\"applied_version\"] != 127:\n    sys.exit(\"consumer did not apply through the final sent version; check pause/apply ordering\")","typeGuard":null,"tryCatchPattern":"try:\n    validate_receipt(receipt)\nexcept PersistenceBacklogError as e:\n    if \"final sent version\" in str(e):\n        raise RuntimeError(\"applied_version off (expected 127); audit version indexing\") from e\n    raise","preventionTips":["Keep version bookkeeping 0-based and consistent between sender and consumer.","Assert applied_version == requests_attempted - 1 inside the Rust test.","Review apply/pause ordering whenever the actor's loop is refactored."],"tags":["measurement","validation","invariants"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}