Hmbown/CodeWhale · error · PersistenceBacklogError

rss_after_delta_bytes is inconsistent

Error message

rss_after_delta_bytes is inconsistent

What it means

This error comes from validate_receipt in scripts/check-persistence-backlog-budget.py when the receipt's rss_after_delta_bytes does not equal max(0, rss_after_bytes - rss_before_bytes). The script requires RSS delta fields to be exactly the derived, non-negative difference between the recorded absolute RSS samples, so hand-edited or partially recomputed receipts fail this consistency invariant. It only fires on the macOS lane where rss_supported is true.

Solutions

  1. Recompute rss_after_delta_bytes as max(0, receipt['rss_after_bytes'] - receipt['rss_before_bytes']) and set it in the receipt
  2. Re-run the measurement (scripts/check-persistence-backlog-budget.py without --receipt) to regenerate a self-consistent receipt
  3. If hand-editing a baseline receipt, update rss_after_bytes and the delta together, never one alone

Example fix

// before
"rss_before_bytes": 1000, "rss_after_bytes": 1200, "rss_after_delta_bytes": 300
// after
"rss_before_bytes": 1000, "rss_after_bytes": 1200, "rss_after_delta_bytes": 200
Defensive patterns

Strategy: validation

Validate before calling

def rss_after_delta_ok(receipt):
    return receipt.get("rss_after_delta_bytes") == max(0, receipt["rss_after_bytes"] - receipt["rss_before_bytes"])

Type guard

def has_consistent_rss_deltas(r):
    return isinstance(r.get("rss_supported"), bool) and (
        not r["rss_supported"] or
        (r["rss_during_delta_bytes"] == max(0, r["rss_during_bytes"] - r["rss_before_bytes"])
         and r["rss_after_delta_bytes"] == max(0, r["rss_after_bytes"] - r["rss_before_bytes"])))

Try / catch

try:
    compare(receipt, budget)
except PersistenceBacklogError as e:
    if "rss_after_delta_bytes is inconsistent" in str(e):
        receipt["rss_after_delta_bytes"] = max(0, receipt["rss_after_bytes"] - receipt["rss_before_bytes"])
    raise

Prevention

When it happens

Trigger: validate_receipt (called via validate_baseline_receipt or compare) processes a receipt with rss_supported=true whose rss_after_delta_bytes was edited independently of the rss_after_bytes/rss_before_bytes sample pair, or the measurement script wrote stale delta values after re-sampling.

Common situations: Manually editing persistence-backlog-baseline-receipt.json or a fresh measurement receipt to tweak numbers; merging receipts from different runs so deltas no longer match samples; re-running measurement with different RSS samples but copying old deltas.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

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

    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"]
        if receipt["rss_during_delta_bytes"] != max(
            0, receipt["rss_during_bytes"] - before
        ):
            raise PersistenceBacklogError("rss_during_delta_bytes is inconsistent")
        if receipt["rss_after_delta_bytes"] != max(
            0, receipt["rss_after_bytes"] - before
        ):
            raise PersistenceBacklogError("rss_after_delta_bytes is inconsistent")
    elif any(receipt[field] is not None for field in rss_fields):
        raise PersistenceBacklogError("unsupported RSS fields must be null")


def validate_budget(budget: dict[str, Any]) -> None:
    if budget.get("document_kind") != BUDGET_KIND:
        raise PersistenceBacklogError(f"budget document_kind must be {BUDGET_KIND}")
    if budget.get("schema_version") != SCHEMA_VERSION:
        raise PersistenceBacklogError("budget schema_version changed")
    fixture = budget.get("fixture")
    if not isinstance(fixture, dict) or set(fixture) != set(FIXTURE):
        raise PersistenceBacklogError("budget fixture no longer matches the frozen workload")
    for field, expected in FIXTURE.items():
        if type(fixture[field]) is not type(expected) or fixture[field] != expected:
            raise PersistenceBacklogError(
                f"budget fixture.{field} must remain {expected!r}"
            )
    if budget.get("baseline_receipt") != BASELINE_RECEIPT_REFERENCE:

View on GitHub (pinned to 433685b202)