Hmbown/CodeWhale · error · PersistenceBacklogError

final_version_applied must be true

Error message

final_version_applied must be true

What it means

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.

Source

Thrown at scripts/check-persistence-backlog-budget.py:211

        raise PersistenceBacklogError("retained_queued_requests exceeds accepted_requests")
    for field in ("estimated_retained_payload_bytes", "enqueue_elapsed_ns"):
        non_negative_integer(receipt[field], field)
    if retained == 0 or receipt["estimated_retained_payload_bytes"] == 0:
        raise PersistenceBacklogError(
            "the paused channel must retain the newest request and its payload"
        )
    minimum_payload_bytes = retained * FIXTURE["content_bytes_per_request"]
    if receipt["estimated_retained_payload_bytes"] < minimum_payload_bytes:
        raise PersistenceBacklogError(
            "estimated_retained_payload_bytes is smaller than the frozen retained content"
        )
    applied = non_negative_integer(
        receipt["applied_version"], "applied_version"
    )
    if applied != FIXTURE["expected_applied_version"]:
        raise PersistenceBacklogError("applied_version is not the final sent version")
    if receipt["final_version_applied"] is not True:
        raise PersistenceBacklogError("final_version_applied must be true")

    limitations = receipt["limitations"]
    if not isinstance(limitations, list) or not limitations or not all(
        isinstance(item, str) and item for item in limitations
    ):
        raise PersistenceBacklogError("limitations must be a non-empty string array")

    if not isinstance(receipt["rss_supported"], bool):
        raise PersistenceBacklogError("rss_supported must be boolean")
    if receipt["rss_supported"] != (platform == "macos"):
        raise PersistenceBacklogError(
            "rss_supported must be true exactly on the macOS measurement lane"
        )
    rss_fields = RSS_SAMPLE_FIELDS + RSS_DELTA_FIELDS
    if receipt["rss_supported"]:
        for field in rss_fields:
            non_negative_integer(receipt[field], field)
        before = receipt["rss_before_bytes"]

View on GitHub (pinned to 8880682c63)

Solutions

  1. Fix the Rust writer to emit a real JSON boolean derived from applied_version == expected.
  2. Resolve the underlying sequencing issue if the flag is false because version 127 was never applied.
  3. Regenerate the receipt.

Example fix

// receipt (before)
"final_version_applied": false
// receipt (after)
"final_version_applied": true
Defensive patterns

Strategy: type-guard

Validate before calling

if receipt.get("final_version_applied") is not True:
    sys.exit("final_version_applied must be literal true; derive it from applied_version == 127")

Type guard

def is_literal_true(value) -> bool:
    return value is True

Try / catch

try:
    validate_receipt(receipt)
except PersistenceBacklogError as e:
    if "final_version_applied" in str(e):
        raise RuntimeError("flag/version bookkeeping diverged; fix the emitter") from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: Serializer coerced the bool; flag and version bookkeeping diverged after a refactor; hand-edited receipt.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/af7fb1e00aef5e6f. Report an issue: GitHub.