Hmbown/CodeWhale · error · PersistenceBacklogError

rss_after_delta_bytes is inconsistent

Error message

rss_after_delta_bytes is inconsistent

What it means

Raised by validate_receipt() when a receipt with rss_supported=true records rss_after_delta_bytes that is not exactly max(0, rss_after_bytes - rss_before_bytes). As with the during-delta check, the three raw RSS samples are ground truth and the after-delta column must be the clamped difference between the after sample and the before sample. A mismatch means the receipt's delta column disagrees with its own samples.

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 8880682c63)

Solutions

  1. Recompute and write rss_after_delta_bytes = max(0, rss_after_bytes - rss_before_bytes) in the receipt
  2. Prefer regenerating the receipt entirely: python scripts/measure-persistence-backlog.py > receipt.json
  3. Fix the sampler if it derives the after delta from anything other than rss_before_bytes
  4. Re-run scripts/check-persistence-backlog-budget.py --receipt receipt.json to confirm

Example fix

// before (receipt.json)
"rss_before_bytes": 18923520,
"rss_after_bytes": 31784960,
"rss_after_delta_bytes": 9453568

// after: 31784960 - 18923520 = 12861440
"rss_before_bytes": 18923520,
"rss_after_bytes": 31784960,
"rss_after_delta_bytes": 12861440
Defensive patterns

Strategy: validation

Validate before calling

def rss_after_delta_consistent(receipt: dict) -> bool:
    if not receipt.get("rss_supported"):
        return receipt.get("rss_after_delta_bytes") is None
    return receipt["rss_after_delta_bytes"] == max(
        0, receipt["rss_after_bytes"] - receipt["rss_before_bytes"]
    )
# call before compare(receipt, budget)

Type guard

from typing import TypeGuard

def has_consistent_rss_deltas(r: dict) -> TypeGuard[dict]:
    before = r["rss_before_bytes"]
    return (r["rss_during_delta_bytes"] == max(0, r["rss_during_bytes"] - before)
            and r["rss_after_delta_bytes"] == max(0, r["rss_after_bytes"] - before))

Prevention

When it happens

Trigger: Calling compare()/validate_receipt() with rss_supported true and rss_after_delta_bytes != max(0, rss_after_bytes - rss_before_bytes) - e.g. delta left at the during value after a copy-paste, or recomputed against rss_during_bytes instead of rss_before_bytes.

Common situations: Copy-pasting the rss_during_delta_bytes value into rss_after_delta_bytes when hand-editing; sampler changes that compute the after delta against a different baseline sample; stale deltas not refreshed after re-sampling.

Related errors


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