Hmbown/CodeWhale · error · PersistenceBacklogError

retained_queued_requests exceeds accepted_requests

Error message

retained_queued_requests exceeds accepted_requests

What it means

validate_receipt checks that retained_queued_requests never exceeds accepted_requests: you cannot retain more queued requests than were accepted into the channel. This is a logical-consistency invariant on the receipt produced by the paused-channel measurement; a larger retained count implies corrupted or fabricated measurement output.

Solutions

  1. Regenerate the receipt with the current measurement script so retained_queued_requests is measured, not asserted.
  2. Verify retained_queued_requests counts distinct queued requests only (no double counting of the final applied request).
  3. If the baseline receipt was edited, restore scripts/persistence-backlog-baseline-receipt.json from a clean measurement run.

Example fix

// before
{"accepted_requests": 128, "retained_queued_requests": 129}
// after
{"accepted_requests": 128, "retained_queued_requests": 1}  # from a real run
Defensive patterns

Strategy: validation

Validate before calling

def retained_within_accepted(receipt):
    return 0 <= receipt.get("retained_queued_requests", -1) <= receipt.get("accepted_requests", 0)

Type guard

def is_non_negative_int(v):
    return isinstance(v, int) and not isinstance(v, bool) and v >= 0

Try / catch

try:
    validate_receipt(receipt)
except PersistenceBacklogError as e:
    print(f"receipt inconsistent: {e}", file=sys.stderr)
    sys.exit(2)

Prevention

When it happens

Trigger: Raised by validate_receipt when receipt['retained_queued_requests'] > receipt['accepted_requests'], from validate_baseline_receipt or compare.

Common situations: Hand-edited receipts where retained was increased for a tighter baseline but accepted was not; a buggy estimator that counts requests twice; schema drift between the measuring script and the checker.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/f2aed7a799a6539d. Report an issue: GitHub.

Appendix: source

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

                    f"receipt {field} does not match the checked source"
                )
    if require_clean_source and receipt["source_dirty"]:
        raise PersistenceBacklogError("persistence measurement source tree is dirty")
    platform = receipt["platform"]
    if not isinstance(platform, str) or platform not in SUPPORTED_PLATFORMS:
        raise PersistenceBacklogError("receipt platform is unsupported")

    attempted = non_negative_integer(receipt["requests_attempted"], "requests_attempted")
    accepted = non_negative_integer(receipt["accepted_requests"], "accepted_requests")
    if accepted != attempted:
        raise PersistenceBacklogError(
            "accepted_requests must equal requests_attempted; sender rejection is not backlog improvement"
        )
    retained = non_negative_integer(
        receipt["retained_queued_requests"], "retained_queued_requests"
    )
    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")

View on GitHub (pinned to 433685b202)