Hmbown/CodeWhale · error · PersistenceBacklogError

applied_version is not the final sent version

Error message

applied_version is not the final sent version

What it means

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.

Source

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

    )
    if retained > accepted:
        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:

View on GitHub (pinned to 8880682c63)

Solutions

  1. Fix the measurement test so the consumer applies through version 127 and then pauses.
  2. Audit version indexing (0-based vs 1-based) in both sender and consumer.
  3. Regenerate the receipt after the sequencing fix.

Example fix

// receipt (before)
"applied_version": 126
// receipt (after)
"applied_version": 127
Defensive patterns

Strategy: validation

Validate before calling

if receipt["applied_version"] != 127:
    sys.exit("consumer did not apply through the final sent version; check pause/apply ordering")

Try / catch

try:
    validate_receipt(receipt)
except PersistenceBacklogError as e:
    if "final sent version" in str(e):
        raise RuntimeError("applied_version off (expected 127); audit version indexing") from e
    raise

Prevention

When it happens

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

Common situations: 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.

Related errors


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