{"record":{"id":"af7fb1e00aef5e6f","repo":"Hmbown/CodeWhale","slug":"final-version-applied-must-be-true","errorCode":null,"errorMessage":"final_version_applied must be true","messagePattern":"final_version_applied must be true","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":211,"sourceCode":"        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:\n            non_negative_integer(receipt[field], field)\n        before = receipt[\"rss_before_bytes\"]","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L193-L229","documentation":"Raised in validate_receipt (scripts/check-persistence-backlog-budget.py:210-211) when receipt[\"final_version_applied\"] is not the literal JSON true. It is the boolean companion of the applied_version == 127 check and uses `is not True` so truthy look-alikes (1, \"true\") are also rejected.","triggerScenarios":"The emitter writing 1 or \"true\" instead of a boolean; the consumer genuinely not reaching the final version, leaving the flag false; the flag computed from a different condition than applied_version.","commonSituations":"Serializer coerced the bool; flag and version bookkeeping diverged after a refactor; hand-edited receipt.","solutions":["Fix the Rust writer to emit a real JSON boolean derived from applied_version == expected.","Resolve the underlying sequencing issue if the flag is false because version 127 was never applied.","Regenerate the receipt."],"exampleFix":"// receipt (before)\n\"final_version_applied\": false\n// receipt (after)\n\"final_version_applied\": true","handlingStrategy":"type-guard","validationCode":"if receipt.get(\"final_version_applied\") is not True:\n    sys.exit(\"final_version_applied must be literal true; derive it from applied_version == 127\")","typeGuard":"def is_literal_true(value) -> bool:\n    return value is True","tryCatchPattern":"try:\n    validate_receipt(receipt)\nexcept PersistenceBacklogError as e:\n    if \"final_version_applied\" in str(e):\n        raise RuntimeError(\"flag/version bookkeeping diverged; fix the emitter\") from e\n    raise","preventionTips":["Compute final_version_applied as applied_version == expected_applied_version in the emitter.","Serialize booleans natively; never template JSON strings.","Keep the flag and applied_version updates in the same code path."],"tags":["measurement","validation","invariants"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}